]> git.pld-linux.org Git - packages/DirectFB.git/blame - DirectFB-broken-i2c-workaround.patch
- bleh, it was even worse - use fragments of old i2c.h and i2c-dev.h instead of
[packages/DirectFB.git] / DirectFB-broken-i2c-workaround.patch
CommitLineData
7505a4d7 1--- DirectFB-0.9.20/gfxdrivers/matrox/matrox_maven.c.orig 2003-07-08 14:44:19.000000000 +0000
1182e3d1
JB
2+++ DirectFB-0.9.20/gfxdrivers/matrox/matrox_maven.c 2003-11-12 15:16:53.000000000 +0000
3@@ -29,7 +29,61 @@
7505a4d7
JB
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <sys/ioctl.h>
7+/* i2c-dev.h is broken in i2c 2.8.[01] - must include <linux/version.h> first :/
8+ * but <linux/version.h> is included in <linux/i2c.h>, which is needed too
9+ * ...and i2c.h is broken even (MUCH!) more, because it uses internal kernel types
10+ * inside not #ifdef __KERNEL__-ed part!!! argh!!! */
1182e3d1 11+#include <linux/version.h>
7505a4d7 12 #include <linux/i2c-dev.h>
1182e3d1
JB
13+#ifndef I2C_SLAVE
14+/* #include <linux/i2c.h> cannot be used with i2c 2.8.x - it's for internal
15+ * kernel use; stuff below is copied from i2c.h and old i2c-dev.h */
16+#define I2C_SLAVE 0x0703 /* Change slave address */
17+ /* Attn.: Slave address is 7 or 10 bits */
18+/*
19+ * Data for SMBus Messages
20+ */
21+#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */
22+union i2c_smbus_data {
23+ __u8 byte;
24+ __u16 word;
25+ __u8 block[I2C_SMBUS_BLOCK_MAX + 3]; /* block[0] is used for length */
26+ /* one more for read length in block process call */
27+ /* and one more for PEC */
28+};
29+#define I2C_SMBUS 0x0720 /* SMBus-level access */
30+static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command,
31+ int size, union i2c_smbus_data *data)
32+{
33+ struct i2c_smbus_ioctl_data args;
34+
35+ args.read_write = read_write;
36+ args.command = command;
37+ args.size = size;
38+ args.data = data;
39+ return ioctl(file,I2C_SMBUS,&args);
40+}
41+/* smbus_access read or write markers */
42+#define I2C_SMBUS_WRITE 0
43+#define I2C_SMBUS_BYTE_DATA 2
44+#define I2C_SMBUS_WORD_DATA 3
45+static inline __s32 i2c_smbus_write_byte_data(int file, __u8 command,
46+ __u8 value)
47+{
48+ union i2c_smbus_data data;
49+ data.byte = value;
50+ return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
51+ I2C_SMBUS_BYTE_DATA, &data);
52+}
53+static inline __s32 i2c_smbus_write_word_data(int file, __u8 command,
54+ __u16 value)
55+{
56+ union i2c_smbus_data data;
57+ data.word = value;
58+ return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
59+ I2C_SMBUS_WORD_DATA, &data);
60+}
61+#endif
7505a4d7
JB
62
63 #include <misc/memcpy.h>
1182e3d1 64 #include <misc/util.h>
This page took 0.040143 seconds and 4 git commands to generate.