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