1# Copyright (c) 2020 Linumiz
2# SPDX-License-Identifier: Apache-2.0
3
4config ZEPHYR_LZ4_MODULE
5	bool
6
7menuconfig LZ4
8	bool "Lz4 data compression and decompression"
9	help
10	  This option enables lz4 compression & decompression library
11	  support.
12if LZ4
13
14config LZ4_MEMORY_USAGE
15	int "Lz4 memory usage"
16	range 10 20
17	default 14
18	help
19	  Increasing memory usage improves compression ratio, but usually at the
20	  cost of speed, due to cache locality. Memory usage 2^value (10 -> 1KB,
21	  12 -> 4KB, 20 -> 1MB).
22
23config LZ4_DISABLE_DYNAMIC_MEMORY_ALLOCATION
24	bool "Disable dynamic memory allocation"
25	help
26	  Disable lz4 functions that use dynamic memory allocation functions.
27
28choice LZ4_HEAPMODE
29	prompt "How stateless compression functions allocate memory for their hash table"
30	default LZ4_HEAPMODE_HEAP
31
32config LZ4_HEAPMODE_STACK
33	bool "in memory stack"
34	help
35	  Allocate memory from stack (fastest).
36
37config LZ4_HEAPMODE_HEAP
38	bool "in memory heap"
39	depends on !LZ4_DISABLE_DYNAMIC_MEMORY_ALLOCATION
40	help
41	  Allocate memory from heap (requires malloc()).
42endchoice
43
44config LZ4_HIGH_COMPRESSION_VARIANT
45	bool "Lz4 high compression variant"
46	help
47	  For more compression ratio at the cost of compression speed,
48	  the High Compression variant called lz4hc is available. This variant
49	  also compresses data using the lz4 block format.
50
51if LZ4_HIGH_COMPRESSION_VARIANT
52choice LZ4HC_HEAPMODE
53	prompt "How stateless HC compression functions allocate memory for their workspace"
54	default LZ4HC_HEAPMODE_HEAP
55
56config LZ4HC_HEAPMODE_STACK
57	bool "in memory stack"
58	help
59	  Allocate memory from stack (fastest).
60
61config LZ4HC_HEAPMODE_HEAP
62	bool "in memory heap"
63	depends on !LZ4_DISABLE_DYNAMIC_MEMORY_ALLOCATION
64	help
65	  Allocate memory from heap (requires malloc()).
66endchoice
67endif
68
69config LZ4_XX_HASH
70	bool "xxHash hashing algorithm"
71	help
72	  Build xxHash library included in lz4 sources.
73
74config LZ4_FRAME_SUPPORT
75	bool "LZ4 frame support"
76	select LZ4_XX_HASH
77	select LZ4_HIGH_COMPRESSION_VARIANT
78	help
79	  In order to produce compressed data compatible with lz4 command line
80	  utility, it's necessary to use the official interoperable frame format.
81	  This format is generated and decoded automatically by the lz4frame library.
82	  Its public API is described in lib/lz4frame.h.
83
84if LZ4_FRAME_SUPPORT
85choice LZ4F_HEAPMODE
86	prompt "Control how LZ4F_compressFrame() allocates the Compression State"
87	default LZ4F_HEAPMODE_STACK
88
89config LZ4F_HEAPMODE_STACK
90	bool "in memory stack"
91	help
92	  Allocate memory from stack (fastest).
93
94config LZ4F_HEAPMODE_HEAP
95	bool "in memory heap"
96	depends on !LZ4_DISABLE_DYNAMIC_MEMORY_ALLOCATION
97	help
98	  Allocate memory from heap (requires malloc()).
99endchoice
100endif
101
102endif
103