Lines Matching full:rs

13  * encoding / decoding of RS codes.
16 * for the given rs parameters. The control struct is unique per instance.
52 /* This list holds all currently allocated rs codec structures */
62 * @fcr: first root of RS code generator polynomial, index form
64 * @nroots: RS code generator polynomial degree (number of roots)
74 struct rs_codec *rs; in codec_init() local
76 rs = kzalloc(sizeof(*rs), gfp); in codec_init()
77 if (!rs) in codec_init()
80 INIT_LIST_HEAD(&rs->list); in codec_init()
82 rs->mm = symsize; in codec_init()
83 rs->nn = (1 << symsize) - 1; in codec_init()
84 rs->fcr = fcr; in codec_init()
85 rs->prim = prim; in codec_init()
86 rs->nroots = nroots; in codec_init()
87 rs->gfpoly = gfpoly; in codec_init()
88 rs->gffunc = gffunc; in codec_init()
91 rs->alpha_to = kmalloc_array(rs->nn + 1, sizeof(uint16_t), gfp); in codec_init()
92 if (rs->alpha_to == NULL) in codec_init()
95 rs->index_of = kmalloc_array(rs->nn + 1, sizeof(uint16_t), gfp); in codec_init()
96 if (rs->index_of == NULL) in codec_init()
99 rs->genpoly = kmalloc_array(rs->nroots + 1, sizeof(uint16_t), gfp); in codec_init()
100 if(rs->genpoly == NULL) in codec_init()
104 rs->index_of[0] = rs->nn; /* log(zero) = -inf */ in codec_init()
105 rs->alpha_to[rs->nn] = 0; /* alpha**-inf = 0 */ in codec_init()
108 for (i = 0; i < rs->nn; i++) { in codec_init()
109 rs->index_of[sr] = i; in codec_init()
110 rs->alpha_to[i] = sr; in codec_init()
114 sr &= rs->nn; in codec_init()
118 for (i = 0; i < rs->nn; i++) { in codec_init()
119 rs->index_of[sr] = i; in codec_init()
120 rs->alpha_to[i] = sr; in codec_init()
125 if(sr != rs->alpha_to[0]) in codec_init()
129 for(iprim = 1; (iprim % prim) != 0; iprim += rs->nn); in codec_init()
131 rs->iprim = iprim / prim; in codec_init()
133 /* Form RS code generator polynomial from its roots */ in codec_init()
134 rs->genpoly[0] = 1; in codec_init()
136 rs->genpoly[i + 1] = 1; in codec_init()
137 /* Multiply rs->genpoly[] by @**(root + x) */ in codec_init()
139 if (rs->genpoly[j] != 0) { in codec_init()
140 rs->genpoly[j] = rs->genpoly[j -1] ^ in codec_init()
141 rs->alpha_to[rs_modnn(rs, in codec_init()
142 rs->index_of[rs->genpoly[j]] + root)]; in codec_init()
144 rs->genpoly[j] = rs->genpoly[j - 1]; in codec_init()
146 /* rs->genpoly[0] can never be zero */ in codec_init()
147 rs->genpoly[0] = in codec_init()
148 rs->alpha_to[rs_modnn(rs, in codec_init()
149 rs->index_of[rs->genpoly[0]] + root)]; in codec_init()
151 /* convert rs->genpoly[] to index form for quicker encoding */ in codec_init()
153 rs->genpoly[i] = rs->index_of[rs->genpoly[i]]; in codec_init()
155 rs->users = 1; in codec_init()
156 list_add(&rs->list, &codec_list); in codec_init()
157 return rs; in codec_init()
160 kfree(rs->genpoly); in codec_init()
161 kfree(rs->index_of); in codec_init()
162 kfree(rs->alpha_to); in codec_init()
163 kfree(rs); in codec_init()
169 * free_rs - Free the rs control structure
170 * @rs: The control structure which is not longer used by the
173 * Free the control structure. If @rs is the last user of the associated
176 void free_rs(struct rs_control *rs) in free_rs() argument
180 if (!rs) in free_rs()
183 cd = rs->codec; in free_rs()
194 kfree(rs); in free_rs()
199 * init_rs_internal - Allocate rs control, find a matching codec or allocate a new one
207 * @fcr: the first consecutive root of the rs code generator polynomial
210 * @nroots: RS code generator polynomial degree (number of roots)
218 struct rs_control *rs; in init_rs_internal() local
237 rs = kzalloc(sizeof(*rs) + bsize, gfp); in init_rs_internal()
238 if (!rs) in init_rs_internal()
261 rs->codec = cd; in init_rs_internal()
266 rs->codec = codec_init(symsize, gfpoly, gffunc, fcr, prim, nroots, gfp); in init_rs_internal()
267 if (!rs->codec) { in init_rs_internal()
268 kfree(rs); in init_rs_internal()
269 rs = NULL; in init_rs_internal()
273 return rs; in init_rs_internal()
277 * init_rs_gfp - Create a RS control struct and initialize it
282 * @fcr: the first consecutive root of the rs code generator polynomial
285 * @nroots: RS code generator polynomial degree (number of roots)
296 * init_rs_non_canonical - Allocate rs control struct for fields with
302 * @fcr: the first consecutive root of the rs code generator polynomial
305 * @nroots: RS code generator polynomial degree (number of roots)
318 * @rsc: the rs control structure
339 * @rsc: the rs control structure
373 * @rsc: the rs control structure
392 * @rsc: the rs control structure