summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMarcus Glocker <mglocker@cvs.openbsd.org>2009-08-27 19:43:51 +0000
committerMarcus Glocker <mglocker@cvs.openbsd.org>2009-08-27 19:43:51 +0000
commited440f7ab35ca2f3ac25ea17a88a06540f00c323 (patch)
treebfec9206cd7375ec5715174df3f1185ee16ec15f /sys
parent01975d3d54e833fb99c394d7bd50ddf425731138 (diff)
Reduce padding overhead in compressed blocks.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/usb/udl.c26
-rw-r--r--sys/dev/usb/udl.h5
2 files changed, 18 insertions, 13 deletions
diff --git a/sys/dev/usb/udl.c b/sys/dev/usb/udl.c
index 64f99e1d608..fc9ad59f639 100644
--- a/sys/dev/usb/udl.c
+++ b/sys/dev/usb/udl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udl.c,v 1.26 2009/08/26 19:30:46 mglocker Exp $ */
+/* $OpenBSD: udl.c,v 1.27 2009/08/27 19:43:50 mglocker Exp $ */
/*
* Copyright (c) 2009 Marcus Glocker <mglocker@openbsd.org>
@@ -26,8 +26,6 @@
* This driver has been inspired by the cfxga(4) driver because we have
* to deal with similar challenges, like no direct access to the video
* memory.
- *
- * TODO: - Reduce padding overhead in compressed blocks.
*/
#include <sys/param.h>
@@ -1055,7 +1053,7 @@ udl_cmd_insert_buf_comp(struct udl_softc *sc, uint8_t *buf, uint32_t len)
uint16_t *pixels, prev;
int16_t diff;
uint32_t bit_count, bit_pattern, bit_cur;
- int i, j, bytes, eob, padding;
+ int i, j, bytes, eob, padding, next;
udl_cmd_insert_check(cb, len);
@@ -1067,7 +1065,7 @@ udl_cmd_insert_buf_comp(struct udl_softc *sc, uint8_t *buf, uint32_t len)
* skip the header and finish up the main-block. We return zero
* to signal our caller that the header has been skipped.
*/
- if (cb->compblock >= UDL_CB_RESTART1_SIZE) {
+ if (cb->compblock > UDL_CB_RESTART_SIZE) {
cb->off -= UDL_CMD_WRITE_HEAD_SIZE;
cb->compblock -= UDL_CMD_WRITE_HEAD_SIZE;
eob = 1;
@@ -1090,6 +1088,18 @@ udl_cmd_insert_buf_comp(struct udl_softc *sc, uint8_t *buf, uint32_t len)
bit_count = h->bit_count;
bit_pattern = betoh32(h->bit_pattern);
+
+ /* we are near the end of the main-block, so quit loop */
+ if (bit_count % 8 == 0)
+ next = bit_count / 8;
+ else
+ next = (bit_count / 8) + 1;
+
+ if (cb->compblock + next >= UDL_CB_BODY_SIZE) {
+ eob = 1;
+ break;
+ }
+
/* generate one pixel compressed data */
for (j = 0; j < bit_count; j++) {
if (bit_pos == 0)
@@ -1105,10 +1115,6 @@ udl_cmd_insert_buf_comp(struct udl_softc *sc, uint8_t *buf, uint32_t len)
}
}
bytes += 2;
-
- /* we are near the end of the main-block, so quit loop */
- if (cb->compblock >= UDL_CB_RESTART1_SIZE)
- eob = 1;
}
/*
@@ -1148,7 +1154,7 @@ udl_cmd_insert_head_comp(struct udl_softc *sc, uint32_t len)
udl_cmd_insert_check(cb, len);
- if (cb->compblock >= UDL_CB_RESTART2_SIZE) {
+ if (cb->compblock > UDL_CB_BODY_SIZE) {
cb->off -= UDL_CMD_COPY_HEAD_SIZE;
cb->compblock -= UDL_CMD_COPY_HEAD_SIZE;
diff --git a/sys/dev/usb/udl.h b/sys/dev/usb/udl.h
index 1ab664283e6..c278dc2e5c1 100644
--- a/sys/dev/usb/udl.h
+++ b/sys/dev/usb/udl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: udl.h,v 1.5 2009/08/26 12:23:39 mglocker Exp $ */
+/* $OpenBSD: udl.h,v 1.6 2009/08/27 19:43:50 mglocker Exp $ */
/*
* Copyright (c) 2009 Marcus Glocker <mglocker@openbsd.org>
@@ -172,8 +172,7 @@ struct udl_huffman {
#define UDL_CB_TOTAL_SIZE 512
#define UDL_CB_TAIL_SIZE 4
#define UDL_CB_BODY_SIZE (UDL_CB_TOTAL_SIZE - UDL_CB_TAIL_SIZE)
-#define UDL_CB_RESTART1_SIZE (UDL_CB_BODY_SIZE - 4)
-#define UDL_CB_RESTART2_SIZE (UDL_CB_BODY_SIZE - 9)
+#define UDL_CB_RESTART_SIZE (UDL_CB_BODY_SIZE - UDL_CB_TAIL_SIZE)
uint8_t udl_decomp_table[] = {
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,