]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/media/video/saa7164/saa7164.h
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[mirror_ubuntu-bionic-kernel.git] / drivers / media / video / saa7164 / saa7164.h
CommitLineData
443c1228
ST
1/*
2 * Driver for the NXP SAA7164 PCIe bridge
3 *
9b8b0199 4 * Copyright (c) 2010 Steven Toth <stoth@kernellabs.com>
443c1228
ST
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 *
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22/*
23 Driver architecture
24 *******************
25
26 saa7164_core.c/buffer.c/cards.c/i2c.c/dvb.c
27 | : Standard Linux driver framework for creating
28 | : exposing and managing interfaces to the rest
29 | : of the kernel or userland. Also uses _fw.c to load
30 | : firmware direct into the PCIe bus, bypassing layers.
31 V
32 saa7164_api..() : Translate kernel specific functions/features
33 | : into command buffers.
34 V
35 saa7164_cmd..() : Manages the flow of command packets on/off,
36 | : the bus. Deal with bus errors, timeouts etc.
37 V
38 saa7164_bus..() : Manage a read/write memory ring buffer in the
39 | : PCIe Address space.
40 |
41 | saa7164_fw...() : Load any frimware
42 | | : direct into the device
43 V V
44 <- ----------------- PCIe address space -------------------- ->
45*/
46
47#include <linux/pci.h>
48#include <linux/i2c.h>
49#include <linux/i2c-algo-bit.h>
50#include <linux/kdev_t.h>
7615e434
ST
51#include <linux/version.h>
52#include <linux/mutex.h>
12d3203e 53#include <linux/crc32.h>
0b62ceb0
ST
54#include <linux/kthread.h>
55#include <linux/freezer.h>
443c1228
ST
56
57#include <media/tuner.h>
58#include <media/tveeprom.h>
59#include <media/videobuf-dma-sg.h>
60#include <media/videobuf-dvb.h>
7615e434
ST
61#include <dvb_demux.h>
62#include <dvb_frontend.h>
63#include <dvb_net.h>
64#include <dvbdev.h>
65#include <dmxdev.h>
66#include <media/v4l2-common.h>
67#include <media/v4l2-ioctl.h>
68#include <media/v4l2-chip-ident.h>
443c1228
ST
69
70#include "saa7164-reg.h"
71#include "saa7164-types.h"
72
443c1228
ST
73#define SAA7164_MAXBOARDS 8
74
75#define UNSET (-1U)
76#define SAA7164_BOARD_NOAUTO UNSET
77#define SAA7164_BOARD_UNKNOWN 0
78#define SAA7164_BOARD_UNKNOWN_REV2 1
79#define SAA7164_BOARD_UNKNOWN_REV3 2
80#define SAA7164_BOARD_HAUPPAUGE_HVR2250 3
81#define SAA7164_BOARD_HAUPPAUGE_HVR2200 4
82#define SAA7164_BOARD_HAUPPAUGE_HVR2200_2 5
83#define SAA7164_BOARD_HAUPPAUGE_HVR2200_3 6
84#define SAA7164_BOARD_HAUPPAUGE_HVR2250_2 7
e3335222 85#define SAA7164_BOARD_HAUPPAUGE_HVR2250_3 8
443c1228
ST
86
87#define SAA7164_MAX_UNITS 8
88#define SAA7164_TS_NUMBER_OF_LINES 312
a97781ac 89#define SAA7164_PS_NUMBER_OF_LINES 256
443c1228 90#define SAA7164_PT_ENTRIES 16 /* (312 * 188) / 4096 */
66e1d378 91#define SAA7164_MAX_ENCODER_BUFFERS 64 /* max 5secs of latency at 6Mbps */
e8ce2f21 92#define SAA7164_MAX_VBI_BUFFERS 64
7615e434
ST
93
94/* Port related defines */
95#define SAA7164_PORT_TS1 (0)
96#define SAA7164_PORT_TS2 (SAA7164_PORT_TS1 + 1)
97#define SAA7164_PORT_ENC1 (SAA7164_PORT_TS2 + 1)
98#define SAA7164_PORT_ENC2 (SAA7164_PORT_ENC1 + 1)
e8ce2f21
ST
99#define SAA7164_PORT_VBI1 (SAA7164_PORT_ENC2 + 1)
100#define SAA7164_PORT_VBI2 (SAA7164_PORT_VBI1 + 1)
101#define SAA7164_MAX_PORTS (SAA7164_PORT_VBI2 + 1)
443c1228
ST
102
103#define DBGLVL_FW 4
104#define DBGLVL_DVB 8
105#define DBGLVL_I2C 16
106#define DBGLVL_API 32
107#define DBGLVL_CMD 64
108#define DBGLVL_BUS 128
109#define DBGLVL_IRQ 256
110#define DBGLVL_BUF 512
9b8b0199 111#define DBGLVL_ENC 1024
e8ce2f21 112#define DBGLVL_VBI 2048
0b62ceb0 113#define DBGLVL_THR 4096
1247ff5c 114#define DBGLVL_CPU 8192
443c1228 115
bc250684
ST
116#define SAA7164_NORMS \
117 (V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_443)
7615e434 118
443c1228
ST
119enum port_t {
120 SAA7164_MPEG_UNDEFINED = 0,
121 SAA7164_MPEG_DVB,
add3f580 122 SAA7164_MPEG_ENCODER,
e8ce2f21 123 SAA7164_MPEG_VBI,
443c1228
ST
124};
125
126enum saa7164_i2c_bus_nr {
127 SAA7164_I2C_BUS_0 = 0,
128 SAA7164_I2C_BUS_1,
129 SAA7164_I2C_BUS_2,
130};
131
132enum saa7164_buffer_flags {
133 SAA7164_BUFFER_UNDEFINED = 0,
134 SAA7164_BUFFER_FREE,
135 SAA7164_BUFFER_BUSY,
136 SAA7164_BUFFER_FULL
137};
138
139enum saa7164_unit_type {
140 SAA7164_UNIT_UNDEFINED = 0,
141 SAA7164_UNIT_DIGITAL_DEMODULATOR,
142 SAA7164_UNIT_ANALOG_DEMODULATOR,
143 SAA7164_UNIT_TUNER,
144 SAA7164_UNIT_EEPROM,
145 SAA7164_UNIT_ZILOG_IRBLASTER,
146 SAA7164_UNIT_ENCODER,
147};
148
149/* The PCIe bridge doesn't grant direct access to i2c.
150 * Instead, you address i2c devices using a uniqely
151 * allocated 'unitid' value via a messaging API. This
152 * is a problem. The kernel and existing demod/tuner
153 * drivers expect to talk 'i2c', so we have to maintain
154 * a translation layer, and a series of functions to
155 * convert i2c bus + device address into a unit id.
156 */
157struct saa7164_unit {
158 enum saa7164_unit_type type;
159 u8 id;
160 char *name;
161 enum saa7164_i2c_bus_nr i2c_bus_nr;
162 u8 i2c_bus_addr;
163 u8 i2c_reg_len;
164};
165
166struct saa7164_board {
167 char *name;
e8ce2f21
ST
168 enum port_t porta, portb, portc,
169 portd, porte, portf;
443c1228
ST
170 enum {
171 SAA7164_CHIP_UNDEFINED = 0,
172 SAA7164_CHIP_REV2,
173 SAA7164_CHIP_REV3,
174 } chiprev;
175 struct saa7164_unit unit[SAA7164_MAX_UNITS];
176};
177
178struct saa7164_subid {
179 u16 subvendor;
180 u16 subdevice;
181 u32 card;
182};
183
96d8420d 184struct saa7164_encoder_fh {
7615e434 185 struct saa7164_port *port;
e8ce2f21
ST
186 atomic_t v4l_reading;
187};
188
189struct saa7164_vbi_fh {
190 struct saa7164_port *port;
7615e434
ST
191 atomic_t v4l_reading;
192};
193
91d80189
ST
194struct saa7164_histogram_bucket {
195 u32 val;
196 u32 count;
197 u64 update_time;
198};
199
200struct saa7164_histogram {
201 char name[32];
202 struct saa7164_histogram_bucket counter1[64];
203};
204
7615e434
ST
205struct saa7164_user_buffer {
206 struct list_head list;
207
208 /* Attributes */
209 u8 *data;
210 u32 pos;
211 u32 actual_size;
12d3203e
ST
212
213 u32 crc;
7615e434
ST
214};
215
443c1228
ST
216struct saa7164_fw_status {
217
218 /* RISC Core details */
219 u32 status;
220 u32 mode;
221 u32 spec;
222 u32 inst;
223 u32 cpuload;
224 u32 remainheap;
225
226 /* Firmware version */
227 u32 version;
228 u32 major;
229 u32 sub;
230 u32 rel;
231 u32 buildnr;
232};
233
234struct saa7164_dvb {
235 struct mutex lock;
236 struct dvb_adapter adapter;
237 struct dvb_frontend *frontend;
238 struct dvb_demux demux;
239 struct dmxdev dmxdev;
240 struct dmx_frontend fe_hw;
241 struct dmx_frontend fe_mem;
242 struct dvb_net net;
243 int feeding;
244};
245
246struct saa7164_i2c {
247 struct saa7164_dev *dev;
248
249 enum saa7164_i2c_bus_nr nr;
250
251 /* I2C I/O */
252 struct i2c_adapter i2c_adap;
253 struct i2c_algo_bit_data i2c_algo;
254 struct i2c_client i2c_client;
255 u32 i2c_rc;
256};
257
7615e434
ST
258struct saa7164_ctrl {
259 struct v4l2_queryctrl v;
260};
261
262struct saa7164_tvnorm {
263 char *name;
264 v4l2_std_id id;
7615e434
ST
265};
266
267struct saa7164_encoder_params {
268 struct saa7164_tvnorm encodernorm;
269 u32 height;
270 u32 width;
271 u32 is_50hz;
272 u32 bitrate; /* bps */
968b11b2 273 u32 bitrate_peak; /* bps */
2600d71c 274 u32 bitrate_mode;
7615e434
ST
275 u32 stream_type; /* V4L2_MPEG_STREAM_TYPE_MPEG2_TS */
276
277 u32 audio_sampling_freq;
278 u32 ctl_mute;
279 u32 ctl_aspect;
3ed43cf9 280 u32 refdist;
5fa56ccd 281 u32 gop_size;
7615e434
ST
282};
283
e8ce2f21
ST
284struct saa7164_vbi_params {
285 struct saa7164_tvnorm encodernorm;
286 u32 height;
287 u32 width;
288 u32 is_50hz;
289 u32 bitrate; /* bps */
290 u32 bitrate_peak; /* bps */
291 u32 bitrate_mode;
292 u32 stream_type; /* V4L2_MPEG_STREAM_TYPE_MPEG2_TS */
293
294 u32 audio_sampling_freq;
295 u32 ctl_mute;
296 u32 ctl_aspect;
297 u32 refdist;
298 u32 gop_size;
299};
300
add3f580 301struct saa7164_port;
443c1228
ST
302
303struct saa7164_buffer {
304 struct list_head list;
305
add3f580
ST
306 /* Note of which h/w buffer list index position we occupy */
307 int idx;
443c1228 308
add3f580 309 struct saa7164_port *port;
443c1228
ST
310
311 /* Hardware Specific */
312 /* PCI Memory allocations */
313 enum saa7164_buffer_flags flags; /* Free, Busy, Full */
314
315 /* A block of page align PCI memory */
316 u32 pci_size; /* PCI allocation size in bytes */
12d3203e 317 u64 __iomem *cpu; /* Virtual address */
443c1228 318 dma_addr_t dma; /* Physical address */
12d3203e 319 u32 crc; /* Checksum for the entire buffer data */
443c1228
ST
320
321 /* A page table that splits the block into a number of entries */
322 u32 pt_size; /* PCI allocation size in bytes */
12d3203e 323 u64 __iomem *pt_cpu; /* Virtual address */
443c1228 324 dma_addr_t pt_dma; /* Physical address */
add3f580
ST
325
326 /* Encoder fops */
327 u32 pos;
328 u32 actual_size;
443c1228
ST
329};
330
add3f580 331struct saa7164_port {
443c1228
ST
332
333 struct saa7164_dev *dev;
443c1228 334 enum port_t type;
add3f580 335 int nr;
443c1228 336
add3f580 337 /* --- Generic port attributes --- */
443c1228 338
add3f580 339 /* HW stream parameters */
4d270cfb 340 struct tmHWStreamParameters hw_streamingparams;
443c1228
ST
341
342 /* DMA configuration values, is seeded during initialization */
4d270cfb 343 struct tmComResDMATermDescrHeader hwcfg;
443c1228
ST
344
345 /* hardware specific registers */
346 u32 bufcounter;
347 u32 pitch;
348 u32 bufsize;
349 u32 bufoffset;
350 u32 bufptr32l;
351 u32 bufptr32h;
352 u64 bufptr64;
353
354 u32 numpte; /* Number of entries in array, only valid in head */
add3f580 355
443c1228 356 struct mutex dmaqueue_lock;
443c1228 357 struct saa7164_buffer dmaqueue;
add3f580 358
91d80189
ST
359 u64 last_irq_msecs, last_svc_msecs;
360 u64 last_irq_msecs_diff, last_svc_msecs_diff;
cfbaf337
ST
361 u32 last_svc_wp;
362 u32 last_svc_rp;
91d80189 363 u64 last_irq_svc_msecs_diff;
58acca10
ST
364 u64 last_read_msecs, last_read_msecs_diff;
365 u64 last_poll_msecs, last_poll_msecs_diff;
91d80189
ST
366
367 struct saa7164_histogram irq_interval;
368 struct saa7164_histogram svc_interval;
369 struct saa7164_histogram irq_svc_interval;
58acca10
ST
370 struct saa7164_histogram read_interval;
371 struct saa7164_histogram poll_interval;
91d80189 372
add3f580
ST
373 /* --- DVB Transport Specific --- */
374 struct saa7164_dvb dvb;
375
376 /* --- Encoder/V4L related attributes --- */
7615e434
ST
377 /* Encoder */
378 /* Defaults established in saa7164-encoder.c */
379 struct saa7164_tvnorm encodernorm;
380 u32 height;
381 u32 width;
382 u32 freq;
383 u32 ts_packet_size;
384 u32 ts_packet_count;
385 u8 mux_input;
386 u8 encoder_profile;
387 u8 video_format;
388 u8 audio_format;
389 u8 video_resolution;
390 u16 ctl_brightness;
391 u16 ctl_contrast;
392 u16 ctl_hue;
393 u16 ctl_saturation;
394 u16 ctl_sharpness;
395 s8 ctl_volume;
396
4d270cfb
MCC
397 struct tmComResAFeatureDescrHeader audfeat;
398 struct tmComResEncoderDescrHeader encunit;
399 struct tmComResProcDescrHeader vidproc;
400 struct tmComResExtDevDescrHeader ifunit;
401 struct tmComResTunerDescrHeader tunerunit;
7615e434 402
91d80189
ST
403 struct work_struct workenc;
404
e8ce2f21 405 /* V4L Encoder Video */
7615e434
ST
406 struct saa7164_encoder_params encoder_params;
407 struct video_device *v4l_device;
408 atomic_t v4l_reader_count;
7615e434
ST
409
410 struct saa7164_buffer list_buf_used;
411 struct saa7164_buffer list_buf_free;
412 wait_queue_head_t wait_read;
9230acaa 413
e8ce2f21 414 /* V4L VBI */
4d270cfb 415 struct tmComResVBIFormatDescrHeader vbi_fmt_ntsc;
e8ce2f21
ST
416 struct saa7164_vbi_params vbi_params;
417
9230acaa
ST
418 /* Debug */
419 u32 sync_errors;
420 u32 v_cc_errors;
421 u32 a_cc_errors;
422 u8 last_v_cc;
423 u8 last_a_cc;
1b0e8e46 424 u32 done_first_interrupt;
443c1228
ST
425};
426
427struct saa7164_dev {
428 struct list_head devlist;
429 atomic_t refcount;
430
431 /* pci stuff */
432 struct pci_dev *pci;
433 unsigned char pci_rev, pci_lat;
434 int pci_bus, pci_slot;
435 u32 __iomem *lmmio;
436 u8 __iomem *bmmio;
437 u32 __iomem *lmmio2;
438 u8 __iomem *bmmio2;
439 int pci_irqmask;
440
441 /* board details */
442 int nr;
443 int hwrevision;
444 u32 board;
0e72cc8b 445 char name[16];
443c1228
ST
446
447 /* firmware status */
448 struct saa7164_fw_status fw_status;
22760ed3 449 u32 firmwareloaded;
443c1228 450
4d270cfb
MCC
451 struct tmComResHWDescr hwdesc;
452 struct tmComResInterfaceDescr intfdesc;
453 struct tmComResBusDescr busdesc;
443c1228 454
4d270cfb 455 struct tmComResBusInfo bus;
443c1228 456
1a6450d4
ST
457 /* Interrupt status and ack registers */
458 u32 int_status;
459 u32 int_ack;
443c1228
ST
460
461 struct cmd cmds[SAA_CMD_MAX_MSG_UNITS];
462 struct mutex lock;
463
464 /* I2c related */
465 struct saa7164_i2c i2c_bus[3];
466
467 /* Transport related */
c7e242ba 468 struct saa7164_port ports[SAA7164_MAX_PORTS];
443c1228
ST
469
470 /* Deferred command/api interrupts handling */
471 struct work_struct workcmd;
472
0b62ceb0
ST
473 /* A kernel thread to monitor the firmware log, used
474 * only in debug mode.
475 */
476 struct task_struct *kthread;
477
443c1228
ST
478};
479
480extern struct list_head saa7164_devlist;
dd1ee444 481extern unsigned int waitsecs;
66e1d378 482extern unsigned int encoder_buffers;
e8ce2f21 483extern unsigned int vbi_buffers;
443c1228
ST
484
485/* ----------------------------------------------------------- */
486/* saa7164-core.c */
487void saa7164_dumpregs(struct saa7164_dev *dev, u32 addr);
488void saa7164_dumphex16(struct saa7164_dev *dev, u8 *buf, int len);
489void saa7164_getfirmwarestatus(struct saa7164_dev *dev);
490u32 saa7164_getcurrentfirmwareversion(struct saa7164_dev *dev);
58acca10 491void saa7164_histogram_update(struct saa7164_histogram *hg, u32 val);
443c1228
ST
492
493/* ----------------------------------------------------------- */
494/* saa7164-fw.c */
495int saa7164_downloadfirmware(struct saa7164_dev *dev);
496
497/* ----------------------------------------------------------- */
498/* saa7164-i2c.c */
499extern int saa7164_i2c_register(struct saa7164_i2c *bus);
500extern int saa7164_i2c_unregister(struct saa7164_i2c *bus);
501extern void saa7164_call_i2c_clients(struct saa7164_i2c *bus,
502 unsigned int cmd, void *arg);
503
504/* ----------------------------------------------------------- */
505/* saa7164-bus.c */
506int saa7164_bus_setup(struct saa7164_dev *dev);
507void saa7164_bus_dump(struct saa7164_dev *dev);
bc250684
ST
508int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg,
509 void *buf);
4d270cfb 510int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
443c1228
ST
511 void *buf, int peekonly);
512
513/* ----------------------------------------------------------- */
514/* saa7164-cmd.c */
515int saa7164_cmd_send(struct saa7164_dev *dev,
4d270cfb 516 u8 id, enum tmComResCmd command, u16 controlselector,
443c1228
ST
517 u16 size, void *buf);
518void saa7164_cmd_signal(struct saa7164_dev *dev, u8 seqno);
39e469ab 519int saa7164_irq_dequeue(struct saa7164_dev *dev);
443c1228
ST
520
521/* ----------------------------------------------------------- */
522/* saa7164-api.c */
443c1228
ST
523int saa7164_api_get_fw_version(struct saa7164_dev *dev, u32 *version);
524int saa7164_api_enum_subdevs(struct saa7164_dev *dev);
525int saa7164_api_i2c_read(struct saa7164_i2c *bus, u8 addr, u32 reglen, u8 *reg,
526 u32 datalen, u8 *data);
527int saa7164_api_i2c_write(struct saa7164_i2c *bus, u8 addr,
528 u32 datalen, u8 *data);
529int saa7164_api_dif_write(struct saa7164_i2c *bus, u8 addr,
530 u32 datalen, u8 *data);
531int saa7164_api_read_eeprom(struct saa7164_dev *dev, u8 *buf, int buflen);
532int saa7164_api_set_gpiobit(struct saa7164_dev *dev, u8 unitid, u8 pin);
533int saa7164_api_clear_gpiobit(struct saa7164_dev *dev, u8 unitid, u8 pin);
add3f580 534int saa7164_api_transition_port(struct saa7164_port *port, u8 mode);
7615e434
ST
535int saa7164_api_initialize_dif(struct saa7164_port *port);
536int saa7164_api_configure_dif(struct saa7164_port *port, u32 std);
537int saa7164_api_set_encoder(struct saa7164_port *port);
538int saa7164_api_get_encoder(struct saa7164_port *port);
539int saa7164_api_set_aspect_ratio(struct saa7164_port *port);
540int saa7164_api_set_usercontrol(struct saa7164_port *port, u8 ctl);
541int saa7164_api_get_usercontrol(struct saa7164_port *port, u8 ctl);
542int saa7164_api_set_videomux(struct saa7164_port *port);
543int saa7164_api_audio_mute(struct saa7164_port *port, int mute);
544int saa7164_api_set_audio_volume(struct saa7164_port *port, s8 level);
545int saa7164_api_set_audio_std(struct saa7164_port *port);
546int saa7164_api_set_audio_detection(struct saa7164_port *port, int autodetect);
547int saa7164_api_get_videomux(struct saa7164_port *port);
e8ce2f21 548int saa7164_api_set_vbi_format(struct saa7164_port *port);
e48836b8 549int saa7164_api_set_debug(struct saa7164_dev *dev, u8 level);
0b62ceb0 550int saa7164_api_collect_debug(struct saa7164_dev *dev);
bc250684
ST
551int saa7164_api_get_load_info(struct saa7164_dev *dev,
552 struct tmFwInfoStruct *i);
443c1228
ST
553
554/* ----------------------------------------------------------- */
555/* saa7164-cards.c */
556extern struct saa7164_board saa7164_boards[];
557extern const unsigned int saa7164_bcount;
558
559extern struct saa7164_subid saa7164_subids[];
560extern const unsigned int saa7164_idcount;
561
562extern void saa7164_card_list(struct saa7164_dev *dev);
563extern void saa7164_gpio_setup(struct saa7164_dev *dev);
564extern void saa7164_card_setup(struct saa7164_dev *dev);
565
566extern int saa7164_i2caddr_to_reglen(struct saa7164_i2c *bus, int addr);
567extern int saa7164_i2caddr_to_unitid(struct saa7164_i2c *bus, int addr);
568extern char *saa7164_unitid_name(struct saa7164_dev *dev, u8 unitid);
569
570/* ----------------------------------------------------------- */
571/* saa7164-dvb.c */
add3f580
ST
572extern int saa7164_dvb_register(struct saa7164_port *port);
573extern int saa7164_dvb_unregister(struct saa7164_port *port);
443c1228
ST
574
575/* ----------------------------------------------------------- */
576/* saa7164-buffer.c */
add3f580
ST
577extern struct saa7164_buffer *saa7164_buffer_alloc(
578 struct saa7164_port *port, u32 len);
579extern int saa7164_buffer_dealloc(struct saa7164_buffer *buf);
580extern void saa7164_buffer_display(struct saa7164_buffer *buf);
581extern int saa7164_buffer_activate(struct saa7164_buffer *buf, int i);
582extern int saa7164_buffer_cfg_port(struct saa7164_port *port);
7615e434
ST
583extern struct saa7164_user_buffer *saa7164_buffer_alloc_user(
584 struct saa7164_dev *dev, u32 len);
585extern void saa7164_buffer_dealloc_user(struct saa7164_user_buffer *buf);
9230acaa 586extern int saa7164_buffer_zero_offsets(struct saa7164_port *port, int i);
7615e434 587
7615e434
ST
588/* ----------------------------------------------------------- */
589/* saa7164-encoder.c */
590int saa7164_encoder_register(struct saa7164_port *port);
591void saa7164_encoder_unregister(struct saa7164_port *port);
443c1228 592
e8ce2f21
ST
593/* ----------------------------------------------------------- */
594/* saa7164-vbi.c */
595int saa7164_vbi_register(struct saa7164_port *port);
596void saa7164_vbi_unregister(struct saa7164_port *port);
597
443c1228
ST
598/* ----------------------------------------------------------- */
599
1b0e8e46
ST
600extern unsigned int crc_checking;
601
b1912a85 602extern unsigned int saa_debug;
443c1228 603#define dprintk(level, fmt, arg...)\
b1912a85 604 do { if (saa_debug & level)\
443c1228
ST
605 printk(KERN_DEBUG "%s: " fmt, dev->name, ## arg);\
606 } while (0)
607
608#define log_warn(fmt, arg...)\
609 do { \
610 printk(KERN_WARNING "%s: " fmt, dev->name, ## arg);\
611 } while (0)
612
613#define log_err(fmt, arg...)\
614 do { \
615 printk(KERN_ERROR "%s: " fmt, dev->name, ## arg);\
616 } while (0)
617
618#define saa7164_readl(reg) readl(dev->lmmio + ((reg) >> 2))
207b42c4
ST
619#define saa7164_writel(reg, value) writel((value), dev->lmmio + ((reg) >> 2))
620
443c1228
ST
621#define saa7164_readb(reg) readl(dev->bmmio + (reg))
622#define saa7164_writeb(reg, value) writel((value), dev->bmmio + (reg))
623