Lines Matching +full:pulse +full:- +full:width
1 // SPDX-License-Identifier: GPL-2.0+
7 // Based on em28xx-input.c.
17 #include <media/rc-core.h>
47 struct i2c_msg msg = { .addr = ir->i2c_dev_addr, .flags = 0, in au8522_rc_write()
50 rc = i2c_transfer(ir->dev->i2c_client.adapter, &msg, 1); in au8522_rc_write()
55 return (rc == 1) ? 0 : -EIO; in au8522_rc_write()
63 struct i2c_msg msg[2] = { { .addr = ir->i2c_dev_addr, .flags = 0, in au8522_rc_read()
65 { .addr = ir->i2c_dev_addr, .flags = I2C_M_RD, in au8522_rc_read()
75 rc = i2c_transfer(ir->dev->i2c_client.adapter, msg, 2); in au8522_rc_read()
80 return (rc == 2) ? 0 : -EIO; in au8522_rc_read()
88 rc = au8522_rc_read(ir, reg, -1, &buf, 1); in au8522_rc_andor()
118 int prv_bit, bit, width; in au0828_get_key_au8522() local
122 if (test_bit(DEV_DISCONNECTED, &ir->dev->dev_state)) in au0828_get_key_au8522()
126 rc = au8522_rc_read(ir, 0xe1, -1, buf, 1); in au0828_get_key_au8522()
149 width = 0; in au0828_get_key_au8522()
151 for (j = 7; j >= 0; j--) { in au0828_get_key_au8522()
154 width++; in au0828_get_key_au8522()
159 * Fix an au8522 bug: the first pulse event in au0828_get_key_au8522()
170 rawir.pulse = true; in au0828_get_key_au8522()
171 if (width > NEC_START_SPACE - 2 && in au0828_get_key_au8522()
172 width < NEC_START_SPACE + 2) { in au0828_get_key_au8522()
176 rawir.pulse ? "pulse" : "space", in au0828_get_key_au8522()
182 rawir.pulse ? "pulse" : "space", in au0828_get_key_au8522()
185 ir_raw_event_store(ir->rc, &rawir); in au0828_get_key_au8522()
188 rawir.pulse = prv_bit ? false : true; in au0828_get_key_au8522()
189 rawir.duration = AU8522_UNIT * width; in au0828_get_key_au8522()
191 rawir.pulse ? "pulse" : "space", in au0828_get_key_au8522()
193 ir_raw_event_store(ir->rc, &rawir); in au0828_get_key_au8522()
195 width = 1; in au0828_get_key_au8522()
200 rawir.pulse = prv_bit ? false : true; in au0828_get_key_au8522()
201 rawir.duration = AU8522_UNIT * width; in au0828_get_key_au8522()
203 rawir.pulse ? "pulse" : "space", in au0828_get_key_au8522()
205 ir_raw_event_store(ir->rc, &rawir); in au0828_get_key_au8522()
207 ir_raw_event_handle(ir->rc); in au0828_get_key_au8522()
221 rc = ir->get_key_i2c(ir); in au0828_rc_work()
225 schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling)); in au0828_rc_work()
230 struct au0828_rc *ir = rc->priv; in au0828_rc_start()
232 INIT_DELAYED_WORK(&ir->work, au0828_rc_work); in au0828_rc_start()
237 schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling)); in au0828_rc_start()
244 struct au0828_rc *ir = rc->priv; in au0828_rc_stop()
246 cancel_delayed_work_sync(&ir->work); in au0828_rc_stop()
249 if (!test_bit(DEV_DISCONNECTED, &ir->dev->dev_state)) { in au0828_rc_stop()
263 if (i2c_probe_func_quick_read(dev->i2c_client.adapter, in au0828_probe_i2c_ir()
269 return -ENODEV; in au0828_probe_i2c_ir()
276 int err = -ENOMEM; in au0828_rc_register()
279 if (!dev->board.has_ir_i2c || disable_ir) in au0828_rc_register()
284 return -ENODEV; in au0828_rc_register()
292 ir->dev = dev; in au0828_rc_register()
293 dev->ir = ir; in au0828_rc_register()
294 ir->rc = rc; in au0828_rc_register()
296 rc->priv = ir; in au0828_rc_register()
297 rc->open = au0828_rc_start; in au0828_rc_register()
298 rc->close = au0828_rc_stop; in au0828_rc_register()
300 if (dev->board.has_ir_i2c) { /* external i2c device */ in au0828_rc_register()
301 switch (dev->boardnr) { in au0828_rc_register()
303 rc->map_name = RC_MAP_HAUPPAUGE; in au0828_rc_register()
304 ir->get_key_i2c = au0828_get_key_au8522; in au0828_rc_register()
307 err = -ENODEV; in au0828_rc_register()
311 ir->i2c_dev_addr = i2c_rc_dev_addr; in au0828_rc_register()
315 ir->polling = 100; /* ms */ in au0828_rc_register()
318 snprintf(ir->name, sizeof(ir->name), "au0828 IR (%s)", in au0828_rc_register()
319 dev->board.name); in au0828_rc_register()
321 usb_make_path(dev->usbdev, ir->phys, sizeof(ir->phys)); in au0828_rc_register()
322 strlcat(ir->phys, "/input0", sizeof(ir->phys)); in au0828_rc_register()
324 rc->device_name = ir->name; in au0828_rc_register()
325 rc->input_phys = ir->phys; in au0828_rc_register()
326 rc->input_id.bustype = BUS_USB; in au0828_rc_register()
327 rc->input_id.version = 1; in au0828_rc_register()
328 rc->input_id.vendor = le16_to_cpu(dev->usbdev->descriptor.idVendor); in au0828_rc_register()
329 rc->input_id.product = le16_to_cpu(dev->usbdev->descriptor.idProduct); in au0828_rc_register()
330 rc->dev.parent = &dev->usbdev->dev; in au0828_rc_register()
331 rc->driver_name = "au0828-input"; in au0828_rc_register()
332 rc->allowed_protocols = RC_PROTO_BIT_NEC | RC_PROTO_BIT_NECX | in au0828_rc_register()
340 pr_info("Remote controller %s initialized\n", ir->name); in au0828_rc_register()
345 dev->ir = NULL; in au0828_rc_register()
353 struct au0828_rc *ir = dev->ir; in au0828_rc_unregister()
359 rc_unregister_device(ir->rc); in au0828_rc_unregister()
363 dev->ir = NULL; in au0828_rc_unregister()
368 struct au0828_rc *ir = dev->ir; in au0828_rc_suspend()
375 cancel_delayed_work_sync(&ir->work); in au0828_rc_suspend()
385 struct au0828_rc *ir = dev->ir; in au0828_rc_resume()
395 schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling)); in au0828_rc_resume()