baseport/syborg/webcamera/webcamera_pdd.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:
*
*/

#ifndef __devicePDD_H__
#define __devicePDD_H__

#ifndef __deviceIF_H__
#include <webcamera_driver.h>
#endif
#include <comm.h>
#include <e32hal.h>
#include "system.h"
#ifndef __deviceBASE_H
#include "webcamera_device.h"
#endif
#ifndef WEBCAMERA_UVC_H_
#include "webcamera_uvc.h"
#endif

const TInt KMinimumLddMajorVersion = 1;
const TInt KMinimumLddMinorVersion = 1;
const TInt KMinimumLddBuild = 0;
const TInt EIrqWebamera = 0xb;

class DWebcameraPddFactory : public DPhysicalDevice
	{
public:
	/**
	Constructor
	*/
	DWebcameraPddFactory();

	virtual TInt Install();
	virtual void GetCaps(TDes8 &aDes) const;
	virtual TInt Create(DBase*& aChannel, TInt aUnit, const TDesC8* anInfo, const TVersion &aVer);
	virtual TInt Validate(TInt aUnit, const TDesC8* anInfo, const TVersion &aVer);
	};

class DWebcameraDriver : public DWebcameraDriverBase
	{
public:
	/**
	Chunk index.
	*/
	enum TWebcameraIndex
		{
		EWEBCAMERAINDEXHAHEADERBUF,
		EWEBCAMERAINDEXADATABUF,
		EWEBCAMERAINDEXMAX
		};

	/**
	Constructor
	*/
	DWebcameraDriver();

	/**
	Destructor
	*/
	~DWebcameraDriver();

	/**
	Second stage constructor called by the kernel's device driver framework.
	This is called in the context of the user thread (client) which requested the creation of a Logical Channel
	The thread is in a critical section.

	@param aUnit The unit argument supplied by the client
	@param aInfo The info argument supplied by the client
	@return KErrNone if successful, otherwise one of the other system wide error codes.
	*/
	TInt DoCreate(TInt aUnit, const TDesC8* anInfo);

	/**
	Power on Camera Device.
	*/
	virtual TInt PowerOn(TAny* aHeaderPtr);

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

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

	@param  aBuffer physical adress
	@param aData   size of buffer.
	*/
	virtual TInt StartViewerFinder(TAny* aDataPtr, TInt aSize);

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

	@param  aMode stop mode
	*/
	virtual void Stop(TUSBStopMode aMode);

	/**
	Disconnect on Camera Device.
	*/
	virtual void Disconnect();

//	virtual void Caps(TDes8 &aCaps) const;

	/**
	Called by ISR to indicate that interrupt occurs.
	*/
	static void Isr(TAny* aPtr);

	/**
	Called from a Isr after the Peripheral has signalled that getting oneflame completed.
	*/
	void receivedatacallback();

	/**
	Chunk Create (Local use).
	*/
	TInt CreateChunk(TInt aSize, TWebcameraIndex aIndex);

	/**
	Chunk Close (Local use).
	*/
	void CloseChunk(TWebcameraIndex aIndex);

public:
	/**
	Enumeration of register types.
	*/
	enum
		{
		WEBCAMERA_REG_ID				= 0,
		WEBCAMERA_REG_INT_ENABLE		= 1,
		WEBCAMERA_REG_DATA_TYPE			= 2,
		WEBCAMERA_REG_DMA_ADDR			= 3,
		WEBCAMERA_REG_DMA_SIZE			= 4,
		WEBCAMERA_REG_DMA_INFO			= 5,
		WEBCAMERA_REG_DMA_INFOSIZE		= 6,
		WEBCAMERA_REG_DMA_CONNECT		= 7,
		WEBCAMERA_REG_DMA_DISCONNECT	= 8
		};

private:
	/**
	operation types.
	*/
	TInt iType;
	TWebcameraDataInfo	iDataInfo;
	DChunk*				iChunk[EWEBCAMERAINDEXMAX];				///< For Chunk process.
	DThread* 			iClient;
	TUint32				iPhysAddr[EWEBCAMERAINDEXMAX];
	TWebcameraUVC		iUvcData;
	};

#endif