{"id":777,"date":"2011-11-02T11:10:44","date_gmt":"2011-11-02T05:40:44","guid":{"rendered":"http:\/\/www.e-consystems.com\/blog\/windowsce\/?p=777"},"modified":"2023-08-15T12:31:28","modified_gmt":"2023-08-15T07:01:28","slug":"usb-camera-driver-working-wec7","status":"publish","type":"post","link":"https:\/\/www.e-consystems.com\/blog\/windowsce\/usb-camera-driver-working-wec7\/","title":{"rendered":"How to get USB Camera Driver Working in WinCE 7.0"},"content":{"rendered":"<p>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 &#8220;<a href=\"https:\/\/www.e-consystems.com\/blog\/windowsce\/how-to-get-usb-camera-working-in-wince6-arm-kit\/\">How to Get USB Camera Working in WinCE 6.0 ARM Kit<\/a><strong>&#8220;<\/strong>.<\/p>\n<p>With our new product e-CAM51_USB (<a href=\"https:\/\/www.e-consystems.com\/5mp-usb-camera-module.asp\">https:\/\/www.e-consystems.com\/5mp-usb-camera-module.asp<\/a> ), we planned to test that in Windows Embedded Compact 7 as well. We did that with a few tweaks.<\/p>\n<p>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&#8217;t find any documentation update about that.<\/p>\n<p><a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg159273.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg159273.aspx<\/a><\/p>\n<p>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<\/p>\n<ul>\n<li><strong>Dbgsettings.h &#8211;&gt;cameradebug.h<\/strong><\/li>\n<li><strong>Pindriver.h &#8211;&gt;camerapindriver.h<\/strong><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>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).<\/p>\n<p>I plugged in the <a href=\"https:\/\/www.e-consystems.com\/5mp-usb-camera-module.asp\">USB Board Camera<\/a> into the WinCE device and got the following error message from the USB camera driver.<\/p>\n<p><span style=\"color: #993300;\">&#8220;ERROR: copying the function table. Insufficient memory&#8221;<\/span><\/p>\n<p>In thiscase, running the DShow camera application will fail to retrieve the loaded Driver name list.<\/p>\n<p>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<\/p>\n<table border=\"1\" width=\"622\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"622\"><span style=\"color: #993300;\">\/\/ Pass the function table to MDD<\/span><br \/>\n<span style=\"color: #993300;\"> if( pPDDFuncTbl-&gt;dwSize&gt;sizeof(PDDFUNCTBL))<\/span><br \/>\n<span style=\"color: #993300;\"> {<\/span><br \/>\n<span style=\"color: #993300;\"> DEBUGMSG(ZONE_ERROR, (DTAG TEXT(&#8220;ERROR: copying the function table. Insufficient memory\\r\\n&#8221;))); <\/span><br \/>\n<span style=\"color: #993300;\"> return ERROR_INSUFFICIENT_BUFFER;<\/span><br \/>\n<span style=\"color: #993300;\"> }<\/span><br \/>\n<span style=\"color: #993300;\"> memcpy( pPDDFuncTbl, &amp;FuncTbl, sizeof( PDDFUNCTBL ) );<br \/>\n<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>As this USB camera driver uses the MDD layer from the WinCE PUBLIC source tree in the following location.<\/p>\n<p><strong>\\WINCE700\\COMMON\\OAK\\DRIVERS\\CAPTURE\\CAMERA\\LAYERED\\MDD<\/strong><\/p>\n<p>By looking into the MDD code it had few additions and update for few cases like handling the AutoFocus feature etc.<\/p>\n<p>They have added three new functions to the original function table in this <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/ee482515.aspx\">link<\/a>.Following are the three function which are added to the <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/ee484660.aspx\">PDDFUNCTBL<\/a> structure and they had named it as <strong>PDDFUNCTBL2.<\/strong><\/p>\n<ul>\n<li>PDD_Open()<\/li>\n<li>PDD_Close()<\/li>\n<li>PDD_GetMetaData()<\/li>\n<\/ul>\n<p>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.<\/p>\n<p><strong>\\WINCE700\\COMMON\\OAK\\DRIVERS\\CAPTURE\\CAMERA\\LAYERED\\PDD_NULL<\/strong><\/p>\n<p>Looking into the nullpdd.cpp this change had been handled in the following way<\/p>\n<table border=\"1\" width=\"622\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"622\"><span style=\"color: #993300;\"> if (pPDDFuncTbl-&gt;dwSize&lt;sizeof(PDDFUNCTBL))<\/span><br \/>\n<span style=\"color: #993300;\"> {<\/span><br \/>\n<span style=\"color: #993300;\"> return ERROR_INSUFFICIENT_BUFFER;<\/span><br \/>\n<span style=\"color: #993300;\"> }<\/span><br \/>\n<span style=\"color: #993300;\"> else if (pPDDFuncTbl-&gt;dwSize&lt;sizeof(PDDFUNCTBL2))<\/span><br \/>\n<span style=\"color: #993300;\"> {<\/span><br \/>\n<span style=\"color: #993300;\"> memcpy(pPDDFuncTbl, &amp;FuncTbl, sizeof(PDDFUNCTBL));<\/span><br \/>\n<span style=\"color: #993300;\"> pPDDFuncTbl-&gt;dwSize = sizeof(PDDFUNCTBL);<\/span><br \/>\n<span style=\"color: #993300;\"> }<\/span><br \/>\n<span style=\"color: #993300;\"> else if (pPDDFuncTbl-&gt;dwSize&gt;= sizeof(PDDFUNCTBL2))<\/span><br \/>\n<span style=\"color: #993300;\"> {<\/span><br \/>\n<span style=\"color: #993300;\"> memcpy(pPDDFuncTbl, &amp;FuncTbl, sizeof(PDDFUNCTBL2));<\/span><br \/>\n<span style=\"color: #993300;\"> }<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>In this case they\u00a0 had handled both the cases if PDD supports either\u00a0 <strong>PDDFUNCTBL <\/strong>or <strong>PDDFUNCTBL2 .<\/strong><\/p>\n<p>After replacing the above code snippet in the usbpdd.cpp ,proceeded with the building and loading the binaries.<\/p>\n<p>As expected the above error gone and USB camera driver loaded successfully and <a href=\"https:\/\/www.e-consystems.com\/blog\/windowsce\/building-simple-camera-directshow-filter-graph-application-wec7\/\">application<\/a> works in WinCE 7.0.<\/p>\n<p>I hope this helps in getting the USB camera working in Windows Embedded Compact 7 OS.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As we know Microsoft has released the USB camera driver source code for Windows Embedded&#8230;<\/p>\n","protected":false},"author":11,"featured_media":1238,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[96,190],"tags":[111,116,102,93],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/posts\/777"}],"collection":[{"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/comments?post=777"}],"version-history":[{"count":22,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/posts\/777\/revisions"}],"predecessor-version":[{"id":1963,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/posts\/777\/revisions\/1963"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/media\/1238"}],"wp:attachment":[{"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/media?parent=777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/categories?post=777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/tags?post=777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}