How-to-get-USB-Camera-Driver-Working-in-WEC7

As we know Microsoft has released the USB camera driver source code for Windows Embedded CE 6.0. Using this driver we can directly plug in the USB webcam to the WinCE 6.0 device and we can test the same. Check out my other post about “How to Get USB Camera Working in WinCE 6.0 ARM Kit.

With our new product e-CAM51_USB (https://www.e-consystems.com/5mp-usb-camera-module.asp ), we planned to test that in Windows Embedded Compact 7 as well. We did that with a few tweaks.

So now in this post I am going to show how to port the WinCE 6.0 USB Camera driver to the Windows Embedded Compact 7 OS. In the new Windows Embedded Compact 7 release Microsoft had updated few things in MDD layer of DirectShow Camera Driver. But in the MSDN I don’t find any documentation update about that.

https://msdn.microsoft.com/en-us/library/gg159273.aspx

First I had just compiled the WinCE 6.0 USB source as is without any change and it came up with few header files missing issue. After looking into the PUBLIC directory, the names for these header files has been changed in WinCE 7.0.Following are the header file changes needed

  • Dbgsettings.h –>cameradebug.h
  • Pindriver.h –>camerapindriver.h

 

After doing the above changes ,it compiles without error and the usbcam.dll is generated. After adding the bib and reg entries I created the final OS binary image (NK.bin).

I plugged in the USB Board Camera into the WinCE device and got the following error message from the USB camera driver.

“ERROR: copying the function table. Insufficient memory”

In thiscase, running the DShow camera application will fail to retrieve the loaded Driver name list.

So I just looked for this message in the code of USB driver and found it on the usbpdd.cpp file. It is failing in PDDInit() function where the PDD will pass the function list table to the MDD. This is the code which is failing

// Pass the function table to MDD
if( pPDDFuncTbl->dwSize>sizeof(PDDFUNCTBL))
{
DEBUGMSG(ZONE_ERROR, (DTAG TEXT(“ERROR: copying the function table. Insufficient memory\r\n”)));
return ERROR_INSUFFICIENT_BUFFER;
}
memcpy( pPDDFuncTbl, &FuncTbl, sizeof( PDDFUNCTBL ) );

As this USB camera driver uses the MDD layer from the WinCE PUBLIC source tree in the following location.

\WINCE700\COMMON\OAK\DRIVERS\CAPTURE\CAMERA\LAYERED\MDD

By looking into the MDD code it had few additions and update for few cases like handling the AutoFocus feature etc.

They have added three new functions to the original function table in this link.Following are the three function which are added to the PDDFUNCTBL structure and they had named it as PDDFUNCTBL2.

  • PDD_Open()
  • PDD_Close()
  • PDD_GetMetaData()

Now I just looked in to the NULLPDD driver to check how these MDD changes are handled in the PDD, which is in the following location is really a good starting point when you develop your own PDD for your camera.

\WINCE700\COMMON\OAK\DRIVERS\CAPTURE\CAMERA\LAYERED\PDD_NULL

Looking into the nullpdd.cpp this change had been handled in the following way

if (pPDDFuncTbl->dwSize<sizeof(PDDFUNCTBL))
{
return ERROR_INSUFFICIENT_BUFFER;
}
else if (pPDDFuncTbl->dwSize<sizeof(PDDFUNCTBL2))
{
memcpy(pPDDFuncTbl, &FuncTbl, sizeof(PDDFUNCTBL));
pPDDFuncTbl->dwSize = sizeof(PDDFUNCTBL);
}
else if (pPDDFuncTbl->dwSize>= sizeof(PDDFUNCTBL2))
{
memcpy(pPDDFuncTbl, &FuncTbl, sizeof(PDDFUNCTBL2));
}

In this case they  had handled both the cases if PDD supports either  PDDFUNCTBL or PDDFUNCTBL2 .

After replacing the above code snippet in the usbpdd.cpp ,proceeded with the building and loading the binaries.

As expected the above error gone and USB camera driver loaded successfully and application works in WinCE 7.0.

I hope this helps in getting the USB camera working in Windows Embedded Compact 7 OS.