aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pvrusb2/pvrusb2-dvb.c
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2008-02-03 21:46:16 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 13:09:46 -0400
commit04910bdc5c172af9bc937a8869e7f2907db4443f (patch)
treeb8b5f224510cca9938f2f766905622632f0f4861 /drivers/media/video/pvrusb2/pvrusb2-dvb.c
parente7f677f33664200b3d75ffc625d218b84ac43875 (diff)
V4L/DVB (7679): pvrusb2: add DVB API framework
Add basic framework for the DVB API. This is enough to control the tuner & demod of the digital frontend, but the stream & buffer handling is still missing. Additional note from Mike Isely <isely@pobox.com> - also, since these changes are still very experimental arrange for DVB changes to be compiled in via new CONFIG_VIDEO_PVRUSB2_DVB option, for now. Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-dvb.c')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-dvb.c179
1 files changed, 179 insertions, 0 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-dvb.c b/drivers/media/video/pvrusb2/pvrusb2-dvb.c
new file mode 100644
index 00000000000..18c18db2fe3
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-dvb.c
@@ -0,0 +1,179 @@
1/*
2 * pvrusb2-dvb.c - linux-dvb api interface to the pvrusb2 driver.
3 *
4 * Copyright (C) 2007, 2008 Michael Krufky <mkrufky@linuxtv.org>
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
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */
20
21#include "dvbdev.h"
22#include "pvrusb2-hdw-internal.h"
23#include "pvrusb2-hdw.h"
24#include "pvrusb2-dvb.h"
25
26DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
27
28static int pvr2_dvb_start_feed(struct dvb_demux_feed *dvbdmxfeed)
29{
30 printk(KERN_DEBUG "start pid: 0x%04x, feedtype: %d\n",
31 dvbdmxfeed->pid, dvbdmxfeed->type);
32 return 0; /* FIXME: pvr2_dvb_ctrl_feed(dvbdmxfeed, 1); */
33}
34
35static int pvr2_dvb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
36{
37 printk(KERN_DEBUG "stop pid: 0x%04x, feedtype: %d\n",
38 dvbdmxfeed->pid, dvbdmxfeed->type);
39 return 0; /* FIXME: pvr2_dvb_ctrl_feed(dvbdmxfeed, 0); */
40}
41
42static int pvr2_dvb_adapter_init(struct pvr2_dvb_adapter *adap)
43{
44 int ret;
45
46 ret = dvb_register_adapter(&adap->dvb_adap, "pvrusb2-dvb",
47 THIS_MODULE/*&hdw->usb_dev->owner*/,
48 &adap->pvr->hdw->usb_dev->dev,
49 adapter_nr);
50 if (ret < 0) {
51 err("dvb_register_adapter failed: error %d", ret);
52 goto err;
53 }
54 adap->dvb_adap.priv = adap;
55
56 adap->demux.dmx.capabilities = DMX_TS_FILTERING |
57 DMX_SECTION_FILTERING |
58 DMX_MEMORY_BASED_FILTERING;
59 adap->demux.priv = adap;
60 adap->demux.filternum = 256;
61 adap->demux.feednum = 256;
62 adap->demux.start_feed = pvr2_dvb_start_feed;
63 adap->demux.stop_feed = pvr2_dvb_stop_feed;
64 adap->demux.write_to_decoder = NULL;
65
66 ret = dvb_dmx_init(&adap->demux);
67 if (ret < 0) {
68 err("dvb_dmx_init failed: error %d", ret);
69 goto err_dmx;
70 }
71
72 adap->dmxdev.filternum = adap->demux.filternum;
73 adap->dmxdev.demux = &adap->demux.dmx;
74 adap->dmxdev.capabilities = 0;
75
76 ret = dvb_dmxdev_init(&adap->dmxdev, &adap->dvb_adap);
77 if (ret < 0) {
78 err("dvb_dmxdev_init failed: error %d", ret);
79 goto err_dmx_dev;
80 }
81
82 dvb_net_init(&adap->dvb_adap, &adap->dvb_net, &adap->demux.dmx);
83
84 adap->digital_up = 1;
85
86 return 0;
87
88err_dmx_dev:
89 dvb_dmx_release(&adap->demux);
90err_dmx:
91 dvb_unregister_adapter(&adap->dvb_adap);
92err:
93 return ret;
94}
95
96static int pvr2_dvb_adapter_exit(struct pvr2_dvb_adapter *adap)
97{
98 if (adap->digital_up) {
99 printk(KERN_DEBUG "unregistering DVB devices\n");
100 dvb_net_release(&adap->dvb_net);
101 adap->demux.dmx.close(&adap->demux.dmx);
102 dvb_dmxdev_release(&adap->dmxdev);
103 dvb_dmx_release(&adap->demux);
104 dvb_unregister_adapter(&adap->dvb_adap);
105 adap->digital_up = 0;
106 }
107 return 0;
108}
109
110static int pvr2_dvb_frontend_init(struct pvr2_dvb_adapter *adap)
111{
112 struct pvr2_dvb_props *dvb_props = adap->pvr->hdw->hdw_desc->dvb_props;
113
114 if (dvb_props == NULL) {
115 err("fe_props not defined!");
116 return -EINVAL;
117 }
118
119 if (dvb_props->frontend_attach == NULL) {
120 err("frontend_attach not defined!");
121 return -EINVAL;
122 }
123
124 if ((dvb_props->frontend_attach(adap) == 0) && (adap->fe)) {
125
126 if (dvb_register_frontend(&adap->dvb_adap, adap->fe)) {
127 err("frontend registration failed!");
128 dvb_frontend_detach(adap->fe);
129 adap->fe = NULL;
130 return -ENODEV;
131 }
132
133 if (dvb_props->tuner_attach)
134 dvb_props->tuner_attach(adap);
135
136 if (adap->fe->ops.analog_ops.standby)
137 adap->fe->ops.analog_ops.standby(adap->fe);
138
139 } else {
140 err("no frontend was attached!");
141 return -ENODEV;
142 }
143
144 return 0;
145}
146
147static int pvr2_dvb_frontend_exit(struct pvr2_dvb_adapter *adap)
148{
149 if (adap->fe != NULL) {
150 dvb_unregister_frontend(adap->fe);
151 dvb_frontend_detach(adap->fe);
152 }
153 return 0;
154}
155
156int pvr2_dvb_init(struct pvr2_context *pvr)
157{
158 int ret = 0;
159
160 pvr->hdw->dvb.pvr = pvr;
161
162 ret = pvr2_dvb_adapter_init(&pvr->hdw->dvb);
163 if (ret < 0)
164 goto fail;
165
166 ret = pvr2_dvb_frontend_init(&pvr->hdw->dvb);
167fail:
168 return ret;
169}
170
171int pvr2_dvb_exit(struct pvr2_context *pvr)
172{
173 pvr2_dvb_frontend_exit(&pvr->hdw->dvb);
174 pvr2_dvb_adapter_exit(&pvr->hdw->dvb);
175
176 pvr->hdw->dvb.pvr = NULL;
177
178 return 0;
179}