BDA MinidriverResponsibilities: modulation (Tunning) Signal, demodulation (Demodulating) Signal, get (Capture), Shunting (Demultiplexing).BytesYesAvstreamOn,Bdasup. LibProvideNowBytesAttribute Set and method set. WriteBytesThe main task of driving isBdasup. LibThe routines of the property set method set required in are all registered (registration is required, and you can skip it if you do not need it) to provide your own implementation.
BytesThe driver entry isDeviceentryFunction. The main task in this function is to register the distribution routine and callKsinitializedriver Function, inputKsdevice_descriptorType parameter, which specifiesKsdevice_dispatchParameters used to register various routines. A typicalKsdevice_dispatchThe parameters are as follows:
Extern
Const
Ksdevice_dispatch
Devicedispatch =
{
Cdevice: create, // Add
Cdevice: start, // Start
Null, // Poststart
Null, // Querystop
Null, // Cancelstop
Null, // Stop
Null, // Queryremove
Null, // Cancelremove
Null, // Remove
Null, // Querycapabilities
Null, // Surpriseremoval
Null, // Querypower
Null // Setpower
} ;
This part of work is actually
Avstream MinidriverTo do this, considerBytesYesAvstreamBased on the extension, we writeBDA MinidriverTo do the same job. Similar work inWDMThe driver must also be used. The difference is thatWDMThe routine registration is similar to the value assignment statement, andAvstream MinidriverThe routine registration is completed using some templates, saving us a lot of work.
Cdevice: Create In the routine, we mainly want to do the following: Download firmware And generate necessary Filter Instance, and can be configured if necessary DMA . Download firmware You must first obtain Product_id And then call Reset8051 (0x09) , Notifies the lower layer to Start Transmission Fireware , And then call Reset8051 (0x08) The notification is sent to the lower layer. Generate Filter Call Bdacreatefilterfactory Function, input Bda_filter_template Parameter, which must be specified Filterdispatch , Filterautomation , Pindescriptors , Ksfilter_category (Directory location ), Nodedescriptors And Connections . Filterdispatch Specified Filter Each distribution routine, Filterautomation Used to provide Propertyset (Attribute Set) and Methodset (Method set ), Pindescriptors Used to specify Pin Each distribution routine, Ksfilter_category Specify the generated Filter Under which directory (hardware Filter Search for instances using directory indexes instead of software Filter Use that way Guid Find an instance ), Nodedescriptors And Connections Specified Filter The internal function topology.
A typicalFilterdispatchAs shown in
Const
Ksfilter_dispatch
Filterdispatch =
{
Cfilter: create, // Create
Cfilter: filterclose, // Close
Null, // Process
Null // Reset
} ;
A typicalPindescriptorsAs shown below
Const
Kspin_descriptor_ex
Initialpindescriptors [] =
{
// Antenna pin
//
{
& Antennapindispatch, distribution routine
& Antennaautomation, // Attribute Set and method set on Pin
// The following is the type definition of the pin.
{
0 , // Interfaces
Null,
0 , // Mediums
Null,
Sizeof_array (antennapinranges ),
Antennapinranges,
Kspin_dataflow_in,
Kspin_communication_both,
Null, // Name
Null, // Category
0
} ,
The following describes the transmission types and methods.
Kspin_flag_do_not_use_standard_transport |
Kspin_flag_frames_not_required_for_processing |
Kspin_flag_fixed_format,
1 , // Instancespossible
0 , // Instancesnecessary
Null, // Allocator framing
Null // Pinintersecthandler
}
} ;
A typicalAntennapindispatchAs shown in
Const
Kspin_dispatch
Antennapindispatch =
{
Cantennapin: pincreate, // Create
Cantennapin: pinclose, // Close
Null, // Process signal data
Null, // Reset
Null, // Setdataformat
Cantennapin: pinsetdevicestate, // Setdevicestate
Null, // Connect
Null, // Disconnect
Null, // Clock
Null // Allocator
} ;
The property set and method set can be found inFilterInNode.FilterThe attribute set provided on can be called by the application layer.NodeThe attribute set provided on can only beBytesSomething in the architecture can be called (as described on the first page,TunnerTwo inNodeAllNetwork providerUsing the built-inGuidTo access,NodeYou only need to provideBytesYou can set the attribute set and method set, such as setting the frequency.GuidYesBytesBuilt-in .)FilterThe attribute set provided on can be customized for the upper layer and can be replacedDeviceiocontrolIn factBytesArchitectureNoRecommendedDeviceiocontrol.
(According to observation, myProgramMedium
Demodulator NodeThere isPropertysetkspropsetid_bdaautodemodulate
Tunner NodeIn Ksproperty_bda_rf_tuner_frequency_multiplier
Ksproperty_bda_rf_tuner_frequency
Ksproperty_bda_signal_strength
Ksproperty_bda_signal_quality
Ksproperty_bda_signal_present
Ksproperty_bda_signal_locked
Ksproperty_bda_sample_time
These attributes provide built-inFrequencyAndSignal. AllBytesFor built-in attributes, seeDDKÀDevice TechnologyÀVideo Capture DeviceÀReferenceÀBroadcast driver architecture driversÀBroadcast driver architecture property, event, and method sets).
The most important operation in the video capture driver is data collection, which occurs inCapture FilterOfOutput pinFrom other StatesStartStatus. It starts a working thread, constantly collects data from the underlying layer and stores the data in the cache, and callsKspinattemptprocessingMethod to respondCapture FilterOfProcessMethod To pass data back.
Stream pointers Yes Avstream Minidriver From Filter To the next Filter Method, Bytes Auto Scaling Avstream , So Bytes Data transmission is also used Stream pointers . Avstream A data queue is managed internally. What we need to do is to insert data into the queue, move the current pointer back, and destroy expired data. Process The Operation will Stream pointer Copy the data to the next Filter , The specific details are blocked. All we need to do is Stream pointer . To move data back, we can call Ksstreampointeradvance Function , Or Ksstreampointerunlock Function ( Eject Set the parameter True ). Stream pointer You can. You need to call Ksstreampointersetstatuscode Check whether the operation is successful. If there is an error, call Ksstreampointerdelete Method To destroy data (in fact, it is not true to destroy, but to reduce the reference count. When the reference count is reduced 0 The data is actually destroyed ).
Stream pointersIt also provides a set of methods for managing data queues,KspingetleadingedgestreampointerGet the header pointer,KspingettrailingedgestreampointerGet the tail pointer,KspingetfirstclonestreampointerGets the pointer of the currently used data,KsstreampointergetnextcloneTo the next pointer of the current pointer.
If you want to transmit only some data in a frame, callKsstreampointeradvanceoffsets Or Ksstreampointeradvanceoffsetsandunlock.Function.
in deviceadd routine, you can also go to ksdevice à context , the lifecycle of this batch of data continues until the deviceremove routine is completed, defining some global variables in a program is not advisable, it is recommended that all data be stored in ksdevice à context .