16 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
18 #include <linux/i2c.h>
19 #include <linux/slab.h>
20 #include <linux/export.h>
24 #define CTRL_READ_REQUEST 0xb8
25 #define CTRL_WRITE_REQUEST 0x38
27 #define REQTYPE_I2C_READ 0xb1
28 #define REQTYPE_I2C_WRITE 0xb0
29 #define REQTYPE_I2C_WRITE_STATT 0xd0
31 #define Z8F0811_IR_TX_I2C_ADDR 0x70
32 #define Z8F0811_IR_RX_I2C_ADDR 0x71
42 init_data->
name =
"HD-PVR";
59 init_data->
name =
"HD-PVR";
67 unsigned char addr,
char *wdata,
int wlen,
78 REQTYPE_I2C_WRITE, CTRL_WRITE_REQUEST,
79 (bus << 8) | addr, 0, &dev->
i2c_buf,
86 REQTYPE_I2C_READ, CTRL_READ_REQUEST,
87 (bus << 8) | addr, 0, &dev->
i2c_buf, len, 1000);
98 static int hdpvr_i2c_write(
struct hdpvr_device *dev,
int bus,
99 unsigned char addr,
char *data,
int len)
103 if (len >
sizeof(dev->
i2c_buf))
108 REQTYPE_I2C_WRITE, CTRL_WRITE_REQUEST,
109 (bus << 8) | addr, 0, &dev->
i2c_buf, len, 1000);
115 REQTYPE_I2C_WRITE_STATT, CTRL_READ_REQUEST,
118 if ((ret == 2) && (dev->
i2c_buf[1] == (len - 1)))
129 struct hdpvr_device *dev = i2c_get_adapdata(i2c_adapter);
137 addr = msgs[0].
addr << 1;
141 retval = hdpvr_i2c_read(dev, 1, addr,
NULL, 0,
142 msgs[0].
buf, msgs[0].len);
144 retval = hdpvr_i2c_write(dev, 1, addr, msgs[0].
buf,
146 }
else if (num == 2) {
147 if (msgs[0].addr != msgs[1].addr) {
149 "with conflicting target addresses\n");
156 "r0=%d, r1=%d\n", msgs[0].
flags & I2C_M_RD,
157 msgs[1].
flags & I2C_M_RD);
166 retval = hdpvr_i2c_read(dev, 1, addr, msgs[0].
buf, msgs[0].len,
167 msgs[1].buf, msgs[1].len);
175 return retval ? retval : num;
178 static u32 hdpvr_functionality(
struct i2c_adapter *
adapter)
185 .functionality = hdpvr_functionality,
188 static struct i2c_adapter hdpvr_i2c_adapter_template = {
189 .
name =
"Hauppage HD PVR I2C",
200 hdpvr_i2c_read(dev, 0, 0x54,
NULL, 0, buffer, 1);
204 hdpvr_i2c_write(dev, 1, 0x54, buffer, 2);
207 hdpvr_i2c_write(dev, 1, 0x54, buffer, 2);
218 hdpvr_activate_ir(dev);
221 sizeof(
struct i2c_adapter));