Obtain an image of Webcamera from QEMU and add the Bitmap change display function.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/baseport/syborg/webcamera/webcamer_convert.cpp Mon Oct 18 19:39:25 2010 +0900
@@ -0,0 +1,184 @@
+/*
+* Copyright (c) 2010 ISB.
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the "Symbian Foundation License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+*
+* Initial Contributors:
+* ISB - Initial contribution
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef WEBCAMERACONVERT_H__
+#include "webcamer_convert.h"
+#endif
+
+#define DP(format...) Kern::Printf(format)
+
+/**
+Constructor.
+*/
+DWebCameraConvert::DWebCameraConvert(TWebcameraUVC* aUvcFormat)
+ {
+ TUint32 wGuid = aUvcFormat->iUVCDescriptor.iFormatDescriptor.iGuid.iData1;
+ switch (wGuid)
+ {
+ case KWebcameraYuy2:
+ //Create object of DWebCameraConvertYuv.
+ iConvertObject = new(ELeave) DWebCameraConvertYuv(aUvcFormat);
+ break;
+ default:
+ break;
+ }
+ }
+
+/**
+Destructor.
+*/
+DWebCameraConvert::~DWebCameraConvert()
+ {
+ delete iConvertObject;
+ }
+
+TInt DWebCameraConvert::ConvertData(TUint8* aInBuf, TUint8* aOutBuf)
+ {
+ return iConvertObject->ConvertData(aInBuf, aOutBuf);
+ }
+
+/**
+Constructor.
+*/
+DWebCameraConvertBase::DWebCameraConvertBase(TWebcameraUVC* aUvcFormat)
+ :iUvcFormat(aUvcFormat)
+ {
+ }
+
+/**
+Destructor.
+*/
+DWebCameraConvertBase::~DWebCameraConvertBase()
+ {
+ }
+
+/**
+Convert FrameData to BitmapData.
+
+@param aInBuf [in] Data to convert.
+ aOutBuf [out] BitmapData after conversion.
+@return KErrNotSupported. Implement in sub-class, return unsupport in base-class.
+*/
+TInt DWebCameraConvertBase::ConvertData(TUint8* /*aInBuf*/, TUint8* /*aOutBuf*/)
+ {
+ return KErrNotSupported;
+ }
+
+/**
+Constructor.
+*/
+DWebCameraConvertYuv::DWebCameraConvertYuv(TWebcameraUVC* aUvcFormat)
+ :DWebCameraConvertBase(aUvcFormat)
+ {
+ }
+
+/**
+Destructor.
+*/
+DWebCameraConvertYuv::~DWebCameraConvertYuv()
+ {
+ }
+
+/**
+Convert FrameData to BitmapData(yuv->Bitmap).
+
+@param aInBuf [in] Data to convert.
+ aOutBuf [out] BitmapData after conversion.
+@return KErrNone.
+*/
+TInt DWebCameraConvertYuv::ConvertData(TUint8* aInBuf, TUint8* aOutBuf)
+ {
+ TUint wInPos = 0; //Declaration to get FrameData before conversion.
+ TUint wOutPos = 0; //Declaration to store BitmapData after conversion.
+ TUint wPixel32 = 0; //Declaration to store data(1pixel32bit) after conversion from yuv to rgb.
+ TInt wY0, wU, wY1, wV; //Declaration to store signal that get from rgb.
+ TUint16 wWidth, wHeight; //Declaration to store width and height from argument aVideoData.
+
+ wWidth = iUvcFormat->iUVCDescriptor.iFrameDescriptor.iWidth; //Store width information from aVideoData.
+ wHeight = iUvcFormat->iUVCDescriptor.iFrameDescriptor.iHeight; //Store height information from aVideoData.
+
+ TUint wImageSize = wWidth * wHeight * 2;
+
+ //Get width and heigth data.
+ for (wInPos = 0; wInPos < wImageSize; wInPos += 4)
+ {
+ //Y16-bit to suitable location of YUYV.
+ wY0 = (static_cast<TUint>(aInBuf[wInPos + 0]) & KWebcameraBitMask);
+ wU = (static_cast<TUint>(aInBuf[wInPos + 1]) & KWebcameraBitMask);
+ wY1 = (static_cast<TUint>(aInBuf[wInPos + 2]) & KWebcameraBitMask);
+ wV = (static_cast<TUint>(aInBuf[wInPos + 3]) & KWebcameraBitMask);
+
+ //Store RGB by wPixel32 format, that was converted from yuv.
+ wPixel32 = ConvertYuvToBitmap(wY0, wU, wV);
+ //Calculate element of RGB from wPixel32.
+ aOutBuf[wOutPos++] = (wPixel32 & KWebcameraBitMask);
+ aOutBuf[wOutPos++] = (wPixel32 & KWebcameraBitMask8) >> 8;
+ aOutBuf[wOutPos++] = (wPixel32 & KWebcameraBitMask16) >> 16;
+
+ //Store RGB by wPixel32 format, that was converetd from yuv.
+ wPixel32 = ConvertYuvToBitmap(wY1, wU, wV);
+ aOutBuf[wOutPos++] = (wPixel32 & KWebcameraBitMask);
+ aOutBuf[wOutPos++] = (wPixel32 & KWebcameraBitMask8) >> 8;
+ aOutBuf[wOutPos++] = (wPixel32 & KWebcameraBitMask16) >> 16;
+ }
+
+ return KErrNone;
+ }
+
+/**
+Convert yuv to rgb.
+
+@param aY [in] Signal of brightness.
+ aU [in] Signal of colour difference(Cb)
+ aV [in] Signal of colour difference(Cr).
+@return pixel.
+*/
+TInt DWebCameraConvertYuv::ConvertYuvToBitmap(TInt aY, TInt aU, TInt aV)
+ {
+ TUint wPixel32 = 0; //Declaration to use still image of wPixel32 format.
+ TUint8* wPixel = static_cast<TUint8*>&wPixel32; //Cast still image of wPixel32 format to 8bit to convert.
+ TInt wR = 0; //Declaration to store still image after conversion.
+ TInt wG = 0;
+ TInt wB = 0;
+
+ //Convert yuv to rgb.
+ wR = aY + ((1370705 * (aV - 128)) / 1000000);
+ wG = aY - ((698001 * (aV - 128)) / 1000000) - ((337633 * (aU - 128)) / 1000000);
+ wB = aY + ((1732446 * (aU - 128)) / 1000000);
+
+ //Define the range of RGB(0~255).
+ if (!(0 <= wR && wR <= 255))
+ {
+ (wR > 255) ? (wR = 255) : (wR = 0);
+ }
+ if (!(0 <= wG && wG <= 255))
+ {
+ (wG > 255) ? (wG = 255) : (wG = 0);
+ }
+ if (!(0 <= wB && wB <= 255))
+ {
+ (wB > 255) ? (wB = 255) : (wB = 0);
+ }
+
+ //Compress RGB.
+ wPixel[0] = (wB * KWebcameraNeutralGrayValue) / KWebcameraColorGradation;
+ wPixel[1] = (wG * KWebcameraNeutralGrayValue) / KWebcameraColorGradation;
+ wPixel[2] = (wR * KWebcameraNeutralGrayValue) / KWebcameraColorGradation;
+
+ return wPixel32;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/baseport/syborg/webcamera/webcamer_convert.h Mon Oct 18 19:39:25 2010 +0900
@@ -0,0 +1,143 @@
+/*
+* Copyright (c) 2010 ISB.
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the "Symbian Foundation License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+*
+* Initial Contributors:
+* ISB - Initial contribution
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef WEBCAMERACONVERT_H__
+#define WEBCAMERACONVERT_H__
+
+#include <e32def.h>
+#include <comm.h>
+#ifndef WEBCAMERA_UVC_H_
+#include "webcamera_uvc.h"
+#endif
+
+const TUint KWebcameraNeutralGrayValue = 220;
+const TUint KWebcameraColorGradation = 256; // true color.
+const TUint KWebcameraBitMask = 0x000000ff;
+const TUint KWebcameraBitMask8 = 0x0000ff00;
+const TUint KWebcameraBitMask16 = 0x00ff0000;
+
+/**
+Perform a Convert function Base.
+*/
+class DWebCameraConvertBase : public DBase
+ {
+public:
+ /**
+ Constructor.
+ */
+ DWebCameraConvertBase(TWebcameraUVC* aUvcFormat);
+
+ /**
+ Destructor.
+ */
+ ~DWebCameraConvertBase();
+public: //virtual function.
+ /**
+ Convert FrameData to Bitmap.
+
+ @param aInBuf [in] FrameData before conversion.
+ aOutBuf [out] BimapData after conversion.
+ @return KErrNotSupported. Implement in sub-class, return unsupport in base-class.
+ */
+ virtual TInt ConvertData(TUint8* aInBuf, TUint8* aOutBuf);
+
+protected:
+ TWebcameraUVC* iUvcFormat;
+ };
+
+/**
+Perform a Convert function (Yuv -> Bitmap).
+*/
+class DWebCameraConvertYuv : public DWebCameraConvertBase
+ {
+public:
+ /**
+ Create object.
+ @return Pointer of object.
+ */
+ static DWebCameraConvertYuv* NewL();
+
+ /**
+ Constructor.
+ */
+ DWebCameraConvertYuv(TWebcameraUVC* aUvcFormat);
+
+ /**
+ Destructor.
+ */
+ ~DWebCameraConvertYuv();
+
+public: //from DWebCameraConvertBase
+ /**
+ Convert FrameData to Bitmap(YUV->Bitmap).
+
+ @param aInBuf [in] FrameData before conversion.
+ aOutBuf [out BitmapData after conversion.
+ @return KErrNone.
+ */
+ TInt ConvertData(TUint8* aInBuf, TUint8* aOutBuf);
+private:
+ /**
+ Secondary constructor.
+ */
+ void ConstructL();
+
+ /**
+ Convert YUV to RGB.
+
+ @param aY [in] Signal of brightness.
+ aU [in] Signal of colour difference(Cb).
+ aV [in] Signal of colour difference(cr).
+ @return Pixel.
+ */
+ TInt ConvertYuvToBitmap(TInt aY, TInt aU, TInt aV);
+ };
+
+/**
+Convert function
+*/
+class DWebCameraConvert : public DBase
+ {
+public:
+ /**
+ Constructor.
+ */
+ DWebCameraConvert(TWebcameraUVC* aUvcFormat);
+
+ /**
+ Destructor.
+ */
+ ~DWebCameraConvert();
+
+ /**
+ Decide video format, by video format from UVC class.
+
+ @param aInBuf [in] Data to convert.
+ aOutBuf [out] BitmapData after conversion.
+ aVideoData [in] Format data of Video.
+ @return KErrNone
+ */
+ TInt ConvertData(TUint8* aInBuf, TUint8* aOutBuf);
+
+private:
+ /**
+ Store the instance.
+ */
+ DWebCameraConvertBase* iConvertObject;
+ };
+
+#endif // ECAMWEBCAMERACONVERT_H
--- a/baseport/syborg/webcamera/webcamera_app.cpp Wed Mar 24 13:46:59 2010 +0900
+++ b/baseport/syborg/webcamera/webcamera_app.cpp Mon Oct 18 19:39:25 2010 +0900
@@ -14,7 +14,6 @@
* Description: USB driver for test
*
*/
-
#include <e32test.h>
#include <webcamera_driver.h>
@@ -23,93 +22,94 @@
LOCAL_D RTest test(_L("WebcameraDevice_TEST"));
-//Wins用ダミーなので実機では正式なものを使用する
+//Dummy environment for 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.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("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("Open Logical Channel"));
+ RWebcameraDevice ldd;
+ r = ldd.Open();
+ 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 sharedChunk"));
+ RChunk Chunk;
+ RWebcameraDevice::TChunkInfo ChunkInfo;
+ r = ldd.OpenSharedChunks(Chunk,ChunkInfo);
+ DP("ChunkHandle = %d",ChunkInfo.iChunkHandle);
+ DP("Chunk.Handle() = %d",Chunk.Handle());
+ DP("r = %d",r);
+ test(r == KErrNone);
- test.Next(_L("Check access by wrong client"));
- RWebcameraDevice ldd2=ldd;
- r=ldd2.Duplicate(RThread(),EOwnerProcess);
- test(r==KErrAccessDenied);
+ if (Chunk.IsReadable())
+ {
+ DP("mapped into its process address space");
+ }
+ 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("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("ReceiveData"));
+ TRequestStatus status;
+ TInt size = 0;
+ ldd.StartViewFinder(status,size);
+ DP("size = %d",size);
+
+ test.Next(_L("ReceiveDataCancel"));
+ ldd.StopViewFinder();
+ User::WaitForRequest(status);
+ r = status.Int();
+ test(r == KErrNone);
+ size = 0;
+ ldd.StartViewFinder(status,size);
+ User::WaitForRequest(status);
+ r = status.Int();
+ test(r == KErrNone);
- 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();
+ test.Next(_L("CaptureData"));
+ TInt size1 = 0;
+ ldd.Capture(status,size1);
+ User::WaitForRequest(status);
+ r = status.Int();
+ test(r == KErrNone);
+
+ test.Next(_L("Close Logical Channel"));
+ ldd.Close();
+
+// __KHEAP_MARKEND;
-// __KHEAP_MARKEND;
-
- test.Next(_L("Unload Logical Device"));
- r=User::FreeLogicalDevice(RWebcameraDevice::Name());
- test(r==KErrNone);
+ 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();
+ test.Next(_L("Unload Physical Device"));
+ TName pddName(RWebcameraDevice::Name());
+ _LIT(KVariantExtension,".pdd");
+ pddName.Append(KVariantExtension);
+ r = User::FreePhysicalDevice(pddName);
+ test(r == KErrNone);
- return(0);
- }
+ test.End();
+
+ return(0);
+ }
--- a/baseport/syborg/webcamera/webcamera_app.mmp Wed Mar 24 13:46:59 2010 +0900
+++ b/baseport/syborg/webcamera/webcamera_app.mmp Mon Oct 18 19:39:25 2010 +0900
@@ -18,15 +18,15 @@
TARGET webcamera_app.exe
TARGETTYPE exe
-//UID 0x1000008d 0x101F399B //TODO:修正する必要
-VENDORID 0x70000001
+//UID 0x1000008d 0x101F399B
+VENDORID 0x70000001
CAPABILITY DISKADMIN ALLFILES
-SYSTEMINCLUDE /epoc32/include
-SYSTEMINCLUDE /epoc32/include/platform
+SYSTEMINCLUDE /epoc32/include
+SYSTEMINCLUDE /epoc32/include/platform
SOURCEPATH .
SOURCE webcamera_app.cpp
-LIBRARY euser.lib
\ No newline at end of file
+LIBRARY euser.lib
--- a/baseport/syborg/webcamera/webcamera_device.h Wed Mar 24 13:46:59 2010 +0900
+++ b/baseport/syborg/webcamera/webcamera_device.h Mon Oct 18 19:39:25 2010 +0900
@@ -24,71 +24,76 @@
class DWebcameraLogicalChannelBase : public DLogicalChannel
-{
+ {
public:
/**
- Called by PDD from ISR to indicate that a get oneflame operation has completed.
+ 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.
- */
+ virtual void GetOneFlameComplete(TInt aResult) = 0;
/**
call to the function if one Capture image is received.
*/
- virtual void DoCaptureComplete()=0;
-
+ virtual void DoCaptureComplete() = 0;
+
public:
- /**
- * pointer to client.
- */
- DThread* iClient;
-};
+ /**
+ 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
+ /**
+ Enumeration of stop modes.
+ */
+ enum TUSBStopMode
+ {
+ USB_ViewerFinder = 0,
+ USB_capture = 1,
+ USB_cancel = 2
+ };
+
+ /**
+ PowerOn.
+ */
+ virtual TInt PowerOn(TAny* aHeaderPtr) = 0;
+
+ /**
+ InitViewFinder.
+ */
+ virtual TInt InitViewFinder() = 0;
+
+ /**
+ request.
+ */
+ virtual TInt StartViewerFinder(TAny* aDataPtr, TInt aSize) = 0;
+
+ /**
+ Enumeration of stop modes.
+ */
+ virtual void Stop(TUSBStopMode aMode) = 0;
+
+ /**
+ */
+ virtual void Disconnect() = 0;
+
+//virtual void Caps(TDes8 &aCaps) const;
+
+public:
+ /**
+ pointer to logic channel.
+ */
+ DWebcameraLogicalChannelBase* iLdd;
+ /**
+ Linear Addresses of Peripherals.
+ */
+ TLinAddr iPortAddr;
+ /**
+ interrupt number.
+ */
+ TInt iIrq;
};
- /**
- 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
--- a/baseport/syborg/webcamera/webcamera_driver.h Wed Mar 24 13:46:59 2010 +0900
+++ b/baseport/syborg/webcamera/webcamera_driver.h Mon Oct 18 19:39:25 2010 +0900
@@ -18,125 +18,186 @@
#define __deviceIF_H__
#include <e32cmn.h>
-#include <e32ver.h>
+#ifndef __KERNEL_MODE__
+#include <e32std.h>
+#endif
-#define BUFSIZE (100*1024)
+#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:
- /**
- 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;
+ /**
+ 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:
- /**
- 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.
+ /**
+ 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
+ };
- @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;
- };
+ // Kernel side LDD channel is a friend
+ friend class DWebcameraLogicalChannel;
+ };
// Inline functions
#include <webcamera_driver.inl>
--- a/baseport/syborg/webcamera/webcamera_driver.inl Wed Mar 24 13:46:59 2010 +0900
+++ b/baseport/syborg/webcamera/webcamera_driver.inl Mon Oct 18 19:39:25 2010 +0900
@@ -19,121 +19,165 @@
#define __deviceIFI_H
/**
- Returns the driver's name
+Returns the driver's name
*/
inline const TDesC& RWebcameraDevice::Name()
- {
- _LIT(KDriverName,"WebcameraDevice");
- return KDriverName;
- }
+ {
+ _LIT(KDriverName,"WebcameraDevice");
+ return KDriverName;
+ }
/**
- Returns the version number of the driver
+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);
- }
+ {
+ 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.
+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
+Opens a logical channel to the driver
- @return One of the system wide error codes.
+@return One of the system wide error codes.
*/
inline TInt RWebcameraDevice::Open()
- {
- return DoCreate(Name(),VersionRequired(),KNullUnit,NULL,NULL,EOwnerThread);
- }
+ {
+ return DoCreate(Name(), VersionRequired(), KNullUnit, NULL, NULL, EOwnerThread);
+ }
/**
- Gets the current configuration settings.
+Gets the current configuration settings.
- @param aConfig A structure which will be filled with the configuration settings.
-
- @return KErrNone
+@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);
- }
+ {
+ return DoControl(EGetConfig, (TAny*)&aConfig);
+ }
/**
- Sets the current configuration settings.
-
- @param aConfig The new configuration settings to be used.
+Sets the current configuration settings.
- @return KErrInUse if there are outstanding data transfer requests.
- KErrArgument if any configuration values are invalid.
- KErrNone otherwise
+@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);
- }
+ {
+ return DoControl(ESetConfig, (TAny*)&aConfig);
+ }
+
+/**
+Open shared chunks
+*/
+inline TInt RWebcameraDevice::OpenSharedChunks(RChunk& aChunk, TChunkInfo& aChunkInfo)
+ {
+ TInt r = DoControl(EOpenSharedChunck, (TAny*)&aChunkInfo);
+ aChunk.SetHandle(aChunkInfo.iChunkHandle);
+ return r;
+ }
+
+/**
+Close shared chunks
+*/
+inline TInt RWebcameraDevice::CloseSharedChunks(TRequestStatus& aStatus, RChunk& aChunk)
+ {
+ DoRequest(ECloseSharedChunck,aStatus, (TAny*)&aChunk);
+ }
/**
- Receives image from the device.
- Only one receive request may be pending at any time.
+Power on Camera Device.
+@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.
+*/
+inline void RWebcameraDevice::PowerOn(TRequestStatus& aStatus)
+ {
+ DoRequest(EPowerOn, aStatus);
+ }
+
+/**
+Power off Camera Device.
+@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.
+*/
+inline void RWebcameraDevice::PowerOff(TRequestStatus& aStatus)
+ {
+ DoRequest(EPowerOff, aStatus);
+ }
- @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.
+/**
+Init ViewFinder.
*/
-inline void RWebcameraDevice::StartViewFinder(TRequestStatus& aStatus,TDes8& aBuffer)
- {
- TInt length=BUFSIZE;
- DoRequest(EStart,aStatus,(TAny*)&aBuffer,(TAny*)&length);
- }
+inline TInt RWebcameraDevice::InitViewFinder()
+ {
+ return DoControl(EInitViewFinder, NULL);
+ }
+
+/**
+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,TInt& aChunkLen)
+ {
+ DoRequest(EStart,aStatus, (TAny*)&aChunkLen);
+ }
/**
- Cancels a previous StartViewFinder request.
+Cancels a previous StartViewFinder request.
*/
inline void RWebcameraDevice::StartViewFinderCancel()
- {
- DoCancel(1<<EStart);
- }
+ {
+ DoCancel(1 << EStart);
+ }
inline void RWebcameraDevice::StopViewFinder()
{
- DoCancel(1<<EStart);
+ DoCancel(1 << EStart);
}
/**
- Capture data from the device.
- Only one Capture request may be pending at any time.
+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.
+@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);
- }
+inline void RWebcameraDevice::Capture(TRequestStatus& aStatus,TInt& aChunkLen)
+ {
+ DoRequest(ECapture,aStatus, (TAny*)&aChunkLen);
+ }
/**
- Cancels a previous capture request.
+Cancels a previous capture request.
*/
inline void RWebcameraDevice::CaptureCancel()
- {
- DoCancel(1<<ECapture);
- }
+ {
+ DoCancel(1 << ECapture);
+ }
#endif // !__KERNEL_MODE__
#endif
--- a/baseport/syborg/webcamera/webcamera_ldd.cpp Wed Mar 24 13:46:59 2010 +0900
+++ b/baseport/syborg/webcamera/webcamera_ldd.cpp Mon Oct 18 19:39:25 2010 +0900
@@ -17,46 +17,44 @@
#include <kern_priv.h>
#include "webcamera_ldd.h"
-#include <webcamera_driver.h>
#define DP(format...) Kern::Printf(format)
_LIT(KDriver1PanicCategory,"WebcameraDevice");
/**
- *Create Logic device.
- *
+Create Logic device.
*/
DECLARE_STANDARD_LDD()
{
- DP("DECLARE_STANDARD_LDD()");
- return new DWebcameraLogicalDevice;
+ DP("DECLARE_STANDARD_LDD()");
+ return new DWebcameraLogicalDevice;
}
/**
- Constructor
+Constructor
*/
DWebcameraLogicalDevice::DWebcameraLogicalDevice()
{
DP("DWebcameraLogicalDevice()");
- // Set version number for this device
- iVersion=RWebcameraDevice::VersionRequired();
- // Indicate that we work with a PDD
- iParseMask=KDeviceAllowPhysicalDevice;
+ // Set version number for this device
+ iVersion = RWebcameraDevice::VersionRequired();
+ // Indicate that we work with a PDD
+ iParseMask = KDeviceAllowPhysicalDevice;
}
/**
- Destructor
+Destructor
*/
DWebcameraLogicalDevice::~DWebcameraLogicalDevice()
{
}
/**
- Second stage constructor for DDriver1Factory.
- This must at least set a name for the driver object.
+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.
+@return KErrNone if successful, otherwise one of the other system wide error codes.
*/
TInt DWebcameraLogicalDevice::Install()
{
@@ -66,521 +64,569 @@
}
/**
- Return the drivers capabilities.
- Called in the response to an RDevice::GetCaps() request.
+Return the drivers capabilities.
+Called in the response to an RDevice::GetCaps() request.
- @param aDes User-side descriptor to write capabilities information into
+@param aDes User-side descriptor to write capabilities information into
*/
void DWebcameraLogicalDevice::GetCaps(TDes8& aDes) const
{
- // Create a capabilities object
+ // Create a capabilities object
RWebcameraDevice::TCaps caps;
- caps.iVersion = iVersion;
- // Write it back to user memory
- Kern::InfoCopy(aDes,(TUint8*)&caps,sizeof(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.
+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.
+@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)
+ if (!aChannel)
+ {
return KErrNoMemory;
+ }
+ DP("DWebcameraLogicalDevice::Create() end");
return KErrNone;
- DP("DWebcameraLogicalDevice::Create() end");
}
/**
- Constructor
+Constructor
*/
DWebcameraLogicalChannel::DWebcameraLogicalChannel()
- : iReceiveDataDfc(GetOneFlameDfc, this, 1)
- ,iCaptureDfc(CaptureDfc,this,1)
+ : iReceiveDataDfc(GetFlameDfc, 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.
+ // 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();
-
+ iWebCameraState = RWebcameraDevice::EPowerOff;
+
DP("DWebcameraLogicalChannel::DWebcameraLogicalChannel() end");
}
/**
- Destructor
+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);
+ // Cancel all processing that we may be doing
+ DoCancel(RWebcameraDevice::EAllRequests);
+ // Close sharedchunks
+ CloseSharedChunks();
+ // Close our reference on the client thread
+ Kern::SafeClose((DObject*&)iClient, NULL);
+
+ delete iConvert;
+
+ // Buffer Free.
+ Kern::Free(iHeaderPtr);
+ Kern::Free(iDataPtr);
+ Kern::Free(iBmpBuf);
DP("DWebcameraLogicalChannel::~DWebcameraLogicalChannel() end");
}
/**
- Called when a user thread requests a handle to this channel.
+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;
- }
+ {
+ // 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.
+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
+@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.
+@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))
+ 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
+ // 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
+ //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)
+ //Give PDD a pointer to this channel
+ Pdd()->iLdd = this;
+ // Create shared chunk.
+ TInt rtn = CreatSharedChunks();
+ if (rtn)
{
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.
+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
+@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;
+ 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)
+ // 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)
+ if (m.Client() != iClient)
{
Kern::ThreadKill(m.Client(),
EExitPanic,
ERequestFromWrongThread,
KDriver1PanicCategory);
- m.Complete(KErrNone,ETrue);
+ m.Complete(KErrNone, ETrue);
+ return;
+ }
+
+ if (id == KMaxTInt)
+ {
+ DoCancel(m.Int0());
+ m.Complete(KErrNone, ETrue);
return;
}
- if (id==KMaxTInt)
- {
- DoCancel(m.Int0());
- m.Complete(KErrNone,ETrue);
- return;
- }
-
- if (id<0)
+ if (id < 0)
{
// DoRequest
- TRequestStatus* pS=(TRequestStatus*)m.Ptr0();
- TInt rtn =DoRequest(~id,pS,m.Ptr1(),aMsg);
+ 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);
+ {
+ Kern::RequestComplete(iClient, pS, rtn);
+ }
+ m.Complete(KErrNone, ETrue);
}
else
{
// DoControl
- TInt rtn = DoControl(id,m.Ptr0(),aMsg);
- m.Complete(rtn,ETrue);
+ TInt rtn = DoControl(id, m.Ptr0(), aMsg);
+ m.Complete(rtn, ETrue);
}
DP("DWebcameraLogicalChannel::HandleMsg() end");
}
/**
- Process synchronous 'control' requests
+Process synchronous 'control' requests
*/
-TInt DWebcameraLogicalChannel::DoControl(TInt aFunction, TAny* a1, TAny* a2)
+TInt DWebcameraLogicalChannel::DoControl(TInt aFunction, TAny* a1, TAny* /*a2*/)
{
DP("DWebcameraLogicalChannel::DoControl() start");
TInt rtn;
- TThreadMessage& m=*(TThreadMessage*)a2;
- TRequestStatus* pS=(TRequestStatus*)m.Ptr0();
+ rtn = KErrNone;
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;
-
+// rtn = SetConfig((const TDesC8*)a1);
+ break;
+ case RWebcameraDevice::EOpenSharedChunck:
+ rtn=OpenSharedChunks((RWebcameraDevice::TChunkInfo*)a1);
+ break;
+ case RWebcameraDevice::EInitViewFinder:
+ rtn = Pdd()->InitViewFinder();
+ iDataPtr = Kern::Alloc(BUFSIZE);
+ iBmpBuf = (TUint8*)Kern::Alloc(BITMAPBUFSIZE);
+ break;
default:
rtn = KErrNotSupported;
- Kern::RequestComplete(iClient,pS,rtn);
break;
}
DP("DWebcameraLogicalChannel::DoControl() end");
return rtn;
-
}
/**
- Process asynchronous requests.
+Process asynchronous requests.
*/
TInt DWebcameraLogicalChannel::DoRequest(TInt aReqNo,
TRequestStatus* aStatus,
TAny* a1,
- TAny* a2)
+ TAny* /*a2*/)
{
- DP("DWebcameraLogicalChannel::DoRequest() start");
TInt rtn;
- TThreadMessage& m=*(TThreadMessage*)a2;
+ iRequesting = ETrue;
+ rtn = KErrNone;
- iRequesting =ETrue;
- rtn = KErrNone;
- DP("aReqNo=%d",aReqNo);
- switch(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 )
+ iReceiving = ETrue;
+ iWebCameraState = RWebcameraDevice::EStart;
+ iReceiveDataDfc.Add();
+ // Example Platform Security capability check which tests the
+ // client for ECapability_None (which always passes)...
+ if (iRequesting == EFalse)
{
- DP("rtn=%d",rtn);
- iReceiving = EFalse ;
- Kern::RequestComplete(iClient,aStatus,rtn);
+ iReceiving = EFalse;
+ Kern::RequestComplete(iClient,
+ iReceiveDataStatus,
+ iReceiveDataResult);
+ }
+ else
+ {
+ iReceiveDataDescriptor = (TInt*)a1;
+ }
+ break;
+ case RWebcameraDevice::ECapture:
+ iCaptureStatus = aStatus;
+ iWebCameraState = RWebcameraDevice::ECapture;
+ iCaptureDfc.Add();
+ if (iRequesting == EFalse)
+ {
+ Kern::RequestComplete(iClient, iCaptureStatus, iCaptureResult);
}
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;
- }
+ iCaptureDescriptor=(TInt*)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 )
+ case RWebcameraDevice::EPowerOn:
+ if (iPowerOn == EFalse)
{
- iCaptureing = EFalse ;
- Kern::RequestComplete(iClient,aStatus,rtn);
+ iPowerOn = ETrue;
+ iWebCameraState = RWebcameraDevice::EPowerOn;
+ iHeaderPtr = Kern::Alloc(sizeof(TWebcameraUVC));
+ rtn = Pdd()->PowerOn(iHeaderPtr);
+ 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;
- }
+ Kern::RequestComplete(iClient, aStatus, KErrAlreadyExists);
}
break;
+ case RWebcameraDevice::EPowerOff:
+ Pdd()->Disconnect();
+ iPowerOn = EFalse;
+ iReceiving = EFalse;
+ iReceiveDataDfc.Cancel();
+ iCaptureDfc.Cancel();
+ iWebCameraState = RWebcameraDevice::EPowerOff;
+ Kern::RequestComplete(iClient, aStatus, rtn);
+ break;
default:
- rtn=KErrNotSupported;
- Kern::RequestComplete(iClient,aStatus,rtn);
+ rtn = KErrNotSupported;
+ Kern::RequestComplete(iClient, aStatus, rtn);
break;
}
iRequesting = EFalse;
-
- DP("DWebcameraLogicalChannel::DoRequest() end");
return rtn;
-
}
/**
- Process cancelling of asynchronous requests.
+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))
- {
+ if (aMask & (1 << RWebcameraDevice::EStart))
+ {
DP("RWebcameraDevice::EStart=%d",RWebcameraDevice::EStart);
if (iReceiveDataStatus)
{
DP("iReceiveDataStatus=%d",iReceiveDataStatus);
Pdd()->Stop(DWebcameraDriverBase::USB_cancel);
- iReceiving = EFalse ;
+ iReceiving = EFalse;
iReceiveDataDfc.Cancel();
- Kern::RequestComplete(iClient,iReceiveDataStatus,KErrCancel);
+ Kern::RequestComplete(iClient, iReceiveDataStatus, KErrCancel);
}
- }
- if (aMask&(1<<RWebcameraDevice::ECapture))
- {
+ }
+ 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);
+ Kern::RequestComplete(iClient, iCaptureStatus, KErrCancel);
}
- }
+ }
DP("DWebcameraLogicalChannel::DoCancel() end");
}
/**
- Called by PDD from ISR to indicate that a ReceiveData operation has completed.
+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");
- }
+ {
+ iSaveSize = iSize - aDataSize;
+ // Queue DFC
+ iWebCameraState = RWebcameraDevice::ETransferData;
+ iReceiveDataDfc.Add();
+ //set size of received data
+ if (iSaveSize > 0)
+ {
+ iReceiveDataResult = KErrNone;
+ }
+ else
+ {
+ iReceiveDataResult = KErrUnknown; //TODO:define of error
+ }
+ }
+
+void DWebcameraLogicalChannel::DoStartViewFinder()
+ {
+ TInt rtn = Pdd()->StartViewerFinder(iDataPtr, BUFSIZE);
+ if (rtn != KErrNone)
+ {
+ DP("rtn=%d",rtn);
+ iReceiving = EFalse;
+ Kern::RequestComplete(iClient, iReceiveDataStatus, rtn);
+ }
+ }
+/**
+DFC Callback which gets triggered after the PDD has signalled that getting oneflame completed.
+This just casts aPtr and calls DoGetOneFlameComplete().
+*/
+void DWebcameraLogicalChannel::GetFlameDfc(TAny* aPtr)
+ {
+ switch (((DWebcameraLogicalChannel*)aPtr)->iWebCameraState)
+ {
+ case RWebcameraDevice::EStart:
+ ((DWebcameraLogicalChannel*)aPtr)->DoStartViewFinder();
+ break;
+ case RWebcameraDevice::ETransferData:
+ ((DWebcameraLogicalChannel*)aPtr)->DoGetOneFlameComplete();
+ break;
+ default:
+ break;
+ }
+ }
+/**
+DFC Callback
+gets 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 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.
+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;
+ {
+ if (!iConvert)
+ {
+ iConvert = new DWebCameraConvert((TWebcameraUVC*)iHeaderPtr);
+ }
+
+ iConvert->ConvertData((TUint8*)iDataPtr, iBmpBuf);
+ kumemget((TAny*)(iChunkLinAddr), iBmpBuf, iSaveSize);
+
+ TInt result = Kern::ThreadRawWrite(iClient, iReceiveDataDescriptor, &iSaveSize,sizeof(TInt), 0);
- // 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");
- }
+ // 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);
+ }
/**
- Called from a DFC after the PDD has signalled that getting Capture image completed.
+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;
+
+ TInt result = Kern::ThreadRawWrite(iClient, iCaptureDescriptor, &iSaveSize, sizeof(TInt), 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);
+ // 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.
+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
- }
+ return KErrNotSupported;
+ }
/**
- Process a SetConfig control message. This sets the driver configuration using a
- RWebcameraDevice::TConfigBuf supplied by the client.
+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
- }
+ return KErrNotSupported;
+ }
/**
- Fill a TConfig with the drivers current configuration.
+Fill a TConfig with the drivers current configuration.
*/
/*void DWebcameraLogicalChannel::CurrentConfig(RWebcameraDevice::TConfig& aConfig)
- {
+ {
//unsupported
- }
+ }
*/
+TInt DWebcameraLogicalChannel::CreatSharedChunks()
+ {
+ DP("DWebcameraLogicalChannel::CreatSharedChunks() start");
+
+ iChunk=NULL;
+
+ NKern::ThreadEnterCS();
+
+ iSize = Kern::RoundToPageSize(BITMAPBUFSIZE);
+
+ TChunkCreateInfo info;
+ info.iType = TChunkCreateInfo::ESharedKernelMultiple;
+ info.iMaxSize = iSize;
+ info.iMapAttr = EMapAttrFullyBlocking;
+ info.iOwnsMemory = ETrue;
+ info.iDestroyedDfc = NULL;
+ TInt r = Kern::ChunkCreate(info, iChunk, iChunkLinAddr, iChunkMappingAttr);
+ if (r != KErrNone)
+ {
+ NKern::ThreadLeaveCS();
+ return r;
+ }
+ iPhysAddr = 0x0;
+ r = Kern::ChunkCommitContiguous(iChunk, 0, iSize, iPhysAddr);
+
+ if (r != KErrNone)
+ {
+ Kern::ChunkClose(iChunk);
+ NKern::ThreadLeaveCS();
+ return r;
+ }
+ NKern::ThreadLeaveCS();
+
+ DP("DWebcameraLogicalChannel::CreatSharedChunks() end");
+ return KErrNone;
+ }
+
+TInt DWebcameraLogicalChannel::OpenSharedChunks(RWebcameraDevice::TChunkInfo* aChunkInfo)
+ {
+ DP("DWebcameraLogicalChannel::OpenSharedChunks() start");
+ RWebcameraDevice::TChunkInfo chunkInfo;
+ NKern::ThreadEnterCS();
+ // Make handle to chunifo for current thread
+ TInt r = Kern::MakeHandleAndOpen(iClient, iChunk);
+ if (r >= 0)
+ {
+ chunkInfo.iChunkHandle = r;
+ r = KErrNone;
+ }
+
+ NKern::ThreadLeaveCS();
+
+ if (r != KErrNone)
+ {
+ memclr(&chunkInfo,sizeof(chunkInfo));
+ }
+ TInt result = Kern::ThreadRawWrite(iClient, aChunkInfo, &chunkInfo, sizeof(chunkInfo), 0);
+
+ DP("DWebcameraLogicalChannel::OpenSharedChunks() end");
+ return r;
+ }
+
+void DWebcameraLogicalChannel::ChunkDestroyed()
+ {
+ DP("DWebcameraLogicalChannel::ChunkDestroyed() start");
+ //unsupported
+ DP("DWebcameraLogicalChannel::ChunkDestroyed() end");
+ }
+
+void DWebcameraLogicalChannel::CloseSharedChunks()
+ {
+ DP("DWebcameraLogicalChannel::CloseSharedChunks() start");
+ if (iChunk)
+ {
+ Kern::ChunkClose(iChunk);
+ }
+ DP("DWebcameraLogicalChannel::CloseSharedChunks() end");
+ }
+
/**
- *Get the point to Physical channel.
+Get the point to Physical channel.
*/
DWebcameraDriverBase* DWebcameraLogicalChannel::Pdd()
{
DP("DWebcameraLogicalChannel::Pdd() start");
return (DWebcameraDriverBase*)iPdd;
}
-
--- a/baseport/syborg/webcamera/webcamera_ldd.h Wed Mar 24 13:46:59 2010 +0900
+++ b/baseport/syborg/webcamera/webcamera_ldd.h Mon Oct 18 19:39:25 2010 +0900
@@ -19,224 +19,299 @@
#include <kernel.h>
#include "webcamera_device.h"
-
-#define BUFSIZE (100*1024)
+#include <webcamera_driver.h>
+#ifndef WEBCAMERA_UVC_H_
+#include "webcamera_uvc.h"
+#endif
+#ifndef WEBCAMERACONVERT_H__
+#include "webcamer_convert.h"
+#endif
/**
- *Logical channel class
- *
- */
+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.
+ /**
+ 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.
+ @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 aDes User-side descriptor to write capabilities information into
+ */
+ virtual void GetCaps(TDes8& aDes) const;
- @param aChannel Set to point to the created Logical Channel
+ /**
+ 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.
- @return KErrNone if successful, otherwise one of the other system wide error codes.
- */
- virtual TInt Create(DLogicalChannelBase*& aChannel);
+ @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);
};
/**
- *
- * 論理チャネルベースクラス
- *
- * 本クラスは、論理チャネル機能を提供する。
- *
- * @
- * @
- *
- */
+Logical channel base-class.
+
+This class provides functions of Logical Channel.
+*/
class DWebcameraLogicalChannel : public DWebcameraLogicalChannelBase
{
public:
/**
- Constructor
+ Constructor
*/
DWebcameraLogicalChannel();
+
/**
- Destructor
+ Destructor
*/
~DWebcameraLogicalChannel();
+
/**
- Called when a user thread requests a handle to this channel.
+ 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.
+ virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
- @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
+ /**
+ 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.
- @return KErrNone if successful, otherwise one of the other system wide error codes.
- */
+ @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
+ /**
+ 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
+ Process synchronous 'control' requests
*/
virtual TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
+
/**
- Process asynchronous requests.
+ Process asynchronous requests.
*/
virtual TInt DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2);
+
/**
- Process cancelling of asynchronous requests.
+ Process cancelling of asynchronous requests.
*/
virtual void DoCancel(TUint aMask);
+
/**
- Called by PDD from ISR to indicate that a get oneflame operation has completed.
+ 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().
*/
- 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);
+ static void GetFlameDfc(TAny* aPtr);
+
/**
- DFC Callback which gets triggered after the PDD has signalled that getting Capture image completed.
- This just casts aPtr and calls DoCaptureComplete().
+ 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.
- */
+ static void CaptureDfc(TAny* aPtr);
+
+ virtual void DoStartViewFinder();
+ /**
+ 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.
+ 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 GetConfig control message. This writes the current driver configuration to a
- RWebcameraDevice::TConfigBuf supplied by the client.
+ 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.
*/
- 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();
-
+ DWebcameraDriverBase* Pdd();
+
+ /**
+ Create shared chunk.
+ */
+ TInt CreatSharedChunks();
+
+ /**
+ Open shared chunk that exists.
+ */
+ TInt OpenSharedChunks(RWebcameraDevice::TChunkInfo* aChunkHandle);
+
+ /**
+ Dchunk call it when Shared chunk is destroyed.
+ */
+ void ChunkDestroyed();
+
+ /**
+ Close shared chunk.
+ */
+ void CloseSharedChunks();
+
private:
- /**
- *point to description sent by user-side.
- */
- TDes8* iReceiveDataDescriptor;
- /**
- *buffer for one flame.
- */
- HBuf8* iReceiveDataBuffer;
- /**
- *the status getting one flame.
- */
+ /**
+ point to description sent by user-side.
+ */
+ TInt* iReceiveDataDescriptor;
+
+ /**
+ power on state.
+ */
+ TBool iPowerOn;
+
+ /**
+ the status getting one flame.
+ */
TRequestStatus* iReceiveDataStatus;
- /**
- *DFC for getting one flame.
- */
+
+ /**
+ DFC for getting one flame.
+ */
TDfc iReceiveDataDfc;
- /**
- *the result of the get oneflame operation.
- */
+
+ /**
+ the result of the get oneflame operation.
+ */
TInt iReceiveDataResult;
- /**
- */
+
+ /**
+ the status running view finder.
+ */
TBool iReceiving;
- /**
- *point to description sent by user-side.
- */
- TDes8* iCaptureDescriptor;
- /**
- *buffer for capture image.
- */
- HBuf8* iCaptureBuffer;
- /**
- *the status getting capture image.
- */
+
+ /**
+ point to description sent by user-side.
+ */
+ TInt* iCaptureDescriptor;
+
+ /**
+ the status getting capture image.
+ */
TRequestStatus* iCaptureStatus;
- /**
- *DFC of capture.
- */
+
+ /**
+ DFC of capture.
+ */
TDfc iCaptureDfc;
- /**
- *the result of the capture operation.
- */
+
+ /**
+ the result of the capture operation.
+ */
TInt iCaptureResult;
- /**
- *the status getting capture image.
- */
+
+ /**
+ the status getting capture image.
+ */
TBool iCaptureing;
- /**
- *the status of request.
- */
+
+ /**
+ the status of request.
+ */
TBool iRequesting;
- /**
- *point to memory used to save one frame or capture image.
- */
- HBuf8* iComm;
- /**
- *Physical adress of contiguous memory.
- */
+
+ /**
+ Physical adress of contiguous memory.
+ */
TUint32 iPhysAddr;
- /**
- *the size of buffer used to save one frame or capture image.
- */
+
+ /**
+ 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.
- */
+
+ /**
+ the size of received data.
+ */
TInt iSaveSize;
+
+ /**
+ point to the created chunk object.
+ */
+ DChunk* iChunk;
+
+ /**
+ he mmu mapping attributes used for the chunk.
+ */
+ TUint32 iChunkMappingAttr;
+
+ /**
+ the linear address in the kernel process where the chunk's memory starts.
+ */
+ TLinAddr iChunkLinAddr;
+
+ /**
+ camera status.
+ */
+ TInt iWebCameraState;
+
+ /**
+ point to usb header info.
+ */
+ TAny* iHeaderPtr;
+
+ /**
+ point to description sent to PDD.
+ */
+ TAny* iDataPtr;
+
+ /**
+ point of convertion object.
+ */
+ DWebCameraConvert* iConvert;
+
+ /**
+ Bitmap data pointer.
+ */
+ TUint8* iBmpBuf;
};
#endif
--- a/baseport/syborg/webcamera/webcamera_ldd.mmp Wed Mar 24 13:46:59 2010 +0900
+++ b/baseport/syborg/webcamera/webcamera_ldd.mmp Mon Oct 18 19:39:25 2010 +0900
@@ -22,20 +22,19 @@
linkas ewebcamera.ldd
TARGETTYPE ldd
-SYSTEMINCLUDE /epoc32/include/drivers
-SYSTEMINCLUDE /epoc32/include/platform/drivers
+SYSTEMINCLUDE /epoc32/include/drivers
SYSTEMINCLUDE AsspNKernIncludePath
SOURCEPATH .
SOURCE webcamera_ldd.cpp
+SOURCE webcamer_convert.cpp
LIBRARY PlatformLib
EPOCALLOWDLLDATA
-UID 0x100000af 0x1020044C //TODO:修正する必要
+UID 0x100000af 0x1020044C
//VENDORID 0x70000001
-//ROMTARGET ewebcamera.ldd
CAPABILITY all
--- a/baseport/syborg/webcamera/webcamera_pdd.cpp Wed Mar 24 13:46:59 2010 +0900
+++ b/baseport/syborg/webcamera/webcamera_pdd.cpp Mon Oct 18 19:39:25 2010 +0900
@@ -15,72 +15,69 @@
*
*/
+#ifndef __devicePDD_H__
#include "webcamera_pdd.h"
-#include <webcamera_driver.h>
+#endif
+//#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);
-}
+ {
+ DP("DWebcameraPddFactory::DWebcameraPddFactory()");
+ iVersion = TVersion(KCommsMajorVersionNumber, KCommsMinorVersionNumber, KCommsBuildVersionNumber);
+ }
TInt DWebcameraPddFactory::Install()
-{
- DP("DWebcameraPddFactory::Install");
- return SetName(&KWebcameraPddName);
-}
+ {
+ 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");
-}
+ {
+ 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;
-}
+ {
+ 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))))
- {
+ {
+ DP("DWebcameraPddFactory::Validate start");
+ if ((!Kern::QueryVersionSupported(iVersion,aVer)) ||
+ (!Kern::QueryVersionSupported(aVer, TVersion(KMinimumLddMajorVersion, KMinimumLddMinorVersion, KMinimumLddBuild))))
+ {
return KErrNotSupported;
- }
- DP("DWebcameraPddFactory::Validate end");
- return KErrNone;
-}
-
-// ---------------------------------------------------------------
-// ---------------------------------------------------------------
+ }
+ DP("DWebcameraPddFactory::Validate end");
+ return KErrNone;
+ }
DWebcameraDriver::DWebcameraDriver()
{
@@ -89,98 +86,171 @@
}
DWebcameraDriver::~DWebcameraDriver()
-{
- DP("DWebcameraDriver::~DWebcameraDriver start");
- Interrupt::Unbind(iIrq);
- DP("DWebcameraDriver::~DWebcameraDriver end");
-}
+ {
+ DP("DWebcameraDriver::~DWebcameraDriver start");
+ CloseChunk(EWEBCAMERAINDEXADATABUF);
+ 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;
-}
+ {
+ DP("DWebcameraDriver::DoCreate start");
+ iPortAddr = KHwSVPWebcameraDevice;
+ iIrq = EIrqWebamera;
+
+ Interrupt::Bind(iIrq, Isr, this);
+ DP("DWebcameraDriver::DoCreate end");
+ return KErrNone;
+ }
+
+TInt DWebcameraDriver::PowerOn(TAny* aHeaderPtr)
+ {
+
+ iClient = &Kern::CurrentThread();
+ ((DObject*)iClient)->Open();
+
+ TInt ret = CreateChunk(sizeof(iDataInfo), EWEBCAMERAINDEXHAHEADERBUF);
+ WriteReg(iPortAddr, WEBCAMERA_REG_DMA_INFO, iPhysAddr[EWEBCAMERAINDEXHAHEADERBUF]);
+ WriteReg(iPortAddr, WEBCAMERA_REG_DMA_INFOSIZE, sizeof(iDataInfo));
+ WriteReg(iPortAddr, WEBCAMERA_REG_DMA_CONNECT,0x0);
+
+ kumemget(&iDataInfo, iChunk[EWEBCAMERAINDEXHAHEADERBUF]->Base(), sizeof(TWebcameraDataInfo));
+
+ //Process(Transaction) that parse iDataInfo.
+ DWebCameraDescribe* bDescribe;
+ bDescribe = new DWebCameraDescribe;
+ iUvcData = bDescribe->ParseDataInfo(iDataInfo);
+ delete bDescribe;
-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;
-}
+ //Store bUVC in TAny* aHeaderPtr.
+ kumemget(aHeaderPtr, &iUvcData, sizeof(TWebcameraUVC));
+
+ CloseChunk(EWEBCAMERAINDEXHAHEADERBUF);
+
+ return ret;
+ }
+
+TInt DWebcameraDriver::InitViewFinder()
+ {
+ TInt ret = KErrNone;
+
+ iClient = &Kern::CurrentThread();
+ ((DObject*)iClient)->Open();
+ ret = CreateChunk(BUFSIZE, EWEBCAMERAINDEXADATABUF);
-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;
-}
+ return ret;
+ }
+
+TInt DWebcameraDriver::StartViewerFinder(TAny* aDataPtr, TInt aSize)
+ {
+ iType = 0;
+
+ WriteReg(iPortAddr, WEBCAMERA_REG_DATA_TYPE, 0x0);
+ WriteReg(iPortAddr, WEBCAMERA_REG_DMA_ADDR, iPhysAddr[EWEBCAMERAINDEXADATABUF]);
+ WriteReg(iPortAddr, WEBCAMERA_REG_DMA_SIZE, aSize);
+ WriteReg(iPortAddr, WEBCAMERA_REG_INT_ENABLE, 0x1);
+
+ kumemget(aDataPtr, iChunk[EWEBCAMERAINDEXADATABUF]->Base(), aSize);
+
+ Interrupt::Enable(iIrq);
+ 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");
-}
+ {
+ WriteReg(iPortAddr, WEBCAMERA_REG_INT_ENABLE, 0x0);
+ Interrupt::Disable(iIrq);
+ }
+
+void DWebcameraDriver::Disconnect()
+ {
+ WriteReg(iPortAddr, WEBCAMERA_REG_DMA_DISCONNECT, 0x0);
+ Interrupt::Disable(iIrq);
+ }
void DWebcameraDriver::Isr(TAny* aPtr)
-{
- DP("DWebcameraDriver::Isr start");
- ((DWebcameraDriver*)aPtr)->receivedatacallback();
- DP("DWebcameraDriver::Isr end");
-}
+ {
+ ((DWebcameraDriver*)aPtr)->receivedatacallback();
+ }
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");
-}
+ {
+ TInt datasize = ReadReg(iPortAddr, WEBCAMERA_REG_DMA_SIZE);
+ switch (iType)
+ {
+ case 0:
+ iLdd->GetOneFlameComplete(datasize);
+ break;
+ default:
+ DP("receivedatacallback error");
+ break;
+ }
+ WriteReg(iPortAddr, WEBCAMERA_REG_DMA_ADDR, 0);
+ WriteReg(iPortAddr, WEBCAMERA_REG_DMA_SIZE, 0);
+ WriteReg(iPortAddr, WEBCAMERA_REG_INT_ENABLE, 0x0);
+ }
+
+/**
+Chunk that used between PDD and USB.
+*/
+TInt DWebcameraDriver::CreateChunk(TInt aSize, TWebcameraIndex aIndex)
+ {
+ TLinAddr wChunkLinAddr;
+ TUint32 wChunkMappingAttr;
+ RWebcameraDevice::TChunkInfo chunkInfo;
+
+ TChunkCreateInfo info;
+ info.iType = TChunkCreateInfo::ESharedKernelMultiple;
+ info.iMaxSize = aSize;
+ info.iMapAttr = EMapAttrFullyBlocking;
+ info.iOwnsMemory = ETrue;
+ info.iDestroyedDfc = NULL;
-// ---------------------------------------------------------------
-// ---------------------------------------------------------------
+//Chunk Create
+ iChunk[aIndex] = NULL;
+ iPhysAddr[aIndex] = 0x0;
+ TInt ret = Kern::ChunkCreate(info, iChunk[aIndex], wChunkLinAddr, wChunkMappingAttr);
+ if (ret != KErrNone)
+ {
+ DP("Kern::ChunkCreate Err = %d",ret);
+ }
+ ret = Kern::ChunkCommitContiguous(iChunk[aIndex], 0, aSize, iPhysAddr[aIndex]);
+ if (ret != KErrNone)
+ {
+ DP("Kern::ChunkCommitContiguous Err = %d",ret);
+ }
+
+//Chunk Open
+ // Make handle to chunifo for current thread
+ ret = Kern::MakeHandleAndOpen(iClient, iChunk[aIndex]);
+ if (ret >= 0)
+ {
+ chunkInfo.iChunkHandle = ret;
+ ret = KErrNone;
+ }
+
+ if (ret != KErrNone)
+ {
+ memclr(&chunkInfo, sizeof(chunkInfo));
+ }
+
+ TInt result = Kern::ThreadRawWrite(iClient, &info, &chunkInfo, sizeof(chunkInfo), 0);
+ if (result != KErrNone)
+ {
+ DP("Kern::ChunkCommitContiguous Err = %d",result);
+ }
+ return KErrNone;
+ }
+
+void DWebcameraDriver::CloseChunk(TWebcameraIndex aIndex)
+ {
+ Kern::ChunkClose(iChunk[aIndex]);
+ Kern::SafeClose((DObject*&)iClient, NULL);
+ }
DECLARE_STANDARD_PDD()
-{
- DP("DECLARE_STANDARD_PDD()");
- return new DWebcameraPddFactory;
-}
-
+ {
+ DP("DECLARE_STANDARD_PDD()");
+ return new DWebcameraPddFactory;
+ }
--- a/baseport/syborg/webcamera/webcamera_pdd.h Wed Mar 24 13:46:59 2010 +0900
+++ b/baseport/syborg/webcamera/webcamera_pdd.h Mon Oct 18 19:39:25 2010 +0900
@@ -18,103 +18,153 @@
#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;
+const TInt KMinimumLddMajorVersion = 1;
+const TInt KMinimumLddMinorVersion = 1;
+const TInt KMinimumLddBuild = 0;
+const TInt EIrqWebamera = 0xb;
class DWebcameraPddFactory : public DPhysicalDevice
-{
+ {
public:
/**
- Constructor
+ 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
+ Chunk index.
+ */
+ enum TWebcameraIndex
+ {
+ EWEBCAMERAINDEXHAHEADERBUF,
+ EWEBCAMERAINDEXADATABUF,
+ EWEBCAMERAINDEXMAX
+ };
+
+ /**
+ Constructor
*/
DWebcameraDriver();
+
/**
- Destructor
+ 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.
+
+ /**
+ 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 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);
- @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.
+ /**
+ Power on Camera Device.
+ */
+ virtual TInt PowerOn(TAny* aHeaderPtr);
+
+ /**
+ Init ViewFinder.
+ */
+ virtual TInt InitViewFinder();
- @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.
+ /**
+ 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 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);
- @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.
+ 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.
- */
+
+ /**
+ 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
- };
+ /**
+ 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.
- */
+ /**
+ operation types.
+ */
TInt iType;
-};
+ TWebcameraDataInfo iDataInfo;
+ DChunk* iChunk[EWEBCAMERAINDEXMAX]; ///< For Chunk process.
+ DThread* iClient;
+ TUint32 iPhysAddr[EWEBCAMERAINDEXMAX];
+ TWebcameraUVC iUvcData;
+ };
#endif
--- a/baseport/syborg/webcamera/webcamera_pdd.mmp Wed Mar 24 13:46:59 2010 +0900
+++ b/baseport/syborg/webcamera/webcamera_pdd.mmp Mon Oct 18 19:39:25 2010 +0900
@@ -22,18 +22,18 @@
linkas webcamera.pdd
TARGETTYPE pdd
-SYSTEMINCLUDE /epoc32/include/drivers
-SYSTEMINCLUDE /epoc32/include/platform/drivers
+SYSTEMINCLUDE /epoc32/include/drivers
SYSTEMINCLUDE AsspNKernIncludePath
SOURCEPATH .
SOURCE webcamera_pdd.cpp
+SOURCE webcamera_uvc.cpp
LIBRARY PlatformLib
EPOCALLOWDLLDATA
-UID 0x100039d0 0x1020044D //TODO:修正する必要
+UID 0x100039d0 0x1020044D
//VENDORID 0x70000001
//ROMTARGET webcamera.pdd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/baseport/syborg/webcamera/webcamera_uvc.cpp Mon Oct 18 19:39:25 2010 +0900
@@ -0,0 +1,352 @@
+/*
+* 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 WEBCAMERA_UVC_H_
+#include "webcamera_uvc.h"
+#endif
+
+#define DP(format...) Kern::Printf(format)
+
+//Describe UVC base.
+
+/**
+Constructor.
+*/
+DWebCameraUVCDescriptor::DWebCameraUVCDescriptor()
+ {
+ DP("DWebcameraUVCDescriptor::DWebcameraUVCDescriptor construct");
+ }
+
+/**
+Destructor.
+*/
+DWebCameraUVCDescriptor::~DWebCameraUVCDescriptor()
+ {
+ DP("DWebcameraUVCDescriptor::DWebcameraUVCDescriptor destruct");
+ }
+
+/**
+Describe UVC Descriptor.
+@param aDataInfo [in] DataInfo from lower layer.
+@return bDescriptor.
+*/
+TWebcameraUVCDescriptor DWebCameraUVCDescriptor::DescribeDescriptor(const TWebcameraDataInfo aDataInfo)
+ {
+ TWebcameraUVCDescriptor bDescriptor;
+ return bDescriptor;
+ }
+
+//Describe UVC descriptor YUY2 class.
+
+/**
+Constructor.
+*/
+DWebCameraUVCDescribeDescriptorYUY2::DWebCameraUVCDescribeDescriptorYUY2()
+ {
+ DP("DWebCameraUVCDescribeDescriptorYUY2::DWebCameraUVCDescribeDescriptorYUY2 construct");
+ }
+
+/**
+Destructor.
+*/
+DWebCameraUVCDescribeDescriptorYUY2::~DWebCameraUVCDescribeDescriptorYUY2()
+ {
+ DP("DWebCameraUVCDescribeDescriptorYUY2::DWebCameraUVCDescribeDescriptorYUY2 destruct");
+ }
+
+/**
+Describe UVC Descriptor of YUY2 Format.
+@param aDataInfo [in] DataInfo from lower layer.
+@return bDescriptor.
+*/
+TWebcameraUVCDescriptor DWebCameraUVCDescribeDescriptorYUY2::DescribeDescriptor(const TWebcameraDataInfo aDataInfo)
+ {
+ DP("DWebcameraUVCDescribeDescriptorYUY2::DescribeDescriptor Start");
+ //Describe FormatDescriptor Part.
+ TWebcameraUVCDescriptor bDescriptor;
+
+ bDescriptor.iFormatDescriptor.iLength = 27;
+ bDescriptor.iFormatDescriptor.iDescriptorType = KWebcameraSCVideoStreaming;
+ bDescriptor.iFormatDescriptor.iDescriptorSubType = KWebcameraVSFormatUnconmpressed;
+
+ //bFormatIndex : First and only format descriptor.
+ //This field is set by the host.
+ bDescriptor.iFormatDescriptor.iFormatIndex = 0x01;
+
+ bDescriptor.iFormatDescriptor.iNumFrameDescriptor = KWebcameraVSFrameUncompressed;
+ bDescriptor.iFormatDescriptor.iGuid = aDataInfo.iDataFortmat.iSubFormat;
+ bDescriptor.iFormatDescriptor.iBitsPerPixel = aDataInfo.iVideoInfoHeader.iBmiHeader.iBitCount;
+
+ //bDefaultFrameIndex : Default frame index is 1.
+ bDescriptor.iFormatDescriptor.iDefaultFrameIndex = 0x01;
+
+ bDescriptor.iFormatDescriptor.iAspectRatioX = 4;
+
+ bDescriptor.iFormatDescriptor.iAspectRatioY = 3;
+
+ //InterlaceFlags. //VideoInfoHeader2 dwInterlaceFlags.
+ //No interlaced stream.
+ bDescriptor.iFormatDescriptor.iInterlaceFlags = 0x00;
+
+ //0: No restrictions.
+ bDescriptor.iFormatDescriptor.iCopyProtect = 0x00;
+
+ //Describe FrameDescriptor Part.
+ bDescriptor.iFrameDescriptor.iDescriptorType = KWebcameraSCVideoStreaming;
+ bDescriptor.iFrameDescriptor.iDescriptorSubType = KWebcameraVSFrameUncompressed;
+
+ //First and only frame descriptor.
+ bDescriptor.iFrameDescriptor.iFrameIndex = 0x01;
+
+ //Still images using capture method 0 are supported at this frame setting.D1: Fixed frame-rate.
+ //D2~D7 reserved.
+ bDescriptor.iFrameDescriptor.iCapabilities = 0x02;
+
+ bDescriptor.iFrameDescriptor.iWidth = (TUint16)aDataInfo.iVideoInfoHeader.iBmiHeader.iWidth;
+ bDescriptor.iFrameDescriptor.iHeight = (TUint16)aDataInfo.iVideoInfoHeader.iBmiHeader.iHeight;
+
+ //iDwBitRate = 147456000 = 640 * 480 * 16 * 30(FPS).
+ //bDescriptor.iFrameDescriptor.iMaxBitRate.
+ bDescriptor.iFrameDescriptor.iMaxBitRate = aDataInfo.iVideoInfoHeader.iDwBitRate;
+ //bDescriptor.iFrameDescriptor.iMinBitRate.
+ bDescriptor.iFrameDescriptor.iMinBitRate = aDataInfo.iVideoInfoHeader.iDwBitRate;
+
+ //bDescriptor.iFrameDescriptor.iMaxVideoFrameBufferSize.
+ //max frame size is 640 * 480 * 2 = 614400.
+ bDescriptor.iFrameDescriptor.iMaxVideoFrameBufferSize = aDataInfo.iVideoInfoHeader.iBmiHeader.iSizeImage;
+
+ //bDescriptor.iFrameDescriptor.iDefaultFrameInterval.
+ //147456000 / 640 / 480 / 16 = 30(FPS) -> 33.3ms -> 33,333.3μs -> 333333.3 * 100ns = 333333 = iAvgTimePerFrame.
+ bDescriptor.iFrameDescriptor.iDefaultFrameInterval = (TUint32)aDataInfo.iVideoInfoHeader.iAvgTimePerFrame;
+
+ //0: Continuous frame interval.
+ bDescriptor.iFrameDescriptor.iFrameIntervalType = 0x00;
+
+ //bDescriptor.iFrameDescriptor.iLength.
+ if (bDescriptor.iFrameDescriptor.iFrameIntervalType == 0)
+ {
+ bDescriptor.iFrameDescriptor.iFrameInterval.iFrameInterval1 = (TUint32)aDataInfo.iVideoInfoHeader.iAvgTimePerFrame;
+ //highest frame rate.
+
+ bDescriptor.iFrameDescriptor.iFrameInterval.iFrameInterval2 = (TUint32)aDataInfo.iVideoInfoHeader.iAvgTimePerFrame;
+ //lowest frame rate.
+
+ bDescriptor.iFrameDescriptor.iFrameInterval.iFrameInterval3 = (TUint32)aDataInfo.iVideoInfoHeader.iAvgTimePerFrame;
+ //Indicates granularity of frame interval range.
+
+ bDescriptor.iFrameDescriptor.iLength = 38;
+ //iFrameIntervalType = 0 : 38, > 0 : 26+(4*n).
+ }
+ return bDescriptor;
+ }
+
+//UVC heder class.
+
+/**
+Constructor.
+*/
+DWebCameraUVCHeader::DWebCameraUVCHeader()
+ {
+ DP("DWebCameraUVCHeader::DWebCameraUVCHeader construct");
+ }
+
+/**
+Destructor.
+*/
+DWebCameraUVCHeader::~DWebCameraUVCHeader()
+ {
+ DP("DWebCameraUVCHeader::DWebCameraUVCHeader destruct");
+ }
+
+/**
+Describe UVC Header.
+@param aDataInfo [in] Information of data from lower layer.
+@return bHeader UVC Header descibed.
+*/
+TWebcameraUVCHeaderFormat DWebCameraUVCHeader::DescribeHeader(const TWebcameraDataInfo aDataInfo)
+ {
+ TWebcameraDataInfo bDataInfo = aDataInfo;
+ TWebcameraUVCHeaderFormat bHeader;
+
+ //Describe HeaderInfo to be included UVC Header.
+ bHeader.iHeaderInfo = DescribeHeaderInfo(bDataInfo);
+
+ //Describe HeaderLength to be included UVC Header if PTS was set.
+ bHeader.iHeaderLength = DescribeHeaderLength(bDataInfo, bHeader.iHeaderInfo);
+
+ //Describe PresentationTime to be included UVC Header.
+ if ((bHeader.iHeaderInfo & KWebcameraPts) > 0)
+ {
+ bHeader.iPresentationTime = DescribePresentationTime(bDataInfo);
+ }
+
+ //Describe SourceClockReference to be included UVC Header if SCR was set.
+ if ((bHeader.iHeaderInfo & KWebcameraScr) > 0)
+ {
+ bHeader.iSourceClockReference = DescribeSourceClockReference(bDataInfo);
+ }
+ return bHeader;
+ }
+
+/**
+Describe HeaderInfo of UVC Header.
+@param aDataInfo [in] DataInfo get from lower layer.
+@return bHeaderInfo.
+*/
+TUint8 DWebCameraUVCHeader::DescribeHeaderInfo(const TWebcameraDataInfo aDataInfo)
+ {
+ TUint8 bHeaderInfo = 0x00;
+
+// bHeaderInfo |= KWebcameraEoh;
+
+// bHeaderInfo |= KWebcameraErr;
+
+// bHeaderInfo |= KWebcameraSti;
+
+// bHeaderInfo |= KWebcameraScr;
+
+ //Case: Set PTS infomation.
+ if (aDataInfo.iVideoInfoHeader.iAvgTimePerFrame != 0)
+ {
+ bHeaderInfo |= KWebcameraPts;
+ }
+
+// bHeaderInfo |= KWebcameraEof;
+
+ //Reversing FID.
+ iFID = ~iFID;
+ iFID &= KWebcameraFid;
+ bHeaderInfo |= iFID;
+
+ return bHeaderInfo;
+ }
+
+/**
+Describe HeaderLength to be included UVC Header.
+@param aDataInfo [in] Information of data from lower layer.
+ aHeaderInfo [in] HeaderInfo to be included UVC Header.
+@return bHeaderLength.
+*/
+TUint8 DWebCameraUVCHeader::DescribeHeaderLength(const TWebcameraDataInfo aDataInfo, TUint8 aHeaderInfo)
+ {
+ TUint8 bHeaderLength;
+ bHeaderLength = 2;
+
+ //Get information of PTS .
+ if ((aHeaderInfo & KWebcameraPts) > 0)
+ {
+ bHeaderLength += 4;
+ }
+
+ //Get information of SCR.
+ if ((aHeaderInfo & KWebcameraScr) > 0)
+ {
+ bHeaderLength += 6;
+ }
+
+ return bHeaderLength;
+ }
+
+/**
+Describe PresentationTime to be included UVC Header.
+@param @param aDataInfo [in] Information of Data from lower layer.
+@return bPresentationTime.
+*/
+TUint32 DWebCameraUVCHeader::DescribePresentationTime(const TWebcameraDataInfo aDataInfo)
+ {
+ TUint32 bPresentationTime;
+ //Substitution information of AvgTimePerFrame for PresentationTime.
+ bPresentationTime = (TUint32)aDataInfo.iVideoInfoHeader.iAvgTimePerFrame;
+
+ return bPresentationTime;
+ }
+
+/**
+Describe SourceClockReference to be included UVC Header.
+@param aDataInfo [in] Information of data from lower layer.
+@return bSourceClockReference.
+*/
+TWebcameraUVCSourceClockReference DWebCameraUVCHeader::DescribeSourceClockReference(const TWebcameraDataInfo aDataInfo)
+ {
+ TWebcameraUVCSourceClockReference bSourceClockReference;
+ //Substitute information of TokenCounter for iTokenCounter.
+ bSourceClockReference.iTokenCounter = 0x0000;
+ bSourceClockReference.iTokenCounter &= KWebcameraTokenCounter;
+
+ //Substitute information of SourceTimeClock for iSourceTimeClock.
+// bSourceClockReference.iSourceTimeClock = (TUint32) aSourceTimeClock;
+
+ return bSourceClockReference;
+ }
+
+//Describe class.
+
+/**
+Constructor.
+*/
+DWebCameraDescribe::DWebCameraDescribe()
+ {
+ DP("DWebCameraDescribe::DWebCameraDescribe construct");
+ }
+
+/**
+Destructor.
+*/
+DWebCameraDescribe::~DWebCameraDescribe()
+ {
+ delete iDescribe;
+ DP("DWebCameraDescribe::DWebCameraDescribe destruct");
+ }
+
+/**
+Parse iDataInfo from lower layer and describe UVC Header and Descriptor.
+@param aDataInfo [in] Information of data from lower layer.
+@return bUVC.
+*/
+TWebcameraUVC DWebCameraDescribe::ParseDataInfo(const TWebcameraDataInfo aDataInfo)
+ {
+ TWebcameraDataInfo bDataInfo = aDataInfo;
+ TWebcameraUVC bUvc;
+
+ //Describe UVC Header.
+ DWebCameraUVCHeader* bHeader;
+ bHeader = new DWebCameraUVCHeader;
+ bUvc.iUVCHeader = bHeader->DescribeHeader(bDataInfo);
+ delete bHeader;
+
+ //If MajorFormat equal KWebcameraVideoStream, this format is VideoStream.
+ if (bDataInfo.iDataFortmat.iMajorFormat.iData1 == KWebcameraVideoStream)
+ {
+ //Discriminate by SubFormat.
+ switch (bDataInfo.iDataFortmat.iSubFormat.iData1)
+ {
+ //Case of YUY2 Format.
+ case KWebcameraYuy2:
+ iDescribe = new DWebCameraUVCDescribeDescriptorYUY2;
+ break;
+
+ //Case of default.
+ default:
+ //No format that discriminated.
+ break;
+ }
+ //Describe UVC Descriptor.
+ bUvc.iUVCDescriptor = iDescribe->DescribeDescriptor(bDataInfo);
+ }
+
+ return bUvc;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/baseport/syborg/webcamera/webcamera_uvc.h Mon Oct 18 19:39:25 2010 +0900
@@ -0,0 +1,349 @@
+/*
+* 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: UVC FOrmat Header
+*
+*/
+
+
+#include <comm.h>
+
+
+#ifndef WEBCAMERA_UVC_H_
+#define WEBCAMERA_UVC_H_
+
+
+#define KWebcameraEoh (TUint8)(0x80)
+#define KWebcameraErr (TUint8)(0x40)
+#define KWebcameraSti (TUint8)(0x20)
+#define KWebcameraRes (TUint8)(0x10)
+#define KWebcameraScr (TUint8)(0x08)
+#define KWebcameraPts (TUint8)(0x04)
+#define KWebcameraEof (TUint8)(0x02)
+#define KWebcameraFid (TUint8)(0x01)
+#define KWebcameraTokenCounter (TUint16)(0x1fff)
+
+
+/* UVC DescriptorType */
+#define KWebcameraSCUndefined (TUint8)(0x00)
+#define KWebcameraSCVideoControl (TUint8)(0x01)
+#define KWebcameraSCVideoStreaming (TUint8)(0x02)
+#define KWebcameraSCVideoInterfaceCollection (TUint8)(0x03)
+
+/* VideoStreaming DescriptorSubType */
+#define KWebcameraVSUndefined (TUint8)(0x00)
+#define KWebcameraVSInputHeader (TUint8)(0x01)
+#define KWebcameraVSOutputHeader (TUint8)(0x02)
+#define KWebcameraVSStillImageFrame (TUint8)(0x03)
+#define KWebcameraVSFormatUnconmpressed (TUint8)(0x04)
+#define KWebcameraVSFrameUncompressed (TUint8)(0x05)
+#define KWebcameraVSFormatJPEG (TUint8)(0x06)
+#define KWebcameraVSFrameJPEG (TUint8)(0x07)
+#define KWebcameraVSFormatMPEG2TS (TUint8)(0x0a)
+#define KWebcameraVSFormatDV (TUint8)(0x0c)
+#define KWebcameraVSColorFormat (TUint8)(0x0d)
+#define KWebcameraVSFormatFrameBased (TUint8)(0x10)
+#define KWebcameraVSFrameFrameBased (TUint8)(0x11)
+#define KWebcameraVSFormatStreamBased (TUint8)(0x12)
+
+/* VideoFormat(GUID) */
+#define KWebcameraYuy2 (TUint32)(0x32595559)
+#define KWebcameraVideoStream (TUint32)(0x73646976)
+
+class TWebcameraGuid
+ {
+public:
+ TUint32 iData1;
+ TUint16 iData2;
+ TUint16 iData3;
+ TUint8 iData4[8];
+ };
+
+class TWebcameraDataFortmat
+ {
+public:
+ TUint32 iFormatSize;
+ TUint32 iFlags;
+ TUint32 iSampleSize;
+ TUint32 iReserved;
+ TWebcameraGuid iMajorFormat;
+ TWebcameraGuid iSubFormat;
+ TWebcameraGuid iSpecifier;
+ };
+
+class TWebcameraRect
+ {
+public:
+ TInt32 iLeft;
+ TInt32 iTop;
+ TInt32 iRight;
+ TInt32 iBottom;
+ };
+
+class TWebcameraBitmapInfoHeader
+ {
+public:
+ TUint32 iSize;
+ TInt32 iWidth;
+ TInt32 iHeight;
+ TUint16 iPlanes;
+ TUint16 iBitCount;
+ TUint32 iCompression;
+ TUint32 iSizeImage;
+ TInt32 iXPelsPerMeter;
+ TInt32 iYPelsPerMeter;
+ TUint32 iClrUsed;
+ TUint32 iClrImportant;
+ };
+
+class TWebcameraVideoInfoHeader
+ {
+public:
+ TWebcameraRect iRcSource;
+ TWebcameraRect iRcTarget;
+ TUint32 iDwBitRate;
+ TUint32 iDwBitErrorRate;
+ Int64 iAvgTimePerFrame;
+ TWebcameraBitmapInfoHeader iBmiHeader;
+ };
+
+class TWebcameraDataInfo
+ {
+public:
+ TWebcameraDataFortmat iDataFortmat;
+ TWebcameraVideoInfoHeader iVideoInfoHeader;
+ };
+
+class TWebcameraUVCSourceClockReference
+ {
+public:
+ TUint16 iTokenCounter;
+ TUint32 iSourceTimeClock;
+ };
+
+class TWebcameraUVCHeaderFormat
+ {
+ /**
+ Variables that configure UVC Header.
+ */
+public:
+ TUint8 iHeaderLength;
+ TUint8 iHeaderInfo;
+ TUint32 iPresentationTime;
+ TWebcameraUVCSourceClockReference iSourceClockReference;
+ };
+
+class TWebcameraUVCFormatDescriptor
+ {
+public:
+ TUint8 iLength;
+ TUint8 iDescriptorType;
+ TUint8 iDescriptorSubType;
+ TUint8 iFormatIndex;
+ TUint8 iNumFrameDescriptor;
+ TWebcameraGuid iGuid;
+ TUint8 iBitsPerPixel;
+ TUint8 iDefaultFrameIndex;
+ TUint8 iAspectRatioX;
+ TUint8 iAspectRatioY;
+ TUint8 iInterlaceFlags;
+ TUint8 iCopyProtect;
+ TUint8 iDataoffset;
+ TUint8 iPacketLength1;
+ TUint32 iPacketLength2;
+ TUint8 iStrideLength;
+ TWebcameraGuid iGuidStrideFormat;
+ TUint8 iFlags;
+ TUint8 iVariableSize;
+ TUint32 iMaxVideoFrameBufferSize;
+ TUint8 iFormatType;
+ };
+
+class TWebcameraUVCFrameInterval
+ {
+public:
+ TUint32 iFrameInterval1;
+ TUint32 iFrameInterval2;
+ TUint32 iFrameInterval3;
+ };
+
+class TWebcameraUVCFrameDescriptor
+ {
+public:
+ TUint8 iLength;
+ TUint8 iDescriptorType;
+ TUint8 iDescriptorSubType;
+ TUint8 iFrameIndex;
+ TUint8 iCapabilities;
+ TUint16 iWidth;
+ TUint16 iHeight;
+ TUint32 iMinBitRate;
+ TUint32 iMaxBitRate;
+ TUint32 iMaxVideoFrameBufferSize;
+ TUint32 iDefaultFrameInterval;
+ TUint8 iFrameIntervalType;
+ TWebcameraUVCFrameInterval iFrameInterval;
+ TUint32 iBytesPerLine;
+ };
+
+class TWebcameraUVCDescriptor
+ {
+public:
+ TWebcameraUVCFormatDescriptor iFormatDescriptor;
+ TWebcameraUVCFrameDescriptor iFrameDescriptor;
+ };
+
+class TWebcameraUVC
+ {
+public:
+ TWebcameraUVCHeaderFormat iUVCHeader;
+ TWebcameraUVCDescriptor iUVCDescriptor;
+ };
+
+/**
+Describe UVC base class.
+*/
+class DWebCameraUVCDescriptor : public DBase// : public DWebCameraUVCBase
+ {
+public://function
+ /**
+ Constructor.
+ */
+ DWebCameraUVCDescriptor();
+
+ /**
+ Destructor.
+ */
+ ~DWebCameraUVCDescriptor();
+ /**
+
+ Describe UVC Format Descriptor and Frame Descriptor.
+
+ @param aDataInfo [in] Information of data from lower layer.
+ bDescriptor.
+ */
+ virtual TWebcameraUVCDescriptor DescribeDescriptor(const TWebcameraDataInfo aDataInfo);
+ };
+
+/**
+Describe descriptor of YUY2 format included in UVC.
+*/
+class DWebCameraUVCDescribeDescriptorYUY2 : public DWebCameraUVCDescriptor
+ {
+public://function
+ /**
+ Constructor.
+ */
+ DWebCameraUVCDescribeDescriptorYUY2();
+
+ /**
+ Destructor.
+ */
+ ~DWebCameraUVCDescribeDescriptorYUY2();
+
+ /**
+ Describe UVC Descriptor of YUY2 Format.
+
+ @param aDataInfo [in] Information of data from lower layer.
+ @return bDescriptor.
+ */
+ TWebcameraUVCDescriptor DescribeDescriptor(const TWebcameraDataInfo aDataInfo);
+ };
+
+/**
+Describe UVC header class.
+ */
+class DWebCameraUVCHeader
+ {
+public://function
+ /**
+ Constructor.
+ */
+ DWebCameraUVCHeader();
+
+ /**
+ Destructor.
+ */
+ ~DWebCameraUVCHeader();
+
+public://function
+ /**
+ Describe UVC Header.
+ @param aDataInfo [in] Information of data from lower layer.
+ @return bHeader.
+ */
+ TWebcameraUVCHeaderFormat DescribeHeader(const TWebcameraDataInfo aDataInfo);
+
+private://function
+ /**
+ Describe HeaderInfo to be included UVC Header.
+ @param aDataInfo [in] Information of data form lower layer.
+ @return bHeaderInfo.
+ */
+ TUint8 DescribeHeaderInfo(TWebcameraDataInfo aDataInfo);
+
+ /**
+ Describe HeaderLength to be included UVC Header.
+ @param aDataInfo [in] Information of data from lower layer.
+ @return bHeaderLength.
+ */
+ TUint8 DescribeHeaderLength(TWebcameraDataInfo aDataInfo, TUint8 aHeaderInfo);
+
+ /**
+ Describe PresentationTime to be included UVC Header.
+ @param aDataInfo [in] Information of data from lower layer.
+ @return bPresentationTime.
+ */
+ TUint32 DescribePresentationTime(TWebcameraDataInfo aDataInfo);
+
+ /**
+ Describe SourceClockReference to be included UVC Header.
+ @param aDataInfo [in] Information of data from lower layer.
+ @return bSourceClockReference.
+ */
+ TWebcameraUVCSourceClockReference DescribeSourceClockReference(TWebcameraDataInfo aDataInfo);
+
+private://variable.
+ TUint8 iFID;
+ };
+
+/**
+Describe class.
+*/
+class DWebCameraDescribe : public DBase
+ {
+public://function.
+ /**
+ Constructor.
+ */
+ DWebCameraDescribe();
+
+ /**
+ Destructor.
+ */
+ ~DWebCameraDescribe();
+
+public://function
+ /**
+ Parse iDataInfo from lower layer and describe UVC Header and Descriptor.
+ @param aDataInfo [in] Information of data from lower layer.
+ aDescriptror [out] Header and Descriptor format of YUY2 format.
+ @return KErrNone.
+ */
+ TWebcameraUVC ParseDataInfo(const TWebcameraDataInfo aDataInfo);
+
+private://val.
+ DWebCameraUVCDescriptor* iDescribe;
+ };
+
+#endif /* WEBCAMERA_UVC_H_ */
--- a/symbian-qemu-0.9.1-12/qemu-symbian-svp/plugins/syborg_usbtest.py Wed Mar 24 13:46:59 2010 +0900
+++ b/symbian-qemu-0.9.1-12/qemu-symbian-svp/plugins/syborg_usbtest.py Mon Oct 18 19:39:25 2010 +0900
@@ -1,113 +1,153 @@
-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)
+import qemu
+import os
+from ctypes import cdll
+import ctypes
+import datetime
+
+class syborg_usbtest(qemu.devclass):
+ REG_ID = 0
+ REG_INT_ENABLE = 1
+ REG_DATA_TYPE = 2
+ REG_DMA_ADDR = 3
+ REG_DMA_SIZE = 4
+ REG_DMA_INFO = 5
+ REG_DMA_INFOSIZE = 6
+ REG_DMA_CONNECT = 7
+ REG_DMA_DISCONNECT = 8
+
+ def loaddll(self):
+ #Load DLL
+ print "start dll load"
+ self.path = r'.\webcamapi.dll'
+ self.webcamdll = cdll.LoadLibrary(self.path)
+ print "end dll load"
+
+ def connect(self):
+ #Connect to USB Camera
+ print "Connect to USB Camera"
+ if self.infobuffer == 0:
+ self.infobuffer = ctypes.create_string_buffer(self.infosize)
+
+ self.DevHandle = self.webcamdll.ConnectDevHandle()
+ self.bufSize = ctypes.c_int()
+ self.PinHandle = self.webcamdll.ConnectPinHandle(self.DevHandle, ctypes.byref(self.bufSize), ctypes.byref(self.infobuffer))
+
+ infobuf = self.infobuffer
+
+ for x in infobuf:
+ ch = ord(x)
+ if self.infosize > 0:
+ self.dma_writeb(self.dataformat, ch)
+ self.dataformat += 1
+ self.infosize -= 1
+
+ def readframe(self):
+ #Read frame data
+ if self.buffer == 0:
+ self.buffer = ctypes.create_string_buffer(self.bufSize.value)
+
+ self.timelog("Read frame data Start")
+ self.Ret = self.webcamdll.ReadFrameData(self.PinHandle, ctypes.byref(self.buffer), self.bufSize.value)
+ self.timelog("Read frame data End")
+
+ #Write frame data. This is for debug.
+ #self.Ret = self.webcamdll.WriteFrameData("_frameData.bin", ctypes.byref(self.buffer), self.bufSize.value);
+
+ buf = self.buffer
+ length = len(buf)
+ count = 0
+ for x in range(1, length, 2):
+ if self.dma_size > 0:
+ self.buf = ord(buf[count+1]) << 8 | ord(buf[count+0])
+ self.dma_writel(self.dma_addr, self.buf)
+ self.dma_addr += 2
+ self.dma_size -= 2
+ count += 2
+
+ self.set_irq_level(0, self.int_enable)
+
+ def timelog(self,buf):
+ date = datetime.datetime.today().isoformat()
+ print "%(view)s %(time)s" % {"view":buf,"time":date}
+
+ def create(self):
+ self.int_enable = 1
+ self.dma_addr = 0
+ self.dma_size = 0
+ self.cha = 0
+ self.dataformat = 0
+ self.infosize = 0
+ self.buffer = 0
+ self.infobuffer = 0
+
+ def write_reg(self, offset, value):
+ #This func is called when PDD performed WriteReg func.
+ offset >>= 2
+ if offset==self.REG_INT_ENABLE:
+ self.int_enable=value
+ if value==1:
+ if self.data_type==0:
+ self.readframe()
+ else:
+ if self.data_type==0:
+ self.set_irq_level(0, self.int_enable)
+ #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
+ elif offset == self.REG_DMA_INFO:
+ self.dataformat = value
+ elif offset == self.REG_DMA_INFOSIZE:
+ self.infosize = value
+ elif offset == self.REG_DMA_CONNECT:
+ self.loaddll()
+ self.connect()
+ elif offset == self.REG_DMA_DISCONNECT:
+ self.Ret = self.webcamdll.DisconnectPinHandle(self.PinHandle)
+ self.set_irq_level(0, self.int_enable)
+
+ def read_reg(self, offset):
+ #This func is called when PDD performed ReadReg func.
+ 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
+ elif offset == self.REG_DMA_FORMAT:
+ return self.dataformat
+ return 0
+
+ def save(self, f):
+ f.put_u32(self.int_enable)
+ f.put_u32(self.dma_addr)
+ f.put_u32(self.dma_size)
+ f.put_u32(self.dataformat)
+ f.put_u32(self.infosize)
+ f.put_u32(self.buffer)
+ f.put_u32(self.infobuffer)
+
+ def load(self, f):
+ self.int_enable = f.get_u32()
+ self.dma_addr = f.get_u32()
+ self.dma_size = f.get_u32()
+ self.dataformat = f.get_u32()
+ self.infosize = f.get_u32()
+ self.buffer = f.get_u32()
+ self.infobuffer = 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)