2024-09-02 19:55:59 +09:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/sw842.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
|
|
|
|
#include "backend_842.h"
|
|
|
|
|
2024-09-02 19:56:07 +09:00
|
|
|
static void release_params_842(struct zcomp_params *params)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static int setup_params_842(struct zcomp_params *params)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-09-02 19:56:06 +09:00
|
|
|
static void destroy_842(struct zcomp_ctx *ctx)
|
2024-09-02 19:55:59 +09:00
|
|
|
{
|
2024-09-02 19:56:06 +09:00
|
|
|
kfree(ctx->context);
|
2024-09-02 19:55:59 +09:00
|
|
|
}
|
|
|
|
|
2024-09-02 19:56:06 +09:00
|
|
|
static int create_842(struct zcomp_params *params, struct zcomp_ctx *ctx)
|
2024-09-02 19:55:59 +09:00
|
|
|
{
|
2024-09-02 19:56:06 +09:00
|
|
|
ctx->context = kmalloc(SW842_MEM_COMPRESS, GFP_KERNEL);
|
|
|
|
if (!ctx->context)
|
|
|
|
return -ENOMEM;
|
|
|
|
return 0;
|
2024-09-02 19:55:59 +09:00
|
|
|
}
|
|
|
|
|
2024-09-02 19:56:07 +09:00
|
|
|
static int compress_842(struct zcomp_params *params, struct zcomp_ctx *ctx,
|
|
|
|
struct zcomp_req *req)
|
2024-09-02 19:55:59 +09:00
|
|
|
{
|
2024-09-02 19:56:05 +09:00
|
|
|
unsigned int dlen = req->dst_len;
|
2024-09-02 19:55:59 +09:00
|
|
|
int ret;
|
|
|
|
|
2024-09-02 19:56:05 +09:00
|
|
|
ret = sw842_compress(req->src, req->src_len, req->dst, &dlen,
|
2024-09-02 19:56:06 +09:00
|
|
|
ctx->context);
|
2024-09-02 19:55:59 +09:00
|
|
|
if (ret == 0)
|
2024-09-02 19:56:05 +09:00
|
|
|
req->dst_len = dlen;
|
2024-09-02 19:55:59 +09:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-09-02 19:56:07 +09:00
|
|
|
static int decompress_842(struct zcomp_params *params, struct zcomp_ctx *ctx,
|
|
|
|
struct zcomp_req *req)
|
2024-09-02 19:55:59 +09:00
|
|
|
{
|
2024-09-02 19:56:05 +09:00
|
|
|
unsigned int dlen = req->dst_len;
|
2024-09-02 19:55:59 +09:00
|
|
|
|
2024-09-02 19:56:05 +09:00
|
|
|
return sw842_decompress(req->src, req->src_len, req->dst, &dlen);
|
2024-09-02 19:55:59 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
const struct zcomp_ops backend_842 = {
|
|
|
|
.compress = compress_842,
|
|
|
|
.decompress = decompress_842,
|
|
|
|
.create_ctx = create_842,
|
|
|
|
.destroy_ctx = destroy_842,
|
2024-09-02 19:56:07 +09:00
|
|
|
.setup_params = setup_params_842,
|
|
|
|
.release_params = release_params_842,
|
2024-09-02 19:55:59 +09:00
|
|
|
.name = "842",
|
|
|
|
};
|