blob: 018d98f94f97095f29abbd540bf8204f30fa3ffb [file] [log] [blame]
Hans Verkuil1c1e45d2008-04-28 20:24:33 -03001/*
2 * cx18 driver internal defines and structures
3 *
4 * Derived from ivtv-driver.h
5 *
6 * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
Andy Walls1ed9dcc2008-11-22 01:37:34 -03007 * Copyright (C) 2008 Andy Walls <awalls@radix.net>
Hans Verkuil1c1e45d2008-04-28 20:24:33 -03008 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */
24
25#ifndef CX18_DRIVER_H
26#define CX18_DRIVER_H
27
28#include <linux/version.h>
29#include <linux/module.h>
30#include <linux/moduleparam.h>
31#include <linux/init.h>
32#include <linux/delay.h>
33#include <linux/sched.h>
34#include <linux/fs.h>
35#include <linux/pci.h>
36#include <linux/interrupt.h>
37#include <linux/spinlock.h>
38#include <linux/i2c.h>
39#include <linux/i2c-algo-bit.h>
40#include <linux/list.h>
41#include <linux/unistd.h>
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030042#include <linux/pagemap.h>
43#include <linux/workqueue.h>
44#include <linux/mutex.h>
Harvey Harrison1a651a02008-10-18 20:28:37 -070045#include <asm/byteorder.h>
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030046
47#include <linux/dvb/video.h>
48#include <linux/dvb/audio.h>
49#include <media/v4l2-common.h>
Hans Verkuil35ea11f2008-07-20 08:12:02 -030050#include <media/v4l2-ioctl.h>
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030051#include <media/tuner.h>
52#include "cx18-mailbox.h"
53#include "cx18-av-core.h"
54#include "cx23418.h"
55
56/* DVB */
57#include "demux.h"
58#include "dmxdev.h"
59#include "dvb_demux.h"
60#include "dvb_frontend.h"
61#include "dvb_net.h"
62#include "dvbdev.h"
63
64#ifndef CONFIG_PCI
65# error "This driver requires kernel PCI support."
66#endif
67
68#define CX18_MEM_OFFSET 0x00000000
69#define CX18_MEM_SIZE 0x04000000
70#define CX18_REG_OFFSET 0x02000000
71
72/* Maximum cx18 driver instances. */
73#define CX18_MAX_CARDS 32
74
75/* Supported cards */
76#define CX18_CARD_HVR_1600_ESMT 0 /* Hauppauge HVR 1600 (ESMT memory) */
77#define CX18_CARD_HVR_1600_SAMSUNG 1 /* Hauppauge HVR 1600 (Samsung memory) */
78#define CX18_CARD_COMPRO_H900 2 /* Compro VideoMate H900 */
79#define CX18_CARD_YUAN_MPC718 3 /* Yuan MPC718 */
Sri Deevi03c28082008-06-21 11:06:44 -030080#define CX18_CARD_CNXT_RAPTOR_PAL 4 /* Conexant Raptor PAL */
Andy Walls9eee4fb2008-10-04 20:28:40 -030081#define CX18_CARD_TOSHIBA_QOSMIO_DVBT 5 /* Toshiba Qosmio Interal DVB-T/Analog*/
82#define CX18_CARD_LEADTEK_PVR2100 6 /* Leadtek WinFast PVR2100 */
83#define CX18_CARD_LAST 6
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030084
85#define CX18_ENC_STREAM_TYPE_MPG 0
86#define CX18_ENC_STREAM_TYPE_TS 1
87#define CX18_ENC_STREAM_TYPE_YUV 2
88#define CX18_ENC_STREAM_TYPE_VBI 3
89#define CX18_ENC_STREAM_TYPE_PCM 4
90#define CX18_ENC_STREAM_TYPE_IDX 5
91#define CX18_ENC_STREAM_TYPE_RAD 6
92#define CX18_MAX_STREAMS 7
93
94/* system vendor and device IDs */
95#define PCI_VENDOR_ID_CX 0x14f1
96#define PCI_DEVICE_ID_CX23418 0x5b7a
97
98/* subsystem vendor ID */
99#define CX18_PCI_ID_HAUPPAUGE 0x0070
100#define CX18_PCI_ID_COMPRO 0x185b
101#define CX18_PCI_ID_YUAN 0x12ab
Sri Deevi03c28082008-06-21 11:06:44 -0300102#define CX18_PCI_ID_CONEXANT 0x14f1
Andy Walls9eee4fb2008-10-04 20:28:40 -0300103#define CX18_PCI_ID_TOSHIBA 0x1179
104#define CX18_PCI_ID_LEADTEK 0x107D
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300105
106/* ======================================================================== */
107/* ========================== START USER SETTABLE DMA VARIABLES =========== */
108/* ======================================================================== */
109
110/* DMA Buffers, Default size in MB allocated */
111#define CX18_DEFAULT_ENC_TS_BUFFERS 1
112#define CX18_DEFAULT_ENC_MPG_BUFFERS 2
113#define CX18_DEFAULT_ENC_IDX_BUFFERS 1
114#define CX18_DEFAULT_ENC_YUV_BUFFERS 2
115#define CX18_DEFAULT_ENC_VBI_BUFFERS 1
116#define CX18_DEFAULT_ENC_PCM_BUFFERS 1
117
Andy Walls6ecd86d2008-12-07 23:30:17 -0300118/* Maximum firmware DMA buffers per stream */
119#define CX18_MAX_MDLS_PER_STREAM 63
120
121/* DMA buffer, default size in kB allocated */
122#define CX18_DEFAULT_ENC_TS_BUFSIZE 32
123#define CX18_DEFAULT_ENC_MPG_BUFSIZE 32
124#define CX18_DEFAULT_ENC_IDX_BUFSIZE 32
125#define CX18_DEFAULT_ENC_YUV_BUFSIZE 128
126/* Default VBI bufsize based on standards supported by card tuner for now */
127#define CX18_DEFAULT_ENC_PCM_BUFSIZE 4
128
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300129/* i2c stuff */
130#define I2C_CLIENTS_MAX 16
131
132/* debugging */
133
134/* Flag to turn on high volume debugging */
135#define CX18_DBGFLG_WARN (1 << 0)
136#define CX18_DBGFLG_INFO (1 << 1)
137#define CX18_DBGFLG_API (1 << 2)
138#define CX18_DBGFLG_DMA (1 << 3)
139#define CX18_DBGFLG_IOCTL (1 << 4)
140#define CX18_DBGFLG_FILE (1 << 5)
141#define CX18_DBGFLG_I2C (1 << 6)
142#define CX18_DBGFLG_IRQ (1 << 7)
143/* Flag to turn on high volume debugging */
144#define CX18_DBGFLG_HIGHVOL (1 << 8)
145
146/* NOTE: extra space before comma in 'cx->num , ## args' is required for
147 gcc-2.95, otherwise it won't compile. */
148#define CX18_DEBUG(x, type, fmt, args...) \
149 do { \
150 if ((x) & cx18_debug) \
151 printk(KERN_INFO "cx18-%d " type ": " fmt, cx->num , ## args); \
152 } while (0)
153#define CX18_DEBUG_WARN(fmt, args...) CX18_DEBUG(CX18_DBGFLG_WARN, "warning", fmt , ## args)
154#define CX18_DEBUG_INFO(fmt, args...) CX18_DEBUG(CX18_DBGFLG_INFO, "info", fmt , ## args)
155#define CX18_DEBUG_API(fmt, args...) CX18_DEBUG(CX18_DBGFLG_API, "api", fmt , ## args)
156#define CX18_DEBUG_DMA(fmt, args...) CX18_DEBUG(CX18_DBGFLG_DMA, "dma", fmt , ## args)
157#define CX18_DEBUG_IOCTL(fmt, args...) CX18_DEBUG(CX18_DBGFLG_IOCTL, "ioctl", fmt , ## args)
158#define CX18_DEBUG_FILE(fmt, args...) CX18_DEBUG(CX18_DBGFLG_FILE, "file", fmt , ## args)
159#define CX18_DEBUG_I2C(fmt, args...) CX18_DEBUG(CX18_DBGFLG_I2C, "i2c", fmt , ## args)
160#define CX18_DEBUG_IRQ(fmt, args...) CX18_DEBUG(CX18_DBGFLG_IRQ, "irq", fmt , ## args)
161
162#define CX18_DEBUG_HIGH_VOL(x, type, fmt, args...) \
163 do { \
164 if (((x) & cx18_debug) && (cx18_debug & CX18_DBGFLG_HIGHVOL)) \
165 printk(KERN_INFO "cx18%d " type ": " fmt, cx->num , ## args); \
166 } while (0)
167#define CX18_DEBUG_HI_WARN(fmt, args...) CX18_DEBUG_HIGH_VOL(CX18_DBGFLG_WARN, "warning", fmt , ## args)
168#define CX18_DEBUG_HI_INFO(fmt, args...) CX18_DEBUG_HIGH_VOL(CX18_DBGFLG_INFO, "info", fmt , ## args)
169#define CX18_DEBUG_HI_API(fmt, args...) CX18_DEBUG_HIGH_VOL(CX18_DBGFLG_API, "api", fmt , ## args)
170#define CX18_DEBUG_HI_DMA(fmt, args...) CX18_DEBUG_HIGH_VOL(CX18_DBGFLG_DMA, "dma", fmt , ## args)
171#define CX18_DEBUG_HI_IOCTL(fmt, args...) CX18_DEBUG_HIGH_VOL(CX18_DBGFLG_IOCTL, "ioctl", fmt , ## args)
172#define CX18_DEBUG_HI_FILE(fmt, args...) CX18_DEBUG_HIGH_VOL(CX18_DBGFLG_FILE, "file", fmt , ## args)
173#define CX18_DEBUG_HI_I2C(fmt, args...) CX18_DEBUG_HIGH_VOL(CX18_DBGFLG_I2C, "i2c", fmt , ## args)
174#define CX18_DEBUG_HI_IRQ(fmt, args...) CX18_DEBUG_HIGH_VOL(CX18_DBGFLG_IRQ, "irq", fmt , ## args)
175
176/* Standard kernel messages */
177#define CX18_ERR(fmt, args...) printk(KERN_ERR "cx18-%d: " fmt, cx->num , ## args)
178#define CX18_WARN(fmt, args...) printk(KERN_WARNING "cx18-%d: " fmt, cx->num , ## args)
179#define CX18_INFO(fmt, args...) printk(KERN_INFO "cx18-%d: " fmt, cx->num , ## args)
180
181/* Values for CX18_API_DEC_PLAYBACK_SPEED mpeg_frame_type_mask parameter: */
182#define MPEG_FRAME_TYPE_IFRAME 1
183#define MPEG_FRAME_TYPE_IFRAME_PFRAME 3
184#define MPEG_FRAME_TYPE_ALL 7
185
186#define CX18_MAX_PGM_INDEX (400)
187
188extern int cx18_debug;
189
190
191struct cx18_options {
192 int megabytes[CX18_MAX_STREAMS]; /* Size in megabytes of each stream */
193 int cardtype; /* force card type on load */
194 int tuner; /* set tuner on load */
195 int radio; /* enable/disable radio */
196};
197
198/* per-buffer bit flags */
199#define CX18_F_B_NEED_BUF_SWAP 0 /* this buffer should be byte swapped */
200
201/* per-stream, s_flags */
202#define CX18_F_S_CLAIMED 3 /* this stream is claimed */
203#define CX18_F_S_STREAMING 4 /* the fw is decoding/encoding this stream */
204#define CX18_F_S_INTERNAL_USE 5 /* this stream is used internally (sliced VBI processing) */
205#define CX18_F_S_STREAMOFF 7 /* signal end of stream EOS */
206#define CX18_F_S_APPL_IO 8 /* this stream is used read/written by an application */
207
208/* per-cx18, i_flags */
Andy Walls1d6782b2008-11-05 00:49:14 -0300209#define CX18_F_I_LOADED_FW 0 /* Loaded firmware 1st time */
210#define CX18_F_I_EOS 4 /* End of encoder stream */
211#define CX18_F_I_RADIO_USER 5 /* radio tuner is selected */
212#define CX18_F_I_ENC_PAUSED 13 /* the encoder is paused */
Andy Walls1d6782b2008-11-05 00:49:14 -0300213#define CX18_F_I_INITED 21 /* set after first open */
214#define CX18_F_I_FAILED 22 /* set if first open failed */
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300215
216/* These are the VBI types as they appear in the embedded VBI private packets. */
217#define CX18_SLICED_TYPE_TELETEXT_B (1)
218#define CX18_SLICED_TYPE_CAPTION_525 (4)
219#define CX18_SLICED_TYPE_WSS_625 (5)
220#define CX18_SLICED_TYPE_VPS (7)
221
222struct cx18_buffer {
223 struct list_head list;
224 dma_addr_t dma_handle;
225 u32 id;
226 unsigned long b_flags;
Andy Wallsbca11a52008-11-19 01:24:33 -0300227 unsigned skipped;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300228 char *buf;
229
230 u32 bytesused;
231 u32 readpos;
232};
233
234struct cx18_queue {
235 struct list_head list;
Andy Wallsb04bce42008-08-22 21:03:11 -0300236 atomic_t buffers;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300237 u32 bytesused;
238};
239
240struct cx18_dvb {
241 struct dmx_frontend hw_frontend;
242 struct dmx_frontend mem_frontend;
243 struct dmxdev dmxdev;
244 struct dvb_adapter dvb_adapter;
245 struct dvb_demux demux;
246 struct dvb_frontend *fe;
247 struct dvb_net dvbnet;
248 int enabled;
249 int feeding;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300250 struct mutex feedlock;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300251};
252
253struct cx18; /* forward reference */
254struct cx18_scb; /* forward reference */
255
Andy Walls72a4f802008-11-16 21:18:00 -0300256
Andy Wallsee2d64f2008-11-16 01:38:19 -0300257#define CX18_MAX_MDL_ACKS 2
258#define CX18_MAX_EPU_WORK_ORDERS 70 /* CPU_DE_RELEASE_MDL bursts 63 commands */
259
Andy Walls72a4f802008-11-16 21:18:00 -0300260#define CX18_F_EWO_MB_STALE_UPON_RECEIPT 0x1
261#define CX18_F_EWO_MB_STALE_WHILE_PROC 0x2
262#define CX18_F_EWO_MB_STALE \
263 (CX18_F_EWO_MB_STALE_UPON_RECEIPT | CX18_F_EWO_MB_STALE_WHILE_PROC)
264
Andy Wallsee2d64f2008-11-16 01:38:19 -0300265struct cx18_epu_work_order {
266 struct work_struct work;
267 atomic_t pending;
268 struct cx18 *cx;
Andy Walls72a4f802008-11-16 21:18:00 -0300269 unsigned long flags;
Andy Wallsee2d64f2008-11-16 01:38:19 -0300270 int rpu;
271 struct cx18_mailbox mb;
272 struct cx18_mdl_ack mdl_ack[CX18_MAX_MDL_ACKS];
273 char *str;
274};
275
Andy Wallsd3c5e702008-08-23 16:42:29 -0300276#define CX18_INVALID_TASK_HANDLE 0xffffffff
277
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300278struct cx18_stream {
279 /* These first four fields are always set, even if the stream
280 is not actually created. */
281 struct video_device *v4l2dev; /* NULL when stream not created */
282 struct cx18 *cx; /* for ease of use */
283 const char *name; /* name of the stream */
284 int type; /* stream type */
285 u32 handle; /* task handle */
286 unsigned mdl_offset;
287
288 u32 id;
Andy Wallsf576cee2008-11-16 20:18:05 -0300289 struct mutex qlock; /* locks access to the queues */
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300290 unsigned long s_flags; /* status flags, see above */
291 int dma; /* can be PCI_DMA_TODEVICE,
292 PCI_DMA_FROMDEVICE or
293 PCI_DMA_NONE */
294 u64 dma_pts;
295 wait_queue_head_t waitq;
296
297 /* Buffer Stats */
298 u32 buffers;
299 u32 buf_size;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300300
301 /* Buffer Queues */
302 struct cx18_queue q_free; /* free buffers */
Andy Walls66c2a6b2008-12-08 23:02:45 -0300303 struct cx18_queue q_busy; /* busy buffers - in use by firmware */
304 struct cx18_queue q_full; /* full buffers - data for user apps */
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300305
306 /* DVB / Digital Transport */
307 struct cx18_dvb dvb;
308};
309
310struct cx18_open_id {
311 u32 open_id;
312 int type;
313 enum v4l2_priority prio;
314 struct cx18 *cx;
315};
316
317/* forward declaration of struct defined in cx18-cards.h */
318struct cx18_card;
319
320
321#define CX18_VBI_FRAMES 32
322
323/* VBI data */
324struct vbi_info {
325 u32 enc_size;
326 u32 frame;
327 u8 cc_data_odd[256];
328 u8 cc_data_even[256];
329 int cc_pos;
330 u8 cc_no_update;
331 u8 vps[5];
332 u8 vps_found;
333 int wss;
334 u8 wss_found;
335 u8 wss_no_update;
336 u32 raw_decoder_line_size;
337 u8 raw_decoder_sav_odd_field;
338 u8 raw_decoder_sav_even_field;
339 u32 sliced_decoder_line_size;
340 u8 sliced_decoder_sav_odd_field;
341 u8 sliced_decoder_sav_even_field;
342 struct v4l2_format in;
343 /* convenience pointer to sliced struct in vbi_in union */
344 struct v4l2_sliced_vbi_format *sliced_in;
345 u32 service_set_in;
346 int insert_mpeg;
347
348 /* Buffer for the maximum of 2 * 18 * packet_size sliced VBI lines.
349 One for /dev/vbi0 and one for /dev/vbi8 */
350 struct v4l2_sliced_vbi_data sliced_data[36];
351
352 /* Buffer for VBI data inserted into MPEG stream.
353 The first byte is a dummy byte that's never used.
354 The next 16 bytes contain the MPEG header for the VBI data,
355 the remainder is the actual VBI data.
356 The max size accepted by the MPEG VBI reinsertion turns out
357 to be 1552 bytes, which happens to be 4 + (1 + 42) * (2 * 18) bytes,
358 where 4 is a four byte header, 42 is the max sliced VBI payload, 1 is
359 a single line header byte and 2 * 18 is the number of VBI lines per frame.
360
361 However, it seems that the data must be 1K aligned, so we have to
362 pad the data until the 1 or 2 K boundary.
363
364 This pointer array will allocate 2049 bytes to store each VBI frame. */
365 u8 *sliced_mpeg_data[CX18_VBI_FRAMES];
366 u32 sliced_mpeg_size[CX18_VBI_FRAMES];
367 struct cx18_buffer sliced_mpeg_buf;
368 u32 inserted_frame;
369
370 u32 start[2], count;
371 u32 raw_size;
372 u32 sliced_size;
373};
374
375/* Per cx23418, per I2C bus private algo callback data */
376struct cx18_i2c_algo_callback_data {
377 struct cx18 *cx;
378 int bus_index; /* 0 or 1 for the cx23418's 1st or 2nd I2C bus */
379};
380
Andy Wallsf7823f82008-11-02 18:15:28 -0300381#define CX18_MAX_MMIO_WR_RETRIES 10
Andy Walls330c6ec2008-11-08 14:19:37 -0300382
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300383/* Struct to hold info about cx18 cards */
384struct cx18 {
385 int num; /* board number, -1 during init! */
386 char name[8]; /* board name for printk and interrupts (e.g. 'cx180') */
387 struct pci_dev *dev; /* PCI device */
388 const struct cx18_card *card; /* card information */
389 const char *card_name; /* full name of the card */
390 const struct cx18_card_tuner_i2c *card_i2c; /* i2c addresses to probe for tuner */
391 u8 is_50hz;
392 u8 is_60hz;
393 u8 is_out_50hz;
394 u8 is_out_60hz;
395 u8 nof_inputs; /* number of video inputs */
396 u8 nof_audio_inputs; /* number of audio inputs */
397 u16 buffer_id; /* buffer ID counter */
398 u32 v4l2_cap; /* V4L2 capabilities of card */
399 u32 hw_flags; /* Hardware description of the board */
400 unsigned mdl_offset;
Andy Walls72c2d6d2008-11-06 01:15:41 -0300401 struct cx18_scb __iomem *scb; /* pointer to SCB */
402 struct mutex epu2apu_mb_lock; /* protect driver to chip mailbox in SCB*/
403 struct mutex epu2cpu_mb_lock; /* protect driver to chip mailbox in SCB*/
404
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300405 struct cx18_av_state av_state;
406
407 /* codec settings */
408 struct cx2341x_mpeg_params params;
409 u32 filter_mode;
410 u32 temporal_strength;
411 u32 spatial_strength;
412
413 /* dualwatch */
414 unsigned long dualwatch_jiffies;
415 u16 dualwatch_stereo_mode;
416
417 /* Digitizer type */
418 int digitizer; /* 0x00EF = saa7114 0x00FO = saa7115 0x0106 = mic */
419
420 struct mutex serialize_lock; /* mutex used to serialize open/close/start/stop/ioctl operations */
421 struct cx18_options options; /* User options */
Andy Walls6ecd86d2008-12-07 23:30:17 -0300422 int stream_buffers[CX18_MAX_STREAMS]; /* # of buffers for each stream */
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300423 int stream_buf_size[CX18_MAX_STREAMS]; /* Stream buffer size */
424 struct cx18_stream streams[CX18_MAX_STREAMS]; /* Stream data */
425 unsigned long i_flags; /* global cx18 flags */
Hans Verkuil31554ae2008-05-25 11:21:27 -0300426 atomic_t ana_capturing; /* count number of active analog capture streams */
427 atomic_t tot_capturing; /* total count number of active capture streams */
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300428 spinlock_t lock; /* lock access to this struct */
429 int search_pack_header;
430
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300431 int open_id; /* incremented each time an open occurs, used as
432 unique ID. Starts at 1, so 0 can be used as
433 uninitialized value in the stream->id. */
434
435 u32 base_addr;
436 struct v4l2_prio_state prio;
437
438 u8 card_rev;
439 void __iomem *enc_mem, *reg_mem;
440
441 struct vbi_info vbi;
442
443 u32 pgm_info_offset;
444 u32 pgm_info_num;
445 u32 pgm_info_write_idx;
446 u32 pgm_info_read_idx;
447 struct v4l2_enc_idx_entry pgm_info[CX18_MAX_PGM_INDEX];
448
449 u64 mpg_data_received;
450 u64 vbi_data_inserted;
451
452 wait_queue_head_t mb_apu_waitq;
453 wait_queue_head_t mb_cpu_waitq;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300454 wait_queue_head_t cap_w;
455 /* when the current DMA is finished this queue is woken up */
456 wait_queue_head_t dma_waitq;
457
Andy Wallsd6c7e5f2008-11-17 22:48:46 -0300458 u32 sw1_irq_mask;
459 u32 sw2_irq_mask;
460 u32 hw2_irq_mask;
461
Andy Walls572bfea2008-11-25 21:43:05 -0300462 struct workqueue_struct *work_queue;
Andy Wallsee2d64f2008-11-16 01:38:19 -0300463 struct cx18_epu_work_order epu_work_order[CX18_MAX_EPU_WORK_ORDERS];
464 char epu_debug_str[256]; /* CX18_EPU_DEBUG is rare: use shared space */
Andy Walls1d6782b2008-11-05 00:49:14 -0300465
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300466 /* i2c */
467 struct i2c_adapter i2c_adap[2];
468 struct i2c_algo_bit_data i2c_algo[2];
469 struct cx18_i2c_algo_callback_data i2c_algo_cb_data[2];
470 struct i2c_client i2c_client[2];
471 struct mutex i2c_bus_lock[2];
472 struct i2c_client *i2c_clients[I2C_CLIENTS_MAX];
473
Hans Verkuilba60bc62008-05-25 14:34:36 -0300474 /* gpio */
475 u32 gpio_dir;
476 u32 gpio_val;
Andy Walls8abdd002008-07-13 19:05:25 -0300477 struct mutex gpio_lock;
Hans Verkuilba60bc62008-05-25 14:34:36 -0300478
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300479 /* v4l2 and User settings */
480
481 /* codec settings */
482 u32 audio_input;
483 u32 active_input;
484 u32 active_output;
485 v4l2_std_id std;
486 v4l2_std_id tuner_std; /* The norm of the tuner (fixed) */
487};
488
489/* Globals */
490extern struct cx18 *cx18_cards[];
491extern int cx18_cards_active;
492extern int cx18_first_minor;
493extern spinlock_t cx18_cards_lock;
494
495/*==============Prototypes==================*/
496
497/* Return non-zero if a signal is pending */
498int cx18_msleep_timeout(unsigned int msecs, int intr);
499
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300500/* Read Hauppauge eeprom */
501struct tveeprom; /* forward reference */
502void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv);
503
504/* First-open initialization: load firmware, etc. */
505int cx18_init_on_first_open(struct cx18 *cx);
506
Andy Wallsdd073432008-12-12 16:24:04 -0300507/* Test if the current VBI mode is raw (1) or sliced (0) */
508static inline int cx18_raw_vbi(const struct cx18 *cx)
509{
510 return cx->vbi.in.type == V4L2_BUF_TYPE_VBI_CAPTURE;
511}
512
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300513#endif /* CX18_DRIVER_H */