Lines Matching full:bc

132 static inline void baycom_int_freq(struct baycom_state *bc)  in baycom_int_freq()  argument
139 bc->debug_vals.cur_intcnt++; in baycom_int_freq()
140 if (time_after_eq(cur_jiffies, bc->debug_vals.last_jiffies + HZ)) { in baycom_int_freq()
141 bc->debug_vals.last_jiffies = cur_jiffies; in baycom_int_freq()
142 bc->debug_vals.last_intcnt = bc->debug_vals.cur_intcnt; in baycom_int_freq()
143 bc->debug_vals.cur_intcnt = 0; in baycom_int_freq()
144 bc->debug_vals.last_pllcorr = bc->debug_vals.cur_pllcorr; in baycom_int_freq()
145 bc->debug_vals.cur_pllcorr = 0; in baycom_int_freq()
181 #define SER12_ARB_DIVIDER(bc) (bc->opt_dcd ? 24 : 36) argument
183 #define SER12_DCD_INTERVAL(bc) (bc->opt_dcd ? 12 : 240) argument
185 static inline void ser12_tx(struct net_device *dev, struct baycom_state *bc) in ser12_tx() argument
193 outb(0x0e | (!!bc->modem.ser12.tx_bit), MCR(dev->base_addr)); in ser12_tx()
194 if (bc->modem.shreg <= 1) in ser12_tx()
195 bc->modem.shreg = 0x10000 | hdlcdrv_getbits(&bc->hdrv); in ser12_tx()
196 bc->modem.ser12.tx_bit = !(bc->modem.ser12.tx_bit ^ in ser12_tx()
197 (bc->modem.shreg & 1)); in ser12_tx()
198 bc->modem.shreg >>= 1; in ser12_tx()
203 static inline void ser12_rx(struct net_device *dev, struct baycom_state *bc) in ser12_rx() argument
210 hdlcdrv_channelbit(&bc->hdrv, cur_s); in ser12_rx()
211 bc->modem.ser12.dcd_shreg = (bc->modem.ser12.dcd_shreg << 1) | in ser12_rx()
212 (cur_s != bc->modem.ser12.last_sample); in ser12_rx()
213 bc->modem.ser12.last_sample = cur_s; in ser12_rx()
214 if(bc->modem.ser12.dcd_shreg & 1) { in ser12_rx()
215 if (!bc->opt_dcd) { in ser12_rx()
219 dcdspos += ((bc->modem.ser12.dcd_shreg >> 1) & 1); in ser12_rx()
220 if (!(bc->modem.ser12.dcd_shreg & 0x7ffffffe)) in ser12_rx()
222 dcdsneg += ((bc->modem.ser12.dcd_shreg >> 2) & 1); in ser12_rx()
223 dcdsneg += ((bc->modem.ser12.dcd_shreg >> 3) & 1); in ser12_rx()
224 dcdsneg += ((bc->modem.ser12.dcd_shreg >> 4) & 1); in ser12_rx()
226 bc->modem.ser12.dcd_sum0 += 16*dcdspos - dcdsneg; in ser12_rx()
228 bc->modem.ser12.dcd_sum0--; in ser12_rx()
230 if(!bc->modem.ser12.dcd_time) { in ser12_rx()
231 hdlcdrv_setdcd(&bc->hdrv, (bc->modem.ser12.dcd_sum0 + in ser12_rx()
232 bc->modem.ser12.dcd_sum1 + in ser12_rx()
233 bc->modem.ser12.dcd_sum2) < 0); in ser12_rx()
234 bc->modem.ser12.dcd_sum2 = bc->modem.ser12.dcd_sum1; in ser12_rx()
235 bc->modem.ser12.dcd_sum1 = bc->modem.ser12.dcd_sum0; in ser12_rx()
237 bc->modem.ser12.dcd_sum0 = 2; in ser12_rx()
238 bc->modem.ser12.dcd_time = SER12_DCD_INTERVAL(bc); in ser12_rx()
240 bc->modem.ser12.dcd_time--; in ser12_rx()
241 if (!bc->opt_dcd) { in ser12_rx()
245 if (bc->modem.ser12.interm_sample) { in ser12_rx()
254 switch (bc->modem.ser12.dcd_shreg & 7) { in ser12_rx()
258 bc->debug_vals.cur_pllcorr++; in ser12_rx()
264 bc->debug_vals.cur_pllcorr--; in ser12_rx()
271 bc->modem.shreg >>= 1; in ser12_rx()
272 if (bc->modem.ser12.last_sample == in ser12_rx()
273 bc->modem.ser12.last_rxbit) in ser12_rx()
274 bc->modem.shreg |= 0x10000; in ser12_rx()
275 bc->modem.ser12.last_rxbit = in ser12_rx()
276 bc->modem.ser12.last_sample; in ser12_rx()
278 if (++bc->modem.ser12.interm_sample >= 3) in ser12_rx()
279 bc->modem.ser12.interm_sample = 0; in ser12_rx()
283 if (bc->modem.ser12.dcd_shreg & 1) { in ser12_rx()
287 dcdspos += ((bc->modem.ser12.dcd_shreg >> 1) & 1); in ser12_rx()
288 dcdspos += (!(bc->modem.ser12.dcd_shreg & 0x7ffffffe)) in ser12_rx()
290 dcdsneg += ((bc->modem.ser12.dcd_shreg >> 2) & 1); in ser12_rx()
291 dcdsneg += ((bc->modem.ser12.dcd_shreg >> 3) & 1); in ser12_rx()
292 dcdsneg += ((bc->modem.ser12.dcd_shreg >> 4) & 1); in ser12_rx()
294 bc->modem.ser12.dcd_sum0 += 16*dcdspos - dcdsneg; in ser12_rx()
300 if (bc->modem.ser12.interm_sample) { in ser12_rx()
309 switch (bc->modem.ser12.dcd_shreg & 3) { in ser12_rx()
313 bc->debug_vals.cur_pllcorr++; in ser12_rx()
319 bc->debug_vals.cur_pllcorr--; in ser12_rx()
326 bc->modem.shreg >>= 1; in ser12_rx()
327 if (bc->modem.ser12.last_sample == in ser12_rx()
328 bc->modem.ser12.last_rxbit) in ser12_rx()
329 bc->modem.shreg |= 0x10000; in ser12_rx()
330 bc->modem.ser12.last_rxbit = in ser12_rx()
331 bc->modem.ser12.last_sample; in ser12_rx()
333 bc->modem.ser12.interm_sample = !bc->modem.ser12.interm_sample; in ser12_rx()
337 bc->modem.ser12.dcd_sum0 -= (bc->modem.ser12.dcd_shreg & 1); in ser12_rx()
340 if (bc->modem.shreg & 1) { in ser12_rx()
341 hdlcdrv_putbits(&bc->hdrv, bc->modem.shreg >> 1); in ser12_rx()
342 bc->modem.shreg = 0x10000; in ser12_rx()
344 if(!bc->modem.ser12.dcd_time) { in ser12_rx()
345 if (bc->opt_dcd & 1) in ser12_rx()
346 hdlcdrv_setdcd(&bc->hdrv, !((inb(MSR(dev->base_addr)) ^ bc->opt_dcd) & 0x80)); in ser12_rx()
348 hdlcdrv_setdcd(&bc->hdrv, (bc->modem.ser12.dcd_sum0 + in ser12_rx()
349 bc->modem.ser12.dcd_sum1 + in ser12_rx()
350 bc->modem.ser12.dcd_sum2) < 0); in ser12_rx()
351 bc->modem.ser12.dcd_sum2 = bc->modem.ser12.dcd_sum1; in ser12_rx()
352 bc->modem.ser12.dcd_sum1 = bc->modem.ser12.dcd_sum0; in ser12_rx()
354 bc->modem.ser12.dcd_sum0 = 2; in ser12_rx()
355 bc->modem.ser12.dcd_time = SER12_DCD_INTERVAL(bc); in ser12_rx()
357 bc->modem.ser12.dcd_time--; in ser12_rx()
365 struct baycom_state *bc = netdev_priv(dev); in ser12_interrupt() local
368 if (!dev || !bc || bc->hdrv.magic != HDLCDRV_MAGIC) in ser12_interrupt()
373 baycom_int_freq(bc); in ser12_interrupt()
388 if (hdlcdrv_ptt(&bc->hdrv)) in ser12_interrupt()
389 ser12_tx(dev, bc); in ser12_interrupt()
391 ser12_rx(dev, bc); in ser12_interrupt()
392 bc->modem.arb_divider--; in ser12_interrupt()
403 if (bc->modem.arb_divider <= 0) { in ser12_interrupt()
404 bc->modem.arb_divider = SER12_ARB_DIVIDER(bc); in ser12_interrupt()
406 hdlcdrv_arbitrate(dev, &bc->hdrv); in ser12_interrupt()
409 hdlcdrv_transmitter(dev, &bc->hdrv); in ser12_interrupt()
410 hdlcdrv_receiver(dev, &bc->hdrv); in ser12_interrupt()
458 struct baycom_state *bc = netdev_priv(dev); in ser12_open() local
461 if (!dev || !bc) in ser12_open()
468 memset(&bc->modem, 0, sizeof(bc->modem)); in ser12_open()
469 bc->hdrv.par.bitrate = 1200; in ser12_open()
491 ser12_set_divisor(dev, bc->opt_dcd ? 6 : 4); in ser12_open()
501 struct baycom_state *bc = netdev_priv(dev); in ser12_close() local
503 if (!dev || !bc) in ser12_close()
539 static int baycom_setmode(struct baycom_state *bc, const char *modestr) in baycom_setmode() argument
542 bc->opt_dcd = 0; in baycom_setmode()
544 bc->opt_dcd = -1; in baycom_setmode()
546 bc->opt_dcd = -2; in baycom_setmode()
548 bc->opt_dcd = 1; in baycom_setmode()
557 struct baycom_state *bc; in baycom_ioctl() local
563 bc = netdev_priv(dev); in baycom_ioctl()
564 BUG_ON(bc->hdrv.magic != HDLCDRV_MAGIC); in baycom_ioctl()
574 if (bc->opt_dcd <= 0) in baycom_ioctl()
575 strcat(hi->data.modename, (!bc->opt_dcd) ? "*" : (bc->opt_dcd == -2) ? "@" : "+"); in baycom_ioctl()
584 return baycom_setmode(bc, hi->data.modename); in baycom_ioctl()
605 bi.data.dbg.debug1 = bc->hdrv.ptt_keyed; in baycom_ioctl()
606 bi.data.dbg.debug2 = bc->debug_vals.last_intcnt; in baycom_ioctl()
607 bi.data.dbg.debug3 = bc->debug_vals.last_pllcorr; in baycom_ioctl()
651 struct baycom_state *bc; in init_baycomserhdx() local
667 bc = netdev_priv(dev); in init_baycomserhdx()
668 if (set_hw && baycom_setmode(bc, mode[i])) in init_baycomserhdx()