diff options
Diffstat (limited to 'drivers/media/common/siano/smsir.c')
| -rw-r--r-- | drivers/media/common/siano/smsir.c | 75 |
1 files changed, 29 insertions, 46 deletions
diff --git a/drivers/media/common/siano/smsir.c b/drivers/media/common/siano/smsir.c index b8c5cad78537..af07fed21ae1 100644 --- a/drivers/media/common/siano/smsir.c +++ b/drivers/media/common/siano/smsir.c @@ -1,34 +1,20 @@ -/**************************************************************** +// SPDX-License-Identifier: GPL-2.0+ +// +// Siano Mobile Silicon, Inc. +// MDTV receiver kernel modules. +// Copyright (C) 2006-2009, Uri Shkolnik +// +// Copyright (c) 2010 - Mauro Carvalho Chehab +// - Ported the driver to use rc-core +// - IR raw event decoding is now done at rc-core +// - Code almost re-written - Siano Mobile Silicon, Inc. - MDTV receiver kernel modules. - Copyright (C) 2006-2009, Uri Shkolnik - - Copyright (c) 2010 - Mauro Carvalho Chehab - - Ported the driver to use rc-core - - IR raw event decoding is now done at rc-core - - Code almost re-written - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - ****************************************************************/ +#include "smscoreapi.h" #include <linux/types.h> #include <linux/input.h> -#include "smscoreapi.h" #include "smsir.h" #include "sms-cards.h" @@ -40,10 +26,10 @@ void sms_ir_event(struct smscore_device_t *coredev, const char *buf, int len) const s32 *samples = (const void *)buf; for (i = 0; i < len >> 2; i++) { - DEFINE_IR_RAW_EVENT(ev); - - ev.duration = abs(samples[i]) * 1000; /* Convert to ns */ - ev.pulse = (samples[i] > 0) ? false : true; + struct ir_raw_event ev = { + .duration = abs(samples[i]), + .pulse = samples[i] <= 0 + }; ir_raw_event_store(coredev->ir.dev, &ev); } @@ -56,30 +42,28 @@ int sms_ir_init(struct smscore_device_t *coredev) int board_id = smscore_get_board_id(coredev); struct rc_dev *dev; - sms_log("Allocating rc device"); - dev = rc_allocate_device(); - if (!dev) { - sms_err("Not enough memory"); + pr_debug("Allocating rc device\n"); + dev = rc_allocate_device(RC_DRIVER_IR_RAW); + if (!dev) return -ENOMEM; - } coredev->ir.controller = 0; /* Todo: vega/nova SPI number */ - coredev->ir.timeout = IR_DEFAULT_TIMEOUT; - sms_log("IR port %d, timeout %d ms", + coredev->ir.timeout = US_TO_NS(IR_DEFAULT_TIMEOUT); + pr_debug("IR port %d, timeout %d ms\n", coredev->ir.controller, coredev->ir.timeout); snprintf(coredev->ir.name, sizeof(coredev->ir.name), "SMS IR (%s)", sms_get_board(board_id)->name); - strlcpy(coredev->ir.phys, coredev->devpath, sizeof(coredev->ir.phys)); + strscpy(coredev->ir.phys, coredev->devpath, sizeof(coredev->ir.phys)); strlcat(coredev->ir.phys, "/ir0", sizeof(coredev->ir.phys)); - dev->input_name = coredev->ir.name; + dev->device_name = coredev->ir.name; dev->input_phys = coredev->ir.phys; dev->dev.parent = coredev->device; #if 0 - /* TODO: properly initialize the parameters bellow */ + /* TODO: properly initialize the parameters below */ dev->input_id.bustype = BUS_USB; dev->input_id.version = 1; dev->input_id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor); @@ -87,16 +71,16 @@ int sms_ir_init(struct smscore_device_t *coredev) #endif dev->priv = coredev; - dev->driver_type = RC_DRIVER_IR_RAW; - dev->allowed_protos = RC_BIT_ALL; + dev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; dev->map_name = sms_get_board(board_id)->rc_codes; dev->driver_name = MODULE_NAME; - sms_log("Input device (IR) %s is set for key events", dev->input_name); + pr_debug("Input device (IR) %s is set for key events\n", + dev->device_name); err = rc_register_device(dev); if (err < 0) { - sms_err("Failed to register device"); + pr_err("Failed to register device\n"); rc_free_device(dev); return err; } @@ -107,8 +91,7 @@ int sms_ir_init(struct smscore_device_t *coredev) void sms_ir_exit(struct smscore_device_t *coredev) { - if (coredev->ir.dev) - rc_unregister_device(coredev->ir.dev); + rc_unregister_device(coredev->ir.dev); - sms_log(""); + pr_debug("\n"); } |
