hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/media/pci/saa7134/saa7134-input.c
....@@ -1,17 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 *
34 * handle saa7134 IR remotes via linux kernel input layer.
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation; either version 2 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
155 */
166
177 #include "saa7134.h"
....@@ -299,43 +289,6 @@
299289 return 1;
300290 }
301291
302
-static int get_key_hvr1110(struct IR_i2c *ir, enum rc_proto *protocol,
303
- u32 *scancode, u8 *toggle)
304
-{
305
- int rc;
306
- unsigned char buf[5];
307
-
308
- /* poll IR chip */
309
- rc = i2c_master_recv(ir->c, buf, 5);
310
- if (rc != 5) {
311
- ir_dbg(ir, "read error\n");
312
- if (rc < 0)
313
- return rc;
314
- return -EIO;
315
- }
316
-
317
- /* Check if some key were pressed */
318
- if (!(buf[0] & 0x80))
319
- return 0;
320
-
321
- /*
322
- * buf[3] & 0x80 is always high.
323
- * buf[3] & 0x40 is a parity bit. A repeat event is marked
324
- * by preserving it into two separate readings
325
- * buf[4] bits 0 and 1, and buf[1] and buf[2] are always
326
- * zero.
327
- *
328
- * Note that the keymap which the hvr1110 uses is RC5.
329
- *
330
- * FIXME: start bits could maybe be used...?
331
- */
332
- *protocol = RC_PROTO_RC5;
333
- *scancode = RC_SCANCODE_RC5(buf[3] & 0x1f, buf[4] >> 2);
334
- *toggle = !!(buf[3] & 0x40);
335
- return 1;
336
-}
337
-
338
-
339292 static int get_key_beholdm6xx(struct IR_i2c *ir, enum rc_proto *protocol,
340293 u32 *scancode, u8 *toggle)
341294 {
....@@ -485,17 +438,10 @@
485438 mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling));
486439 }
487440
488
-static int __saa7134_ir_start(void *priv)
441
+int saa7134_ir_open(struct rc_dev *rc)
489442 {
490
- struct saa7134_dev *dev = priv;
491
- struct saa7134_card_ir *ir;
492
-
493
- if (!dev || !dev->remote)
494
- return -EINVAL;
495
-
496
- ir = dev->remote;
497
- if (ir->running)
498
- return 0;
443
+ struct saa7134_dev *dev = rc->priv;
444
+ struct saa7134_card_ir *ir = dev->remote;
499445
500446 /* Moved here from saa7134_input_init1() because the latter
501447 * is not called on device resume */
....@@ -544,55 +490,15 @@
544490 return 0;
545491 }
546492
547
-static void __saa7134_ir_stop(void *priv)
493
+void saa7134_ir_close(struct rc_dev *rc)
548494 {
549
- struct saa7134_dev *dev = priv;
550
- struct saa7134_card_ir *ir;
551
-
552
- if (!dev || !dev->remote)
553
- return;
554
-
555
- ir = dev->remote;
556
- if (!ir->running)
557
- return;
495
+ struct saa7134_dev *dev = rc->priv;
496
+ struct saa7134_card_ir *ir = dev->remote;
558497
559498 if (ir->polling)
560499 del_timer_sync(&ir->timer);
561500
562501 ir->running = false;
563
-
564
- return;
565
-}
566
-
567
-int saa7134_ir_start(struct saa7134_dev *dev)
568
-{
569
- if (dev->remote->users)
570
- return __saa7134_ir_start(dev);
571
-
572
- return 0;
573
-}
574
-
575
-void saa7134_ir_stop(struct saa7134_dev *dev)
576
-{
577
- if (dev->remote->users)
578
- __saa7134_ir_stop(dev);
579
-}
580
-
581
-static int saa7134_ir_open(struct rc_dev *rc)
582
-{
583
- struct saa7134_dev *dev = rc->priv;
584
-
585
- dev->remote->users++;
586
- return __saa7134_ir_start(dev);
587
-}
588
-
589
-static void saa7134_ir_close(struct rc_dev *rc)
590
-{
591
- struct saa7134_dev *dev = rc->priv;
592
-
593
- dev->remote->users--;
594
- if (!dev->remote->users)
595
- __saa7134_ir_stop(dev);
596502 }
597503
598504 int saa7134_input_init1(struct saa7134_dev *dev)
....@@ -661,7 +567,7 @@
661567 mask_keycode = 0x0007C8;
662568 mask_keydown = 0x000010;
663569 polling = 50; // ms
664
- /* GPIO stuff moved to __saa7134_ir_start() */
570
+ /* GPIO stuff moved to saa7134_ir_open() */
665571 break;
666572 case SAA7134_BOARD_AVERMEDIA_M135A:
667573 ir_codes = RC_MAP_AVERMEDIA_M135A;
....@@ -683,14 +589,14 @@
683589 mask_keycode = 0x02F200;
684590 mask_keydown = 0x000400;
685591 polling = 50; // ms
686
- /* GPIO stuff moved to __saa7134_ir_start() */
592
+ /* GPIO stuff moved to saa7134_ir_open() */
687593 break;
688594 case SAA7134_BOARD_AVERMEDIA_A16D:
689595 ir_codes = RC_MAP_AVERMEDIA_A16D;
690596 mask_keycode = 0x02F200;
691597 mask_keydown = 0x000400;
692598 polling = 50; /* ms */
693
- /* GPIO stuff moved to __saa7134_ir_start() */
599
+ /* GPIO stuff moved to saa7134_ir_open() */
694600 break;
695601 case SAA7134_BOARD_KWORLD_TERMINATOR:
696602 ir_codes = RC_MAP_PIXELVIEW;
....@@ -742,7 +648,7 @@
742648 mask_keycode = 0x0003CC;
743649 mask_keydown = 0x000010;
744650 polling = 5; /* ms */
745
- /* GPIO stuff moved to __saa7134_ir_start() */
651
+ /* GPIO stuff moved to saa7134_ir_open() */
746652 break;
747653 case SAA7134_BOARD_VIDEOMATE_TV_PVR:
748654 case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS:
....@@ -880,8 +786,6 @@
880786 ir->raw_decode = raw_decode;
881787
882788 /* init input device */
883
- snprintf(ir->name, sizeof(ir->name), "saa7134 IR (%s)",
884
- saa7134_boards[dev->board].name);
885789 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
886790 pci_name(dev->pci));
887791
....@@ -893,7 +797,7 @@
893797 rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
894798 }
895799
896
- rc->device_name = ir->name;
800
+ rc->device_name = saa7134_boards[dev->board].name;
897801 rc->input_phys = ir->phys;
898802 rc->input_id.bustype = BUS_PCI;
899803 rc->input_id.version = 1;
....@@ -929,7 +833,6 @@
929833 if (NULL == dev->remote)
930834 return;
931835
932
- saa7134_ir_stop(dev);
933836 rc_unregister_device(dev->remote->dev);
934837 kfree(dev->remote);
935838 dev->remote = NULL;
....@@ -953,7 +856,7 @@
953856
954857 memset(&info, 0, sizeof(struct i2c_board_info));
955858 memset(&dev->init_data, 0, sizeof(dev->init_data));
956
- strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
859
+ strscpy(info.type, "ir_video", I2C_NAME_SIZE);
957860
958861 switch (dev->board) {
959862 case SAA7134_BOARD_PINNACLE_PCTV_110i:
....@@ -1031,9 +934,11 @@
1031934 (1 == rc) ? "yes" : "no");
1032935 break;
1033936 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1034
- dev->init_data.name = "HVR 1110";
1035
- dev->init_data.get_key = get_key_hvr1110;
937
+ dev->init_data.name = saa7134_boards[dev->board].name;
1036938 dev->init_data.ir_codes = RC_MAP_HAUPPAUGE;
939
+ dev->init_data.type = RC_PROTO_BIT_RC5 |
940
+ RC_PROTO_BIT_RC6_MCE | RC_PROTO_BIT_RC6_6A_32;
941
+ dev->init_data.internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
1037942 info.addr = 0x71;
1038943 break;
1039944 case SAA7134_BOARD_BEHOLD_607FM_MK3:
....@@ -1077,7 +982,7 @@
1077982
1078983 if (dev->init_data.name)
1079984 info.platform_data = &dev->init_data;
1080
- i2c_new_device(&dev->i2c_adap, &info);
985
+ i2c_new_client_device(&dev->i2c_adap, &info);
1081986 }
1082987
1083988 static int saa7134_raw_decode_irq(struct saa7134_dev *dev)