forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/media/usb/em28xx/em28xx-input.c
....@@ -24,6 +24,7 @@
2424 #include <linux/delay.h>
2525 #include <linux/interrupt.h>
2626 #include <linux/usb.h>
27
+#include <linux/usb/input.h>
2728 #include <linux/slab.h>
2829 #include <linux/bitrev.h>
2930
....@@ -58,7 +59,6 @@
5859 struct em28xx_IR {
5960 struct em28xx *dev;
6061 struct rc_dev *rc;
61
- char name[32];
6262 char phys[32];
6363
6464 /* poll decoder */
....@@ -277,21 +277,8 @@
277277 break;
278278
279279 case RC_PROTO_BIT_NEC:
280
- poll_result->scancode = msg[1] << 8 | msg[2];
281
- if ((msg[3] ^ msg[4]) != 0xff) { /* 32 bits NEC */
282
- poll_result->protocol = RC_PROTO_NEC32;
283
- poll_result->scancode = RC_SCANCODE_NEC32((msg[1] << 24) |
284
- (msg[2] << 16) |
285
- (msg[3] << 8) |
286
- (msg[4]));
287
- } else if ((msg[1] ^ msg[2]) != 0xff) { /* 24 bits NEC */
288
- poll_result->protocol = RC_PROTO_NECX;
289
- poll_result->scancode = RC_SCANCODE_NECX(msg[1] << 8 |
290
- msg[2], msg[3]);
291
- } else { /* Normal NEC */
292
- poll_result->protocol = RC_PROTO_NEC;
293
- poll_result->scancode = RC_SCANCODE_NEC(msg[1], msg[3]);
294
- }
280
+ poll_result->scancode = ir_nec_bytes_to_scancode(msg[1], msg[2], msg[3], msg[4],
281
+ &poll_result->protocol);
295282 break;
296283
297284 case RC_PROTO_BIT_RC6_0:
....@@ -499,7 +486,7 @@
499486 * at address 0x18, so if that address is needed for another board in
500487 * the future, please put it after 0x1f.
501488 */
502
- const unsigned short addr_list[] = {
489
+ static const unsigned short addr_list[] = {
503490 0x1f, 0x30, 0x47, I2C_CLIENT_END
504491 };
505492
....@@ -617,10 +604,7 @@
617604 set_bit(EM28XX_SNAPSHOT_KEY, input_dev->keybit);
618605 input_dev->keycodesize = 0;
619606 input_dev->keycodemax = 0;
620
- input_dev->id.bustype = BUS_USB;
621
- input_dev->id.vendor = le16_to_cpu(udev->descriptor.idVendor);
622
- input_dev->id.product = le16_to_cpu(udev->descriptor.idProduct);
623
- input_dev->id.version = 1;
607
+ usb_to_input_id(udev, &input_dev->id);
624608 input_dev->dev.parent = &dev->intf->dev;
625609
626610 err = input_register_device(input_dev);
....@@ -833,19 +817,12 @@
833817 /* This is how often we ask the chip for IR information */
834818 ir->polling = 100; /* ms */
835819
836
- /* init input device */
837
- snprintf(ir->name, sizeof(ir->name), "%s IR",
838
- dev_name(&dev->intf->dev));
839
-
840820 usb_make_path(udev, ir->phys, sizeof(ir->phys));
841821 strlcat(ir->phys, "/input0", sizeof(ir->phys));
842822
843
- rc->device_name = ir->name;
823
+ rc->device_name = em28xx_boards[dev->model].name;
844824 rc->input_phys = ir->phys;
845
- rc->input_id.bustype = BUS_USB;
846
- rc->input_id.version = 1;
847
- rc->input_id.vendor = le16_to_cpu(udev->descriptor.idVendor);
848
- rc->input_id.product = le16_to_cpu(udev->descriptor.idProduct);
825
+ usb_to_input_id(udev, &rc->input_id);
849826 rc->dev.parent = &dev->intf->dev;
850827 rc->driver_name = MODULE_NAME;
851828