Lines Matching refs:p
65 static int next_bits(struct sw842_param *p, u64 *d, u8 n);
67 static int __split_next_bits(struct sw842_param *p, u64 *d, u8 n, u8 s) in __split_next_bits() argument
77 ret = next_bits(p, &tmp, n - s); in __split_next_bits()
80 ret = next_bits(p, d, s); in __split_next_bits()
87 static int next_bits(struct sw842_param *p, u64 *d, u8 n) in next_bits() argument
89 u8 *in = p->in, b = p->bit, bits = b + n; in next_bits()
100 return __split_next_bits(p, d, n, 32); in next_bits()
101 else if (p->ilen < 8 && bits > 32 && bits <= 56) in next_bits()
102 return __split_next_bits(p, d, n, 16); in next_bits()
103 else if (p->ilen < 4 && bits > 16 && bits <= 24) in next_bits()
104 return __split_next_bits(p, d, n, 8); in next_bits()
106 if (DIV_ROUND_UP(bits, 8) > p->ilen) in next_bits()
120 p->bit += n; in next_bits()
122 if (p->bit > 7) { in next_bits()
123 p->in += p->bit / 8; in next_bits()
124 p->ilen -= p->bit / 8; in next_bits()
125 p->bit %= 8; in next_bits()
131 static int do_data(struct sw842_param *p, u8 n) in do_data() argument
136 if (n > p->olen) in do_data()
139 ret = next_bits(p, &v, n * 8); in do_data()
145 put_unaligned(cpu_to_be16((u16)v), (__be16 *)p->out); in do_data()
148 put_unaligned(cpu_to_be32((u32)v), (__be32 *)p->out); in do_data()
151 put_unaligned(cpu_to_be64((u64)v), (__be64 *)p->out); in do_data()
157 p->out += n; in do_data()
158 p->olen -= n; in do_data()
163 static int __do_index(struct sw842_param *p, u8 size, u8 bits, u64 fsize) in __do_index() argument
165 u64 index, offset, total = round_down(p->out - p->ostart, 8); in __do_index()
168 ret = next_bits(p, &index, bits); in __do_index()
203 (unsigned long)beN_to_cpu(&p->ostart[offset], size)); in __do_index()
205 memcpy(p->out, &p->ostart[offset], size); in __do_index()
206 p->out += size; in __do_index()
207 p->olen -= size; in __do_index()
212 static int do_index(struct sw842_param *p, u8 n) in do_index() argument
216 return __do_index(p, 2, I2_BITS, I2_FIFO_SIZE); in do_index()
218 return __do_index(p, 4, I4_BITS, I4_FIFO_SIZE); in do_index()
220 return __do_index(p, 8, I8_BITS, I8_FIFO_SIZE); in do_index()
226 static int do_op(struct sw842_param *p, u8 o) in do_op() argument
240 ret = do_data(p, op & OP_AMOUNT); in do_op()
243 ret = do_index(p, op & OP_AMOUNT); in do_op()
280 struct sw842_param p; in sw842_decompress() local
285 p.in = (u8 *)in; in sw842_decompress()
286 p.bit = 0; in sw842_decompress()
287 p.ilen = ilen; in sw842_decompress()
288 p.out = out; in sw842_decompress()
289 p.ostart = out; in sw842_decompress()
290 p.olen = *olen; in sw842_decompress()
292 total = p.olen; in sw842_decompress()
297 ret = next_bits(&p, &op, OP_BITS); in sw842_decompress()
305 ret = next_bits(&p, &rep, REPEAT_BITS); in sw842_decompress()
309 if (p.out == out) /* no previous bytes */ in sw842_decompress()
315 if (rep * 8 > p.olen) in sw842_decompress()
319 memcpy(p.out, p.out - 8, 8); in sw842_decompress()
320 p.out += 8; in sw842_decompress()
321 p.olen -= 8; in sw842_decompress()
329 if (8 > p.olen) in sw842_decompress()
332 memset(p.out, 0, 8); in sw842_decompress()
333 p.out += 8; in sw842_decompress()
334 p.olen -= 8; in sw842_decompress()
341 ret = next_bits(&p, &bytes, SHORT_DATA_BITS); in sw842_decompress()
349 ret = next_bits(&p, &tmp, 8); in sw842_decompress()
352 *p.out = (u8)tmp; in sw842_decompress()
353 p.out++; in sw842_decompress()
354 p.olen--; in sw842_decompress()
367 ret = do_op(&p, op); in sw842_decompress()
378 ret = next_bits(&p, &crc, CRC_BITS); in sw842_decompress()
385 if (crc != (u64)crc32_be(0, out, total - p.olen)) { in sw842_decompress()
390 if (unlikely((total - p.olen) > UINT_MAX)) in sw842_decompress()
393 *olen = total - p.olen; in sw842_decompress()