Win32 Drivers for Digital/Video Camcorders 
by Thomas Tewell


Table 1: 

REQUEST_ASYNC_READ 
 REQUEST_ASYNC_WRITE
REQUEST_ASYNC_LOCK 
 REQUEST_ISOCH_ALLOCATE_BANDWIDTH
REQUEST_ISOCH_ALLOCATE_CHANNEL 
 REQUEST_ISOCH_ALLOCATE_RESOURCES
REQUEST_ISOCH_ATTACH_BUFFERS 
 REQUEST_ISOCH_DETACH_BUFFERS
REQUEST_ISOCH_FREE_BANDWIDTH 
 REQUEST_ISOCH_FREE_CHANNEL
REQUEST_ISOCH_FREE_RESOURCES 
 REQUEST_ISOCH_LISTEN
REQUEST_ISOCH_STOP 
 REQUEST_ISOCH_TALK
REQUEST_ISOCH_QUERY_CYCLE_TIME 
 REQUEST_ISOCH_QUERY_RESOURCES
REQUEST_ISOCH_SET_CHANNEL_BANDWIDTH 
 REQUEST_ALLOCATE_ADDRESS_RANGE
REQUEST_FREE_ADDRESS_RANGE 
 REQUEST_GET_LOCAL_HOST_INFO
REQUEST_GET_ADDR_FROM_DEVICE_OBJECT 
 REQUEST_CONTROL
REQUEST_GET_SPEED_BETWEEN_DEVICES 
 REQUEST_SET_DEVICE_XMIT_PROPERTIES
REQUEST_GET_CONFIGURATION_INFO 
 REQUEST_BUS_RESET
REQUEST_GET_GENERATION_COUNT 
 REQUEST_SEND_PHY_CONFIG_PACKET
REQUEST_GET_SPEED_TOPOLOGY_MAPS 
 REQUEST_BUS_RESET_NOTIFICATION 
REQUEST_ASYNC_STREAM 
 REQUEST_SET_LOCAL_HOST_PROPERTIES

Example 1: 

Irb = ExAllocatePool(NonPagedPool, sizeof(IRB));
 ...Fill out IRB for desired 1394 function...
NextIrpStack = IoGetNextIrpStackLocation(Irp);
NextIrpStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
NextIrpStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_1394_CLASS;
NextIrpStack->Parameters.Others.Argument1 = Irb;
 ...Setup IRP Completion Routine...
status = IoCallDriver(DeviceExtension->SonyPC10DeviceObject,Irp);


Example 2: 

USHORT Node_Vendor_Id
UCHAR Chip_Id_High
ULONG Chip_Id_Low.


Listing One
/*----------------------------------------------------------------------- */
/* Filename: DDJDVTST.C                                                   */
/* Description: Dr. Dobb's Journal DV Frame Capture Driver Project        */
/*              Win32 Console Application for testing the DV Driver       */
/*----------------------------------------------------------------------- */
/* (C) Copyright 1994-1998 by Sequoia Advanced Technologies, Inc.         */
/* http://www.seqadvtech.com                                              */
/* All Rights Reserved.                                                   */
/*----------------------------------------------------------------------- */
#define STRICT
#include <stdlib.h>
#include <stdio.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winioctl.h>
#include "ddjdvw32.h"

bswap(ULONG value)
{
    __asm mov eax, value
    __asm bswap eax
}
main(int argc, char *argv[])
{
    HANDLE hDev;
    DWORD dwOutCount;
    DWORD inBuffer[2];
    DWORD dwRet;
    printf("Dr. Dobb's DV Camcorder Driver Test Utility\n\n");
    //-----------------------------------------------------------------
    // Open our DV Camcorder driver, if it is loaded.
    // This will result in DDJDV_Create being called in the driver.
    //-----------------------------------------------------------------
    hDev = CreateFile("\\\\.\\DDJDVCAP", GENERIC_WRITE | GENERIC_READ,
          FILE_SHARE_WRITE | FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
    if(hDev == INVALID_HANDLE_VALUE)
    {
        printf("DDJDVCAP Driver Not Loaded!!\n\n");
        exit(1);
    }
    //------------------------------------------------------------------
    // Send command to DV Driver to read Node Unique ID from Camcorder. 
    // This will result in DDJDV_Dispatch being called in driver.
    //-------------------------------------------------------------------
    dwRet = DeviceIoControl(hDev, GET_NODE_UNIQUE_ID_CODE, NULL, 0, 
                                         inBuffer, 8, &dwOutCount, NULL);
    //-------------------------------------------------------------------
    // Put in little-endian numeric format
    //--------------------------------------------------------------------
    inBuffer[0] = bswap(inBuffer[0]);
    inBuffer[1] = bswap(inBuffer[1]);

    printf("Camcorder Vendor ID = %x\n",(inBuffer[0] >> 8));
    printf("Camcorder Model ID = %x%.8x\n",(inBuffer[0] & 0xFF),inBuffer[1]);

    //-------------------------------------------------------------------
    // Close DV Driver. Will result in DDJDV_Close being called in driver.
    //--------------------------------------------------------------------
    CloseHandle(hDev);
    return(0);
}

1


