⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intelcam.c

📁 winddk src目录下的WDM源码压缩!
💻 C
📖 第 1 页 / 共 5 页
字号:
/*++

Copyright (c) 1998  Microsoft Corporation

Module Name:

   intelcam.c

Abstract:

   driver for the intel camera.

Author:

Notes:

  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  PURPOSE.
  

Environment:

   Kernel mode only


Revision History:

--*/

#include "warn.h"
#include "wdm.h"
#include "intelcam.h"
#include "strmini.h"
#include "prpobj.h"
#include "prpftn.h"

extern const GUID PROPSETID_CUSTOM_PROP;

ULONG INTELCAM_DebugTraceLevel
#ifdef MAX_DEBUG
    = MAX_TRACE;
#else
    = MIN_TRACE;
#endif

KSPIN_MEDIUM StandardMedium = {
    STATIC_KSMEDIUMSETID_Standard,
    0, 0
};

MaxPktSizePerInterface BusBWArray[BUS_BW_ARRAY_SIZE] = {
    {7, 0,NUM_100NANOSEC_UNITS_PERFRAME(0)},   // Interface # 7, Max. Pkt size 0, 0 fps (QCIF) 
    {1, 240,NUM_100NANOSEC_UNITS_PERFRAME(6)}, // Interface # 1, Max. Pkt size 240, 6 fps
    {0, 384,NUM_100NANOSEC_UNITS_PERFRAME(10)}, // Interface # 0, Max. pkt size 384, 10 fps
    {3, 464,NUM_100NANOSEC_UNITS_PERFRAME(12)}, // Interface # 3, Max. Pkt size 464, 12 fps
    {2, 576,NUM_100NANOSEC_UNITS_PERFRAME(15)}, // Interface # 2, Max. Pkt size 576, 15 fps
    {4, 688,NUM_100NANOSEC_UNITS_PERFRAME(18)}, // Interface # 4, Max. pkt size 688, 18 fps
    {5, 768,NUM_100NANOSEC_UNITS_PERFRAME(20)}, // Interface # 5, Max. Pkt size 768, 20 fps
    {6, 960,NUM_100NANOSEC_UNITS_PERFRAME(25)}, // Interface # 6, Max. Pkt size 960, 25 fps
};

#ifdef USBCAMD2

// this array is used for single-pin cameras
USBCAMD_Pipe_Config_Descriptor INTELCAM_PipeConfigArray1[INTELCAM_PIPECONFIG_LISTSIZE] = {
    {0, USBCAMD_SYNC_PIPE},
    {USBCAMD_VIDEO_STREAM,USBCAMD_DATA_PIPE  }
};
// this array is used for dual-pins cameras. 
USBCAMD_Pipe_Config_Descriptor INTELCAM_PipeConfigArray2[INTELCAM_PIPECONFIG_LISTSIZE] = {
    {0, USBCAMD_SYNC_PIPE},
    {USBCAMD_VIDEO_STILL_STREAM,USBCAMD_MULTIPLEX_PIPE  }
};

#endif

// ------------------------------------------------------------------------
// Property sets for all video capture streams
// ------------------------------------------------------------------------

DEFINE_KSPROPERTY_TABLE(VideoStreamConnectionProperties)
{
    DEFINE_KSPROPERTY_ITEM
    (
        KSPROPERTY_CONNECTION_ALLOCATORFRAMING,
        TRUE,                                   // GetSupported or Handler
        sizeof(KSPROPERTY),                     // MinProperty
        sizeof(KSALLOCATOR_FRAMING),            // MinData
        FALSE,                                  // SetSupported or Handler
        NULL,                                   // Values
        0,                                      // RelationsCount
        NULL,                                   // Relations
        NULL,                                   // SupportHandler
        sizeof(ULONG)                           // SerializedSize
    ),
};

DEFINE_KSPROPERTY_TABLE(VideoStreamDroppedFramesProperties)
{
    DEFINE_KSPROPERTY_ITEM
    (
        KSPROPERTY_DROPPEDFRAMES_CURRENT,
        TRUE,                                   // GetSupported or Handler
        sizeof(KSPROPERTY_DROPPEDFRAMES_CURRENT_S),// MinProperty
        sizeof(KSPROPERTY_DROPPEDFRAMES_CURRENT_S),// MinData
        FALSE,                                  // SetSupported or Handler
        NULL,                                   // Values
        0,                                      // RelationsCount
        NULL,                                   // Relations
        NULL,                                   // SupportHandler
        0                                       // SerializedSize
    ),
};


// ------------------------------------------------------------------------
// Array of all of the property sets supported by video streams
// ------------------------------------------------------------------------

DEFINE_KSPROPERTY_SET_TABLE(VideoStreamProperties)
{
    DEFINE_KSPROPERTY_SET
    ( 
        &KSPROPSETID_Connection,                        // Set
        SIZEOF_ARRAY(VideoStreamConnectionProperties),  // PropertiesCount
        VideoStreamConnectionProperties,                // PropertyItem
        0,                                              // FastIoCount
        NULL                                            // FastIoTable
    ),
    DEFINE_KSPROPERTY_SET
    ( 
        &PROPSETID_VIDCAP_DROPPEDFRAMES,                // Set
        SIZEOF_ARRAY(VideoStreamDroppedFramesProperties),  // PropertiesCount
        VideoStreamDroppedFramesProperties,                // PropertyItem
        0,                                              // FastIoCount
        NULL                                            // FastIoTable
    ),
};

#define NUMBER_VIDEO_STREAM_PROPERTIES (SIZEOF_ARRAY(VideoStreamProperties))


/*
 * The following are for FOURCC IYUV
 */
#define D_X 176
#define D_Y 144

KS_DATARANGE_VIDEO INTELCAM_StreamFormat_0 = 
{
    // KSDATARANGE
    {   
        sizeof (KS_DATARANGE_VIDEO),
        0,                      // Flags
        (D_X * D_Y * 12)/8,     // SampleSize
        0,                      // Reserved
//MEDIATYPE_Video
        STATIC_KSDATAFORMAT_TYPE_VIDEO,      
//MEDIASUBTYPE_IYUV        
        FCC_FORMAT_YUV12N, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71,
        STATIC_KSDATAFORMAT_SPECIFIER_VIDEOINFO
    },

    TRUE,               // BOOL,  bFixedSizeSamples (all samples same size?)
    TRUE,               // BOOL,  bTemporalCompression (all I frames?)
    KS_VIDEOSTREAM_CAPTURE,   // StreamDescriptionFlags
    0,                  // MemoryAllocationFlags   (KS_VIDEO_ALLOC_*)

    // _KS_VIDEO_STREAM_CONFIG_CAPS  
    {
        STATIC_KSDATAFORMAT_SPECIFIER_VIDEOINFO,
        KS_AnalogVideo_None,    // VideoStandard
        D_X, D_Y,               // InputSize, (the inherent size of the incoming signal
                                //             with every digitized pixel unique)
        D_X, D_Y,               // MinCroppingSize, smallest rcSrc cropping rect allowed
        D_X, D_Y,               // MaxCroppingSize, largest  rcSrc cropping rect allowed
        1,                      // CropGranularityX, granularity of cropping size
        1,                      // CropGranularityY
        1,                      // CropAlignX, alignment of cropping rect 
        1,                      // CropAlignY;
        D_X, D_Y,               // MinOutputSize, smallest bitmap stream can produce
        D_X, D_Y,               // MaxOutputSize, largest  bitmap stream can produce
        1,                      // OutputGranularityX, granularity of output bitmap size
        1,                      // OutputGranularityY;
        0,                      // StretchTapsX
    	0,                      // StretchTapsY
        0,                      // ShrinkTapsX
    	0,                      // ShrinkTapsY
        400000,                 // MinFrameInterval, 100 nS units
        1666667,                 // MaxFrameInterval, 100 nS units
        12 * 6 * D_X * D_Y,     // MinBitsPerSecond;
        12 * 25 * D_X * D_Y      // MaxBitsPerSecond;
    }, 
        

    // KS_VIDEOINFOHEADER (default format)
    {
        0,0,0,0,                        // RECT  rcSource; 
        0,0,0,0,                        // RECT  rcTarget; 
        D_X * D_Y * 12 * 25,                 // DWORD dwBitRate;
        0L,                                 // DWORD dwBitErrorRate; 
        400000,                             // REFERENCE_TIME  AvgTimePerFrame;   
        sizeof (KS_BITMAPINFOHEADER),       //    DWORD      biSize;
        D_X,                                //    LONG       biWidth;
        D_Y,                                //    LONG       biHeight;
        1,                                  //    WORD       biPlanes;
        12,                                 //    WORD       biBitCount;
        FCC_FORMAT_YUV12N,                  //    DWORD      biCompression;
        (D_X * D_Y * 12)/8,                 //    DWORD      biSizeImage;
        0,                                  //    LONG       biXPelsPerMeter;
        0,                                  //    LONG       biYPelsPerMeter;
        0,                                  //    DWORD      biClrUsed;
        0                                   //    DWORD      biClrImportant;

    }
}; 

#undef D_X
#undef D_Y
        

#define D_X 160
#define D_Y 120

KS_DATARANGE_VIDEO INTELCAM_StreamFormat_1 = 
{
    // KSDATARANGE
    {   
        sizeof (KS_DATARANGE_VIDEO),
        0,                      // Flags
        (D_X * D_Y * 12)/8,     // SampleSize
        0,                      // Reserved
//MEDIATYPE_Video
        STATIC_KSDATAFORMAT_TYPE_VIDEO,      
//  MEDIASUBTYPE_IYUV
        FCC_FORMAT_YUV12N, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71,
        STATIC_KSDATAFORMAT_SPECIFIER_VIDEOINFO
    },

    TRUE,               // BOOL,  bFixedSizeSamples (all samples same size?)
    TRUE,               // BOOL,  bTemporalCompression (all I frames?)
    KS_VIDEOSTREAM_CAPTURE,   // StreamDescriptionFlags
    0,                  // MemoryAllocationFlags   (KS_VIDEO_ALLOC_*)

    // _KS_VIDEO_STREAM_CONFIG_CAPS  
    {
        STATIC_KSDATAFORMAT_SPECIFIER_VIDEOINFO,
        KS_AnalogVideo_None,    // VideoStandard
        D_X, D_Y,               // InputSize, (the inherent size of the incoming signal
                                //             with every digitized pixel unique)
        D_X, D_Y,               // MinCroppingSize, smallest rcSrc cropping rect allowed
        D_X, D_Y,               // MaxCroppingSize, largest  rcSrc cropping rect allowed
        1,                      // CropGranularityX, granularity of cropping size
        1,                      // CropGranularityY
        1,                      // CropAlignX, alignment of cropping rect 
        1,                      // CropAlignY;
        D_X, D_Y,               // MinOutputSize, smallest bitmap stream can produce
        D_X, D_Y,               // MaxOutputSize, largest  bitmap stream can produce
        1,                      // OutputGranularityX, granularity of output bitmap size
        1,                      // OutputGranularityY;
        0,                      // StretchTapsX
    	0,                      // StretchTapsY
        0,                      // ShrinkTapsX
    	0,                      // ShrinkTapsY
        300000,         // MinFrameInterval, 100 nS units
        1249999,         // MaxFrameInterval, 100 nS units
        12 * 8 * D_X * D_Y,  // MinBitsPerSecond;
        12 * 33 * D_X * D_Y   // MaxBitsPerSecond;
    }, 
        
    // KS_VIDEOINFOHEADER (default format)
    {
        0,0,0,0,                        // RECT  rcSource; 
        0,0,0,0,                        // RECT  rcTarget; 
        D_X * D_Y * 12 * 24,                 // DWORD dwBitRate;
        0L,                                 // DWORD dwBitErrorRate; 
        416666,                             // REFERENCE_TIME  AvgTimePerFrame;   
        sizeof (KS_BITMAPINFOHEADER),       //    DWORD      biSize;
        D_X,                                //    LONG       biWidth;
        D_Y,                                //    LONG       biHeight;
        1,                                  //    WORD       biPlanes;
        12,                                 //    WORD       biBitCount;
        FCC_FORMAT_YUV12N,                  //    DWORD      biCompression;
        (D_X * D_Y * 12)/8,                 //    DWORD      biSizeImage;
        0,                                  //    LONG       biXPelsPerMeter;
        0,                                  //    LONG       biYPelsPerMeter;
        0,                                  //    DWORD      biClrUsed;
        0                                   //    DWORD      biClrImportant;

    }
}; 
    

#undef D_X
#undef D_Y

#define D_X 320
#define D_Y 240

KS_DATARANGE_VIDEO INTELCAM_StreamFormat_2 = 
{
    // KSDATARANGE
    {   
        sizeof (KS_DATARANGE_VIDEO),

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -