Lines Matching refs:dev
31 struct i2c_client *hdpvr_register_ir_i2c(struct hdpvr_device *dev) in hdpvr_register_ir_i2c() argument
33 struct IR_i2c_init_data *init_data = &dev->ir_i2c_init_data; in hdpvr_register_ir_i2c()
47 return i2c_new_client_device(&dev->i2c_adapter, &info); in hdpvr_register_ir_i2c()
50 static int hdpvr_i2c_read(struct hdpvr_device *dev, int bus, in hdpvr_i2c_read() argument
56 if ((len > sizeof(dev->i2c_buf)) || (wlen > sizeof(dev->i2c_buf))) in hdpvr_i2c_read()
60 memcpy(dev->i2c_buf, wdata, wlen); in hdpvr_i2c_read()
61 ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), in hdpvr_i2c_read()
63 (bus << 8) | addr, 0, dev->i2c_buf, in hdpvr_i2c_read()
69 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), in hdpvr_i2c_read()
71 (bus << 8) | addr, 0, dev->i2c_buf, len, 1000); in hdpvr_i2c_read()
74 memcpy(data, dev->i2c_buf, len); in hdpvr_i2c_read()
82 static int hdpvr_i2c_write(struct hdpvr_device *dev, int bus, in hdpvr_i2c_write() argument
87 if (len > sizeof(dev->i2c_buf)) in hdpvr_i2c_write()
90 memcpy(dev->i2c_buf, data, len); in hdpvr_i2c_write()
91 ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), in hdpvr_i2c_write()
93 (bus << 8) | addr, 0, dev->i2c_buf, len, 1000); in hdpvr_i2c_write()
98 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), in hdpvr_i2c_write()
100 0, 0, dev->i2c_buf, 2, 1000); in hdpvr_i2c_write()
102 if ((ret == 2) && (dev->i2c_buf[1] == (len - 1))) in hdpvr_i2c_write()
113 struct hdpvr_device *dev = i2c_get_adapdata(i2c_adapter); in hdpvr_transfer() local
116 mutex_lock(&dev->i2c_mutex); in hdpvr_transfer()
122 retval = hdpvr_i2c_read(dev, 1, addr, NULL, 0, in hdpvr_transfer()
125 retval = hdpvr_i2c_write(dev, 1, addr, msgs[0].buf, in hdpvr_transfer()
129 v4l2_warn(&dev->v4l2_dev, "refusing 2-phase i2c xfer with conflicting target addresses\n"); in hdpvr_transfer()
135 v4l2_warn(&dev->v4l2_dev, "refusing complex xfer with r0=%d, r1=%d\n", in hdpvr_transfer()
146 retval = hdpvr_i2c_read(dev, 1, addr, msgs[0].buf, msgs[0].len, in hdpvr_transfer()
149 v4l2_warn(&dev->v4l2_dev, "refusing %d-phase i2c xfer\n", num); in hdpvr_transfer()
153 mutex_unlock(&dev->i2c_mutex); in hdpvr_transfer()
174 static int hdpvr_activate_ir(struct hdpvr_device *dev) in hdpvr_activate_ir() argument
178 mutex_lock(&dev->i2c_mutex); in hdpvr_activate_ir()
180 hdpvr_i2c_read(dev, 0, 0x54, NULL, 0, buffer, 1); in hdpvr_activate_ir()
184 hdpvr_i2c_write(dev, 1, 0x54, buffer, 2); in hdpvr_activate_ir()
187 hdpvr_i2c_write(dev, 1, 0x54, buffer, 2); in hdpvr_activate_ir()
189 mutex_unlock(&dev->i2c_mutex); in hdpvr_activate_ir()
194 int hdpvr_register_i2c_adapter(struct hdpvr_device *dev) in hdpvr_register_i2c_adapter() argument
196 hdpvr_activate_ir(dev); in hdpvr_register_i2c_adapter()
198 dev->i2c_adapter = hdpvr_i2c_adapter_template; in hdpvr_register_i2c_adapter()
199 dev->i2c_adapter.dev.parent = &dev->udev->dev; in hdpvr_register_i2c_adapter()
201 i2c_set_adapdata(&dev->i2c_adapter, dev); in hdpvr_register_i2c_adapter()
203 return i2c_add_adapter(&dev->i2c_adapter); in hdpvr_register_i2c_adapter()