Lines Matching refs:bc

146 static void inline baycom_int_freq(struct baycom_state *bc)  in baycom_int_freq()  argument
153 bc->debug_vals.cur_intcnt++; in baycom_int_freq()
154 if ((cur_jiffies - bc->debug_vals.last_jiffies) >= HZ) { in baycom_int_freq()
155 bc->debug_vals.last_jiffies = cur_jiffies; in baycom_int_freq()
156 bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt; in baycom_int_freq()
157 bc->debug_vals.cur_intcnt = 0; in baycom_int_freq()
158 bc->debug_vals.last_pllcorr = bc->debug_vals.cur_pllcorr; in baycom_int_freq()
159 bc->debug_vals.cur_pllcorr = 0; in baycom_int_freq()
195 #define SER12_ARB_DIVIDER(bc) (bc->opt_dcd ? 24 : 36) argument
197 #define SER12_DCD_INTERVAL(bc) (bc->opt_dcd ? 12 : 240) argument
199 static inline void ser12_tx(struct net_device *dev, struct baycom_state *bc) in ser12_tx() argument
207 outb(0x0e | (!!bc->modem.ser12.tx_bit), MCR(dev->base_addr)); in ser12_tx()
208 if (bc->modem.shreg <= 1) in ser12_tx()
209 bc->modem.shreg = 0x10000 | hdlcdrv_getbits(&bc->hdrv); in ser12_tx()
210 bc->modem.ser12.tx_bit = !(bc->modem.ser12.tx_bit ^ in ser12_tx()
211 (bc->modem.shreg & 1)); in ser12_tx()
212 bc->modem.shreg >>= 1; in ser12_tx()
217 static inline void ser12_rx(struct net_device *dev, struct baycom_state *bc) in ser12_rx() argument
224 hdlcdrv_channelbit(&bc->hdrv, cur_s); in ser12_rx()
225 bc->modem.ser12.dcd_shreg = (bc->modem.ser12.dcd_shreg << 1) | in ser12_rx()
226 (cur_s != bc->modem.ser12.last_sample); in ser12_rx()
227 bc->modem.ser12.last_sample = cur_s; in ser12_rx()
228 if(bc->modem.ser12.dcd_shreg & 1) { in ser12_rx()
229 if (!bc->opt_dcd) { in ser12_rx()
233 dcdspos += ((bc->modem.ser12.dcd_shreg >> 1) & 1); in ser12_rx()
234 if (!(bc->modem.ser12.dcd_shreg & 0x7ffffffe)) in ser12_rx()
236 dcdsneg += ((bc->modem.ser12.dcd_shreg >> 2) & 1); in ser12_rx()
237 dcdsneg += ((bc->modem.ser12.dcd_shreg >> 3) & 1); in ser12_rx()
238 dcdsneg += ((bc->modem.ser12.dcd_shreg >> 4) & 1); in ser12_rx()
240 bc->modem.ser12.dcd_sum0 += 16*dcdspos - dcdsneg; in ser12_rx()
242 bc->modem.ser12.dcd_sum0--; in ser12_rx()
244 if(!bc->modem.ser12.dcd_time) { in ser12_rx()
245 hdlcdrv_setdcd(&bc->hdrv, (bc->modem.ser12.dcd_sum0 + in ser12_rx()
246 bc->modem.ser12.dcd_sum1 + in ser12_rx()
247 bc->modem.ser12.dcd_sum2) < 0); in ser12_rx()
248 bc->modem.ser12.dcd_sum2 = bc->modem.ser12.dcd_sum1; in ser12_rx()
249 bc->modem.ser12.dcd_sum1 = bc->modem.ser12.dcd_sum0; in ser12_rx()
251 bc->modem.ser12.dcd_sum0 = 2; in ser12_rx()
252 bc->modem.ser12.dcd_time = SER12_DCD_INTERVAL(bc); in ser12_rx()
254 bc->modem.ser12.dcd_time--; in ser12_rx()
255 if (!bc->opt_dcd) { in ser12_rx()
259 if (bc->modem.ser12.interm_sample) { in ser12_rx()
268 switch (bc->modem.ser12.dcd_shreg & 7) { in ser12_rx()
272 bc->debug_vals.cur_pllcorr++; in ser12_rx()
278 bc->debug_vals.cur_pllcorr--; in ser12_rx()
285 bc->modem.shreg >>= 1; in ser12_rx()
286 if (bc->modem.ser12.last_sample == in ser12_rx()
287 bc->modem.ser12.last_rxbit) in ser12_rx()
288 bc->modem.shreg |= 0x10000; in ser12_rx()
289 bc->modem.ser12.last_rxbit = in ser12_rx()
290 bc->modem.ser12.last_sample; in ser12_rx()
292 if (++bc->modem.ser12.interm_sample >= 3) in ser12_rx()
293 bc->modem.ser12.interm_sample = 0; in ser12_rx()
297 if (bc->modem.ser12.dcd_shreg & 1) { in ser12_rx()
301 dcdspos += ((bc->modem.ser12.dcd_shreg >> 1) & 1); in ser12_rx()
302 dcdspos += (!(bc->modem.ser12.dcd_shreg & 0x7ffffffe)) in ser12_rx()
304 dcdsneg += ((bc->modem.ser12.dcd_shreg >> 2) & 1); in ser12_rx()
305 dcdsneg += ((bc->modem.ser12.dcd_shreg >> 3) & 1); in ser12_rx()
306 dcdsneg += ((bc->modem.ser12.dcd_shreg >> 4) & 1); in ser12_rx()
308 bc->modem.ser12.dcd_sum0 += 16*dcdspos - dcdsneg; in ser12_rx()
314 if (bc->modem.ser12.interm_sample) { in ser12_rx()
323 switch (bc->modem.ser12.dcd_shreg & 3) { in ser12_rx()
327 bc->debug_vals.cur_pllcorr++; in ser12_rx()
333 bc->debug_vals.cur_pllcorr--; in ser12_rx()
340 bc->modem.shreg >>= 1; in ser12_rx()
341 if (bc->modem.ser12.last_sample == in ser12_rx()
342 bc->modem.ser12.last_rxbit) in ser12_rx()
343 bc->modem.shreg |= 0x10000; in ser12_rx()
344 bc->modem.ser12.last_rxbit = in ser12_rx()
345 bc->modem.ser12.last_sample; in ser12_rx()
347 bc->modem.ser12.interm_sample = !bc->modem.ser12.interm_sample; in ser12_rx()
351 bc->modem.ser12.dcd_sum0 -= (bc->modem.ser12.dcd_shreg & 1); in ser12_rx()
354 if (bc->modem.shreg & 1) { in ser12_rx()
355 hdlcdrv_putbits(&bc->hdrv, bc->modem.shreg >> 1); in ser12_rx()
356 bc->modem.shreg = 0x10000; in ser12_rx()
358 if(!bc->modem.ser12.dcd_time) { in ser12_rx()
359 if (bc->opt_dcd & 1) in ser12_rx()
360 hdlcdrv_setdcd(&bc->hdrv, !((inb(MSR(dev->base_addr)) ^ bc->opt_dcd) & 0x80)); in ser12_rx()
362 hdlcdrv_setdcd(&bc->hdrv, (bc->modem.ser12.dcd_sum0 + in ser12_rx()
363 bc->modem.ser12.dcd_sum1 + in ser12_rx()
364 bc->modem.ser12.dcd_sum2) < 0); in ser12_rx()
365 bc->modem.ser12.dcd_sum2 = bc->modem.ser12.dcd_sum1; in ser12_rx()
366 bc->modem.ser12.dcd_sum1 = bc->modem.ser12.dcd_sum0; in ser12_rx()
368 bc->modem.ser12.dcd_sum0 = 2; in ser12_rx()
369 bc->modem.ser12.dcd_time = SER12_DCD_INTERVAL(bc); in ser12_rx()
371 bc->modem.ser12.dcd_time--; in ser12_rx()
379 struct baycom_state *bc = (struct baycom_state *)dev->priv; in ser12_interrupt() local
382 if (!dev || !bc || bc->hdrv.magic != HDLCDRV_MAGIC) in ser12_interrupt()
387 baycom_int_freq(bc); in ser12_interrupt()
402 if (hdlcdrv_ptt(&bc->hdrv)) in ser12_interrupt()
403 ser12_tx(dev, bc); in ser12_interrupt()
405 ser12_rx(dev, bc); in ser12_interrupt()
406 bc->modem.arb_divider--; in ser12_interrupt()
417 if (bc->modem.arb_divider <= 0) { in ser12_interrupt()
418 bc->modem.arb_divider = SER12_ARB_DIVIDER(bc); in ser12_interrupt()
420 hdlcdrv_arbitrate(dev, &bc->hdrv); in ser12_interrupt()
423 hdlcdrv_transmitter(dev, &bc->hdrv); in ser12_interrupt()
424 hdlcdrv_receiver(dev, &bc->hdrv); in ser12_interrupt()
471 struct baycom_state *bc = (struct baycom_state *)dev->priv; in ser12_open() local
474 if (!dev || !bc) in ser12_open()
481 memset(&bc->modem, 0, sizeof(bc->modem)); in ser12_open()
482 bc->hdrv.par.bitrate = 1200; in ser12_open()
501 ser12_set_divisor(dev, bc->opt_dcd ? 6 : 4); in ser12_open()
512 struct baycom_state *bc = (struct baycom_state *)dev->priv; in ser12_close() local
514 if (!dev || !bc) in ser12_close()
551 static int baycom_setmode(struct baycom_state *bc, const char *modestr) in baycom_setmode() argument
554 bc->opt_dcd = 0; in baycom_setmode()
556 bc->opt_dcd = -1; in baycom_setmode()
558 bc->opt_dcd = -2; in baycom_setmode()
560 bc->opt_dcd = 1; in baycom_setmode()
569 struct baycom_state *bc; in baycom_ioctl() local
578 bc = (struct baycom_state *)dev->priv; in baycom_ioctl()
590 if (bc->opt_dcd <= 0) in baycom_ioctl()
591 strcat(hi->data.modename, (!bc->opt_dcd) ? "*" : (bc->opt_dcd == -2) ? "@" : "+"); in baycom_ioctl()
600 return baycom_setmode(bc, hi->data.modename); in baycom_ioctl()
621 bi.data.dbg.debug1 = bc->hdrv.ptt_keyed; in baycom_ioctl()
622 bi.data.dbg.debug2 = bc->debug_vals.last_intcnt; in baycom_ioctl()
623 bi.data.dbg.debug3 = bc->debug_vals.last_pllcorr; in baycom_ioctl()
660 struct baycom_state *bc; in init_baycomserhdx() local
678 bc = (struct baycom_state *)dev->priv; in init_baycomserhdx()
679 if (set_hw && baycom_setmode(bc, mode[i])) in init_baycomserhdx()
698 struct baycom_state *bc = (struct baycom_state *)dev->priv; in cleanup_baycomserhdx() local
700 if (bc) { in cleanup_baycomserhdx()
701 if (bc->hdrv.magic != HDLCDRV_MAGIC) in cleanup_baycomserhdx()