Review Board 1.7.16


Generate VMWI neon pulses from FXS module to light NEON lamp on older 'non intellegent phones'

Review Request #1144 - Created March 16, 2011 and updated

Alec Davis
dahdi/linux
14261
Reviewers
asterisk-dev
sruffell
DAHDI
Implement same code as for wcdtm
13/04/12
Tested with mwisendtype=lrev,hvac
at 2 different phones on same FXS port, one a real neon phone, and another a led+zener phone.
Left messages, and neon would flash as expected.

Changes between revision 2 and 3

1 2 3 4 5 6 7
1 2 3 4 5 6 7

  1. linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/base.c: Loading...
linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/base.c
Diff Revision 2 Diff Revision 3
[20] 1435 lines
[+20] [+] wctdm_proslic_setreg_indirect(struct wctdm *wc, struct wctdm_module *const mod,
1436
	};
1436
	};
1437
	return res;
1437
	return res;
1438
}
1438
}
1439

    
   
1439

   
1440
static int
1440
static int

    
   
1441
wctdm_proslic_setreg_indirect_intr(struct wctdm *wc, struct wctdm_module *const mod,

    
   
1442
			      unsigned char address, unsigned short data)

    
   
1443
{

    
   
1444
	int res = -1;

    
   
1445

   

    
   
1446
	address = translate_3215(address);

    
   
1447
	if (address == 255)

    
   
1448
		return 0;

    
   
1449

   

    
   
1450
//	if (!wait_access(wc, mod)) {

    
   
1451
		wctdm_setreg_intr(wc, mod, IDA_LO, (u8)(data & 0xFF));

    
   
1452
		wctdm_setreg_intr(wc, mod, IDA_HI, (u8)((data & 0xFF00)>>8));

    
   
1453
		wctdm_setreg_intr(wc, mod, IAA, address);

    
   
1454
		res = 0;

    
   
1455
//	};

    
   
1456
	return res;

    
   
1457
}

    
   
1458

   

    
   
1459
static int
1441
wctdm_proslic_getreg_indirect(struct wctdm *wc, struct wctdm_module *const mod,
1460
wctdm_proslic_getreg_indirect(struct wctdm *wc, struct wctdm_module *const mod,
1442
			      unsigned char address)
1461
			      unsigned char address)
1443
{ 
1462
{ 
1444
	int res = -1;
1463
	int res = -1;
1445
	char *p=NULL;
1464
	char *p=NULL;
[+20] [20] 1362 lines
[+20] [+] static int set_vmwi(struct wctdm *wc, struct wctdm_module *const mod)
2808
			/* Can't change polarity while ringing or when open */
2827
			/* Can't change polarity while ringing or when open */
2809
			if ((fxs->lasttxhook == SLIC_LF_RINGING) ||
2828
			if ((fxs->lasttxhook == SLIC_LF_RINGING) ||
2810
				(fxs->lasttxhook == SLIC_LF_OPEN)) {
2829
				(fxs->lasttxhook == SLIC_LF_OPEN)) {
2811
				/* Set line polarity for new VMWI state */
2830
				/* Set line polarity for new VMWI state */
2812
				if (POLARITY_XOR(fxs))
2831
				if (POLARITY_XOR(fxs))
2813
					fxs->idletxhookstate |= SLIC_LF_RINGING;
2832
					fxs->idletxhookstate |= SLIC_LF_REVMASK;
2814
				else
2833
				else
2815
					fxs->idletxhookstate &= ~SLIC_LF_RINGING;
2834
					fxs->idletxhookstate &= ~SLIC_LF_REVMASK;
2816

    
   
2835

   
2817
				printk(KERN_DEBUG\
2836
				dev_info(&wc->vb.pdev->dev,
2818
					"Unable to change polarity on channel %d, lasttxhook=0x%X\n",
2837
					"Unable to change polarity on channel %d, lasttxhook=0x%X\n",
2819
					mod->card,
2838
					mod->card,
2820
					fxs->lasttxhook
2839
					fxs->lasttxhook
2821
					);
2840
					);
2822
				return 0;
2841
				return 0;
2823
			}
2842
			}
2824
		}
2843
		}
2825

    
   
2844

   
2826
		/* Set line polarity for new VMWI state */
2845
		/* Set line polarity for new VMWI state */
2827
		if (POLARITY_XOR(fxs)) {
2846
		if (POLARITY_XOR(fxs)) {
2828
			fxs->idletxhookstate |= SLIC_LF_RINGING;
2847
			fxs->idletxhookstate |= SLIC_LF_REVMASK;
2829
			fxs->lasttxhook = SLIC_LF_RINGING;
2848
			fxs->lasttxhook |= SLIC_LF_REVMASK;
2830
		} else {
2849
		} else {
2831
			fxs->idletxhookstate &= ~SLIC_LF_RINGING;
2850
			fxs->idletxhookstate &= ~SLIC_LF_REVMASK;
2832

    
   
2851

   
2833
			x = fxs->lasttxhook;
2852
			x = fxs->lasttxhook;
2834
			x &= ~SLIC_LF_RINGING;
2853
			x &= ~SLIC_LF_REVMASK;
2835
			fxs->lasttxhook = x;
2854
			fxs->lasttxhook = x;
2836
		}
2855
		}
2837
		set_lasttxhook_interruptible(fxs, fxs->lasttxhook, &mod->sethook);
2856
		set_lasttxhook_interruptible(fxs, fxs->lasttxhook, &mod->sethook);
2838
	}
2857
	}
2839
	if (debug) {
2858
	if (debug) {
2840
		dev_info(&wc->vb.pdev->dev,
2859
		dev_info(&wc->vb.pdev->dev,
2841
			 "Setting VMWI on channel %d, messages=%d, lrev=%d\n",
2860
			 "Setting VMWI on channel %d, messages=%d, lrev=%d hvac=%d\n",
2842
			 mod->card, fxs->vmwi_active_messages,
2861
			 mod->card, fxs->vmwi_active_messages,
2843
			 fxs->vmwi_linereverse);
2862
			 fxs->vmwi_linereverse, fxs->vmwi_hvac);
2844
	}
2863
	}
2845
	return 0;
2864
	return 0;
2846
}
2865
}
2847

    
   
2866

   
2848
static void
2867
static void
[+20] [20] 1051 lines
[+20] [+] static int wctdm_init_ring_generator_mode(struct wctdm *wc, struct wctdm_module *const mod)
3900

    
   
3919

   
3901
static int wctdm_set_ring_generator_mode(struct wctdm *wc, struct wctdm_module *const mod, int mode)
3920
static int wctdm_set_ring_generator_mode(struct wctdm *wc, struct wctdm_module *const mod, int mode)
3902
{
3921
{
3903
	struct fxs *const fxs = &mod->mod.fxs;
3922
	struct fxs *const fxs = &mod->mod.fxs;
3904
	int reg20,reg21,reg74; /* RCO, RNGX, VBATH */
3923
	int reg20,reg21,reg74; /* RCO, RNGX, VBATH */
3905
#if 0
3924
#if 1
3906
	fxs->neonringing = mode;   /* track ring generator mode */
3925
	fxs->neonringing = mode;   /* track ring generator mode */
3907

    
   
3926

   
3908
	if (mode) { /* Neon */
3927
	if (mode) { /* Neon */
3909
		if (debug)
3928
		if (debug)
3910
			printk(KERN_DEBUG "NEON ring on channel %d, lasttxhook was 0x%x\n", mod->card, fxs->lasttxhook);
3929
			printk(KERN_DEBUG "NEON ring on channel %d, lasttxhook was 0x%x\n", mod->card, fxs->lasttxhook);
3911
		fxs->lasttxhook = SLIC_LF_ACTIVE_FWD;			/* Must be in FORWARD ACTIVE before setting ringer */
3930
		fxs->lasttxhook = SLIC_LF_ACTIVE_FWD;			/* Must be in FORWARD ACTIVE before setting ringer */
3912
		wctdm_setreg(wc, mod, 64, fxs->lasttxhook);
3931
		wctdm_setreg_intr(wc, mod, 64, fxs->lasttxhook);
3913

    
   
3932

   
3914
		wctdm_proslic_setreg_indirect(wc, mod, 22, 0x03e8);	/* RNGY (4 HZ) */
3933
		wctdm_proslic_setreg_indirect_intr(wc, mod, 22, 0x03e8);	/* RNGY (4 HZ) */
3915
		wctdm_proslic_setreg_indirect(wc, mod, 21, 0x7bef);	/* RNGX (91.5Vpk) */
3934
		wctdm_proslic_setreg_indirect_intr(wc, mod, 21, 0x7bef);	/* RNGX (91.5Vpk) */
3916
		wctdm_proslic_setreg_indirect(wc, mod, 20, 0x009f);	/* RCO (RNGX, t rise) */
3935
		wctdm_proslic_setreg_indirect_intr(wc, mod, 20, 0x009f);	/* RCO (RNGX, t rise) */
3917

    
   
3936

   
3918
		wctdm_setreg(wc, mod, 34, 0x19);			/* Ringing Osc. Control */
3937
		wctdm_setreg_intr(wc, mod, 34, 0x19);			/* Ringing Osc. Control */
3919
		wctdm_setreg(wc, mod, 74, 0x3f);			/* VBATH 94.5V */
3938
		wctdm_setreg_intr(wc, mod, 74, 0x3f);			/* VBATH 94.5V */
3920
		wctdm_proslic_setreg_indirect(wc, mod, 29, 0x4600);	/* RPTP */
3939
		wctdm_proslic_setreg_indirect_intr(wc, mod, 29, 0x4600);	/* RPTP */
3921
		/* A write of 0x04 to register 64 will turn on the VM led */
3940
		/* A write of 0x04 to register 64 will turn on the VM led */
3922
	} else {
3941
	} else {
3923
		if (debug)
3942
		if (debug)
3924
			printk(KERN_DEBUG "NORMAL ring on channel %d, lasttxhook was 0x%x\n", mod->card, fxs->lasttxhook);
3943
			printk(KERN_DEBUG "NORMAL ring on channel %d, lasttxhook was 0x%x\n", mod->card, fxs->lasttxhook);
3925

    
   
3944

   
3926
		wctdm_setreg(wc, mod, 34, 0x00);			/* Ringing Osc. Control */
3945
		wctdm_setreg_intr(wc, mod, 34, 0x00);			/* Ringing Osc. Control */
3927

    
   
3946

   
3928
		wctdm_proslic_setreg_indirect(wc, mod, 22, 0x0000);	/* RNGY Initial Phase */
3947
		wctdm_proslic_setreg_indirect_intr(wc, mod, 22, 0x0000);	/* RNGY Initial Phase */
3929
		wctdm_proslic_setreg_indirect(wc, mod, 29, 0x3600);	/* RPTP */
3948
		wctdm_proslic_setreg_indirect_intr(wc, mod, 29, 0x3600);	/* RPTP */
3930
		/* A write of 0x04 to register 64 will turn on the ringer */
3949
		/* A write of 0x04 to register 64 will turn on the ringer */
3931

    
   
3950

   
3932
		if (fastringer) {
3951
		if (fastringer) {
3933
			/* Speed up Ringer */
3952
			/* Speed up Ringer */
3934
			reg20 =  0x7e6d;
3953
			reg20 =  0x7e6d;
[+20] [20] 16 lines
[+20] static int wctdm_set_ring_generator_mode(struct wctdm *wc, struct wctdm_module *const mod, int mode)
3951
			} else {
3970
			} else {
3952
				reg21 = 0x01b9;
3971
				reg21 = 0x01b9;
3953
				if (debug)
3972
				if (debug)
3954
					printk(KERN_DEBUG "Speeding up ringer on channel %d (25Hz)\n", mod->card);
3973
					printk(KERN_DEBUG "Speeding up ringer on channel %d (25Hz)\n", mod->card);
3955
			}
3974
			}
3956
			wctdm_setreg(wc, mod, 74, reg74);			/* VBATH */
3975
			wctdm_setreg_intr(wc, mod, 74, reg74);			/* VBATH */
3957
			wctdm_proslic_setreg_indirect(wc, mod, 20, reg20);	/* RCO */
3976
			wctdm_proslic_setreg_indirect_intr(wc, mod, 20, reg20);	/* RCO */
3958
			wctdm_proslic_setreg_indirect(wc, mod, 21, reg21);	/* RNGX */
3977
			wctdm_proslic_setreg_indirect_intr(wc, mod, 21, reg21);	/* RNGX */
3959

    
   
3978

   
3960
		} else {
3979
		} else {
3961
			/* Ringer Speed */
3980
			/* Ringer Speed */
3962
			if (fxshonormode && fxo_modes[_opermode].ring_osc){
3981
			if (fxshonormode && fxo_modes[_opermode].ring_osc){
3963
				reg20 = fxo_modes[_opermode].ring_osc;
3982
				reg20 = fxo_modes[_opermode].ring_osc;
[+20] [20] 21 lines
[+20] static int wctdm_set_ring_generator_mode(struct wctdm *wc, struct wctdm_module *const mod, int mode)
3985
			} else {
4004
			} else {
3986
				reg21 = 0x160;
4005
				reg21 = 0x160;
3987
				if (debug)
4006
				if (debug)
3988
					printk(KERN_DEBUG "Normal ring power on channel %d\n", mod->card);
4007
					printk(KERN_DEBUG "Normal ring power on channel %d\n", mod->card);
3989
			}
4008
			}
3990
			wctdm_setreg(wc, mod, 74, reg74);			/* VBATH */
4009
			wctdm_setreg_intr(wc, mod, 74, reg74);			/* VBATH */
3991
			wctdm_proslic_setreg_indirect(wc, mod, 20, reg20);	/* RCO */
4010
			wctdm_proslic_setreg_indirect_intr(wc, mod, 20, reg20);	/* RCO */
3992
			wctdm_proslic_setreg_indirect(wc, mod, 21, reg21);	/* RNGX */
4011
			wctdm_proslic_setreg_indirect_intr(wc, mod, 21, reg21);	/* RNGX */
3993
		}
4012
		}
3994
	}
4013
	}
3995
#endif
4014
#endif
3996
	if (debug)
4015
	if (debug)
3997
		printk(KERN_DEBUG "DONE ringgen on channel %d\n", mod->card);
4016
		printk(KERN_DEBUG "DONE ringgen on channel %d\n", mod->card);
[+20] [20] 1811 lines
  1. linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/base.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.