Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 204057 | Differences between
and this patch

Collapse All | Expand All

(-)zaptel-1.2.18/oslec.h (+24 lines)
Line 0 Link Here
1
/*
2
  oslec.h
3
  David Rowe
4
  7 Feb 2007
5
6
  Interface for OSLEC module.
7
*/
8
9
#ifndef __OSLEC__
10
11
struct echo_can_state {
12
  void *ec;
13
};
14
15
struct echo_can_state *oslec_echo_can_create(int len, int adaption_mode);
16
void oslec_echo_can_free(struct echo_can_state *ec);
17
short oslec_echo_can_update(struct echo_can_state *ec, short iref, short isig);
18
int oslec_echo_can_traintap(struct echo_can_state *ec, int pos, short val);
19
static inline void echo_can_init(void) {}
20
static inline void echo_can_shutdown(void) {}
21
short oslec_hpf_tx(struct echo_can_state *ec, short txlin);
22
23
#endif
24
(-)zaptel-1.2.18/version.h (+6 lines)
Line 0 Link Here
1
/*
2
 * version.h 
3
 * Automatically generated
4
 */
5
#define ZAPTEL_VERSION "1.2.13"
6
(-)zaptel-1.2.18/zaptel-base.c (+208 lines)
Lines 417-422 Link Here
417
#include "mg2ec.h"
417
#include "mg2ec.h"
418
#elif defined(ECHO_CAN_JP1)
418
#elif defined(ECHO_CAN_JP1)
419
#include "jpah.h"
419
#include "jpah.h"
420
/* Start Open Source Line Echo Canceller (OSLEC) -----------------*/
421
#elif defined(ECHO_CAN_OSLEC)
422
#include "oslec.h"
423
#define echo_can_create oslec_echo_can_create
424
#define echo_can_free oslec_echo_can_free
425
#define echo_can_update oslec_echo_can_update
426
#define echo_can_traintap oslec_echo_can_traintap
427
#define ZAPTEL_ECHO_CANCELLER "OSLEC"
428
/* End Open Source Line Echo Canceller (OSLEC) -------------------*/
420
#else
429
#else
421
#include "mec3.h"
430
#include "mec3.h"
422
#endif
431
#endif
Lines 5588-5593 Link Here
5588
	spin_unlock_irqrestore(&chan->lock, flags);
5597
	spin_unlock_irqrestore(&chan->lock, flags);
5589
}
5598
}
5590
5599
5600
/* Zaptap code -----------------------------------------------------------*/
5601
5602
#define SAMPLE_BUF_SZ  1000 
5603
#define SAMPLE_IDLE    0
5604
#define SAMPLE_PING    1
5605
#define SAMPLE_PONG    2
5606
5607
DECLARE_WAIT_QUEUE_HEAD(sample_wait);
5608
static int sample_state = 0;
5609
static int samples = 0;
5610
static short *psample;
5611
static short ping[3*SAMPLE_BUF_SZ];
5612
static short pong[3*SAMPLE_BUF_SZ];
5613
static int sample_ch = 1;
5614
static int sample_impulse = 0;
5615
static int tmp1,tmp2;
5616
5617
static inline void sample_echo_before(int channo, short rxlin, short txlin) {
5618
5619
  // Sample echo canceller signals
5620
  // Notes:
5621
  //   1. Samples are multiplexed in buffer:
5622
  //        tx sample
5623
  //        rx sample
5624
  //        ec sample
5625
  //   2. We needs to sample rx here before echo can as it is
5626
  //      overwritten.
5627
5628
  tmp1++;
5629
  tmp2 = channo;
5630
  if ((sample_state != SAMPLE_IDLE) && (channo == sample_ch)) {
5631
      *psample++ = txlin;
5632
      *psample++ = rxlin;
5633
  }
5634
}
5635
5636
static inline void sample_echo_after(int channo, short rxlin) {
5637
5638
  if ((sample_state != SAMPLE_IDLE) && (channo == sample_ch)) {
5639
5640
    *psample++ = rxlin;
5641
5642
    // sample collection ping-pong buffer logic
5643
5644
    samples++;
5645
    if (samples >= SAMPLE_BUF_SZ) {
5646
      // time to swap buffers
5647
      samples = 0;
5648
5649
      if (sample_state == SAMPLE_PING) {
5650
	sample_state = SAMPLE_PONG;
5651
	psample = pong;
5652
      }
5653
      else {
5654
	sample_state = SAMPLE_PING;
5655
	psample = ping;
5656
      }
5657
      wake_up_interruptible(&sample_wait);
5658
    }
5659
  }
5660
}
5661
5662
/* end Zaptap code -----------------------------------------------------*/
5663
5591
static inline void __zt_ec_chunk(struct zt_chan *ss, unsigned char *rxchunk, const unsigned char *txchunk)
5664
static inline void __zt_ec_chunk(struct zt_chan *ss, unsigned char *rxchunk, const unsigned char *txchunk)
5592
{
5665
{
5593
	short rxlin, txlin;
5666
	short rxlin, txlin;
Lines 5638-5644 Link Here
5638
#if !defined(ZT_EC_ARRAY_UPDATE)
5711
#if !defined(ZT_EC_ARRAY_UPDATE)
5639
			for (x=0;x<ZT_CHUNKSIZE;x++) {
5712
			for (x=0;x<ZT_CHUNKSIZE;x++) {
5640
				rxlin = ZT_XLAW(rxchunk[x], ss);
5713
				rxlin = ZT_XLAW(rxchunk[x], ss);
5714
				sample_echo_before(ss->channo, rxlin, ZT_XLAW(txchunk[x], ss)); /* Zaptap code */
5641
				rxlin = echo_can_update(ss->ec, ZT_XLAW(txchunk[x], ss), rxlin);
5715
				rxlin = echo_can_update(ss->ec, ZT_XLAW(txchunk[x], ss), rxlin);
5716
				sample_echo_after(ss->channo, rxlin);                           /* Zaptap code */
5642
				rxchunk[x] = ZT_LIN2X((int)rxlin, ss);
5717
				rxchunk[x] = ZT_LIN2X((int)rxlin, ss);
5643
			}
5718
			}
5644
#else /* defined(ZT_EC_ARRAY_UPDATE) */
5719
#else /* defined(ZT_EC_ARRAY_UPDATE) */
Lines 6356-6361 Link Here
6356
static void __zt_transmit_chunk(struct zt_chan *chan, unsigned char *buf)
6431
static void __zt_transmit_chunk(struct zt_chan *chan, unsigned char *buf)
6357
{
6432
{
6358
	unsigned char silly[ZT_CHUNKSIZE];
6433
	unsigned char silly[ZT_CHUNKSIZE];
6434
	int x;
6435
6359
	/* Called with chan->lock locked */
6436
	/* Called with chan->lock locked */
6360
	if (!buf)
6437
	if (!buf)
6361
		buf = silly;
6438
		buf = silly;
Lines 6370-6379 Link Here
6370
		kernel_fpu_end();
6447
		kernel_fpu_end();
6371
#endif
6448
#endif
6372
	}
6449
	}
6450
6451
	/* Start Zaptap code -----------------------------------------*/
6452
6453
	if (sample_impulse && (samples == 0)) {
6454
6455
		// option impulse insertion, tx stream becomes one
6456
                // impulse followed by SAMPLE_BUF_SZ-1 0's
6457
6458
		buf[0] = ZT_LIN2MU(10000);
6459
		for (x=1;x<ZT_CHUNKSIZE;x++) {
6460
		    buf[x] = ZT_LIN2MU(0);
6461
		}
6462
	}
6463
6464
	/* End Zaptap code -----------------------------------------*/
6465
	
6373
}
6466
}
6374
6467
6375
static inline void __zt_real_transmit(struct zt_chan *chan)
6468
static inline void __zt_real_transmit(struct zt_chan *chan)
6376
{
6469
{
6470
6377
	/* Called with chan->lock held */
6471
	/* Called with chan->lock held */
6378
	if (chan->confmode) {
6472
	if (chan->confmode) {
6379
		/* Pull queued data off the conference */
6473
		/* Pull queued data off the conference */
Lines 6381-6386 Link Here
6381
	} else {
6475
	} else {
6382
		__zt_transmit_chunk(chan, chan->writechunk);
6476
		__zt_transmit_chunk(chan, chan->writechunk);
6383
	}
6477
	}
6478
		
6384
}
6479
}
6385
6480
6386
static void __zt_getempty(struct zt_chan *ms, unsigned char *buf)
6481
static void __zt_getempty(struct zt_chan *ms, unsigned char *buf)
Lines 6774-6779 Link Here
6774
6869
6775
#endif
6870
#endif
6776
6871
6872
/* Zaptap code -----------------------------------------------------*/
6873
6874
static int sample_open (struct inode *inode, struct file *file) {
6875
	printk("sample_open:\n");
6876
	tmp1 = tmp2 = -1;
6877
6878
	psample = ping;
6879
	samples = 0;
6880
	sample_state = SAMPLE_PING;
6881
6882
	return 0;
6883
}
6884
6885
static int sample_release (struct inode *inode, struct file *file) {
6886
	printk("sample_release: tmp1 = %d tmp2 = %d\n", tmp1, tmp2);
6887
6888
	sample_state = SAMPLE_IDLE;
6889
	sample_impulse = 0;
6890
	samples = 0;
6891
6892
	return 0;
6893
}
6894
6895
static ssize_t sample_read(struct file *file, char *buf,
6896
		size_t count, loff_t *ppos) {
6897
	int    err, len;
6898
	short *pread;
6899
6900
	/* wait for next buffer to be prepared by ISR, we read
6901
           alternate buffer just after transition.
6902
         */
6903
	interruptible_sleep_on(&sample_wait);
6904
6905
	if (sample_state == SAMPLE_PING) {
6906
	  pread = pong;
6907
	}
6908
	else {
6909
	  pread = ping;
6910
	}
6911
6912
	len = 3*sizeof(short)*SAMPLE_BUF_SZ;
6913
	err = copy_to_user(buf, pread, len);
6914
6915
	if (err != 0)
6916
		return -EFAULT;
6917
6918
	return len;
6919
}
6920
6921
/* ioctls for sample */
6922
6923
#define SAMPLE_SET_CHANNEL 0
6924
#define SAMPLE_TX_IMPULSE  1
6925
6926
static int sample_ioctl(struct inode *inode, struct file *file,
6927
		unsigned int cmd, unsigned long arg) {
6928
	int retval = 0;
6929
6930
	switch ( cmd ) {
6931
		case SAMPLE_SET_CHANNEL:
6932
		  if (copy_from_user(&sample_ch, (int *)arg, sizeof(int)))
6933
		    return -EFAULT;
6934
	          printk("sample_ioctl: sample_ch = %d\n", sample_ch);
6935
		  break;
6936
		case SAMPLE_TX_IMPULSE:
6937
		  sample_impulse = 1;
6938
		  printk("sample_ioctl: under impulse power\n");
6939
		  break;
6940
		default:
6941
		  retval = -EINVAL;
6942
        }
6943
6944
	return retval;
6945
}
6946
6947
// define which file operations are supported
6948
struct file_operations sample_fops = {
6949
	.owner	=	THIS_MODULE,
6950
	.llseek	=	NULL,
6951
	.read	=	sample_read,
6952
	.write	=	NULL,
6953
	.readdir=	NULL,
6954
	.poll	=	NULL,
6955
	.ioctl	=	sample_ioctl,
6956
	.mmap	=	NULL,
6957
	.open	=	sample_open,
6958
	.flush	=	NULL,
6959
	.release=	sample_release,
6960
	.fsync	=	NULL,
6961
	.fasync	=	NULL,
6962
	.lock	=	NULL,
6963
};
6964
6965
#define SAMPLE_NAME  "sample"
6966
#define SAMPLE_MAJOR 33
6967
6968
/* end Zaptap code -----------------------------------------------------*/
6969
6777
static int __init zt_init(void) {
6970
static int __init zt_init(void) {
6778
	int res = 0;
6971
	int res = 0;
6779
6972
Lines 6820-6831 Link Here
6820
#ifdef CONFIG_ZAPTEL_WATCHDOG
7013
#ifdef CONFIG_ZAPTEL_WATCHDOG
6821
	watchdog_init();
7014
	watchdog_init();
6822
#endif	
7015
#endif	
7016
7017
	/* start Zaptap code ----------------------------------------*/
7018
7019
	sample_state = SAMPLE_IDLE;
7020
	sample_impulse = 0;
7021
	if ((res = register_chrdev (SAMPLE_MAJOR, SAMPLE_NAME, &sample_fops))) {
7022
	  printk(KERN_ERR "Zaptap unable to register 'sample' char driver on %d\n", SAMPLE_MAJOR);
7023
	  return res;
7024
	}
7025
	printk("Zaptap registered 'sample' char driver on major %d\n", SAMPLE_MAJOR);
7026
7027
	/* end Zaptap code ------------------------------------------*/
7028
6823
	return res;
7029
	return res;
6824
}
7030
}
6825
7031
6826
static void __exit zt_cleanup(void) {
7032
static void __exit zt_cleanup(void) {
6827
	int x;
7033
	int x;
6828
7034
7035
	unregister_chrdev (SAMPLE_MAJOR, SAMPLE_NAME); /* Zaptap code */
7036
6829
#ifdef CONFIG_PROC_FS
7037
#ifdef CONFIG_PROC_FS
6830
	remove_proc_entry("zaptel", NULL);
7038
	remove_proc_entry("zaptel", NULL);
6831
#endif
7039
#endif
(-)zaptel-1.2.18/zconfig.h (+1 lines)
Lines 58-63 Link Here
58
 * supposed to improve how it performs.  If you have echo problems,
58
 * supposed to improve how it performs.  If you have echo problems,
59
 * try it out! */
59
 * try it out! */
60
/* #define ECHO_CAN_MG2 */
60
/* #define ECHO_CAN_MG2 */
61
/* #define ECHO_CAN_OSLEC */
61
62
62
/*
63
/*
63
 * This is only technically an "echo canceller"...
64
 * This is only technically an "echo canceller"...

Return to bug 204057