V4L/DVB (13795): [Mantis/Hopper] Code overhaul, add Hopper devices into the PCI ID...
[safe/jmp/linux-2.6] / drivers / media / dvb / mantis / mantis_vp3030.c
1 /*
2         Mantis VP-3030 driver
3
4         Copyright (C) 2005, 2006 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 <asm/irq.h>
22 #include <linux/signal.h>
23 #include <linux/sched.h>
24 #include <linux/interrupt.h>
25
26 #include "dmxdev.h"
27 #include "dvbdev.h"
28 #include "dvb_demux.h"
29 #include "dvb_frontend.h"
30 #include "dvb_net.h"
31
32 #include "zl10353.h"
33 #include "mantis_common.h"
34 #include "mantis_vp3030.h"
35
36 struct zl10353_config mantis_vp3030_config = {
37         .demod_address  = 0x0f,
38 };
39
40 #define MANTIS_MODEL_NAME       "VP-3030"
41 #define MANTIS_DEV_TYPE         "DVB-T"
42
43 int panasonic_en57h12d5_set_params(struct dvb_frontend *fe,
44                                    struct dvb_frontend_parameters *params)
45 {
46         u8 buf[4];
47         int rc;
48         struct mantis_pci *mantis = fe->dvb->priv;
49
50         struct i2c_msg tuner_msg = {
51                 .addr = 0x60,
52                 .flags = 0,
53                 .buf = buf,
54                 .len = sizeof (buf)
55         };
56
57         if ((params->frequency < 950000) || (params->frequency > 2150000))
58                 return -EINVAL;
59         rc = i2c_transfer(&mantis->adapter, &tuner_msg, 1);
60         if (rc != 1) {
61                 printk("%s: I2C Transfer returned [%d]\n", __func__, rc);
62                 return -EIO;
63         }
64         msleep_interruptible(1);
65         printk("%s: Send params to tuner ok!!!\n", __func__);
66
67         return 0;
68 }
69
70 static int vp3030_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
71 {
72         struct i2c_adapter *adapter     = &mantis->adapter;
73
74         dprintk(MANTIS_ERROR, 1, "Probing for 10353 (DVB-T)");
75         fe = zl10353_attach(&mantis_vp3030_config, adapter);
76
77         if (!fe)
78                 return -1;
79
80         mantis->fe = fe;
81         dprintk(MANTIS_ERROR, 1, "Done!");
82
83         return 0;
84 }
85
86 struct mantis_hwconfig vp3030_config = {
87         .model_name     = MANTIS_MODEL_NAME,
88         .dev_type       = MANTIS_DEV_TYPE,
89         .ts_size        = MANTIS_TS_188,
90
91         .baud_rate      = MANTIS_BAUD_9600,
92         .parity         = MANTIS_PARITY_NONE,
93         .bytes          = 0,
94
95         .frontend_init  = vp3030_frontend_init,
96 };