@@ -92,6 +92,7 @@ struct imon_usb_dev_descr {
92
92
__u16 flags ;
93
93
#define IMON_NO_FLAGS 0
94
94
#define IMON_NEED_20MS_PKT_DELAY 1
95
+ #define IMON_IR_RAW 2
95
96
struct imon_panel_key_table key_table [];
96
97
};
97
98
@@ -122,6 +123,12 @@ struct imon_context {
122
123
unsigned char usb_tx_buf [8 ];
123
124
unsigned int send_packet_delay ;
124
125
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
+
125
132
struct tx_t {
126
133
unsigned char data_buf [35 ]; /* user data buffer */
127
134
struct completion finished ; /* wait for write to finish */
@@ -324,6 +331,10 @@ static const struct imon_usb_dev_descr imon_DH102 = {
324
331
}
325
332
};
326
333
334
+ static const struct imon_usb_dev_descr imon_ir_raw = {
335
+ .flags = IMON_IR_RAW ,
336
+ };
337
+
327
338
/*
328
339
* USB Device ID for iMON USB Control Boards
329
340
*
@@ -407,6 +418,18 @@ static struct usb_device_id imon_usb_id_table[] = {
407
418
/* device specifics unknown */
408
419
{ USB_DEVICE (0x15c2 , 0x0046 ),
409
420
.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 },
410
433
{}
411
434
};
412
435
@@ -1573,8 +1596,91 @@ static int imon_parse_press_type(struct imon_context *ictx,
1573
1596
/**
1574
1597
* Process the incoming packet
1575
1598
*/
1576
- static void imon_incoming_packet (struct imon_context * ictx ,
1599
+ /**
1600
+ * Convert bit count to time duration (in us) and submit
1601
+ * the value to lirc_dev.
1602
+ */
1603
+ static void submit_data (struct imon_context * context )
1604
+ {
1605
+ DEFINE_IR_RAW_EVENT (ev );
1606
+
1607
+ ev .pulse = context -> rx .prev_bit ;
1608
+ ev .duration = US_TO_NS (context -> rx .count * BIT_DURATION );
1609
+ ir_raw_event_store_with_filter (context -> rdev , & ev );
1610
+ }
1611
+
1612
+ /**
1613
+ * Process the incoming packet
1614
+ */
1615
+ static void imon_incoming_ir_raw (struct imon_context * context ,
1577
1616
struct urb * urb , int intf )
1617
+ {
1618
+ int len = urb -> actual_length ;
1619
+ unsigned char * buf = urb -> transfer_buffer ;
1620
+ struct device * dev = context -> dev ;
1621
+ int octet , bit ;
1622
+ unsigned char mask ;
1623
+
1624
+ if (len != 8 ) {
1625
+ dev_warn (dev , "imon %s: invalid incoming packet size (len = %d, intf%d)\n" ,
1626
+ __func__ , len , intf );
1627
+ return ;
1628
+ }
1629
+
1630
+ if (debug )
1631
+ dev_info (dev , "raw packet: %*ph\n" , len , buf );
1632
+ /*
1633
+ * Translate received data to pulse and space lengths.
1634
+ * Received data is active low, i.e. pulses are 0 and
1635
+ * spaces are 1.
1636
+ *
1637
+ * My original algorithm was essentially similar to
1638
+ * Changwoo Ryu's with the exception that he switched
1639
+ * the incoming bits to active high and also fed an
1640
+ * initial space to LIRC at the start of a new sequence
1641
+ * if the previous bit was a pulse.
1642
+ *
1643
+ * I've decided to adopt his algorithm.
1644
+ */
1645
+
1646
+ if (buf [7 ] == 1 && context -> rx .initial_space ) {
1647
+ /* LIRC requires a leading space */
1648
+ context -> rx .prev_bit = 0 ;
1649
+ context -> rx .count = 4 ;
1650
+ submit_data (context );
1651
+ context -> rx .count = 0 ;
1652
+ }
1653
+
1654
+ for (octet = 0 ; octet < 5 ; ++ octet ) {
1655
+ mask = 0x80 ;
1656
+ for (bit = 0 ; bit < 8 ; ++ bit ) {
1657
+ int curr_bit = !(buf [octet ] & mask );
1658
+
1659
+ if (curr_bit != context -> rx .prev_bit ) {
1660
+ if (context -> rx .count ) {
1661
+ submit_data (context );
1662
+ context -> rx .count = 0 ;
1663
+ }
1664
+ context -> rx .prev_bit = curr_bit ;
1665
+ }
1666
+ ++ context -> rx .count ;
1667
+ mask >>= 1 ;
1668
+ }
1669
+ }
1670
+
1671
+ if (buf [7 ] == 10 ) {
1672
+ if (context -> rx .count ) {
1673
+ submit_data (context );
1674
+ context -> rx .count = 0 ;
1675
+ }
1676
+ context -> rx .initial_space = context -> rx .prev_bit ;
1677
+ }
1678
+
1679
+ ir_raw_event_handle (context -> rdev );
1680
+ }
1681
+
1682
+ static void imon_incoming_scancode (struct imon_context * ictx ,
1683
+ struct urb * urb , int intf )
1578
1684
{
1579
1685
int len = urb -> actual_length ;
1580
1686
unsigned char * buf = urb -> transfer_buffer ;
@@ -1757,7 +1863,10 @@ static void usb_rx_callback_intf0(struct urb *urb)
1757
1863
break ;
1758
1864
1759
1865
case 0 :
1760
- imon_incoming_packet (ictx , urb , intfnum );
1866
+ if (ictx -> rdev -> driver_type == RC_DRIVER_IR_RAW )
1867
+ imon_incoming_ir_raw (ictx , urb , intfnum );
1868
+ else
1869
+ imon_incoming_scancode (ictx , urb , intfnum );
1761
1870
break ;
1762
1871
1763
1872
default :
@@ -1798,7 +1907,10 @@ static void usb_rx_callback_intf1(struct urb *urb)
1798
1907
break ;
1799
1908
1800
1909
case 0 :
1801
- imon_incoming_packet (ictx , urb , intfnum );
1910
+ if (ictx -> rdev -> driver_type == RC_DRIVER_IR_RAW )
1911
+ imon_incoming_ir_raw (ictx , urb , intfnum );
1912
+ else
1913
+ imon_incoming_scancode (ictx , urb , intfnum );
1802
1914
break ;
1803
1915
1804
1916
default :
@@ -1906,11 +2018,14 @@ static void imon_set_display_type(struct imon_context *ictx)
1906
2018
case 0x0041 :
1907
2019
case 0x0042 :
1908
2020
case 0x0043 :
2021
+ case 0x8001 :
2022
+ case 0xff30 :
1909
2023
configured_display_type = IMON_DISPLAY_TYPE_NONE ;
1910
2024
ictx -> display_supported = false;
1911
2025
break ;
1912
2026
case 0x0036 :
1913
2027
case 0x0044 :
2028
+ case 0xffda :
1914
2029
default :
1915
2030
configured_display_type = IMON_DISPLAY_TYPE_VFD ;
1916
2031
break ;
@@ -1935,7 +2050,8 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
1935
2050
const unsigned char fp_packet [] = { 0x40 , 0x00 , 0x00 , 0x00 ,
1936
2051
0x00 , 0x00 , 0x00 , 0x88 };
1937
2052
1938
- rdev = rc_allocate_device (RC_DRIVER_SCANCODE );
2053
+ rdev = rc_allocate_device (ictx -> dev_descr -> flags & IMON_IR_RAW ?
2054
+ RC_DRIVER_IR_RAW : RC_DRIVER_SCANCODE );
1939
2055
if (!rdev ) {
1940
2056
dev_err (ictx -> dev , "remote control dev allocation failed\n" );
1941
2057
goto out ;
@@ -1953,7 +2069,11 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
1953
2069
rdev -> dev .parent = ictx -> dev ;
1954
2070
1955
2071
rdev -> priv = ictx ;
1956
- rdev -> allowed_protocols = RC_BIT_OTHER | RC_BIT_RC6_MCE ; /* iMON PAD or MCE */
2072
+ if (ictx -> dev_descr -> flags & IMON_IR_RAW )
2073
+ rdev -> allowed_protocols = RC_BIT_ALL_IR_DECODER ;
2074
+ else
2075
+ /* iMON PAD or MCE */
2076
+ rdev -> allowed_protocols = RC_BIT_OTHER | RC_BIT_RC6_MCE ;
1957
2077
rdev -> change_protocol = imon_ir_change_protocol ;
1958
2078
rdev -> driver_name = MOD_NAME ;
1959
2079
@@ -1971,7 +2091,8 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
1971
2091
1972
2092
imon_set_display_type (ictx );
1973
2093
1974
- if (ictx -> rc_type == RC_BIT_RC6_MCE )
2094
+ if (ictx -> rc_type == RC_BIT_RC6_MCE ||
2095
+ ictx -> dev_descr -> flags & IMON_IR_RAW )
1975
2096
rdev -> map_name = RC_MAP_IMON_MCE ;
1976
2097
else
1977
2098
rdev -> map_name = RC_MAP_IMON_PAD ;
0 commit comments