diff options
| -rw-r--r-- | drivers/media/dvb/mantis/Makefile | 3 | ||||
| -rw-r--r-- | drivers/media/dvb/mantis/mantis_cards.c | 14 | ||||
| -rw-r--r-- | drivers/media/dvb/mantis/mantis_common.h | 2 | ||||
| -rw-r--r-- | drivers/media/dvb/mantis/mantis_input.c | 147 | ||||
| -rw-r--r-- | drivers/media/dvb/mantis/mantis_uart.c | 55 | ||||
| -rw-r--r-- | drivers/media/dvb/mantis/mantis_uart.h | 3 |
6 files changed, 209 insertions, 15 deletions
diff --git a/drivers/media/dvb/mantis/Makefile b/drivers/media/dvb/mantis/Makefile index 399c9018cdb0..98dc5cd258ac 100644 --- a/drivers/media/dvb/mantis/Makefile +++ b/drivers/media/dvb/mantis/Makefile | |||
| @@ -7,7 +7,8 @@ mantis_core-objs := mantis_ioc.o \ | |||
| 7 | mantis_evm.o \ | 7 | mantis_evm.o \ |
| 8 | mantis_hif.o \ | 8 | mantis_hif.o \ |
| 9 | mantis_ca.o \ | 9 | mantis_ca.o \ |
| 10 | mantis_pcmcia.o | 10 | mantis_pcmcia.o \ |
| 11 | mantis_input.o | ||
| 11 | 12 | ||
| 12 | mantis-objs := mantis_cards.o \ | 13 | mantis-objs := mantis_cards.o \ |
| 13 | mantis_vp1033.o \ | 14 | mantis_vp1033.o \ |
diff --git a/drivers/media/dvb/mantis/mantis_cards.c b/drivers/media/dvb/mantis/mantis_cards.c index 0b52f996f8e1..f3fefbbc876f 100644 --- a/drivers/media/dvb/mantis/mantis_cards.c +++ b/drivers/media/dvb/mantis/mantis_cards.c | |||
| @@ -194,9 +194,21 @@ static int __devinit mantis_pci_probe(struct pci_dev *pdev, const struct pci_dev | |||
| 194 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization failed <%d>", err); | 194 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization failed <%d>", err); |
| 195 | goto fail4; | 195 | goto fail4; |
| 196 | } | 196 | } |
| 197 | err = mantis_uart_init(mantis); | ||
| 198 | if (err < 0) { | ||
| 199 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART initialization failed <%d>", err); | ||
| 200 | goto fail6; | ||
| 201 | } | ||
| 202 | |||
| 197 | devs++; | 203 | devs++; |
| 198 | 204 | ||
| 199 | return err; | 205 | return err; |
| 206 | |||
| 207 | |||
| 208 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART exit! <%d>", err); | ||
| 209 | mantis_uart_exit(mantis); | ||
| 210 | |||
| 211 | fail6: | ||
| 200 | fail4: | 212 | fail4: |
| 201 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA exit! <%d>", err); | 213 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA exit! <%d>", err); |
| 202 | mantis_dma_exit(mantis); | 214 | mantis_dma_exit(mantis); |
| @@ -222,6 +234,8 @@ static void __devexit mantis_pci_remove(struct pci_dev *pdev) | |||
| 222 | struct mantis_pci *mantis = pci_get_drvdata(pdev); | 234 | struct mantis_pci *mantis = pci_get_drvdata(pdev); |
| 223 | 235 | ||
| 224 | if (mantis) { | 236 | if (mantis) { |
| 237 | |||
| 238 | mantis_uart_exit(mantis); | ||
| 225 | mantis_dvb_exit(mantis); | 239 | mantis_dvb_exit(mantis); |
| 226 | mantis_dma_exit(mantis); | 240 | mantis_dma_exit(mantis); |
| 227 | mantis_i2c_exit(mantis); | 241 | mantis_i2c_exit(mantis); |
diff --git a/drivers/media/dvb/mantis/mantis_common.h b/drivers/media/dvb/mantis/mantis_common.h index 6ae3aabe5604..c2d085460e60 100644 --- a/drivers/media/dvb/mantis/mantis_common.h +++ b/drivers/media/dvb/mantis/mantis_common.h | |||
| @@ -170,6 +170,8 @@ struct mantis_pci { | |||
| 170 | wait_queue_head_t uart_wq; | 170 | wait_queue_head_t uart_wq; |
| 171 | struct work_struct uart_work; | 171 | struct work_struct uart_work; |
| 172 | spinlock_t uart_lock; | 172 | spinlock_t uart_lock; |
| 173 | |||
| 174 | struct input_dev *rc; | ||
| 173 | }; | 175 | }; |
| 174 | 176 | ||
| 175 | #define MANTIS_HIF_STATUS (mantis->gpio_status) | 177 | #define MANTIS_HIF_STATUS (mantis->gpio_status) |
diff --git a/drivers/media/dvb/mantis/mantis_input.c b/drivers/media/dvb/mantis/mantis_input.c new file mode 100644 index 000000000000..9395fcf4a453 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_input.c | |||
| @@ -0,0 +1,147 @@ | |||
| 1 | /* | ||
| 2 | Mantis PCI bridge driver | ||
| 3 | |||
| 4 | Copyright (C) Manu Abraham (abraham.manu@gmail.com) | ||
| 5 | |||
| 6 | This program is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with this program; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include <linux/input.h> | ||
| 22 | #include <media/ir-common.h> | ||
| 23 | #include <linux/pci.h> | ||
| 24 | |||
| 25 | #include "dmxdev.h" | ||
| 26 | #include "dvbdev.h" | ||
| 27 | #include "dvb_demux.h" | ||
| 28 | #include "dvb_frontend.h" | ||
| 29 | #include "dvb_net.h" | ||
| 30 | |||
| 31 | #include "mantis_common.h" | ||
| 32 | #include "mantis_reg.h" | ||
| 33 | #include "mantis_uart.h" | ||
| 34 | |||
| 35 | static struct ir_scancode mantis_ir_table[] = { | ||
| 36 | { 0x29, KEY_POWER }, | ||
| 37 | { 0x28, KEY_FAVORITES }, | ||
| 38 | { 0x30, KEY_TEXT }, | ||
| 39 | { 0x17, KEY_INFO }, // Preview | ||
| 40 | { 0x23, KEY_EPG }, | ||
| 41 | { 0x3b, KEY_F22 },// Record List | ||
| 42 | { 0x3c, KEY_1 }, | ||
| 43 | { 0x3e, KEY_2 }, | ||
| 44 | { 0x39, KEY_3 }, | ||
| 45 | { 0x36, KEY_4 }, | ||
| 46 | { 0x22, KEY_5 }, | ||
| 47 | { 0x20, KEY_6 }, | ||
| 48 | { 0x32, KEY_7 }, | ||
| 49 | { 0x26, KEY_8 }, | ||
| 50 | { 0x24, KEY_9 }, | ||
| 51 | { 0x2a, KEY_0 }, | ||
| 52 | |||
| 53 | { 0x33, KEY_CANCEL }, | ||
| 54 | { 0x2c, KEY_BACK }, | ||
| 55 | { 0x15, KEY_CLEAR }, | ||
| 56 | { 0x3f, KEY_TAB }, | ||
| 57 | { 0x10, KEY_ENTER }, | ||
| 58 | { 0x14, KEY_UP }, | ||
| 59 | { 0x0d, KEY_RIGHT }, | ||
| 60 | { 0x0e, KEY_DOWN }, | ||
| 61 | { 0x11, KEY_LEFT }, | ||
| 62 | |||
| 63 | { 0x21, KEY_VOLUMEUP }, | ||
| 64 | { 0x35, KEY_VOLUMEDOWN }, | ||
| 65 | { 0x3d, KEY_CHANNELDOWN }, | ||
| 66 | { 0x3a, KEY_CHANNELUP }, | ||
| 67 | { 0x2e, KEY_RECORD }, | ||
| 68 | { 0x2b, KEY_PLAY }, | ||
| 69 | { 0x13, KEY_PAUSE }, | ||
| 70 | { 0x25, KEY_STOP }, | ||
| 71 | |||
| 72 | { 0x1f, KEY_REWIND }, | ||
| 73 | { 0x2d, KEY_FASTFORWARD }, | ||
| 74 | { 0x1e, KEY_PREVIOUS }, // Replay |< | ||
| 75 | { 0x1d, KEY_NEXT }, // Skip >| | ||
| 76 | |||
| 77 | { 0x0b, KEY_CAMERA }, // Capture | ||
| 78 | { 0x0f, KEY_LANGUAGE }, // SAP | ||
| 79 | { 0x18, KEY_MODE }, // PIP | ||
| 80 | { 0x12, KEY_ZOOM }, // Full screen, | ||
| 81 | { 0x1c, KEY_SUBTITLE }, | ||
| 82 | { 0x2f, KEY_MUTE }, | ||
| 83 | { 0x16, KEY_F20 }, // L/R, | ||
| 84 | { 0x38, KEY_F21 }, // Hibernate, | ||
| 85 | |||
| 86 | { 0x37, KEY_SWITCHVIDEOMODE }, // A/V | ||
| 87 | { 0x31, KEY_AGAIN }, // Recall, | ||
| 88 | { 0x1a, KEY_KPPLUS }, // Zoom+, | ||
| 89 | { 0x19, KEY_KPMINUS }, // Zoom-, | ||
| 90 | { 0x27, KEY_RED }, | ||
| 91 | { 0x0C, KEY_GREEN }, | ||
| 92 | { 0x01, KEY_YELLOW }, | ||
| 93 | { 0x00, KEY_BLUE }, | ||
| 94 | }; | ||
| 95 | |||
| 96 | struct ir_scancode_table ir_mantis = { | ||
| 97 | .scan = mantis_ir_table, | ||
| 98 | .size = ARRAY_SIZE(mantis_ir_table), | ||
| 99 | }; | ||
| 100 | EXPORT_SYMBOL_GPL(ir_mantis); | ||
| 101 | |||
| 102 | int mantis_input_init(struct mantis_pci *mantis) | ||
| 103 | { | ||
| 104 | struct input_dev *rc; | ||
| 105 | struct ir_input_state rc_state; | ||
| 106 | char name[80], dev[80]; | ||
| 107 | int err; | ||
| 108 | |||
| 109 | rc = input_allocate_device(); | ||
| 110 | if (!rc) { | ||
| 111 | dprintk(MANTIS_ERROR, 1, "Input device allocate failed"); | ||
| 112 | return -ENOMEM; | ||
| 113 | } | ||
| 114 | |||
| 115 | sprintf(name, "Mantis %s IR receiver", mantis->hwconfig->model_name); | ||
| 116 | sprintf(dev, "pci-%s/ir0", pci_name(mantis->pdev)); | ||
| 117 | |||
| 118 | rc->name = name; | ||
| 119 | rc->phys = dev; | ||
| 120 | |||
| 121 | ir_input_init(rc, &rc_state, IR_TYPE_OTHER, &ir_mantis); | ||
| 122 | |||
| 123 | rc->id.bustype = BUS_PCI; | ||
| 124 | rc->id.vendor = mantis->vendor_id; | ||
| 125 | rc->id.product = mantis->device_id; | ||
| 126 | rc->id.version = 1; | ||
| 127 | rc->dev = mantis->pdev->dev; | ||
| 128 | |||
| 129 | err = input_register_device(rc); | ||
| 130 | if (err) { | ||
| 131 | dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err); | ||
| 132 | return -ENODEV; | ||
| 133 | } | ||
| 134 | |||
| 135 | mantis->rc = rc; | ||
| 136 | |||
| 137 | return 0; | ||
| 138 | } | ||
| 139 | |||
| 140 | int mantis_exit(struct mantis_pci *mantis) | ||
| 141 | { | ||
| 142 | struct input_dev *rc = mantis->rc; | ||
| 143 | |||
| 144 | input_unregister_device(rc); | ||
| 145 | |||
| 146 | return 0; | ||
| 147 | } | ||
diff --git a/drivers/media/dvb/mantis/mantis_uart.c b/drivers/media/dvb/mantis/mantis_uart.c index 03b47cf15f8d..7d2f2398fa8b 100644 --- a/drivers/media/dvb/mantis/mantis_uart.c +++ b/drivers/media/dvb/mantis/mantis_uart.c | |||
| @@ -1,7 +1,26 @@ | |||
| 1 | /* | ||
| 2 | Mantis PCI bridge driver | ||
| 3 | |||
| 4 | Copyright (C) Manu Abraham (abraham.manu@gmail.com) | ||
| 5 | |||
| 6 | This program is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with this program; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 19 | */ | ||
| 20 | |||
| 1 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
| 2 | #include <linux/spinlock.h> | 22 | #include <linux/spinlock.h> |
| 3 | 23 | ||
| 4 | #include <asm/irq.h> | ||
| 5 | #include <linux/signal.h> | 24 | #include <linux/signal.h> |
| 6 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
| 7 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
| @@ -21,6 +40,24 @@ struct mantis_uart_params { | |||
| 21 | enum mantis_parity parity; | 40 | enum mantis_parity parity; |
| 22 | }; | 41 | }; |
| 23 | 42 | ||
| 43 | static struct { | ||
| 44 | char string[7]; | ||
| 45 | } rates[5] = { | ||
| 46 | { "9600" }, | ||
| 47 | { "19200" }, | ||
| 48 | { "38400" }, | ||
| 49 | { "57600" }, | ||
| 50 | { "115200" } | ||
| 51 | }; | ||
| 52 | |||
| 53 | static struct { | ||
| 54 | char string[5]; | ||
| 55 | } parity[3] = { | ||
| 56 | { "NONE" }, | ||
| 57 | { "ODD" }, | ||
| 58 | { "EVEN" } | ||
| 59 | }; | ||
| 60 | |||
| 24 | #define UART_MAX_BUF 16 | 61 | #define UART_MAX_BUF 16 |
| 25 | 62 | ||
| 26 | int mantis_uart_read(struct mantis_pci *mantis, u8 *data) | 63 | int mantis_uart_read(struct mantis_pci *mantis, u8 *data) |
| @@ -60,12 +97,10 @@ static void mantis_uart_work(struct work_struct *work) | |||
| 60 | u8 buf[16]; | 97 | u8 buf[16]; |
| 61 | int i; | 98 | int i; |
| 62 | 99 | ||
| 63 | dprintk(MANTIS_DEBUG, 1, "UART read"); | ||
| 64 | mantis_uart_read(mantis, buf); | 100 | mantis_uart_read(mantis, buf); |
| 65 | 101 | ||
| 66 | dprintk(MANTIS_DEBUG, 1, "UART: "); | ||
| 67 | for (i = 0; i < (config->bytes + 1); i++) | 102 | for (i = 0; i < (config->bytes + 1); i++) |
| 68 | dprintk(MANTIS_DEBUG, 0, "<%02x> ", buf[i]); | 103 | dprintk(MANTIS_INFO, 1, "UART BUF:%d <%02x> ", i, buf[i]); |
| 69 | 104 | ||
| 70 | dprintk(MANTIS_DEBUG, 0, "\n"); | 105 | dprintk(MANTIS_DEBUG, 0, "\n"); |
| 71 | } | 106 | } |
| @@ -73,15 +108,8 @@ static void mantis_uart_work(struct work_struct *work) | |||
| 73 | static int mantis_uart_setup(struct mantis_pci *mantis, | 108 | static int mantis_uart_setup(struct mantis_pci *mantis, |
| 74 | struct mantis_uart_params *params) | 109 | struct mantis_uart_params *params) |
| 75 | { | 110 | { |
| 76 | char* rates[] = { "B_9600", "B_19200", "B_38400", "B_57600", "B_115200" }; | ||
| 77 | char* parity[] = { "NONE", "ODD", "EVEN" }; | ||
| 78 | |||
| 79 | u32 reg; | 111 | u32 reg; |
| 80 | 112 | ||
| 81 | dprintk(MANTIS_DEBUG, 1, "Set Parity <%s> Baud Rate <%s>", | ||
| 82 | parity[params->parity], | ||
| 83 | rates[params->baud_rate]); | ||
| 84 | |||
| 85 | mmwrite((mmread(MANTIS_UART_CTL) | (params->parity & 0x3)), MANTIS_UART_CTL); | 113 | mmwrite((mmread(MANTIS_UART_CTL) | (params->parity & 0x3)), MANTIS_UART_CTL); |
| 86 | 114 | ||
| 87 | reg = mmread(MANTIS_UART_BAUD); | 115 | reg = mmread(MANTIS_UART_BAUD); |
| @@ -116,10 +144,12 @@ int mantis_uart_init(struct mantis_pci *mantis) | |||
| 116 | struct mantis_hwconfig *config = mantis->hwconfig; | 144 | struct mantis_hwconfig *config = mantis->hwconfig; |
| 117 | struct mantis_uart_params params; | 145 | struct mantis_uart_params params; |
| 118 | 146 | ||
| 119 | dprintk(MANTIS_DEBUG, 1, "Initializing UART .."); | ||
| 120 | /* default parity: */ | 147 | /* default parity: */ |
| 121 | params.baud_rate = config->baud_rate; | 148 | params.baud_rate = config->baud_rate; |
| 122 | params.parity = config->parity; | 149 | params.parity = config->parity; |
| 150 | dprintk(MANTIS_INFO, 1, "Initializing UART @ %sbps parity:%s", | ||
| 151 | rates[params.baud_rate].string, | ||
| 152 | parity[params.parity].string); | ||
| 123 | 153 | ||
| 124 | init_waitqueue_head(&mantis->uart_wq); | 154 | init_waitqueue_head(&mantis->uart_wq); |
| 125 | spin_lock_init(&mantis->uart_lock); | 155 | spin_lock_init(&mantis->uart_lock); |
| @@ -142,6 +172,7 @@ int mantis_uart_init(struct mantis_pci *mantis) | |||
| 142 | mmwrite(mmread(MANTIS_UART_CTL) | MANTIS_UART_RXINT, MANTIS_UART_CTL); | 172 | mmwrite(mmread(MANTIS_UART_CTL) | MANTIS_UART_RXINT, MANTIS_UART_CTL); |
| 143 | 173 | ||
| 144 | schedule_work(&mantis->uart_work); | 174 | schedule_work(&mantis->uart_work); |
| 175 | dprintk(MANTIS_DEBUG, 1, "UART succesfully initialized"); | ||
| 145 | 176 | ||
| 146 | return 0; | 177 | return 0; |
| 147 | } | 178 | } |
diff --git a/drivers/media/dvb/mantis/mantis_uart.h b/drivers/media/dvb/mantis/mantis_uart.h index 0a42cd01ab22..62ab66ebb971 100644 --- a/drivers/media/dvb/mantis/mantis_uart.h +++ b/drivers/media/dvb/mantis/mantis_uart.h | |||
| @@ -45,10 +45,9 @@ enum mantis_baud { | |||
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| 47 | enum mantis_parity { | 47 | enum mantis_parity { |
| 48 | MANTIS_PARITY_UNDEFINED = 0, | 48 | MANTIS_PARITY_NONE = 0, |
| 49 | MANTIS_PARITY_EVEN, | 49 | MANTIS_PARITY_EVEN, |
| 50 | MANTIS_PARITY_ODD, | 50 | MANTIS_PARITY_ODD, |
| 51 | MANTIS_PARITY_NONE | ||
| 52 | }; | 51 | }; |
| 53 | 52 | ||
| 54 | struct mantis_pci; | 53 | struct mantis_pci; |
