Initialization Sequence for Camera Drivers of CE6.0

来源:互联网 发布:阿里云备案幕布 编辑:程序博客网 时间:2024/05/01 23:37

在MSDN上看到一篇关于CE6.0 camera 驱动初始化过程的文章,对整个初始化过程做了介绍,能帮助我们理解整个驱动框架,本想翻译过来,但自己的英文水平太烂了,就贴出原文吧,原汁原味的更好!

  

The initialization sequence for camera devices is as follows:

  • All camera drivers must be registered under the same GUID. The following code shows the stream interface driver registry entry for a camera driver.
    Copy
    [HKEY_LOCAL_MACHINE/Drivers/BuiltIn/CameraDriver]   "Prefix"="<Driver prefix>"   "Dll"="<Driver DLL name>"   "Order"=dword:10   "Index"=dword:1   "IClass"=multi_sz: "{CB998A05-122C-4166-846A-933E4D7E3C86}"
  • The Windows Embedded CE Device Manager loads the camera driver and calls the driver's entry point, CAM_Init. Upon receiving the call, the camera driver detects and initializes the hardware, allocates and initializes its data structures, and returns device instance identifier. This device identifier will be used in subsequent calls to CAM_Open.
  • DirectShow calls CreateFile using the appropriate device name. Applications should use FindFirstDevice to retrieve the actual name based on the appropriate device class GUID. For more information, see Capture Device Selection.
  • DirectShow queries the camera driver for the number of pins it supports using CSPROPERTY_PIN_CTYPES (see CSPROPERTY_PIN). It then queries for the type (preview, capture, or still) of each of these pins using CSPROPERTY_PIN_CATEGORY.
  • DirectShow queries the camera driver for the name of the pin device using CSPROPERTY_PIN_DEVICENAME. This will commonly be PIN1:, but drivers are free to use whatever name they wish.
  • DirectShow calls CreateFile on the pin driver for each pin type the camera driver supports.
  • The driver initializes the stream by setting its properties and data formats and by allocating buffers for it.
  • The client sets the stream type for the given pin handle using IOCTL_STREAM_INSTANTIATE by passing, as input, the identifier of the pin and a handle to the message queue that will be used for transferring asynchronous bundles between the driver and the DirectShow middleware. For example, if CSPROPERTY_PIN_CTYPES returned 3 and if the CSPROPERTY_PIN_CATEGORY for Id = 0 returned PINNAME_VIDEO_PREVIEW, then calling IOCTL_STREAM_INSTANTIATE with PinId = 0 would associate the given handle to preview stream.
  • Begin streaming data through the pins

From the perspective of the camera driver, there are at least two objects to instantiate: one for the adapter and one for the stream. If the camera supports more than one stream then driver must instantiate additional pins. The camera adapter entry points are referred to as CAM_XXX and stream entry points are referred to as PIN_XXX. For a complete list of entry point functions, see Camera Driver Functions

原创粉丝点击