5f0de88e41a614c100f308f92ffe05cc05eafc2f
[linux-2.6-block.git] / drivers / media / dvb / firesat / firesat.h
1 /*
2  * FireDTV driver (formerly known as FireSAT)
3  *
4  * Copyright (C) 2004 Andreas Monitzer <andy@monitzer.com>
5  * Copyright (C) 2008 Henrik Kurelid <henrik@kurelid.se>
6  *
7  *      This program is free software; you can redistribute it and/or
8  *      modify it under the terms of the GNU General Public License as
9  *      published by the Free Software Foundation; either version 2 of
10  *      the License, or (at your option) any later version.
11  */
12
13 #ifndef _FIREDTV_H
14 #define _FIREDTV_H
15
16 #include <linux/dvb/dmx.h>
17 #include <linux/dvb/frontend.h>
18 #include <linux/list.h>
19 #include <linux/mutex.h>
20 #include <linux/spinlock_types.h>
21 #include <linux/types.h>
22 #include <linux/wait.h>
23 #include <linux/workqueue.h>
24 #include <asm/atomic.h>
25
26 #include <demux.h>
27 #include <dmxdev.h>
28 #include <dvb_demux.h>
29 #include <dvb_net.h>
30 #include <dvbdev.h>
31
32 #include <linux/version.h>
33 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 25)
34 #define DVB_REGISTER_ADAPTER(x, y, z, w, v) dvb_register_adapter(x, y, z, w, v)
35 #else
36 #define DVB_REGISTER_ADAPTER(x, y, z, w, v) dvb_register_adapter(x, y, z, w)
37 #define DVB_DEFINE_MOD_OPT_ADAPTER_NR(x)
38 #endif
39
40 /*****************************************************************
41  * CA message command constants from en50221_app_tags.h of libdvb
42  *****************************************************************/
43 /*      Resource Manager                */
44 #define TAG_PROFILE_ENQUIRY             0x9f8010
45 #define TAG_PROFILE                     0x9f8011
46 #define TAG_PROFILE_CHANGE              0x9f8012
47
48 /*      Application Info                */
49 #define TAG_APP_INFO_ENQUIRY            0x9f8020
50 #define TAG_APP_INFO                    0x9f8021
51 #define TAG_ENTER_MENU                  0x9f8022
52
53 /*      CA Support                      */
54 #define TAG_CA_INFO_ENQUIRY             0x9f8030
55 #define TAG_CA_INFO                     0x9f8031
56 #define TAG_CA_PMT                      0x9f8032
57 #define TAG_CA_PMT_REPLY                0x9f8033
58
59 /*      Host Control                    */
60 #define TAG_TUNE                        0x9f8400
61 #define TAG_REPLACE                     0x9f8401
62 #define TAG_CLEAR_REPLACE               0x9f8402
63 #define TAG_ASK_RELEASE                 0x9f8403
64
65 /*      Date and Time                   */
66 #define TAG_DATE_TIME_ENQUIRY           0x9f8440
67 #define TAG_DATE_TIME                   0x9f8441
68
69 /*      Man Machine Interface (MMI)     */
70 #define TAG_CLOSE_MMI                   0x9f8800
71 #define TAG_DISPLAY_CONTROL             0x9f8801
72 #define TAG_DISPLAY_REPLY               0x9f8802
73 #define TAG_TEXT_LAST                   0x9f8803
74 #define TAG_TEXT_MORE                   0x9f8804
75 #define TAG_KEYPAD_CONTROL              0x9f8805
76 #define TAG_KEYPRESS                    0x9f8806
77 #define TAG_ENQUIRY                     0x9f8807
78 #define TAG_ANSWER                      0x9f8808
79 #define TAG_MENU_LAST                   0x9f8809
80 #define TAG_MENU_MORE                   0x9f880a
81 #define TAG_MENU_ANSWER                 0x9f880b
82 #define TAG_LIST_LAST                   0x9f880c
83 #define TAG_LIST_MORE                   0x9f880d
84 #define TAG_SUBTITLE_SEGMENT_LAST       0x9f880e
85 #define TAG_SUBTITLE_SEGMENT_MORE       0x9f880f
86 #define TAG_DISPLAY_MESSAGE             0x9f8810
87 #define TAG_SCENE_END_MARK              0x9f8811
88 #define TAG_SCENE_DONE                  0x9f8812
89 #define TAG_SCENE_CONTROL               0x9f8813
90 #define TAG_SUBTITLE_DOWNLOAD_LAST      0x9f8814
91 #define TAG_SUBTITLE_DOWNLOAD_MORE      0x9f8815
92 #define TAG_FLUSH_DOWNLOAD              0x9f8816
93 #define TAG_DOWNLOAD_REPLY              0x9f8817
94
95 /*      Low Speed Communications        */
96 #define TAG_COMMS_COMMAND               0x9f8c00
97 #define TAG_CONNECTION_DESCRIPTOR       0x9f8c01
98 #define TAG_COMMS_REPLY                 0x9f8c02
99 #define TAG_COMMS_SEND_LAST             0x9f8c03
100 #define TAG_COMMS_SEND_MORE             0x9f8c04
101 #define TAG_COMMS_RECV_LAST             0x9f8c05
102 #define TAG_COMMS_RECV_MORE             0x9f8c06
103
104 /* Authentication */
105 #define TAG_AUTH_REQ                    0x9f8200
106 #define TAG_AUTH_RESP                   0x9f8201
107
108 /* Teletext */
109 #define TAG_TELETEXT_EBU                0x9f9000
110
111 /* Smartcard */
112 #define TAG_SMARTCARD_COMMAND           0x9f8e00
113 #define TAG_SMARTCARD_REPLY             0x9f8e01
114 #define TAG_SMARTCARD_SEND              0x9f8e02
115 #define TAG_SMARTCARD_RCV               0x9f8e03
116
117 /* EPG */
118 #define TAG_EPG_ENQUIRY                 0x9f8f00
119 #define TAG_EPG_REPLY                   0x9f8f01
120
121
122 enum model_type {
123         FireSAT_UNKNOWN = 0,
124         FireSAT_DVB_S   = 1,
125         FireSAT_DVB_C   = 2,
126         FireSAT_DVB_T   = 3,
127         FireSAT_DVB_S2  = 4,
128 };
129
130 struct hpsb_host;
131 struct hpsb_iso;
132 struct node_entry;
133
134 struct firesat {
135         struct dvb_demux dvb_demux;
136
137         /* DVB bits */
138         struct dvb_adapter              *adapter;
139         struct dmxdev                   dmxdev;
140         struct dvb_demux                demux;
141         struct dmx_frontend             frontend;
142         struct dvb_net                  dvbnet;
143         struct dvb_frontend_info        *frontend_info;
144         struct dvb_frontend             *fe;
145
146         struct dvb_device               *cadev;
147         int                             ca_last_command;
148         int                             ca_time_interval;
149
150         struct mutex                    avc_mutex;
151         wait_queue_head_t               avc_wait;
152         atomic_t                        avc_reply_received;
153         struct work_struct              remote_ctrl_work;
154
155         struct firesat_channel {
156                 struct firesat *firesat;
157                 struct dvb_demux_feed *dvbdmxfeed;
158
159                 int active;
160                 int id;
161                 int pid;
162                 int type;       /* 1 - TS, 2 - Filter */
163         } channel[16];
164         struct mutex                    demux_mutex;
165
166         /* needed by avc_api */
167         void *respfrm;
168         int resp_length;
169
170         struct hpsb_host *host;
171         u64 guid;                       /* GUID of this node */
172         u32 guid_vendor_id;             /* Top 24bits of guid */
173         struct node_entry *nodeentry;
174
175         enum model_type type;
176         char subunit;
177         fe_sec_voltage_t voltage;
178         fe_sec_tone_mode_t tone;
179
180         int isochannel;
181         struct hpsb_iso *iso_handle;
182
183         struct list_head list;
184 };
185
186 struct firewireheader {
187         union {
188                 struct {
189                         __u8 tcode:4;
190                         __u8 sy:4;
191                         __u8 tag:2;
192                         __u8 channel:6;
193
194                         __u8 length_l;
195                         __u8 length_h;
196                 } hdr;
197                 __u32 val;
198         };
199 };
200
201 struct CIPHeader {
202         union {
203                 struct {
204                         __u8 syncbits:2;
205                         __u8 sid:6;
206                         __u8 dbs;
207                         __u8 fn:2;
208                         __u8 qpc:3;
209                         __u8 sph:1;
210                         __u8 rsv:2;
211                         __u8 dbc;
212                         __u8 syncbits2:2;
213                         __u8 fmt:6;
214                         __u32 fdf:24;
215                 } cip;
216                 __u64 val;
217         };
218 };
219
220 extern const char *firedtv_model_names[];
221 extern struct list_head firesat_list;
222 extern spinlock_t firesat_list_lock;
223
224 struct device;
225
226 /* firesat_dvb.c */
227 int firesat_start_feed(struct dvb_demux_feed *dvbdmxfeed);
228 int firesat_stop_feed(struct dvb_demux_feed *dvbdmxfeed);
229 int firesat_dvbdev_init(struct firesat *firesat, struct device *dev,
230                 struct dvb_frontend *fe);
231
232 /* firesat_fe.c */
233 int firesat_frontend_attach(struct firesat *firesat, struct dvb_frontend *fe);
234
235 /* firesat_iso.c */
236 int setup_iso_channel(struct firesat *firesat);
237 void tear_down_iso_channel(struct firesat *firesat);
238
239 #endif /* _FIREDTV_H */