Index: head/share/man/man4/Makefile =================================================================== --- head/share/man/man4/Makefile (revision 285875) +++ head/share/man/man4/Makefile (revision 285876) @@ -1,915 +1,916 @@ # @(#)Makefile 8.1 (Berkeley) 6/18/93 # $FreeBSD$ .include MAN= aac.4 \ aacraid.4 \ acpi.4 \ ${_acpi_asus.4} \ ${_acpi_asus_wmi.4} \ ${_acpi_dock.4} \ ${_acpi_fujitsu.4} \ ${_acpi_hp.4} \ ${_acpi_ibm.4} \ ${_acpi_panasonic.4} \ ${_acpi_rapidstart.4} \ ${_acpi_sony.4} \ acpi_thermal.4 \ ${_acpi_toshiba.4} \ acpi_video.4 \ ${_acpi_wmi.4} \ ada.4 \ adv.4 \ adw.4 \ ae.4 \ ${_aesni.4} \ age.4 \ agp.4 \ aha.4 \ ahb.4 \ ahc.4 \ ahci.4 \ ahd.4 \ ${_aibs.4} \ aio.4 \ alc.4 \ ale.4 \ alpm.4 \ altera_atse.4 \ altera_avgen.4 \ altera_jtag_uart.4 \ altera_sdcard.4 \ altq.4 \ amdpm.4 \ ${_amdsbwd.4} \ ${_amdsmb.4} \ ${_amdtemp.4} \ ${_bxe.4} \ amr.4 \ an.4 \ ${_aout.4} \ ${_apic.4} \ arcmsr.4 \ ${_asmc.4} \ ata.4 \ ath.4 \ ath_ahb.4 \ ath_hal.4 \ ath_pci.4 \ atkbd.4 \ atkbdc.4 \ atp.4 \ ${_atf_test_case.4} \ ${_atrtc.4} \ ${_attimer.4} \ audit.4 \ auditpipe.4 \ aue.4 \ axe.4 \ axge.4 \ bce.4 \ bfe.4 \ bge.4 \ ${_bhyve.4} \ bktr.4 \ blackhole.4 \ bpf.4 \ bridge.4 \ bt.4 \ bwi.4 \ bwn.4 \ capsicum.4 \ cardbus.4 \ carp.4 \ cas.4 \ cc_cdg.4 \ cc_chd.4 \ cc_cubic.4 \ cc_dctcp.4 \ cc_hd.4 \ cc_htcp.4 \ cc_newreno.4 \ cc_vegas.4 \ ${_ccd.4} \ cd.4 \ cdce.4 \ ch.4 \ ciss.4 \ cm.4 \ cmx.4 \ ${_coretemp.4} \ ${_cpuctl.4} \ cpufreq.4 \ crypto.4 \ ctl.4 \ cue.4 \ cxgb.4 \ cxgbe.4 \ cy.4 \ + cyapa.4 \ da.4 \ dc.4 \ dcons.4 \ dcons_crom.4 \ ddb.4 \ de.4 \ devctl.4 \ digi.4 \ disc.4 \ divert.4 \ ${_dpms.4} \ dpt.4 \ ds1307.4 \ ds3231.4 \ ${_dtrace_io.4} \ ${_dtrace_ip.4} \ ${_dtrace_proc.4} \ ${_dtrace_sched.4} \ ${_dtrace_tcp.4} \ ${_dtrace_udp.4} \ dummynet.4 \ ed.4 \ edsc.4 \ ehci.4 \ em.4 \ en.4 \ enc.4 \ epair.4 \ esp.4 \ est.4 \ et.4 \ etherswitch.4 \ eventtimers.4 \ exca.4 \ fatm.4 \ fd.4 \ fdc.4 \ fdt.4 \ fdtbus.4 \ ffclock.4 \ filemon.4 \ firewire.4 \ fpa.4 \ full.4 \ fwe.4 \ fwip.4 \ fwohci.4 \ fxp.4 \ gbde.4 \ gdb.4 \ gem.4 \ geom.4 \ geom_fox.4 \ geom_linux_lvm.4 \ geom_map.4 \ geom_uncompress.4 \ geom_uzip.4 \ gif.4 \ gpio.4 \ gpioiic.4 \ gpioled.4 \ gre.4 \ h_ertt.4 \ hatm.4 \ hifn.4 \ hme.4 \ hpet.4 \ ${_hpt27xx.4} \ ${_hptiop.4} \ ${_hptmv.4} \ ${_hptnr.4} \ ${_hptrr.4} \ hv_ata_pci_disengage.4 \ hv_kvp.4 \ hv_netvsc.4 \ hv_storvsc.4 \ hv_utils.4 \ hv_vmbus.4 \ hwpmc.4 \ ichsmb.4 \ ${_ichwd.4} \ icmp.4 \ icmp6.4 \ ida.4 \ ifmib.4 \ ig4.4 \ igb.4 \ igmp.4 \ iic.4 \ iicbb.4 \ iicbus.4 \ iicsmb.4 \ iir.4 \ inet.4 \ inet6.4 \ intpm.4 \ intro.4 \ ${_io.4} \ ip.4 \ ip6.4 \ ipfirewall.4 \ ipheth.4 \ ${_ipmi.4} \ ips.4 \ ipsec.4 \ ipw.4 \ ipwfw.4 \ isci.4 \ ismt.4 \ isp.4 \ ispfw.4 \ iwi.4 \ iwifw.4 \ iwn.4 \ iwnfw.4 \ ixgb.4 \ ixgbe.4 \ ixl.4 \ ixlv.4 \ jme.4 \ joy.4 \ kbdmux.4 \ keyboard.4 \ kld.4 \ ksyms.4 \ ktr.4 \ kue.4 \ lagg.4 \ le.4 \ led.4 \ lge.4 \ ${_linux.4} \ lm75.4 \ lmc.4 \ lo.4 \ lp.4 \ lpbb.4 \ lpt.4 \ mac.4 \ mac_biba.4 \ mac_bsdextended.4 \ mac_ifoff.4 \ mac_lomac.4 \ mac_mls.4 \ mac_none.4 \ mac_partition.4 \ mac_portacl.4 \ mac_seeotheruids.4 \ mac_stub.4 \ mac_test.4 \ malo.4 \ mcd.4 \ md.4 \ me.4 \ mem.4 \ meteor.4 \ mfi.4 \ miibus.4 \ mk48txx.4 \ mld.4 \ mlx.4 \ mly.4 \ mmc.4 \ mmcsd.4 \ mn.4 \ mod_cc.4 \ mos.4 \ mouse.4 \ mpr.4 \ mps.4 \ mpt.4 \ mrsas.4 \ msk.4 \ mtio.4 \ multicast.4 \ mvs.4 \ mwl.4 \ mwlfw.4 \ mxge.4 \ my.4 \ nand.4 \ nandsim.4 \ natm.4 \ natmip.4 \ ncr.4 \ ncv.4 \ ${_ndis.4} \ net80211.4 \ netfpga10g_nf10bmac.4 \ netgraph.4 \ netintro.4 \ netmap.4 \ ${_nfe.4} \ ${_nfsmb.4} \ ng_async.4 \ ng_atm.4 \ ngatmbase.4 \ ng_atmllc.4 \ ng_bluetooth.4 \ ng_bpf.4 \ ng_bridge.4 \ ng_bt3c.4 \ ng_btsocket.4 \ ng_car.4 \ ng_ccatm.4 \ ng_cisco.4 \ ng_deflate.4 \ ng_device.4 \ nge.4 \ ng_echo.4 \ ng_eiface.4 \ ng_etf.4 \ ng_ether.4 \ ng_ether_echo.4 \ ng_frame_relay.4 \ ng_gif.4 \ ng_gif_demux.4 \ ng_h4.4 \ ng_hci.4 \ ng_hole.4 \ ng_hub.4 \ ng_iface.4 \ ng_ipfw.4 \ ng_ip_input.4 \ ng_ksocket.4 \ ng_l2cap.4 \ ng_l2tp.4 \ ng_lmi.4 \ ng_mppc.4 \ ng_nat.4 \ ng_netflow.4 \ ng_one2many.4 \ ng_patch.4 \ ng_ppp.4 \ ng_pppoe.4 \ ng_pptpgre.4 \ ng_pred1.4 \ ng_rfc1490.4 \ ng_socket.4 \ ng_source.4 \ ng_split.4 \ ng_sppp.4 \ ng_sscfu.4 \ ng_sscop.4 \ ng_tag.4 \ ng_tcpmss.4 \ ng_tee.4 \ ng_tty.4 \ ng_ubt.4 \ ng_UI.4 \ ng_uni.4 \ ng_vjc.4 \ ng_vlan.4 \ nmdm.4 \ nsp.4 \ ${_ntb.4} \ null.4 \ numa.4 \ ${_nvd.4} \ ${_nvme.4} \ ${_nvram.4} \ ${_nvram2env.4} \ ${_nxge.4} \ oce.4 \ ohci.4 \ orm.4 \ ${_padlock.4} \ pass.4 \ patm.4 \ pccard.4 \ pccbb.4 \ pcf.4 \ pci.4 \ pcib.4 \ pcic.4 \ pcm.4 \ pcn.4 \ ${_pf.4} \ ${_pflog.4} \ ${_pfsync.4} \ pim.4 \ pms.4 \ polling.4 \ ppbus.4 \ ppc.4 \ ppi.4 \ procdesc.4 \ proto.4 \ psm.4 \ pst.4 \ pt.4 \ pts.4 \ pty.4 \ puc.4 \ ${_qlxge.4} \ ${_qlxgb.4} \ ${_qlxgbe.4} \ ral.4 \ random.4 \ rc.4 \ re.4 \ rgephy.4 \ rights.4 \ rl.4 \ rndtest.4 \ route.4 \ rp.4 \ rsu.4 \ rsufw.4 \ rue.4 \ rum.4 \ run.4 \ runfw.4 \ sa.4 \ safe.4 \ sbp.4 \ sbp_targ.4 \ scc.4 \ scd.4 \ sched_4bsd.4 \ sched_ule.4 \ screen.4 \ scsi.4 \ sctp.4 \ sdhci.4 \ sem.4 \ send.4 \ ses.4 \ sf.4 \ ${_sfxge.4} \ sge.4 \ si.4 \ siba.4 \ siftr.4 \ siis.4 \ simplebus.4 \ sio.4 \ sis.4 \ sk.4 \ smb.4 \ smbus.4 \ smp.4 \ smsc.4 \ sn.4 \ snd_ad1816.4 \ snd_als4000.4 \ snd_atiixp.4 \ snd_cmi.4 \ snd_cs4281.4 \ snd_csa.4 \ snd_ds1.4 \ snd_emu10k1.4 \ snd_emu10kx.4 \ snd_envy24.4 \ snd_envy24ht.4 \ snd_es137x.4 \ snd_ess.4 \ snd_fm801.4 \ snd_gusc.4 \ snd_hda.4 \ snd_hdspe.4 \ snd_ich.4 \ snd_maestro3.4 \ snd_maestro.4 \ snd_mss.4 \ snd_neomagic.4 \ snd_sbc.4 \ snd_solo.4 \ snd_spicds.4 \ snd_t4dwave.4 \ snd_uaudio.4 \ snd_via8233.4 \ snd_via82c686.4 \ snd_vibes.4 \ snp.4 \ spic.4 \ ${_spkr.4} \ splash.4 \ sppp.4 \ ste.4 \ stf.4 \ stg.4 \ stge.4 \ sym.4 \ syncache.4 \ syncer.4 \ syscons.4 \ sysmouse.4 \ tap.4 \ targ.4 \ tcp.4 \ tdfx.4 \ terasic_mtl.4 \ termios.4 \ textdump.4 \ ti.4 \ timecounters.4 \ tl.4 \ ${_tpm.4} \ trm.4 \ tty.4 \ tun.4 \ twa.4 \ twe.4 \ tws.4 \ tx.4 \ txp.4 \ vale.4 \ vga.4 \ vge.4 \ viapm.4 \ ${_viawd.4} \ ${_virtio.4} \ ${_virtio_balloon.4} \ ${_virtio_blk.4} \ ${_virtio_console.4} \ ${_virtio_random.4} \ ${_virtio_scsi.4} \ vkbd.4 \ vlan.4 \ vxlan.4 \ ${_vmx.4} \ vpo.4 \ vr.4 \ vt.4 \ vte.4 \ ${_vtnet.4} \ ${_vxge.4} \ watchdog.4 \ wb.4 \ ${_wbwd.4} \ wi.4 \ witness.4 \ wlan.4 \ wlan_acl.4 \ wlan_amrr.4 \ wlan_ccmp.4 \ wlan_tkip.4 \ wlan_wep.4 \ wlan_xauth.4 \ ${_wpi.4} \ wsp.4 \ xe.4 \ ${_xen.4} \ xhci.4 \ xl.4 \ ${_xnb.4} \ xpt.4 \ zero.4 \ zyd.4 MLINKS= ae.4 if_ae.4 MLINKS+=age.4 if_age.4 MLINKS+=agp.4 agpgart.4 MLINKS+=alc.4 if_alc.4 MLINKS+=ale.4 if_ale.4 MLINKS+=altera_atse.4 atse.4 MLINKS+=altera_sdcard.4 altera_sdcardc.4 MLINKS+=altq.4 ALTQ.4 MLINKS+=ath.4 if_ath.4 MLINKS+=ath_pci.4 if_ath_pci.4 MLINKS+=an.4 if_an.4 MLINKS+=aue.4 if_aue.4 MLINKS+=axe.4 if_axe.4 MLINKS+=bce.4 if_bce.4 MLINKS+=bfe.4 if_bfe.4 MLINKS+=bge.4 if_bge.4 MLINKS+=bktr.4 brooktree.4 MLINKS+=bridge.4 if_bridge.4 MLINKS+=bwi.4 if_bwi.4 MLINKS+=bwn.4 if_bwn.4 MLINKS+=${_bxe.4} ${_if_bxe.4} MLINKS+=cas.4 if_cas.4 MLINKS+=cdce.4 if_cdce.4 MLINKS+=crypto.4 cryptodev.4 MLINKS+=cue.4 if_cue.4 MLINKS+=cxgb.4 if_cxgb.4 MLINKS+=cxgbe.4 if_cxgbe.4 \ cxgbe.4 cxl.4 \ cxgbe.4 if_cxl.4 MLINKS+=dc.4 if_dc.4 MLINKS+=de.4 if_de.4 MLINKS+=disc.4 if_disc.4 MLINKS+=ed.4 if_ed.4 MLINKS+=edsc.4 if_edsc.4 MLINKS+=em.4 if_em.4 MLINKS+=en.4 if_en.4 MLINKS+=enc.4 if_enc.4 MLINKS+=epair.4 if_epair.4 MLINKS+=et.4 if_et.4 MLINKS+=fatm.4 if_fatm.4 MLINKS+=fd.4 stderr.4 \ fd.4 stdin.4 \ fd.4 stdout.4 MLINKS+=fdt.4 FDT.4 MLINKS+=firewire.4 ieee1394.4 MLINKS+=fpa.4 fea.4 MLINKS+=fwe.4 if_fwe.4 MLINKS+=fwip.4 if_fwip.4 MLINKS+=fxp.4 if_fxp.4 MLINKS+=gem.4 if_gem.4 MLINKS+=geom.4 GEOM.4 MLINKS+=gif.4 if_gif.4 MLINKS+=gpio.4 gpiobus.4 MLINKS+=gre.4 if_gre.4 MLINKS+=hatm.4 if_hatm.4 MLINKS+=hme.4 if_hme.4 MLINKS+=hpet.4 acpi_hpet.4 MLINKS+=${_hptrr.4} ${_rr232x.4} MLINKS+=${_attimer.4} ${_i8254.4} MLINKS+=igb.4 if_igb.4 MLINKS+=ip.4 rawip.4 MLINKS+=ipfirewall.4 ipaccounting.4 \ ipfirewall.4 ipacct.4 \ ipfirewall.4 ipfw.4 MLINKS+=ipheth.4 if_ipheth.4 MLINKS+=ipw.4 if_ipw.4 MLINKS+=iwi.4 if_iwi.4 MLINKS+=iwn.4 if_iwn.4 MLINKS+=ixgb.4 if_ixgb.4 MLINKS+=ixgbe.4 ix.4 MLINKS+=ixgbe.4 if_ix.4 MLINKS+=ixgbe.4 if_ixgbe.4 MLINKS+=ixl.4 if_ixl.4 MLINKS+=ixlv.4 if_ixlv.4 MLINKS+=jme.4 if_jme.4 MLINKS+=kue.4 if_kue.4 MLINKS+=lagg.4 trunk.4 MLINKS+=lagg.4 if_lagg.4 MLINKS+=le.4 if_le.4 MLINKS+=lge.4 if_lge.4 MLINKS+=lmc.4 if_lmc.4 MLINKS+=lo.4 loop.4 MLINKS+=lp.4 plip.4 MLINKS+=malo.4 if_malo.4 MLINKS+=md.4 vn.4 MLINKS+=mem.4 kmem.4 MLINKS+=mn.4 if_mn.4 MLINKS+=mos.4 if_mos.4 MLINKS+=msk.4 if_msk.4 MLINKS+=mwl.4 if_mwl.4 MLINKS+=mxge.4 if_mxge.4 MLINKS+=my.4 if_my.4 MLINKS+=${_ndis.4} ${_if_ndis.4} MLINKS+=netfpga10g_nf10bmac.4 if_nf10bmac.4 MLINKS+=netintro.4 net.4 \ netintro.4 networking.4 MLINKS+=${_nfe.4} ${_if_nfe.4} MLINKS+=nge.4 if_nge.4 MLINKS+=${_ntb.4} ${_if_ntb.4} \ ${_ntb.4} ${_ntb_hw.4} MLINKS+=${_nxge.4} ${_if_nxge.4} MLINKS+=patm.4 if_patm.4 MLINKS+=pccbb.4 cbb.4 MLINKS+=pcm.4 snd.4 \ pcm.4 sound.4 MLINKS+=pcn.4 if_pcn.4 MLINKS+=ral.4 if_ral.4 MLINKS+=re.4 if_re.4 MLINKS+=rl.4 if_rl.4 MLINKS+=rue.4 if_rue.4 MLINKS+=rum.4 if_rum.4 MLINKS+=run.4 if_run.4 MLINKS+=scsi.4 CAM.4 \ scsi.4 cam.4 \ scsi.4 scbus.4 \ scsi.4 SCSI.4 MLINKS+=sf.4 if_sf.4 MLINKS+=sge.4 if_sge.4 MLINKS+=sis.4 if_sis.4 MLINKS+=sk.4 if_sk.4 MLINKS+=smp.4 SMP.4 MLINKS+=smsc.4 if_smsc.4 MLINKS+=sn.4 if_sn.4 MLINKS+=snd_envy24.4 snd_ak452x.4 MLINKS+=snd_sbc.4 snd_sb16.4 \ snd_sbc.4 snd_sb8.4 MLINKS+=${_spkr.4} ${_speaker.4} MLINKS+=splash.4 screensaver.4 MLINKS+=ste.4 if_ste.4 MLINKS+=stf.4 if_stf.4 MLINKS+=stge.4 if_stge.4 MLINKS+=syncache.4 syncookies.4 MLINKS+=syscons.4 sc.4 MLINKS+=tap.4 if_tap.4 MLINKS+=tdfx.4 tdfx_linux.4 MLINKS+=ti.4 if_ti.4 MLINKS+=tl.4 if_tl.4 MLINKS+=tun.4 if_tun.4 MLINKS+=tx.4 if_tx.4 MLINKS+=txp.4 if_txp.4 MLINKS+=vge.4 if_vge.4 MLINKS+=vlan.4 if_vlan.4 MLINKS+=vxlan.4 if_vxlan.4 MLINKS+=${_vmx.4} ${_if_vmx.4} MLINKS+=vpo.4 imm.4 MLINKS+=vr.4 if_vr.4 MLINKS+=vte.4 if_vte.4 MLINKS+=${_vtnet.4} ${_if_vtnet.4} MLINKS+=${_vxge.4} ${_if_vxge.4} MLINKS+=watchdog.4 SW_WATCHDOG.4 MLINKS+=wb.4 if_wb.4 MLINKS+=wi.4 if_wi.4 MLINKS+=${_wpi.4} ${_if_wpi.4} MLINKS+=xe.4 if_xe.4 MLINKS+=xl.4 if_xl.4 MLINKS+=zyd.4 if_zyd.4 .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" _acpi_asus.4= acpi_asus.4 _acpi_asus_wmi.4= acpi_asus_wmi.4 _acpi_dock.4= acpi_dock.4 _acpi_fujitsu.4=acpi_fujitsu.4 _acpi_hp.4= acpi_hp.4 _acpi_ibm.4= acpi_ibm.4 _acpi_panasonic.4=acpi_panasonic.4 _acpi_rapidstart.4=acpi_rapidstart.4 _acpi_sony.4= acpi_sony.4 _acpi_toshiba.4=acpi_toshiba.4 _acpi_wmi.4= acpi_wmi.4 _aesni.4= aesni.4 _aout.4= aout.4 _apic.4= apic.4 _atrtc.4= atrtc.4 _attimer.4= attimer.4 _aibs.4= aibs.4 _amdsbwd.4= amdsbwd.4 _amdsmb.4= amdsmb.4 _amdtemp.4= amdtemp.4 _asmc.4= asmc.4 _bxe.4= bxe.4 _coretemp.4= coretemp.4 _cpuctl.4= cpuctl.4 _dpms.4= dpms.4 _hpt27xx.4= hpt27xx.4 _hptiop.4= hptiop.4 _hptmv.4= hptmv.4 _hptnr.4= hptnr.4 _hptrr.4= hptrr.4 _i8254.4= i8254.4 _ichwd.4= ichwd.4 _if_bxe.4= if_bxe.4 _if_ndis.4= if_ndis.4 _if_nfe.4= if_nfe.4 _if_nxge.4= if_nxge.4 _if_urtw.4= if_urtw.4 _if_vmx.4= if_vmx.4 _if_vtnet.4= if_vtnet.4 _if_vxge.4= if_vxge.4 _if_wpi.4= if_wpi.4 _ipmi.4= ipmi.4 _io.4= io.4 _linux.4= linux.4 _ndis.4= ndis.4 _nfe.4= nfe.4 _nfsmb.4= nfsmb.4 _nvd.4= nvd.4 _nvme.4= nvme.4 _nvram.4= nvram.4 _nxge.4= nxge.4 _virtio.4= virtio.4 _virtio_balloon.4=virtio_balloon.4 _virtio_blk.4= virtio_blk.4 _virtio_console.4=virtio_console.4 _virtio_random.4= virtio_random.4 _virtio_scsi.4= virtio_scsi.4 _vmx.4= vmx.4 _vtnet.4= vtnet.4 _vxge.4= vxge.4 _padlock.4= padlock.4 _rr232x.4= rr232x.4 _speaker.4= speaker.4 _spkr.4= spkr.4 _tpm.4= tpm.4 _urtw.4= urtw.4 _viawd.4= viawd.4 _wbwd.4= wbwd.4 _wpi.4= wpi.4 _xen.4= xen.4 _xnb.4= xnb.4 .endif .if ${MACHINE_CPUARCH} == "amd64" _if_ntb.4= if_ntb.4 _ntb.4= ntb.4 _ntb_hw.4= ntb_hw.4 _qlxge.4= qlxge.4 _qlxgb.4= qlxgb.4 _qlxgbe.4= qlxgbe.4 _sfxge.4= sfxge.4 MLINKS+=qlxge.4 if_qlxge.4 MLINKS+=qlxgb.4 if_qlxgb.4 MLINKS+=qlxgbe.4 if_qlxgbe.4 MLINKS+=sfxge.4 if_sfxge.4 .if ${MK_BHYVE} != "no" _bhyve.4= bhyve.4 .endif .endif .if ${MACHINE_CPUARCH} == "mips" _nvram2env.4= nvram2env.4 .endif .if exists(${.CURDIR}/man4.${MACHINE_CPUARCH}) SUBDIR= man4.${MACHINE_CPUARCH} .endif .if ${MK_CCD} != "no" _ccd.4= ccd.4 .endif .if ${MK_CDDL} != "no" _dtrace_io.4= dtrace_io.4 _dtrace_ip.4= dtrace_ip.4 _dtrace_proc.4= dtrace_proc.4 _dtrace_sched.4= dtrace_sched.4 _dtrace_tcp.4= dtrace_tcp.4 _dtrace_udp.4= dtrace_udp.4 .endif .if ${MK_ISCSI} != "no" MAN+= iscsi.4 MAN+= iscsi_initiator.4 .endif .if ${MK_TESTS} != "no" ATF= ${.CURDIR}/../../../contrib/atf .PATH: ${ATF}/doc _atf_test_case.4= atf-test-case.4 .endif .if ${MK_PF} != "no" _pf.4= pf.4 _pflog.4= pflog.4 _pfsync.4= pfsync.4 .endif .if ${MK_USB} != "no" MAN+= \ u3g.4 \ uark.4 \ uart.4 \ uath.4 \ ubsa.4 \ ubsec.4 \ ubser.4 \ ubtbcmfw.4 \ uchcom.4 \ ucom.4 \ ucycom.4 \ udav.4 \ udbp.4 \ udp.4 \ udplite.4 \ udl.4 \ uep.4 \ ufm.4 \ ufoma.4 \ uftdi.4 \ ugen.4 \ ugold.4 \ uhci.4 \ uhid.4 \ uhso.4 \ uipaq.4 \ ukbd.4 \ uled.4 \ ulpt.4 \ umass.4 \ umcs.4 \ umct.4 \ umodem.4 \ umoscom.4 \ ums.4 \ unix.4 \ upgt.4 \ uplcom.4 \ ural.4 \ urio.4 \ urndis.4 \ ${_urtw.4} \ urtwn.4 \ urtwnfw.4 \ usb.4 \ usb_quirk.4 \ usb_template.4 \ usfs.4 \ uslcom.4 \ utopia.4 \ uvisor.4 \ uvscom.4 \ MLINKS+=u3g.4 u3gstub.4 MLINKS+=uath.4 if_uath.4 MLINKS+=udav.4 if_udav.4 MLINKS+=upgt.4 if_upgt.4 MLINKS+=ural.4 if_ural.4 MLINKS+=urndis.4 if_urndis.4 MLINKS+=${_urtw.4} ${_if_urtw.4} .endif .include Index: head/share/man/man4/cyapa.4 =================================================================== --- head/share/man/man4/cyapa.4 (nonexistent) +++ head/share/man/man4/cyapa.4 (revision 285876) @@ -0,0 +1,200 @@ +.\" Copyright (c) 2015 Michael Gmelin +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd July 25, 2015 +.Dt CYAPA 4 +.Os +.Sh NAME +.Nm cyapa +.Nd Cypress APA trackpad with I2C interface driver +.Sh SYNOPSIS +To compile this driver into the kernel, place the following lines into +the kernel configuration file: +.Bd -ragged -offset indent +.Cd "device cyapa" +.Cd "device ig4" +.Cd "device smbus" +.Ed +.Pp +Alternatively, to load the driver as a module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +cyapa_load="YES" +ig4_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides support for the Cypress APA trackpad. +It emulates the IntelliMouse PS/2 protocol. +It supports basic mouse ioctls, so that +.Xr moused 8 +is supported properly. +.Ss Trackpad layout +.Bd -literal + 2/3 1/3 + +--------------------+------------+ + | | Middle | + | | Button | + | Left | | + | Button +------------+ + | | Right | + | | Button | + +--------------------+............| + | Thumb/Button Area | 15% + +---------------------------------+ +.Ed +.Ss Trackpad features +.Bl -tag -width 8n +.It Va Two finger scrolling +Use two fingers for Z axis scrolling. +.It Va Button down/second finger +While one finger clicks and holds down the touchpad, the second finger can be +used to move the mouse cursor. +This can be useful for drawing or selecting text. +.It Va Thumb/Button area +The lower 15% of the trackpad will not affect the mouse cursor position. +This allows for high precision clicking, by controlling the cursor with the +index finger and pushing/holding the pad down with the thumb. +.It Va Trackpad button +Push physical button. +The left two thirds of the pad issues a LEFT button event. +The upper right corner issues a MIDDLE button event. +The lower right corner issues a RIGHT button. +Optionally, tap to click can be enabled (see below). +.El +.Sh SYSCTL VARIABLES +These +.Xr sysctl 8 +variables are available: +.Bl -tag -width 8n +.It Va debug.cyapa_idle_freq +Scan frequency in idle mode, the default is 1. +.It Va debug.cyapa_slow_freq +Scan frequency in slow mode, the default is 20. +.It Va debug.cyapa_norm_freq +Scan frequency in normal mode, the default is 100. +.It Va debug.cyapa_minpressure +Minimum pressure to detect a finger, the default is 12. +.It Va debug.cyapa_enable_tapclick +Controls tap to click. +Possible values: +.Bl -tag -width 8n +.It 0 +Tap to click is disabled. +This is the default value. +.It 1 +Tap to click always generates a left mouse button event. +.It 2 +Tap to click generates left mouse button event if the left 2/3rds of the pad +are tapped and a right mouse button event otherwise. +.It 3 +Tap to click generates mouse button events as if the physical button was +pressed (see +.Sx DESCRIPTION +above). +.El +.It Va debug.cyapa_tapclick_min_ticks +Minimum tap duration in ticks to create a click, the default is 1. +.It Va debug.cyapa_tapclick_max_ticks +Maximum tap duration in ticks to create a click, the default is 8. +.It Va debug.cyapa_move_min_ticks +Minimum ticks before cursor movement occurs, the default is 4. +.It Va debug.cyapa_scroll_wait_ticks +Ticks to wait before starting to scroll, the default is 0. +.It Va debug.cyapa_scroll_stick_ticks +Ticks while preventing cursor movement on single finger after scroll, +the default is 15. +.It Va debug.cyapa_thumbarea_percent +Size of bottom thumb area in percent, the default is 15. +.It Va debug.cyapa_debug +Setting this to a non-zero value enables debug output to console and syslog, +the default is 0. +.It Va debug.cyapa_reset +Setting this to a non-zero value reinitializes the device. +The sysctl resets to zero immediately. +.El +.Sh FILES +.Nm +creates +.Pa /dev/cyapa0 , +which presents the mouse as an +.Ar IntelliMouse PS/2 +device. +It supports +.Xr moused 8 +levels 0 through 2, level 1 is used by default. +.Sh EXAMPLES +To use +.Nm +with +.Xr moused 8 , +add the following lines to the +.Xr rc.conf 5 +file: +.Pp +.Dl moused_enable="YES" +.Dl moused_port="/dev/cyapa0" +.Pp +If vertical scrolling is not desired, add +.Pp +.Dl moused_flags="-l0" +.Pp +to +.Xr rc.conf 5 . +.Pp +Enable tap to click for the left and the right mouse button and +disable the thumb area by adding these lines to the +.Xr sysctl.conf 5 +file: +.Pp +.Dl debug.cyapa_thumbarea_percent=0 +.Dl debug.cyapa_enable_tapclick=2 +.Sh SEE ALSO +.Xr ig4 4 , +.Xr moused 4 , +.Xr smbus 4 , +.Xr sysmouse 4 +.Sh AUTHORS +.An -nosplit +The original +.Nm +driver was written for DragonFly BSD by +.An Matthew Dillon . +.Pp +It has been ported, modified, and enhanced for +.Fx +by +.An Michael Gmelin Aq Mt freebsd@grem.de . +.Pp +This manual page was written by +.An Michael Gmelin Aq Mt freebsd@grem.de . +.Sh BUGS +The +.Nm +driver detects the device based on its I2C address (0x67). +This might have unforeseen consequences if the initialization sequence +is sent to an unknown device at that address. Property changes on: head/share/man/man4/cyapa.4 ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sys/dev/cyapa/cyapa.c =================================================================== --- head/sys/dev/cyapa/cyapa.c (nonexistent) +++ head/sys/dev/cyapa/cyapa.c (revision 285876) @@ -0,0 +1,1707 @@ +/* + * Copyright (c) 2014 The DragonFly Project. All rights reserved. + * + * This code is derived from software contributed to The DragonFly Project + * by Matthew Dillon and was subsequently ported, + * modified and enhanced for FreeBSD by Michael Gmelin . + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of The DragonFly Project nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific, prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * CYAPA - Cypress APA trackpad with I2C Interface driver + * + * Based on DragonFlyBSD's cyapa driver, which referenced the linux + * cyapa.c driver to figure out the bootstrapping and commands. + * + * Unable to locate any datasheet for the device. + * + * + * Trackpad layout: + * + * 2/3 1/3 + * +--------------------+------------+ + * | | Middle | + * | | Button | + * | Left | | + * | Button +------------+ + * | | Right | + * | | Button | + * +--------------------+............| + * | Thumb/Button Area | 15% + * +---------------------------------+ + * + * + * FEATURES + * + * IMPS/2 emulation - Emulates the IntelliMouse protocol. + * + * Jitter supression - Implements 2-pixel hysteresis with memory. + * + * Jump detecion - Detect jumps caused by touchpad. + * + * Two finger scrolling - Use two fingers for Z axis scrolling. + * + * Button down/2nd finger - While one finger clicks and holds down the + * touchpad, the second one can be used to move + * the mouse cursor. Useful for drawing or + * selecting text. + * + * Thumb/Button Area - The lower 15%* of the trackpad will not affect + * the mouse cursor position. This allows for high + * precision clicking, by controlling the cursor + * with the index finger and pushing/holding the + * pad down with the thumb. + * * can be changed using sysctl + * + * Track-pad button - Push physical button. Left 2/3rds of the pad + * will issue a LEFT button event, upper right + * corner will issue a MIDDLE button event, + * lower right corner will issue a RIGHT button + * event. Optional tap support can be enabled + * and configured using sysctl. + * + * WARNINGS + * + * These trackpads get confused when three or more fingers are down on the + * same horizontal axis and will start to glitch the finger detection. + * Removing your hand for a few seconds will allow the trackpad to + * recalibrate. Generally speaking, when using three or more fingers + * please try to place at least one finger off-axis (a little above or + * below) the other two. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "smbus_if.h" +#include "bus_if.h" +#include "device_if.h" + +#define CYAPA_BUFSIZE 128 /* power of 2 */ +#define CYAPA_BUFMASK (CYAPA_BUFSIZE - 1) + +#define ZSCALE 15 + +#define TIME_TO_IDLE (hz * 10) +#define TIME_TO_RESET (hz * 3) + +static MALLOC_DEFINE(M_CYAPA, "cyapa", "CYAPA device data"); + +struct cyapa_fifo { + int rindex; + int windex; + char buf[CYAPA_BUFSIZE]; +}; + +struct cyapa_softc { + device_t dev; + int count; /* >0 if device opened */ + int unit; + int addr; + struct cdev *devnode; + struct selinfo selinfo; + struct mtx mutex; + + int cap_resx; + int cap_resy; + int cap_phyx; + int cap_phyy; + uint8_t cap_buttons; + + int detaching; /* driver is detaching */ + int poll_thread_running; /* poll thread is running */ + + /* PS/2 mouse emulation */ + int track_x; /* current tracking */ + int track_y; + int track_z; + int track_z_ticks; + uint16_t track_but; + char track_id; /* first finger id */ + int track_nfingers; + int delta_x; /* accumulation -> report */ + int delta_y; + int delta_z; + int fuzz_x; + int fuzz_y; + int fuzz_z; + int touch_x; /* touch down coordinates */ + int touch_y; + int touch_z; + int finger1_ticks; + int finger2_ticks; + int finger3_ticks; + uint16_t reported_but; + + struct cyapa_fifo rfifo; /* device->host */ + struct cyapa_fifo wfifo; /* host->device */ + uint8_t ps2_cmd; /* active p2_cmd waiting for data */ + uint8_t ps2_acked; + int active_tick; + int data_signal; + int blocked; + int isselect; + int reporting_mode; /* 0=disabled 1=enabled */ + int scaling_mode; /* 0=1:1 1=2:1 */ + int remote_mode; /* 0 for streaming mode */ + int zenabled; /* z-axis enabled (mode 1 or 2) */ + mousehw_t hw; /* hardware information */ + mousemode_t mode; /* mode */ + int poll_ticks; +}; + +struct cyapa_cdevpriv { + struct cyapa_softc *sc; +}; + +#define CYPOLL_SHUTDOWN 0x0001 + +static void cyapa_poll_thread(void *arg); +static int cyapa_raw_input(struct cyapa_softc *sc, struct cyapa_regs *regs, + int freq); +static void cyapa_set_power_mode(struct cyapa_softc *sc, int mode); + +static int fifo_empty(struct cyapa_softc *sc, struct cyapa_fifo *fifo); +static size_t fifo_ready(struct cyapa_softc *sc, struct cyapa_fifo *fifo); +static char *fifo_read(struct cyapa_softc *sc, struct cyapa_fifo *fifo, + size_t n); +static char *fifo_write(struct cyapa_softc *sc, struct cyapa_fifo *fifo, + size_t n); +static uint8_t fifo_read_char(struct cyapa_softc *sc, + struct cyapa_fifo *fifo); +static void fifo_write_char(struct cyapa_softc *sc, struct cyapa_fifo *fifo, + uint8_t c); +static size_t fifo_space(struct cyapa_softc *sc, struct cyapa_fifo *fifo); +static void fifo_reset(struct cyapa_softc *sc, struct cyapa_fifo *fifo); + +static int cyapa_fuzz(int delta, int *fuzz); + +static int cyapa_idle_freq = 1; +SYSCTL_INT(_debug, OID_AUTO, cyapa_idle_freq, CTLFLAG_RW, + &cyapa_idle_freq, 0, "Scan frequency in idle mode"); +static int cyapa_slow_freq = 20; +SYSCTL_INT(_debug, OID_AUTO, cyapa_slow_freq, CTLFLAG_RW, + &cyapa_slow_freq, 0, "Scan frequency in slow mode "); +static int cyapa_norm_freq = 100; +SYSCTL_INT(_debug, OID_AUTO, cyapa_norm_freq, CTLFLAG_RW, + &cyapa_norm_freq, 0, "Normal scan frequency"); +static int cyapa_minpressure = 12; +SYSCTL_INT(_debug, OID_AUTO, cyapa_minpressure, CTLFLAG_RW, + &cyapa_minpressure, 0, "Minimum pressure to detect finger"); +static int cyapa_enable_tapclick = 0; +SYSCTL_INT(_debug, OID_AUTO, cyapa_enable_tapclick, CTLFLAG_RW, + &cyapa_enable_tapclick, 0, "Enable tap to click"); +static int cyapa_tapclick_min_ticks = 1; +SYSCTL_INT(_debug, OID_AUTO, cyapa_tapclick_min_ticks, CTLFLAG_RW, + &cyapa_tapclick_min_ticks, 0, "Minimum tap duration for click"); +static int cyapa_tapclick_max_ticks = 8; +SYSCTL_INT(_debug, OID_AUTO, cyapa_tapclick_max_ticks, CTLFLAG_RW, + &cyapa_tapclick_max_ticks, 0, "Maximum tap duration for click"); +static int cyapa_move_min_ticks = 4; +SYSCTL_INT(_debug, OID_AUTO, cyapa_move_min_ticks, CTLFLAG_RW, + &cyapa_move_min_ticks, 0, + "Minimum ticks before cursor position is changed"); +static int cyapa_scroll_wait_ticks = 0; +SYSCTL_INT(_debug, OID_AUTO, cyapa_scroll_wait_ticks, CTLFLAG_RW, + &cyapa_scroll_wait_ticks, 0, + "Wait N ticks before starting to scroll"); +static int cyapa_scroll_stick_ticks = 15; +SYSCTL_INT(_debug, OID_AUTO, cyapa_scroll_stick_ticks, CTLFLAG_RW, + &cyapa_scroll_stick_ticks, 0, + "Prevent cursor move on single finger for N ticks after scroll"); +static int cyapa_thumbarea_percent = 15; +SYSCTL_INT(_debug, OID_AUTO, cyapa_thumbarea_percent, CTLFLAG_RW, + &cyapa_thumbarea_percent, 0, + "Size of bottom thumb area in percent"); + +static int cyapa_debug = 0; +SYSCTL_INT(_debug, OID_AUTO, cyapa_debug, CTLFLAG_RW, + &cyapa_debug, 0, "Enable debugging"); +static int cyapa_reset = 0; +SYSCTL_INT(_debug, OID_AUTO, cyapa_reset, CTLFLAG_RW, + &cyapa_reset, 0, "Reset track pad"); + +static void +cyapa_lock(struct cyapa_softc *sc) +{ + + mtx_lock(&sc->mutex); +} + +static void +cyapa_unlock(struct cyapa_softc *sc) +{ + + mtx_unlock(&sc->mutex); +} + +#define CYAPA_LOCK_ASSERT(sc) mtx_assert(&(sc)->mutex, MA_OWNED); + +/* + * Notify if possible receive data ready. Must be called + * with sc->mutex held (cyapa_lock(sc)). + */ +static void +cyapa_notify(struct cyapa_softc *sc) +{ + + CYAPA_LOCK_ASSERT(sc); + + if (sc->data_signal || !fifo_empty(sc, &sc->rfifo)) { + KNOTE_LOCKED(&sc->selinfo.si_note, 0); + if (sc->blocked || sc->isselect) { + if (sc->blocked) { + sc->blocked = 0; + wakeup(&sc->blocked); + } + if (sc->isselect) { + sc->isselect = 0; + selwakeup(&sc->selinfo); + } + } + } +} + +/* + * Initialize the device + */ +static int +init_device(device_t dev, struct cyapa_cap *cap, int addr, int probe) +{ + static char bl_exit[] = { + 0x00, 0xff, 0xa5, 0x00, 0x01, + 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }; + static char bl_deactivate[] = { + 0x00, 0xff, 0x3b, 0x00, 0x01, + 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }; + device_t bus; + struct cyapa_boot_regs boot; + int error; + int retries; + + bus = device_get_parent(dev); /* smbus */ + + /* Get status */ + error = smbus_trans(bus, addr, CMD_BOOT_STATUS, + SMB_TRANS_NOCNT | SMB_TRANS_7BIT, + NULL, 0, (void *)&boot, sizeof(boot), NULL); + if (error) + goto done; + + /* + * Bootstrap the device if necessary. It can take up to 2 seconds + * for the device to fully initialize. + */ + retries = 20; + while ((boot.stat & CYAPA_STAT_RUNNING) == 0 && retries > 0) { + if (boot.boot & CYAPA_BOOT_BUSY) { + /* Busy, wait loop. */ + } else if (boot.error & CYAPA_ERROR_BOOTLOADER) { + /* Magic */ + error = smbus_trans(bus, addr, CMD_BOOT_STATUS, + SMB_TRANS_NOCNT | SMB_TRANS_7BIT, + bl_deactivate, sizeof(bl_deactivate), + NULL, 0, NULL); + if (error) + goto done; + } else { + /* Magic */ + error = smbus_trans(bus, addr, CMD_BOOT_STATUS, + SMB_TRANS_NOCNT | SMB_TRANS_7BIT, + bl_exit, sizeof(bl_exit), NULL, 0, NULL); + if (error) + goto done; + } + pause("cyapab1", (hz * 2) / 10); + --retries; + error = smbus_trans(bus, addr, CMD_BOOT_STATUS, + SMB_TRANS_NOCNT | SMB_TRANS_7BIT, + NULL, 0, (void *)&boot, sizeof(boot), NULL); + if (error) + goto done; + } + + if (retries == 0) { + device_printf(dev, "Unable to bring device out of bootstrap\n"); + error = ENXIO; + goto done; + } + + /* Check identity */ + if (cap) { + error = smbus_trans(bus, addr, CMD_QUERY_CAPABILITIES, + SMB_TRANS_NOCNT | SMB_TRANS_7BIT, + NULL, 0, (void *)cap, sizeof(*cap), NULL); + + if (strncmp(cap->prod_ida, "CYTRA", 5) != 0) { + device_printf(dev, "Product ID \"%5.5s\" mismatch\n", + cap->prod_ida); + error = ENXIO; + } + } + error = smbus_trans(bus, addr, CMD_BOOT_STATUS, + SMB_TRANS_NOCNT | SMB_TRANS_7BIT, + NULL, 0, (void *)&boot, sizeof(boot), NULL); + + if (probe == 0) /* official init */ + device_printf(dev, "cyapa init status %02x\n", boot.stat); + else if (probe == 2) + device_printf(dev, "cyapa reset status %02x\n", boot.stat); + +done: + if (error) + device_printf(dev, "Unable to initialize\n"); + return (error); +} + +static int cyapa_probe(device_t); +static int cyapa_attach(device_t); +static int cyapa_detach(device_t); +static void cyapa_cdevpriv_dtor(void*); + +static devclass_t cyapa_devclass; + +static device_method_t cyapa_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, cyapa_probe), + DEVMETHOD(device_attach, cyapa_attach), + DEVMETHOD(device_detach, cyapa_detach), + + DEVMETHOD_END +}; + +static driver_t cyapa_driver = { + "cyapa", + cyapa_methods, + sizeof(struct cyapa_softc), +}; + +static d_open_t cyapaopen; +static d_ioctl_t cyapaioctl; +static d_read_t cyaparead; +static d_write_t cyapawrite; +static d_kqfilter_t cyapakqfilter; +static d_poll_t cyapapoll; + +static struct cdevsw cyapa_cdevsw = { + .d_version = D_VERSION, + .d_open = cyapaopen, + .d_ioctl = cyapaioctl, + .d_read = cyaparead, + .d_write = cyapawrite, + .d_kqfilter = cyapakqfilter, + .d_poll = cyapapoll, +}; + +static int +cyapa_probe(device_t dev) +{ + struct cyapa_cap cap; + int unit; + int addr; + int error; + + addr = smbus_get_addr(dev); + + /* + * 0x67 - cypress trackpad on the acer c720 + * (other devices might use other ids). + */ + if (addr != 0x67) + return (ENXIO); + + unit = device_get_unit(dev); + + error = init_device(dev, &cap, addr, 1); + if (error != 0) + return (ENXIO); + + device_set_desc(dev, "Cypress APA I2C Trackpad"); + + return (BUS_PROBE_VENDOR); +} + +static int +cyapa_attach(device_t dev) +{ + struct cyapa_softc *sc; + struct cyapa_cap cap; + int unit; + int addr; + + sc = device_get_softc(dev); + sc->reporting_mode = 1; + + unit = device_get_unit(dev); + addr = *((unsigned char*) device_get_ivars(dev)); + + if (init_device(dev, &cap, addr, 0)) + return (ENXIO); + + mtx_init(&sc->mutex, "cyapa", NULL, MTX_DEF); + + sc->dev = dev; + sc->unit = unit; + sc->addr = addr; + + knlist_init_mtx(&sc->selinfo.si_note, &sc->mutex); + + sc->cap_resx = ((cap.max_abs_xy_high << 4) & 0x0F00) | + cap.max_abs_x_low; + sc->cap_resy = ((cap.max_abs_xy_high << 8) & 0x0F00) | + cap.max_abs_y_low; + sc->cap_phyx = ((cap.phy_siz_xy_high << 4) & 0x0F00) | + cap.phy_siz_x_low; + sc->cap_phyy = ((cap.phy_siz_xy_high << 8) & 0x0F00) | + cap.phy_siz_y_low; + sc->cap_buttons = cap.buttons; + + device_printf(dev, "%5.5s-%6.6s-%2.2s buttons=%c%c%c res=%dx%d\n", + cap.prod_ida, cap.prod_idb, cap.prod_idc, + ((cap.buttons & CYAPA_FNGR_LEFT) ? 'L' : '-'), + ((cap.buttons & CYAPA_FNGR_MIDDLE) ? 'M' : '-'), + ((cap.buttons & CYAPA_FNGR_RIGHT) ? 'R' : '-'), + sc->cap_resx, sc->cap_resy); + + sc->hw.buttons = 5; + sc->hw.iftype = MOUSE_IF_PS2; + sc->hw.type = MOUSE_MOUSE; + sc->hw.model = MOUSE_MODEL_INTELLI; + sc->hw.hwid = addr; + + sc->mode.protocol = MOUSE_PROTO_PS2; + sc->mode.rate = 100; + sc->mode.resolution = 4; + sc->mode.accelfactor = 1; + sc->mode.level = 0; + sc->mode.packetsize = MOUSE_PS2_PACKETSIZE; + + /* Setup input event tracking */ + cyapa_set_power_mode(sc, CMD_POWER_MODE_IDLE); + + /* Start the polling thread */ + kthread_add(cyapa_poll_thread, sc, NULL, NULL, + 0, 0, "cyapa-poll"); + + sc->devnode = make_dev(&cyapa_cdevsw, unit, + UID_ROOT, GID_WHEEL, 0600, "cyapa%d", unit); + + sc->devnode->si_drv1 = sc; + + return (0); +} + +static int +cyapa_detach(device_t dev) +{ + struct cyapa_softc *sc; + + sc = device_get_softc(dev); + + /* Cleanup poller thread */ + cyapa_lock(sc); + while (sc->poll_thread_running) { + sc->detaching = 1; + mtx_sleep(&sc->detaching, &sc->mutex, PCATCH, "cyapadet", hz); + } + cyapa_unlock(sc); + + destroy_dev(sc->devnode); + + knlist_clear(&sc->selinfo.si_note, 0); + seldrain(&sc->selinfo); + knlist_destroy(&sc->selinfo.si_note); + + mtx_destroy(&sc->mutex); + + return (0); +} + +/* + * USER DEVICE I/O FUNCTIONS + */ +static int +cyapaopen(struct cdev *dev, int oflags, int devtype, struct thread *td) +{ + struct cyapa_cdevpriv *priv; + int error; + + priv = malloc(sizeof(*priv), M_CYAPA, M_WAITOK | M_ZERO); + priv->sc = dev->si_drv1; + + error = devfs_set_cdevpriv(priv, cyapa_cdevpriv_dtor); + if (error == 0) { + cyapa_lock(priv->sc); + priv->sc->count++; + cyapa_unlock(priv->sc); + } + else + free(priv, M_CYAPA); + + return (error); +} + +static void +cyapa_cdevpriv_dtor(void *data) +{ + struct cyapa_cdevpriv *priv; + + priv = data; + KASSERT(priv != NULL, ("cyapa cdevpriv should not be NULL!")); + + cyapa_lock(priv->sc); + priv->sc->count--; + cyapa_unlock(priv->sc); + + free(priv, M_CYAPA); +} + +static int +cyaparead(struct cdev *dev, struct uio *uio, int ioflag) +{ + struct cyapa_softc *sc; + int error; + int didread; + size_t n; + char* ptr; + + sc = dev->si_drv1; + /* If buffer is empty, load a new event if it is ready */ + cyapa_lock(sc); +again: + if (fifo_empty(sc, &sc->rfifo) && + (sc->data_signal || sc->delta_x || sc->delta_y || + sc->track_but != sc->reported_but)) { + uint8_t c0; + uint16_t but; + int delta_x; + int delta_y; + int delta_z; + + /* Accumulate delta_x, delta_y */ + sc->data_signal = 0; + delta_x = sc->delta_x; + delta_y = sc->delta_y; + delta_z = sc->delta_z; + if (delta_x > 255) { + delta_x = 255; + sc->data_signal = 1; + } + if (delta_x < -256) { + delta_x = -256; + sc->data_signal = 1; + } + if (delta_y > 255) { + delta_y = 255; + sc->data_signal = 1; + } + if (delta_y < -256) { + delta_y = -256; + sc->data_signal = 1; + } + if (delta_z > 255) { + delta_z = 255; + sc->data_signal = 1; + } + if (delta_z < -256) { + delta_z = -256; + sc->data_signal = 1; + } + but = sc->track_but; + + /* Adjust baseline for next calculation */ + sc->delta_x -= delta_x; + sc->delta_y -= delta_y; + sc->delta_z -= delta_z; + sc->reported_but = but; + + /* + * Fuzz reduces movement jitter by introducing some + * hysteresis. It operates without cumulative error so + * if you swish around quickly and return your finger to + * where it started, so to will the mouse. + */ + delta_x = cyapa_fuzz(delta_x, &sc->fuzz_x); + delta_y = cyapa_fuzz(delta_y, &sc->fuzz_y); + delta_z = cyapa_fuzz(delta_z, &sc->fuzz_z); + + /* + * Generate report + */ + c0 = 0; + if (delta_x < 0) + c0 |= 0x10; + if (delta_y < 0) + c0 |= 0x20; + c0 |= 0x08; + if (but & CYAPA_FNGR_LEFT) + c0 |= 0x01; + if (but & CYAPA_FNGR_MIDDLE) + c0 |= 0x04; + if (but & CYAPA_FNGR_RIGHT) + c0 |= 0x02; + + fifo_write_char(sc, &sc->rfifo, c0); + fifo_write_char(sc, &sc->rfifo, (uint8_t)delta_x); + fifo_write_char(sc, &sc->rfifo, (uint8_t)delta_y); + switch(sc->zenabled) { + case 1: + /* Z axis all 8 bits */ + fifo_write_char(sc, &sc->rfifo, (uint8_t)delta_z); + break; + case 2: + /* + * Z axis low 4 bits + 4th button and 5th button + * (high 2 bits must be left 0). Auto-scale + * delta_z to fit to avoid a wrong-direction + * overflow (don't try to retain the remainder). + */ + while (delta_z > 7 || delta_z < -8) + delta_z >>= 1; + c0 = (uint8_t)delta_z & 0x0F; + fifo_write_char(sc, &sc->rfifo, c0); + break; + default: + /* basic PS/2 */ + break; + } + cyapa_notify(sc); + } + + /* Blocking / Non-blocking */ + error = 0; + didread = (uio->uio_resid == 0); + + while ((ioflag & IO_NDELAY) == 0 && fifo_empty(sc, &sc->rfifo)) { + if (sc->data_signal) + goto again; + sc->blocked = 1; + error = mtx_sleep(&sc->blocked, &sc->mutex, PCATCH, "cyablk", 0); + if (error) + break; + } + + /* Return any buffered data */ + while (error == 0 && uio->uio_resid && + (n = fifo_ready(sc, &sc->rfifo)) > 0) { + if (n > uio->uio_resid) + n = uio->uio_resid; + ptr = fifo_read(sc, &sc->rfifo, 0); + cyapa_unlock(sc); + error = uiomove(ptr, n, uio); + cyapa_lock(sc); + if (error) + break; + fifo_read(sc, &sc->rfifo, n); + didread = 1; + } + cyapa_unlock(sc); + + if (error == 0 && didread == 0) { + error = EWOULDBLOCK; + } + return (didread ? 0 : error); +} + +static int +cyapawrite(struct cdev *dev, struct uio *uio, int ioflag) +{ + struct cyapa_softc *sc; + int error; + int cmd_completed; + size_t n; + uint8_t c0; + char* ptr; + + sc = dev->si_drv1; +again: + /* + * Copy data from userland. This will also cross-over the end + * of the fifo and keep filling. + */ + cyapa_lock(sc); + while ((n = fifo_space(sc, &sc->wfifo)) > 0 && uio->uio_resid) { + if (n > uio->uio_resid) + n = uio->uio_resid; + ptr = fifo_write(sc, &sc->wfifo, 0); + cyapa_unlock(sc); + error = uiomove(ptr, n, uio); + cyapa_lock(sc); + if (error) + break; + fifo_write(sc, &sc->wfifo, n); + } + + /* Handle commands */ + cmd_completed = (fifo_ready(sc, &sc->wfifo) != 0); + while (fifo_ready(sc, &sc->wfifo) && cmd_completed && error == 0) { + if (sc->ps2_cmd == 0) + sc->ps2_cmd = fifo_read_char(sc, &sc->wfifo); + switch(sc->ps2_cmd) { + case 0xE6: + /* SET SCALING 1:1 */ + sc->scaling_mode = 0; + fifo_write_char(sc, &sc->rfifo, 0xFA); + break; + case 0xE7: + /* SET SCALING 2:1 */ + sc->scaling_mode = 1; + fifo_write_char(sc, &sc->rfifo, 0xFA); + break; + case 0xE8: + /* SET RESOLUTION +1 byte */ + if (sc->ps2_acked == 0) { + sc->ps2_acked = 1; + fifo_write_char(sc, &sc->rfifo, 0xFA); + } + if (fifo_ready(sc, &sc->wfifo) == 0) { + cmd_completed = 0; + break; + } + sc->mode.resolution = fifo_read_char(sc, &sc->wfifo); + fifo_write_char(sc, &sc->rfifo, 0xFA); + break; + case 0xE9: + /* + * STATUS REQUEST + * + * byte1: + * bit 7 0 + * bit 6 Mode (1=remote mode, 0=stream mode) + * bit 5 Enable (data reporting enabled) + * bit 4 Scaling (0=1:1 1=2:1) + * bit 3 0 + * bit 2 LEFT BUTTON (1 if pressed) + * bit 1 MIDDLE BUTTON (1 if pressed) + * bit 0 RIGHT BUTTON (1 if pressed) + * + * byte2: resolution counts/mm + * byte3: sample rate + */ + c0 = 0; + if (sc->remote_mode) + c0 |= 0x40; + if (sc->reporting_mode) + c0 |= 0x20; + if (sc->scaling_mode) + c0 |= 0x10; + if (sc->track_but & CYAPA_FNGR_LEFT) + c0 |= 0x04; + if (sc->track_but & CYAPA_FNGR_MIDDLE) + c0 |= 0x02; + if (sc->track_but & CYAPA_FNGR_RIGHT) + c0 |= 0x01; + fifo_write_char(sc, &sc->rfifo, 0xFA); + fifo_write_char(sc, &sc->rfifo, c0); + fifo_write_char(sc, &sc->rfifo, 0x00); + fifo_write_char(sc, &sc->rfifo, 100); + break; + case 0xEA: + /* Set stream mode and reset movement counters */ + sc->remote_mode = 0; + fifo_write_char(sc, &sc->rfifo, 0xFA); + sc->delta_x = 0; + sc->delta_y = 0; + sc->delta_z = 0; + break; + case 0xEB: + /* + * Read Data (if in remote mode). If not in remote + * mode force an event. + */ + fifo_write_char(sc, &sc->rfifo, 0xFA); + sc->data_signal = 1; + break; + case 0xEC: + /* Reset Wrap Mode (ignored) */ + fifo_write_char(sc, &sc->rfifo, 0xFA); + break; + case 0xEE: + /* Set Wrap Mode (ignored) */ + fifo_write_char(sc, &sc->rfifo, 0xFA); + break; + case 0xF0: + /* Set Remote Mode */ + sc->remote_mode = 1; + fifo_write_char(sc, &sc->rfifo, 0xFA); + sc->delta_x = 0; + sc->delta_y = 0; + sc->delta_z = 0; + break; + case 0xF2: + /* + * Get Device ID + * + * If we send 0x00 - normal PS/2 mouse, no Z-axis + * + * If we send 0x03 - Intellimouse, data packet has + * an additional Z movement byte (8 bits signed). + * (also reset movement counters) + * + * If we send 0x04 - Now includes z-axis and the + * 4th and 5th mouse buttons. + */ + fifo_write_char(sc, &sc->rfifo, 0xFA); + switch(sc->zenabled) { + case 1: + fifo_write_char(sc, &sc->rfifo, 0x03); + break; + case 2: + fifo_write_char(sc, &sc->rfifo, 0x04); + break; + default: + fifo_write_char(sc, &sc->rfifo, 0x00); + break; + } + sc->delta_x = 0; + sc->delta_y = 0; + sc->delta_z = 0; + break; + case 0xF3: + /* + * Set Sample Rate + * + * byte1: the sample rate + */ + if (sc->ps2_acked == 0) { + sc->ps2_acked = 1; + fifo_write_char(sc, &sc->rfifo, 0xFA); + } + if (fifo_ready(sc, &sc->wfifo) == 0) { + cmd_completed = 0; + break; + } + sc->mode.rate = fifo_read_char(sc, &sc->wfifo); + fifo_write_char(sc, &sc->rfifo, 0xFA); + + /* + * zenabling sequence: 200,100,80 (device id 0x03) + * 200,200,80 (device id 0x04) + * + * We support id 0x03 (no 4th or 5th button). + * We support id 0x04 (w/ 4th and 5th button). + */ + if (sc->zenabled == 0 && sc->mode.rate == 200) + sc->zenabled = -1; + else if (sc->zenabled == -1 && sc->mode.rate == 100) + sc->zenabled = -2; + else if (sc->zenabled == -1 && sc->mode.rate == 200) + sc->zenabled = -3; + else if (sc->zenabled == -2 && sc->mode.rate == 80) + sc->zenabled = 1; /* z-axis mode */ + else if (sc->zenabled == -3 && sc->mode.rate == 80) + sc->zenabled = 2; /* z-axis+but4/5 */ + if (sc->mode.level) + sc->zenabled = 1; + break; + case 0xF4: + /* Enable data reporting. Only effects stream mode. */ + fifo_write_char(sc, &sc->rfifo, 0xFA); + sc->reporting_mode = 1; + break; + case 0xF5: + /* + * Disable data reporting. Only effects stream mode + * and is ignored right now. + */ + fifo_write_char(sc, &sc->rfifo, 0xFA); + sc->reporting_mode = 1; + break; + case 0xF6: + /* + * SET DEFAULTS + * + * (reset sampling rate, resolution, scaling and + * enter stream mode) + */ + fifo_write_char(sc, &sc->rfifo, 0xFA); + sc->mode.rate = 100; + sc->mode.resolution = 4; + sc->scaling_mode = 0; + sc->reporting_mode = 1; + sc->remote_mode = 0; + sc->delta_x = 0; + sc->delta_y = 0; + sc->delta_z = 0; + /* signal */ + break; + case 0xFE: + /* + * RESEND + * + * Force a resend by guaranteeing that reported_but + * differs from track_but. + */ + fifo_write_char(sc, &sc->rfifo, 0xFA); + sc->data_signal = 1; + break; + case 0xFF: + /* + * RESET + */ + fifo_reset(sc, &sc->rfifo); /* should we do this? */ + fifo_reset(sc, &sc->wfifo); /* should we do this? */ + fifo_write_char(sc, &sc->rfifo, 0xFA); + sc->delta_x = 0; + sc->delta_y = 0; + sc->delta_z = 0; + sc->zenabled = 0; + sc->mode.level = 0; + break; + default: + printf("unknown command %02x\n", sc->ps2_cmd); + break; + } + if (cmd_completed) { + sc->ps2_cmd = 0; + sc->ps2_acked = 0; + } + cyapa_notify(sc); + } + cyapa_unlock(sc); + if (error == 0 && (cmd_completed || uio->uio_resid)) + goto again; + return (error); +} + +static void cyapafiltdetach(struct knote *); +static int cyapafilt(struct knote *, long); + +static struct filterops cyapa_filtops = { + .f_isfd = 1, + .f_detach = cyapafiltdetach, + .f_event = cyapafilt +}; + +static int +cyapakqfilter(struct cdev *dev, struct knote *kn) +{ + struct cyapa_softc *sc; + struct knlist *knlist; + + sc = dev->si_drv1; + + switch(kn->kn_filter) { + case EVFILT_READ: + kn->kn_fop = &cyapa_filtops; + kn->kn_hook = (void *)sc; + break; + default: + return (EOPNOTSUPP); + } + knlist = &sc->selinfo.si_note; + knlist_add(knlist, kn, 0); + + return (0); +} + +static int +cyapapoll(struct cdev *dev, int events, struct thread *td) +{ + struct cyapa_softc *sc; + int revents; + + sc = dev->si_drv1; + revents = 0; + + cyapa_lock(sc); + if (events & (POLLIN | POLLRDNORM)) { + if (sc->data_signal || !fifo_empty(sc, &sc->rfifo)) + revents = events & (POLLIN | POLLRDNORM); + else { + sc->isselect = 1; + selrecord(td, &sc->selinfo); + } + } + cyapa_unlock(sc); + + return (revents); +} + +static void +cyapafiltdetach(struct knote *kn) +{ + struct cyapa_softc *sc; + struct knlist *knlist; + + sc = (struct cyapa_softc *)kn->kn_hook; + + knlist = &sc->selinfo.si_note; + knlist_remove(knlist, kn, 0); +} + +static int +cyapafilt(struct knote *kn, long hint) +{ + struct cyapa_softc *sc; + int ready; + + sc = (struct cyapa_softc *)kn->kn_hook; + + cyapa_lock(sc); + ready = fifo_ready(sc, &sc->rfifo) || sc->data_signal; + cyapa_unlock(sc); + + return (ready); +} + +static int +cyapaioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td) +{ + struct cyapa_softc *sc; + int error; + + sc = dev->si_drv1; + error = 0; + + cyapa_lock(sc); + switch (cmd) { + case MOUSE_GETHWINFO: + *(mousehw_t *)data = sc->hw; + if (sc->mode.level == 0) + ((mousehw_t *)data)->model = MOUSE_MODEL_GENERIC; + break; + + case MOUSE_GETMODE: + *(mousemode_t *)data = sc->mode; + ((mousemode_t *)data)->resolution = + MOUSE_RES_LOW - sc->mode.resolution; + switch (sc->mode.level) { + case 0: + ((mousemode_t *)data)->protocol = MOUSE_PROTO_PS2; + ((mousemode_t *)data)->packetsize = + MOUSE_PS2_PACKETSIZE; + break; + case 2: + ((mousemode_t *)data)->protocol = MOUSE_PROTO_PS2; + ((mousemode_t *)data)->packetsize = + MOUSE_PS2_PACKETSIZE + 1; + break; + } + break; + + case MOUSE_GETLEVEL: + *(int *)data = sc->mode.level; + break; + + case MOUSE_SETLEVEL: + if ((*(int *)data < 0) && + (*(int *)data > 2)) { + error = EINVAL; + break; + } + sc->mode.level = *(int *)data ? 2 : 0; + sc->zenabled = sc->mode.level ? 1 : 0; + break; + + default: + error = ENOTTY; + break; + } + cyapa_unlock(sc); + + return (error); +} + +/* + * MAJOR SUPPORT FUNCTIONS + */ +static void +cyapa_poll_thread(void *arg) +{ + struct cyapa_softc *sc; + struct cyapa_regs regs; + device_t bus; /* smbus */ + int error; + int freq; + int isidle; + int pstate; + int npstate; + int last_reset; + + sc = arg; + freq = cyapa_norm_freq; + isidle = 0; + pstate = CMD_POWER_MODE_IDLE; + last_reset = ticks; + + bus = device_get_parent(sc->dev); + + cyapa_lock(sc); + sc->poll_thread_running = 1; + + while (!sc->detaching) { + cyapa_unlock(sc); + error = smbus_request_bus(bus, sc->dev, SMB_WAIT); + if (error == 0) { + error = smbus_trans(bus, sc->addr, CMD_DEV_STATUS, + SMB_TRANS_NOCNT | SMB_TRANS_7BIT, + NULL, 0, + (void *)®s, sizeof(regs), NULL); + if (error == 0) { + isidle = cyapa_raw_input(sc, ®s, freq); + } + + /* + * For some reason the device can crap-out. If it + * drops back into bootstrap mode try to reinitialize + * it. + */ + if (cyapa_reset || + ((regs.stat & CYAPA_STAT_RUNNING) == 0 && + (unsigned)(ticks - last_reset) > TIME_TO_RESET)) { + cyapa_reset = 0; + last_reset = ticks; + init_device(sc->dev, NULL, sc->addr, 2); + } + smbus_release_bus(bus, sc->dev); + } + pause("cyapw", hz / freq); + ++sc->poll_ticks; + + if (sc->count == 0) { + freq = cyapa_idle_freq; + npstate = CMD_POWER_MODE_IDLE; + } else if (isidle) { + freq = cyapa_slow_freq; + npstate = CMD_POWER_MODE_IDLE; + } else { + freq = cyapa_norm_freq; + npstate = CMD_POWER_MODE_FULL; + } + if (pstate != npstate) { + pstate = npstate; + cyapa_set_power_mode(sc, pstate); + if (cyapa_debug) { + switch(pstate) { + case CMD_POWER_MODE_OFF: + printf("cyapa: power off\n"); + break; + case CMD_POWER_MODE_IDLE: + printf("cyapa: power idle\n"); + break; + case CMD_POWER_MODE_FULL: + printf("cyapa: power full\n"); + break; + } + } + } + + cyapa_lock(sc); + } + sc->poll_thread_running = 0; + cyapa_unlock(sc); + kthread_exit(); +} + +static int +cyapa_raw_input(struct cyapa_softc *sc, struct cyapa_regs *regs, int freq) +{ + int nfingers; + int afingers; /* actual fingers after culling */ + int i; + int j; + int k; + int isidle; + int thumbarea_begin; + int seen_thumb; + int x; + int y; + int z; + int newfinger; + int lessfingers; + int click_x; + int click_y; + uint16_t but; /* high bits used for simulated but4/but5 */ + + thumbarea_begin = sc->cap_resy - + ((sc->cap_resy * cyapa_thumbarea_percent) / 100); + click_x = click_y = 0; + + /* + * If the device is not running the rest of the status + * means something else, set fingers to 0. + */ + if ((regs->stat & CYAPA_STAT_RUNNING) == 0) { + regs->fngr = 0; + } + + /* Process fingers/movement */ + nfingers = CYAPA_FNGR_NUMFINGERS(regs->fngr); + afingers = nfingers; + + if (cyapa_debug) { + printf("stat %02x buttons %c%c%c nfngrs=%d ", + regs->stat, + ((regs->fngr & CYAPA_FNGR_LEFT) ? 'L' : '-'), + ((regs->fngr & CYAPA_FNGR_MIDDLE) ? 'M' : '-'), + ((regs->fngr & CYAPA_FNGR_RIGHT) ? 'R' : '-'), + nfingers); + } + + seen_thumb = 0; + for (i = 0; i < afingers; ) { + if (cyapa_debug) { + printf(" [x=%04d y=%04d p=%d i=%d]", + CYAPA_TOUCH_X(regs, i), + CYAPA_TOUCH_Y(regs, i), + CYAPA_TOUCH_P(regs, i), + regs->touch[i].id); + } + if ((CYAPA_TOUCH_Y(regs, i) > thumbarea_begin && seen_thumb) || + CYAPA_TOUCH_P(regs, i) < cyapa_minpressure) { + --afingers; + if (i < afingers) { + regs->touch[i] = regs->touch[i+1]; + continue; + } + } else { + if (CYAPA_TOUCH_Y(regs, i) > thumbarea_begin) + seen_thumb = 1; + } + ++i; + } + nfingers = afingers; + + /* Tracking for local solutions */ + cyapa_lock(sc); + + /* + * Track timing for finger-downs. Used to detect false-3-finger + * button-down. + */ + switch(afingers) { + case 0: + break; + case 1: + if (sc->track_nfingers == 0) + sc->finger1_ticks = sc->poll_ticks; + break; + case 2: + if (sc->track_nfingers <= 0) + sc->finger1_ticks = sc->poll_ticks; + if (sc->track_nfingers <= 1) + sc->finger2_ticks = sc->poll_ticks; + break; + case 3: + default: + if (sc->track_nfingers <= 0) + sc->finger1_ticks = sc->poll_ticks; + if (sc->track_nfingers <= 1) + sc->finger2_ticks = sc->poll_ticks; + if (sc->track_nfingers <= 2) + sc->finger3_ticks = sc->poll_ticks; + break; + } + newfinger = sc->track_nfingers < afingers; + lessfingers = sc->track_nfingers > afingers; + sc->track_nfingers = afingers; + + /* + * Lookup and track finger indexes in the touch[] array. + */ + if (afingers == 0) { + click_x = sc->track_x; + click_y = sc->track_y; + sc->track_x = -1; + sc->track_y = -1; + sc->track_z = -1; + sc->fuzz_x = 0; + sc->fuzz_y = 0; + sc->fuzz_z = 0; + sc->touch_x = -1; + sc->touch_y = -1; + sc->touch_z = -1; + sc->track_id = -1; + sc->track_but = 0; + i = 0; + j = 0; + k = 0; + } else { + /* + * The id assigned on touch can move around in the array, + * find it. If that finger is lifted up, assign some other + * finger for mouse tracking and reset track_x and track_y + * to avoid a mouse jump. + * + * If >= 2 fingers are down be sure not to assign i and + * j to the same index. + */ + for (i = 0; i < nfingers; ++i) { + if (sc->track_id == regs->touch[i].id) + break; + } + if (i == nfingers) { + i = 0; + sc->track_x = -1; + sc->track_y = -1; + sc->track_z = -1; + while (CYAPA_TOUCH_Y(regs, i) >= thumbarea_begin && + i < nfingers) ++i; + if (i == nfingers) { + i = 0; + } + sc->track_id = regs->touch[i].id; + } + else if ((sc->track_but || + CYAPA_TOUCH_Y(regs, i) >= thumbarea_begin) && + newfinger && afingers == 2) { + j = regs->touch[0].id == sc->track_id ? 1 : 0; + if (CYAPA_TOUCH_Y(regs, j) < thumbarea_begin) { + i = j; + sc->track_x = -1; + sc->track_y = -1; + sc->track_z = -1; + sc->track_id = regs->touch[i].id; + } + } + } + + /* Two finger scrolling - reset after timeout */ + if (sc->track_z != -1 && afingers != 2 && + (sc->poll_ticks - sc->track_z_ticks) > cyapa_scroll_stick_ticks) { + sc->track_z = -1; + sc->track_z_ticks = 0; + } + + /* Initiate two finger scrolling */ + if (!(regs->fngr & CYAPA_FNGR_LEFT) && + ((afingers && sc->track_z != -1) || + (afingers == 2 && CYAPA_TOUCH_Y(regs, 0) < thumbarea_begin && + CYAPA_TOUCH_Y(regs, 1) < thumbarea_begin))) { + if (afingers == 2 && (sc->poll_ticks - sc->finger2_ticks) + > cyapa_scroll_wait_ticks) { + z = (CYAPA_TOUCH_Y(regs, 0) + + CYAPA_TOUCH_Y(regs, 1)) >> 1; + sc->delta_z += z / ZSCALE - sc->track_z; + if (sc->track_z == -1) { + sc->delta_z = 0; + } + if (sc->touch_z == -1) + sc->touch_z = z; /* not used atm */ + sc->track_z = z / ZSCALE; + sc->track_z_ticks = sc->poll_ticks; + } + } else if (afingers) { + /* Normal pad position reporting */ + x = CYAPA_TOUCH_X(regs, i); + y = CYAPA_TOUCH_Y(regs, i); + click_x = x; + click_y = y; + if (sc->track_x != -1 && sc->track_y < thumbarea_begin && + (afingers > 1 || (sc->poll_ticks - sc->finger1_ticks) + >= cyapa_move_min_ticks || freq < cyapa_norm_freq)) { + sc->delta_x += x - sc->track_x; + sc->delta_y -= y - sc->track_y; + if (sc->delta_x > sc->cap_resx) + sc->delta_x = sc->cap_resx; + if (sc->delta_x < -sc->cap_resx) + sc->delta_x = -sc->cap_resx; + if (sc->delta_y > sc->cap_resx) + sc->delta_y = sc->cap_resy; + if (sc->delta_y < -sc->cap_resy) + sc->delta_y = -sc->cap_resy; + + if (abs(sc->delta_y) > sc->cap_resy / 2 || + abs(sc->delta_x) > sc->cap_resx / 2) { + if (cyapa_debug) + printf("Detected jump by %i %i\n", + sc->delta_x, sc->delta_y); + sc->delta_x = sc->delta_y = 0; + } + } + if (sc->touch_x == -1) { + sc->touch_x = x; + sc->touch_y = y; + } + sc->track_x = x; + sc->track_y = y; + } + + /* Select finger (L = 2/3x, M = 1/3u, R = 1/3d) */ + int is_tapclick = (cyapa_enable_tapclick && lessfingers && + afingers == 0 && sc->poll_ticks - sc->finger1_ticks + >= cyapa_tapclick_min_ticks && + sc->poll_ticks - sc->finger1_ticks < cyapa_tapclick_max_ticks); + + if (regs->fngr & CYAPA_FNGR_LEFT || is_tapclick) { + if (sc->track_but) { + but = sc->track_but; + } else if (afingers == 1) { + if (click_x < sc->cap_resx * 2 / 3) + but = CYAPA_FNGR_LEFT; + else if (click_y < sc->cap_resy / 2) + but = CYAPA_FNGR_MIDDLE; + else + but = CYAPA_FNGR_RIGHT; + } else if (is_tapclick) { + if (click_x < sc->cap_resx * 2 / 3 || + cyapa_enable_tapclick < 2) + but = CYAPA_FNGR_LEFT; + else if (click_y < sc->cap_resy / 2 && + cyapa_enable_tapclick > 2) + but = CYAPA_FNGR_MIDDLE; + else + but = CYAPA_FNGR_RIGHT; + } else { + but = CYAPA_FNGR_LEFT; + } + } else { + but = 0; + } + + /* + * Detect state change from last reported state and + * determine if we have gone idle. + */ + sc->track_but = but; + if (sc->delta_x || sc->delta_y || sc->delta_z || + sc->track_but != sc->reported_but) { + sc->active_tick = ticks; + if (sc->remote_mode == 0 && sc->reporting_mode) + sc->data_signal = 1; + isidle = 0; + } else if ((unsigned)(ticks - sc->active_tick) >= TIME_TO_IDLE) { + sc->active_tick = ticks - TIME_TO_IDLE; /* prevent overflow */ + isidle = 1; + } else { + isidle = 0; + } + cyapa_notify(sc); + cyapa_unlock(sc); + + if (cyapa_debug) + printf("%i >> %i << %i\n", isidle, sc->track_id, sc->delta_y); + return (isidle); +} + +static void +cyapa_set_power_mode(struct cyapa_softc *sc, int mode) +{ + uint8_t data; + device_t bus; + int error; + + bus = device_get_parent(sc->dev); + error = smbus_request_bus(bus, sc->dev, SMB_WAIT); + if (error == 0) { + error = smbus_trans(bus, sc->addr, CMD_POWER_MODE, + SMB_TRANS_NOCNT | SMB_TRANS_7BIT, + NULL, 0, (void *)&data, 1, NULL); + data = (data & ~0xFC) | mode; + if (error == 0) { + error = smbus_trans(bus, sc->addr, CMD_POWER_MODE, + SMB_TRANS_NOCNT | SMB_TRANS_7BIT, + (void *)&data, 1, NULL, 0, NULL); + } + smbus_release_bus(bus, sc->dev); + } +} + +/* + * FIFO FUNCTIONS + */ + +/* + * Returns non-zero if the fifo is empty + */ +static int +fifo_empty(struct cyapa_softc *sc, struct cyapa_fifo *fifo) +{ + + CYAPA_LOCK_ASSERT(sc); + + return (fifo->rindex == fifo->windex); +} + +/* + * Returns the number of characters available for reading from + * the fifo without wrapping the fifo buffer. + */ +static size_t +fifo_ready(struct cyapa_softc *sc, struct cyapa_fifo *fifo) +{ + size_t n; + + CYAPA_LOCK_ASSERT(sc); + + n = CYAPA_BUFSIZE - (fifo->rindex & CYAPA_BUFMASK); + if (n > (size_t)(fifo->windex - fifo->rindex)) + n = (size_t)(fifo->windex - fifo->rindex); + return (n); +} + +/* + * Returns a read pointer into the fifo and then bumps + * rindex. The FIFO must have at least 'n' characters in + * it. The value (n) can cause the index to wrap but users + * of the buffer should never supply a value for (n) that wraps + * the buffer. + */ +static char * +fifo_read(struct cyapa_softc *sc, struct cyapa_fifo *fifo, size_t n) +{ + char *ptr; + + CYAPA_LOCK_ASSERT(sc); + if (n > (CYAPA_BUFSIZE - (fifo->rindex & CYAPA_BUFMASK))) { + printf("fifo_read: overflow\n"); + return (fifo->buf); + } + ptr = fifo->buf + (fifo->rindex & CYAPA_BUFMASK); + fifo->rindex += n; + + return (ptr); +} + +static uint8_t +fifo_read_char(struct cyapa_softc *sc, struct cyapa_fifo *fifo) +{ + uint8_t c; + + CYAPA_LOCK_ASSERT(sc); + + if (fifo->rindex == fifo->windex) { + printf("fifo_read_char: overflow\n"); + c = 0; + } else { + c = fifo->buf[fifo->rindex & CYAPA_BUFMASK]; + ++fifo->rindex; + } + return (c); +} + + +/* + * Write a character to the FIFO. The character will be discarded + * if the FIFO is full. + */ +static void +fifo_write_char(struct cyapa_softc *sc, struct cyapa_fifo *fifo, uint8_t c) +{ + + CYAPA_LOCK_ASSERT(sc); + + if (fifo->windex - fifo->rindex < CYAPA_BUFSIZE) { + fifo->buf[fifo->windex & CYAPA_BUFMASK] = c; + ++fifo->windex; + } +} + +/* + * Return the amount of space available for writing without wrapping + * the fifo. + */ +static size_t +fifo_space(struct cyapa_softc *sc, struct cyapa_fifo *fifo) +{ + size_t n; + + CYAPA_LOCK_ASSERT(sc); + + n = CYAPA_BUFSIZE - (fifo->windex & CYAPA_BUFMASK); + if (n > (size_t)(CYAPA_BUFSIZE - (fifo->windex - fifo->rindex))) + n = (size_t)(CYAPA_BUFSIZE - (fifo->windex - fifo->rindex)); + return (n); +} + +static char * +fifo_write(struct cyapa_softc *sc, struct cyapa_fifo *fifo, size_t n) +{ + char *ptr; + + CYAPA_LOCK_ASSERT(sc); + + ptr = fifo->buf + (fifo->windex & CYAPA_BUFMASK); + fifo->windex += n; + + return (ptr); +} + +static void +fifo_reset(struct cyapa_softc *sc, struct cyapa_fifo *fifo) +{ + + CYAPA_LOCK_ASSERT(sc); + + fifo->rindex = 0; + fifo->windex = 0; +} + +/* + * Fuzz handling + */ +static int +cyapa_fuzz(int delta, int *fuzzp) +{ + int fuzz; + + fuzz = *fuzzp; + if (fuzz >= 0 && delta < 0) { + ++delta; + --fuzz; + } else if (fuzz <= 0 && delta > 0) { + --delta; + ++fuzz; + } + *fuzzp = fuzz; + + return (delta); +} + +DRIVER_MODULE(cyapa, smbus, cyapa_driver, cyapa_devclass, NULL, NULL); +MODULE_DEPEND(cyapa, smbus, SMBUS_MINVER, SMBUS_PREFVER, SMBUS_MAXVER); +MODULE_VERSION(cyapa, 1); Property changes on: head/sys/dev/cyapa/cyapa.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sys/dev/cyapa/cyapa.h =================================================================== --- head/sys/dev/cyapa/cyapa.h (nonexistent) +++ head/sys/dev/cyapa/cyapa.h (revision 285876) @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2014 The DragonFly Project. All rights reserved. + * + * This code is derived from software contributed to The DragonFly Project + * by Matthew Dillon and was subsequently ported + * to FreeBSD by Michael Gmelin + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of The DragonFly Project nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific, prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _SYS_DEV_SMBUS_CYAPA_CYAPA_H_ +#define _SYS_DEV_SMBUS_CYAPA_CYAPA_H_ + +#define CYAPA_MAX_MT 5 + +/* + * Boot-time registers. This is the device map + * if (stat & CYAPA_STAT_RUNNING) is 0. + */ +struct cyapa_boot_regs { + uint8_t stat; /* CYAPA_STAT_xxx */ + uint8_t boot; /* CYAPA_BOOT_xxx */ + uint8_t error; +} __packed; + +#define CYAPA_BOOT_BUSY 0x80 +#define CYAPA_BOOT_RUNNING 0x10 +#define CYAPA_BOOT_DATA_VALID 0x08 +#define CYAPA_BOOT_CSUM_VALID 0x01 + +#define CYAPA_ERROR_INVALID 0x80 +#define CYAPA_ERROR_INVALID_KEY 0x40 +#define CYAPA_ERROR_BOOTLOADER 0x20 +#define CYAPA_ERROR_CMD_CSUM 0x10 +#define CYAPA_ERROR_FLASH_PROT 0x08 +#define CYAPA_ERROR_FLASH_CSUM 0x04 + +struct cyapa_regs { + uint8_t stat; + uint8_t fngr; + + struct { + uint8_t xy_high; /* 7:4 high 4 bits of x */ + uint8_t x_low; /* 3:0 high 4 bits of y */ + uint8_t y_low; + uint8_t pressure; + uint8_t id; /* 1-15 incremented each touch */ + } touch[CYAPA_MAX_MT]; +} __packed; + +struct cyapa_cap { + uint8_t prod_ida[5]; /* 0x00 - 0x04 */ + uint8_t prod_idb[6]; /* 0x05 - 0x0A */ + uint8_t prod_idc[2]; /* 0x0B - 0x0C */ + uint8_t reserved[6]; /* 0x0D - 0x12 */ + uint8_t buttons; /* 0x13 */ + uint8_t gen; /* 0x14, low 4 bits */ + uint8_t max_abs_xy_high;/* 0x15 7:4 high x bits, 3:0 high y bits */ + uint8_t max_abs_x_low; /* 0x16 */ + uint8_t max_abs_y_low; /* 0x17 */ + uint8_t phy_siz_xy_high;/* 0x18 7:4 high x bits, 3:0 high y bits */ + uint8_t phy_siz_x_low; /* 0x19 */ + uint8_t phy_siz_y_low; /* 0x1A */ +} __packed; + +#define CYAPA_STAT_RUNNING 0x80 +#define CYAPA_STAT_PWR_MASK 0x0C +#define CYAPA_PWR_OFF 0x00 +#define CYAPA_PWR_IDLE 0x08 +#define CYAPA_PWR_ACTIVE 0x0C + +#define CYAPA_STAT_DEV_MASK 0x03 +#define CYAPA_DEV_NORMAL 0x03 +#define CYAPA_DEV_BUSY 0x01 + +#define CYAPA_FNGR_DATA_VALID 0x08 +#define CYAPA_FNGR_MIDDLE 0x04 +#define CYAPA_FNGR_RIGHT 0x02 +#define CYAPA_FNGR_LEFT 0x01 +#define CYAPA_FNGR_NUMFINGERS(c) (((c) >> 4) & 0x0F) + +#define CYAPA_TOUCH_X(regs, i) ((((regs)->touch[i].xy_high << 4) & 0x0F00) | \ + (regs)->touch[i].x_low) +#define CYAPA_TOUCH_Y(regs, i) ((((regs)->touch[i].xy_high << 8) & 0x0F00) | \ + (regs)->touch[i].y_low) +#define CYAPA_TOUCH_P(regs, i) ((regs)->touch[i].pressure) + +#define CMD_BOOT_STATUS 0x00 /* only if in boot state */ +#define CMD_DEV_STATUS 0x00 /* only if in operational state */ +#define CMD_SOFT_RESET 0x28 +#define CMD_POWER_MODE 0x29 +#define CMD_POWER_MODE_OFF 0x00 +#define CMD_POWER_MODE_IDLE 0x14 +#define CMD_POWER_MODE_FULL 0xFC +#define CMD_QUERY_CAPABILITIES 0x2A + +#endif Property changes on: head/sys/dev/cyapa/cyapa.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sys/modules/i2c/Makefile =================================================================== --- head/sys/modules/i2c/Makefile (revision 285875) +++ head/sys/modules/i2c/Makefile (revision 285876) @@ -1,6 +1,6 @@ # $FreeBSD$ SUBDIR = -SUBDIR += controllers if_ic smbus iicbus iicbb iicsmb iic smb +SUBDIR += controllers if_ic smbus iicbus iicbb iicsmb iic cyapa smb .include Index: head/sys/modules/i2c/cyapa/Makefile =================================================================== --- head/sys/modules/i2c/cyapa/Makefile (nonexistent) +++ head/sys/modules/i2c/cyapa/Makefile (revision 285876) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../../dev/cyapa +KMOD = cyapa +SRCS = cyapa.c device_if.h bus_if.h smbus_if.h vnode_if.h + +.include Property changes on: head/sys/modules/i2c/cyapa/Makefile ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property