From 7a2d28f0b0bf69cff96de520355233848b7b4033 Mon Sep 17 00:00:00 2001 From: Will Andrews Date: Mon, 14 Oct 2002 08:43:37 +0000 Subject: Add sjog 0.5, a userland daemon for Sony Vaio Jog Dial. PR: 41905 Submitted by: Bruce M Simpson --- sysutils/sjog/files/patch-src::pci_freebsd.c | 153 +++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 sysutils/sjog/files/patch-src::pci_freebsd.c (limited to 'sysutils/sjog/files/patch-src::pci_freebsd.c') diff --git a/sysutils/sjog/files/patch-src::pci_freebsd.c b/sysutils/sjog/files/patch-src::pci_freebsd.c new file mode 100644 index 000000000000..227c211b16e5 --- /dev/null +++ b/sysutils/sjog/files/patch-src::pci_freebsd.c @@ -0,0 +1,153 @@ +--- src/pci_freebsd.c.orig Sat Aug 17 20:38:56 2002 ++++ src/pci_freebsd.c Sat Aug 17 20:38:56 2002 +@@ -0,0 +1,150 @@ ++/* manipulate PCI devices from user space ++ ++ Tridge, July 2000 ++ ++ FreeBSD modifications for sjog by Jay Kuri jk@oneway.com 08/13/01 ++*/ ++/* ++ Copyright (C) Andrew Tridgell 2000 ++ Copyright (C) Takanori Watanabe 2000 ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 2 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program; if not, write to the Free Software ++ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ++*/ ++#include ++#include ++#include ++#include "sonypi.h" ++#define MAX_BUS 8 ++ ++#define PCI_GETCONF_MATCH_VENDDEV (PCI_GETCONF_MATCH_VENDOR|PCI_GETCONF_MATCH_DEVICE) ++#define MAXHANDLE 32 ++ ++static struct pci_io pio[MAXHANDLE]; ++static u_int32_t handlebmp=0; ++static int pci_fd=-1; ++static int pcifd_internal_init(); ++int pcifd_internal_init() ++{ ++ return pci_fd=open("/dev/pci",O_RDWR,0); ++} ++/* find a PCI device and return a handle to it */ ++int pci_find_device(u32 vendor, u32 device) ++{ ++ ++ struct pci_conf pc[4];/*I think only one is enough*/ ++ struct pci_conf_io pcfi; ++ struct pci_match_conf pmc={{0,0,0},"",0,0xffff,0xffff,0, ++ PCI_GETCONF_MATCH_VENDDEV}; ++ int handle; ++ if(pci_fd==-1){ ++ if(pcifd_internal_init()==-1) ++ return -1; ++ } ++ pmc.pc_vendor=vendor; ++ pmc.pc_device=device; ++ pcfi.pat_buf_len=sizeof(pmc); ++ pcfi.num_patterns=1; ++ pcfi.patterns=&pmc; ++ pcfi.match_buf_len=sizeof(pc); ++ pcfi.num_matches=0; ++ pcfi.matches=pc; ++ pcfi.offset=0; ++ pcfi.generation=0; ++ ioctl(pci_fd,PCIOCGETCONF,&pcfi); ++ if(pcfi.num_matches==0){ ++ goto error; ++ } ++ for(handle=0;handle<32;handle++){ ++ if(!(handlebmp&(1<