[media] b2c2: fix driver's build due to the lack of pci DMA code
[linux-2.6/btrfs-unstable.git] / drivers / media / video / pvrusb2 / pvrusb2-hdw.h
blob8060fc666eeb3c417ec5cde225b6c385d013cccc
1 /*
4 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
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
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.
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
20 #ifndef __PVRUSB2_HDW_H
21 #define __PVRUSB2_HDW_H
23 #include <linux/usb.h>
24 #include <linux/videodev2.h>
25 #include "pvrusb2-io.h"
26 #include "pvrusb2-ctrl.h"
29 /* Private internal control ids, look these up with
30 pvr2_hdw_get_ctrl_by_id() - these are NOT visible in V4L */
31 #define PVR2_CID_STDCUR 2
32 #define PVR2_CID_STDAVAIL 3
33 #define PVR2_CID_INPUT 4
34 #define PVR2_CID_AUDIOMODE 5
35 #define PVR2_CID_FREQUENCY 6
36 #define PVR2_CID_HRES 7
37 #define PVR2_CID_VRES 8
38 #define PVR2_CID_CROPL 9
39 #define PVR2_CID_CROPT 10
40 #define PVR2_CID_CROPW 11
41 #define PVR2_CID_CROPH 12
42 #define PVR2_CID_CROPCAPPAN 13
43 #define PVR2_CID_CROPCAPPAD 14
44 #define PVR2_CID_CROPCAPBL 15
45 #define PVR2_CID_CROPCAPBT 16
46 #define PVR2_CID_CROPCAPBW 17
47 #define PVR2_CID_CROPCAPBH 18
48 #define PVR2_CID_STDDETECT 19
50 /* Legal values for the INPUT state variable */
51 #define PVR2_CVAL_INPUT_TV 0
52 #define PVR2_CVAL_INPUT_DTV 1
53 #define PVR2_CVAL_INPUT_COMPOSITE 2
54 #define PVR2_CVAL_INPUT_SVIDEO 3
55 #define PVR2_CVAL_INPUT_RADIO 4
57 enum pvr2_config {
58 pvr2_config_empty, /* No configuration */
59 pvr2_config_mpeg, /* Encoded / compressed video */
60 pvr2_config_vbi, /* Standard vbi info */
61 pvr2_config_pcm, /* Audio raw pcm stream */
62 pvr2_config_rawvideo, /* Video raw frames */
65 enum pvr2_v4l_type {
66 pvr2_v4l_type_video,
67 pvr2_v4l_type_vbi,
68 pvr2_v4l_type_radio,
71 /* Major states that we can be in:
73 * DEAD - Device is in an unusable state and cannot be recovered. This
74 * can happen if we completely lose the ability to communicate with it
75 * (but it might still on the bus). In this state there's nothing we can
76 * do; it must be replugged in order to recover.
78 * COLD - Device is in an unusable state, needs microcontroller firmware.
80 * WARM - We can communicate with the device and the proper
81 * microcontroller firmware is running, but other device initialization is
82 * still needed (e.g. encoder firmware).
84 * ERROR - A problem prevents capture operation (e.g. encoder firmware
85 * missing).
87 * READY - Device is operational, but not streaming.
89 * RUN - Device is streaming.
92 #define PVR2_STATE_NONE 0
93 #define PVR2_STATE_DEAD 1
94 #define PVR2_STATE_COLD 2
95 #define PVR2_STATE_WARM 3
96 #define PVR2_STATE_ERROR 4
97 #define PVR2_STATE_READY 5
98 #define PVR2_STATE_RUN 6
100 /* Translate configuration enum to a string label */
101 const char *pvr2_config_get_name(enum pvr2_config);
103 struct pvr2_hdw;
105 /* Create and return a structure for interacting with the underlying
106 hardware */
107 struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
108 const struct usb_device_id *devid);
110 /* Perform second stage initialization, passing in a notification callback
111 for when the master state changes. */
112 int pvr2_hdw_initialize(struct pvr2_hdw *,
113 void (*callback_func)(void *),
114 void *callback_data);
116 /* Destroy hardware interaction structure */
117 void pvr2_hdw_destroy(struct pvr2_hdw *);
119 /* Return true if in the ready (normal) state */
120 int pvr2_hdw_dev_ok(struct pvr2_hdw *);
122 /* Return small integer number [1..N] for logical instance number of this
123 device. This is useful for indexing array-valued module parameters. */
124 int pvr2_hdw_get_unit_number(struct pvr2_hdw *);
126 /* Get pointer to underlying USB device */
127 struct usb_device *pvr2_hdw_get_dev(struct pvr2_hdw *);
129 /* Retrieve serial number of device */
130 unsigned long pvr2_hdw_get_sn(struct pvr2_hdw *);
132 /* Retrieve bus location info of device */
133 const char *pvr2_hdw_get_bus_info(struct pvr2_hdw *);
135 /* Retrieve per-instance string identifier for this specific device */
136 const char *pvr2_hdw_get_device_identifier(struct pvr2_hdw *);
138 /* Called when hardware has been unplugged */
139 void pvr2_hdw_disconnect(struct pvr2_hdw *);
141 /* Get the number of defined controls */
142 unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *);
144 /* Retrieve a control handle given its index (0..count-1) */
145 struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_index(struct pvr2_hdw *,unsigned int);
147 /* Retrieve a control handle given its internal ID (if any) */
148 struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_id(struct pvr2_hdw *,unsigned int);
150 /* Retrieve a control handle given its V4L ID (if any) */
151 struct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *,unsigned int ctl_id);
153 /* Retrieve a control handle given its immediate predecessor V4L ID (if any) */
154 struct pvr2_ctrl *pvr2_hdw_get_ctrl_nextv4l(struct pvr2_hdw *,
155 unsigned int ctl_id);
157 /* Commit all control changes made up to this point */
158 int pvr2_hdw_commit_ctl(struct pvr2_hdw *);
160 /* Return a bit mask of valid input selections for this device. Mask bits
161 * will be according to PVR_CVAL_INPUT_xxxx definitions. */
162 unsigned int pvr2_hdw_get_input_available(struct pvr2_hdw *);
164 /* Return a bit mask of allowed input selections for this device. Mask bits
165 * will be according to PVR_CVAL_INPUT_xxxx definitions. */
166 unsigned int pvr2_hdw_get_input_allowed(struct pvr2_hdw *);
168 /* Change the set of allowed input selections for this device. Both
169 change_mask and change_valu are mask bits according to
170 PVR_CVAL_INPUT_xxxx definitions. The change_mask parameter indicate
171 which settings are being changed and the change_val parameter indicates
172 whether corresponding settings are being set or cleared. */
173 int pvr2_hdw_set_input_allowed(struct pvr2_hdw *,
174 unsigned int change_mask,
175 unsigned int change_val);
177 /* Return name for this driver instance */
178 const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *);
180 /* Mark tuner status stale so that it will be re-fetched */
181 void pvr2_hdw_execute_tuner_poll(struct pvr2_hdw *);
183 /* Return information about the tuner */
184 int pvr2_hdw_get_tuner_status(struct pvr2_hdw *,struct v4l2_tuner *);
186 /* Return information about cropping capabilities */
187 int pvr2_hdw_get_cropcap(struct pvr2_hdw *, struct v4l2_cropcap *);
189 /* Query device and see if it thinks it is on a high-speed USB link */
190 int pvr2_hdw_is_hsm(struct pvr2_hdw *);
192 /* Return a string token representative of the hardware type */
193 const char *pvr2_hdw_get_type(struct pvr2_hdw *);
195 /* Return a single line description of the hardware type */
196 const char *pvr2_hdw_get_desc(struct pvr2_hdw *);
198 /* Turn streaming on/off */
199 int pvr2_hdw_set_streaming(struct pvr2_hdw *,int);
201 /* Find out if streaming is on */
202 int pvr2_hdw_get_streaming(struct pvr2_hdw *);
204 /* Retrieve driver overall state */
205 int pvr2_hdw_get_state(struct pvr2_hdw *);
207 /* Configure the type of stream to generate */
208 int pvr2_hdw_set_stream_type(struct pvr2_hdw *, enum pvr2_config);
210 /* Get handle to video output stream */
211 struct pvr2_stream *pvr2_hdw_get_video_stream(struct pvr2_hdw *);
213 /* Enable / disable retrieval of CPU firmware or prom contents. This must
214 be enabled before pvr2_hdw_cpufw_get() will function. Note that doing
215 this may prevent the device from running (and leaving this mode may
216 imply a device reset). */
217 void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *,
218 int mode, /* 0=8KB FX2, 1=16KB FX2, 2=PROM */
219 int enable_flag);
221 /* Return true if we're in a mode for retrieval CPU firmware */
222 int pvr2_hdw_cpufw_get_enabled(struct pvr2_hdw *);
224 /* Retrieve a piece of the CPU's firmware at the given offset. Return
225 value is the number of bytes retrieved or zero if we're past the end or
226 an error otherwise (e.g. if firmware retrieval is not enabled). */
227 int pvr2_hdw_cpufw_get(struct pvr2_hdw *,unsigned int offs,
228 char *buf,unsigned int cnt);
230 /* Retrieve a previously stored v4l minor device number */
231 int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *,enum pvr2_v4l_type index);
233 /* Store a v4l minor device number */
234 void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,
235 enum pvr2_v4l_type index,int);
237 /* Direct read/write access to chip's registers:
238 match - specify criteria to identify target chip (this is a v4l dbg struct)
239 reg_id - register number to access
240 setFl - true to set the register, false to read it
241 val_ptr - storage location for source / result. */
242 int pvr2_hdw_register_access(struct pvr2_hdw *,
243 struct v4l2_dbg_match *match, u64 reg_id,
244 int setFl, u64 *val_ptr);
246 /* The following entry points are all lower level things you normally don't
247 want to worry about. */
249 /* Issue a command and get a response from the device. LOTS of higher
250 level stuff is built on this. */
251 int pvr2_send_request(struct pvr2_hdw *,
252 void *write_ptr,unsigned int write_len,
253 void *read_ptr,unsigned int read_len);
255 /* Slightly higher level device communication functions. */
256 int pvr2_write_register(struct pvr2_hdw *, u16, u32);
258 /* Call if for any reason we can't talk to the hardware anymore - this will
259 cause the driver to stop flailing on the device. */
260 void pvr2_hdw_render_useless(struct pvr2_hdw *);
262 /* Set / clear 8051's reset bit */
263 void pvr2_hdw_cpureset_assert(struct pvr2_hdw *,int);
265 /* Execute a USB-commanded device reset */
266 void pvr2_hdw_device_reset(struct pvr2_hdw *);
268 /* Reset worker's error trapping circuit breaker */
269 int pvr2_hdw_untrip(struct pvr2_hdw *);
271 /* Execute hard reset command (after this point it's likely that the
272 encoder will have to be reconfigured). This also clears the "useless"
273 state. */
274 int pvr2_hdw_cmd_deep_reset(struct pvr2_hdw *);
276 /* Execute simple reset command */
277 int pvr2_hdw_cmd_powerup(struct pvr2_hdw *);
279 /* suspend */
280 int pvr2_hdw_cmd_powerdown(struct pvr2_hdw *);
282 /* Order decoder to reset */
283 int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *);
285 /* Direct manipulation of GPIO bits */
286 int pvr2_hdw_gpio_get_dir(struct pvr2_hdw *hdw,u32 *);
287 int pvr2_hdw_gpio_get_out(struct pvr2_hdw *hdw,u32 *);
288 int pvr2_hdw_gpio_get_in(struct pvr2_hdw *hdw,u32 *);
289 int pvr2_hdw_gpio_chg_dir(struct pvr2_hdw *hdw,u32 msk,u32 val);
290 int pvr2_hdw_gpio_chg_out(struct pvr2_hdw *hdw,u32 msk,u32 val);
292 /* This data structure is specifically for the next function... */
293 struct pvr2_hdw_debug_info {
294 int big_lock_held;
295 int ctl_lock_held;
296 int flag_disconnected;
297 int flag_init_ok;
298 int flag_ok;
299 int fw1_state;
300 int flag_decoder_missed;
301 int flag_tripped;
302 int state_encoder_ok;
303 int state_encoder_run;
304 int state_decoder_run;
305 int state_decoder_ready;
306 int state_usbstream_run;
307 int state_decoder_quiescent;
308 int state_pipeline_config;
309 int state_pipeline_req;
310 int state_pipeline_pause;
311 int state_pipeline_idle;
312 int cmd_debug_state;
313 int cmd_debug_write_len;
314 int cmd_debug_read_len;
315 int cmd_debug_write_pend;
316 int cmd_debug_read_pend;
317 int cmd_debug_timeout;
318 int cmd_debug_rstatus;
319 int cmd_debug_wstatus;
320 unsigned char cmd_code;
323 /* Non-intrusively retrieve internal state info - this is useful for
324 diagnosing lockups. Note that this operation is completed without any
325 kind of locking and so it is not atomic and may yield inconsistent
326 results. This is *purely* a debugging aid. */
327 void pvr2_hdw_get_debug_info_unlocked(const struct pvr2_hdw *hdw,
328 struct pvr2_hdw_debug_info *);
330 /* Intrusively retrieve internal state info - this is useful for
331 diagnosing overall driver state. This operation synchronizes against
332 the overall driver mutex - so if there are locking problems this will
333 likely hang! This is *purely* a debugging aid. */
334 void pvr2_hdw_get_debug_info_locked(struct pvr2_hdw *hdw,
335 struct pvr2_hdw_debug_info *);
337 /* Report out several lines of text that describes driver internal state.
338 Results are written into the passed-in buffer. */
339 unsigned int pvr2_hdw_state_report(struct pvr2_hdw *hdw,
340 char *buf_ptr,unsigned int buf_size);
342 /* Cause modules to log their state once */
343 void pvr2_hdw_trigger_module_log(struct pvr2_hdw *hdw);
345 /* Cause encoder firmware to be uploaded into the device. This is normally
346 done autonomously, but the interface is exported here because it is also
347 a debugging aid. */
348 int pvr2_upload_firmware2(struct pvr2_hdw *hdw);
350 #endif /* __PVRUSB2_HDW_H */
353 Stuff for Emacs to see, in order to encourage consistent editing style:
354 *** Local Variables: ***
355 *** mode: c ***
356 *** fill-column: 75 ***
357 *** tab-width: 8 ***
358 *** c-basic-offset: 8 ***
359 *** End: ***