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 5 and 6

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

  1. linux/trunk/drivers/dahdi/wctdm24xxp/base.c: Loading...
linux/trunk/drivers/dahdi/wctdm24xxp/base.c
Diff Revision 5 Diff Revision 6
[20] 276 lines
[+20] [+] static const struct dahdi_echocan_ops vpm_ec_ops = {
277

    
   
277

   
278
static int
278
static int
279
wctdm_init_proslic(struct wctdm *wc, struct wctdm_module *const mod, int fast,
279
wctdm_init_proslic(struct wctdm *wc, struct wctdm_module *const mod, int fast,
280
		   int manual, int sane);
280
		   int manual, int sane);
281

    
   
281

   
282
static int wctdm_init_ring_generator_mode(struct wctdm *wc, struct wctdm_module *const mod);
282
static int
283
static int wctdm_set_ring_generator_mode(struct wctdm *wc, struct wctdm_module *const mod, int mode);
283
wctdm_init_ring_generator_mode(struct wctdm *wc, struct wctdm_module *const mod);

    
   
284

   

    
   
285
static int

    
   
286
wctdm_set_ring_generator_mode(struct wctdm *wc, struct wctdm_module *const mod, int mode);
284

    
   
287

   
285
static void set_offsets(struct wctdm_module *const mod, int altcs)
288
static void set_offsets(struct wctdm_module *const mod, int altcs)
286
{
289
{
287
	int card = mod->card;
290
	int card = mod->card;
288
	int bit;
291
	int bit;
[+20] [20] 1264 lines
[+20] [+] static unsigned char translate_3215(unsigned char address)
1553
	}
1556
	}
1554
	return address;
1557
	return address;
1555
}
1558
}
1556

    
   
1559

   
1557
static int
1560
static int

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

    
   
1562
			      unsigned char address, unsigned short data)

    
   
1563
{

    
   
1564
	int res = -1;

    
   
1565

   

    
   
1566
	address = translate_3215(address);

    
   
1567
	if (address == 255)

    
   
1568
		return 0;

    
   
1569

   

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

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

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

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

    
   
1574
		res = 0;

    
   
1575
//	};

    
   
1576
	return res;

    
   
1577
}

    
   
1578

   

    
   
1579
static int
1558
wctdm_proslic_setreg_indirect(struct wctdm *wc, struct wctdm_module *const mod,
1580
wctdm_proslic_setreg_indirect(struct wctdm *wc, struct wctdm_module *const mod,
1559
			      unsigned char address, unsigned short data)
1581
			      unsigned char address, unsigned short data)
1560
{
1582
{
1561
	int res = -1;
1583
	int res = -1;
1562

    
   
1584

   
[+20] [20] 1505 lines
[+20] [+] static int set_vmwi(struct wctdm *wc, struct wctdm_module *const mod)
3068
		}
3090
		}
3069

    
   
3091

   
3070
		/* Set line polarity for new VMWI state */
3092
		/* Set line polarity for new VMWI state */
3071
		if (POLARITY_XOR(fxs)) {
3093
		if (POLARITY_XOR(fxs)) {
3072
			fxs->idletxhookstate |= SLIC_LF_REVMASK;
3094
			fxs->idletxhookstate |= SLIC_LF_REVMASK;
3073
			fxs->lasttxhook |= SLIC_LF_REVMASK;
3095
			x = fxs->lasttxhook;

    
   
3096
			x |= SLIC_LF_REVMASK;
3074
		} else {
3097
		} else {
3075
			fxs->idletxhookstate &= ~SLIC_LF_REVMASK;
3098
			fxs->idletxhookstate &= ~SLIC_LF_REVMASK;
3076

    
   

   
3077
			x = fxs->lasttxhook;
3099
			x = fxs->lasttxhook;
3078
			x &= ~SLIC_LF_REVMASK;
3100
			x &= ~SLIC_LF_REVMASK;
3079
			fxs->lasttxhook = x;

   
3080
		}
3101
		}
3081
		set_lasttxhook_interruptible(wc, fxs, fxs->idletxhookstate, &mod->sethook);
3102
		set_lasttxhook_interruptible(wc, fxs, x, &mod->sethook);
3082
	}
3103
	}
3083
	if (debug) {
3104
	if (debug) {
3084
		dev_info(&wc->vb.pdev->dev,
3105
		dev_info(&wc->vb.pdev->dev,
3085
			"Setting VMWI on channel %d, messages=%d, lrev=%d hvac=%d\n",
3106
			"Setting VMWI on channel %d, messages=%d, lrev=%d hvac=%d\n",
3086
			mod->card, fxs->vmwi_active_messages,
3107
			mod->card, fxs->vmwi_active_messages,
[+20] [20] 1075 lines
[+20] [+] static int wctdm_init_ring_generator_mode(struct wctdm *wc, struct wctdm_module *const mod)
4162
	spin_unlock_irqrestore(&wc->reglock, flags);
4183
	spin_unlock_irqrestore(&wc->reglock, flags);
4163

    
   
4184

   
4164
	return 0;
4185
	return 0;
4165
}
4186
}
4166

    
   
4187

   

    
   
4188
/* Must be called with wc.reglock held and local interrupts disabled */
4167
static int wctdm_set_ring_generator_mode(struct wctdm *wc, struct wctdm_module *const mod, int mode)
4189
static int wctdm_set_ring_generator_mode(struct wctdm *wc, struct wctdm_module *const mod, int mode)
4168
{
4190
{
4169
	struct fxs *const fxs = &mod->mod.fxs;
4191
	struct fxs *const fxs = &mod->mod.fxs;
4170
	int reg20,reg21,reg74; /* RCO, RNGX, VBATH */
4192
	int reg20,reg21,reg74; /* RCO, RNGX, VBATH */
4171

    
   
4193

   
[+20] [20] 10 lines
[+20] static int wctdm_set_ring_generator_mode(struct wctdm *wc, struct wctdm_module *const mod, int mode)
4182

    
   
4204

   
4183
		/* Must be in FORWARD ACTIVE before setting up ringer */
4205
		/* Must be in FORWARD ACTIVE before setting up ringer */
4184
		fxs->lasttxhook = SLIC_LF_ACTIVE_FWD;
4206
		fxs->lasttxhook = SLIC_LF_ACTIVE_FWD;
4185
		wctdm_setreg_intr(wc, mod, LINE_STATE, fxs->lasttxhook);
4207
		wctdm_setreg_intr(wc, mod, LINE_STATE, fxs->lasttxhook);
4186

    
   
4208

   
4187
		wctdm_proslic_setreg_indirect(wc, mod, RING_Y, 0x03e8);			/* 4 HZ */
4209
		wctdm_proslic_setreg_indirect_intr(wc, mod, RING_Y, 0x03e8);		/* 4 HZ */
4188
		wctdm_proslic_setreg_indirect(wc, mod, RING_X, 0x7bef);			/* 91.5Vpk */
4210
		wctdm_proslic_setreg_indirect_intr(wc, mod, RING_X, 0x7bef);		/* 91.5Vpk */
4189
		wctdm_proslic_setreg_indirect(wc, mod, RING_OSC_COEF, 0x009f);		/* (RNGX, t rise) */
4211
		wctdm_proslic_setreg_indirect_intr(wc, mod, RING_OSC_COEF, 0x009f);	/* (RNGX, t rise) */
4190

    
   
4212

   
4191
		wctdm_setreg_intr(wc, mod, RING_OSC_CTL, 0x19);				/* Ringing Osc. Control */
4213
		wctdm_setreg_intr(wc, mod, RING_OSC_CTL, 0x19);				/* Ringing Osc. Control */
4192
		wctdm_setreg_intr(wc, mod, BAT_V_HI, 0x3f);				/* 94.5V */
4214
		wctdm_setreg_intr(wc, mod, BAT_V_HI, 0x3f);				/* 94.5V */
4193
		wctdm_proslic_setreg_indirect(wc, mod, RING_TRIP_THRESH, 0x4600);
4215
		wctdm_proslic_setreg_indirect_intr(wc, mod, RING_TRIP_THRESH, 0x4600);
4194
		/* A write of 0x04 to register LINE_STATE(64) will turn on the VM neon */
4216
		/* A write of 0x04 to register LINE_STATE(64) will turn on the VM neon */
4195

    
   
4217

   
4196
	} else {
4218
	} else {
4197
		if (debug) {
4219
		if (debug) {
4198
			dev_info(&wc->vb.pdev->dev,
4220
			dev_info(&wc->vb.pdev->dev,
4199
				"Normal ring on channel %d, lasttxhook was 0x%x\n",
4221
				"Normal ring on channel %d, lasttxhook was 0x%x\n",
4200
				mod->card,
4222
				mod->card,
4201
				fxs->lasttxhook
4223
				fxs->lasttxhook
4202
				);
4224
				);
4203
		}
4225
		}
4204

    
   
4226

   
4205
		wctdm_setreg_intr(wc, mod, RING_OSC_CTL, 0x00);				/* Ringing Osc. Control */
4227
		wctdm_setreg_intr(wc, mod, RING_OSC_CTL, 0x00);				/* Ringing Osc. Control */
4206
		wctdm_proslic_setreg_indirect(wc, mod, RING_Y, 0x0000);			/* RNGY Initial Phase */
4228
		wctdm_proslic_setreg_indirect_intr(wc, mod, RING_Y, 0x0000);		/* RNGY Initial Phase */
4207
		wctdm_proslic_setreg_indirect(wc, mod, RING_TRIP_THRESH, 0x3600);	/* RPTP */
4229
		wctdm_proslic_setreg_indirect_intr(wc, mod, RING_TRIP_THRESH, 0x3600);	/* RPTP */
4208
		/* A write of 0x04 to register LINE_STATE(64) will turn on the ringer */
4230
		/* A write of 0x04 to register LINE_STATE(64) will turn on the ringer */
4209

    
   
4231

   
4210
		if (fastringer) {
4232
		if (fastringer) {
4211
			/* Speed up Ringer */
4233
			/* Speed up Ringer */
4212
			reg20 =  0x7e6d;
4234
			reg20 =  0x7e6d;
[+20] [20] 17 lines
[+20] static int wctdm_set_ring_generator_mode(struct wctdm *wc, struct wctdm_module *const mod, int mode)
4230
				reg21 = 0x01b9;
4252
				reg21 = 0x01b9;
4231
				if (debug)
4253
				if (debug)
4232
					printk(KERN_DEBUG "Speeding up ringer on channel %d (25Hz)\n", mod->card);
4254
					printk(KERN_DEBUG "Speeding up ringer on channel %d (25Hz)\n", mod->card);
4233
			}
4255
			}
4234
			wctdm_setreg_intr(wc, mod, BAT_V_HI, reg74);
4256
			wctdm_setreg_intr(wc, mod, BAT_V_HI, reg74);
4235
			wctdm_proslic_setreg_indirect(wc, mod, RING_OSC_COEF, reg20);
4257
			wctdm_proslic_setreg_indirect_intr(wc, mod, RING_OSC_COEF, reg20);
4236
			wctdm_proslic_setreg_indirect(wc, mod, RING_X, reg21);
4258
			wctdm_proslic_setreg_indirect_intr(wc, mod, RING_X, reg21);
4237

    
   
4259

   
4238
		} else {
4260
		} else {
4239
			/* Ringer Speed */
4261
			/* Ringer Speed */
4240
			if (fxshonormode && fxo_modes[_opermode].ring_osc) {
4262
			if (fxshonormode && fxo_modes[_opermode].ring_osc) {
4241
				reg20 = fxo_modes[_opermode].ring_osc;
4263
				reg20 = fxo_modes[_opermode].ring_osc;
[+20] [20] 22 lines
[+20] static int wctdm_set_ring_generator_mode(struct wctdm *wc, struct wctdm_module *const mod, int mode)
4264
				reg21 = 0x160;
4286
				reg21 = 0x160;
4265
				if (debug)
4287
				if (debug)
4266
					printk(KERN_DEBUG "Normal ring power on channel %d\n", mod->card);
4288
					printk(KERN_DEBUG "Normal ring power on channel %d\n", mod->card);
4267
			}
4289
			}
4268
			wctdm_setreg_intr(wc, mod, BAT_V_HI, reg74);
4290
			wctdm_setreg_intr(wc, mod, BAT_V_HI, reg74);
4269
			wctdm_proslic_setreg_indirect(wc, mod, RING_OSC_COEF, reg20);
4291
			wctdm_proslic_setreg_indirect_intr(wc, mod, RING_OSC_COEF, reg20);
4270
			wctdm_proslic_setreg_indirect(wc, mod, RING_X, reg21);
4292
			wctdm_proslic_setreg_indirect_intr(wc, mod, RING_X, reg21);
4271
		}
4293
		}
4272
	}
4294
	}
4273
	return 0;
4295
	return 0;
4274
}
4296
}
4275

    
   
4297

   
[+20] [20] 2104 lines
  1. linux/trunk/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.