Raw Video
The CX2388x video stream (function 0) allows for raw pixel data to be transferred either from an analog frontend or VIP-compliant device into host memory. The raw video stream supports a variety of pixel formats, and can utilize either packed or planar color formats. One DMA channel is used to transfer either packed pixel data or the Y color plane, while two additional channels are provided to transfer the U and V color planes (obviously for planar formats only). A fourth DMA channel can be used to transfer vertical blanking interval (VBI) data, which is typically used to convey teletext or closed captioning.
The ioctl(2) interface is provided by /usr/local/include/cx88/cx88_video_ioctl.h, and works in a similar fashion to the MPEG TS ioctl interface. The video stream does expose a richer set of controls than MPEG TS, because raw video is fundamentally more flexible from a hardware standpoint. Besides using an actual hardware decoder, there are few meaningful transformations that can be made in hardware to an MPEG stream.
The buffering scheme for raw video works in a slightly different way than for MPEG--the CX88_VIDEO_CONFIGURE ioctl requires the number of frames, and each buffer that is allocated by the driver (or provided by the application) will constitute a single frame for its color or VBI channel. Additionally, the CX88_VIDEO_FORMAT ioctl should be issued before CX88_VIDEO_CONFIGURE in order to obtain buffer geometry for each channel.
Video Formatting
The CX2388x video function can perform image scaling and cropping in hardware, and the CX88_VIDEO_FORMAT ioctl takes advantage of this by allowing the application to specify the scaled size of the image through the in_rows and in_cols fields of the ioctl parameter structure. Scaling is typically used to make the image smaller rather than larger, though (for example) an NTSC frame can be scaled as high as 720x480, while an unscaled NTSC frame would have 640 and 480 in the in_cols and in_rows fields, respectively. The in_x_offset, in_y_offset, in_x_size, and in_y_size can then be used to set the cropping region with respect to the scaled image. Buffer sizes for each channel can be computed using the out_geoms field, in which the num_lines subfield will typically be the same as in_y_size, and the line_size field will typically be in_x_size * <bytes per pixel>.
Video Composition & Clipping
The DMA engine can be instructed to place a frame at an arbitrary location within a larger frame. This is done via the per-channel header/trailer fields in the CX88_VIDEO_CONFIGURE parameter. The in_x_header and in_x_trailer fields specify the position of each line of the generated frame within the larger buffer, while the in_y_header and in_y_trailer fields specify the vertical position of the generated frame within the larger buffer.
The CX2388x also has hardware support for clipping regions of arbitrary complexity. The cx88 driver provides access to this via the CX88_VIDEO_CLIP ioctl. For each video channel, a buffer containing the clipping region(s) is specified through the in_patterns field, along with the buffer size (in bytes) through the in_pattern_size field. The buffer should consist of a series of cx88_video_clip_pattern structures, stored sequentially. The cx88_video_clip_pattern structure uses a C99 flexible array member (in_points) to store an arbitrary number of 16-bit integers that specify the clipping region as a series of points that define where, in each line, the video data should be captured or omitted. The in_start_line and in_end_line fields define the inclusive range of lines to which the clipping points in in_points apply, and the in_clip_type field specifies whether the line should begin with data captured or omitted. Each subsequent point in the in_points array will toggle between capturing and omitting the video data.