summaryrefslogtreecommitdiffstats
path: root/meta/packages/mtd/mtd-utils/add_lzo.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/packages/mtd/mtd-utils/add_lzo.patch')
-rw-r--r--meta/packages/mtd/mtd-utils/add_lzo.patch222
1 files changed, 0 insertions, 222 deletions
diff --git a/meta/packages/mtd/mtd-utils/add_lzo.patch b/meta/packages/mtd/mtd-utils/add_lzo.patch
deleted file mode 100644
index 3421571372..0000000000
--- a/meta/packages/mtd/mtd-utils/add_lzo.patch
+++ /dev/null
@@ -1,222 +0,0 @@
1Subject: [mtd-utils patch 1/2] Add lzo support to mtd-utils
2
3Add LZO support to mtd-utils to generate LZO compressed jffs2 images
4
5Unlike the kernel version, the standard lzo userspace library is used
6along with lzo1x_999_compress rather than the lzo1x_1_compress version
7since better compression ratios can be obtained (at no significant cost
8to decompression time).
9
10Signed-off-by: Richard Purdie <rpurdie@openedhand.com>
11
12---
13 Makefile | 3 -
14 compr.c | 6 ++
15 compr.h | 6 ++
16 compr_lzo.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++
17 include/linux/jffs2.h | 1
18 5 files changed, 135 insertions(+), 1 deletion(-)
19
20Index: git/Makefile
21===================================================================
22--- git.orig/Makefile 2007-03-01 11:57:58.000000000 +0000
23+++ git/Makefile 2007-03-01 11:58:01.000000000 +0000
24@@ -58,8 +58,9 @@ $(BUILDDIR)/mkfs.jffs2: $(BUILDDIR)/crc3
25 $(BUILDDIR)/compr_rtime.o \
26 $(BUILDDIR)/mkfs.jffs2.o \
27 $(BUILDDIR)/compr_zlib.o \
28+ $(BUILDDIR)/compr_lzo.o \
29 $(BUILDDIR)/compr.o
30- $(CC) $(LDFLAGS) -o $@ $^ -lz
31+ $(CC) $(LDFLAGS) -o $@ $^ -lz -llzo
32
33 $(BUILDDIR)/flash_eraseall: $(BUILDDIR)/crc32.o $(BUILDDIR)/flash_eraseall.o
34 $(CC) $(LDFLAGS) -o $@ $^
35Index: git/compr.c
36===================================================================
37--- git.orig/compr.c 2007-03-01 11:57:58.000000000 +0000
38+++ git/compr.c 2007-03-01 11:58:01.000000000 +0000
39@@ -474,6 +474,9 @@ int jffs2_compressors_init(void)
40 #ifdef CONFIG_JFFS2_RTIME
41 jffs2_rtime_init();
42 #endif
43+#ifdef CONFIG_JFFS2_LZO
44+ jffs2_lzo_init();
45+#endif
46 return 0;
47 }
48
49@@ -485,5 +488,8 @@ int jffs2_compressors_exit(void)
50 #ifdef CONFIG_JFFS2_ZLIB
51 jffs2_zlib_exit();
52 #endif
53+#ifdef CONFIG_JFFS2_LZO
54+ jffs2_lzo_exit();
55+#endif
56 return 0;
57 }
58Index: git/compr.h
59===================================================================
60--- git.orig/compr.h 2007-03-01 11:57:58.000000000 +0000
61+++ git/compr.h 2007-03-01 11:58:01.000000000 +0000
62@@ -21,11 +21,13 @@
63
64 #define CONFIG_JFFS2_ZLIB
65 #define CONFIG_JFFS2_RTIME
66+#define CONFIG_JFFS2_LZO
67
68 #define JFFS2_RUBINMIPS_PRIORITY 10
69 #define JFFS2_DYNRUBIN_PRIORITY 20
70 #define JFFS2_RTIME_PRIORITY 50
71 #define JFFS2_ZLIB_PRIORITY 60
72+#define JFFS2_LZO_PRIORITY 80
73
74 #define JFFS2_COMPR_MODE_NONE 0
75 #define JFFS2_COMPR_MODE_PRIORITY 1
76@@ -111,5 +113,9 @@ void jffs2_zlib_exit(void);
77 int jffs2_rtime_init(void);
78 void jffs2_rtime_exit(void);
79 #endif
80+#ifdef CONFIG_JFFS2_LZO
81+int jffs2_lzo_init(void);
82+void jffs2_lzo_exit(void);
83+#endif
84
85 #endif /* __JFFS2_COMPR_H__ */
86Index: git/compr_lzo.c
87===================================================================
88--- /dev/null 1970-01-01 00:00:00.000000000 +0000
89+++ git/compr_lzo.c 2007-03-01 11:58:01.000000000 +0000
90@@ -0,0 +1,120 @@
91+/*
92+ * JFFS2 LZO Compression Interface.
93+ *
94+ * Copyright (C) 2007 Nokia Corporation. All rights reserved.
95+ *
96+ * Author: Richard Purdie <rpurdie@openedhand.com>
97+ *
98+ * This program is free software; you can redistribute it and/or
99+ * modify it under the terms of the GNU General Public License
100+ * version 2 as published by the Free Software Foundation.
101+ *
102+ * This program is distributed in the hope that it will be useful, but
103+ * WITHOUT ANY WARRANTY; without even the implied warranty of
104+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
105+ * General Public License for more details.
106+ *
107+ * You should have received a copy of the GNU General Public License
108+ * along with this program; if not, write to the Free Software
109+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
110+ * 02110-1301 USA
111+ *
112+ */
113+
114+#include <stdint.h>
115+#include <stdio.h>
116+#include <string.h>
117+#include <asm/types.h>
118+#include <linux/jffs2.h>
119+#include <lzo1x.h>
120+#include "compr.h"
121+
122+extern int page_size;
123+
124+static void *lzo_mem;
125+static void *lzo_compress_buf;
126+
127+/*
128+ * Note about LZO compression.
129+ *
130+ * We want to use the _999_ compression routine which gives better compression
131+ * rates at the expense of time. Decompression time is unaffected. We might as
132+ * well use the standard lzo library routines for this but they will overflow
133+ * the destination buffer since they don't check the destination size.
134+ *
135+ * We therefore compress to a temporary buffer and copy if it will fit.
136+ *
137+ */
138+static int jffs2_lzo_cmpr(unsigned char *data_in, unsigned char *cpage_out,
139+ uint32_t *sourcelen, uint32_t *dstlen, void *model)
140+{
141+ uint32_t compress_size;
142+ int ret;
143+
144+ ret = lzo1x_999_compress(data_in, *sourcelen, lzo_compress_buf, &compress_size, lzo_mem);
145+
146+ if (ret != LZO_E_OK)
147+ return -1;
148+
149+ if (compress_size > *dstlen)
150+ return -1;
151+
152+ memcpy(cpage_out, lzo_compress_buf, compress_size);
153+ *dstlen = compress_size;
154+
155+ return 0;
156+}
157+
158+static int jffs2_lzo_decompress(unsigned char *data_in, unsigned char *cpage_out,
159+ uint32_t srclen, uint32_t destlen, void *model)
160+{
161+ int ret;
162+ uint32_t dl;
163+
164+ ret = lzo1x_decompress_safe(data_in,srclen,cpage_out,&dl,NULL);
165+
166+ if (ret != LZO_E_OK || dl != destlen)
167+ return -1;
168+
169+ return 0;
170+}
171+
172+static struct jffs2_compressor jffs2_lzo_comp = {
173+ .priority = JFFS2_LZO_PRIORITY,
174+ .name = "lzo",
175+ .compr = JFFS2_COMPR_LZO,
176+ .compress = &jffs2_lzo_cmpr,
177+ .decompress = &jffs2_lzo_decompress,
178+ .disabled = 0,
179+};
180+
181+int jffs2_lzo_init(void)
182+{
183+ int ret;
184+
185+ lzo_mem = malloc(LZO1X_999_MEM_COMPRESS);
186+ if (!lzo_mem)
187+ return -1;
188+
189+ /* Worse case LZO compression size from their FAQ */
190+ lzo_compress_buf = malloc(page_size + (page_size / 64) + 16 + 3);
191+ if (!lzo_compress_buf) {
192+ free(lzo_mem);
193+ return -1;
194+ }
195+
196+ ret = jffs2_register_compressor(&jffs2_lzo_comp);
197+ if (ret < 0) {
198+ free(lzo_compress_buf);
199+ free(lzo_mem);
200+ }
201+
202+ return ret;
203+}
204+
205+void jffs2_lzo_exit(void)
206+{
207+ jffs2_unregister_compressor(&jffs2_lzo_comp);
208+ free(lzo_compress_buf);
209+ free(lzo_mem);
210+}
211Index: git/include/linux/jffs2.h
212===================================================================
213--- git.orig/include/linux/jffs2.h 2007-03-01 11:57:58.000000000 +0000
214+++ git/include/linux/jffs2.h 2007-03-01 11:58:01.000000000 +0000
215@@ -46,6 +46,7 @@
216 #define JFFS2_COMPR_COPY 0x04
217 #define JFFS2_COMPR_DYNRUBIN 0x05
218 #define JFFS2_COMPR_ZLIB 0x06
219+#define JFFS2_COMPR_LZO 0x07
220 /* Compatibility flags. */
221 #define JFFS2_COMPAT_MASK 0xc000 /* What do to if an unknown nodetype is found */
222 #define JFFS2_NODE_ACCURATE 0x2000