Skip to content

Commit f41003a

Browse files
seanyoungmchehab
authored andcommitted
[media] staging: lirc_imon: port remaining usb ids to imon and remove
The staging lirc_imon driver contains 4 usb ids. Two of those have a VFD and two don't. The VFD code is exactly the same in the mainline imon driver, so that part is easily ported. The staging driver produces raw IR rather than scancodes for the four devices, so I've ported the raw IR code from staging to mainline imon. Now that mainline imon can handle these four devices, lirc_imon is no longer needed. Compile tested only. Signed-off-by: Sean Young <[email protected]> Cc: Venky Raju <[email protected]> Cc: Jarod Wilson <[email protected]> Cc: Alexey Khoroshilov <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent d48982f commit f41003a

File tree

4 files changed

+127
-994
lines changed

4 files changed

+127
-994
lines changed

drivers/media/rc/imon.c

Lines changed: 127 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ struct imon_usb_dev_descr {
9292
__u16 flags;
9393
#define IMON_NO_FLAGS 0
9494
#define IMON_NEED_20MS_PKT_DELAY 1
95+
#define IMON_IR_RAW 2
9596
struct imon_panel_key_table key_table[];
9697
};
9798

@@ -122,6 +123,12 @@ struct imon_context {
122123
unsigned char usb_tx_buf[8];
123124
unsigned int send_packet_delay;
124125

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+
125132
struct tx_t {
126133
unsigned char data_buf[35]; /* user data buffer */
127134
struct completion finished; /* wait for write to finish */
@@ -324,6 +331,10 @@ static const struct imon_usb_dev_descr imon_DH102 = {
324331
}
325332
};
326333

334+
static const struct imon_usb_dev_descr imon_ir_raw = {
335+
.flags = IMON_IR_RAW,
336+
};
337+
327338
/*
328339
* USB Device ID for iMON USB Control Boards
329340
*
@@ -407,6 +418,18 @@ static struct usb_device_id imon_usb_id_table[] = {
407418
/* device specifics unknown */
408419
{ USB_DEVICE(0x15c2, 0x0046),
409420
.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},
410433
{}
411434
};
412435

@@ -1573,8 +1596,91 @@ static int imon_parse_press_type(struct imon_context *ictx,
15731596
/**
15741597
* Process the incoming packet
15751598
*/
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,
15771616
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)
15781684
{
15791685
int len = urb->actual_length;
15801686
unsigned char *buf = urb->transfer_buffer;
@@ -1757,7 +1863,10 @@ static void usb_rx_callback_intf0(struct urb *urb)
17571863
break;
17581864

17591865
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);
17611870
break;
17621871

17631872
default:
@@ -1798,7 +1907,10 @@ static void usb_rx_callback_intf1(struct urb *urb)
17981907
break;
17991908

18001909
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);
18021914
break;
18031915

18041916
default:
@@ -1906,11 +2018,14 @@ static void imon_set_display_type(struct imon_context *ictx)
19062018
case 0x0041:
19072019
case 0x0042:
19082020
case 0x0043:
2021+
case 0x8001:
2022+
case 0xff30:
19092023
configured_display_type = IMON_DISPLAY_TYPE_NONE;
19102024
ictx->display_supported = false;
19112025
break;
19122026
case 0x0036:
19132027
case 0x0044:
2028+
case 0xffda:
19142029
default:
19152030
configured_display_type = IMON_DISPLAY_TYPE_VFD;
19162031
break;
@@ -1935,7 +2050,8 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
19352050
const unsigned char fp_packet[] = { 0x40, 0x00, 0x00, 0x00,
19362051
0x00, 0x00, 0x00, 0x88 };
19372052

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);
19392055
if (!rdev) {
19402056
dev_err(ictx->dev, "remote control dev allocation failed\n");
19412057
goto out;
@@ -1953,7 +2069,11 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
19532069
rdev->dev.parent = ictx->dev;
19542070

19552071
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;
19572077
rdev->change_protocol = imon_ir_change_protocol;
19582078
rdev->driver_name = MOD_NAME;
19592079

@@ -1971,7 +2091,8 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
19712091

19722092
imon_set_display_type(ictx);
19732093

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)
19752096
rdev->map_name = RC_MAP_IMON_MCE;
19762097
else
19772098
rdev->map_name = RC_MAP_IMON_PAD;

drivers/staging/media/lirc/Kconfig

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ menuconfig LIRC_STAGING
1212

1313
if LIRC_STAGING
1414

15-
config LIRC_IMON
16-
tristate "Legacy SoundGraph iMON Receiver and Display"
17-
depends on LIRC && USB
18-
help
19-
Driver for the original SoundGraph iMON IR Receiver and Display
20-
21-
Current generation iMON devices use the input layer imon driver.
22-
2315
config LIRC_SASEM
2416
tristate "Sasem USB IR Remote"
2517
depends on LIRC && USB

drivers/staging/media/lirc/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
# Each configuration option enables a list of files.
55

6-
obj-$(CONFIG_LIRC_IMON) += lirc_imon.o
76
obj-$(CONFIG_LIRC_SASEM) += lirc_sasem.o
87
obj-$(CONFIG_LIRC_SIR) += lirc_sir.o
98
obj-$(CONFIG_LIRC_ZILOG) += lirc_zilog.o

0 commit comments

Comments
 (0)