aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Young <sean@mess.org>2018-01-06 07:24:50 -0500
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2018-03-21 11:09:44 -0400
commit1b450f211e009d207402ed546837ad5dbbeac276 (patch)
tree3e804927d20ac73c2ffd4b3cd69d87fce4e331cf
parentd60f6e3713ecf56408c38d761ef7fc0ce9510f16 (diff)
media: Revert "[media] staging: lirc_imon: port remaining usb ids to imon and remove"
This code was ported without the necessary hardware to test. There are multiple problems which are more easily solved by writing a separate driver. This reverts commit f41003a23a02dc7299539300f74360c2a932714a. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--drivers/media/rc/imon.c135
1 files changed, 7 insertions, 128 deletions
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 950d068ba806..527920a59d99 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -92,7 +92,6 @@ struct imon_usb_dev_descr {
92 __u16 flags; 92 __u16 flags;
93#define IMON_NO_FLAGS 0 93#define IMON_NO_FLAGS 0
94#define IMON_NEED_20MS_PKT_DELAY 1 94#define IMON_NEED_20MS_PKT_DELAY 1
95#define IMON_IR_RAW 2
96 struct imon_panel_key_table key_table[]; 95 struct imon_panel_key_table key_table[];
97}; 96};
98 97
@@ -123,12 +122,6 @@ struct imon_context {
123 unsigned char usb_tx_buf[8]; 122 unsigned char usb_tx_buf[8];
124 unsigned int send_packet_delay; 123 unsigned int send_packet_delay;
125 124
126 struct rx_data {
127 int count; /* length of 0 or 1 sequence */
128 int prev_bit; /* logic level of sequence */
129 int initial_space; /* initial space flag */
130 } rx;
131
132 struct tx_t { 125 struct tx_t {
133 unsigned char data_buf[35]; /* user data buffer */ 126 unsigned char data_buf[35]; /* user data buffer */
134 struct completion finished; /* wait for write to finish */ 127 struct completion finished; /* wait for write to finish */
@@ -331,10 +324,6 @@ static const struct imon_usb_dev_descr imon_DH102 = {
331 } 324 }
332}; 325};
333 326
334static const struct imon_usb_dev_descr imon_ir_raw = {
335 .flags = IMON_IR_RAW,
336};
337
338/* 327/*
339 * USB Device ID for iMON USB Control Boards 328 * USB Device ID for iMON USB Control Boards
340 * 329 *
@@ -418,18 +407,6 @@ static const struct usb_device_id imon_usb_id_table[] = {
418 /* device specifics unknown */ 407 /* device specifics unknown */
419 { USB_DEVICE(0x15c2, 0x0046), 408 { USB_DEVICE(0x15c2, 0x0046),
420 .driver_info = (unsigned long)&imon_default_table}, 409 .driver_info = (unsigned long)&imon_default_table},
421 /* TriGem iMON (IR only) -- TG_iMON.inf */
422 { USB_DEVICE(0x0aa8, 0x8001),
423 .driver_info = (unsigned long)&imon_ir_raw},
424 /* SoundGraph iMON (IR only) -- sg_imon.inf */
425 { USB_DEVICE(0x04e8, 0xff30),
426 .driver_info = (unsigned long)&imon_ir_raw},
427 /* SoundGraph iMON VFD (IR & VFD) -- iMON_VFD.inf */
428 { USB_DEVICE(0x0aa8, 0xffda),
429 .driver_info = (unsigned long)&imon_ir_raw},
430 /* SoundGraph iMON SS (IR & VFD) -- iMON_SS.inf */
431 { USB_DEVICE(0x15c2, 0xffda),
432 .driver_info = (unsigned long)&imon_ir_raw},
433 {} 410 {}
434}; 411};
435 412
@@ -1572,94 +1549,11 @@ static int imon_parse_press_type(struct imon_context *ictx,
1572/* 1549/*
1573 * Process the incoming packet 1550 * Process the incoming packet
1574 */ 1551 */
1575/* 1552static void imon_incoming_packet(struct imon_context *ictx,
1576 * Convert bit count to time duration (in us) and submit
1577 * the value to lirc_dev.
1578 */
1579static void submit_data(struct imon_context *context)
1580{
1581 DEFINE_IR_RAW_EVENT(ev);
1582
1583 ev.pulse = context->rx.prev_bit;
1584 ev.duration = US_TO_NS(context->rx.count * BIT_DURATION);
1585 ir_raw_event_store_with_filter(context->rdev, &ev);
1586}
1587
1588/*
1589 * Process the incoming packet
1590 */
1591static void imon_incoming_ir_raw(struct imon_context *context,
1592 struct urb *urb, int intf) 1553 struct urb *urb, int intf)
1593{ 1554{
1594 int len = urb->actual_length; 1555 int len = urb->actual_length;
1595 unsigned char *buf = urb->transfer_buffer; 1556 unsigned char *buf = urb->transfer_buffer;
1596 struct device *dev = context->dev;
1597 int octet, bit;
1598 unsigned char mask;
1599
1600 if (len != 8) {
1601 dev_warn(dev, "imon %s: invalid incoming packet size (len = %d, intf%d)\n",
1602 __func__, len, intf);
1603 return;
1604 }
1605
1606 if (debug)
1607 dev_info(dev, "raw packet: %*ph\n", len, buf);
1608 /*
1609 * Translate received data to pulse and space lengths.
1610 * Received data is active low, i.e. pulses are 0 and
1611 * spaces are 1.
1612 *
1613 * My original algorithm was essentially similar to
1614 * Changwoo Ryu's with the exception that he switched
1615 * the incoming bits to active high and also fed an
1616 * initial space to LIRC at the start of a new sequence
1617 * if the previous bit was a pulse.
1618 *
1619 * I've decided to adopt his algorithm.
1620 */
1621
1622 if (buf[7] == 1 && context->rx.initial_space) {
1623 /* LIRC requires a leading space */
1624 context->rx.prev_bit = 0;
1625 context->rx.count = 4;
1626 submit_data(context);
1627 context->rx.count = 0;
1628 }
1629
1630 for (octet = 0; octet < 5; ++octet) {
1631 mask = 0x80;
1632 for (bit = 0; bit < 8; ++bit) {
1633 int curr_bit = !(buf[octet] & mask);
1634
1635 if (curr_bit != context->rx.prev_bit) {
1636 if (context->rx.count) {
1637 submit_data(context);
1638 context->rx.count = 0;
1639 }
1640 context->rx.prev_bit = curr_bit;
1641 }
1642 ++context->rx.count;
1643 mask >>= 1;
1644 }
1645 }
1646
1647 if (buf[7] == 10) {
1648 if (context->rx.count) {
1649 submit_data(context);
1650 context->rx.count = 0;
1651 }
1652 context->rx.initial_space = context->rx.prev_bit;
1653 }
1654
1655 ir_raw_event_handle(context->rdev);
1656}
1657
1658static void imon_incoming_scancode(struct imon_context *ictx,
1659 struct urb *urb, int intf)
1660{
1661 int len = urb->actual_length;
1662 unsigned char *buf = urb->transfer_buffer;
1663 struct device *dev = ictx->dev; 1557 struct device *dev = ictx->dev;
1664 unsigned long flags; 1558 unsigned long flags;
1665 u32 kc; 1559 u32 kc;
@@ -1839,10 +1733,7 @@ static void usb_rx_callback_intf0(struct urb *urb)
1839 break; 1733 break;
1840 1734
1841 case 0: 1735 case 0:
1842 if (ictx->rdev->driver_type == RC_DRIVER_IR_RAW) 1736 imon_incoming_packet(ictx, urb, intfnum);
1843 imon_incoming_ir_raw(ictx, urb, intfnum);
1844 else
1845 imon_incoming_scancode(ictx, urb, intfnum);
1846 break; 1737 break;
1847 1738
1848 default: 1739 default:
@@ -1883,10 +1774,7 @@ static void usb_rx_callback_intf1(struct urb *urb)
1883 break; 1774 break;
1884 1775
1885 case 0: 1776 case 0:
1886 if (ictx->rdev->driver_type == RC_DRIVER_IR_RAW) 1777 imon_incoming_packet(ictx, urb, intfnum);
1887 imon_incoming_ir_raw(ictx, urb, intfnum);
1888 else
1889 imon_incoming_scancode(ictx, urb, intfnum);
1890 break; 1778 break;
1891 1779
1892 default: 1780 default:
@@ -2000,14 +1888,11 @@ static void imon_set_display_type(struct imon_context *ictx)
2000 case 0x0041: 1888 case 0x0041:
2001 case 0x0042: 1889 case 0x0042:
2002 case 0x0043: 1890 case 0x0043:
2003 case 0x8001:
2004 case 0xff30:
2005 configured_display_type = IMON_DISPLAY_TYPE_NONE; 1891 configured_display_type = IMON_DISPLAY_TYPE_NONE;
2006 ictx->display_supported = false; 1892 ictx->display_supported = false;
2007 break; 1893 break;
2008 case 0x0036: 1894 case 0x0036:
2009 case 0x0044: 1895 case 0x0044:
2010 case 0xffda:
2011 default: 1896 default:
2012 configured_display_type = IMON_DISPLAY_TYPE_VFD; 1897 configured_display_type = IMON_DISPLAY_TYPE_VFD;
2013 break; 1898 break;
@@ -2032,8 +1917,7 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
2032 static const unsigned char fp_packet[] = { 1917 static const unsigned char fp_packet[] = {
2033 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88 }; 1918 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88 };
2034 1919
2035 rdev = rc_allocate_device(ictx->dev_descr->flags & IMON_IR_RAW ? 1920 rdev = rc_allocate_device(RC_DRIVER_SCANCODE);
2036 RC_DRIVER_IR_RAW : RC_DRIVER_SCANCODE);
2037 if (!rdev) { 1921 if (!rdev) {
2038 dev_err(ictx->dev, "remote control dev allocation failed\n"); 1922 dev_err(ictx->dev, "remote control dev allocation failed\n");
2039 goto out; 1923 goto out;
@@ -2051,12 +1935,8 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
2051 rdev->dev.parent = ictx->dev; 1935 rdev->dev.parent = ictx->dev;
2052 1936
2053 rdev->priv = ictx; 1937 rdev->priv = ictx;
2054 if (ictx->dev_descr->flags & IMON_IR_RAW) 1938 /* iMON PAD or MCE */
2055 rdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; 1939 rdev->allowed_protocols = RC_PROTO_BIT_OTHER | RC_PROTO_BIT_RC6_MCE;
2056 else
2057 /* iMON PAD or MCE */
2058 rdev->allowed_protocols = RC_PROTO_BIT_OTHER |
2059 RC_PROTO_BIT_RC6_MCE;
2060 rdev->change_protocol = imon_ir_change_protocol; 1940 rdev->change_protocol = imon_ir_change_protocol;
2061 rdev->driver_name = MOD_NAME; 1941 rdev->driver_name = MOD_NAME;
2062 1942
@@ -2074,8 +1954,7 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
2074 1954
2075 imon_set_display_type(ictx); 1955 imon_set_display_type(ictx);
2076 1956
2077 if (ictx->rc_proto == RC_PROTO_BIT_RC6_MCE || 1957 if (ictx->rc_proto == RC_PROTO_BIT_RC6_MCE)
2078 ictx->dev_descr->flags & IMON_IR_RAW)
2079 rdev->map_name = RC_MAP_IMON_MCE; 1958 rdev->map_name = RC_MAP_IMON_MCE;
2080 else 1959 else
2081 rdev->map_name = RC_MAP_IMON_PAD; 1960 rdev->map_name = RC_MAP_IMON_PAD;