Lines Matching full:pps

1409 	 * PPS events, so instead we poll them.  There is a finite risk that  in tc_windup()
1577 * RFC 2783 PPS-API implementation.
1585 abi_aware(struct pps_state *pps, int vers) in abi_aware() argument
1588 return ((pps->kcmode & KCMODE_ABIFLAG) && pps->driver_abi >= vers); in abi_aware()
1592 pps_fetch(struct pps_fetch_args *fapi, struct pps_state *pps) in pps_fetch() argument
1616 aseq = atomic_load_int(&pps->ppsinfo.assert_sequence); in pps_fetch()
1617 cseq = atomic_load_int(&pps->ppsinfo.clear_sequence); in pps_fetch()
1618 while (aseq == atomic_load_int(&pps->ppsinfo.assert_sequence) && in pps_fetch()
1619 cseq == atomic_load_int(&pps->ppsinfo.clear_sequence)) { in pps_fetch()
1620 if (abi_aware(pps, 1) && pps->driver_mtx != NULL) { in pps_fetch()
1621 if (pps->flags & PPSFLAG_MTX_SPIN) { in pps_fetch()
1622 err = msleep_spin(pps, pps->driver_mtx, in pps_fetch()
1625 err = msleep(pps, pps->driver_mtx, PCATCH, in pps_fetch()
1629 err = tsleep(pps, PCATCH, "ppsfch", timo); in pps_fetch()
1643 pps->ppsinfo.current_mode = pps->ppsparam.mode; in pps_fetch()
1644 fapi->pps_info_buf = pps->ppsinfo; in pps_fetch()
1650 pps_ioctl(u_long cmd, caddr_t data, struct pps_state *pps) in pps_ioctl() argument
1661 KASSERT(pps != NULL, ("NULL pps pointer in pps_ioctl")); in pps_ioctl()
1669 if (app->mode & ~pps->ppscap) in pps_ioctl()
1676 pps->ppsparam = *app; in pps_ioctl()
1680 *app = pps->ppsparam; in pps_ioctl()
1684 *(int*)data = pps->ppscap; in pps_ioctl()
1688 return (pps_fetch(fapi, pps)); in pps_ioctl()
1697 pps->ppsinfo_ffc.current_mode = pps->ppsparam.mode; in pps_ioctl()
1698 fapi_ffc->pps_info_buf_ffc = pps->ppsinfo_ffc; in pps_ioctl()
1700 switch (pps->ppsparam.mode & PPS_TSCLK_MASK) { in pps_ioctl()
1703 pps->ppsinfo.assert_timestamp; in pps_ioctl()
1705 pps->ppsinfo.clear_timestamp; in pps_ioctl()
1722 if (kapi->edge & ~pps->ppscap) in pps_ioctl()
1724 pps->kcmode = (kapi->edge & KCMODE_EDGEMASK) | in pps_ioctl()
1725 (pps->kcmode & KCMODE_ABIFLAG); in pps_ioctl()
1736 pps_init(struct pps_state *pps) in pps_init() argument
1738 pps->ppscap |= PPS_TSFMT_TSPEC | PPS_CANWAIT; in pps_init()
1739 if (pps->ppscap & PPS_CAPTUREASSERT) in pps_init()
1740 pps->ppscap |= PPS_OFFSETASSERT; in pps_init()
1741 if (pps->ppscap & PPS_CAPTURECLEAR) in pps_init()
1742 pps->ppscap |= PPS_OFFSETCLEAR; in pps_init()
1744 pps->ppscap |= PPS_TSCLK_MASK; in pps_init()
1746 pps->kcmode &= ~KCMODE_ABIFLAG; in pps_init()
1750 pps_init_abi(struct pps_state *pps) in pps_init_abi() argument
1753 pps_init(pps); in pps_init_abi()
1754 if (pps->driver_abi > 0) { in pps_init_abi()
1755 pps->kcmode |= KCMODE_ABIFLAG; in pps_init_abi()
1756 pps->kernel_abi = PPS_ABI_VERSION; in pps_init_abi()
1761 pps_capture(struct pps_state *pps) in pps_capture() argument
1766 KASSERT(pps != NULL, ("NULL pps pointer in pps_capture")); in pps_capture()
1768 pps->capgen = atomic_load_acq_int(&th->th_generation); in pps_capture()
1769 pps->capth = th; in pps_capture()
1771 pps->capffth = fftimehands; in pps_capture()
1774 pps->capcount = tc->tc_get_timecount(tc); in pps_capture()
1778 pps_event(struct pps_state *pps, int event) in pps_event() argument
1797 KASSERT(pps != NULL, ("NULL pps pointer in pps_event")); in pps_event()
1799 if ((event & pps->ppsparam.mode) == 0) in pps_event()
1803 capth = pps->capth; in pps_event()
1811 if (pps->capgen == 0 || pps->capgen != capth->th_generation) in pps_event()
1816 tsp = &pps->ppsinfo.assert_timestamp; in pps_event()
1817 osp = &pps->ppsparam.assert_offset; in pps_event()
1818 foff = pps->ppsparam.mode & PPS_OFFSETASSERT; in pps_event()
1820 fhard = pps->kcmode & PPS_CAPTUREASSERT; in pps_event()
1822 pcount = &pps->ppscount[0]; in pps_event()
1823 pseq = &pps->ppsinfo.assert_sequence; in pps_event()
1825 ffcount = &pps->ppsinfo_ffc.assert_ffcount; in pps_event()
1826 tsp_ffc = &pps->ppsinfo_ffc.assert_timestamp; in pps_event()
1827 pseq_ffc = &pps->ppsinfo_ffc.assert_sequence; in pps_event()
1830 tsp = &pps->ppsinfo.clear_timestamp; in pps_event()
1831 osp = &pps->ppsparam.clear_offset; in pps_event()
1832 foff = pps->ppsparam.mode & PPS_OFFSETCLEAR; in pps_event()
1834 fhard = pps->kcmode & PPS_CAPTURECLEAR; in pps_event()
1836 pcount = &pps->ppscount[1]; in pps_event()
1837 pseq = &pps->ppsinfo.clear_sequence; in pps_event()
1839 ffcount = &pps->ppsinfo_ffc.clear_ffcount; in pps_event()
1840 tsp_ffc = &pps->ppsinfo_ffc.clear_timestamp; in pps_event()
1841 pseq_ffc = &pps->ppsinfo_ffc.clear_sequence; in pps_event()
1845 *pcount = pps->capcount; in pps_event()
1849 * we have to drop the rest of the PPS-stuff until the next event. in pps_event()
1851 if (__predict_false(pps->ppstc != captc)) { in pps_event()
1852 pps->ppstc = captc; in pps_event()
1853 pps->ppscount[2] = pps->capcount; in pps_event()
1860 tcount = pps->capcount - tcount; in pps_event()
1874 *ffcount = pps->capffth->tick_ffcount + tcount; in pps_event()
1875 bt = pps->capffth->tick_time; in pps_event()
1876 ffclock_convert_delta(tcount, pps->capffth->cest.period, &bt); in pps_event()
1877 bintime_add(&bt, &pps->capffth->tick_time); in pps_event()
1892 tcount = pps->capcount - pps->ppscount[2]; in pps_event()
1893 pps->ppscount[2] = pps->capcount; in pps_event()
1904 wakeup(pps); in pps_event()