DGS Driver
2-86
Transform Functions
The following transform functions are already provided with the DGS
driver:
❏
u32tou8/u8tou32
. These functions provide conversion to/from
packed unsigned 8-bit integers to unsigned 32-bit integers. The
buffer must contain a multiple of 4 number of 32-bit/8-bit unsigned
values.
❏
u16tou32/u32tou16
. These functions provide conversion to/from
packed unsigned 16-bit integers to unsigned 32-bit integers. The
buffer must contain an even number of 16-bit/32-bit unsigned values.
❏
i16toi32/i32toi16
. These functions provide conversion to/from
packed signed 16-bit integers to signed 32-bit integers. The buffer
must contain an even number of 16-bit/32-bit integers.
❏
u8toi16/i16tou8
. These functions provide conversion to/from a
packed 8-bit format (two 8-bit words in one 16-bit word) to a one word
per 16 bit format.
❏
i16tof32/f32toi16
. These functions provide conversion to/from
packed signed 16-bit integers to 32-bit floating point values. The
buffer must contain an even number of 16-bit integers/32-bit floats.
❏
localcopy
. This function simply passes the data to the underlying
device without packing or compressing it.
Data Streaming
DGS devices can be opened for input or output. DGS_open allocates
buffers for use by the underlying device. For input devices, the size of
these buffers is (bufsize * numerator) / denominator. For output devices,
the size of these buffers is (bufsize * denominator) / numerator. Data is
transformed into or out of these buffers before or after calling the
underlying device’s output or input functions respectively.
You can use the same stacking device in more that one stream, provided
that the terminating device underneath it is not the same. For example, if
u32tou8 is a DGS device, you can create two streams dynamically as
follows:
stream = SIO_create("/u32tou8/codec", SIO_INPUT, 128, NULL);
...
stream = SIO_create("/u32tou8/port", SIO_INPUT, 128, NULL);
You can also create the streams with Tconf. To do that, add two new SIO
objects. Enter /codec (or any other configured terminal device) as the
Device Control String for the first stream. Then select the DGS device
configured to use u32tou8 in the Device property. For the second stream,
enter /port as the Device Control String. Then select the DGS device
configured to use u32tou8 in the Device property.