2 * Copyright (C) 2014 Sergey Senozhatsky.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
13 #include <linux/mutex.h>
16 /* compression/decompression buffer */
19 * The private data of the compression stream, only compression
20 * stream backend can touch this (e.g. compression algorithm
24 /* used in multi stream backend, protected by backend strm_lock */
25 struct list_head list
;
28 /* static compression backend */
29 struct zcomp_backend
{
30 int (*compress
)(const unsigned char *src
, unsigned char *dst
,
31 size_t *dst_len
, void *private);
33 int (*decompress
)(const unsigned char *src
, size_t src_len
,
36 void *(*create
)(void);
37 void (*destroy
)(void *private);
42 /* dynamic per-device compression frontend */
45 struct zcomp_backend
*backend
;
47 struct zcomp_strm
*(*strm_find
)(struct zcomp
*comp
);
48 void (*strm_release
)(struct zcomp
*comp
, struct zcomp_strm
*zstrm
);
49 bool (*set_max_streams
)(struct zcomp
*comp
, int num_strm
);
50 void (*destroy
)(struct zcomp
*comp
);
53 ssize_t
zcomp_available_show(const char *comp
, char *buf
);
54 bool zcomp_available_algorithm(const char *comp
);
56 struct zcomp
*zcomp_create(const char *comp
, int max_strm
);
57 void zcomp_destroy(struct zcomp
*comp
);
59 struct zcomp_strm
*zcomp_strm_find(struct zcomp
*comp
);
60 void zcomp_strm_release(struct zcomp
*comp
, struct zcomp_strm
*zstrm
);
62 int zcomp_compress(struct zcomp
*comp
, struct zcomp_strm
*zstrm
,
63 const unsigned char *src
, size_t *dst_len
);
65 int zcomp_decompress(struct zcomp
*comp
, const unsigned char *src
,
66 size_t src_len
, unsigned char *dst
);
68 bool zcomp_set_max_streams(struct zcomp
*comp
, int num_strm
);
69 #endif /* _ZCOMP_H_ */