1 // SPDX-License-Identifier: GPL-2.0+
3 // Siano Mobile Silicon, Inc.
4 // MDTV receiver kernel modules.
5 // Copyright (C) 2006-2009, Uri Shkolnik
7 // Copyright (c) 2010 - Mauro Carvalho Chehab
8 // - Ported the driver to use rc-core
9 // - IR raw event decoding is now done at rc-core
10 // - Code almost re-written
13 #include "smscoreapi.h"
15 #include <linux/types.h>
16 #include <linux/input.h>
19 #include "sms-cards.h"
21 #define MODULE_NAME "smsmdtv"
23 void sms_ir_event(struct smscore_device_t
*coredev
, const char *buf
, int len
)
26 const s32
*samples
= (const void *)buf
;
28 for (i
= 0; i
< len
>> 2; i
++) {
29 struct ir_raw_event ev
= {
30 .duration
= abs(samples
[i
]) * 1000, /* Convert to ns */
31 .pulse
= (samples
[i
] > 0) ? false : true
34 ir_raw_event_store(coredev
->ir
.dev
, &ev
);
36 ir_raw_event_handle(coredev
->ir
.dev
);
39 int sms_ir_init(struct smscore_device_t
*coredev
)
42 int board_id
= smscore_get_board_id(coredev
);
45 pr_debug("Allocating rc device\n");
46 dev
= rc_allocate_device(RC_DRIVER_IR_RAW
);
50 coredev
->ir
.controller
= 0; /* Todo: vega/nova SPI number */
51 coredev
->ir
.timeout
= IR_DEFAULT_TIMEOUT
;
52 pr_debug("IR port %d, timeout %d ms\n",
53 coredev
->ir
.controller
, coredev
->ir
.timeout
);
55 snprintf(coredev
->ir
.name
, sizeof(coredev
->ir
.name
),
56 "SMS IR (%s)", sms_get_board(board_id
)->name
);
58 strscpy(coredev
->ir
.phys
, coredev
->devpath
, sizeof(coredev
->ir
.phys
));
59 strlcat(coredev
->ir
.phys
, "/ir0", sizeof(coredev
->ir
.phys
));
61 dev
->device_name
= coredev
->ir
.name
;
62 dev
->input_phys
= coredev
->ir
.phys
;
63 dev
->dev
.parent
= coredev
->device
;
66 /* TODO: properly initialize the parameters below */
67 dev
->input_id
.bustype
= BUS_USB
;
68 dev
->input_id
.version
= 1;
69 dev
->input_id
.vendor
= le16_to_cpu(dev
->udev
->descriptor
.idVendor
);
70 dev
->input_id
.product
= le16_to_cpu(dev
->udev
->descriptor
.idProduct
);
74 dev
->allowed_protocols
= RC_PROTO_BIT_ALL_IR_DECODER
;
75 dev
->map_name
= sms_get_board(board_id
)->rc_codes
;
76 dev
->driver_name
= MODULE_NAME
;
78 pr_debug("Input device (IR) %s is set for key events\n",
81 err
= rc_register_device(dev
);
83 pr_err("Failed to register device\n");
88 coredev
->ir
.dev
= dev
;
92 void sms_ir_exit(struct smscore_device_t
*coredev
)
94 rc_unregister_device(coredev
->ir
.dev
);