Added web camera drivers and QEMU plug-in for obtaining and transferring dummy data.
authorMasaki Hosaka <hosaka@isb.co.jp>
Wed, 24 Mar 2010 13:46:59 +0900
changeset 52 0dfaca43d90e
parent 51 457d682728ee
child 54 fc9fa34e0c9e
Added web camera drivers and QEMU plug-in for obtaining and transferring dummy data.
baseport/syborg/bld.inf
baseport/syborg/bootstrap/syborg.inc
baseport/syborg/bootstrap/syborg.s
baseport/syborg/rom/base_syborg.iby
baseport/syborg/rom/kernel.iby
baseport/syborg/specific/syborg.h
baseport/syborg/syborg.dtb
baseport/syborg/syborg.dts
baseport/syborg/webcamera/webcamera_app.cpp
baseport/syborg/webcamera/webcamera_app.mmp
baseport/syborg/webcamera/webcamera_device.h
baseport/syborg/webcamera/webcamera_driver.h
baseport/syborg/webcamera/webcamera_driver.inl
baseport/syborg/webcamera/webcamera_ldd.cpp
baseport/syborg/webcamera/webcamera_ldd.h
baseport/syborg/webcamera/webcamera_ldd.mmp
baseport/syborg/webcamera/webcamera_pdd.cpp
baseport/syborg/webcamera/webcamera_pdd.h
baseport/syborg/webcamera/webcamera_pdd.mmp
symbian-qemu-0.9.1-12/qemu-symbian-svp/plugins/qemu_arm_plugins.py
symbian-qemu-0.9.1-12/qemu-symbian-svp/plugins/syborg_usbtest.py
--- a/baseport/syborg/bld.inf	Wed Mar 17 11:58:43 2010 +0000
+++ b/baseport/syborg/bld.inf	Wed Mar 24 13:46:59 2010 +0900
@@ -28,7 +28,8 @@
 estart.txt						/epoc32/rom/syborg/		//
 syborg.dtb						/epoc32/rom/syborg/		//
 trk_l1.ini						/epoc32/data/Z/trk/trk_syborg.ini
-
+webcamera/webcamera_driver.h				/epoc32/include/syborg/
+webcamera/webcamera_driver.inl				/epoc32/include/syborg/
 specific/variantmediadef.h /epoc32/include/syborg/variantmediadef.h
 
 PRJ_EXTENSIONS
@@ -88,6 +89,11 @@
 //Add Sound Driver
 soundsc\soundsc
 
+//Webcamera Device
+webcamera/webcamera_pdd
+webcamera/webcamera_ldd
+webcamera/webcamera_app
+
 PRJ_EXTENSIONS
 start		extension		base/config
 option		PREFIX			_syborg_
--- a/baseport/syborg/bootstrap/syborg.inc	Wed Mar 17 11:58:43 2010 +0000
+++ b/baseport/syborg/bootstrap/syborg.inc	Wed Mar 24 13:46:59 2010 +0900
@@ -51,7 +51,9 @@
 KHwBaseNet		EQU     KHwBaseRegisters + 0x0c000
 KHwBaseNand		EQU     KHwBaseRegisters + 0x0d000
 KHwBaseAudio		EQU     KHwBaseRegisters + 0x0e000
-KHwBasePlatform		EQU     KHwBaseRegisters + 0x0f000
+KHwBaseWebcamera	EQU     KHwBaseRegisters + 0x0f000
+KHwBasePlatform		EQU     KHwBaseRegisters + 0x10000
+
 ;-----------------------------------------------------------------------------
 ; Module linear bases
 ;-----------------------------------------------------------------------------
@@ -76,6 +78,7 @@
 KHwLinBaseNet		EQU	KHwLinBaseRegisters + 0x0c*KHwLinSeparation
 KHwLinBaseNand		EQU	KHwLinBaseRegisters + 0x0d*KHwLinSeparation
 KHwLinBaseAudio		EQU	KHwLinBaseRegisters + 0x0e*KHwLinSeparation
-KHwLinBasePlatform	EQU	KHwLinBaseRegisters + 0x0f*KHwLinSeparation
+KHwLinBaseWebcameraDevice	EQU	KHwLinBaseRegisters + 0x0f*KHwLinSeparation
+KHwLinBasePlatform	EQU	KHwLinBaseRegisters + 0x10*KHwLinSeparation;
 	
 	END
--- a/baseport/syborg/bootstrap/syborg.s	Wed Mar 17 11:58:43 2010 +0000
+++ b/baseport/syborg/bootstrap/syborg.s	Wed Mar 24 13:46:59 2010 +0900
@@ -182,6 +182,7 @@
 		HW_MAPPING		KHwBaseNet,			1,	HW_MULT_4K
 		HW_MAPPING		KHwBaseNand,    		1,	HW_MULT_4K
 		HW_MAPPING		KHwBaseAudio,    		1,	HW_MULT_4K
+		HW_MAPPING		KHwBaseWebcamera,    		1,	HW_MULT_4K
 		HW_MAPPING		KHwBasePlatform,    		8,	HW_MULT_4K
 	
 		DCD     0   ; terminator
--- a/baseport/syborg/rom/base_syborg.iby	Wed Mar 17 11:58:43 2010 +0000
+++ b/baseport/syborg/rom/base_syborg.iby	Wed Mar 24 13:46:59 2010 +0900
@@ -119,6 +119,11 @@
 extension[VARID]=	KERNEL_DIR\DEBUG_DIR\_PLATFORM_NAME_svpsnapdriver.ldd	sys\bin\svpsnapdriver.ldd
 file=			KERNEL_DIR\DEBUG_DIR\snapapp.exe			sys\bin\snapapp.exe
 
+// Webcamera Driver
+device[VARID]=		KERNEL_DIR\DEBUG_DIR\_PLATFORM_NAME_webcamera.pdd	sys\bin\webcamera.pdd
+device[VARID]=		KERNEL_DIR\DEBUG_DIR\_PLATFORM_NAME_ewebcamera.ldd	sys\bin\ewebcamera.ldd
+file=			KERNEL_DIR\DEBUG_DIR\webcamera_app.exe			sys\bin\webcamera_app.exe
+
 // Estart drive mapping setup files.
 data=			EPOCROOT##epoc32\rom\syborg\estart.txt			\sys\data\estart.txt
 
--- a/baseport/syborg/rom/kernel.iby	Wed Mar 17 11:58:43 2010 +0000
+++ b/baseport/syborg/rom/kernel.iby	Wed Mar 24 13:46:59 2010 +0900
@@ -63,6 +63,11 @@
 extension[VARID]=	\epoc32\release\##KMAIN##\##BUILD##\_##VARIANT##_svpsnapdriver.ldd  \sys\bin\svpsnapdriver.ldd
 file=			\epoc32\release\##KMAIN##\##BUILD##\snapapp.exe			\sys\bin\snapapp.exe
 
+// Webcamera Driver
+device[VARID]=		\epoc32\release\##KMAIN##\##BUILD##\_##VARIANT##_webcamera.PDD    	\sys\bin\webcamera.PDD
+device[VARID]=		\epoc32\release\##KMAIN##\##BUILD##\_##VARIANT##_ewebcamera.LDD    	\sys\bin\ewebcamera.LDD
+file=			\epoc32\release\##KMAIN##\##BUILD##\webcamera_app.exe			\sys\bin\webcamera_app.exe
+
 // Estart
 data=               	\epoc32\rom\syborg\ESTART.TXT					    \sys\data\ESTART.TXT
 
--- a/baseport/syborg/specific/syborg.h	Wed Mar 17 11:58:43 2010 +0000
+++ b/baseport/syborg/specific/syborg.h	Wed Mar 24 13:46:59 2010 +0900
@@ -50,8 +50,8 @@
 const TUint KHwSVPNetDevice			= KHwBasePeripherals + 0x0c*KHwLinSeparation;
 const TUint KHwSVPNandDevice			= KHwBasePeripherals + 0x0d*KHwLinSeparation;
 const TUint KHwSVPAudioDevice			= KHwBasePeripherals + 0x0e*KHwLinSeparation;
-const TUint KHwSVPPlatformDevice		= KHwBasePeripherals + 0x0f*KHwLinSeparation;
-
+const TUint KHwSVPWebcameraDevice		= KHwBasePeripherals + 0x0f*KHwLinSeparation;
+const TUint KHwSVPPlatformDevice		= KHwBasePeripherals + 0x10*KHwLinSeparation;
 	
 enum TSyborgInterruptId
 {
Binary file baseport/syborg/syborg.dtb has changed
--- a/baseport/syborg/syborg.dts	Wed Mar 17 11:58:43 2010 +0000
+++ b/baseport/syborg/syborg.dts	Wed Mar 24 13:46:59 2010 +0900
@@ -115,9 +115,15 @@
             interrupts = <a>;
             interrupt-parent = <&intc>;
         };
+        usbtest@0 {
+            compatible = "syborg,usbtest";
+            reg = <c000f000>;
+            interrupts = <b>;
+            interrupt-parent = <&intc>;
+        };
         platform@0 {
             compatible = "syborg,platform";
-            reg = <c000f000>;
+            reg = <c0010000>;
         };
     };
 };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/baseport/syborg/webcamera/webcamera_app.cpp	Wed Mar 24 13:46:59 2010 +0900
@@ -0,0 +1,115 @@
+/*
+* 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
+*
+*/
+
+#include <e32test.h>
+#include <webcamera_driver.h>
+
+#include <e32debug.h>
+#define DP(format...) RDebug::Printf(format)
+
+LOCAL_D RTest test(_L("WebcameraDevice_TEST"));
+
+//Wins用ダミーなので実機では正式なものを使用する
+_LIT(KWebcameraPddFileName, "webcamera.pdd");
+_LIT(KWebcameraLddFileName, "ewebcamera.ldd");
+
+GLDEF_C TInt E32Main()
+ {
+    test.Title();
+    TInt r;
+    
+    test.Start(_L("Load Physical Device"));
+    r=User::LoadPhysicalDevice(KWebcameraPddFileName);
+    test(r==KErrNone || r==KErrAlreadyExists);
+
+    test.Next(_L("Load Logical Device"));
+    r=User::LoadLogicalDevice(KWebcameraLddFileName);
+    test(r==KErrNone || r==KErrAlreadyExists);
+//    __KHEAP_MARK;
+
+//    test.Next(_L("Open Device"));
+//    RDevice device;
+//    r=device.Open(RWebcameraDevice::Name());
+//    test(r==KErrNone);
+
+    //test.Next(_L("Close Device"));
+    //device.Close();
+
+    test.Next(_L("Open Logical Channel"));
+    RWebcameraDevice ldd;
+    r=ldd.Open();
+    test(r==KErrNone);
+
+    test.Next(_L("Check access by wrong client"));
+    RWebcameraDevice ldd2=ldd;
+    r=ldd2.Duplicate(RThread(),EOwnerProcess);
+    test(r==KErrAccessDenied);
+
+    test.Next(_L("Check handle duplication"));
+    ldd2=ldd;
+    r=ldd2.Duplicate(RThread(),EOwnerThread);
+    test(r==KErrNone);
+    ldd2.Close();
+
+    test.Next(_L("ReceiveData"));
+    TRequestStatus status;
+    HBufC8 * buffer = HBufC8::NewL(BUFSIZE);
+    TPtr8	itempPtr(buffer->Des());
+    itempPtr.SetLength(0);
+    ldd.StartViewFinder(status,itempPtr);
+
+    test.Next(_L("ReceiveDataCancel"));
+    ldd.StopViewFinder();
+    User::WaitForRequest(status);
+    r=status.Int();
+    test(r==KErrNone);
+	
+    itempPtr.SetLength(0);
+    ldd.StartViewFinder(status,itempPtr);
+    User::WaitForRequest(status);
+    r=status.Int();
+	test(r==KErrNone);
+	
+    test.Next(_L("CaptureData"));
+    HBufC8 * buffer1 = buffer;
+    TPtr8	itempPtr1(buffer1->Des());
+    itempPtr1.SetLength(0);
+    ldd.Capture(status,itempPtr1);
+    User::WaitForRequest(status);
+    r=status.Int();
+    test(r==KErrNone);
+    
+    test.Next(_L("Close Logical Channel"));
+    ldd.Close();
+
+//    __KHEAP_MARKEND;
+
+    test.Next(_L("Unload Logical Device"));
+    r=User::FreeLogicalDevice(RWebcameraDevice::Name());
+    test(r==KErrNone);
+
+    test.Next(_L("Unload Physical Device"));
+    TName pddName(RWebcameraDevice::Name());
+    _LIT(KVariantExtension,".pdd");
+    pddName.Append(KVariantExtension);
+    r=User::FreePhysicalDevice(pddName);
+    test(r==KErrNone);
+	
+    test.End();
+
+    return(0);
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/baseport/syborg/webcamera/webcamera_app.mmp	Wed Mar 24 13:46:59 2010 +0900
@@ -0,0 +1,32 @@
+/*
+* 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:
+*
+*/
+
+TARGET		webcamera_app.exe
+TARGETTYPE	exe
+
+//UID		0x1000008d 0x101F399B   //TODO:修正する必要
+VENDORID        0x70000001
+
+CAPABILITY	DISKADMIN ALLFILES
+
+SYSTEMINCLUDE   /epoc32/include
+SYSTEMINCLUDE   /epoc32/include/platform
+
+SOURCEPATH	.
+SOURCE		webcamera_app.cpp
+
+LIBRARY		euser.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/baseport/syborg/webcamera/webcamera_device.h	Wed Mar 24 13:46:59 2010 +0900
@@ -0,0 +1,94 @@
+/*
+* 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 __deviceBASE_H
+#define __deviceBASE_H
+
+#include <comm.h>
+#include <e32hal.h>
+#include <e32ver.h>
+
+
+class DWebcameraLogicalChannelBase : public DLogicalChannel
+{
+public:
+	/**
+	  Called by PDD from ISR to indicate that a get oneflame operation has completed.
+	*/
+    virtual void GetOneFlameComplete(TInt aResult)=0;
+	/** 
+	call to the function if one Capture image is received.
+	*/
+    virtual void CaptureComplete(TInt aResult)=0;
+	/** 
+	call to the function if one flame is received.
+	*/
+	/** 
+	call to the function if one Capture image is received.
+	*/
+	virtual void DoCaptureComplete()=0;
+	
+public:
+  /**
+   * pointer to client.
+   */	
+	DThread* iClient;	
+};
+
+class DWebcameraDriverBase : public DBase
+{
+public:
+  /**
+  Enumeration of stop modes.
+  */
+  enum TUSBStopMode
+	{
+	USB_ViewerFinder =0,
+	USB_capture      =1,
+	USB_cancel      =2
+	};
+  /**
+  request.
+  */
+  virtual TInt StartViewerFinder(TUint aBuffer,TInt aSize)=0;
+  /**
+  Enumeration of stop modes.
+  */
+  virtual TInt StartCapture(TUint aBuffer,TInt aSize)=0;
+  /**
+  Enumeration of stop modes.
+  */
+  virtual void Stop(TUSBStopMode aMode)=0;
+//virtual void Caps(TDes8 &aCaps) const;
+ 
+public:
+  /**
+   * pointer to logic channel.
+   */		
+  DWebcameraLogicalChannelBase* iLdd;
+   /**
+   * Linear Addresses of Peripherals.
+   */		
+  TLinAddr iPortAddr;
+  /**
+   * interrupt number.
+   */		
+  TInt iIrq;
+  
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/baseport/syborg/webcamera/webcamera_driver.h	Wed Mar 24 13:46:59 2010 +0900
@@ -0,0 +1,144 @@
+/*
+* 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>
+#include <e32ver.h>
+
+#define BUFSIZE  (100*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;
+
+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);
+    /**
+      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,TDes8& aBuffer);
+    /**
+      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,TDes8& aBuffer);
+    /**
+      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();
+    
+public:
+    /**
+    Enumeration of Control messages.
+    */
+    enum TControl
+        {
+        EGetConfig,
+        ESetConfig
+        };
+    /**
+    Enumeration of Request messages.
+    */
+    enum TRequest
+        {
+        EStart,
+        ECapture,
+        ENumRequests,
+        EAllRequests = (1<<ENumRequests)-1
+        };
+
+    // Kernel side LDD channel is a friend
+    friend class DDriver1Channel;
+    };
+
+// Inline functions
+#include <webcamera_driver.inl>
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/baseport/syborg/webcamera/webcamera_driver.inl	Wed Mar 24 13:46:59 2010 +0900
@@ -0,0 +1,139 @@
+/*
+* 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 __deviceIFI_H
+#define __deviceIFI_H
+
+/**
+  Returns the driver's name
+*/
+inline const TDesC& RWebcameraDevice::Name()
+    {
+    _LIT(KDriverName,"WebcameraDevice");
+    return KDriverName;
+    }
+
+/**
+  Returns the version number of the driver
+*/
+inline TVersion RWebcameraDevice::VersionRequired()
+    {
+    const TInt KMajorVersionNumber=1;
+    const TInt KMinorVersionNumber=1;
+    const TInt KBuildVersionNumber=0;
+    return TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
+    }
+
+/*
+  NOTE: The following member functions would normally be exported from a seperate client DLL
+  but are included inline in this header file for convenience.
+*/
+
+#ifndef __KERNEL_MODE__
+
+/**
+  Opens a logical channel to the driver
+
+  @return One of the system wide error codes.
+*/
+inline TInt RWebcameraDevice::Open()
+    {
+    return DoCreate(Name(),VersionRequired(),KNullUnit,NULL,NULL,EOwnerThread);
+    }
+
+
+/**
+  Gets the current configuration settings.
+
+  @param aConfig A structure which will be filled with the configuration settings.
+
+  @return KErrNone
+*/
+inline TInt RWebcameraDevice::GetConfig(TConfigBuf& aConfig)
+    {
+    return DoControl(EGetConfig,(TAny*)&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 RWebcameraDevice::SetConfig(const TConfigBuf& aConfig)
+    {
+    return DoControl(ESetConfig,(TAny*)&aConfig);
+    }
+
+/**
+  Receives image from the device.
+  Only one receive request may be pending at any time.
+
+  @param aStatus The request to be signalled when the data has been received.
+                 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 to which the received data will be written.
+*/
+inline void RWebcameraDevice::StartViewFinder(TRequestStatus& aStatus,TDes8& aBuffer)
+    {
+	TInt length=BUFSIZE;
+    DoRequest(EStart,aStatus,(TAny*)&aBuffer,(TAny*)&length);
+    }
+
+
+/**
+  Cancels a previous StartViewFinder request.
+*/
+inline void RWebcameraDevice::StartViewFinderCancel()
+    {
+    DoCancel(1<<EStart);
+    }
+
+inline void RWebcameraDevice::StopViewFinder()
+	{
+    DoCancel(1<<EStart);
+	}
+
+/**
+  Capture data from the device.
+  Only one Capture request may be pending at any time.
+
+  @param aStatus The request to be signalled when the data has been captureed.
+                 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 to which the captured data will be written.
+*/
+inline void RWebcameraDevice::Capture(TRequestStatus& aStatus,TDes8& aBuffer)
+    {
+	TInt length=BUFSIZE;
+    DoRequest(ECapture,aStatus,(TAny*)&aBuffer,(TAny*)&length);
+    }
+
+/**
+  Cancels a previous capture request.
+*/
+inline void RWebcameraDevice::CaptureCancel()
+    {
+	DoCancel(1<<ECapture);
+    }
+#endif   // !__KERNEL_MODE__
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/baseport/syborg/webcamera/webcamera_ldd.cpp	Wed Mar 24 13:46:59 2010 +0900
@@ -0,0 +1,586 @@
+/*
+* 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
+*
+*/
+
+#include <kern_priv.h>
+#include "webcamera_ldd.h"
+#include <webcamera_driver.h>
+
+#define DP(format...) Kern::Printf(format)
+
+_LIT(KDriver1PanicCategory,"WebcameraDevice");
+
+/**
+ *Create Logic device.
+ *
+ */
+DECLARE_STANDARD_LDD()
+	{
+    DP("DECLARE_STANDARD_LDD()");
+    return new DWebcameraLogicalDevice;
+	}
+
+/**
+  Constructor
+*/
+DWebcameraLogicalDevice::DWebcameraLogicalDevice()
+	{
+	DP("DWebcameraLogicalDevice()");
+    // Set version number for this device
+    iVersion=RWebcameraDevice::VersionRequired();
+    // Indicate that we work with a PDD
+    iParseMask=KDeviceAllowPhysicalDevice;
+	}
+
+/**
+  Destructor
+*/
+DWebcameraLogicalDevice::~DWebcameraLogicalDevice()
+	{
+	}
+
+/**
+  Second stage constructor for DDriver1Factory.
+  This must at least set a name for the driver object.
+
+  @return KErrNone if successful, otherwise one of the other system wide error codes.
+*/
+TInt DWebcameraLogicalDevice::Install()
+	{
+	DP("DWebcameraLogicalDevice::Install()");
+
+	return SetName(&RWebcameraDevice::Name());
+	}
+
+/**
+  Return the drivers capabilities.
+  Called in the response to an RDevice::GetCaps() request.
+
+  @param aDes User-side descriptor to write capabilities information into
+*/
+void DWebcameraLogicalDevice::GetCaps(TDes8& aDes) const
+	{
+    // Create a capabilities object
+	RWebcameraDevice::TCaps caps;
+    caps.iVersion = iVersion;
+    // Write it back to user memory
+    Kern::InfoCopy(aDes,(TUint8*)&caps,sizeof(caps));
+	}
+
+/**
+  Called by the kernel's device driver framework to create a Logical Channel.
+  This is called in the context of the user thread (client) which requested the creation of a Logical Channel
+  (E.g. through a call to RBusLogicalChannel::DoCreate)
+  The thread is in a critical section.
+
+  @param aChannel Set to point to the created Logical Channel
+
+  @return KErrNone if successful, otherwise one of the other system wide error codes.
+*/
+TInt DWebcameraLogicalDevice::Create(DLogicalChannelBase*& aChannel)
+	{
+	DP("DWebcameraLogicalDevice::Create() start");
+	aChannel = new DWebcameraLogicalChannel;
+	if(!aChannel)
+		return KErrNoMemory;
+	return KErrNone;
+	DP("DWebcameraLogicalDevice::Create() end");
+	}
+
+/**
+  Constructor
+*/
+DWebcameraLogicalChannel::DWebcameraLogicalChannel()
+	: iReceiveDataDfc(GetOneFlameDfc, this, 1)
+	  ,iCaptureDfc(CaptureDfc,this,1)
+	{
+	DP("DWebcameraLogicalChannel::DWebcameraLogicalChannel() start");
+
+    // Get pointer to client threads DThread object
+	iClient=&Kern::CurrentThread();
+    // Open a reference on client thread so it's control block can't dissapear until
+    // this driver has finished with it.
+	((DObject*)iClient)->Open();
+	
+	DP("DWebcameraLogicalChannel::DWebcameraLogicalChannel() end");
+	}
+
+/**
+  Destructor
+*/
+DWebcameraLogicalChannel::~DWebcameraLogicalChannel()
+	{
+	DP("DWebcameraLogicalChannel::~DWebcameraLogicalChannel() start");
+    // Cancel all processing that we may be doing
+	DoCancel(RWebcameraDevice::EAllRequests);	
+	if (iComm)
+		{
+		delete iComm;
+		}
+    if (iChunk)
+        {
+        Epoc::FreePhysicalRam(iPhysAddr, iSize);
+        }
+    // Close our reference on the client thread
+	Kern::SafeClose((DObject*&)iClient,NULL);
+	DP("DWebcameraLogicalChannel::~DWebcameraLogicalChannel() end");
+	}
+
+/**
+  Called when a user thread requests a handle to this channel.
+*/
+TInt DWebcameraLogicalChannel::RequestUserHandle(DThread* aThread, TOwnerType aType)
+    {
+    // Make sure that only our client can get a handle
+    if (aType!=EOwnerThread || aThread!=iClient)
+        return KErrAccessDenied;
+    return KErrNone;
+    }
+
+/**
+  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
+  (E.g. through a call to RBusLogicalChannel::DoCreate)
+  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
+  @param aVer The version argument supplied by the client
+
+  @return KErrNone if successful, otherwise one of the other system wide error codes.
+*/
+TInt DWebcameraLogicalChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& aVer)
+	{
+	DP("DWebcameraLogicalChannel::DoCreate() start");
+    if(!Kern::CurrentThreadHasCapability(ECapability_None,__PLATSEC_DIAGNOSTIC_STRING("Checked by Webcamera")))
+    	{
+        return KErrPermissionDenied;
+    	}
+    // Check version
+	if (!Kern::QueryVersionSupported(RWebcameraDevice::VersionRequired(),aVer))
+		{
+		return KErrNotSupported;
+		}
+    // Setup LDD for receiving client messages
+	SetDfcQ(Kern::DfcQue0());
+	iMsgQ.Receive();
+    // Associate DFCs with the same queue we set above to receive client messages on
+	iReceiveDataDfc.SetDfcQ(iDfcQ);
+	iCaptureDfc.SetDfcQ(iDfcQ);
+    // Give PDD a pointer to this channel
+	Pdd()->iLdd=this;
+
+	//allocate Memory
+	iSize=Kern::RoundToPageSize(BUFSIZE);
+	TInt rtn=Epoc::AllocPhysicalRam(iSize, iPhysAddr);
+	if (rtn != KErrNone)
+		{
+		return rtn;
+		}
+	rtn=DPlatChunkHw::New(iChunk, iPhysAddr, iSize,EMapAttrUserRw|EMapAttrBufferedC);
+	if (rtn != KErrNone)
+		{
+		if (iPhysAddr)
+			{
+			Epoc::FreePhysicalRam(iPhysAddr, iSize);
+			}
+		return rtn;
+		}
+	iLAdr = reinterpret_cast<TUint8*>(iChunk->LinearAddress());
+	
+	iComm=HBuf8::New(BUFSIZE);
+	if (!iComm)
+		{
+		return KErrNotSupported;
+		}
+	iReceiveDataBuffer=iComm;
+	iCaptureBuffer=iComm;
+
+	DP("DWebcameraLogicalChannel::DoCreate() end");
+	return KErrNone;
+	}
+
+/**
+  Process a message for this logical channel.
+  This function is called in the context of a DFC thread.
+
+  @param aMessage The message to process.
+                  The iValue member of this distinguishes the message type:
+                  iValue==ECloseMsg, channel close message
+                  iValue==KMaxTInt, a 'DoCancel' message
+                  iValue>=0, a 'DoControl' message with function number equal to iValue
+                  iValue<0, a 'DoRequest' message with function number equal to ~iValue
+*/
+void DWebcameraLogicalChannel::HandleMsg(TMessageBase* aMsg)
+	{
+	DP("DWebcameraLogicalChannel::HandleMsg() start");
+	TThreadMessage& m=*(TThreadMessage*)aMsg;
+
+    // Get message type
+	TInt id=m.iValue;
+    DP("id=%d",id);
+    
+    // Decode the message type and dispatch it to the relevent handler function...
+	if (id==(TInt)ECloseMsg)
+		{
+		DoCancel(RWebcameraDevice::EAllRequests);
+		m.Complete(KErrNone, EFalse);
+		return;
+		}
+
+	if(m.Client()!=iClient)
+		{
+		Kern::ThreadKill(m.Client(),
+						 EExitPanic,
+						 ERequestFromWrongThread,
+						 KDriver1PanicCategory);
+		m.Complete(KErrNone,ETrue);
+		return;
+		}
+
+	if (id==KMaxTInt)
+		{
+		DoCancel(m.Int0());
+		m.Complete(KErrNone,ETrue);
+		return;
+		}
+
+	if (id<0)
+		{
+		// DoRequest
+		TRequestStatus* pS=(TRequestStatus*)m.Ptr0();
+		TInt rtn =DoRequest(~id,pS,m.Ptr1(),aMsg);
+
+		if (rtn != KErrNone)
+			Kern::RequestComplete(iClient,pS,rtn);
+        m.Complete(KErrNone,ETrue);
+		}
+	else
+		{
+		// DoControl
+		TInt rtn = DoControl(id,m.Ptr0(),aMsg);
+		m.Complete(rtn,ETrue);
+		}
+	DP("DWebcameraLogicalChannel::HandleMsg() end");
+	}
+
+/**
+  Process synchronous 'control' requests
+*/
+TInt DWebcameraLogicalChannel::DoControl(TInt aFunction, TAny* a1, TAny* a2)
+	{
+	DP("DWebcameraLogicalChannel::DoControl() start");
+	TInt rtn;
+	TThreadMessage& m=*(TThreadMessage*)a2;
+	TRequestStatus* pS=(TRequestStatus*)m.Ptr0();
+
+	switch (aFunction)
+		{
+		case RWebcameraDevice::EGetConfig:
+//			rtn = GetConfig((TDes8*)a1);
+			rtn = KErrNone;
+			if ( rtn != KErrNone )
+				{
+				Kern::RequestComplete(iClient,pS,rtn);
+				}
+			break;
+        case RWebcameraDevice::ESetConfig:
+ //       	rtn = SetConfig((const TDesC8*)a1);
+            break;
+            
+		default:
+			rtn = KErrNotSupported;
+			Kern::RequestComplete(iClient,pS,rtn);
+			break;
+		}
+	DP("DWebcameraLogicalChannel::DoControl() end");
+	return rtn;
+
+	}
+
+/**
+  Process asynchronous requests.
+*/
+TInt DWebcameraLogicalChannel::DoRequest(TInt aReqNo,
+											TRequestStatus* aStatus,
+											TAny* a1,
+											TAny* a2)
+	{
+	DP("DWebcameraLogicalChannel::DoRequest() start");
+	TInt rtn;
+	TThreadMessage& m=*(TThreadMessage*)a2;
+
+	iRequesting =ETrue;
+	rtn = KErrNone;
+    DP("aReqNo=%d",aReqNo);
+	switch(aReqNo)
+		{
+		case RWebcameraDevice::EStart:
+   			DP("EStart=%d",RWebcameraDevice::EStart);
+			iReceiveDataStatus = aStatus;
+			iReceiving = ETrue ;
+			iReceiveDataBuffer->FillZ(iCaptureBuffer->MaxLength());
+			iReceiveDataBuffer->Zero();
+			DP("iReceiveDataBuffer Len=%d",iReceiveDataBuffer->MaxLength());
+			DP("iReceiveDataBuffer Len=%d",iReceiveDataBuffer->Length());
+			rtn = Pdd()->StartViewerFinder(iPhysAddr,iSize);
+			if ( rtn != KErrNone ) 
+				{
+	   			DP("rtn=%d",rtn);
+				iReceiving = EFalse ;
+				Kern::RequestComplete(iClient,aStatus,rtn);
+				}
+			else
+				{
+	   			DP("rtn=%d",rtn);
+				// Example Platform Security capability check which tests the
+				// client for ECapability_None (which always passes)...
+				if ( iRequesting == EFalse )
+					{
+		   			DP("iRequesting=EFalse");
+					iReceiving = EFalse ;
+					Kern::RequestComplete(iClient,
+										  iReceiveDataStatus,
+										  iReceiveDataResult);
+					}
+				else
+					{
+					DP("iRequesting=ETrue");
+					iReceiveDataDescriptor=(TDes8*)a1;
+					}
+				}
+			break;
+		case RWebcameraDevice::ECapture:
+			iCaptureing = ETrue ;
+			iCaptureStatus = aStatus;
+			iCaptureBuffer->FillZ(iCaptureBuffer->MaxLength());
+			iCaptureBuffer->Zero();
+		    DP("iCaptureBuffer Len=%d",iCaptureBuffer->MaxLength());
+		    DP("iCaptureBuffer Len=%d",iCaptureBuffer->Length());
+			rtn = Pdd()->StartCapture(iPhysAddr,iSize);
+			DP("rtn=%d",rtn);
+			if ( rtn != KErrNone ) 
+				{
+				iCaptureing = EFalse ;
+				Kern::RequestComplete(iClient,aStatus,rtn);
+				}
+			else
+				{
+				if ( iRequesting == EFalse )
+					{
+				    DP("iRequesting=EFalse");
+					iReceiving = EFalse ;
+					Kern::RequestComplete(iClient,iCaptureStatus,iCaptureResult);
+					}
+				else
+					{
+			        DP("Capture iRequesting=ETrue");
+				    iCaptureDescriptor=(TDes8*)a1;
+					}
+				}
+			break;
+		default:
+			rtn=KErrNotSupported;
+			Kern::RequestComplete(iClient,aStatus,rtn);
+			break;
+		}
+	iRequesting = EFalse;
+
+	DP("DWebcameraLogicalChannel::DoRequest() end");
+	return rtn;
+
+	}
+
+/**
+  Process cancelling of asynchronous requests.
+*/
+void DWebcameraLogicalChannel::DoCancel(TUint aMask)
+	{
+	DP("DWebcameraLogicalChannel::DoCancel() start");
+	TInt rtn;
+	DP("aMask=%d",aMask);
+    if (aMask&(1<<RWebcameraDevice::EStart))
+    	{
+		DP("RWebcameraDevice::EStart=%d",RWebcameraDevice::EStart);
+		if (iReceiveDataStatus)
+			{
+			DP("iReceiveDataStatus=%d",iReceiveDataStatus);
+			Pdd()->Stop(DWebcameraDriverBase::USB_cancel);
+			iReceiving = EFalse ;
+			iReceiveDataDfc.Cancel();
+			Kern::RequestComplete(iClient,iReceiveDataStatus,KErrCancel);
+			}
+    	}
+    if (aMask&(1<<RWebcameraDevice::ECapture))
+    	{
+		DP("RWebcameraDevice::ECapture=%d",RWebcameraDevice::ECapture);
+		if (iCaptureStatus)
+			{
+			Pdd()->Stop(DWebcameraDriverBase::USB_cancel);
+			iReceiving = EFalse ;
+			iCaptureDfc.Cancel();
+			Kern::RequestComplete(iClient,iCaptureStatus,KErrCancel);
+			}
+    	}
+	DP("DWebcameraLogicalChannel::DoCancel() end");
+	}
+
+/**
+  Called by PDD from ISR to indicate that a ReceiveData operation has completed.
+*/
+void DWebcameraLogicalChannel::GetOneFlameComplete(TInt aDataSize)
+    {
+	DP("DWebcameraLogicalChannel::GetOneFlameComplete() start");
+	DP("datasize=%d",aDataSize);
+	iSaveSize=iSize - aDataSize;
+    // Queue DFC
+    iReceiveDataDfc.Add();
+    //set size of received data
+    if (iSaveSize > 0)
+    	{
+	    iReceiveDataResult = KErrNone;
+    	}
+    else
+    	{
+		iReceiveDataResult = KErrUnknown;//TODO:define of error
+    	}
+	DP("DWebcameraLogicalChannel::GetOneFlameComplete() end");
+    }
+
+/**
+  Called by PDD from ISR to indicate that a get capture image operation has completed.
+*/
+void DWebcameraLogicalChannel::CaptureComplete(TInt aDataSize)
+    {
+	DP("DWebcameraLogicalChannel::CaptureComplete() start");
+	DP("datasize=%d",aDataSize);
+	iSaveSize=iSize - aDataSize;
+    // Queue DFC
+	iCaptureDfc.Add();
+    //set size of received data
+    if (iSaveSize > 0)
+    	{
+		iCaptureResult = KErrNone;
+    	}
+    else
+    	{
+        iCaptureResult = KErrUnknown;//TODO:define of error
+    	}
+	DP("DWebcameraLogicalChannel::CaptureComplete() end");
+    }
+
+/**
+  DFC Callback which gets triggered after the PDD has signalled that getting oneflame completed.
+  This just casts aPtr and calls DoGetOneFlameComplete().
+*/
+void DWebcameraLogicalChannel::GetOneFlameDfc(TAny* aPtr)
+    {
+	DP("DWebcameraLogicalChannel::GetOneFlameDfc() start");
+    ((DWebcameraLogicalChannel*)aPtr)->DoGetOneFlameComplete();
+	DP("DWebcameraLogicalChannel::GetOneFlameDfc() end");
+    }
+
+/**
+  DFC Callback which gets triggered after the PDD has signalled that getting Capture image completed.
+  This just casts aPtr and calls DoCaptureComplete().
+*/
+void DWebcameraLogicalChannel::CaptureDfc(TAny* aPtr)
+    {
+	DP("DWebcameraLogicalChannel::CaptureDfc() start");
+    ((DWebcameraLogicalChannel*)aPtr)->DoCaptureComplete();
+	DP("DWebcameraLogicalChannel::CaptureDfc() end");
+    }
+
+/**
+  Called from a DFC after the PDD has signalled that getting oneflame completed.
+*/
+void DWebcameraLogicalChannel::DoGetOneFlameComplete()
+    {
+	DP("DWebcameraLogicalChannel::DoGetOneFlameComplete() start");
+	iReceiveDataBuffer->Copy(iLAdr,iSaveSize);
+    DP("iReceiveDataBuffer Len=%d",iReceiveDataBuffer->Length());
+	// Write data to client from our buffer
+    TInt result=Kern::ThreadDesWrite(iClient,iReceiveDataDescriptor,*iReceiveDataBuffer,0);
+    // Finished with client descriptor, so NULL it to help detect coding errors
+    iReceiveDataDescriptor = NULL;
+
+    // Use result code from PDD if it was an error
+    if(iReceiveDataResult!=KErrNone)
+        result = iReceiveDataResult;
+    
+    // Complete clients request
+    Kern::RequestComplete(iClient,iReceiveDataStatus,result);
+	DP("DWebcameraLogicalChannel::DoGetOneFlameComplete() end");
+    }
+
+/**
+  Called from a DFC after the PDD has signalled that getting Capture image completed.
+*/
+void DWebcameraLogicalChannel::DoCaptureComplete()
+    {
+	DP("DWebcameraLogicalChannel::DoCaptureComplete() start");
+	iCaptureBuffer->Copy(iLAdr,iSaveSize);
+    DP("iCaptureBuffer Len=%d",iCaptureBuffer->Length());
+	// Write data to client from our buffer
+   TInt result=Kern::ThreadDesWrite(iClient,iCaptureDescriptor,*iCaptureBuffer,0);  	
+    // Finished with client descriptor, so NULL it to help detect coding errors
+    iCaptureDescriptor = NULL;
+
+    // Use result code from PDD if it was an error
+    if(iCaptureResult!=KErrNone)
+        result = iCaptureResult;
+
+    // Complete clients request
+    Kern::RequestComplete(iClient,iCaptureStatus,result);
+	DP("DWebcameraLogicalChannel::DoCaptureComplete() end");
+    }
+
+/**
+  Process a GetConfig control message. This writes the current driver configuration to a
+  RWebcameraDevice::TConfigBuf supplied by the client.
+*/
+TInt DWebcameraLogicalChannel::GetConfig(TDes8* aConfigBuf)
+    {
+	//unsupported
+    }
+
+/**
+  Process a SetConfig control message. This sets the driver configuration using a
+  RWebcameraDevice::TConfigBuf supplied by the client.
+*/
+TInt DWebcameraLogicalChannel::SetConfig(const TDesC8* aConfigBuf)
+    {
+	//unsupported
+    }
+
+/**
+  Fill a TConfig with the drivers current configuration.
+*/
+/*void DWebcameraLogicalChannel::CurrentConfig(RWebcameraDevice::TConfig& aConfig)
+    {
+	//unsupported
+    }
+*/
+
+/**
+ *Get the point to Physical channel.
+ */
+DWebcameraDriverBase* DWebcameraLogicalChannel::Pdd()
+	{
+	DP("DWebcameraLogicalChannel::Pdd() start");
+	return (DWebcameraDriverBase*)iPdd;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/baseport/syborg/webcamera/webcamera_ldd.h	Wed Mar 24 13:46:59 2010 +0900
@@ -0,0 +1,242 @@
+/*
+* 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 __deviceLDD_H__
+#define __deviceLDD_H__
+
+#include <kernel.h>
+#include "webcamera_device.h"
+
+#define BUFSIZE  (100*1024)
+/**
+ *Logical channel class
+ *
+ */
+class DWebcameraLogicalDevice : public DLogicalDevice
+	{
+public:
+	DWebcameraLogicalDevice();
+	~DWebcameraLogicalDevice();
+    /**
+      Second stage constructor for DDriver1Factory.
+      This must at least set a name for the driver object.
+
+      @return KErrNone if successful, otherwise one of the other system wide error codes.
+    */
+    virtual TInt Install();
+    /**
+      Return the drivers capabilities.
+      Called in the response to an RDevice::GetCaps() request.
+
+      @param aDes User-side descriptor to write capabilities information into
+    */
+    virtual void GetCaps(TDes8& aDes) const;
+    /**
+      Called by the kernel's device driver framework to create a Logical Channel.
+      This is called in the context of the user thread (client) which requested the creation of a Logical Channel
+      (E.g. through a call to RBusLogicalChannel::DoCreate)
+      The thread is in a critical section.
+
+      @param aChannel Set to point to the created Logical Channel
+
+      @return KErrNone if successful, otherwise one of the other system wide error codes.
+    */
+    virtual TInt Create(DLogicalChannelBase*& aChannel);
+	};
+
+/**
+ *
+ * 論理チャネルベースクラス
+ *
+ * 本クラスは、論理チャネル機能を提供する。
+ *
+ * @
+ * @
+ *
+ */
+class DWebcameraLogicalChannel : public DWebcameraLogicalChannelBase
+	{
+public:
+	/**
+	  Constructor
+	*/
+	DWebcameraLogicalChannel();
+	/**
+	  Destructor
+	*/
+	~DWebcameraLogicalChannel();
+	/**
+	  Called when a user thread requests a handle to this channel.
+	*/
+    virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
+    /**
+      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
+      @param aVer The version argument supplied by the client
+
+      @return KErrNone if successful, otherwise one of the other system wide error codes.
+    */
+	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
+	/**
+	  Process a message for this logical channel.
+	  This function is called in the context of a DFC thread.
+
+	  @param aMessage The message to process.
+	                  The iValue member of this distinguishes the message type:
+	                  iValue==ECloseMsg, channel close message
+	                  iValue==KMaxTInt, a 'DoCancel' message
+	                  iValue>=0, a 'DoControl' message with function number equal to iValue
+	                  iValue<0, a 'DoRequest' message with function number equal to ~iValue
+	*/
+	virtual void HandleMsg(TMessageBase* aMsg);
+	/**
+	  Process synchronous 'control' requests
+	*/
+	virtual TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
+	/**
+	  Process asynchronous requests.
+	*/
+	virtual TInt DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2);
+	/**
+	  Process cancelling of asynchronous requests.
+	*/
+	virtual void DoCancel(TUint aMask);
+	/**
+	  Called by PDD from ISR to indicate that a get oneflame operation has completed.
+	*/
+    virtual void GetOneFlameComplete(TInt aResult);
+    /**
+      Called by PDD from ISR to indicate that a get capture image operation has completed.
+    */
+    virtual void CaptureComplete(TInt aResult);
+    /**
+      DFC Callback which gets triggered after the PDD has signalled that get oneflame completed.
+      This just casts aPtr and calls DoGetOneFlameComplete().
+    */
+    static  void GetOneFlameDfc(TAny* aPtr);
+	/**
+	  DFC Callback which gets triggered after the PDD has signalled that getting Capture image completed.
+	  This just casts aPtr and calls DoCaptureComplete().
+	*/
+    static  void CaptureDfc(TAny* aPtr);
+    /**
+      Called from a DFC after the PDD has signalled that getting oneflame completed.
+    */
+	virtual void DoGetOneFlameComplete();
+	/**
+	  Called from a DFC after the PDD has signalled that getting Capture image completed.
+	*/
+	virtual void DoCaptureComplete();
+    
+	/**
+	  Process a GetConfig control message. This writes the current driver configuration to a
+	  RWebcameraDevice::TConfigBuf supplied by the client.
+	*/
+    TInt GetConfig(TDes8* aConfigBuf);
+    /**
+      Process a SetConfig control message. This sets the driver configuration using a
+      RWebcameraDevice::TConfigBuf supplied by the client.
+    */
+    TInt SetConfig(const TDesC8* aConfigBuf);
+//  void CurrentConfig(RWebcameraDevice::TConfig& aConfig);
+    /**
+     *Get the point to Physical channel.
+     */
+    DWebcameraDriverBase* Pdd();
+    
+private:
+    /**
+     *point to description sent by user-side.
+     */
+    TDes8* iReceiveDataDescriptor;
+    /**
+     *buffer for one flame.
+     */
+    HBuf8* iReceiveDataBuffer;
+    /**
+     *the status getting one flame.
+     */
+	TRequestStatus* iReceiveDataStatus;
+    /**
+     *DFC for getting one flame.
+     */
+	TDfc iReceiveDataDfc;
+    /**
+     *the result of the get oneflame operation.
+     */
+	TInt iReceiveDataResult;
+    /**
+     */
+	TBool iReceiving;
+    /**
+     *point to description sent by user-side.
+     */
+    TDes8* iCaptureDescriptor;
+    /**
+     *buffer for capture image.
+     */
+	HBuf8* iCaptureBuffer;
+    /**
+     *the status getting capture image.
+     */
+	TRequestStatus* iCaptureStatus;
+    /**
+     *DFC of capture.
+     */
+	TDfc iCaptureDfc;
+    /**
+     *the result of the capture operation.
+     */
+	TInt iCaptureResult;
+    /**
+     *the status getting capture image.
+     */
+	TBool iCaptureing;
+    /**
+     *the status of request.
+     */	
+	TBool iRequesting;
+    /**
+     *point to memory used to save one frame or capture image.
+     */
+    HBuf8* iComm;
+    /**
+     *Physical adress of contiguous memory.
+     */
+	TUint32 iPhysAddr;
+    /**
+     *the size of buffer used to save one frame or capture image.
+     */
+	TInt iSize;
+    /**
+     *chunck.
+     */
+	DPlatChunkHw* iChunk;
+    /**
+     *Linear adress of chunck.
+     */
+	TUint8* iLAdr;
+    /**
+     *the size of received data.
+     */
+	TInt iSaveSize;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/baseport/syborg/webcamera/webcamera_ldd.mmp	Wed Mar 24 13:46:59 2010 +0900
@@ -0,0 +1,41 @@
+/*
+* 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:
+*
+*/
+
+#include <variant.mmh>
+#include "kernel/kern_ext.mmh"
+
+TARGET			VariantTarget(ewebcamera,ldd)
+linkas			ewebcamera.ldd
+TARGETTYPE		ldd
+
+SYSTEMINCLUDE   /epoc32/include/drivers
+SYSTEMINCLUDE   /epoc32/include/platform/drivers
+SYSTEMINCLUDE	AsspNKernIncludePath
+
+SOURCEPATH		.
+SOURCE			webcamera_ldd.cpp
+
+LIBRARY			PlatformLib
+
+EPOCALLOWDLLDATA
+
+UID				0x100000af 0x1020044C   //TODO:修正する必要
+//VENDORID        0x70000001
+
+//ROMTARGET		ewebcamera.ldd
+
+CAPABILITY		all
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/baseport/syborg/webcamera/webcamera_pdd.cpp	Wed Mar 24 13:46:59 2010 +0900
@@ -0,0 +1,186 @@
+/*
+* 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
+*
+*/
+
+#include "webcamera_pdd.h"
+#include <webcamera_driver.h>
+
+#define DP(format...) Kern::Printf(format)
+
+//Name for PDD
+_LIT(KWebcameraPddName,"WebcameraDevice.pdd");
+
+// ---------------------------------------------------------------
+// ---------------------------------------------------------------
+
+DWebcameraPddFactory::DWebcameraPddFactory()
+{
+  DP("DWebcameraPddFactory::DWebcameraPddFactory()");
+  iVersion=TVersion(KCommsMajorVersionNumber,KCommsMinorVersionNumber,KCommsBuildVersionNumber);
+}
+
+TInt DWebcameraPddFactory::Install()
+{
+  DP("DWebcameraPddFactory::Install");
+  return SetName(&KWebcameraPddName);
+}
+
+void DWebcameraPddFactory::GetCaps(TDes8 &aDes) const
+{
+  DP("DWebcameraPddFactory::GetCaps start");
+  RWebcameraDevice::TCaps capsBuf;
+  capsBuf.iVersion = iVersion;
+  aDes.FillZ(aDes.MaxLength());
+  TInt size=sizeof(capsBuf);
+  if(size>aDes.MaxLength())
+	  {
+      size=aDes.MaxLength();
+	  }
+  aDes.Copy((TUint8*)&capsBuf,size);
+  DP("DWebcameraPddFactory::GetCaps end");
+}
+
+TInt DWebcameraPddFactory::Create(DBase*& aChannel, TInt aUnit, const TDesC8* anInfo, const TVersion& aVer)
+{
+  DP("DWebcameraPddFactory::Create start");
+  DWebcameraDriver* pD=new DWebcameraDriver;
+  aChannel=pD;
+  TInt r=KErrNoMemory;
+  if (pD)
+	  {
+	  r=pD->DoCreate(aUnit,anInfo);
+	  }
+  DP("DWebcameraPddFactory::Create end");
+  return r;
+}
+
+TInt DWebcameraPddFactory::Validate(TInt aUnit, const TDesC8* /*anInfo*/, const TVersion& aVer)
+{
+  DP("DWebcameraPddFactory::Validate start");
+  if ((!Kern::QueryVersionSupported(iVersion,aVer)) || 
+	  (!Kern::QueryVersionSupported(aVer,TVersion(KMinimumLddMajorVersion,KMinimumLddMinorVersion,KMinimumLddBuild))))
+	  {
+		return KErrNotSupported;
+	  }
+  DP("DWebcameraPddFactory::Validate end");
+  return KErrNone;
+}
+
+// ---------------------------------------------------------------
+// ---------------------------------------------------------------
+
+DWebcameraDriver::DWebcameraDriver()
+{
+	DP("DWebcameraDriver::DWebcameraDriver start");
+	DP("DWebcameraDriver::DWebcameraDriver end");
+}
+
+DWebcameraDriver::~DWebcameraDriver()
+{
+  DP("DWebcameraDriver::~DWebcameraDriver start");
+  Interrupt::Unbind(iIrq);
+  DP("DWebcameraDriver::~DWebcameraDriver end");
+}
+
+TInt DWebcameraDriver::DoCreate(TInt aUnit, const TDesC8* anInfo)
+{
+  DP("DWebcameraDriver::DoCreate start");
+  iPortAddr=KHwSVPWebcameraDevice;
+  iIrq = EIrqWebamera;
+  Interrupt::Bind(iIrq,Isr,this);
+  DP("DWebcameraDriver::DoCreate end");
+  return KErrNone;
+}
+
+TInt DWebcameraDriver::StartViewerFinder(TUint aBuffer,TInt aSize)
+{
+  DP("DWebcameraDriver::StartViewerFinder start");
+  iType=0;
+  TUint32 temp=(TUint32)aBuffer;
+  DP("temp=%x",temp);
+  DP("iPortAddr=%x",iPortAddr);
+  WriteReg(iPortAddr,WEBCAMERA_REG_DATA_TYPE, 0x0);
+  WriteReg(iPortAddr,WEBCAMERA_REG_DMA_ADDR,temp);
+  WriteReg(iPortAddr,WEBCAMERA_REG_DMA_SIZE, aSize);
+  WriteReg(iPortAddr,WEBCAMERA_REG_INT_ENABLE, 0x1);
+  Interrupt::Enable(iIrq);
+  
+  DP("DWebcameraDriver::StartViewerFinder END"); 
+  return KErrNone;
+}
+
+TInt DWebcameraDriver::StartCapture(TUint aBuffer,TInt aSize)
+{
+  DP("DWebcameraDriver::StartCapture start");
+  // Save a pointer to the buffer we need to put the 'recevied' data in
+  iType=1;
+  TUint32 temp=(TUint32)aBuffer;
+  DP("temp=%x",temp);
+  WriteReg(iPortAddr,WEBCAMERA_REG_DATA_TYPE, 0x1);
+  WriteReg(iPortAddr,WEBCAMERA_REG_DMA_ADDR,temp);
+  WriteReg(iPortAddr,WEBCAMERA_REG_DMA_SIZE, aSize);
+  WriteReg(iPortAddr,WEBCAMERA_REG_INT_ENABLE, 0x1);
+  Interrupt::Enable(iIrq);
+  
+  DP("DWebcameraDriver::StartCapture END"); 
+  return KErrNone;
+}
+
+void DWebcameraDriver::Stop(TUSBStopMode aMode)
+{
+  DP("DWebcameraDriver::Stop start");
+  WriteReg(iPortAddr, WEBCAMERA_REG_INT_ENABLE, 0x0);
+  Interrupt::Disable(iIrq);
+  DP("DWebcameraDriver::Stop end");
+}
+
+void DWebcameraDriver::Isr(TAny* aPtr)
+{
+  DP("DWebcameraDriver::Isr start");
+  ((DWebcameraDriver*)aPtr)->receivedatacallback();
+  DP("DWebcameraDriver::Isr end");
+}
+
+void DWebcameraDriver::receivedatacallback()
+{
+  DP("DWebcameraDriver::receivedatacallback start");
+  TInt datasize=ReadReg(iPortAddr,WEBCAMERA_REG_DMA_SIZE);
+  switch (iType)
+	  {
+	  case 0:
+		  iLdd->GetOneFlameComplete(datasize);
+		  break;
+	  case 1:
+		  iLdd->CaptureComplete(datasize);
+		  break;
+	  default:
+		  //
+	  }
+  WriteReg(iPortAddr,WEBCAMERA_REG_DMA_ADDR, 0);
+  WriteReg(iPortAddr,WEBCAMERA_REG_DMA_SIZE, 0);
+  WriteReg(iPortAddr,WEBCAMERA_REG_INT_ENABLE, 0x0);
+  DP("DWebcameraDriver::receivedatacallback end");	  
+}
+
+// ---------------------------------------------------------------
+// ---------------------------------------------------------------
+
+DECLARE_STANDARD_PDD()
+{
+  DP("DECLARE_STANDARD_PDD()");
+  return new DWebcameraPddFactory;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/baseport/syborg/webcamera/webcamera_pdd.h	Wed Mar 24 13:46:59 2010 +0900
@@ -0,0 +1,120 @@
+/*
+* 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__
+
+#include <comm.h>
+#include <e32hal.h>
+#include "system.h"
+#include "webcamera_device.h"
+
+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:
+	/**
+	  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);
+    /**
+      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(TUint aBuffer,TInt aSize);
+    /**
+      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 StartCapture(TUint aBuffer,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);
+//	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();
+
+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
+	    };
+
+private:
+    /**
+    operation types.
+    */
+	TInt iType;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/baseport/syborg/webcamera/webcamera_pdd.mmp	Wed Mar 24 13:46:59 2010 +0900
@@ -0,0 +1,41 @@
+/*
+* 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:
+*
+*/
+
+#include <variant.mmh>
+#include "kernel/kern_ext.mmh"
+
+TARGET			VariantTarget(webcamera,pdd)
+linkas			webcamera.pdd
+TARGETTYPE		pdd
+
+SYSTEMINCLUDE   /epoc32/include/drivers
+SYSTEMINCLUDE   /epoc32/include/platform/drivers
+SYSTEMINCLUDE	AsspNKernIncludePath
+
+SOURCEPATH		.
+SOURCE			webcamera_pdd.cpp
+
+LIBRARY			PlatformLib
+
+EPOCALLOWDLLDATA
+
+UID				0x100039d0 0x1020044D  //TODO:修正する必要
+//VENDORID        0x70000001
+
+//ROMTARGET		webcamera.pdd
+
+CAPABILITY		all
--- a/symbian-qemu-0.9.1-12/qemu-symbian-svp/plugins/qemu_arm_plugins.py	Wed Mar 17 11:58:43 2010 +0000
+++ b/symbian-qemu-0.9.1-12/qemu-symbian-svp/plugins/qemu_arm_plugins.py	Wed Mar 24 13:46:59 2010 +0900
@@ -5,3 +5,4 @@
 import syborg_timer
 import syborg_keyboard
 import syborg_pointer
+import syborg_usbtest
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/symbian-qemu-0.9.1-12/qemu-symbian-svp/plugins/syborg_usbtest.py	Wed Mar 24 13:46:59 2010 +0900
@@ -0,0 +1,113 @@
+import qemu
+import os
+
+class syborg_usbtest(qemu.devclass):
+  REG_ID           = 0
+  REG_INT_ENABLE   = 1
+  REG_DATA_TYPE    = 2
+  REG_DMA_ADDR     = 3
+  REG_DMA_SIZE     = 4
+
+  def loadIMG(self):
+    self.buf = open('test1.BMP','rb').read()
+    self.bufC = open('test.BMP','rb').read()
+    self.bmpsize = os.path.getsize('test1.BMP')
+    self.Csize = os.path.getsize('test.BMP')
+
+  def timertick(self):
+    if self.cha==0:
+        compSize=self.bmpsize
+        buf=self.buf
+        self.cha=1
+    else:
+        compSize=self.Csize
+        buf=self.bufC
+        self.cha=0
+    if self.dma_size < compSize:
+        self.dma_size = 0
+    else:
+        for x in buf:
+	    ch = ord(x)
+	    if self.dma_size > 0:
+            	self.dma_writeb(self.dma_addr, ch)
+            	self.dma_addr += 1
+		self.dma_size -= 1
+    self.set_irq_level(0, self.int_enable)
+
+  def timer_on(self):
+    self.ptimer = qemu.ptimer(self.timertick, 1)
+    self.ptimer.run(0)
+
+  def timer_off(self):
+    self.ptimer.stop()
+    self.set_irq_level(0, self.int_enable)
+
+  def capturedata(self):
+    if self.dma_size < self.Csize:
+        self.dma_size = 0
+    else:
+        for x in self.bufC:
+	    ch = ord(x)
+	    if self.dma_size > 0:
+            	self.dma_writeb(self.dma_addr, ch)
+            	self.dma_addr += 1
+		self.dma_size -= 1
+    self.set_irq_level(0, self.int_enable)
+
+  def create(self):
+    self.int_enable = 1
+    self.dma_addr = 0
+    self.dma_size =0
+    self.cha=0
+    self.loadIMG()
+
+  def write_reg(self, offset, value):
+    offset >>= 2
+    if offset==self.REG_INT_ENABLE:
+        self.int_enable=value
+        if value==1:
+	    if self.data_type==0:
+                self.timer_on()
+            elif self.data_type==1:
+                self.capturedata()
+        else:
+	    if self.data_type==0:
+           	self.timer_off()
+            elif self.data_type==1:
+	        self.set_irq_level(0, self.int_enable)
+    elif offset == self.REG_DATA_TYPE:
+      self.data_type = value
+    elif offset == self.REG_DMA_ADDR:
+      self.dma_addr = value
+    elif offset == self.REG_DMA_SIZE:
+      self.dma_size = value
+
+  def read_reg(self, offset):
+    offset >>= 2
+    if offset == self.REG_ID:
+      return 0xc600f000
+    elif offset == self.REG_INT_ENABLE:
+      return self.int_enable
+    elif offset == self.REG_DMA_ADDR:
+      return self.dma_addr
+    elif offset == self.REG_DMA_SIZE:
+      return self.dma_size
+    return 0
+
+  def save(self, f):
+    f.put_u32(self.int_enable)
+    f.put_u32(self.dma_addr)
+    f.put_u32(self.dma_size)
+
+  def load(self, f):
+    self.int_enable = f.get_u32()
+    self.dma_addr = f.get_u32()
+    self.dma_size = f.get_u32()
+
+  # Device class properties
+  regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)]
+  irqs = 1
+  name = "syborg,usbtest"
+  properties={"chardev":None}
+
+qemu.register_device(syborg_usbtest)