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> 3601df530c2791610727e345b3dd97ef75943c7320Hans Verkuil#include <linux/device.h> 371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/io.h> 3818f3fa1e2eab297a2f7ec704385fa0ecfda0de55Mauro Carvalho Chehab#include <media/v4l2-common.h> 3901df530c2791610727e345b3dd97ef75943c7320Hans Verkuil#include <media/v4l2-ctrls.h> 40ae50f0f83efce31c8d485b5de131a4fd3f13e24bHans Verkuil#include <media/v4l2-fh.h> 41c1accaa21bdef38ec0f36eaaf7ce3384fff9d0c5Mauro Carvalho Chehab#include <media/videobuf-dma-sg.h> 421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <media/tveeprom.h> 436bda96447cef24fbf97a798b1ea664224d5fdc25Mauro Carvalho Chehab#include <media/rc-core.h> 44c0c46826274a4da5d9e312d7cfd4ca0806c0a358Mauro Carvalho Chehab#include <media/ir-kbd-i2c.h> 45674434c691e10015660022fc00b04985a23ef87bMauro Carvalho Chehab 461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include "bt848.h" 471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include "bttv.h" 481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include "btcx-risc.h" 491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef __KERNEL__ 511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define FORMAT_FLAGS_DITHER 0x01 531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define FORMAT_FLAGS_PACKED 0x02 541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define FORMAT_FLAGS_PLANAR 0x04 551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define FORMAT_FLAGS_RAW 0x08 561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define FORMAT_FLAGS_CrCb 0x10 571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RISC_SLOT_O_VBI 4 591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RISC_SLOT_O_FIELD 6 601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RISC_SLOT_E_VBI 10 611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RISC_SLOT_E_FIELD 12 621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RISC_SLOT_LOOP 14 631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RESOURCE_OVERLAY 1 65e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek#define RESOURCE_VIDEO_STREAM 2 661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RESOURCE_VBI 4 67e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek#define RESOURCE_VIDEO_READ 8 681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RAW_LINES 640 701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RAW_BPL 1024 711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define UNSET (-1U) 731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 74e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek/* Min. value in VDELAY register. */ 75e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek#define MIN_VDELAY 2 76e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek/* Even to get Cb first, odd for Cr. */ 77e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek#define MAX_HDELAY (0x3FF & -2) 78e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek/* Limits scaled width, which must be a multiple of 4. */ 79e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek#define MAX_HACTIVE (0x3FF & -4) 80e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek 81402aa76aa5e57801b4db5ccf8c7beea9f580bb1bDouglas Schilling Landgraf#define BTTV_NORMS (\ 82402aa76aa5e57801b4db5ccf8c7beea9f580bb1bDouglas Schilling Landgraf V4L2_STD_PAL | V4L2_STD_PAL_N | \ 83402aa76aa5e57801b4db5ccf8c7beea9f580bb1bDouglas Schilling Landgraf V4L2_STD_PAL_Nc | V4L2_STD_SECAM | \ 84402aa76aa5e57801b4db5ccf8c7beea9f580bb1bDouglas Schilling Landgraf V4L2_STD_NTSC | V4L2_STD_PAL_M | \ 85402aa76aa5e57801b4db5ccf8c7beea9f580bb1bDouglas Schilling Landgraf V4L2_STD_PAL_60) 861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* ---------------------------------------------------------- */ 871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct bttv_tvnorm { 891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int v4l2_id; 901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds char *name; 914ac97914c6c35f6bf132071c718e034d0846b9f5Mauro Carvalho Chehab u32 Fsc; 924ac97914c6c35f6bf132071c718e034d0846b9f5Mauro Carvalho Chehab u16 swidth, sheight; /* scaled standard width, height */ 931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 totalwidth; 941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u8 adelay, bdelay, iform; 951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u32 scaledtwidth; 961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 hdelayx1, hactivex1; 971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 vdelay; 984ac97914c6c35f6bf132071c718e034d0846b9f5Mauro Carvalho Chehab u8 vbipack; 991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 vtotal; 1001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int sram; 10167f1570a0659abba5efbf55cc986187af61bdd52Michael H. Schimek /* ITU-R frame line number of the first VBI line we can 102e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek capture, of the first and second field. The last possible line 103e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek is determined by cropcap.bounds. */ 10467f1570a0659abba5efbf55cc986187af61bdd52Michael H. Schimek u16 vbistart[2]; 105e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek /* Horizontally this counts fCLKx1 samples following the leading 106e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek edge of the horizontal sync pulse, vertically ITU-R frame line 107e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek numbers of the first field times two (2, 4, 6, ... 524 or 624). */ 108e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek struct v4l2_cropcap cropcap; 1091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 1101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern const struct bttv_tvnorm bttv_tvnorms[]; 1111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct bttv_format { 1131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds char *name; 1141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int fourcc; /* video4linux 2 */ 1151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int btformat; /* BT848_COLOR_FMT_* */ 1161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int btswap; /* BT848_COLOR_CTL_* */ 1171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int depth; /* bit/pixel */ 1181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int flags; 1191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int hshift,vshift; /* for planar modes */ 1201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 1211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 122edb4c25ca3a7997660500692eca3510eac9726e5David Härdemanstruct bttv_ir { 123a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab struct rc_dev *dev; 1243938e0cfeb812e7b66f4e1cb6e34eb2e6864c6a2David Härdeman struct timer_list timer; 125a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab 126a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab char name[32]; 127a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab char phys[32]; 128edb4c25ca3a7997660500692eca3510eac9726e5David Härdeman 129a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab /* Usual gpio signalling */ 130a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab u32 mask_keycode; 131a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab u32 mask_keydown; 132a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab u32 mask_keyup; 133a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab u32 polling; 134a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab u32 last_gpio; 135a6e3b81f6198654207c4e972e7ed91931e53e93cMauro Carvalho Chehab int shift_by; 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 { 217ae50f0f83efce31c8d485b5de131a4fd3f13e24bHans Verkuil /* This must be the first field in this struct */ 218ae50f0f83efce31c8d485b5de131a4fd3f13e24bHans Verkuil struct v4l2_fh fh; 219ae50f0f83efce31c8d485b5de131a4fd3f13e24bHans Verkuil 2201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct bttv *btv; 2211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int resources; 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); 301457ba4ce4f435d0b4dd82a0acc6c796e541a2ea7Frank Schaefer 302457ba4ce4f435d0b4dd82a0acc6c796e541a2ea7Frank Schaefer/* ---------------------------------------------------------- */ 303457ba4ce4f435d0b4dd82a0acc6c796e541a2ea7Frank Schaefer/* bttv-i2c.c */ 304457ba4ce4f435d0b4dd82a0acc6c796e541a2ea7Frank Schaeferextern int init_bttv_i2c(struct bttv *btv); 305c0c46826274a4da5d9e312d7cfd4ca0806c0a358Mauro Carvalho Chehabextern int fini_bttv_i2c(struct bttv *btv); 306c0c46826274a4da5d9e312d7cfd4ca0806c0a358Mauro Carvalho Chehab 307c0c46826274a4da5d9e312d7cfd4ca0806c0a358Mauro Carvalho Chehab/* ---------------------------------------------------------- */ 3081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* bttv-driver.c */ 3091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* insmod options */ 3111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern unsigned int bttv_verbose; 3121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern unsigned int bttv_debug; 3131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern unsigned int bttv_gpio; 3141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern void bttv_gpio_tracking(struct bttv *btv, char *comment); 3151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3168af443e581ab57a6a38f595eb40be3514ea55195Joe Perches#define dprintk(fmt, ...) \ 3178af443e581ab57a6a38f595eb40be3514ea55195Joe Perchesdo { \ 3188af443e581ab57a6a38f595eb40be3514ea55195Joe Perches if (bttv_debug >= 1) \ 3198af443e581ab57a6a38f595eb40be3514ea55195Joe Perches pr_debug(fmt, ##__VA_ARGS__); \ 3208af443e581ab57a6a38f595eb40be3514ea55195Joe Perches} while (0) 3218af443e581ab57a6a38f595eb40be3514ea55195Joe Perches#define dprintk_cont(fmt, ...) \ 3228af443e581ab57a6a38f595eb40be3514ea55195Joe Perchesdo { \ 3238af443e581ab57a6a38f595eb40be3514ea55195Joe Perches if (bttv_debug >= 1) \ 3248af443e581ab57a6a38f595eb40be3514ea55195Joe Perches pr_cont(fmt, ##__VA_ARGS__); \ 3258af443e581ab57a6a38f595eb40be3514ea55195Joe Perches} while (0) 3268af443e581ab57a6a38f595eb40be3514ea55195Joe Perches#define d2printk(fmt, ...) \ 3278af443e581ab57a6a38f595eb40be3514ea55195Joe Perchesdo { \ 3288af443e581ab57a6a38f595eb40be3514ea55195Joe Perches if (bttv_debug >= 2) \ 3298af443e581ab57a6a38f595eb40be3514ea55195Joe Perches printk(fmt, ##__VA_ARGS__); \ 3308af443e581ab57a6a38f595eb40be3514ea55195Joe Perches} while (0) 3311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BTTV_MAX_FBUF 0x208000 333fe06fe0a4d0f781f8ae0570e4d7e517a81878c1dMauro Carvalho Chehab#define BTTV_TIMEOUT msecs_to_jiffies(500) /* 0.5 seconds */ 334fe06fe0a4d0f781f8ae0570e4d7e517a81878c1dMauro Carvalho Chehab#define BTTV_FREE_IDLE msecs_to_jiffies(1000) /* one second */ 3351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct bttv_pll_info { 3381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int pll_ifreq; /* PLL input frequency */ 3391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int pll_ofreq; /* PLL output frequency */ 3401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int pll_crystal; /* Crystal used for input */ 3411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int pll_current; /* Currently programmed ofreq */ 3421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 3431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* for gpio-connected remote control */ 3451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct bttv_input { 346b7df3910c1298fee8ed7b9dfd2da74b85df5539cDmitry Torokhov struct input_dev *dev; 3471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds char name[32]; 3481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds char phys[32]; 3491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u32 mask_keycode; 3501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u32 mask_keydown; 3511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 3521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct bttv_suspend_state { 3541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u32 gpio_enable; 3551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u32 gpio_data; 3561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int disabled; 3571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int loop_irq; 3581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct bttv_buffer_set video; 3591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct bttv_buffer *vbi; 3601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 3611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct bttv { 3631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct bttv_core c; 3641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* pci device config */ 3661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned short id; 3671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned char revision; 3681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned char __iomem *bt848_mmio; /* pointer to mmio */ 3691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* card configuration info */ 3711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int cardid; /* pci subsystem id (bt878 based ones) */ 3724ac97914c6c35f6bf132071c718e034d0846b9f5Mauro Carvalho Chehab unsigned int tuner_type; /* tuner chip type */ 37339e8f40da20a803a17e16304e73fd31050b1871cHans Verkuil unsigned int tda9887_conf; 3745221e21e5ecd3aebd2e8e3234bd18883ce720945Trent Piepho unsigned int svhs, dig; 375859f0277a6c3ba59b0a5a1eb183f8f6ce661a95dHans Verkuil unsigned int has_saa6588:1; 3761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct bttv_pll_info pll; 3771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int triton1; 3781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int gpioirq; 3794abdfed5676e5ef7f2461bb76f5929068a9cc9cfRicardo Cerqueira 3801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int use_i2c_hw; 3811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* old gpio interface */ 3831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int shutdown; 3844b9b936f278163614543d66f8e8c93d5484dd148Nickolay V. Shmyrev 3854b9b936f278163614543d66f8e8c93d5484dd148Nickolay V. Shmyrev void (*volume_gpio)(struct bttv *btv, __u16 volume); 3864b9b936f278163614543d66f8e8c93d5484dd148Nickolay V. Shmyrev void (*audio_mode_gpio)(struct bttv *btv, struct v4l2_tuner *tuner, int set); 3874b9b936f278163614543d66f8e8c93d5484dd148Nickolay V. Shmyrev 3881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* new gpio interface */ 3891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds spinlock_t gpio_lock; 3901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* i2c layer */ 3921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct i2c_algo_bit_data i2c_algo; 3931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct i2c_client i2c_client; 3941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int i2c_state, i2c_rc; 3951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int i2c_done; 3961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds wait_queue_head_t i2c_queue; 397859f0277a6c3ba59b0a5a1eb183f8f6ce661a95dHans Verkuil struct v4l2_subdev *sd_msp34xx; 398859f0277a6c3ba59b0a5a1eb183f8f6ce661a95dHans Verkuil struct v4l2_subdev *sd_tvaudio; 39901df530c2791610727e345b3dd97ef75943c7320Hans Verkuil struct v4l2_subdev *sd_tda7432; 4001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* video4linux (1) */ 4021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct video_device *video_dev; 4031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct video_device *radio_dev; 4041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct video_device *vbi_dev; 4051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 40601df530c2791610727e345b3dd97ef75943c7320Hans Verkuil /* controls */ 40701df530c2791610727e345b3dd97ef75943c7320Hans Verkuil struct v4l2_ctrl_handler ctrl_handler; 40801df530c2791610727e345b3dd97ef75943c7320Hans Verkuil struct v4l2_ctrl_handler radio_ctrl_handler; 40901df530c2791610727e345b3dd97ef75943c7320Hans Verkuil 4101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* infrared remote */ 4111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int has_remote; 412edb4c25ca3a7997660500692eca3510eac9726e5David Härdeman struct bttv_ir *remote; 4131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 414c0c46826274a4da5d9e312d7cfd4ca0806c0a358Mauro Carvalho Chehab /* I2C remote data */ 415c0c46826274a4da5d9e312d7cfd4ca0806c0a358Mauro Carvalho Chehab struct IR_i2c_init_data init_data; 416c0c46826274a4da5d9e312d7cfd4ca0806c0a358Mauro Carvalho Chehab 4171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* locking */ 4181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds spinlock_t s_lock; 419bd5f0ac930168899003952110c45d110958a5c55Ingo Molnar struct mutex lock; 4201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int resources; 4211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* video state */ 4231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int input; 4242166f0a9710413ea60bd72a4983de11b764468e4Frank Schaefer unsigned int audio_input; 4258bf2f8e747700419cc5bbc56c4496774eb8f2f1fHans Verkuil unsigned int mute; 42676ea992a036c4a5d3bc606a79ef775dd32fd3daaHans Verkuil unsigned long tv_freq; 4274ef2ccc2611456667ea78c6f418ce87e1fa9fac5Trent Piepho unsigned int tvnorm; 4286795cc55506606988175c16aa0e17d9f349706caHans Verkuil v4l2_std_id std; 4294ef2ccc2611456667ea78c6f418ce87e1fa9fac5Trent Piepho int hue, contrast, bright, saturation; 4301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct v4l2_framebuffer fbuf; 4311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int field_count; 4321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* various options */ 4341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int opt_combfilter; 4351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int opt_automute; 4361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int opt_vcr_hack; 437060d3027f26aab9adeac8ff6d1184bca67c7d174Mauro Carvalho Chehab int opt_uv_ratio; 4381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* radio data/state */ 4401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int has_radio; 441b8e2a361ce4247118fe81224b43137821cda50f7Hans Verkuil int has_radio_tuner; 4421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int radio_user; 4437025e521b1b068af8a47a7625335a605bbd4d7eaHans de Goede int radio_uses_msp_demodulator; 44476ea992a036c4a5d3bc606a79ef775dd32fd3daaHans Verkuil unsigned long radio_freq; 4451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* miro/pinnacle + Aimslab VHX 4471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds philips matchbox (tea5757 radio tuner) support */ 4481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int has_matchbox; 4491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int mbox_we; 4501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int mbox_data; 4511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int mbox_clk; 4521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int mbox_most; 4531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int mbox_mask; 4541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* ISA stuff (Terratec Active Radio Upgrade) */ 4561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int mbox_ior; 4571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int mbox_iow; 4581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int mbox_csel; 4591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 460cd2e34ead8bf530c45e0446dc4bbbd9e35f28af9Ondrej Zary /* switch status for multi-controller cards */ 461cd2e34ead8bf530c45e0446dc4bbbd9e35f28af9Ondrej Zary char sw_status[4]; 462cd2e34ead8bf530c45e0446dc4bbbd9e35f28af9Ondrej Zary 4631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* risc memory management data 4640418726bb5c7b5a70c7e7e82e860d5979d0c78cfAdrian Bunk - must acquire s_lock before changing these 4651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds - only the irq handler is supported to touch top + bottom + vcurr */ 4661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct btcx_riscmem main; 4671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct bttv_buffer *screen; /* overlay */ 4681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct list_head capture; /* video capture queue */ 4691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct list_head vcapture; /* vbi capture queue */ 4701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct bttv_buffer_set curr; /* active buffers */ 4711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct bttv_buffer *cvbi; /* active vbi buffer */ 4721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int loop_irq; 4731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int new_input; 4741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long cap_ctl; 4761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long dma_on; 4771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct timer_list timeout; 4781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct bttv_suspend_state state; 4791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* stats */ 4811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int errors; 4821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int framedrop; 4831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int irq_total; 4841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int irq_me; 4851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int users; 4871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct bttv_fh init; 488e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek 489f992a497c71981e215b1415759fc13593ed2919fJarod Wilson /* used to make dvb-bt8xx autoloadable */ 490f992a497c71981e215b1415759fc13593ed2919fJarod Wilson struct work_struct request_module_wk; 491f992a497c71981e215b1415759fc13593ed2919fJarod Wilson 492e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek /* Default (0) and current (1) video capturing and overlay 493e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek cropping parameters in bttv_tvnorm.cropcap units. Protected 494e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek by bttv.lock. */ 495e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek struct bttv_crop crop[2]; 496e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek 497e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek /* Earliest possible start of video capturing in 498e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek bttv_tvnorm.cropcap line units. Set by check_alloc_btres() 499e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek and free_btres(). Protected by bttv.lock. */ 500e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek __s32 vbi_end; 501e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek 502e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek /* Latest possible end of VBI capturing (= crop[x].rect.top when 503e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek VIDEO_RESOURCES are locked). Set by check_alloc_btres() 504e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek and free_btres(). Protected by bttv.lock. */ 505e5bd0260e7d3d806e66c12859f50733dca43bbcfMichael Schimek __s32 crop_start; 5061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 5072d03e289ea4b13d78ce55f1ea0b0d45b8f1b34c3Mauro Carvalho Chehab 50874fc7bd9cec0ccdbea23659208492ec7ffc58297Hans Verkuilstatic inline struct bttv *to_bttv(struct v4l2_device *v4l2_dev) 50974fc7bd9cec0ccdbea23659208492ec7ffc58297Hans Verkuil{ 51074fc7bd9cec0ccdbea23659208492ec7ffc58297Hans Verkuil return container_of(v4l2_dev, struct bttv, c.v4l2_dev); 51174fc7bd9cec0ccdbea23659208492ec7ffc58297Hans Verkuil} 51274fc7bd9cec0ccdbea23659208492ec7ffc58297Hans Verkuil 5132d03e289ea4b13d78ce55f1ea0b0d45b8f1b34c3Mauro Carvalho Chehab/* our devices */ 5142499abe710a86084eee1c0d5662ebd43c261350dAlan McIvor#define BTTV_MAX 32 5152d03e289ea4b13d78ce55f1ea0b0d45b8f1b34c3Mauro Carvalho Chehabextern unsigned int bttv_num; 5164b10d3b626922ffa2387905a230b12450281a12dTrent Piephoextern struct bttv *bttvs[BTTV_MAX]; 5171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5186f98700a5bb8d218162b04db1b8a3921a0dcc7ceTrent Piephostatic inline unsigned int bttv_muxsel(const struct bttv *btv, 5196f98700a5bb8d218162b04db1b8a3921a0dcc7ceTrent Piepho unsigned int input) 5206f98700a5bb8d218162b04db1b8a3921a0dcc7ceTrent Piepho{ 5216f98700a5bb8d218162b04db1b8a3921a0dcc7ceTrent Piepho return (bttv_tvcards[btv->c.type].muxsel >> (input * 2)) & 3; 5226f98700a5bb8d218162b04db1b8a3921a0dcc7ceTrent Piepho} 5236f98700a5bb8d218162b04db1b8a3921a0dcc7ceTrent Piepho 5241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 5251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define btwrite(dat,adr) writel((dat), btv->bt848_mmio+(adr)) 5271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define btread(adr) readl(btv->bt848_mmio+(adr)) 5281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define btand(dat,adr) btwrite((dat) & btread(adr), adr) 5301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define btor(dat,adr) btwrite((dat) | btread(adr), adr) 5311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr) 5321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif /* _BTTVP_H_ */ 5341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 5361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Local variables: 5371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * c-basic-offset: 8 5381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * End: 5391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 540