WinCE6.0 Camera驱动源码分析(一)

       学习 WinCE6.0 下面的 Camera 也一段时间了,准备做些记录结束了。由于 Camera 驱动中有太多的数据结构、层次结构,而且依靠 DirectShow 架构,所以这里没法细节到代码,只能从整体上分析源码了。
       应用层操作 Camera 设备的接口主要就是 IOCONTROL ,今天先来看看 Camera Pin 的各种 IO 控制码。
       本人使用的环境是 WinCE6.0+Android6410 开发板。
 
       一、 CAM_IOControl 函数 ,主要源码如下:
 
 
 
 
 
 
 
 
 
 
 
       1 从上面的代码可以看出,每次都会调用 AdapterHandleCustomRequests 函数,该函数实际是个空函数,只有打印输出,没有实际的操作 ( 也许是为了以后扩展用 ) 。调用关系为:
AdapterHandleCustomRequests à PDD_HandleAdapterCustomProperties à
HandleAdapterCustomProperties à 打印输出
       2 185 行的 AdapterHandlePinRequests 函数,从名称可以看出是用来处理各种 Pin 的请求,即获取 Pin 的相关信息。
typedef enum {
    CSPROPERTY_PIN_CINSTANCES = 0,
    CSPROPERTY_PIN_CTYPES,
    CSPROPERTY_PIN_DATARANGES,
    CSPROPERTY_PIN_DATAINTERSECTION,
    CSPROPERTY_PIN_CATEGORY,
    CSPROPERTY_PIN_NAME,
} CSPROPERTY_PIN;
CSPROPERTY_PIN_CINSTANCES
Used to query for the current number of pins this pin factory has instantiated, as well as the maximum number of pins this pin factory can instantiate, per filter.
CSPROPERTY_PIN_CTYPES
Used to query the camera driver for the number of pin types it supports.
CSPROPERTY_PIN_DATARANGES
Used to determine the data ranges supported by pins instantiated by the pin factory.
CSPROPERTY_PIN_DATAINTERSECTION
Used to find a data format supported by pins instantiated by the pin factory. The client supplies a list of data formats; the CS filter returns the first data format on the list that is supported.
CSPROPERTY_PIN_CATEGORY
Used to query the camera driver for a pin's type (preview, capture, or still).
CSPROPERTY_PIN_DEVICENAME
Used to query the camera driver for a pin's name. Drivers can assign any name to a pin, but typically the name will be PIN1:.
CSPROPERTY_PIN_NAME
查询 Pin 的类型名称,如 "Capture" "Still" "Preview"
       3 189 行的 AdapterHandleVersion 函数用来获得 MDD/PDD 接口的版本号。
       4 193 行的 AdapterHandleVidProcAmpRequests 函数用来获得或者设置基于过滤器的 PCSPROPERTY_VIDEOPROCAMP_S 属性。
CSPROPERTY_TYPE_GET
Retrieves the value of the specified property item.
CSPROPERTY_TYPE_SET
Sets the value of the specified property item.
CSPROPERTY_TYPE_BASICSUPPORT
Queries the request types that the driver handles for this property item. Returns CSPROPERTY_TYPE_GET or CSPROPERTY_TYPE_SET or both. All property sets must support this flag.
CSPROPERTY_TYPE_DEFAULTVALUES
Queries the default values for the specified property item.
       5 197 行的 AdapterHandleCamControlRequests 函数和上面的很类似,只是该函数获取或设置的属性为 CSPROPERTY_CAMERACONTROL_S
       6 201 行的 AdapterHandleVideoControlRequests 函数用来处理视频控制的属性,主要包括两部分:
PCSPROPERTY_VIDEOCONTROL_CAPS_S
This structure is used to set or get filter-based properties in the PROPSETID_VIDCAP_VIDEOCONTROL property set. It describes the video-control capabilities of a minidriver, such as image flipping, or event triggering abilities.
PCSPROPERTY_VIDEOCONTROL_MODE_S
This structure describes video-control modes for a stream, such as image flipping or event triggering abilities.
       7 205 行的 AdapterHandleDroppedFramesRequests 函数主要处理丢失的帧信息。
PCSPROPERTY_DROPPEDFRAMES_CURRENT_S
This structure describes the dropped frame information from the minidriver.
 
       二、 PIN_IOControl 函数 ,主要是关于视频流数据的操作接口,源码如下:
 
 
       1 IOCTL_CS_PROPERTY 处理与属性相关的请求,主要调用 PinHandleCustomRequests 函数和 PinHandleConnectionRequests 函数。 PinHandleCustomRequests 调用关系为: PDDHandlePinCustomProperties à CCameraPdd::HandleSensorModeCustomProperties 。上述调用都是空函数,除了打印输出以外,没有其他的操作。
       PinHandleConnectionRequests 函数是比较重要的,用来描述 Pin 的连接关系,根据请求的不同分以下几种:
typedef enum {
    CSPROPERTY_CONNECTION_STATE,
    CSPROPERTY_CONNECTION_DATAFORMAT,
    CSPROPERTY_CONNECTION_ALLOCATORFRAMING,
    CSPROPERTY_CONNECTION_PROPOSEDATAFORMAT,
    CSPROPERTY_CONNECTION_ALLOCATORFRAMING_EX
} CSPROPERTY_CONNECTION;
CSPROPERTY_CONNECTION_STATE
Sets the current run state of the pin. This property returns a value from the CSSTATE enumeration.
The pin only reads or writes data in the CSSTATE_RUN state. Both individual pins and the CS filter as a whole may support this property.
CSPROPERTY_CONNECTION_DATAFORMAT
Used to get or set the current data format.
This property returns a CSDATAFORMAT specifying the current data format.
CS filters only need to support this property if they allow clients to reset the current property, or if connections can be made with the data format incompletely specified.
CSPROPERTY_CONNECTION_ALLOCATORFRAMING
Used to determine framing requirements for a pin.
This property returns a CSALLOCATOR_FRAMING structure, which describes the framing requirements for the pin. For example, the FrameSize member specifies the frame size of data on the pin.
CSPROPERTY_CONNECTION_PROPOSEDATAFORMAT
Used to propose a new data format for the connection.
This property returns a CSDATAFORMAT specifying the proposed data format.
The CS filter returns STATUS_SUCCESS if the pin can be reset to the proposed data format, or an error code otherwise. Note that this property request does not change the data format. Clients use CSPROPERTY_CONNECTION_DATAFORMAT to change the format.
       2 IOCTL_CS_BUFFERS 处理与图像数据存储相关的请求,包括 buffer 有驱动分配还是用户分配、在驱动和 DShow 之间传递数据等,主要调用 PinHandleBufferRequest 函数,根据 Buffer 管理的命令不同,分以下几种:
typedef enum {
        CS_ALLOCATE,
        CS_ENQUEUE,
        CS_DEALLOCATE
} BUFFER_COMMANDS;
CS_ALLOCATE
Indicates that the driver should allocate the buffer.
CS_ENQUEUE
Indicates that the driver should add a buffer to its queue.
CS_DEALLOCATE
Indicates that the driver should free the memory for the buffer.
       3 IOCTL_STREAM_INSTANTIATE 处理流的实例化操作,主要调用 StreamInstantiate 函数。

你可能感兴趣的:(源码分析,休闲,6410,WinCE6.0,Camera驱动)