sync code with last improvements from OpenBSD

This commit is contained in:
purplerain 2023-08-28 05:57:34 +00:00
commit 88965415ff
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
26235 changed files with 29195616 additions and 0 deletions

View file

@ -0,0 +1,9 @@
noinst_LTLIBRARIES = libi2c.la
libi2c_la_SOURCES = xf86i2c.c
AM_CPPFLAGS = $(XORG_INCS)
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
sdk_HEADERS = xf86i2c.h i2c_def.h

View file

@ -0,0 +1,814 @@
# Makefile.in generated by automake 1.12.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2012 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__make_dryrun = \
{ \
am__dry=no; \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
| grep '^AM OK$$' >/dev/null || am__dry=yes;; \
*) \
for am__flg in $$MAKEFLAGS; do \
case $$am__flg in \
*=*|--*) ;; \
*n*) am__dry=yes; break;; \
esac; \
done;; \
esac; \
test $$am__dry = yes; \
}
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = hw/xfree86/i2c
DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(top_srcdir)/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \
$(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
$(top_builddir)/include/xorg-server.h \
$(top_builddir)/include/dix-config.h \
$(top_builddir)/include/xorg-config.h \
$(top_builddir)/include/xkb-config.h \
$(top_builddir)/include/xwin-config.h \
$(top_builddir)/include/version-config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libi2c_la_LIBADD =
am_libi2c_la_OBJECTS = xf86i2c.lo
libi2c_la_OBJECTS = $(am_libi2c_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libi2c_la_SOURCES)
DIST_SOURCES = $(libi2c_la_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(sdkdir)"
HEADERS = $(sdk_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
APPLE_APPLICATION_NAME = @APPLE_APPLICATION_NAME@
APP_MAN_DIR = @APP_MAN_DIR@
APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BASE_CFLAGS = @BASE_CFLAGS@
BASE_FONT_PATH = @BASE_FONT_PATH@
BUNDLE_ID_PREFIX = @BUNDLE_ID_PREFIX@
BUNDLE_VERSION = @BUNDLE_VERSION@
BUNDLE_VERSION_STRING = @BUNDLE_VERSION_STRING@
CC = @CC@
CCAS = @CCAS@
CCASDEPMODE = @CCASDEPMODE@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CHANGELOG_CMD = @CHANGELOG_CMD@
COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CWARNFLAGS = @CWARNFLAGS@
CYGPATH_W = @CYGPATH_W@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFAULT_XDG_DATA_HOME = @DEFAULT_XDG_DATA_HOME@
DEFAULT_XDG_DATA_HOME_LOGDIR = @DEFAULT_XDG_DATA_HOME_LOGDIR@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DGA_CFLAGS = @DGA_CFLAGS@
DGA_LIBS = @DGA_LIBS@
DIX_CFLAGS = @DIX_CFLAGS@
DIX_LIB = @DIX_LIB@
DLLTOOL = @DLLTOOL@
DLOPEN_LIBS = @DLOPEN_LIBS@
DOT = @DOT@
DOXYGEN = @DOXYGEN@
DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
DRI3PROTO_CFLAGS = @DRI3PROTO_CFLAGS@
DRI3PROTO_LIBS = @DRI3PROTO_LIBS@
DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
DSYMUTIL = @DSYMUTIL@
DTRACE = @DTRACE@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
FILE_MAN_DIR = @FILE_MAN_DIR@
FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
FONT100DPIDIR = @FONT100DPIDIR@
FONT75DPIDIR = @FONT75DPIDIR@
FONTMISCDIR = @FONTMISCDIR@
FONTOTFDIR = @FONTOTFDIR@
FONTROOTDIR = @FONTROOTDIR@
FONTTTFDIR = @FONTTTFDIR@
FONTTYPE1DIR = @FONTTYPE1DIR@
FOP = @FOP@
GBM_CFLAGS = @GBM_CFLAGS@
GBM_LIBS = @GBM_LIBS@
GLAMOR_CFLAGS = @GLAMOR_CFLAGS@
GLAMOR_LIBS = @GLAMOR_LIBS@
GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
GLX_DEFINES = @GLX_DEFINES@
GLX_SYS_LIBS = @GLX_SYS_LIBS@
GL_CFLAGS = @GL_CFLAGS@
GL_LIBS = @GL_LIBS@
GREP = @GREP@
HAL_CFLAGS = @HAL_CFLAGS@
HAL_LIBS = @HAL_LIBS@
HAVE_DOT = @HAVE_DOT@
INSTALL = @INSTALL@
INSTALL_CMD = @INSTALL_CMD@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
KDRIVE_INCS = @KDRIVE_INCS@
KDRIVE_LIBS = @KDRIVE_LIBS@
KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
KDRIVE_MAIN_LIB = @KDRIVE_MAIN_LIB@
KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
KHRONOS_OPENGL_REGISTRY_CFLAGS = @KHRONOS_OPENGL_REGISTRY_CFLAGS@
KHRONOS_OPENGL_REGISTRY_LIBS = @KHRONOS_OPENGL_REGISTRY_LIBS@
KHRONOS_SPEC_DIR = @KHRONOS_SPEC_DIR@
LD = @LD@
LDFLAGS = @LDFLAGS@
LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
LD_NO_UNDEFINED_FLAG = @LD_NO_UNDEFINED_FLAG@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
LIBDRM_LIBS = @LIBDRM_LIBS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBSHA1_CFLAGS = @LIBSHA1_CFLAGS@
LIBSHA1_LIBS = @LIBSHA1_LIBS@
LIBTOOL = @LIBTOOL@
LIBUNWIND_CFLAGS = @LIBUNWIND_CFLAGS@
LIBUNWIND_LIBS = @LIBUNWIND_LIBS@
LIBXCVT_CFLAGS = @LIBXCVT_CFLAGS@
LIBXCVT_LIBS = @LIBXCVT_LIBS@
LIB_MAN_DIR = @LIB_MAN_DIR@
LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAIN_LIB = @MAIN_LIB@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MAN_SUBSTS = @MAN_SUBSTS@
MISC_MAN_DIR = @MISC_MAN_DIR@
MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJC = @OBJC@
OBJCCLD = @OBJCCLD@
OBJCDEPMODE = @OBJCDEPMODE@
OBJCFLAGS = @OBJCFLAGS@
OBJCLINK = @OBJCLINK@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
OPENSSL_LIBS = @OPENSSL_LIBS@
OS_LIB = @OS_LIB@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
PCIACCESS_LIBS = @PCIACCESS_LIBS@
PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
PIXMAN_CFLAGS = @PIXMAN_CFLAGS@
PIXMAN_LIBS = @PIXMAN_LIBS@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PROJECTROOT = @PROJECTROOT@
PTHREAD_CC = @PTHREAD_CC@
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
PTHREAD_LIBS = @PTHREAD_LIBS@
PYTHON3 = @PYTHON3@
RANLIB = @RANLIB@
RAWCPP = @RAWCPP@
RAWCPPFLAGS = @RAWCPPFLAGS@
RELEASE_DATE = @RELEASE_DATE@
SDK_REQUIRED_MODULES = @SDK_REQUIRED_MODULES@
SED = @SED@
SELINUX_CFLAGS = @SELINUX_CFLAGS@
SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SHA1_CFLAGS = @SHA1_CFLAGS@
SHA1_LIBS = @SHA1_LIBS@
SHELL = @SHELL@
SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
STRICT_CFLAGS = @STRICT_CFLAGS@
STRIP = @STRIP@
STYLESHEET_SRCDIR = @STYLESHEET_SRCDIR@
SUID_WRAPPER_DIR = @SUID_WRAPPER_DIR@
SYSCONFDIR = @SYSCONFDIR@
SYSTEMD_DAEMON_CFLAGS = @SYSTEMD_DAEMON_CFLAGS@
SYSTEMD_DAEMON_LIBS = @SYSTEMD_DAEMON_LIBS@
TRADITIONALCPPFLAGS = @TRADITIONALCPPFLAGS@
UDEV_CFLAGS = @UDEV_CFLAGS@
UDEV_LIBS = @UDEV_LIBS@
UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
VERSION = @VERSION@
WINDOWSDRI_CFLAGS = @WINDOWSDRI_CFLAGS@
WINDOWSDRI_LIBS = @WINDOWSDRI_LIBS@
WINDRES = @WINDRES@
XCONFIGDIR = @XCONFIGDIR@
XCONFIGFILE = @XCONFIGFILE@
XDMCP_CFLAGS = @XDMCP_CFLAGS@
XDMCP_LIBS = @XDMCP_LIBS@
XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
XEPHYR_INCS = @XEPHYR_INCS@
XEPHYR_LIBS = @XEPHYR_LIBS@
XF86CONFIGDIR = @XF86CONFIGDIR@
XF86CONFIGFILE = @XF86CONFIGFILE@
XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
XKB_DFLT_LAYOUT = @XKB_DFLT_LAYOUT@
XKB_DFLT_MODEL = @XKB_DFLT_MODEL@
XKB_DFLT_OPTIONS = @XKB_DFLT_OPTIONS@
XKB_DFLT_RULES = @XKB_DFLT_RULES@
XKB_DFLT_VARIANT = @XKB_DFLT_VARIANT@
XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
XLIB_CFLAGS = @XLIB_CFLAGS@
XLIB_LIBS = @XLIB_LIBS@
XMLTO = @XMLTO@
XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
XNEST_LIBS = @XNEST_LIBS@
XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
XORG_CFLAGS = @XORG_CFLAGS@
XORG_DRIVER_LIBS = @XORG_DRIVER_LIBS@
XORG_INCS = @XORG_INCS@
XORG_LIBS = @XORG_LIBS@
XORG_MALLOC_DEBUG_ENV = @XORG_MALLOC_DEBUG_ENV@
XORG_MAN_PAGE = @XORG_MAN_PAGE@
XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
XORG_SGML_PATH = @XORG_SGML_PATH@
XORG_SYS_LIBS = @XORG_SYS_LIBS@
XPBPROXY_CFLAGS = @XPBPROXY_CFLAGS@
XPBPROXY_LIBS = @XPBPROXY_LIBS@
XQUARTZ_LIBS = @XQUARTZ_LIBS@
XQUARTZ_SPARKLE = @XQUARTZ_SPARKLE@
XQUARTZ_SPARKLE_FEED_URL = @XQUARTZ_SPARKLE_FEED_URL@
XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
XSERVER_LIBS = @XSERVER_LIBS@
XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
XSHMFENCE_CFLAGS = @XSHMFENCE_CFLAGS@
XSHMFENCE_LIBS = @XSHMFENCE_LIBS@
XSLTPROC = @XSLTPROC@
XSL_STYLESHEET = @XSL_STYLESHEET@
XVFB_LIBS = @XVFB_LIBS@
XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
XWINMODULES_LIBS = @XWINMODULES_LIBS@
XWIN_LIBS = @XWIN_LIBS@
XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
YACC = @YACC@
YFLAGS = @YFLAGS@
abi_ansic = @abi_ansic@
abi_extension = @abi_extension@
abi_videodrv = @abi_videodrv@
abi_xinput = @abi_xinput@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
ax_pthread_config = @ax_pthread_config@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
driverdir = @driverdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
extdir = @extdir@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
logdir = @logdir@
mandir = @mandir@
mkdir_p = @mkdir_p@
moduledir = @moduledir@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sdkdir = @sdkdir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
symbol_visibility = @symbol_visibility@
sysconfdir = @sysconfdir@
sysconfigdir = @sysconfigdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LTLIBRARIES = libi2c.la
libi2c_la_SOURCES = xf86i2c.c
AM_CPPFLAGS = $(XORG_INCS)
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
sdk_HEADERS = xf86i2c.h i2c_def.h
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/i2c/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign hw/xfree86/i2c/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@list='$(noinst_LTLIBRARIES)'; \
locs=`for p in $$list; do echo $$p; done | \
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
sort -u`; \
test -z "$$locs" || { \
echo rm -f $${locs}; \
rm -f $${locs}; \
}
libi2c.la: $(libi2c_la_OBJECTS) $(libi2c_la_DEPENDENCIES) $(EXTRA_libi2c_la_DEPENDENCIES)
$(AM_V_CCLD)$(LINK) $(libi2c_la_OBJECTS) $(libi2c_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86i2c.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
install-sdkHEADERS: $(sdk_HEADERS)
@$(NORMAL_INSTALL)
@list='$(sdk_HEADERS)'; test -n "$(sdkdir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(sdkdir)'"; \
$(MKDIR_P) "$(DESTDIR)$(sdkdir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(sdkdir)'"; \
$(INSTALL_HEADER) $$files "$(DESTDIR)$(sdkdir)" || exit $$?; \
done
uninstall-sdkHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(sdk_HEADERS)'; test -n "$(sdkdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(sdkdir)'; $(am__uninstall_files_from_dir)
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS) $(LISP)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
for dir in "$(DESTDIR)$(sdkdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-sdkHEADERS
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-sdkHEADERS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstLTLIBRARIES cscopelist ctags \
distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-sdkHEADERS install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-sdkHEADERS
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View file

@ -0,0 +1,6 @@
#ifndef __I2C_DEF_H__
#define __I2C_DEF_H__
#include "xf86i2c.h"
#endif

View file

@ -0,0 +1,12 @@
srcs_xorg_i2c = [
'xf86i2c.c'
]
xorg_i2c = static_library('xorg_i2c',
srcs_xorg_i2c,
include_directories: [inc, xorg_inc],
dependencies: common_dep,
c_args: xorg_c_args,
)
install_data(['xf86i2c.h', 'i2c_def.h'], install_dir: xorgsdkdir)

View file

@ -0,0 +1,880 @@
/*
* Copyright (C) 1998 Itai Nahshon, Michael Schimek
*
* The original code was derived from and inspired by
* the I2C driver from the Linux kernel.
* (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de>
*/
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
#include <sys/time.h>
#include <string.h>
#include "misc.h"
#include "xf86.h"
#include "xf86_OSproc.h"
#include <X11/X.h>
#include <X11/Xos.h>
#include <X11/Xproto.h>
#include "scrnintstr.h"
#include "regionstr.h"
#include "windowstr.h"
#include "pixmapstr.h"
#include "validate.h"
#include "resource.h"
#include "gcstruct.h"
#include "dixstruct.h"
#include "xf86i2c.h"
#define I2C_TIMEOUT(x) /*(x)*/ /* Report timeouts */
#define I2C_TRACE(x) /*(x)*/ /* Report progress */
/* This is the default I2CUDelay function if not supplied by the driver.
* High level I2C interfaces implementing the bus protocol in hardware
* should supply this function too.
*
* Delay execution at least usec microseconds.
* All values 0 to 1e6 inclusive must be expected.
*/
static void
I2CUDelay(I2CBusPtr b, int usec)
{
struct timeval begin, cur;
long d_secs, d_usecs;
long diff;
if (usec > 0) {
X_GETTIMEOFDAY(&begin);
do {
/* It would be nice to use {xf86}usleep,
* but usleep (1) takes >10000 usec !
*/
X_GETTIMEOFDAY(&cur);
d_secs = (cur.tv_sec - begin.tv_sec);
d_usecs = (cur.tv_usec - begin.tv_usec);
diff = d_secs * 1000000 + d_usecs;
} while (diff >= 0 && diff < (usec + 1));
}
}
/* Most drivers will register just with GetBits/PutBits functions.
* The following functions implement a software I2C protocol
* by using the promitive functions given by the driver.
* ================================================================
*
* It is assumed that there is just one master on the I2C bus, therefore
* there is no explicit test for conflits.
*/
#define RISEFALLTIME 2 /* usec, actually 300 to 1000 ns according to the i2c specs */
/* Some devices will hold SCL low to slow down the bus or until
* ready for transmission.
*
* This condition will be noticed when the master tries to raise
* the SCL line. You can set the timeout to zero if the slave device
* does not support this clock synchronization.
*/
static Bool
I2CRaiseSCL(I2CBusPtr b, int sda, int timeout)
{
int i, scl;
b->I2CPutBits(b, 1, sda);
b->I2CUDelay(b, b->RiseFallTime);
for (i = timeout; i > 0; i -= b->RiseFallTime) {
b->I2CGetBits(b, &scl, &sda);
if (scl)
break;
b->I2CUDelay(b, b->RiseFallTime);
}
if (i <= 0) {
I2C_TIMEOUT(ErrorF
("[I2CRaiseSCL(<%s>, %d, %d) timeout]", b->BusName, sda,
timeout));
return FALSE;
}
return TRUE;
}
/* Send a start signal on the I2C bus. The start signal notifies
* devices that a new transaction is initiated by the bus master.
*
* The start signal is always followed by a slave address.
* Slave addresses are 8+ bits. The first 7 bits identify the
* device and the last bit signals if this is a read (1) or
* write (0) operation.
*
* There may be more than one start signal on one transaction.
* This happens for example on some devices that allow reading
* of registers. First send a start bit followed by the device
* address (with the last bit 0) and the register number. Then send
* a new start bit with the device address (with the last bit 1)
* and then read the value from the device.
*
* Note this is function does not implement a multiple master
* arbitration procedure.
*/
static Bool
I2CStart(I2CBusPtr b, int timeout)
{
if (!I2CRaiseSCL(b, 1, timeout))
return FALSE;
b->I2CPutBits(b, 1, 0);
b->I2CUDelay(b, b->HoldTime);
b->I2CPutBits(b, 0, 0);
b->I2CUDelay(b, b->HoldTime);
I2C_TRACE(ErrorF("\ni2c: <"));
return TRUE;
}
/* This is the default I2CStop function if not supplied by the driver.
*
* Signal devices on the I2C bus that a transaction on the
* bus has finished. There may be more than one start signal
* on a transaction but only one stop signal.
*/
static void
I2CStop(I2CDevPtr d)
{
I2CBusPtr b = d->pI2CBus;
b->I2CPutBits(b, 0, 0);
b->I2CUDelay(b, b->RiseFallTime);
b->I2CPutBits(b, 1, 0);
b->I2CUDelay(b, b->HoldTime);
b->I2CPutBits(b, 1, 1);
b->I2CUDelay(b, b->HoldTime);
I2C_TRACE(ErrorF(">\n"));
}
/* Write/Read a single bit to/from a device.
* Return FALSE if a timeout occurs.
*/
static Bool
I2CWriteBit(I2CBusPtr b, int sda, int timeout)
{
Bool r;
b->I2CPutBits(b, 0, sda);
b->I2CUDelay(b, b->RiseFallTime);
r = I2CRaiseSCL(b, sda, timeout);
b->I2CUDelay(b, b->HoldTime);
b->I2CPutBits(b, 0, sda);
b->I2CUDelay(b, b->HoldTime);
return r;
}
static Bool
I2CReadBit(I2CBusPtr b, int *psda, int timeout)
{
Bool r;
int scl;
r = I2CRaiseSCL(b, 1, timeout);
b->I2CUDelay(b, b->HoldTime);
b->I2CGetBits(b, &scl, psda);
b->I2CPutBits(b, 0, 1);
b->I2CUDelay(b, b->HoldTime);
return r;
}
/* This is the default I2CPutByte function if not supplied by the driver.
*
* A single byte is sent to the device.
* The function returns FALSE if a timeout occurs, you should send
* a stop condition afterwards to reset the bus.
*
* A timeout occurs,
* if the slave pulls SCL to slow down the bus more than ByteTimeout usecs,
* or slows down the bus for more than BitTimeout usecs for each bit,
* or does not send an ACK bit (0) to acknowledge the transmission within
* AcknTimeout usecs, but a NACK (1) bit.
*
* AcknTimeout must be at least b->HoldTime, the other timeouts can be
* zero according to the comment on I2CRaiseSCL.
*/
static Bool
I2CPutByte(I2CDevPtr d, I2CByte data)
{
Bool r;
int i, scl, sda;
I2CBusPtr b = d->pI2CBus;
if (!I2CWriteBit(b, (data >> 7) & 1, d->ByteTimeout))
return FALSE;
for (i = 6; i >= 0; i--)
if (!I2CWriteBit(b, (data >> i) & 1, d->BitTimeout))
return FALSE;
b->I2CPutBits(b, 0, 1);
b->I2CUDelay(b, b->RiseFallTime);
r = I2CRaiseSCL(b, 1, b->HoldTime);
if (r) {
for (i = d->AcknTimeout; i > 0; i -= b->HoldTime) {
b->I2CUDelay(b, b->HoldTime);
b->I2CGetBits(b, &scl, &sda);
if (sda == 0)
break;
}
if (i <= 0) {
I2C_TIMEOUT(ErrorF("[I2CPutByte(<%s>, 0x%02x, %d, %d, %d) timeout]",
b->BusName, data, d->BitTimeout,
d->ByteTimeout, d->AcknTimeout));
r = FALSE;
}
I2C_TRACE(ErrorF("W%02x%c ", (int) data, sda ? '-' : '+'));
}
b->I2CPutBits(b, 0, 1);
b->I2CUDelay(b, b->HoldTime);
return r;
}
/* This is the default I2CGetByte function if not supplied by the driver.
*
* A single byte is read from the device.
* The function returns FALSE if a timeout occurs, you should send
* a stop condition afterwards to reset the bus.
*
* A timeout occurs,
* if the slave pulls SCL to slow down the bus more than ByteTimeout usecs,
* or slows down the bus for more than b->BitTimeout usecs for each bit.
*
* ByteTimeout must be at least b->HoldTime, the other timeouts can be
* zero according to the comment on I2CRaiseSCL.
*
* For the <last> byte in a sequence the acknowledge bit NACK (1),
* otherwise ACK (0) will be sent.
*/
static Bool
I2CGetByte(I2CDevPtr d, I2CByte * data, Bool last)
{
int i, sda;
I2CBusPtr b = d->pI2CBus;
b->I2CPutBits(b, 0, 1);
b->I2CUDelay(b, b->RiseFallTime);
if (!I2CReadBit(b, &sda, d->ByteTimeout))
return FALSE;
*data = (sda > 0) << 7;
for (i = 6; i >= 0; i--)
if (!I2CReadBit(b, &sda, d->BitTimeout))
return FALSE;
else
*data |= (sda > 0) << i;
if (!I2CWriteBit(b, last ? 1 : 0, d->BitTimeout))
return FALSE;
I2C_TRACE(ErrorF("R%02x%c ", (int) *data, last ? '+' : '-'));
return TRUE;
}
/* This is the default I2CAddress function if not supplied by the driver.
*
* It creates the start condition, followed by the d->SlaveAddr.
* Higher level functions must call this routine rather than
* I2CStart/PutByte because a hardware I2C master may not be able
* to send a slave address without a start condition.
*
* The same timeouts apply as with I2CPutByte and additional a
* StartTimeout, similar to the ByteTimeout but for the start
* condition.
*
* In case of a timeout, the bus is left in a clean idle condition.
* I. e. you *must not* send a Stop. If this function succeeds, you *must*.
*
* The slave address format is 16 bit, with the legacy _8_bit_ slave address
* in the least significant byte. This is, the slave address must include the
* R/_W flag as least significant bit.
*
* The most significant byte of the address will be sent _after_ the LSB,
* but only if the LSB indicates:
* a) an 11 bit address, this is LSB = 1111 0xxx.
* b) a 'general call address', this is LSB = 0000 000x - see the I2C specs
* for more.
*/
static Bool
I2CAddress(I2CDevPtr d, I2CSlaveAddr addr)
{
if (I2CStart(d->pI2CBus, d->StartTimeout)) {
if (I2CPutByte(d, addr & 0xFF)) {
if ((addr & 0xF8) != 0xF0 && (addr & 0xFE) != 0x00)
return TRUE;
if (I2CPutByte(d, (addr >> 8) & 0xFF))
return TRUE;
}
I2CStop(d);
}
return FALSE;
}
/* These are the hardware independent I2C helper functions.
* ========================================================
*/
/* Function for probing. Just send the slave address
* and return true if the device responds. The slave address
* must have the lsb set to reflect a read (1) or write (0) access.
* Don't expect a read- or write-only device will respond otherwise.
*/
Bool
xf86I2CProbeAddress(I2CBusPtr b, I2CSlaveAddr addr)
{
int r;
I2CDevRec d;
d.DevName = "Probing";
d.BitTimeout = b->BitTimeout;
d.ByteTimeout = b->ByteTimeout;
d.AcknTimeout = b->AcknTimeout;
d.StartTimeout = b->StartTimeout;
d.SlaveAddr = addr;
d.pI2CBus = b;
d.NextDev = NULL;
r = b->I2CAddress(&d, addr);
if (r)
b->I2CStop(&d);
return r;
}
/* All functions below are related to devices and take the
* slave address and timeout values from an I2CDevRec. They
* return FALSE in case of an error (presumably a timeout).
*/
/* General purpose read and write function.
*
* 1st, if nWrite > 0
* Send a start condition
* Send the slave address (1 or 2 bytes) with write flag
* Write n bytes from WriteBuffer
* 2nd, if nRead > 0
* Send a start condition [again]
* Send the slave address (1 or 2 bytes) with read flag
* Read n bytes to ReadBuffer
* 3rd, if a Start condition has been successfully sent,
* Send a Stop condition.
*
* The function exits immediately when an error occurs,
* not processing any data left. However, step 3 will
* be executed anyway to leave the bus in clean idle state.
*/
static Bool
I2CWriteRead(I2CDevPtr d,
I2CByte * WriteBuffer, int nWrite, I2CByte * ReadBuffer, int nRead)
{
Bool r = TRUE;
I2CBusPtr b = d->pI2CBus;
int s = 0;
if (r && nWrite > 0) {
r = b->I2CAddress(d, d->SlaveAddr & ~1);
if (r) {
for (; nWrite > 0; WriteBuffer++, nWrite--)
if (!(r = b->I2CPutByte(d, *WriteBuffer)))
break;
s++;
}
}
if (r && nRead > 0) {
r = b->I2CAddress(d, d->SlaveAddr | 1);
if (r) {
for (; nRead > 0; ReadBuffer++, nRead--)
if (!(r = b->I2CGetByte(d, ReadBuffer, nRead == 1)))
break;
s++;
}
}
if (s)
b->I2CStop(d);
return r;
}
/* wrapper - for compatibility and convenience */
Bool
xf86I2CWriteRead(I2CDevPtr d,
I2CByte * WriteBuffer, int nWrite,
I2CByte * ReadBuffer, int nRead)
{
I2CBusPtr b = d->pI2CBus;
return b->I2CWriteRead(d, WriteBuffer, nWrite, ReadBuffer, nRead);
}
/* Read a byte, the only readable register of a device.
*/
Bool
xf86I2CReadStatus(I2CDevPtr d, I2CByte * pbyte)
{
return xf86I2CWriteRead(d, NULL, 0, pbyte, 1);
}
/* Read a byte from one of the registers determined by its sub-address.
*/
Bool
xf86I2CReadByte(I2CDevPtr d, I2CByte subaddr, I2CByte * pbyte)
{
return xf86I2CWriteRead(d, &subaddr, 1, pbyte, 1);
}
/* Read bytes from subsequent registers determined by the
* sub-address of the first register.
*/
Bool
xf86I2CReadBytes(I2CDevPtr d, I2CByte subaddr, I2CByte * pbyte, int n)
{
return xf86I2CWriteRead(d, &subaddr, 1, pbyte, n);
}
/* Read a word (high byte, then low byte) from one of the registers
* determined by its sub-address.
*/
Bool
xf86I2CReadWord(I2CDevPtr d, I2CByte subaddr, unsigned short *pword)
{
I2CByte rb[2];
if (!xf86I2CWriteRead(d, &subaddr, 1, rb, 2))
return FALSE;
*pword = (rb[0] << 8) | rb[1];
return TRUE;
}
/* Write a byte to one of the registers determined by its sub-address.
*/
Bool
xf86I2CWriteByte(I2CDevPtr d, I2CByte subaddr, I2CByte byte)
{
I2CByte wb[2];
wb[0] = subaddr;
wb[1] = byte;
return xf86I2CWriteRead(d, wb, 2, NULL, 0);
}
/* Write bytes to subsequent registers determined by the
* sub-address of the first register.
*/
Bool
xf86I2CWriteBytes(I2CDevPtr d, I2CByte subaddr,
I2CByte * WriteBuffer, int nWrite)
{
I2CBusPtr b = d->pI2CBus;
Bool r = TRUE;
if (nWrite > 0) {
r = b->I2CAddress(d, d->SlaveAddr & ~1);
if (r) {
if ((r = b->I2CPutByte(d, subaddr)))
for (; nWrite > 0; WriteBuffer++, nWrite--)
if (!(r = b->I2CPutByte(d, *WriteBuffer)))
break;
b->I2CStop(d);
}
}
return r;
}
/* Write a word (high byte, then low byte) to one of the registers
* determined by its sub-address.
*/
Bool
xf86I2CWriteWord(I2CDevPtr d, I2CByte subaddr, unsigned short word)
{
I2CByte wb[3];
wb[0] = subaddr;
wb[1] = word >> 8;
wb[2] = word & 0xFF;
return xf86I2CWriteRead(d, wb, 3, NULL, 0);
}
/* Write a vector of bytes to not adjacent registers. This vector is,
* 1st byte sub-address, 2nd byte value, 3rd byte sub-address asf.
* This function is intended to initialize devices. Note this function
* exits immediately when an error occurs, some registers may
* remain uninitialized.
*/
Bool
xf86I2CWriteVec(I2CDevPtr d, I2CByte * vec, int nValues)
{
I2CBusPtr b = d->pI2CBus;
Bool r = TRUE;
int s = 0;
if (nValues > 0) {
for (; nValues > 0; nValues--, vec += 2) {
if (!(r = b->I2CAddress(d, d->SlaveAddr & ~1)))
break;
s++;
if (!(r = b->I2CPutByte(d, vec[0])))
break;
if (!(r = b->I2CPutByte(d, vec[1])))
break;
}
if (s > 0)
b->I2CStop(d);
}
return r;
}
/* Administrative functions.
* =========================
*/
/* Allocates an I2CDevRec for you and initializes with proper defaults
* you may modify before calling xf86I2CDevInit. Your I2CDevRec must
* contain at least a SlaveAddr, and a pI2CBus pointer to the bus this
* device shall be linked to.
*
* See function I2CAddress for the slave address format. Always set
* the least significant bit, indicating a read or write access, to zero.
*/
I2CDevPtr
xf86CreateI2CDevRec(void)
{
return calloc(1, sizeof(I2CDevRec));
}
/* Unlink an I2C device. If you got the I2CDevRec from xf86CreateI2CDevRec
* you should set <unalloc> to free it.
*/
void
xf86DestroyI2CDevRec(I2CDevPtr d, Bool unalloc)
{
if (d && d->pI2CBus) {
I2CDevPtr *p;
/* Remove this from the list of active I2C devices. */
for (p = &d->pI2CBus->FirstDev; *p != NULL; p = &(*p)->NextDev)
if (*p == d) {
*p = (*p)->NextDev;
break;
}
xf86DrvMsg(d->pI2CBus->scrnIndex, X_INFO,
"I2C device \"%s:%s\" removed.\n",
d->pI2CBus->BusName, d->DevName);
}
if (unalloc)
free(d);
}
/* I2C transmissions are related to an I2CDevRec you must link to a
* previously registered bus (see xf86I2CBusInit) before attempting
* to read and write data. You may call xf86I2CProbeAddress first to
* see if the device in question is present on this bus.
*
* xf86I2CDevInit will not allocate an I2CBusRec for you, instead you
* may enter a pointer to a statically allocated I2CDevRec or the (modified)
* result of xf86CreateI2CDevRec.
*
* If you don't specify timeouts for the device (n <= 0), it will inherit
* the bus-wide defaults. The function returns TRUE on success.
*/
Bool
xf86I2CDevInit(I2CDevPtr d)
{
I2CBusPtr b;
if (d == NULL ||
(b = d->pI2CBus) == NULL ||
(d->SlaveAddr & 1) || xf86I2CFindDev(b, d->SlaveAddr) != NULL)
return FALSE;
if (d->BitTimeout <= 0)
d->BitTimeout = b->BitTimeout;
if (d->ByteTimeout <= 0)
d->ByteTimeout = b->ByteTimeout;
if (d->AcknTimeout <= 0)
d->AcknTimeout = b->AcknTimeout;
if (d->StartTimeout <= 0)
d->StartTimeout = b->StartTimeout;
d->NextDev = b->FirstDev;
b->FirstDev = d;
xf86DrvMsg(b->scrnIndex, X_INFO,
"I2C device \"%s:%s\" registered at address 0x%02X.\n",
b->BusName, d->DevName, d->SlaveAddr);
return TRUE;
}
I2CDevPtr
xf86I2CFindDev(I2CBusPtr b, I2CSlaveAddr addr)
{
I2CDevPtr d;
if (b) {
for (d = b->FirstDev; d != NULL; d = d->NextDev)
if (d->SlaveAddr == addr)
return d;
}
return NULL;
}
static I2CBusPtr I2CBusList;
/* Allocates an I2CBusRec for you and initializes with proper defaults
* you may modify before calling xf86I2CBusInit. Your I2CBusRec must
* contain at least a BusName, a scrnIndex (or -1), and a complete set
* of either high or low level I2C function pointers. You may pass
* bus-wide timeouts, otherwise inplausible values will be replaced
* with safe defaults.
*/
I2CBusPtr
xf86CreateI2CBusRec(void)
{
I2CBusPtr b;
b = (I2CBusPtr) calloc(1, sizeof(I2CBusRec));
if (b != NULL) {
b->scrnIndex = -1;
b->pScrn = NULL;
b->HoldTime = 5; /* 100 kHz bus */
b->BitTimeout = 5;
b->ByteTimeout = 5;
b->AcknTimeout = 5;
b->StartTimeout = 5;
b->RiseFallTime = RISEFALLTIME;
}
return b;
}
/* Unregister an I2C bus. If you got the I2CBusRec from xf86CreateI2CBusRec
* you should set <unalloc> to free it. If you set <devs_too>, the function
* xf86DestroyI2CDevRec will be called for all devices linked to the bus
* first, passing down the <unalloc> option.
*/
void
xf86DestroyI2CBusRec(I2CBusPtr b, Bool unalloc, Bool devs_too)
{
if (b) {
I2CBusPtr *p;
/* Remove this from the list of active I2C buses */
for (p = &I2CBusList; *p != NULL; p = &(*p)->NextBus)
if (*p == b) {
*p = (*p)->NextBus;
break;
}
if (b->FirstDev != NULL) {
if (devs_too) {
I2CDevPtr d;
while ((d = b->FirstDev) != NULL) {
b->FirstDev = d->NextDev;
xf86DestroyI2CDevRec(d, unalloc);
}
}
else {
if (unalloc) {
xf86Msg(X_ERROR,
"i2c bug: Attempt to remove I2C bus \"%s\", "
"but device list is not empty.\n", b->BusName);
return;
}
}
}
xf86DrvMsg(b->scrnIndex, X_INFO, "I2C bus \"%s\" removed.\n",
b->BusName);
if (unalloc)
free(b);
}
}
/* I2C masters have to register themselves using this function.
* It will not allocate an I2CBusRec for you, instead you may enter
* a pointer to a statically allocated I2CBusRec or the (modified)
* result of xf86CreateI2CBusRec. Returns TRUE on success.
*
* At this point there won't be any traffic on the I2C bus.
*/
Bool
xf86I2CBusInit(I2CBusPtr b)
{
/* I2C buses must be identified by a unique scrnIndex
* and name. If scrnIndex is unspecified (a negative value),
* then the name must be unique throughout the server.
*/
if (b->BusName == NULL || xf86I2CFindBus(b->scrnIndex, b->BusName) != NULL)
return FALSE;
/* If the high level functions are not
* supplied, use the generic functions.
* In this case we need the low-level
* function.
*/
if (b->I2CWriteRead == NULL) {
b->I2CWriteRead = I2CWriteRead;
if (b->I2CPutBits == NULL || b->I2CGetBits == NULL) {
if (b->I2CPutByte == NULL ||
b->I2CGetByte == NULL ||
b->I2CAddress == NULL ||
b->I2CStart == NULL || b->I2CStop == NULL)
return FALSE;
}
else {
b->I2CPutByte = I2CPutByte;
b->I2CGetByte = I2CGetByte;
b->I2CAddress = I2CAddress;
b->I2CStop = I2CStop;
b->I2CStart = I2CStart;
}
}
if (b->I2CUDelay == NULL)
b->I2CUDelay = I2CUDelay;
if (b->HoldTime < 2)
b->HoldTime = 5;
if (b->BitTimeout <= 0)
b->BitTimeout = b->HoldTime;
if (b->ByteTimeout <= 0)
b->ByteTimeout = b->HoldTime;
if (b->AcknTimeout <= 0)
b->AcknTimeout = b->HoldTime;
if (b->StartTimeout <= 0)
b->StartTimeout = b->HoldTime;
/* Put new bus on list. */
b->NextBus = I2CBusList;
I2CBusList = b;
xf86DrvMsg(b->scrnIndex, X_INFO, "I2C bus \"%s\" initialized.\n",
b->BusName);
return TRUE;
}
I2CBusPtr
xf86I2CFindBus(int scrnIndex, char *name)
{
I2CBusPtr p;
if (name != NULL)
for (p = I2CBusList; p != NULL; p = p->NextBus)
if (scrnIndex < 0 || p->scrnIndex == scrnIndex)
if (!strcmp(p->BusName, name))
return p;
return NULL;
}
/*
* Return an array of I2CBusPtr's related to a screen. The caller is
* responsible for freeing the array.
*/
int
xf86I2CGetScreenBuses(int scrnIndex, I2CBusPtr ** pppI2CBus)
{
I2CBusPtr pI2CBus;
int n = 0;
if (pppI2CBus)
*pppI2CBus = NULL;
for (pI2CBus = I2CBusList; pI2CBus; pI2CBus = pI2CBus->NextBus) {
if ((pI2CBus->scrnIndex >= 0) && (pI2CBus->scrnIndex != scrnIndex))
continue;
n++;
if (!pppI2CBus)
continue;
*pppI2CBus = xnfreallocarray(*pppI2CBus, n, sizeof(I2CBusPtr));
(*pppI2CBus)[n - 1] = pI2CBus;
}
return n;
}

View file

@ -0,0 +1,117 @@
/*
* Copyright (C) 1998 Itai Nahshon, Michael Schimek
*/
#ifndef _XF86I2C_H
#define _XF86I2C_H
#include "regionstr.h"
#include "xf86.h"
typedef unsigned char I2CByte;
typedef unsigned short I2CSlaveAddr;
typedef struct _I2CBusRec *I2CBusPtr;
typedef struct _I2CDevRec *I2CDevPtr;
/* I2C masters have to register themselves */
typedef struct _I2CBusRec {
char *BusName;
int scrnIndex;
ScrnInfoPtr pScrn;
void (*I2CUDelay) (I2CBusPtr b, int usec);
void (*I2CPutBits) (I2CBusPtr b, int scl, int sda);
void (*I2CGetBits) (I2CBusPtr b, int *scl, int *sda);
/* Look at the generic routines to see how these functions should behave. */
Bool (*I2CStart) (I2CBusPtr b, int timeout);
Bool (*I2CAddress) (I2CDevPtr d, I2CSlaveAddr);
void (*I2CStop) (I2CDevPtr d);
Bool (*I2CPutByte) (I2CDevPtr d, I2CByte data);
Bool (*I2CGetByte) (I2CDevPtr d, I2CByte * data, Bool);
DevUnion DriverPrivate;
int HoldTime; /* 1 / bus clock frequency, 5 or 2 usec */
int BitTimeout; /* usec */
int ByteTimeout; /* usec */
int AcknTimeout; /* usec */
int StartTimeout; /* usec */
int RiseFallTime; /* usec */
I2CDevPtr FirstDev;
I2CBusPtr NextBus;
Bool (*I2CWriteRead) (I2CDevPtr d, I2CByte * WriteBuffer, int nWrite,
I2CByte * ReadBuffer, int nRead);
} I2CBusRec;
#define CreateI2CBusRec xf86CreateI2CBusRec
extern _X_EXPORT I2CBusPtr xf86CreateI2CBusRec(void);
#define DestroyI2CBusRec xf86DestroyI2CBusRec
extern _X_EXPORT void xf86DestroyI2CBusRec(I2CBusPtr pI2CBus, Bool unalloc,
Bool devs_too);
#define I2CBusInit xf86I2CBusInit
extern _X_EXPORT Bool xf86I2CBusInit(I2CBusPtr pI2CBus);
extern _X_EXPORT I2CBusPtr xf86I2CFindBus(int scrnIndex, char *name);
extern _X_EXPORT int xf86I2CGetScreenBuses(int scrnIndex,
I2CBusPtr ** pppI2CBus);
/* I2C slave devices */
typedef struct _I2CDevRec {
const char *DevName;
int BitTimeout; /* usec */
int ByteTimeout; /* usec */
int AcknTimeout; /* usec */
int StartTimeout; /* usec */
I2CSlaveAddr SlaveAddr;
I2CBusPtr pI2CBus;
I2CDevPtr NextDev;
DevUnion DriverPrivate;
} I2CDevRec;
#define CreateI2CDevRec xf86CreateI2CDevRec
extern _X_EXPORT I2CDevPtr xf86CreateI2CDevRec(void);
extern _X_EXPORT void xf86DestroyI2CDevRec(I2CDevPtr pI2CDev, Bool unalloc);
#define I2CDevInit xf86I2CDevInit
extern _X_EXPORT Bool xf86I2CDevInit(I2CDevPtr pI2CDev);
extern _X_EXPORT I2CDevPtr xf86I2CFindDev(I2CBusPtr, I2CSlaveAddr);
/* See descriptions of these functions in xf86i2c.c */
#define I2CProbeAddress xf86I2CProbeAddress
extern _X_EXPORT Bool xf86I2CProbeAddress(I2CBusPtr pI2CBus, I2CSlaveAddr);
#define I2C_WriteRead xf86I2CWriteRead
extern _X_EXPORT Bool xf86I2CWriteRead(I2CDevPtr d, I2CByte * WriteBuffer,
int nWrite, I2CByte * ReadBuffer,
int nRead);
#define xf86I2CRead(d, rb, nr) xf86I2CWriteRead(d, NULL, 0, rb, nr)
extern _X_EXPORT Bool xf86I2CReadStatus(I2CDevPtr d, I2CByte * pbyte);
extern _X_EXPORT Bool xf86I2CReadByte(I2CDevPtr d, I2CByte subaddr,
I2CByte * pbyte);
extern _X_EXPORT Bool xf86I2CReadBytes(I2CDevPtr d, I2CByte subaddr,
I2CByte * pbyte, int n);
extern _X_EXPORT Bool xf86I2CReadWord(I2CDevPtr d, I2CByte subaddr,
unsigned short *pword);
#define xf86I2CWrite(d, wb, nw) xf86I2CWriteRead(d, wb, nw, NULL, 0)
extern _X_EXPORT Bool xf86I2CWriteByte(I2CDevPtr d, I2CByte subaddr,
I2CByte byte);
extern _X_EXPORT Bool xf86I2CWriteBytes(I2CDevPtr d, I2CByte subaddr,
I2CByte * WriteBuffer, int nWrite);
extern _X_EXPORT Bool xf86I2CWriteWord(I2CDevPtr d, I2CByte subaddr,
unsigned short word);
extern _X_EXPORT Bool xf86I2CWriteVec(I2CDevPtr d, I2CByte * vec, int nValues);
#endif /*_XF86I2C_H */