/* * Render a command stream for an encoded horizontal line segment of pixels. * * A command buffer holds several commands. * It always begins with a fresh command header * (the protocol doesn't require this, but we enforce it to allow * multiple buffers to be potentially encoded and sent in parallel). * A single command encodes one contiguous horizontal line of pixels * * The function relies on the client to do all allocation, so that * rendering can be done directly to output buffers (e.g. USB URBs). * The function fills the supplied command buffer, providing information * on where it left off, so the client may call in again with additional * buffers if the line will take several buffers to complete. * * A single command can transmit a maximum of 256 pixels, * regardless of the compression ratio (protocol design limit). * To the hardware, 0 for a size byte means 256 * * Rather than 256 pixel commands which are either rl or raw encoded, * the rlx command simply assumes alternating raw and rl spans within one cmd. * This has a slightly larger header overhead, but produces more even results. * It also processes all data (read and write) in a single pass. * Performance benchmarks of common cases show it having just slightly better * compression than 256 pixel raw or rle commands, with similar CPU consumpion. * But for very rl friendly data, will compress not quite as well.
*/ staticvoid udl_compress_hline16( const u8 **pixel_start_ptr, const u8 *const pixel_end,
uint32_t *device_address_ptr,
uint8_t **command_buffer_ptr, const uint8_t *const cmd_buffer_end, int log_bpp)
{ constint bpp = 1 << log_bpp; const u8 *pixel = *pixel_start_ptr;
uint32_t dev_addr = *device_address_ptr;
uint8_t *cmd = *command_buffer_ptr;
while (pixel < cmd_pixel_end) {
pixel_val16 = get_pixel_val16(pixel, log_bpp); if (pixel_val16 != repeating_pixel_val16) break;
pixel += bpp;
}
if (unlikely(pixel > start + bpp)) { /* go back and fill in raw pixel count */
*raw_pixels_count_byte = (((start -
raw_pixel_start) >> log_bpp) + 1) & 0xFF;
/* immediately after raw data is repeat byte */
*cmd++ = (((pixel - start) >> log_bpp) - 1) & 0xFF;
/* Then start another raw pixel span */
raw_pixel_start = pixel;
raw_pixels_count_byte = cmd++;
}
}
if (pixel > raw_pixel_start) { /* finalize last RAW span */
*raw_pixels_count_byte = ((pixel - raw_pixel_start) >> log_bpp) & 0xFF;
} else { /* undo unused byte */
cmd--;
}
/* * There are 3 copies of every pixel: The front buffer that the fbdev * client renders to, the actual framebuffer across the USB bus in hardware * (that we can only write to, slowly, and can never read), and (optionally) * our shadow copy that tracks what's been sent to that hardware buffer.
*/ int udl_render_hline(struct udl_device *udl, int log_bpp, struct urb **urb_ptr, constchar *front, char **urb_buf_ptr,
u32 byte_offset, u32 device_byte_offset,
u32 byte_width)
{ const u8 *line_start, *line_end, *next_pixel;
u32 base16 = 0 + (device_byte_offset >> log_bpp) * 2; struct urb *urb = *urb_ptr;
u8 *cmd = *urb_buf_ptr;
u8 *cmd_end = (u8 *) urb->transfer_buffer + urb->transfer_buffer_length;
if (WARN_ON(!(log_bpp == 1 || log_bpp == 2))) { /* need to finish URB at error from this function */
udl_urb_completion(urb); return -EINVAL;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.