| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Generic binary BCH encoding/decoding library |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 5 | | - * under the terms of the GNU General Public License version 2 as published by |
|---|
| 6 | | - * the Free Software Foundation. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 9 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 10 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 11 | | - * more details. |
|---|
| 12 | | - * |
|---|
| 13 | | - * You should have received a copy of the GNU General Public License along with |
|---|
| 14 | | - * this program; if not, write to the Free Software Foundation, Inc., 51 |
|---|
| 15 | | - * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|---|
| 16 | 4 | * |
|---|
| 17 | 5 | * Copyright © 2011 Parrot S.A. |
|---|
| 18 | 6 | * |
|---|
| .. | .. |
|---|
| 45 | 33 | * @cache: log-based polynomial representation buffer |
|---|
| 46 | 34 | * @elp: error locator polynomial |
|---|
| 47 | 35 | * @poly_2t: temporary polynomials of degree 2t |
|---|
| 36 | + * @swap_bits: swap bits within data and syndrome bytes |
|---|
| 48 | 37 | */ |
|---|
| 49 | 38 | struct bch_control { |
|---|
| 50 | 39 | unsigned int m; |
|---|
| .. | .. |
|---|
| 63 | 52 | int *cache; |
|---|
| 64 | 53 | struct gf_poly *elp; |
|---|
| 65 | 54 | struct gf_poly *poly_2t[4]; |
|---|
| 55 | + bool swap_bits; |
|---|
| 66 | 56 | }; |
|---|
| 67 | 57 | |
|---|
| 68 | | -struct bch_control *init_bch(int m, int t, unsigned int prim_poly); |
|---|
| 58 | +struct bch_control *bch_init(int m, int t, unsigned int prim_poly, |
|---|
| 59 | + bool swap_bits); |
|---|
| 69 | 60 | |
|---|
| 70 | | -void free_bch(struct bch_control *bch); |
|---|
| 61 | +void bch_free(struct bch_control *bch); |
|---|
| 71 | 62 | |
|---|
| 72 | | -void encode_bch(struct bch_control *bch, const uint8_t *data, |
|---|
| 63 | +void bch_encode(struct bch_control *bch, const uint8_t *data, |
|---|
| 73 | 64 | unsigned int len, uint8_t *ecc); |
|---|
| 74 | 65 | |
|---|
| 75 | | -int decode_bch(struct bch_control *bch, const uint8_t *data, unsigned int len, |
|---|
| 66 | +int bch_decode(struct bch_control *bch, const uint8_t *data, unsigned int len, |
|---|
| 76 | 67 | const uint8_t *recv_ecc, const uint8_t *calc_ecc, |
|---|
| 77 | 68 | const unsigned int *syn, unsigned int *errloc); |
|---|
| 78 | 69 | |
|---|