Specifications

Remote Control and Receiver-Transceiver Specifications and Requirements
for Windows Media Center in Windows Operating Systems
144
Data Flow
This section provides an overview of the data exchange process that takes place between
CIRClass and a CIR Port driver. This overview will serve as an introduction to the topic, in
preparation for reading the sample CIR Port driver code, the IOCTL definitions, and the data
structure definitions.
While reading the overview in this section, keep in mind that the code for the example driver,
which is described in a later section of this document, provides the most detailed example of how
data is exchanged between a CIR Port driver and the CIRClass driver. That code is also the
ultimate authority on the rules of those exchanges, such that if any information in this document
differs from the sample implementation, the sample implementation should be considered
correct.
Receive Data
A CIR Port driver reads data from its IR device as a result of receiving an IOCTL_IR_RECEIVE
request from CIRClass. This IOCTL utilizes direct I/O, and thus its data buffer is described using
a Memory Descriptor List (MDL). The data buffer for the IOCTL_IR_RECEIVE request is
formatted as an IR_RECEIVE_PARAMS structure:
typedef struct _IR_RECEIVE_PARAMS {
OUT ULONG_PTR DataEnd;
IN ULONG_PTR ByteCount;
OUT LONG Data[1];
}IR_RECEIVE_PARAMS, *PIR_RECEIVE_PARAMS;
Before sending the IOCTL_IR_RECEIVE request to the CIR Port driver, the CIRClass driver
initializes the fields in the IR_RECEIVE_PARAMS structure as follows:
ByteCount This field is set to the maximum number of data bytes that can be accommodated
in the receive data buffer.
When a CIR Port driver receives a packet of IR data from its hardware, it converts that data into
the RLC format previously described. It then returns the RLC data packet in the Data field of the
IR_RECEIVE_PARAMS structure.
Note that only two events can cause a CIR Port driver to consider an IR data packet "complete"
and therefore complete a pending IOCTL_IR_RECEIVE:
The CIR Port driver completely fills the data buffer with IR data. In this case, the CIR Port driver
sets the DataEnd field of the IR_RECEIVE_PARAMS structure to FALSE.
The IR sample period elapses, indicating the end of a stream of key presses. This sample period
is the time period that must elapse without IR data being received, after receiving one or more IR
key presses, before a "packet" of IR data is considered complete. In this case, the CIR Port driver
sets the DataEnd field of the IR_RECEIVE_PARMS structure to TRUE. The default timeout is
100 milliseconds.
In both cases, before completing the IOCTL_IR_RECEIVE request, the CIR Port driver sets the
ByteCount field of the IR_RECEIVE_PARAMS structure to the number of bytes of RLC-coded
data being returned in the data buffer. To complete the request, the CIR Port driver sets the
request's completion status to STATUS_SUCCESS and the request's information field to the
number of bytes returned in the IOCTL data buffer. Note that the byte count in the information
field includes both the RLC data bytes returned and the overhead of the IR_RECEIVE_PARMS
structure.