--- i2c-tools-3.0.2.orig/i2c-tools.doc +++ i2c-tools-3.0.2/i2c-tools.doc @@ -0,0 +1 @@ +eeprom/README --- i2c-tools-3.0.2.orig/debian/control +++ i2c-tools-3.0.2/debian/control @@ -0,0 +1,40 @@ +Source: i2c-tools +Section: utils +Priority: extra +Build-Depends: debhelper (>= 5), python-all-dev (>= 2.3.5-11), python-support (>= 0.4) +Maintainer: Aurelien Jarno +Standards-Version: 3.8.3 +Homepage: http://www.lm-sensors.org + +Package: i2c-tools +Architecture: any +Section: utils +Conflicts: lm-sensors (<< 1:3.0.0-1) +Depends: ${shlibs:Depends}, ${perl:Depends}, ${misc:Depends}, adduser, udev | makedev +Suggests: libi2c-dev, python-smbus +Description: heterogeneous set of I2C tools for Linux + This package contains a heterogeneous set of I2C tools for Linux: a bus + probing tool, a chip dumper, register-level access helpers, EEPROM + decoding scripts, and more. + +Package: libi2c-dev +Architecture: all +Depends: ${misc:Depends} +Section: libdevel +Recommends: i2c-tools +Description: userspace I2C programming library development files + I2C devices are usually controlled by a kernel driver. Using this + library it is also possible to access all devices on an adapter + from userspace and without the knowledge of Linux kernel internals. + +Package: python-smbus +Architecture: any +Section: python +Depends: ${shlibs:Depends}, ${python:Depends}, ${misc:Depends} +XB-Python-Version: ${python:Versions} +Provides: ${python:Provides} +Recommends: i2c-tools +Description: Python bindings for Linux SMBus access through i2c-dev + This Python module allows SMBus access through the I2C /dev interface on + Linux hosts. The host kernel must have I2C support, I2C device interface + support, and a bus adapter driver. --- i2c-tools-3.0.2.orig/debian/dev-interface +++ i2c-tools-3.0.2/debian/dev-interface @@ -0,0 +1,154 @@ +Usually, i2c devices are controlled by a kernel driver. But it is also +possible to access all devices on an adapter from userspace, through +the /dev interface. You need to load module i2c-dev for this. + +Each registered i2c adapter gets a number, counting from 0. You can +examine /sys/class/i2c-dev/ to see what number corresponds to which adapter. +I2C device files are character device files with major device number 89 +and a minor device number corresponding to the number assigned as +explained above. They should be called "i2c-%d" (i2c-0, i2c-1, ..., +i2c-10, ...). All 256 minor device numbers are reserved for i2c. + + +C example +========= + +So let's say you want to access an i2c adapter from a C program. The +first thing to do is "#include ". Please note that +there are two files named "i2c-dev.h" out there, one is distributed +with the Linux kernel and is meant to be included from kernel +driver code, the other one is distributed with lm_sensors and is +meant to be included from user-space programs. You obviously want +the second one here. + +Now, you have to decide which adapter you want to access. You should +inspect /sys/class/i2c-dev/ to decide this. Adapter numbers are assigned +somewhat dynamically, so you can not even assume /dev/i2c-0 is the +first adapter. + +Next thing, open the device file, as follows: + int file; + int adapter_nr = 2; /* probably dynamically determined */ + char filename[20]; + + sprintf(filename,"/dev/i2c-%d",adapter_nr); + if ((file = open(filename,O_RDWR)) < 0) { + /* ERROR HANDLING; you can check errno to see what went wrong */ + exit(1); + } + +When you have opened the device, you must specify with what device +address you want to communicate: + int addr = 0x40; /* The I2C address */ + if (ioctl(file,I2C_SLAVE,addr) < 0) { + /* ERROR HANDLING; you can check errno to see what went wrong */ + exit(1); + } + +Well, you are all set up now. You can now use SMBus commands or plain +I2C to communicate with your device. SMBus commands are preferred if +the device supports them. Both are illustrated below. + __u8 register = 0x10; /* Device register to access */ + __s32 res; + char buf[10]; + /* Using SMBus commands */ + res = i2c_smbus_read_word_data(file,register); + if (res < 0) { + /* ERROR HANDLING: i2c transaction failed */ + } else { + /* res contains the read word */ + } + /* Using I2C Write, equivalent of + i2c_smbus_write_word_data(file,register,0x6543) */ + buf[0] = register; + buf[1] = 0x43; + buf[2] = 0x65; + if ( write(file,buf,3) != 3) { + /* ERROR HANDLING: i2c transaction failed */ + } + /* Using I2C Read, equivalent of i2c_smbus_read_byte(file) */ + if (read(file,buf,1) != 1) { + /* ERROR HANDLING: i2c transaction failed */ + } else { + /* buf[0] contains the read byte */ + } + +IMPORTANT: because of the use of inline functions, you *have* to use +'-O' or some variation when you compile your program! + + +Full interface description +========================== + +The following IOCTLs are defined and fully supported +(see also i2c-dev.h): + +ioctl(file,I2C_SLAVE,long addr) + Change slave address. The address is passed in the 7 lower bits of the + argument (except for 10 bit addresses, passed in the 10 lower bits in this + case). + +ioctl(file,I2C_TENBIT,long select) + Selects ten bit addresses if select not equals 0, selects normal 7 bit + addresses if select equals 0. Default 0. This request is only valid + if the adapter has I2C_FUNC_10BIT_ADDR. + +ioctl(file,I2C_PEC,long select) + Selects SMBus PEC (packet error checking) generation and verification + if select not equals 0, disables if select equals 0. Default 0. + Used only for SMBus transactions. This request only has an effect if the + the adapter has I2C_FUNC_SMBUS_PEC; it is still safe if not, it just + doesn't have any effect. + +ioctl(file,I2C_FUNCS,unsigned long *funcs) + Gets the adapter functionality and puts it in *funcs. + +ioctl(file,I2C_RDWR,struct i2c_rdwr_ioctl_data *msgset) + + Do combined read/write transaction without stop in between. + Only valid if the adapter has I2C_FUNC_I2C. The argument is + a pointer to a + + struct i2c_rdwr_ioctl_data { + struct i2c_msg *msgs; /* ptr to array of simple messages */ + int nmsgs; /* number of messages to exchange */ + } + + The msgs[] themselves contain further pointers into data buffers. + The function will write or read data to or from that buffers depending + on whether the I2C_M_RD flag is set in a particular message or not. + The slave address and whether to use ten bit address mode has to be + set in each message, overriding the values set with the above ioctl's. + + +Other values are NOT supported at this moment, except for I2C_SMBUS, +which you should never directly call; instead, use the access functions +below. + +You can do plain i2c transactions by using read(2) and write(2) calls. +You do not need to pass the address byte; instead, set it through +ioctl I2C_SLAVE before you try to access the device. + +You can do SMBus level transactions (see documentation file smbus-protocol +for details) through the following functions: + __s32 i2c_smbus_write_quick(int file, __u8 value); + __s32 i2c_smbus_read_byte(int file); + __s32 i2c_smbus_write_byte(int file, __u8 value); + __s32 i2c_smbus_read_byte_data(int file, __u8 command); + __s32 i2c_smbus_write_byte_data(int file, __u8 command, __u8 value); + __s32 i2c_smbus_read_word_data(int file, __u8 command); + __s32 i2c_smbus_write_word_data(int file, __u8 command, __u16 value); + __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value); + __s32 i2c_smbus_read_block_data(int file, __u8 command, __u8 *values); + __s32 i2c_smbus_write_block_data(int file, __u8 command, __u8 length, + __u8 *values); +All these transactions return -1 on failure; you can read errno to see +what happened. The 'write' transactions return 0 on success; the +'read' transactions return the read value, except for read_block, which +returns the number of values read. The block buffers need not be longer +than 32 bytes. + +The above functions are all macros, that resolve to calls to the +i2c_smbus_access function, that on its turn calls a specific ioctl +with the data in a specific format. Read the source code if you +want to know what happens behind the screens. --- i2c-tools-3.0.2.orig/debian/i2c-tools.udev +++ i2c-tools-3.0.2/debian/i2c-tools.udev @@ -0,0 +1 @@ +KERNEL=="i2c-[0-9]*", GROUP="i2c", MODE="0660" --- i2c-tools-3.0.2.orig/debian/libi2c-dev.install +++ i2c-tools-3.0.2/debian/libi2c-dev.install @@ -0,0 +1 @@ +usr/include/linux/i2c-dev.h --- i2c-tools-3.0.2.orig/debian/libi2c-dev.docs +++ i2c-tools-3.0.2/debian/libi2c-dev.docs @@ -0,0 +1 @@ +debian/dev-interface --- i2c-tools-3.0.2.orig/debian/changelog +++ i2c-tools-3.0.2/debian/changelog @@ -0,0 +1,54 @@ +i2c-tools (3.0.2-5) unstable; urgency=low + + * Add depends on adduser to i2ctools. (Closes: #608835). + + -- Aurelien Jarno Mon, 03 Jan 2011 23:22:26 +0100 + +i2c-tools (3.0.2-4) unstable; urgency=low + + * Add ${misc:Depends} to all binaries. + * Create an i2c group on install, and add a udev file to set the group + and the mode of /dev/i2c-* nodes. + + -- Aurelien Jarno Thu, 14 Jan 2010 06:39:06 +0100 + +i2c-tools (3.0.2-3) unstable; urgency=low + + * Correctly call dh_pysupport. (Closes: #556147). + + -- Aurelien Jarno Sat, 14 Nov 2009 14:27:26 +0100 + +i2c-tools (3.0.2-2) unstable; urgency=low + + * i2c-tools: depends on udev | makedev and create /dev/i2c-0 (Closes: + bug#546871). + * Bump standard versions to 3.8.3 (no changes). + + -- Aurelien Jarno Wed, 14 Oct 2009 00:19:49 +0200 + +i2c-tools (3.0.2-1) unstable; urgency=low + + * New upstream version. + * Bump standard versions to 3.8.0 (no changes). + + -- Aurelien Jarno Wed, 28 Jan 2009 23:37:31 +0100 + +i2c-tools (3.0.1-1) unstable; urgency=low + + * New upstream version. + + -- Aurelien Jarno Fri, 04 Apr 2008 22:14:04 +0200 + +i2c-tools (3.0.0-2) unstable; urgency=low + + * Bump standard versions to 3.7.3 (no changes). + * Fix python-pysmbus description. + * Fix debian/copyright. + + -- Aurelien Jarno Sun, 02 Mar 2008 18:54:37 +0100 + +i2c-tools (3.0.0-1) unstable; urgency=low + + * New upstream package split from lm-sensors. + + -- Aurelien Jarno Tue, 27 Nov 2007 16:46:35 +0100 --- i2c-tools-3.0.2.orig/debian/pyversions +++ i2c-tools-3.0.2/debian/pyversions @@ -0,0 +1 @@ +2.2- --- i2c-tools-3.0.2.orig/debian/i2c-tools.install +++ i2c-tools-3.0.2/debian/i2c-tools.install @@ -0,0 +1,12 @@ +usr/bin/ddcmon +usr/bin/decode-vaio +usr/bin/decode-edid +usr/bin/decode-dimms +usr/share/man/man8/i2cset.8 +usr/share/man/man8/i2cdump.8 +usr/share/man/man8/i2cget.8 +usr/share/man/man8/i2cdetect.8 +usr/sbin/i2cset +usr/sbin/i2cdetect +usr/sbin/i2cget +usr/sbin/i2cdump --- i2c-tools-3.0.2.orig/debian/rules +++ i2c-tools-3.0.2/debian/rules @@ -0,0 +1,116 @@ +#!/usr/bin/make -f + +# Sample debian/rules that uses debhelper. +# GNU copyright 1997 to 1999 by Joey Hess. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# These are used for cross-compiling and for saving the configure script +# from having to guess our platform (since we know it already) +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) +DEB_HOST_GNU_SYSTEM ?= $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM) + +ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) + CFLAGS += -g +endif +ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + INSTALL_PROGRAM += -s +endif + + +DEB_PYTHON_SYSTEM=pysupport +PYVERS = $(shell pyversions -v -r debian/control) + +clean: + dh_testdir + dh_testroot + + $(MAKE) clean + + rm -rf py-smbus/build + rm -f *-stamp* + dh_clean + + +# Build everything that goes into the Debian package. Use recursive make +# invocations to build all of the interesting components. +build: build-stamp-binaries $(PYVERS:%=build-stamp-python-%) + +build-stamp-binaries: + dh_testdir + $(MAKE) CFLAGS="$(CFLAGS)" + touch $@ + +build-stamp-python-%: + dh_testdir + cd py-smbus && \ + CFLAGS="$(CFLAGS) -I../include" python$* setup.py build + touch $@ + +install: install-stamp-binaries $(PYVERS:%=install-stamp-python-%) + +install-stamp-binaries: build-stamp-binaries + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp prefix=/usr + + dh_install --sourcedir=debian/tmp + + touch $@ + +install-stamp-python-%: build-stamp-python-% + dh_testdir + dh_testroot + dh_installdirs + + $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp prefix=/usr + cd py-smbus && \ + CFLAGS="$(CFLAGS) -I../include" python$* setup.py install --root=$(CURDIR)/debian/python-smbus + + touch $@ + + +# Build architecture-independent files here. +binary-indep: build install + dh_testdir + dh_testroot + dh_installchangelogs -i CHANGES + dh_installdocs -i + dh_installman -i + dh_link -i + dh_strip -i + dh_compress -i + dh_fixperms -i + dh_installdeb -i + dh_gencontrol -i + dh_md5sums -i + dh_builddeb -i + +# Build architecture-dependant files that arn't kernel modules here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs -a CHANGES + dh_installdocs -a + dh_installman -a + dh_installudev -a + dh_link -a + dh_strip -a + dh_compress -a + dh_fixperms -a + dh_perl -a + dh_makeshlibs -a + dh_pysupport -a + dh_installdeb -a + dh_shlibdeps -a + dh_gencontrol -a + dh_md5sums -a + dh_builddeb -a + +binary: binary-arch binary-indep +.PHONY: clean build install binary-indep binary-arch binary --- i2c-tools-3.0.2.orig/debian/copyright +++ i2c-tools-3.0.2/debian/copyright @@ -0,0 +1,35 @@ +This package was debianized by Aurelien Jarno . + +It was downloaded from http://www.lm-sensors.org/ + +Copyright + + Copyright (C) 1995-1997 Simon G. Vogl + Copyright (C) 1998-2004 Frodo Looijaard + Copyright (C) 1998, 1999 Philip Edelbrock + Copyright (C) 1998-2004 Mark D. Studebaker + Copyright (C) 2002 James Simmons + Copyright (C) 2002-2007 Jean Delvare + Copyright (c) 2003 Stefano Barbato + Copyright (C) 2005-2007 Mark M. Hoffman + +License: + + 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 with + the Debian GNU/Linux distribution in file /usr/share/common-licenses/GPL; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, + Fifth Floor, Boston, MA 02110-1301 USA + +On Debian systems, the complete text of the GNU General Public +License, version 2, can be found in /usr/share/common-licenses/GPL-2. + --- i2c-tools-3.0.2.orig/debian/compat +++ i2c-tools-3.0.2/debian/compat @@ -0,0 +1 @@ +5 --- i2c-tools-3.0.2.orig/debian/libi2c-dev.preinst +++ i2c-tools-3.0.2/debian/libi2c-dev.preinst @@ -0,0 +1,39 @@ +#! /bin/sh +# preinst script for libi2c-dev +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `install' +# * `install' +# * `upgrade' +# * `abort-upgrade' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + install|upgrade) + dpkg-divert --package libi2c-dev --divert /usr/include/linux/i2c-dev.h.kernel --rename /usr/include/linux/i2c-dev.h + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + --- i2c-tools-3.0.2.orig/debian/libi2c-dev.postrm +++ i2c-tools-3.0.2/debian/libi2c-dev.postrm @@ -0,0 +1,20 @@ +#! /bin/sh +# postrm script for lib-i2c-dev + +set -e + +case "$1" in + remove|purge) + dpkg-divert --package libi2c-dev --rename --remove /usr/include/linux/i2c-dev.h + ;; + upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 0 +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# --- i2c-tools-3.0.2.orig/debian/i2c-tools.postinst +++ i2c-tools-3.0.2/debian/i2c-tools.postinst @@ -0,0 +1,35 @@ +#!/bin/sh + +set -e + +case "$1" in + configure) + # Add the i2c group unless it's already there + if ! getent group i2c >/dev/null; then + addgroup --quiet --system i2c || true + fi + + # Create the device node if MAKEDEV exists + if ! [ -d /dev/.udevdb/ -o -d /dev/.udev/ ] && [ -x /sbin/MAKEDEV ] ; then + if [ ! -c /dev/i2c-0 ]; then + (cd /dev && MAKEDEV i2c) + chmod 0660 /dev/i2c-0 + chown root:i2c /dev/i2c-0 + fi + fi + ;; + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0