bttvp.h revision 76ea992a036c4a5d3bc606a79ef775dd32fd3daa
11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds    bttv - Bt848 frame grabber driver
41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds    bttv's *private* header file  --  nobody other than bttv itself
61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds    should ever include this file.
71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds    (c) 2000-2002 Gerd Knorr <kraxel@bytesex.org>
91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds    This program is free software; you can redistribute it and/or modify
111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds    it under the terms of the GNU General Public License as published by
121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds    the Free Software Foundation; either version 2 of the License, or
131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds    (at your option) any later version.
141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds    This program is distributed in the hope that it will be useful,
161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds    but WITHOUT ANY WARRANTY; without even the implied warranty of
171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds    GNU General Public License for more details.
191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds    You should have received a copy of the GNU General Public License
211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds    along with this program; if not, write to the Free Software
221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds*/
241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifndef _BTTVP_H_
261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define _BTTVP_H_
271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/types.h>
291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/wait.h>
301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/i2c.h>
311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/i2c-algo-bit.h>
321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/pci.h>
331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/input.h>
34bd5f0ac930168899003952110c45d110958a5c55Ingo Molnar#include <linux/mutex.h>
3587ae9afdcada236d0a1b38ce2c465a65916961dcAdrian Bunk#include <linux/scatterlist.h>
361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/io.h>
3718f3fa1e2eab297a2f7ec704385fa0ecfda0de55Mauro Carvalho Chehab#include <media/v4l2-common.h>
381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/device.h>
39c1accaa21bdef38ec0f36eaaf7ce3384fff9d0c5Mauro Carvalho Chehab#include <media/videobuf-dma-sg.h>
401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <media/tveeprom.h>
416bda96447cef24fbf97a798b1ea664224d5fdc25Mauro Carvalho Chehab#include <media/rc-core.h>
42c0c46826274a4da5d9e312d7cfd4ca0806c0a358Mauro Carvalho Chehab#include <media/ir-kbd-i2c.h>
43674434c691e10015660022fc00b04985a23ef87bMauro Carvalho Chehab
441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include "bt848.h"
451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include "bttv.h"
461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include "btcx-risc.h"
471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef __KERNEL__
491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define FORMAT_FLAGS_DITHER       0x01
511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define FORMAT_FLAGS_PACKED       0x02
521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define FORMAT_FLAGS_PLANAR       0x04
531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define FORMAT_FLAGS_RAW          0x08
541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define FORMAT_FLAGS_CrCb         0x10
551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RISC_SLOT_O_VBI        4
571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RISC_SLOT_O_FIELD      6
581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RISC_SLOT_E_VBI       10
591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RISC_SLOT_E_FIELD     12
601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RISC_SLOT_LOOP        14
611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RESOURCE_OVERLAY       1
63e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek#define RESOURCE_VIDEO_STREAM  2
641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RESOURCE_VBI           4
65e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek#define RESOURCE_VIDEO_READ    8
661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RAW_LINES            640
681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RAW_BPL             1024
691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define UNSET (-1U)
711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
72e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek/* Min. value in VDELAY register. */
73e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek#define MIN_VDELAY 2
74e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek/* Even to get Cb first, odd for Cr. */
75e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek#define MAX_HDELAY (0x3FF & -2)
76e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek/* Limits scaled width, which must be a multiple of 4. */
77e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek#define MAX_HACTIVE (0x3FF & -4)
78e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek
79402aa76aa5e57801b4db5ccf8c7beea9f580bb1bDouglas Schilling Landgraf#define BTTV_NORMS    (\
80402aa76aa5e57801b4db5ccf8c7beea9f580bb1bDouglas Schilling Landgraf		V4L2_STD_PAL    | V4L2_STD_PAL_N | \
81402aa76aa5e57801b4db5ccf8c7beea9f580bb1bDouglas Schilling Landgraf		V4L2_STD_PAL_Nc | V4L2_STD_SECAM | \
82402aa76aa5e57801b4db5ccf8c7beea9f580bb1bDouglas Schilling Landgraf		V4L2_STD_NTSC   | V4L2_STD_PAL_M | \
83402aa76aa5e57801b4db5ccf8c7beea9f580bb1bDouglas Schilling Landgraf		V4L2_STD_PAL_60)
841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* ---------------------------------------------------------- */
851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct bttv_tvnorm {
871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int   v4l2_id;
881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	char  *name;
894ac97914c6c35f6bf132071c718e034d0846b9f5Mauro Carvalho Chehab	u32   Fsc;
904ac97914c6c35f6bf132071c718e034d0846b9f5Mauro Carvalho Chehab	u16   swidth, sheight; /* scaled standard width, height */
911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u16   totalwidth;
921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u8    adelay, bdelay, iform;
931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32   scaledtwidth;
941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u16   hdelayx1, hactivex1;
951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u16   vdelay;
964ac97914c6c35f6bf132071c718e034d0846b9f5Mauro Carvalho Chehab	u8    vbipack;
971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u16   vtotal;
981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int   sram;
9967f1570a0659abba5efbf55cc986187af61bdd52Michael H. Schimek	/* ITU-R frame line number of the first VBI line we can
100e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	   capture, of the first and second field. The last possible line
101e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	   is determined by cropcap.bounds. */
10267f1570a0659abba5efbf55cc986187af61bdd52Michael H. Schimek	u16   vbistart[2];
103e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	/* Horizontally this counts fCLKx1 samples following the leading
104e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	   edge of the horizontal sync pulse, vertically ITU-R frame line
105e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	   numbers of the first field times two (2, 4, 6, ... 524 or 624). */
106e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	struct v4l2_cropcap cropcap;
1071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
1081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern const struct bttv_tvnorm bttv_tvnorms[];
1091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct bttv_format {
1111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	char *name;
1121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int  fourcc;          /* video4linux 2      */
1131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int  btformat;        /* BT848_COLOR_FMT_*  */
1141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int  btswap;          /* BT848_COLOR_CTL_*  */
1151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int  depth;           /* bit/pixel          */
1161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int  flags;
1171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int  hshift,vshift;   /* for planar modes   */
1181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
1191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
120edb4c25ca3a7997660500692eca3510eac9726e5David Härdemanstruct bttv_ir {
121a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab	struct rc_dev           *dev;
1223938e0cfeb812e7b66f4e1cb6e34eb2e6864c6a2David Härdeman	struct timer_list       timer;
123a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab
124a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab	char                    name[32];
125a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab	char                    phys[32];
126edb4c25ca3a7997660500692eca3510eac9726e5David Härdeman
127a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab	/* Usual gpio signalling */
128a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab	u32                     mask_keycode;
129a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab	u32                     mask_keydown;
130a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab	u32                     mask_keyup;
131a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab	u32                     polling;
132a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab	u32                     last_gpio;
133a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab	int                     shift_by;
134a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab	int                     start; // What should RC5_START() be
135a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab	int                     addr; // What RC5_ADDR() should be.
136a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab	int                     rc5_remote_gap;
137a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab
138a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab	/* RC5 gpio */
139b7c7a4bed8d695933ae172031556de9de30ae598Mauro Carvalho Chehab	bool			rc5_gpio;   /* Is RC5 legacy GPIO enabled? */
140edb4c25ca3a7997660500692eca3510eac9726e5David Härdeman	u32                     last_bit;   /* last raw bit seen */
141edb4c25ca3a7997660500692eca3510eac9726e5David Härdeman	u32                     code;       /* raw code under construction */
142edb4c25ca3a7997660500692eca3510eac9726e5David Härdeman	struct timeval          base_time;  /* time of last seen code */
143edb4c25ca3a7997660500692eca3510eac9726e5David Härdeman	bool                    active;     /* building raw code */
144a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab};
145a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab
146a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab
1471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* ---------------------------------------------------------- */
1481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct bttv_geometry {
1501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u8  vtc,crop,comb;
1511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u16 width,hscale,hdelay;
1521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u16 sheight,vscale,vdelay,vtotal;
1531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
1541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct bttv_buffer {
1561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* common v4l buffer stuff -- must be first */
1571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct videobuf_buffer     vb;
1581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* bttv specific */
1601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	const struct bttv_format   *fmt;
1614ef2ccc2611456667ea78c6f418ce87e1fa9fac5Trent Piepho	unsigned int               tvnorm;
1621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int                        btformat;
1631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int                        btswap;
1641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct bttv_geometry       geo;
1651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct btcx_riscmem        top;
1661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct btcx_riscmem        bottom;
167e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	struct v4l2_rect           crop;
168e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	unsigned int               vbi_skip[2];
169e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	unsigned int               vbi_count[2];
1701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
1711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct bttv_buffer_set {
1731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct bttv_buffer     *top;       /* top field buffer    */
1741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct bttv_buffer     *bottom;    /* bottom field buffer */
1751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int           top_irq;
1761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int           frame_irq;
1771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
1781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct bttv_overlay {
1804ef2ccc2611456667ea78c6f418ce87e1fa9fac5Trent Piepho	unsigned int           tvnorm;
1811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct v4l2_rect       w;
1821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	enum v4l2_field        field;
1831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct v4l2_clip       *clips;
1841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int                    nclips;
1851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int                    setup_ok;
1861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
1871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
188e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimekstruct bttv_vbi_fmt {
189e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	struct v4l2_vbi_format fmt;
190e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek
191e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	/* fmt.start[] and count[] refer to this video standard. */
192e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	const struct bttv_tvnorm *tvnorm;
193e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek
194e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	/* Earliest possible start of video capturing with this
195e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	   v4l2_vbi_format, in struct bttv_crop.rect units. */
196e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	__s32                  end;
197e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek};
198e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek
199e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek/* bttv-vbi.c */
2004ef2ccc2611456667ea78c6f418ce87e1fa9fac5Trent Piephovoid bttv_vbi_fmt_reset(struct bttv_vbi_fmt *f, unsigned int norm);
201e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek
202e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimekstruct bttv_crop {
203e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	/* A cropping rectangle in struct bttv_tvnorm.cropcap units. */
204e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	struct v4l2_rect       rect;
205e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek
206e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	/* Scaled image size limits with this crop rect. Divide
207e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	   max_height, but not min_height, by two when capturing
208e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	   single fields. See also bttv_crop_reset() and
209e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	   bttv_crop_adjust() in bttv-driver.c. */
210e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	__s32                  min_scaled_width;
211e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	__s32                  min_scaled_height;
212e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	__s32                  max_scaled_width;
213e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	__s32                  max_scaled_height;
214e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek};
215e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek
2161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct bttv_fh {
2171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct bttv              *btv;
2181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int resources;
2191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef VIDIOC_G_PRIORITY
2201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	enum v4l2_priority       prio;
2211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
2221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	enum v4l2_buf_type       type;
2231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* video capture */
2251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct videobuf_queue    cap;
2261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	const struct bttv_format *fmt;
2271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int                      width;
2281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int                      height;
2291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
230e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	/* video overlay */
2311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	const struct bttv_format *ovfmt;
2321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct bttv_overlay      ov;
2331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
234e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	/* Application called VIDIOC_S_CROP. */
235e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	int                      do_crop;
236e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek
237e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	/* vbi capture */
2381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct videobuf_queue    vbi;
239e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	/* Current VBI capture window as seen through this fh (cannot
240e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	   be global for compatibility with earlier drivers). Protected
241e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	   by struct bttv.lock and struct bttv_fh.vbi.lock. */
242e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	struct bttv_vbi_fmt      vbi_fmt;
2431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
2441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* ---------------------------------------------------------- */
2461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* bttv-risc.c                                                */
2471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* risc code generators - capture */
2491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint bttv_risc_packed(struct bttv *btv, struct btcx_riscmem *risc,
2501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		     struct scatterlist *sglist,
2511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		     unsigned int offset, unsigned int bpl,
252e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek		     unsigned int pitch, unsigned int skip_lines,
253e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek		     unsigned int store_lines);
2541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* control dma register + risc main loop */
2561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsvoid bttv_set_dma(struct bttv *btv, int override);
2571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint bttv_risc_init_main(struct bttv *btv);
2581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint bttv_risc_hook(struct bttv *btv, int slot, struct btcx_riscmem *risc,
2591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		   int irqflags);
2601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* capture buffer handling */
2621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf);
2631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint bttv_buffer_activate_video(struct bttv *btv,
2641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			       struct bttv_buffer_set *set);
2651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint bttv_buffer_activate_vbi(struct bttv *btv,
2661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			     struct bttv_buffer *vbi);
267c7b0ac0546985fc6361a8d92cf808d46da797677Mauro Carvalho Chehabvoid bttv_dma_free(struct videobuf_queue *q, struct bttv *btv,
268c7b0ac0546985fc6361a8d92cf808d46da797677Mauro Carvalho Chehab		   struct bttv_buffer *buf);
2691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* overlay handling */
2711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint bttv_overlay_risc(struct bttv *btv, struct bttv_overlay *ov,
2721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		      const struct bttv_format *fmt,
2731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		      struct bttv_buffer *buf);
2741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* ---------------------------------------------------------- */
2771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* bttv-vbi.c                                                 */
2781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
27978b526a43561d7e5e702ba27948e422dfbc4bea1Hans Verkuilint bttv_try_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *f);
28078b526a43561d7e5e702ba27948e422dfbc4bea1Hans Verkuilint bttv_g_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *f);
28178b526a43561d7e5e702ba27948e422dfbc4bea1Hans Verkuilint bttv_s_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *f);
2821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern struct videobuf_queue_ops bttv_vbi_qops;
2841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* ---------------------------------------------------------- */
2861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* bttv-gpio.c */
2871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern struct bus_type bttv_sub_bus_type;
2891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint bttv_sub_add_device(struct bttv_core *core, char *name);
2901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint bttv_sub_del_devices(struct bttv_core *core);
2911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* ---------------------------------------------------------- */
293c6eb8eafdba4ad18b4520a0d28a38bc9e61883eaHans Verkuil/* bttv-cards.c                                               */
294c6eb8eafdba4ad18b4520a0d28a38bc9e61883eaHans Verkuil
295c6eb8eafdba4ad18b4520a0d28a38bc9e61883eaHans Verkuilextern int no_overlay;
296c6eb8eafdba4ad18b4520a0d28a38bc9e61883eaHans Verkuil
297c6eb8eafdba4ad18b4520a0d28a38bc9e61883eaHans Verkuil/* ---------------------------------------------------------- */
298c0c46826274a4da5d9e312d7cfd4ca0806c0a358Mauro Carvalho Chehab/* bttv-input.c                                               */
299c0c46826274a4da5d9e312d7cfd4ca0806c0a358Mauro Carvalho Chehab
300c0c46826274a4da5d9e312d7cfd4ca0806c0a358Mauro Carvalho Chehabextern void init_bttv_i2c_ir(struct bttv *btv);
301c0c46826274a4da5d9e312d7cfd4ca0806c0a358Mauro Carvalho Chehabextern int fini_bttv_i2c(struct bttv *btv);
302c0c46826274a4da5d9e312d7cfd4ca0806c0a358Mauro Carvalho Chehab
303c0c46826274a4da5d9e312d7cfd4ca0806c0a358Mauro Carvalho Chehab/* ---------------------------------------------------------- */
3041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* bttv-driver.c                                              */
3051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* insmod options */
3071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern unsigned int bttv_verbose;
3081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern unsigned int bttv_debug;
3091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern unsigned int bttv_gpio;
3101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern void bttv_gpio_tracking(struct bttv *btv, char *comment);
3111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int init_bttv_i2c(struct bttv *btv);
3121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3138af443e581ab57a6a38f595eb40be3514ea55195Joe Perches#define dprintk(fmt, ...)			\
3148af443e581ab57a6a38f595eb40be3514ea55195Joe Perchesdo {						\
3158af443e581ab57a6a38f595eb40be3514ea55195Joe Perches	if (bttv_debug >= 1)			\
3168af443e581ab57a6a38f595eb40be3514ea55195Joe Perches		pr_debug(fmt, ##__VA_ARGS__);	\
3178af443e581ab57a6a38f595eb40be3514ea55195Joe Perches} while (0)
3188af443e581ab57a6a38f595eb40be3514ea55195Joe Perches#define dprintk_cont(fmt, ...)			\
3198af443e581ab57a6a38f595eb40be3514ea55195Joe Perchesdo {						\
3208af443e581ab57a6a38f595eb40be3514ea55195Joe Perches	if (bttv_debug >= 1)			\
3218af443e581ab57a6a38f595eb40be3514ea55195Joe Perches		pr_cont(fmt, ##__VA_ARGS__);	\
3228af443e581ab57a6a38f595eb40be3514ea55195Joe Perches} while (0)
3238af443e581ab57a6a38f595eb40be3514ea55195Joe Perches#define d2printk(fmt, ...)			\
3248af443e581ab57a6a38f595eb40be3514ea55195Joe Perchesdo {						\
3258af443e581ab57a6a38f595eb40be3514ea55195Joe Perches	if (bttv_debug >= 2)			\
3268af443e581ab57a6a38f595eb40be3514ea55195Joe Perches		printk(fmt, ##__VA_ARGS__);	\
3278af443e581ab57a6a38f595eb40be3514ea55195Joe Perches} while (0)
3281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BTTV_MAX_FBUF   0x208000
330fe06fe0a4d0f781f8ae0570e4d7e517a81878c1dMauro Carvalho Chehab#define BTTV_TIMEOUT    msecs_to_jiffies(500)    /* 0.5 seconds */
331fe06fe0a4d0f781f8ae0570e4d7e517a81878c1dMauro Carvalho Chehab#define BTTV_FREE_IDLE  msecs_to_jiffies(1000)   /* one second */
3321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct bttv_pll_info {
3351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int pll_ifreq;    /* PLL input frequency        */
3361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int pll_ofreq;    /* PLL output frequency       */
3371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int pll_crystal;  /* Crystal used for input     */
3381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int pll_current;  /* Currently programmed ofreq */
3391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
3401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* for gpio-connected remote control */
3421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct bttv_input {
343b7df3910c1298fee8ed7b9dfd2da74b85df5539cDmitry Torokhov	struct input_dev      *dev;
3441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	char                  name[32];
3451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	char                  phys[32];
3461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32                   mask_keycode;
3471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32                   mask_keydown;
3481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
3491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct bttv_suspend_state {
3511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32  gpio_enable;
3521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32  gpio_data;
3531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int  disabled;
3541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int  loop_irq;
3551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct bttv_buffer_set video;
3561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct bttv_buffer     *vbi;
3571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
3581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct bttv {
3601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct bttv_core c;
3611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* pci device config */
3631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned short id;
3641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned char revision;
3651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned char __iomem *bt848_mmio;   /* pointer to mmio */
3661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* card configuration info */
3681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int cardid;   /* pci subsystem id (bt878 based ones) */
3694ac97914c6c35f6bf132071c718e034d0846b9f5Mauro Carvalho Chehab	unsigned int tuner_type;  /* tuner chip type */
37039e8f40da20a803a17e16304e73fd31050b1871cHans Verkuil	unsigned int tda9887_conf;
3715221e21e5ecd3aebd2e8e3234bd18883ce720945Trent Piepho	unsigned int svhs, dig;
372859f0277a6c3ba59b0a5a1eb183f8f6ce661a95dHans Verkuil	unsigned int has_saa6588:1;
3731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct bttv_pll_info pll;
3741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int triton1;
3751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int gpioirq;
3764abdfed5676e5ef7f2461bb76f5929068a9cc9cfRicardo Cerqueira
3771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int use_i2c_hw;
3781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* old gpio interface */
3801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int shutdown;
3814b9b936f278163614543d66f8e8c93d5484dd148Nickolay V. Shmyrev
3824b9b936f278163614543d66f8e8c93d5484dd148Nickolay V. Shmyrev	void (*volume_gpio)(struct bttv *btv, __u16 volume);
3834b9b936f278163614543d66f8e8c93d5484dd148Nickolay V. Shmyrev	void (*audio_mode_gpio)(struct bttv *btv, struct v4l2_tuner *tuner, int set);
3844b9b936f278163614543d66f8e8c93d5484dd148Nickolay V. Shmyrev
3851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* new gpio interface */
3861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	spinlock_t gpio_lock;
3871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* i2c layer */
3891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct i2c_algo_bit_data   i2c_algo;
3901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct i2c_client          i2c_client;
3911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int                        i2c_state, i2c_rc;
3921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int                        i2c_done;
3931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	wait_queue_head_t          i2c_queue;
394859f0277a6c3ba59b0a5a1eb183f8f6ce661a95dHans Verkuil	struct v4l2_subdev 	  *sd_msp34xx;
395859f0277a6c3ba59b0a5a1eb183f8f6ce661a95dHans Verkuil	struct v4l2_subdev 	  *sd_tvaudio;
3961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* video4linux (1) */
3981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct video_device *video_dev;
3991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct video_device *radio_dev;
4001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct video_device *vbi_dev;
4011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* infrared remote */
4031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int has_remote;
404edb4c25ca3a7997660500692eca3510eac9726e5David Härdeman	struct bttv_ir *remote;
4051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
406c0c46826274a4da5d9e312d7cfd4ca0806c0a358Mauro Carvalho Chehab	/* I2C remote data */
407c0c46826274a4da5d9e312d7cfd4ca0806c0a358Mauro Carvalho Chehab	struct IR_i2c_init_data    init_data;
408c0c46826274a4da5d9e312d7cfd4ca0806c0a358Mauro Carvalho Chehab
4091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* locking */
4101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	spinlock_t s_lock;
411bd5f0ac930168899003952110c45d110958a5c55Ingo Molnar	struct mutex lock;
4121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int resources;
4131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef VIDIOC_G_PRIORITY
4141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct v4l2_prio_state prio;
4151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
4161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* video state */
4181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int input;
4191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int audio;
4208bf2f8e747700419cc5bbc56c4496774eb8f2f1fHans Verkuil	unsigned int mute;
42176ea992a036c4a5d3bc606a79ef775dd32fd3daaHans Verkuil	unsigned long tv_freq;
4224ef2ccc2611456667ea78c6f418ce87e1fa9fac5Trent Piepho	unsigned int tvnorm;
4234ef2ccc2611456667ea78c6f418ce87e1fa9fac5Trent Piepho	int hue, contrast, bright, saturation;
4241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct v4l2_framebuffer fbuf;
4251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int field_count;
4261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* various options */
4281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int opt_combfilter;
4291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int opt_lumafilter;
4301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int opt_automute;
4311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int opt_chroma_agc;
43234e59a7d45950b1a03e498d34c1baf4998218cd7Guilherme Herrmann Destefani	int opt_color_killer;
4331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int opt_adc_crush;
4341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int opt_vcr_hack;
4351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int opt_whitecrush_upper;
4361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int opt_whitecrush_lower;
437060d3027f26aab9adeac8ff6d1184bca67c7d174Mauro Carvalho Chehab	int opt_uv_ratio;
438060d3027f26aab9adeac8ff6d1184bca67c7d174Mauro Carvalho Chehab	int opt_full_luma_range;
439060d3027f26aab9adeac8ff6d1184bca67c7d174Mauro Carvalho Chehab	int opt_coring;
4401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* radio data/state */
4421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int has_radio;
4431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int radio_user;
4447025e521b1b068af8a47a7625335a605bbd4d7eaHans de Goede	int radio_uses_msp_demodulator;
44576ea992a036c4a5d3bc606a79ef775dd32fd3daaHans Verkuil	unsigned long radio_freq;
4461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* miro/pinnacle + Aimslab VHX
4481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	   philips matchbox (tea5757 radio tuner) support */
4491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int has_matchbox;
4501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int mbox_we;
4511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int mbox_data;
4521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int mbox_clk;
4531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int mbox_most;
4541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int mbox_mask;
4551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* ISA stuff (Terratec Active Radio Upgrade) */
4571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int mbox_ior;
4581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int mbox_iow;
4591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int mbox_csel;
4601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* risc memory management data
4620418726bb5c7b5a70c7e7e82e860d5979d0c78cfAdrian Bunk	   - must acquire s_lock before changing these
4631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	   - only the irq handler is supported to touch top + bottom + vcurr */
4641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct btcx_riscmem     main;
4651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct bttv_buffer      *screen;    /* overlay             */
4661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct list_head        capture;    /* video capture queue */
4671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct list_head        vcapture;   /* vbi capture queue   */
4681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct bttv_buffer_set  curr;       /* active buffers      */
4691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct bttv_buffer      *cvbi;      /* active vbi buffer   */
4701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int                     loop_irq;
4711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int                     new_input;
4721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned long cap_ctl;
4741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned long dma_on;
4751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct timer_list timeout;
4761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct bttv_suspend_state state;
4771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* stats */
4791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int errors;
4801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int framedrop;
4811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int irq_total;
4821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int irq_me;
4831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int users;
4851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct bttv_fh init;
486e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek
487f992a497c71981e215b1415759fc13593ed2919fJarod Wilson	/* used to make dvb-bt8xx autoloadable */
488f992a497c71981e215b1415759fc13593ed2919fJarod Wilson	struct work_struct request_module_wk;
489f992a497c71981e215b1415759fc13593ed2919fJarod Wilson
490e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	/* Default (0) and current (1) video capturing and overlay
491e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	   cropping parameters in bttv_tvnorm.cropcap units. Protected
492e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	   by bttv.lock. */
493e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	struct bttv_crop crop[2];
494e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek
495e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	/* Earliest possible start of video capturing in
496e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	   bttv_tvnorm.cropcap line units. Set by check_alloc_btres()
497e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	   and free_btres(). Protected by bttv.lock. */
498e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	__s32			vbi_end;
499e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek
500e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	/* Latest possible end of VBI capturing (= crop[x].rect.top when
501e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	   VIDEO_RESOURCES are locked). Set by check_alloc_btres()
502e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	   and free_btres(). Protected by bttv.lock. */
503e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek	__s32			crop_start;
5041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
5052d03e289ea4b13d78ce55f1ea0b0d45b8f1b34c3Mauro Carvalho Chehab
50674fc7bd9cec0ccdbea23659208492ec7ffc58297Hans Verkuilstatic inline struct bttv *to_bttv(struct v4l2_device *v4l2_dev)
50774fc7bd9cec0ccdbea23659208492ec7ffc58297Hans Verkuil{
50874fc7bd9cec0ccdbea23659208492ec7ffc58297Hans Verkuil	return container_of(v4l2_dev, struct bttv, c.v4l2_dev);
50974fc7bd9cec0ccdbea23659208492ec7ffc58297Hans Verkuil}
51074fc7bd9cec0ccdbea23659208492ec7ffc58297Hans Verkuil
5112d03e289ea4b13d78ce55f1ea0b0d45b8f1b34c3Mauro Carvalho Chehab/* our devices */
5122499abe710a86084eee1c0d5662ebd43c261350dAlan McIvor#define BTTV_MAX 32
5132d03e289ea4b13d78ce55f1ea0b0d45b8f1b34c3Mauro Carvalho Chehabextern unsigned int bttv_num;
5144b10d3b626922ffa2387905a230b12450281a12dTrent Piephoextern struct bttv *bttvs[BTTV_MAX];
5151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
5166f98700a5bb8d218162b04db1b8a3921a0dcc7ceTrent Piephostatic inline unsigned int bttv_muxsel(const struct bttv *btv,
5176f98700a5bb8d218162b04db1b8a3921a0dcc7ceTrent Piepho				       unsigned int input)
5186f98700a5bb8d218162b04db1b8a3921a0dcc7ceTrent Piepho{
5196f98700a5bb8d218162b04db1b8a3921a0dcc7ceTrent Piepho	return (bttv_tvcards[btv->c.type].muxsel >> (input * 2)) & 3;
5206f98700a5bb8d218162b04db1b8a3921a0dcc7ceTrent Piepho}
5216f98700a5bb8d218162b04db1b8a3921a0dcc7ceTrent Piepho
5221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
5231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
5241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define btwrite(dat,adr)    writel((dat), btv->bt848_mmio+(adr))
5251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define btread(adr)         readl(btv->bt848_mmio+(adr))
5261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
5271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define btand(dat,adr)      btwrite((dat) & btread(adr), adr)
5281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define btor(dat,adr)       btwrite((dat) | btread(adr), adr)
5291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr)
5301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
5311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif /* _BTTVP_H_ */
5321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
5331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
5341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Local variables:
5351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * c-basic-offset: 8
5361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * End:
5371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
538