MPEG Transport Stream
The MPEG Transport Stream (Function 2) exposes an interface for transferring MPEG-2 packets generated by an encoder or digital frontend to host memory. The ioctl(2) interface is defined in /usr/local/include/cx88/cx88_mpeg_ioctl.h. Typically, an application will first issue the CX88_MPEG_CONFIG ioctl to provide the DMA buffer configuration to the driver. The application can choose to either provide a buffer of its own, or to mmap(2) a buffer allocated by the kernel driver. For the latter case, the allocated buffers will be persisted until the buffer configuration is changed by another CX88_MPEG_CONFIG ioctl, either by the same application instance or a different one. The CX88_MPEG_CONFIG ioctl only requires that the application specify the total number of MPEG packets for which buffer space should be allocated. The driver then splits the total requested packet allocation into a series of buffers in order allow the application to process the contents of one or more buffers while DMA is being performed to other buffers. For kernel-allocated buffers, the CX88_MPEG_CONFIG ioctl will return the actual number of allocated packets, which may be slightly different from the requested number to allow better utilization of the SRAM FIFO space.
Applications may choose to omit the CX88_MPEG_CONFIG ioctl if they can be sure the driver is already configured. If the driver is not already configured, attempts to initiate capture on the device will return an error. Captures are controlled via the CX88_MPEG_CAPTURE and CX88_MPEG_STOP ioctls, while the CX88_MPEG_WAIT ioctl can be used to wait for data to become available after a capture has been started.