hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/media/rc/ir-imon-decoder.c
....@@ -8,7 +8,7 @@
88 #include <linux/module.h>
99 #include "rc-core-priv.h"
1010
11
-#define IMON_UNIT 415662 /* ns */
11
+#define IMON_UNIT 416 /* us */
1212 #define IMON_BITS 30
1313 #define IMON_CHKBITS (BIT(30) | BIT(25) | BIT(24) | BIT(22) | \
1414 BIT(21) | BIT(20) | BIT(19) | BIT(18) | \
....@@ -70,24 +70,13 @@
7070 }
7171
7272 if (!imon->stick_keyboard) {
73
- struct lirc_scancode lsc = {
74
- .scancode = imon->bits,
75
- .rc_proto = RC_PROTO_IMON,
76
- };
73
+ input_report_rel(dev->input_dev, REL_X, rel_x);
74
+ input_report_rel(dev->input_dev, REL_Y, rel_y);
7775
78
- ir_lirc_scancode_event(dev, &lsc);
79
-
80
- input_event(imon->idev, EV_MSC, MSC_SCAN, imon->bits);
81
-
82
- input_report_rel(imon->idev, REL_X, rel_x);
83
- input_report_rel(imon->idev, REL_Y, rel_y);
84
-
85
- input_report_key(imon->idev, BTN_LEFT,
76
+ input_report_key(dev->input_dev, BTN_LEFT,
8677 (imon->bits & 0x00010000) != 0);
87
- input_report_key(imon->idev, BTN_RIGHT,
78
+ input_report_key(dev->input_dev, BTN_RIGHT,
8879 (imon->bits & 0x00040000) != 0);
89
- input_sync(imon->idev);
90
- return;
9180 }
9281 }
9382
....@@ -113,8 +102,7 @@
113102
114103 dev_dbg(&dev->dev,
115104 "iMON decode started at state %d bitno %d (%uus %s)\n",
116
- data->state, data->count, TO_US(ev.duration),
117
- TO_STR(ev.pulse));
105
+ data->state, data->count, ev.duration, TO_STR(ev.pulse));
118106
119107 /*
120108 * Since iMON protocol is a series of bits, if at any point
....@@ -127,7 +115,7 @@
127115 * we're at a new scancode.
128116 */
129117 if (data->state == STATE_ERROR) {
130
- if (!ev.pulse && ev.duration > MS_TO_NS(10))
118
+ if (!ev.pulse && ev.duration > MS_TO_US(10))
131119 data->state = STATE_INACTIVE;
132120 return 0;
133121 }
....@@ -180,8 +168,7 @@
180168 err_out:
181169 dev_dbg(&dev->dev,
182170 "iMON decode failed at state %d bitno %d (%uus %s)\n",
183
- data->state, data->count, TO_US(ev.duration),
184
- TO_STR(ev.pulse));
171
+ data->state, data->count, ev.duration, TO_STR(ev.pulse));
185172
186173 data->state = STATE_ERROR;
187174
....@@ -243,51 +230,9 @@
243230
244231 static int ir_imon_register(struct rc_dev *dev)
245232 {
246
- struct input_dev *idev;
247233 struct imon_dec *imon = &dev->raw->imon;
248
- int ret;
249234
250
- idev = input_allocate_device();
251
- if (!idev)
252
- return -ENOMEM;
253
-
254
- snprintf(imon->name, sizeof(imon->name),
255
- "iMON PAD Stick (%s)", dev->device_name);
256
- idev->name = imon->name;
257
- idev->phys = dev->input_phys;
258
-
259
- /* Mouse bits */
260
- set_bit(EV_REL, idev->evbit);
261
- set_bit(EV_KEY, idev->evbit);
262
- set_bit(REL_X, idev->relbit);
263
- set_bit(REL_Y, idev->relbit);
264
- set_bit(BTN_LEFT, idev->keybit);
265
- set_bit(BTN_RIGHT, idev->keybit);
266
-
267
- /* Report scancodes too */
268
- set_bit(EV_MSC, idev->evbit);
269
- set_bit(MSC_SCAN, idev->mscbit);
270
-
271
- input_set_drvdata(idev, imon);
272
-
273
- ret = input_register_device(idev);
274
- if (ret < 0) {
275
- input_free_device(idev);
276
- return -EIO;
277
- }
278
-
279
- imon->idev = idev;
280235 imon->stick_keyboard = false;
281
-
282
- return 0;
283
-}
284
-
285
-static int ir_imon_unregister(struct rc_dev *dev)
286
-{
287
- struct imon_dec *imon = &dev->raw->imon;
288
-
289
- input_unregister_device(imon->idev);
290
- imon->idev = NULL;
291236
292237 return 0;
293238 }
....@@ -298,7 +243,6 @@
298243 .encode = ir_imon_encode,
299244 .carrier = 38000,
300245 .raw_register = ir_imon_register,
301
- .raw_unregister = ir_imon_unregister,
302246 .min_timeout = IMON_UNIT * IMON_BITS * 2,
303247 };
304248