baseport/syborg/webcamera/webcamera_driver.h
author Shimizu Satoshi <s_shimizu@isb.co.jp>
Mon, 18 Oct 2010 19:39:25 +0900
changeset 124 606eafc6d6a8
parent 52 0dfaca43d90e
permissions -rw-r--r--
Obtain an image of Webcamera from QEMU and add the Bitmap change display function.

/*
* Copyright (c) 2010 ISB.
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* ISB - initial contribution.
*
* Contributors:
*
* Description: USB driver for test
*
*/
#ifndef __deviceIF_H__
#define __deviceIF_H__

#include <e32cmn.h>
#ifndef __KERNEL_MODE__
#include <e32std.h>
#endif

#define BUFSIZE  (600*1024)
#define BITMAPBUFSIZE  (900 * 1024)

/**
User interface for 'WebcameraDevice'
Define of the RBusLogicalChannel that is used in the application
*/
class RWebcameraDevice : public RBusLogicalChannel
	{
public:
	/**
	Structure for holding driver capabilities information
	*/
	class TCaps
		{
	public:
		TVersion iVersion;
		};

	/**
	Structure for holding driver configuration data
	*/
	class TConfig
		{
	public:
		TInt iPddBufferSize;        /**< Size of the PDD's data buffer (not modifiable) */
		//RArray<TSize> iImageSizes /**< size the PDD support*/ //TODO:implement
		};
	typedef TPckgBuf<TConfig> TConfigBuf;

	/**
	Structure for holding driver chuck information
	*/
	class TChunkInfo
		{
	public:
		TInt iChunkHandle;
		TInt iChunkMaxSize;
		TInt iChunkRemSize;
		};
public:
	/**
	Opens a logical channel to the driver
	@return One of the system wide error codes.
	*/
	inline TInt Open();

	/**
	Gets the current configuration settings.

	@param aConfig A structure which will be filled with the configuration settings.

	@return KErrNone
	*/
	inline TInt GetConfig(TConfigBuf& aConfig);

	/**
	Sets the current configuration settings.

	@param aConfig The new configuration settings to be used.

	@return KErrInUse if there are outstanding data transfer requests.
			KErrArgument if any configuration values are invalid.
			KErrNone otherwise
	*/
	inline TInt SetConfig(const TConfigBuf& aConfig);

	/**
	Power on Camera Device.
	*/
	inline void PowerOn(TRequestStatus& aStatus);

	/**
	Power off Camera Device.
	*/
	inline void PowerOff(TRequestStatus& aStatus);

	/** 
	Init ViewFinder.
	*/
	inline TInt InitViewFinder();

	/**
	Request data from device.
	Only one send request may be pending at any time.

	@param aStatus	The request to be signalled when the data has been sent.
					The result value will be set to KErrNone on success;
					or set to one of the system wide error codes when an error occurs.
	@param aData	A descriptor containing the data to send.
	*/
	inline void StartViewFinder(TRequestStatus& aStatus,TInt& aChunkLen);

	/**
	Cancels a previous getdata request.
	*/
	inline void StartViewFinderCancel();

	/**
	Cancels a previous getdata request and notice device not to send data
	*/
	inline void StopViewFinder();

	/**
	Request data(Capture data) from device.
	Only one send request may be pending at any time.

	@param aStatus	The request to be signalled when the data has been sent.
					The result value will be set to KErrNone on success;
					or set to one of the system wide error codes when an error occurs.
	@param aData	A descriptor containing the data to send.
	*/
	inline void Capture(TRequestStatus& aStatus,TInt& aChunkLen);

	/**
	Cancels a previous getCapturedata request.
	*/
	inline void CaptureCancel();

	/**
	Returns the driver's name
	*/
	inline static const TDesC& Name();

	/**
	Returns the version number of the driver
	*/
	inline static TVersion VersionRequired();

	/**
	Opens a shared chunk on kernel side and makes a handle to the kernel chunk object
	@param aChunk		The object to which the handle will refer
	@param aChunkInfo	information of the created chunk.
	*/
#ifndef __KERNEL_MODE__
	inline TInt OpenSharedChunks(RChunk& aChunk,TChunkInfo& aChunkInfo);

	/**
	Closes ashared chunk
	@param aChunk 	The object to which the handle will refer
	@param aStatus	The request to be signalled when the data has been sent.
					The result value will be set to KErrNone on success;
					or set to one of the system wide error codes when an error occurs.
	*/
	inline TInt CloseSharedChunks(TRequestStatus& aStatus,RChunk& aChunk);
#endif

public:
	/**
	Enumeration of Control messages.
	*/
	enum TControl
		{
		EGetConfig,
		ESetConfig,
		EInitViewFinder,
		EOpenSharedChunck
		};
	/**
	Enumeration of Request messages.
	*/
	enum TRequest
		{
		EPowerOff,
		EPowerOn,
		EStart,
		ETransferData,
		ECapture,
		ECloseSharedChunck,
		ENumRequests,
		EAllRequests = (1<<ENumRequests)-1
		};

	// Kernel side LDD channel is a friend
	friend class DWebcameraLogicalChannel;
	};

// Inline functions
#include <webcamera_driver.inl>

#endif