⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 brooktree848.c

📁 基于组件方式开发操作系统的OSKIT源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* $Id: brooktree848.c,v 1.61.2.4 1999/05/08 06:29:19 roger Exp $ *//* BT848 Driver for Brooktree's Bt848, Bt849, Bt878 and Bt 879 based cards.   The Brooktree  BT848 Driver driver is based upon Mark Tinguely and   Jim Lowe's driver for the Matrox Meteor PCI card . The    Philips SAA 7116 and SAA 7196 are very different chipsets than   the BT848. For starters, the BT848 is a one chipset solution and   it incorporates a RISC engine to control the DMA transfers --   that is it the actual dma process is control by a program which   resides in the hosts memory also the register definitions between   the Philips chipsets and the Bt848 are very different.   The original copyright notice by Mark and Jim is included mostly   to honor their fantastic work in the Matrox Meteor driver!      Enjoy,      Amancio *//* * 1. Redistributions of source code must retain the  * Copyright (c) 1997 Amancio Hasty * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by Amancio Hasty * 4. The name of the author may not be used to endorse or promote products  *    derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED.	IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *//* * 1. Redistributions of source code must retain the  * Copyright (c) 1995 Mark Tinguely and Jim Lowe * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by Mark Tinguely and Jim Lowe * 4. The name of the author may not be used to endorse or promote products  *    derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED.	IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *//*		Change History:Note: These version numbers represent the authors own numbering.They are unrelated to Revision Control numbering of FreeBSD or any other system.1.0		1/24/97	   First Alpha release1.1		2/20/97	   Added video ioctl so we can do PCI To PCI			   data transfers. This is for capturing data			   directly to a vga frame buffer which has			   a linear frame buffer. Minor code clean-up.1.3		2/23/97	   Fixed system lock-up reported by 			   Randall Hopper <rhh@ct.picker.com>. This			   problem seems somehow to be exhibited only			   in his system. I changed the setting of			   INT_MASK for CAP_CONTINUOUS to be exactly			   the same as CAP_SINGLE apparently setting			   bit 23 cleared the system lock up. 			   version 1.1 of the driver has been reported			   to work with STB's WinTv, Hauppage's Wincast/Tv			   and last but not least with the Intel Smart			   Video Recorder.1.4		3/9/97	   fsmp@freefall.org			   Merged code to support tuners on STB and WinCast			   cards.			   Modifications to the contrast and chroma ioctls.			   Textual cleanup.1.5             3/15/97    fsmp@freefall.org                	   new bt848 specific versions of hue/bright/                           contrast/satu/satv.                           Amancio's patch to fix "screen freeze" problem.1.6             3/19/97    fsmp@freefall.org			   new table-driven frequency lookup.			   removed disable_intr()/enable_intr() calls from i2c.			   misc. cleanup.1.7             3/19/97    fsmp@freefall.org			   added audio support submitted by:				Michael Petry <petry@netwolf.NetMasters.com>1.8             3/20/97    fsmp@freefall.org			   extended audio support.			   card auto-detection.			   major cleanup, order of routines, declarations, etc.1.9             3/22/97    fsmp@freefall.org			   merged in Amancio's minor unit for tuner control			   mods.			   misc. cleanup, especially in the _intr routine.			   made AUDIO_SUPPORT mainline code.1.10            3/23/97    fsmp@freefall.org			   added polled hardware i2c routines,			   removed all existing software i2c routines.			   created software i2cProbe() routine.			   Randall Hopper's fixes of BT848_GHUE & BT848_GBRIG.			   eeprom support.1.11            3/24/97    fsmp@freefall.org			   Louis Mamakos's new bt848 struct.1.12		3/25/97    fsmp@freefall.org			   japanese freq table from Naohiro Shichijo.			   new table structs for tuner lookups.			   major scrub for "magic numbers".1.13		3/28/97    fsmp@freefall.org			   1st PAL support.			   MAGIC_[1-4] demarcates magic #s needing PAL work.			   AFC code submitted by Richard Tobin			    <richard@cogsci.ed.ac.uk>.1.14		3/29/97    richard@cogsci.ed.ac.uk			   PAL support: magic numbers moved into			   format_params structure.			   Revised AFC interface.			   fixed DMA_PROG_ALLOC size misdefinition.1.15		4/18/97	   John-Mark Gurney <gurney_j@resnet.uoregon.edu>                           Added [SR]RGBMASKs ioctl for byte swapping.1.16		4/20/97	   Randall Hopper <rhh@ct.picker.com>                           Generalized RGBMASK ioctls for general pixel			   format setting [SG]ACTPIXFMT, and added query API			   to return driver-supported pix fmts GSUPPIXFMT.1.17		4/21/97	   hasty@rah.star-gate.com                           Clipping support added.1.18		4/23/97	   Clean up after failed CAP_SINGLEs where bt                            interrupt isn't delivered, and fixed fixing 			   CAP_SINGLEs that for ODD_ONLY fields.1.19            9/8/97     improved yuv support , cleaned up weurope                           channel table, incorporated cleanup work from                           Luigi, fixed pci interface bug due to a                           change in the pci interface which disables                           interrupts from a PCI device by default,                           Added Luigi's, ioctl's BT848_SLNOTCH,                            BT848_GLNOTCH (set luma notch and get luma not)1.20            10/5/97    Keith Sklower <sklower@CS.Berkeley.EDU> submitted                           a patch to fix compilation of the BSDI's PCI                           interface.                            Hideyuki Suzuki <hideyuki@sat.t.u-tokyo.ac.jp>                           Submitted a patch for Japanese cable channels                           Joao Carlos Mendes Luis jonny@gta.ufrj.br                           Submitted general ioctl to set video broadcast                           formats (PAL, NTSC, etc..) previously we depended                           on the Bt848 auto video detect feature.1.21            10/24/97   Randall Hopper <rhh@ct.picker.com>                           Fix temporal decimation, disable it when                           doing CAP_SINGLEs, and in dual-field capture, don't                           capture fields for different frames1.22            11/08/97   Randall Hopper <rhh@ct.picker.com>                           Fixes for packed 24bpp - FIFO alignment1.23            11/17/97   Amancio <hasty@star-gate.com>                           Added yuv support mpeg encoding 1.24            12/27/97   Jonathan Hanna <pangolin@rogers.wave.ca>                           Patch to support Philips FR1236MK2 tuner1.25            02/02/98   Takeshi Ohashi                            <ohashi@atohasi.mickey.ai.kyutech.ac.jp> submitted                           code to support bktr_read .                           Flemming Jacobsen <fj@schizo.dk.tfs.com>                           submitted code to support  radio available with in                           some bt848 based cards;additionally, wrote code to                           correctly recognized his bt848 card.                           Roger Hardiman <roger@cs.strath.ac.uk> submitted                            various fixes to smooth out the microcode and made                            all modes consistent.1.26                       Moved Luigi's I2CWR ioctl from the video_ioctl                           section to the tuner_ioctl section                           Changed Major device from 79 to 92 and reserved                           our Major device number -- hasty@star-gate.com1.27                       Last batch of patches for radio support from                           Flemming Jacobsen <fj@trw.nl>.                           Added B849 PCI ID submitted by:                            Tomi Vainio <tomppa@fidata.fi>1.28                       Frank Nobis <fn@Radio-do.de> added tuner support                           for the  German Phillips PAL tuner and                           additional channels for german cable tv.1.29                       Roger Hardiman <roger@cs.strath.ac.uk>                           Revised autodetection code to correctly handle both                           old and new VideoLogic Captivator PCI cards.                           Added tsleep of 2 seconds to initialistion code                           for PAL users.Corrected clock selection code on                           format change.1.30                       Bring back Frank Nobis <fn@Radio-do.de>'s opt_bktr.h1.31                       Randall Hopper <rhh@ct.picker.com>                           submitted ioctl to clear the video buffer                           prior to starting video capture			   Amancio : clean up yuv12 so that it does not                           affect rgb capture. Basically, fxtv after                           capturing in yuv12 mode , switching to rgb                           would cause the video capture to be too bright.1.32                       disable inverse gamma function for rgb and yuv                           capture. fixed meteor brightness ioctl it now                           converts the brightness value from unsigned to                            signed.1.33                       added sysctl: hw.bt848.tuner, hw.bt848.reverse_mute,                           hw.bt848.card			   card takes a value from 0 to bt848_max_card                           tuner takes a value from 0 to bt848_max_tuner                           reverse_mute : 0 no effect, 1 reverse tuner                           mute function some tuners are wired reversed :(1.34                       reverse mute function for ims turbo card1.35                       Roger Hardiman <roger@cs.strath.ac.uk>                           options BROOKTREE_SYSTEM_DEFAULT=BROOKTREE_PAL                           in the kernel config file makes the driver's                           video_open() function select PAL rather than NTSC.                           This fixed all the hangs on my Dual Crystal card                           when using a PAL video signal. As a result, you                           can loose the tsleep (of 2 seconds - now 0.25!!)                           which I previously added. (Unless someone else                           wanted the 0.25 second tsleep).1.36                       added bt848.format sysctl variable.                            1 denotes NTSC , 0 denotes PAL1.37                       added support for Bt878 and improved Hauppauge's                           bt848 tuner recognition1.38                       Further improvements on Hauppauge's rely on                           eeprom[9] to determine the tuner type 8)                           AVerMedia card type added <sos@freebsd.org>1.39            08/05/98   Roger Hardiman <roger@cs.strath.ac.uk>                           Updated Hauppauge detection code for Tuner ID 0x0a                            for newer NTSC WinCastTV 404 with Bt878 chipset.                           Tidied up PAL default in video_open()1.49       10 August 1998  Roger Hardiman <roger@cs.strath.ac.uk>                           Added Capture Area ioctl - BT848[SG]CAPAREA.                           Normally the full 640x480 (768x576 PAL) image                           is grabbed. This ioctl allows a smaller area                           from anywhere within the video image to be                           grabbed, eg a 400x300 image from (50,10).                           See restrictions in BT848SCAPAREA.1.50       31 August 1998  Roger Hardiman <roger@cs.strath.ac.uk>                           Renamed BT848[SG]CAPAREA to BT848_[SG]CAPAREA.                           Added PR kern/7177 for SECAM Video Highway Xtreme                           with single crystal PLL configuration                           submitted by Vsevolod Lobko <seva@alex-ua.com>.                           In kernel configuration file add                             options OVERRIDE_CARD=2                             options OVERRIDE_TUNER=11                             options BKTR_USE_PLL1.51       31 August 1998  Roger Hardiman <roger@cs.strath.ac.uk>                           Fixed bug in Miro Tuner detection. Missing Goto.                           Removed Hauppauge EEPROM 0x10 detection as I think			   0x10 should be a PAL tuner, not NTSC.			   Reinstated some Tuner Guesswork code from 1.271.52           3 Sep 1998  Roger Hardiman <roger@cs.strath.ac.uk>                           Submitted patch by Vsevolod Lobko <seva@alex-ua.com>                           to correct SECAM B-Delay and add XUSSR channel set.1.53           9 Sep 1998  Roger Hardiman <roger@cs.strath.ac.uk>                           Changed METEORSINPUT for Hauppauge cards with bt878.                           Submitted by Fred Templin <templin@erg.sri.com>                           Also fixed video_open defines and 878 support.1.54          18 Sep 1998  Roger Hardiman <roger@cs.strath.ac.uk>                           Changed tuner code to autodetect tuner i2c address.                           Addresses were incorrectly hardcoded.1.55          21 Sep 1998  Roger Hardiman <roger@cs.strath.ac.uk>                           Hauppauge Tech Support confirmed all Hauppauge 878                           PAL/SECAM boards will use PLL mode.			   Added to card probe. Thanks to Ken and Fred.1.56    21 Jan 1999 Roger Hardiman <roger@cs.strath.ac.uk>                    Added detection of Hauppauge IR remote control.                    and MSP34xx Audio chip. Fixed i2c read error.                    Hauppauge supplied details of new Tuner Types.                    Danny Braniss <danny@cs.huji.ac.il> submitted Bt878                    AverMedia detection with PCI subsystem vendor id.1.57    26 Jan 1999 Roger Hardiman <roger@cs.strath.ac.uk>                    Support for MSP3410D / MSP3415D Stereo/Mono audio                    using the audio format Auto Detection Mode.                    Nicolas Souchu <nsouch@freebsd.org> ported the                    msp_read/write/reset functions to smbus/iicbus.                    METEOR_INPUT_DEV2 now selects a composite camera on                    the SVIDEO port for Johan Larsson<gozer@ludd.luth.se>                    For true SVIDEO, use METEOR_INPUT_DEV_SVIDEO1.58     8 Feb 1999 Roger Hardiman <roger@cs.strath.ac.uk>                    Added check to bktr_mmap from OpenBSD driver.                    Improved MSP34xx reset for bt848 Hauppauge boards.                    Added detection for Bt848a.                    Vsevolod Lobko<seva@sevasoft.alex-ua.com> added                    more XUSSR channels.1.59     9 Feb 1999 Added ioctl REMOTE_GETKEY for Hauppauge Infra-Red                    Remote Control. Submitted by Roger Hardiman.                    Added ioctl TVTUNER_GETCHANSET and                    BT848_GPIO_SET_EN,BT848_GPIO_SET_DATA (and GETs)                    Submitted by Vsevolod Lobko <seva@alex-ua.com>1.60    23 Feb 1999 Roger Hardiman <roger@freebsd.org>                    Corrected Mute on Hauppauge Radio cards.                    Autodetect MMAC Osprey by looking for "MMAC" in the EEPROM.                    Added for Jan Schmidt <mmedia@rz.uni-greifswald.de>                    Added ALPS Tuner Type from Hiroki Mori <mori@infocity.co.jp>1.61    29 Apr 1999 Roger Hardiman <roger@freebsd.org>                    Fix row=0/columns=0 bug. From Randal Hopper<aa8vb@ipass.net>                    Add option to block the reset of the MSP34xx audio chip by                    adding options BKTR_NO_MSP_RESET to the kernel config file.                    This is usefull if you run another operating system                    first to initialise the audio chip, then do a soft reboot.                    Added for Yuri Gindin <yuri@xpert.com>*/#define DDB(x) x#define DEB(x)#ifdef __FreeBSD__#include "bktr.h"#include "opt_bktr.h"#include "opt_devfs.h"#include "pci.h"#endif /* __FreeBSD__ */#if !defined(__FreeBSD__) || (NBKTR > 0 && NPCI > 0)#include <sys/param.h>#include <sys/systm.h>#include <sys/conf.h>#include <sys/uio.h>#include <sys/kernel.h>#include <sys/signalvar.h>#include <sys/mman.h>#include <vm/vm.h>#include <vm/vm_kern.h>#include <vm/pmap.h>#include <vm/vm_extern.h>#ifdef __FreeBSD__#ifdef DEVFS#include <sys/devfsext.h>#endif /* DEVFS */#include <machine/clock.h>#include <pci/pcivar.h>#include <pci/pcireg.h>#include <machine/ioctl_meteor.h>#include <machine/ioctl_bt848.h>	/* extensions to ioctl_meteor.h */#include <sys/bus.h>#include <pci/brktree_reg.h>#include <pci/bt848_i2c.h>#include <dev/smbus/smbconf.h>#include <dev/iicbus/iiconf.h>#include "smbus_if.h"#include "iicbus_if.h"#include <sys/sysctl.h>static int bt848_card = -1;static int bt848_tuner = -1;static int bt848_reverse_mute = -1;static int bt848_format = -1;SYSCTL_NODE(_hw, OID_AUTO, bt848, CTLFLAG_RW, 0, "Bt848 Driver mgmt");SYSCTL_INT(_hw_bt848, OID_AUTO, card, CTLFLAG_RW, &bt848_card, -1, "");SYSCTL_INT(_hw_bt848, OID_AUTO, tuner, CTLFLAG_RW, &bt848_tuner, -1, "");SYSCTL_INT(_hw_bt848, OID_AUTO, reverse_mute, CTLFLAG_RW, &bt848_reverse_mute, -1, "");SYSCTL_INT(_hw_bt848, OID_AUTO, format, CTLFLAG_RW, &bt848_format, -1, "");typedef u_long ioctl_cmd_t;#endif  /* __FreeBSD__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -