Path: blob/master/drivers/media/dvb/mantis/mantis_input.c
15112 views
/*1Mantis PCI bridge driver23Copyright (C) Manu Abraham ([email protected])45This program is free software; you can redistribute it and/or modify6it under the terms of the GNU General Public License as published by7the Free Software Foundation; either version 2 of the License, or8(at your option) any later version.910This program is distributed in the hope that it will be useful,11but WITHOUT ANY WARRANTY; without even the implied warranty of12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13GNU General Public License for more details.1415You should have received a copy of the GNU General Public License16along with this program; if not, write to the Free Software17Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.18*/1920#include <media/rc-core.h>21#include <linux/pci.h>2223#include "dmxdev.h"24#include "dvbdev.h"25#include "dvb_demux.h"26#include "dvb_frontend.h"27#include "dvb_net.h"2829#include "mantis_common.h"30#include "mantis_reg.h"31#include "mantis_uart.h"3233#define MODULE_NAME "mantis_core"34#define RC_MAP_MANTIS "rc-mantis"3536static struct rc_map_table mantis_ir_table[] = {37{ 0x29, KEY_POWER },38{ 0x28, KEY_FAVORITES },39{ 0x30, KEY_TEXT },40{ 0x17, KEY_INFO }, /* Preview */41{ 0x23, KEY_EPG },42{ 0x3b, KEY_F22 }, /* Record List */43{ 0x3c, KEY_1 },44{ 0x3e, KEY_2 },45{ 0x39, KEY_3 },46{ 0x36, KEY_4 },47{ 0x22, KEY_5 },48{ 0x20, KEY_6 },49{ 0x32, KEY_7 },50{ 0x26, KEY_8 },51{ 0x24, KEY_9 },52{ 0x2a, KEY_0 },5354{ 0x33, KEY_CANCEL },55{ 0x2c, KEY_BACK },56{ 0x15, KEY_CLEAR },57{ 0x3f, KEY_TAB },58{ 0x10, KEY_ENTER },59{ 0x14, KEY_UP },60{ 0x0d, KEY_RIGHT },61{ 0x0e, KEY_DOWN },62{ 0x11, KEY_LEFT },6364{ 0x21, KEY_VOLUMEUP },65{ 0x35, KEY_VOLUMEDOWN },66{ 0x3d, KEY_CHANNELDOWN },67{ 0x3a, KEY_CHANNELUP },68{ 0x2e, KEY_RECORD },69{ 0x2b, KEY_PLAY },70{ 0x13, KEY_PAUSE },71{ 0x25, KEY_STOP },7273{ 0x1f, KEY_REWIND },74{ 0x2d, KEY_FASTFORWARD },75{ 0x1e, KEY_PREVIOUS }, /* Replay |< */76{ 0x1d, KEY_NEXT }, /* Skip >| */7778{ 0x0b, KEY_CAMERA }, /* Capture */79{ 0x0f, KEY_LANGUAGE }, /* SAP */80{ 0x18, KEY_MODE }, /* PIP */81{ 0x12, KEY_ZOOM }, /* Full screen */82{ 0x1c, KEY_SUBTITLE },83{ 0x2f, KEY_MUTE },84{ 0x16, KEY_F20 }, /* L/R */85{ 0x38, KEY_F21 }, /* Hibernate */8687{ 0x37, KEY_SWITCHVIDEOMODE }, /* A/V */88{ 0x31, KEY_AGAIN }, /* Recall */89{ 0x1a, KEY_KPPLUS }, /* Zoom+ */90{ 0x19, KEY_KPMINUS }, /* Zoom- */91{ 0x27, KEY_RED },92{ 0x0C, KEY_GREEN },93{ 0x01, KEY_YELLOW },94{ 0x00, KEY_BLUE },95};9697static struct rc_map_list ir_mantis_map = {98.map = {99.scan = mantis_ir_table,100.size = ARRAY_SIZE(mantis_ir_table),101.rc_type = RC_TYPE_UNKNOWN,102.name = RC_MAP_MANTIS,103}104};105106int mantis_input_init(struct mantis_pci *mantis)107{108struct rc_dev *dev;109int err;110111err = rc_map_register(&ir_mantis_map);112if (err)113goto out;114115dev = rc_allocate_device();116if (!dev) {117dprintk(MANTIS_ERROR, 1, "Remote device allocation failed");118err = -ENOMEM;119goto out_map;120}121122sprintf(mantis->input_name, "Mantis %s IR receiver", mantis->hwconfig->model_name);123sprintf(mantis->input_phys, "pci-%s/ir0", pci_name(mantis->pdev));124125dev->input_name = mantis->input_name;126dev->input_phys = mantis->input_phys;127dev->input_id.bustype = BUS_PCI;128dev->input_id.vendor = mantis->vendor_id;129dev->input_id.product = mantis->device_id;130dev->input_id.version = 1;131dev->driver_name = MODULE_NAME;132dev->map_name = RC_MAP_MANTIS;133dev->dev.parent = &mantis->pdev->dev;134135err = rc_register_device(dev);136if (err) {137dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err);138goto out_dev;139}140141mantis->rc = dev;142return 0;143144out_dev:145rc_free_device(dev);146out_map:147rc_map_unregister(&ir_mantis_map);148out:149return err;150}151152int mantis_exit(struct mantis_pci *mantis)153{154rc_unregister_device(mantis->rc);155rc_map_unregister(&ir_mantis_map);156return 0;157}158159160161