29 #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
31 #include <linux/errno.h>
33 #include <linux/kernel.h>
34 #include <linux/module.h>
35 #include <linux/slab.h>
39 #include <linux/input.h>
44 #include <linux/time.h>
48 #define MOD_DESC "Driver for SoundGraph iMON MultiMedia IR/Display"
49 #define MOD_NAME "imon"
50 #define MOD_VERSION "0.9.4"
52 #define DISPLAY_MINOR_BASE 144
53 #define DEVICE_NAME "lcd%d"
55 #define BUF_CHUNK_SIZE 8
58 #define BIT_DURATION 250
60 #define IMON_CLOCK_ENABLE_PACKETS 2
68 static void usb_rx_callback_intf0(
struct urb *
urb);
69 static void usb_rx_callback_intf1(
struct urb *
urb);
70 static void usb_tx_callback(
struct urb *
urb);
82 size_t n_bytes, loff_t *
pos);
86 size_t n_bytes, loff_t *
pos);
154 #define TOUCH_TIMEOUT (HZ/30)
159 .open = &display_open,
161 .release = &display_close,
168 .open = &display_open,
170 .release = &display_close,
206 { USB_DEVICE(0x15c2, 0xffdc) },
214 { USB_DEVICE(0x15c2, 0x0034) },
216 { USB_DEVICE(0x15c2, 0x0035) },
218 { USB_DEVICE(0x15c2, 0x0036) },
220 { USB_DEVICE(0x15c2, 0x0037) },
222 { USB_DEVICE(0x15c2, 0x0038) },
224 { USB_DEVICE(0x15c2, 0x0039) },
226 { USB_DEVICE(0x15c2, 0x003a) },
228 { USB_DEVICE(0x15c2, 0x003b) },
230 { USB_DEVICE(0x15c2, 0x003c) },
232 { USB_DEVICE(0x15c2, 0x003d) },
234 { USB_DEVICE(0x15c2, 0x003e) },
236 { USB_DEVICE(0x15c2, 0x003f) },
238 { USB_DEVICE(0x15c2, 0x0040) },
240 { USB_DEVICE(0x15c2, 0x0041) },
242 { USB_DEVICE(0x15c2, 0x0042) },
244 { USB_DEVICE(0x15c2, 0x0043) },
246 { USB_DEVICE(0x15c2, 0x0044) },
248 { USB_DEVICE(0x15c2, 0x0045) },
250 { USB_DEVICE(0x15c2, 0x0046) },
255 static struct usb_driver imon_driver = {
259 .suspend = imon_suspend,
260 .resume = imon_resume,
261 .id_table = imon_usb_id_table,
264 static struct usb_class_driver imon_vfd_class = {
270 static struct usb_class_driver imon_lcd_class = {
277 static const struct {
280 } imon_panel_key_table[] = {
282 { 0x000000001200ffeell,
KEY_UP },
287 { 0x000000001700ffeell,
KEY_ESC },
291 { 0x000000002700ffeell,
KEY_DVD },
292 { 0x000000002300ffeell,
KEY_TV },
313 { 0x00000012ffffffeell,
KEY_UP },
318 { 0x00000017ffffffeell,
KEY_ESC },
340 static int display_type;
343 "1=vfd, 2=lcd, 3=vga, 4=none (default: autodetect)");
345 static int pad_stabilize = 1;
347 MODULE_PARM_DESC(pad_stabilize,
"Apply stabilization algorithm to iMON PAD "
348 "presses in arrow key mode. 0=disable, 1=enable (default).");
356 MODULE_PARM_DESC(nomouse,
"Disable mouse input device mode when IR device is "
357 "open. 0=don't disable, 1=disable. (default: don't disable)");
360 static int pad_thresh;
362 MODULE_PARM_DESC(pad_thresh,
"Threshold at which a pad push registers as an "
363 "arrow key in kbd mode (default: 28)");
366 static void free_imon_context(
struct imon_context *ictx)
375 dev_dbg(dev,
"%s: iMON context freed\n", __func__);
392 subminor = iminor(inode);
395 pr_err(
"could not find interface for minor %d\n", subminor);
399 ictx = usb_get_intfdata(interface);
402 pr_err(
"no context found for minor %d\n", subminor);
410 pr_err(
"display not supported by device\n");
413 pr_err(
"display port is already open\n");
432 static int display_close(
struct inode *inode,
struct file *file)
440 pr_err(
"no context for device\n");
447 pr_err(
"display not supported by device\n");
450 pr_err(
"display is not open\n");
483 usb_tx_callback, ictx, interval);
485 ictx->
tx_urb->actual_length = 0;
490 if (control_req ==
NULL)
505 pipe, (
unsigned char *)control_req,
508 usb_tx_callback, ictx);
509 ictx->
tx_urb->actual_length = 0;
512 init_completion(&ictx->
tx.finished);
513 ictx->
tx.busy =
true;
518 ictx->
tx.busy =
false;
530 retval = ictx->
tx.status;
557 static int send_associate_24g(
struct imon_context *ictx)
560 const unsigned char packet[8] = { 0x01, 0x00, 0x00, 0x00,
561 0x00, 0x00, 0x00, 0x20 };
564 pr_err(
"no context for device\n");
569 pr_err(
"no iMON device present\n");
586 static int send_set_imon_clock(
struct imon_context *ictx,
588 unsigned int day,
unsigned int dow,
597 pr_err(
"no context for device\n");
603 clock_enable_pkt[0][0] = 0x80;
604 clock_enable_pkt[0][1] =
year;
605 clock_enable_pkt[0][2] = month-1;
606 clock_enable_pkt[0][3] =
day;
607 clock_enable_pkt[0][4] =
hour;
608 clock_enable_pkt[0][5] =
minute;
609 clock_enable_pkt[0][6] =
second;
611 clock_enable_pkt[1][0] = 0x80;
612 clock_enable_pkt[1][1] = 0;
613 clock_enable_pkt[1][2] = 0;
614 clock_enable_pkt[1][3] = 0;
615 clock_enable_pkt[1][4] = 0;
616 clock_enable_pkt[1][5] = 0;
617 clock_enable_pkt[1][6] = 0;
620 clock_enable_pkt[0][7] = 0x50;
621 clock_enable_pkt[1][7] = 0x51;
623 clock_enable_pkt[0][7] = 0x88;
624 clock_enable_pkt[1][7] = 0x8a;
630 clock_enable_pkt[0][0] =
year;
631 clock_enable_pkt[0][1] = month-1;
632 clock_enable_pkt[0][2] =
day;
633 clock_enable_pkt[0][3] = dow;
634 clock_enable_pkt[0][4] =
hour;
635 clock_enable_pkt[0][5] =
minute;
636 clock_enable_pkt[0][6] =
second;
637 clock_enable_pkt[0][7] = 0x40;
639 clock_enable_pkt[1][0] = 0;
640 clock_enable_pkt[1][1] = 0;
641 clock_enable_pkt[1][2] = 1;
642 clock_enable_pkt[1][3] = 0;
643 clock_enable_pkt[1][4] = 0;
644 clock_enable_pkt[1][5] = 0;
645 clock_enable_pkt[1][6] = 0;
646 clock_enable_pkt[1][7] = 0x42;
658 pr_err(
"send_packet failed for packet %d\n", i);
680 strcpy(buf,
"associating\n");
684 dev_info(d,
"Visit http://www.lirc.org/html/imon-24g.html for "
685 "instructions on how to associate your iMON 2.4G DT/LT "
693 const char *buf,
size_t count)
704 send_associate_24g(ictx);
728 "To set the clock on your iMON display:\n"
729 "# date \"+%%y %%m %%d %%w %%H %%M %%S\" > imon_clock\n"
731 "\nNOTE: imon device must be closed\n" :
"");
741 const char *buf,
size_t count)
760 if (
sscanf(buf,
"%u %u %u %u %u %u %u", &year, &month, &day, &dow,
761 &hour, &minute, &second) != 7) {
766 if ((month < 1 || month > 12) ||
767 (day < 1 || day > 31) || (dow > 6) ||
768 (hour > 23) || (minute > 59) || (second > 59)) {
773 retval = send_set_imon_clock(ictx, year, month, day, dow,
774 hour, minute, second);
790 store_associate_remote);
792 static struct attribute *imon_display_sysfs_entries[] = {
793 &dev_attr_imon_clock.attr,
798 .attrs = imon_display_sysfs_entries
801 static struct attribute *imon_rf_sysfs_entries[] = {
802 &dev_attr_associate_remote.attr,
807 .attrs = imon_rf_sysfs_entries
821 static ssize_t vfd_write(
struct file *file,
const char *buf,
822 size_t n_bytes, loff_t *
pos)
829 const unsigned char vfd_packet6[] = {
830 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF };
846 if (n_bytes <= 0 || n_bytes > 32) {
858 for (i = n_bytes; i < 32; ++
i)
859 ictx->
tx.data_buf[i] =
' ';
861 for (i = 32; i < 35; ++
i)
862 ictx->
tx.data_buf[i] = 0xFF;
880 }
while (offset < 35);
892 return (!retval) ? n_bytes :
retval;
908 static ssize_t lcd_write(
struct file *file,
const char *buf,
909 size_t n_bytes, loff_t *pos)
945 dev_dbg(ictx->
dev,
"%s: write %d bytes to LCD\n",
946 __func__, (
int) n_bytes);
950 return (!retval) ? n_bytes :
retval;
956 static void usb_tx_callback(
struct urb *
urb)
966 ictx->
tx.status = urb->status;
969 ictx->
tx.busy =
false;
977 static void imon_touch_display_timeout(
unsigned long data)
987 input_sync(ictx->
touch);
1009 bool unlock =
false;
1010 unsigned char ir_proto_packet[] = {
1011 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 };
1014 dev_warn(dev,
"Looks like you're trying to use an IR protocol "
1015 "this device does not support\n");
1019 dev_dbg(dev,
"Configuring IR receiver for MCE protocol\n");
1020 ir_proto_packet[0] = 0x01;
1024 dev_dbg(dev,
"Configuring IR receiver for iMON protocol\n");
1026 dev_dbg(dev,
"PAD stabilize functionality disabled\n");
1031 dev_warn(dev,
"Unsupported IR protocol specified, overriding "
1032 "to iMON IR protocol\n");
1034 dev_dbg(dev,
"PAD stabilize functionality disabled\n");
1042 if (!mutex_is_locked(&ictx->
lock)) {
1096 static struct timeval hit_time = {0, 0};
1097 static int x,
y, prev_result, hits;
1102 msec = tv2int(&
ct, &prev_time);
1103 msec_hit = tv2int(&
ct, &hit_time);
1116 if (
abs(x) > threshold ||
abs(y) > threshold) {
1118 result = (y > 0) ? 0x7F : 0x80;
1120 result = (x > 0) ? 0x7F00 : 0x8000;
1125 if (result == prev_result) {
1131 y = 17 * threshold / 30;
1134 y -= 17 * threshold / 30;
1137 x = 17 * threshold / 30;
1140 x -= 17 * threshold / 30;
1145 if (hits == 2 && msec_hit < timeout) {
1163 bool is_release_code =
false;
1172 release = scancode & ~0x4000;
1175 is_release_code =
true;
1187 #define MCE_KEY_MASK 0x7000
1188 #define MCE_TOGGLE_BIT 0x8000
1198 if (scancode & 0x80000000)
1215 for (i = 0; i <
ARRAY_SIZE(imon_panel_key_table); i++) {
1216 if (imon_panel_key_table[i].
hw_code == (code | 0xffee)) {
1217 keycode = imon_panel_key_table[
i].keycode;
1225 static bool imon_mouse_event(
struct imon_context *ictx,
1226 unsigned char *buf,
int len)
1232 unsigned long flags;
1237 if (ictx->
product != 0xffdc && (buf[0] & 0x01) && len == 5) {
1242 }
else if (ictx->
product == 0xffdc && (buf[0] & 0x40) &&
1243 !((buf[1] & 0x01) || ((buf[1] >> 2) & 0x01))) {
1244 rel_x = (buf[1] & 0x08) | (buf[1] & 0x10) >> 2 |
1245 (buf[1] & 0x20) >> 4 | (buf[1] & 0x40) >> 6;
1248 rel_x = rel_x + rel_x / 2;
1249 rel_y = (buf[2] & 0x08) | (buf[2] & 0x10) >> 2 |
1250 (buf[2] & 0x20) >> 4 | (buf[2] & 0x40) >> 6;
1256 }
else if (ictx->
product == 0xffdc && (buf[0] == 0x68)) {
1264 mouse_input =
false;
1266 spin_unlock_irqrestore(&ictx->
kc_lock, flags);
1269 dev_dbg(ictx->
dev,
"sending mouse data via input subsystem\n");
1273 }
else if (rel_x ||
rel_y) {
1274 input_report_rel(ictx->
idev,
REL_X, rel_x);
1279 buf[1] >> right_shift & 0x1);
1281 input_sync(ictx->
idev);
1284 spin_unlock_irqrestore(&ictx->
kc_lock, flags);
1290 static void imon_touch_event(
struct imon_context *ictx,
unsigned char *buf)
1293 ictx->
touch_x = (buf[0] << 4) | (buf[1] >> 4);
1294 ictx->
touch_y = 0xfff - ((buf[2] << 4) | (buf[1] & 0xf));
1298 input_sync(ictx->
touch);
1301 static void imon_pad_to_keys(
struct imon_context *ictx,
unsigned char *buf)
1304 char rel_x = 0x00,
rel_y = 0x00;
1307 unsigned long flags;
1317 if (ictx->
product != 0xffdc) {
1319 buf[5] = buf[6] = buf[7] = 0;
1322 threshold = pad_thresh ? pad_thresh : 28;
1327 if ((buf[1] == 0) && ((rel_x != 0) || (
rel_y != 0))) {
1328 dir = stabilize((
int)rel_x, (
int)
rel_y,
1329 timeout, threshold);
1334 spin_unlock_irqrestore(&ictx->
kc_lock,
1338 buf[2] = dir & 0xFF;
1339 buf[3] = (dir >> 8) & 0xFF;
1348 buf[2] = (
rel_y > 0) ? 0x7F : 0x80;
1351 scancode = 0x01007f00;
1353 scancode = 0x01008000;
1356 buf[3] = (rel_x > 0) ? 0x7F : 0x80;
1358 scancode = 0x0100007f;
1360 scancode = 0x01000080;
1377 threshold = pad_thresh ? pad_thresh : 15;
1380 rel_x = (buf[1] & 0x08) | (buf[1] & 0x10) >> 2 |
1381 (buf[1] & 0x20) >> 4 | (buf[1] & 0x40) >> 6;
1385 rel_y = (buf[2] & 0x08) | (buf[2] & 0x10) >> 2 |
1386 (buf[2] & 0x20) >> 4 | (buf[2] & 0x40) >> 6;
1391 buf[1] = buf[4] = buf[5] = buf[6] = buf[7] = 0;
1394 dir = stabilize((
int)rel_x, (
int)
rel_y,
1395 timeout, threshold);
1399 spin_unlock_irqrestore(&ictx->
kc_lock, flags);
1402 buf[2] = dir & 0xFF;
1403 buf[3] = (dir >> 8) & 0xFF;
1411 buf[2] = (
rel_y > 0) ? 0x7F : 0x80;
1414 scancode = 0x01007f00;
1416 scancode = 0x01008000;
1419 buf[3] = (rel_x > 0) ? 0x7F : 0x80;
1421 scancode = 0x0100007f;
1423 scancode = 0x01000080;
1430 ictx->
kc = imon_remote_key_lookup(ictx, scancode);
1431 spin_unlock_irqrestore(&ictx->
kc_lock, flags);
1440 static int imon_parse_press_type(
struct imon_context *ictx,
1444 unsigned long flags;
1449 if (ictx->
kc ==
KEY_RESERVED && buf[0] == 0x02 && buf[3] == 0x00)
1453 else if (ictx->
kc ==
KEY_RESERVED && buf[0] == 0x68 && buf[1] == 0x82 &&
1454 buf[2] == 0x81 && buf[3] == 0xb7)
1458 else if (ictx->
kc ==
KEY_RESERVED && buf[0] == 0x01 && buf[1] == 0x00 &&
1459 buf[2] == 0x81 && buf[3] == 0xb7)
1479 spin_unlock_irqrestore(&ictx->
kc_lock, flags);
1487 static void imon_incoming_packet(
struct imon_context *ictx,
1488 struct urb *urb,
int intf)
1490 int len = urb->actual_length;
1491 unsigned char *buf = urb->transfer_buffer;
1493 unsigned long flags;
1500 static struct timeval prev_time = { 0, 0 };
1504 if ((buf[0] == 0xff) && (buf[1] == 0xff) && (buf[2] == 0xff))
1508 if (len == 8 && buf[7] == 0xee) {
1511 kc = imon_panel_key_lookup(scancode);
1518 kc = imon_mce_key_lookup(ictx, scancode);
1521 kc = imon_remote_key_lookup(ictx, scancode);
1531 dev_dbg(dev,
"toggling to %s mode\n",
1532 ictx->
pad_mouse ?
"mouse" :
"keyboard");
1533 spin_unlock_irqrestore(&ictx->
kc_lock, flags);
1537 dev_dbg(dev,
"mouse mode disabled, passing key value\n");
1542 spin_unlock_irqrestore(&ictx->
kc_lock, flags);
1547 imon_touch_event(ictx, buf);
1552 if (imon_mouse_event(ictx, buf, len))
1557 if (((len == 5) && (buf[0] == 0x01) && (buf[4] == 0x00)) ||
1558 ((len == 8) && (buf[0] & 0x40) &&
1559 !(buf[1] & 0x1 || buf[1] >> 2 & 0x1))) {
1561 imon_pad_to_keys(ictx, buf);
1566 for (i = 0; i < len; ++
i)
1571 press_type = imon_parse_press_type(ictx, buf, ktype);
1573 goto not_input_data;
1578 spin_unlock_irqrestore(&ictx->
kc_lock, flags);
1581 if (press_type == 0)
1587 spin_unlock_irqrestore(&ictx->
kc_lock, flags);
1598 msec = tv2int(&
t, &prev_time);
1600 spin_unlock_irqrestore(&ictx->
kc_lock, flags);
1607 spin_unlock_irqrestore(&ictx->
kc_lock, flags);
1609 input_report_key(ictx->
idev, kc, press_type);
1610 input_sync(ictx->
idev);
1613 input_report_key(ictx->
idev, kc, 0);
1614 input_sync(ictx->
idev);
1618 spin_unlock_irqrestore(&ictx->
kc_lock, flags);
1623 spin_unlock_irqrestore(&ictx->
kc_lock, flags);
1624 dev_info(dev,
"%s: unknown keypress, code 0x%llx\n", __func__,
1625 (
long long)scancode);
1630 dev_warn(dev,
"imon %s: invalid incoming packet "
1631 "size (len = %d, intf%d)\n", __func__, len, intf);
1636 if (buf[0] == 0x00 &&
1641 ((buf[6] == 0x4E && buf[7] == 0xDF) ||
1642 (buf[6] == 0x5E && buf[7] == 0xDF))) {
1643 dev_warn(dev,
"%s: remote associated refid=%02X\n",
1652 static void usb_rx_callback_intf0(
struct urb *urb)
1672 switch (urb->status) {
1680 imon_incoming_packet(ictx, urb, intfnum);
1684 dev_warn(ictx->
dev,
"imon %s: status(%d): ignored\n",
1685 __func__, urb->status);
1693 static void usb_rx_callback_intf1(
struct urb *urb)
1713 switch (urb->status) {
1721 imon_incoming_packet(ictx, urb, intfnum);
1725 dev_warn(ictx->
dev,
"imon %s: status(%d): ignored\n",
1726 __func__, urb->status);
1743 static void imon_get_ffdc_type(
struct imon_context *ictx)
1749 switch (ffdc_cfg_byte) {
1757 dev_info(ictx->
dev,
"0xffdc iMON 2.4G LT, iMON RF");
1763 dev_info(ictx->
dev,
"0xffdc iMON VFD + knob, no IR");
1788 "defaulting to VFD and iMON IR");
1799 ictx->
rc_type = allowed_protos;
1802 static void imon_set_display_type(
struct imon_context *ictx)
1845 dev_info(ictx->
dev,
"%s: overriding display type to %d via "
1856 const unsigned char fp_packet[] = { 0x40, 0x00, 0x00, 0x00,
1857 0x00, 0x00, 0x00, 0x88 };
1861 dev_err(ictx->
dev,
"remote control dev allocation failed\n");
1874 rdev->
dev.parent = ictx->
dev;
1887 dev_info(ictx->
dev,
"panel buttons/knobs setup failed\n");
1889 if (ictx->
product == 0xffdc) {
1890 imon_get_ffdc_type(ictx);
1894 imon_set_display_type(ictx);
1903 dev_err(ictx->
dev,
"remote input dev register failed\n");
1914 static struct input_dev *imon_init_idev(
struct imon_context *ictx)
1916 struct input_dev *
idev;
1919 idev = input_allocate_device();
1921 dev_err(ictx->
dev,
"input dev allocation failed\n");
1926 "iMON Panel, Knob and Mouse(%04x:%04x)",
1943 for (i = 0; i <
ARRAY_SIZE(imon_panel_key_table); i++) {
1944 u32 kc = imon_panel_key_table[
i].keycode;
1949 idev->dev.parent = ictx->
dev;
1950 input_set_drvdata(idev, ictx);
1952 ret = input_register_device(idev);
1954 dev_err(ictx->
dev,
"input dev register failed\n");
1961 input_free_device(idev);
1965 static struct input_dev *imon_init_touch(
struct imon_context *ictx)
1967 struct input_dev *touch;
1970 touch = input_allocate_device();
1972 dev_err(ictx->
dev,
"touchscreen input dev allocation failed\n");
1973 goto touch_alloc_failed;
1977 "iMON USB Touchscreen (%04x:%04x)",
1990 input_set_abs_params(touch,
ABS_X,
1992 input_set_abs_params(touch,
ABS_Y,
1995 input_set_drvdata(touch, ictx);
1998 touch->dev.parent = ictx->
dev;
1999 ret = input_register_device(touch);
2001 dev_info(ictx->
dev,
"touchscreen input dev register failed\n");
2002 goto touch_register_failed;
2007 touch_register_failed:
2008 input_free_device(touch);
2014 static bool imon_find_endpoints(
struct imon_context *ictx,
2015 struct usb_host_interface *iface_desc)
2020 int ifnum = iface_desc->desc.bInterfaceNumber;
2021 int num_endpts = iface_desc->desc.bNumEndpoints;
2023 bool ir_ep_found =
false;
2024 bool display_ep_found =
false;
2032 for (i = 0; i < num_endpts && !(ir_ep_found && display_ep_found); ++
i) {
2033 ep = &iface_desc->endpoint[
i].desc;
2042 dev_dbg(ictx->
dev,
"%s: found IR endpoint\n", __func__);
2044 }
else if (!display_ep_found && ep_dir ==
USB_DIR_OUT &&
2047 display_ep_found =
true;
2048 dev_dbg(ictx->
dev,
"%s: found display endpoint\n", __func__);
2067 if (!display_ep_found) {
2069 display_ep_found =
true;
2070 dev_dbg(ictx->
dev,
"%s: device uses control endpoint, not "
2071 "interface OUT endpoint\n", __func__);
2080 display_ep_found =
false;
2081 dev_dbg(ictx->
dev,
"%s: device has no display\n", __func__);
2089 display_ep_found =
false;
2090 dev_dbg(ictx->
dev,
"%s: iMON Touch device found\n", __func__);
2095 pr_err(
"no valid input (IR) endpoint found\n");
2099 if (display_ep_found)
2111 struct device *dev = &intf->dev;
2112 struct usb_host_interface *iface_desc;
2117 dev_err(dev,
"%s: kzalloc failed for context", __func__);
2122 dev_err(dev,
"%s: usb_alloc_urb failed for IR urb", __func__);
2123 goto rx_urb_alloc_failed;
2127 dev_err(dev,
"%s: usb_alloc_urb failed for display urb",
2129 goto tx_urb_alloc_failed;
2147 iface_desc = intf->cur_altsetting;
2148 if (!imon_find_endpoints(ictx, iface_desc)) {
2149 goto find_endpoint_failed;
2156 usb_rx_callback_intf0, ictx,
2161 pr_err(
"usb_submit_urb failed for intf0 (%d)\n", ret);
2162 goto urb_submit_failed;
2165 ictx->
idev = imon_init_idev(ictx);
2167 dev_err(dev,
"%s: input device setup failed\n", __func__);
2168 goto idev_setup_failed;
2171 ictx->
rdev = imon_init_rdev(ictx);
2173 dev_err(dev,
"%s: rc device setup failed\n", __func__);
2174 goto rdev_setup_failed;
2183 input_unregister_device(ictx->
idev);
2187 find_endpoint_failed:
2190 tx_urb_alloc_failed:
2192 rx_urb_alloc_failed:
2195 dev_err(dev,
"unable to initialize intf0, err %d\n", ret);
2204 struct usb_host_interface *iface_desc;
2209 pr_err(
"usb_alloc_urb failed for IR urb\n");
2210 goto rx_urb_alloc_failed;
2218 ictx->
ttimer.function = imon_touch_display_timeout;
2225 iface_desc = intf->cur_altsetting;
2226 if (!imon_find_endpoints(ictx, iface_desc))
2227 goto find_endpoint_failed;
2230 ictx->
touch = imon_init_touch(ictx);
2232 goto touch_setup_failed;
2240 usb_rx_callback_intf1, ictx,
2246 pr_err(
"usb_submit_urb failed for intf1 (%d)\n", ret);
2247 goto urb_submit_failed;
2257 input_unregister_device(ictx->
touch);
2259 find_endpoint_failed:
2262 rx_urb_alloc_failed:
2263 dev_err(ictx->
dev,
"unable to initialize intf1, err %d\n", ret);
2268 static void imon_init_display(
struct imon_context *ictx,
2273 dev_dbg(ictx->
dev,
"Registering iMON display with sysfs\n");
2278 dev_err(ictx->
dev,
"Could not create display sysfs "
2279 "entries(%d)", ret);
2287 dev_info(ictx->
dev,
"could not get a minor number for "
2298 struct usb_device *usbdev =
NULL;
2299 struct usb_host_interface *iface_desc =
NULL;
2301 struct device *dev = &interface->dev;
2302 int ifnum, sysfs_err;
2308 usbdev =
usb_get_dev(interface_to_usbdev(interface));
2309 iface_desc = interface->cur_altsetting;
2310 ifnum = iface_desc->desc.bInterfaceNumber;
2311 vendor =
le16_to_cpu(usbdev->descriptor.idVendor);
2312 product =
le16_to_cpu(usbdev->descriptor.idProduct);
2314 dev_dbg(dev,
"%s: found iMON device (%04x:%04x, intf%d)\n",
2315 __func__, vendor, product, ifnum);
2321 first_if_ctx = usb_get_intfdata(first_if);
2324 ictx = imon_init_intf0(interface);
2326 pr_err(
"failed to initialize context!\n");
2333 ictx = imon_init_intf1(interface, first_if_ctx);
2335 pr_err(
"failed to attach to context!\n");
2342 usb_set_intfdata(interface, ictx);
2347 if (product == 0xffdc && ictx->
rf_device) {
2349 &imon_rf_attr_group);
2351 pr_err(
"Could not create RF sysfs entries(%d)\n",
2356 imon_init_display(ictx, interface);
2361 dev_info(dev,
"iMON device (%04x:%04x, intf%d) on "
2362 "usb<%d:%d> initialized\n", vendor, product, ifnum,
2363 usbdev->
bus->busnum, usbdev->devnum);
2371 dev_err(dev,
"unable to register, err %d\n", ret);
2388 ictx = usb_get_intfdata(interface);
2390 ifnum = interface->cur_altsetting->desc.bInterfaceNumber;
2399 usb_set_intfdata(interface,
NULL);
2402 if (ictx->
tx.busy) {
2410 input_unregister_device(ictx->
idev);
2422 input_unregister_device(ictx->
touch);
2428 free_imon_context(ictx);
2432 dev_dbg(dev,
"%s: iMON device (intf%d) disconnected\n",
2439 int ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
2453 int ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
2460 usb_rx_callback_intf0, ictx,
2470 usb_rx_callback_intf1, ictx,