• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/staging/echo/

Lines Matching defs:ec

120 static inline void lms_adapt_bg(struct oslec_state *ec, int clean,
138 offset2 = ec->curr_pos;
139 offset1 = ec->taps - offset2;
140 phist = &ec->fir_state_bg.history[offset2];
145 n = ec->taps;
148 ec->fir_taps16[1][i] += (int16_t) ((exp + (1 << 14)) >> 15);
192 static inline void lms_adapt_bg(struct oslec_state *ec, int clean,
209 offset2 = ec->curr_pos;
210 offset1 = ec->taps - offset2;
212 for (i = ec->taps - 1; i >= offset1; i--) {
213 exp = (ec->fir_state_bg.history[i - offset1] * factor);
214 ec->fir_taps16[1][i] += (int16_t) ((exp + (1 << 14)) >> 15);
217 exp = (ec->fir_state_bg.history[i + offset2] * factor);
218 ec->fir_taps16[1][i] += (int16_t) ((exp + (1 << 14)) >> 15);
233 struct oslec_state *ec;
236 ec = kzalloc(sizeof(*ec), GFP_KERNEL);
237 if (!ec)
240 ec->taps = len;
241 ec->log2taps = top_bit(len);
242 ec->curr_pos = ec->taps - 1;
245 ec->fir_taps16[i] =
246 kcalloc(ec->taps, sizeof(int16_t), GFP_KERNEL);
247 if (!ec->fir_taps16[i])
251 fir16_create(&ec->fir_state, ec->fir_taps16[0], ec->taps);
252 fir16_create(&ec->fir_state_bg, ec->fir_taps16[1], ec->taps);
255 ec->xvtx[i] = ec->yvtx[i] = ec->xvrx[i] = ec->yvrx[i] = 0;
257 ec->cng_level = 1000;
258 oslec_adaption_mode(ec, adaption_mode);
260 ec->snapshot = kcalloc(ec->taps, sizeof(int16_t), GFP_KERNEL);
261 if (!ec->snapshot)
264 ec->cond_met = 0;
265 ec->Pstates = 0;
266 ec->Ltxacc = ec->Lrxacc = ec->Lcleanacc = ec->Lclean_bgacc = 0;
267 ec->Ltx = ec->Lrx = ec->Lclean = ec->Lclean_bg = 0;
268 ec->tx_1 = ec->tx_2 = ec->rx_1 = ec->rx_2 = 0;
269 ec->Lbgn = ec->Lbgn_acc = 0;
270 ec->Lbgn_upper = 200;
271 ec->Lbgn_upper_acc = ec->Lbgn_upper << 13;
273 return ec;
277 kfree(ec->fir_taps16[i]);
279 kfree(ec);
284 void oslec_free(struct oslec_state *ec)
288 fir16_free(&ec->fir_state);
289 fir16_free(&ec->fir_state_bg);
291 kfree(ec->fir_taps16[i]);
292 kfree(ec->snapshot);
293 kfree(ec);
297 void oslec_adaption_mode(struct oslec_state *ec, int adaption_mode)
299 ec->adaption_mode = adaption_mode;
303 void oslec_flush(struct oslec_state *ec)
307 ec->Ltxacc = ec->Lrxacc = ec->Lcleanacc = ec->Lclean_bgacc = 0;
308 ec->Ltx = ec->Lrx = ec->Lclean = ec->Lclean_bg = 0;
309 ec->tx_1 = ec->tx_2 = ec->rx_1 = ec->rx_2 = 0;
311 ec->Lbgn = ec->Lbgn_acc = 0;
312 ec->Lbgn_upper = 200;
313 ec->Lbgn_upper_acc = ec->Lbgn_upper << 13;
315 ec->nonupdate_dwell = 0;
317 fir16_flush(&ec->fir_state);
318 fir16_flush(&ec->fir_state_bg);
319 ec->fir_state.curr_pos = ec->taps - 1;
320 ec->fir_state_bg.curr_pos = ec->taps - 1;
322 memset(ec->fir_taps16[i], 0, ec->taps * sizeof(int16_t));
324 ec->curr_pos = ec->taps - 1;
325 ec->Pstates = 0;
329 void oslec_snapshot(struct oslec_state *ec)
331 memcpy(ec->snapshot, ec->fir_taps16[0], ec->taps * sizeof(int16_t));
337 int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx)
349 ec->tx = tx;
350 ec->rx = rx;
369 if (ec->adaption_mode & ECHO_CAN_USE_RX_HPF) {
382 ec->rx_1 += -(ec->rx_1 >> DC_LOG2BETA) + tmp - ec->rx_2;
389 tmp1 = ec->rx_1 >> 15;
395 ec->rx_2 = tmp;
408 old = (int)ec->fir_state.history[ec->fir_state.curr_pos] *
409 (int)ec->fir_state.history[ec->fir_state.curr_pos];
410 ec->Pstates +=
411 ((new - old) + (1 << (ec->log2taps-1))) >> ec->log2taps;
412 if (ec->Pstates < 0)
413 ec->Pstates = 0;
418 ec->Ltxacc += abs(tx) - ec->Ltx;
419 ec->Ltx = (ec->Ltxacc + (1 << 4)) >> 5;
420 ec->Lrxacc += abs(rx) - ec->Lrx;
421 ec->Lrx = (ec->Lrxacc + (1 << 4)) >> 5;
425 ec->fir_state.coeffs = ec->fir_taps16[0];
426 echo_value = fir16(&ec->fir_state, tx);
427 ec->clean = rx - echo_value;
428 ec->Lcleanacc += abs(ec->clean) - ec->Lclean;
429 ec->Lclean = (ec->Lcleanacc + (1 << 4)) >> 5;
433 echo_value = fir16(&ec->fir_state_bg, tx);
435 ec->Lclean_bgacc += abs(clean_bg) - ec->Lclean_bg;
436 ec->Lclean_bg = (ec->Lclean_bgacc + (1 << 4)) >> 5;
444 ec->factor = 0;
445 ec->shift = 0;
446 if ((ec->nonupdate_dwell == 0)) {
482 P = MIN_TX_POWER_FOR_ADAPTION + ec->Pstates;
483 logP = top_bit(P) + ec->log2taps;
485 ec->shift = shift;
487 lms_adapt_bg(ec, clean_bg, shift);
493 ec->adapt = 0;
494 if ((ec->Lrx > MIN_RX_POWER_FOR_ADAPTION) && (ec->Lrx > ec->Ltx))
495 ec->nonupdate_dwell = DTD_HANGOVER;
496 if (ec->nonupdate_dwell)
497 ec->nonupdate_dwell--;
504 if ((ec->adaption_mode & ECHO_CAN_USE_ADAPTION) &&
505 (ec->nonupdate_dwell == 0) &&
506 /* (ec->Lclean_bg < 0.875*ec->Lclean) */
507 (8 * ec->Lclean_bg < 7 * ec->Lclean) &&
508 /* (ec->Lclean_bg < 0.125*ec->Ltx) */
509 (8 * ec->Lclean_bg < ec->Ltx)) {
510 if (ec->cond_met == 6) {
515 ec->adapt = 1;
516 memcpy(ec->fir_taps16[0], ec->fir_taps16[1],
517 ec->taps * sizeof(int16_t));
519 ec->cond_met++;
521 ec->cond_met = 0;
525 ec->clean_nlp = ec->clean;
526 if (ec->adaption_mode & ECHO_CAN_USE_NLP) {
533 if ((16 * ec->Lclean < ec->Ltx)) {
539 if (ec->adaption_mode & ECHO_CAN_USE_CNG) {
540 ec->cng_level = ec->Lbgn;
553 ec->cng_rndnum =
554 1664525U * ec->cng_rndnum + 1013904223U;
555 ec->cng_filter =
556 ((ec->cng_rndnum & 0xFFFF) - 32768 +
557 5 * ec->cng_filter) >> 3;
558 ec->clean_nlp =
559 (ec->cng_filter * ec->cng_level * 8) >> 14;
561 } else if (ec->adaption_mode & ECHO_CAN_USE_CLIP) {
563 if (ec->clean_nlp > ec->Lbgn)
564 ec->clean_nlp = ec->Lbgn;
565 if (ec->clean_nlp < -ec->Lbgn)
566 ec->clean_nlp = -ec->Lbgn;
572 ec->clean_nlp = 0;
585 if (ec->Lclean < 40) {
586 ec->Lbgn_acc += abs(ec->clean) - ec->Lbgn;
587 ec->Lbgn = (ec->Lbgn_acc + (1 << 11)) >> 12;
593 if (ec->curr_pos <= 0)
594 ec->curr_pos = ec->taps;
595 ec->curr_pos--;
597 if (ec->adaption_mode & ECHO_CAN_DISABLE)
598 ec->clean_nlp = rx;
602 return (int16_t) ec->clean_nlp << 1;
628 int16_t oslec_hpf_tx(struct oslec_state *ec, int16_t tx)
632 if (ec->adaption_mode & ECHO_CAN_USE_TX_HPF) {
645 ec->tx_1 += -(ec->tx_1 >> DC_LOG2BETA) + tmp - ec->tx_2;
646 tmp1 = ec->tx_1 >> 15;
652 ec->tx_2 = tmp;