Split the Bt848 driver into seperate files for
audio, tuner, card make, os dependent code and core bt848/i2c code. Also, rewrite tuner code for FM Radio to make the code cleaner.
This commit is contained in:
parent
161e746fca
commit
96476a9986
404
sys/dev/bktr/CHANGELOG.TXT
Executable file
404
sys/dev/bktr/CHANGELOG.TXT
Executable file
@ -0,0 +1,404 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*
|
||||
* This is part of the Driver for Video Capture Cards (Frame grabbers)
|
||||
* and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879
|
||||
* chipset.
|
||||
* Copyright Roger Hardiman and Amancio Hasty.
|
||||
*
|
||||
* CHANGELOG : The Change History:
|
||||
* 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 release
|
||||
|
||||
1.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 frames
|
||||
1.22 11/08/97 Randall Hopper <rhh@ct.picker.com>
|
||||
Fixes for packed 24bpp - FIFO alignment
|
||||
1.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 tuner
|
||||
1.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.com
|
||||
1.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.h
|
||||
|
||||
1.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 card
|
||||
|
||||
1.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 PAL
|
||||
|
||||
1.37 added support for Bt878 and improved Hauppauge's
|
||||
bt848 tuner recognition
|
||||
1.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()
|
||||
|
||||
Soren bumped version from 1.39 to 1.49 to sync
|
||||
with FreeBSD CVS numbers.
|
||||
|
||||
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_PLL
|
||||
|
||||
1.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.27
|
||||
|
||||
1.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_SVIDEO
|
||||
|
||||
1.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>
|
||||
|
||||
1.62 29 Apr 1999 Added new cards: NEC PK-UG-X017 and I/O DATA GV-BCTV2/PCI
|
||||
Added new tuner: ALPS_TSBH1 (plus FM Radio for ALPS_TSCH5)
|
||||
Added support for BCTV audio mux.
|
||||
All submitted by Hiroki Mori <mori@infocity.co.jp>
|
||||
|
||||
1.63 29 Apr 1999 Roger Hardiman <roger@freebsd.org>
|
||||
Added initial code for VBI capture based on work by
|
||||
Hiroki Mori <mori@infocity.co.jp> and reworked by myself.
|
||||
This allows software decoding of teletext, intercast and
|
||||
subtitles via /dev/vbi.
|
||||
|
||||
1.64 7 May 1999 Roger Hardiman <roger@freebsd.org>
|
||||
Support LifeView FlyVideo 98 cards. Use EEPROM for card
|
||||
autodetection. Use bttv's audio mux values.
|
||||
Thanks to Paul Reece <paul@fastlane.net.au>,
|
||||
Ivan Brawley <brawley@internode.com.au> and
|
||||
Gilad Rom <rom_glsa@ein-hashofet.co.il>
|
||||
Automatically locate the EEPROM i2c address and read the
|
||||
subsystem_vendor_id from EEPROM and not the PCI registers.
|
||||
Add NSMBUS checks around smbus/iicbus i2c bus code
|
||||
making it easier to compile the driver under 2.2.x.
|
||||
Add GPIO mask for the audio mux to each card type.
|
||||
Add CARD_ZOLTRIX and CARD_KISS from mailing list searches.
|
||||
|
||||
1.65 18 May 1999 Roger Hardiman <roger@freebsd.org>
|
||||
Change Intel GPIO mask to stop turning the Intel Camera off
|
||||
Fixed tuner selection on Hauppauge card with tuner 0x0a
|
||||
Replaced none tuner with no tuner for Theo de Raadt.
|
||||
Ivan Brawley <brawley@internode.com.au> added
|
||||
the Australian channel frequencies.
|
||||
|
||||
1.66 19 May 1999 Ivan Brawley <brawley@internode.com.au> added better
|
||||
Australian channel frequencies.
|
||||
|
||||
1.67 23 May 1999 Roger Hardiman <roger@freebsd.org>
|
||||
Added rgb_vbi_prog() to capture VBI data and video at the
|
||||
same time. To capture VBI data, /dev/vbi must be opened
|
||||
before starting video capture.
|
||||
|
||||
1.68 25 May 1999 Roger Hardiman <roger@freebsd.org>
|
||||
Due to differences in PCI bus implementations from various
|
||||
motherboard chipset manufactuers, the Bt878/Bt879 has 3
|
||||
PCI bus compatibility modes. These are
|
||||
NORMAL PCI 2.1 for proper PCI 2.1 compatible chipsets.
|
||||
INTEL 430 FX for the Intel 430 FX chipset.
|
||||
SIS VIA CHIPSET for certain SiS and VIA chipsets.
|
||||
Older Intel and non-Intel chipsets may also benefit from
|
||||
either 430_FX or SIS/VIA mode.
|
||||
|
||||
NORMAL PCI mode is enabled by default.
|
||||
For INTEL 430 FX mode, add this to your kenel config:
|
||||
options "BKTR_430_FX_MODE"
|
||||
For SiS / VIA mode, add this to your kernel config:
|
||||
options "BKTR_SIS_VIA_MODE"
|
||||
|
||||
Using quotes in these options is not needed in FreeBSD 4.x.
|
||||
|
||||
Note. Newer VIA chipsets should be fully PCI 2.1 compatible
|
||||
and should work fine in the Default mode.
|
||||
|
||||
Also rename 849 to 849A, the correct name for the chip.
|
||||
|
||||
1.69 12 June 1999 Roger Hardiman <roger@freebsd.org>
|
||||
Updates for FreeBSD 4.x device driver interface.
|
||||
BSDI code removed. Will be restored later.
|
||||
|
||||
1.70 12 July 1999 Roger Hardiman <roger@freebsd.org>
|
||||
Reorganise OS device dependant parts (based on a port to
|
||||
linux by Brad Parker).
|
||||
Make the driver compile on FreeBSD 2.2.x systems again.
|
||||
Change number of VBI lines from 16 to 12 for NTSC formats.
|
||||
Changes to probeCard() for better eeprom identification.
|
||||
Added STB Bt878 card identification.
|
||||
Add Hauppauge model identification to probeCard().
|
||||
Added TDA9850 initialisation code taken from Linux bttv.
|
||||
Juha.Nurmela@quicknet.inet.fi found/fixed bug in VBI_SLEEP.
|
||||
Matt Brown <matt@dqc.org> added MSP3430G DBX initialisation.
|
||||
|
||||
1.71 30 Aug 1999 Roger Hardiman <roger@freebsd.org>
|
||||
Small cleanup of OS dependant code. Remove NPCI usage.
|
||||
Fix bug in AVerMedia detection.
|
||||
Update VBI support for the AleVT Teletext package. Parts
|
||||
from Juha Nurmela's driver <Juha.Nurmela@quicknet.inet.fi>
|
||||
Add support for Hauppauge 627 and Temic 4006 submitted
|
||||
by Maurice Castro <maurice@atum.castro.aus.net>
|
||||
Tom Jansen <tom@unhooked.net> added BSDi support again.
|
||||
|
||||
1.72 31 Aug 1999 Juha Nurmela <Juha.Nurmela@quicknet.inet.fi>
|
||||
Clear cap_ctl register when restarting the RISC program.
|
||||
This fixes the freezes experienced when changing changes.
|
||||
|
||||
1.73 10 Sep 1999 Roger Hardiman <roger@freebsd.org>
|
||||
Add Hauppauge tuner #6 for Brian Somers <brian@freebsd.org>
|
||||
Add card type for Aimslabs Video Highway Xtreme for
|
||||
Ladislav Kostal <kostal@pefstud.uniag.sk>
|
||||
Added select() code (for VBI) for the 2.2.x driver
|
||||
tested by Steve Richards <steve@richsoft.demon.co.uk>
|
||||
|
||||
1.74 17 Sep 1999 Roger Hardiman <roger@freebsd.org>
|
||||
Fix bug where FM radio stations were offset after using FXTV
|
||||
AVerMedia tuner type autodetection added for cards with
|
||||
a configuration EEPROM (currently their Bt878 range)
|
||||
Thanks to Frank at AVerMedia for providing the information.
|
||||
Tested by David La Croix <dlacroix@cowpie.acm.vt.edu>
|
||||
Tidy up some tuner code and Hauppauge detection code.
|
||||
New NetBSD code from Bernd Ernesti<bernd@arresum.inka.de>
|
||||
|
||||
2.00 25 Sep 1999 Roger Hardiman <roger@freebsd.org>
|
||||
Split the driver into seperate tuner, card and audio sections.
|
||||
Update tuner code so Tuner FM radio support to use correct
|
||||
datasheet values.
|
||||
|
||||
|
432
sys/dev/bktr/bktr_audio.c
Normal file
432
sys/dev/bktr/bktr_audio.c
Normal file
@ -0,0 +1,432 @@
|
||||
/* $FreeBSD$ */
|
||||
/*
|
||||
* This is part of the Driver for Video Capture Cards (Frame grabbers)
|
||||
* and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879
|
||||
* chipset.
|
||||
* Copyright Roger Hardiman and Amancio Hasty.
|
||||
*
|
||||
* bktr_audio : This deals with controlling the audio on TV cards,
|
||||
* controlling the Audio Multiplexer (audio source selector).
|
||||
* controlling any MSP34xx stereo audio decoders.
|
||||
* initialising TDA98xx audio devices.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* 1. Redistributions of source code must retain the
|
||||
* Copyright (c) 1997 Amancio Hasty, 1999 Roger Hardiman
|
||||
* 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 and
|
||||
* Roger Hardiman
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/vnode.h>
|
||||
|
||||
#include <machine/clock.h> /* for DELAY */
|
||||
|
||||
#include <pci/pcivar.h>
|
||||
|
||||
#include <machine/ioctl_meteor.h>
|
||||
#include <machine/ioctl_bt848.h> /* extensions to ioctl_meteor.h */
|
||||
#include <dev/bktr/bktr_reg.h>
|
||||
#include <dev/bktr/bktr_core.h>
|
||||
#include <dev/bktr/bktr_tuner.h>
|
||||
#include <dev/bktr/bktr_card.h>
|
||||
#include <dev/bktr/bktr_audio.h>
|
||||
|
||||
|
||||
/*
|
||||
* Prototypes for the GV_BCTV specific functions.
|
||||
*/
|
||||
void set_bctv_audio( bktr_ptr_t bktr );
|
||||
void bctv_gpio_write( bktr_ptr_t bktr, int port, int val );
|
||||
/*int bctv_gpio_read( bktr_ptr_t bktr, int port );*/ /* Not used */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* init_audio_devices
|
||||
* Reset any MSP34xx or TDA98xx audio devices.
|
||||
*/
|
||||
void init_audio_devices( bktr_ptr_t bktr ) {
|
||||
|
||||
/* enable stereo if appropriate on TDA audio chip */
|
||||
if ( bktr->card.dbx )
|
||||
init_BTSC( bktr );
|
||||
|
||||
/* reset the MSP34xx stereo audio chip */
|
||||
if ( bktr->card.msp3400c )
|
||||
msp_reset( bktr );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
#define AUDIOMUX_DISCOVER_NOT
|
||||
int
|
||||
set_audio( bktr_ptr_t bktr, int cmd )
|
||||
{
|
||||
bt848_ptr_t bt848;
|
||||
u_long temp;
|
||||
volatile u_char idx;
|
||||
|
||||
#if defined( AUDIOMUX_DISCOVER )
|
||||
if ( cmd >= 200 )
|
||||
cmd -= 200;
|
||||
else
|
||||
#endif /* AUDIOMUX_DISCOVER */
|
||||
|
||||
/* check for existance of audio MUXes */
|
||||
if ( !bktr->card.audiomuxs[ 4 ] )
|
||||
return( -1 );
|
||||
|
||||
switch (cmd) {
|
||||
case AUDIO_TUNER:
|
||||
#ifdef BKTR_REVERSEMUTE
|
||||
bktr->audio_mux_select = 3;
|
||||
#else
|
||||
bktr->audio_mux_select = 0;
|
||||
#endif
|
||||
|
||||
if (bktr->reverse_mute )
|
||||
bktr->audio_mux_select = 0;
|
||||
else
|
||||
bktr->audio_mux_select = 3;
|
||||
|
||||
break;
|
||||
case AUDIO_EXTERN:
|
||||
bktr->audio_mux_select = 1;
|
||||
break;
|
||||
case AUDIO_INTERN:
|
||||
bktr->audio_mux_select = 2;
|
||||
break;
|
||||
case AUDIO_MUTE:
|
||||
bktr->audio_mute_state = TRUE; /* set mute */
|
||||
break;
|
||||
case AUDIO_UNMUTE:
|
||||
bktr->audio_mute_state = FALSE; /* clear mute */
|
||||
break;
|
||||
default:
|
||||
printf("bktr: audio cmd error %02x\n", cmd);
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
||||
/* Most cards have a simple audio multiplexer to select the
|
||||
* audio source. The I/O_GV card has a more advanced multiplexer
|
||||
* and requires special handling.
|
||||
*/
|
||||
if ( bktr->bt848_card == CARD_IO_GV ) {
|
||||
set_bctv_audio( bktr );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/* Proceed with the simpler audio multiplexer code for the majority
|
||||
* of Bt848 cards.
|
||||
*/
|
||||
|
||||
bt848 = bktr->base;
|
||||
|
||||
/*
|
||||
* Leave the upper bits of the GPIO port alone in case they control
|
||||
* something like the dbx or teletext chips. This doesn't guarantee
|
||||
* success, but follows the rule of least astonishment.
|
||||
*/
|
||||
|
||||
if ( bktr->audio_mute_state == TRUE ) {
|
||||
#ifdef BKTR_REVERSEMUTE
|
||||
idx = 0;
|
||||
#else
|
||||
idx = 3;
|
||||
#endif
|
||||
|
||||
if (bktr->reverse_mute )
|
||||
idx = 3;
|
||||
else
|
||||
idx = 0;
|
||||
|
||||
}
|
||||
else
|
||||
idx = bktr->audio_mux_select;
|
||||
|
||||
temp = bt848->gpio_data & ~bktr->card.gpio_mux_bits;
|
||||
bt848->gpio_data =
|
||||
#if defined( AUDIOMUX_DISCOVER )
|
||||
bt848->gpio_data = temp | (cmd & 0xff);
|
||||
printf("cmd: %d audio mux %x temp %x \n", cmd,bktr->card.audiomuxs[ idx ], temp );
|
||||
#else
|
||||
temp | bktr->card.audiomuxs[ idx ];
|
||||
#endif /* AUDIOMUX_DISCOVER */
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void
|
||||
temp_mute( bktr_ptr_t bktr, int flag )
|
||||
{
|
||||
static int muteState = FALSE;
|
||||
|
||||
if ( flag == TRUE ) {
|
||||
muteState = bktr->audio_mute_state;
|
||||
set_audio( bktr, AUDIO_MUTE ); /* prevent 'click' */
|
||||
}
|
||||
else {
|
||||
tsleep( BKTR_SLEEP, PZERO, "tuning", hz/8 );
|
||||
if ( muteState == FALSE )
|
||||
set_audio( bktr, AUDIO_UNMUTE );
|
||||
}
|
||||
}
|
||||
|
||||
/* address of BTSC/SAP decoder chip */
|
||||
#define TDA9850_WADDR 0xb6
|
||||
#define TDA9850_RADDR 0xb7
|
||||
|
||||
|
||||
/* registers in the TDA9850 BTSC/dbx chip */
|
||||
#define CON1ADDR 0x04
|
||||
#define CON2ADDR 0x05
|
||||
#define CON3ADDR 0x06
|
||||
#define CON4ADDR 0x07
|
||||
#define ALI1ADDR 0x08
|
||||
#define ALI2ADDR 0x09
|
||||
#define ALI3ADDR 0x0a
|
||||
|
||||
/*
|
||||
* initialise the dbx chip
|
||||
* taken from the Linux bttv driver TDA9850 initialisation code
|
||||
*/
|
||||
void
|
||||
init_BTSC( bktr_ptr_t bktr )
|
||||
{
|
||||
i2cWrite(bktr, TDA9850_WADDR, CON1ADDR, 0x08); /* noise threshold st */
|
||||
i2cWrite(bktr, TDA9850_WADDR, CON2ADDR, 0x08); /* noise threshold sap */
|
||||
i2cWrite(bktr, TDA9850_WADDR, CON3ADDR, 0x40); /* stereo mode */
|
||||
i2cWrite(bktr, TDA9850_WADDR, CON4ADDR, 0x07); /* 0 dB input gain? */
|
||||
i2cWrite(bktr, TDA9850_WADDR, ALI1ADDR, 0x10); /* wideband alignment? */
|
||||
i2cWrite(bktr, TDA9850_WADDR, ALI2ADDR, 0x10); /* spectral alignment? */
|
||||
i2cWrite(bktr, TDA9850_WADDR, ALI3ADDR, 0x03);
|
||||
}
|
||||
|
||||
/*
|
||||
* setup the dbx chip
|
||||
* XXX FIXME: alot of work to be done here, this merely unmutes it.
|
||||
*/
|
||||
int
|
||||
set_BTSC( bktr_ptr_t bktr, int control )
|
||||
{
|
||||
return( i2cWrite( bktr, TDA9850_WADDR, CON3ADDR, control ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* CARD_GV_BCTV specific functions.
|
||||
*/
|
||||
|
||||
#define BCTV_AUDIO_MAIN 0x10 /* main audio program */
|
||||
#define BCTV_AUDIO_SUB 0x20 /* sub audio program */
|
||||
#define BCTV_AUDIO_BOTH 0x30 /* main(L) + sub(R) program */
|
||||
|
||||
#define BCTV_GPIO_REG0 1
|
||||
#define BCTV_GPIO_REG1 3
|
||||
|
||||
#define BCTV_GR0_AUDIO_MODE 3
|
||||
#define BCTV_GR0_AUDIO_MAIN 0 /* main program */
|
||||
#define BCTV_GR0_AUDIO_SUB 3 /* sub program */
|
||||
#define BCTV_GR0_AUDIO_BOTH 1 /* main(L) + sub(R) */
|
||||
#define BCTV_GR0_AUDIO_MUTE 4 /* audio mute */
|
||||
#define BCTV_GR0_AUDIO_MONO 8 /* force mono */
|
||||
|
||||
void
|
||||
set_bctv_audio( bktr_ptr_t bktr )
|
||||
{
|
||||
int data;
|
||||
|
||||
switch (bktr->audio_mux_select) {
|
||||
case 1: /* external */
|
||||
case 2: /* internal */
|
||||
bctv_gpio_write(bktr, BCTV_GPIO_REG1, 0);
|
||||
break;
|
||||
default: /* tuner */
|
||||
bctv_gpio_write(bktr, BCTV_GPIO_REG1, 1);
|
||||
break;
|
||||
}
|
||||
/* switch (bktr->audio_sap_select) { */
|
||||
switch (BCTV_AUDIO_BOTH) {
|
||||
case BCTV_AUDIO_SUB:
|
||||
data = BCTV_GR0_AUDIO_SUB;
|
||||
break;
|
||||
case BCTV_AUDIO_BOTH:
|
||||
data = BCTV_GR0_AUDIO_BOTH;
|
||||
break;
|
||||
case BCTV_AUDIO_MAIN:
|
||||
default:
|
||||
data = BCTV_GR0_AUDIO_MAIN;
|
||||
break;
|
||||
}
|
||||
if (bktr->audio_mute_state == TRUE)
|
||||
data |= BCTV_GR0_AUDIO_MUTE;
|
||||
|
||||
bctv_gpio_write(bktr, BCTV_GPIO_REG0, data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* gpio_data bit assignment */
|
||||
#define BCTV_GPIO_ADDR_MASK 0x000300
|
||||
#define BCTV_GPIO_WE 0x000400
|
||||
#define BCTV_GPIO_OE 0x000800
|
||||
#define BCTV_GPIO_VAL_MASK 0x00f000
|
||||
|
||||
#define BCTV_GPIO_PORT_MASK 3
|
||||
#define BCTV_GPIO_ADDR_SHIFT 8
|
||||
#define BCTV_GPIO_VAL_SHIFT 12
|
||||
|
||||
/* gpio_out_en value for read/write */
|
||||
#define BCTV_GPIO_OUT_RMASK 0x000f00
|
||||
#define BCTV_GPIO_OUT_WMASK 0x00ff00
|
||||
|
||||
#define BCTV_BITS 100
|
||||
|
||||
void
|
||||
bctv_gpio_write( bktr_ptr_t bktr, int port, int val )
|
||||
{
|
||||
bt848_ptr_t bt848 = bktr->base;
|
||||
u_long data, outbits;
|
||||
|
||||
port &= BCTV_GPIO_PORT_MASK;
|
||||
switch (port) {
|
||||
case 1:
|
||||
case 3:
|
||||
data = ((val << BCTV_GPIO_VAL_SHIFT) & BCTV_GPIO_VAL_MASK) |
|
||||
((port << BCTV_GPIO_ADDR_SHIFT) & BCTV_GPIO_ADDR_MASK) |
|
||||
BCTV_GPIO_WE | BCTV_GPIO_OE;
|
||||
outbits = BCTV_GPIO_OUT_WMASK;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
bt848->gpio_out_en = 0;
|
||||
bt848->gpio_data = data;
|
||||
bt848->gpio_out_en = outbits;
|
||||
DELAY(BCTV_BITS);
|
||||
bt848->gpio_data = data & ~BCTV_GPIO_WE;
|
||||
DELAY(BCTV_BITS);
|
||||
bt848->gpio_data = data;
|
||||
DELAY(BCTV_BITS);
|
||||
bt848->gpio_data = ~0;
|
||||
bt848->gpio_out_en = 0;
|
||||
}
|
||||
|
||||
/* Not yet used
|
||||
int
|
||||
bctv_gpio_read( bktr_ptr_t bktr, int port )
|
||||
{
|
||||
bt848_ptr_t bt848 = bktr->base;
|
||||
u_long data, outbits, ret;
|
||||
|
||||
port &= BCTV_GPIO_PORT_MASK;
|
||||
switch (port) {
|
||||
case 1:
|
||||
case 3:
|
||||
data = ((port << BCTV_GPIO_ADDR_SHIFT) & BCTV_GPIO_ADDR_MASK) |
|
||||
BCTV_GPIO_WE | BCTV_GPIO_OE;
|
||||
outbits = BCTV_GPIO_OUT_RMASK;
|
||||
break;
|
||||
default:
|
||||
return( -1 );
|
||||
}
|
||||
bt848->gpio_out_en = 0;
|
||||
bt848->gpio_data = data;
|
||||
bt848->gpio_out_en = outbits;
|
||||
DELAY(BCTV_BITS);
|
||||
bt848->gpio_data = data & ~BCTV_GPIO_OE;
|
||||
DELAY(BCTV_BITS);
|
||||
ret = bt848->gpio_data;
|
||||
DELAY(BCTV_BITS);
|
||||
bt848->gpio_data = data;
|
||||
DELAY(BCTV_BITS);
|
||||
bt848->gpio_data = ~0;
|
||||
bt848->gpio_out_en = 0;
|
||||
return( (ret & BCTV_GPIO_VAL_MASK) >> BCTV_GPIO_VAL_SHIFT );
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* setup the MSP34xx Stereo Audio Chip
|
||||
* This uses the Auto Configuration Option on MSP3410D and MSP3415D chips
|
||||
* and DBX mode selection for MSP3430G chips.
|
||||
* For MSP3400C support, the full programming sequence is required and is
|
||||
* not yet supported.
|
||||
*/
|
||||
|
||||
/* Read the MSP version string */
|
||||
void msp_read_id( bktr_ptr_t bktr ){
|
||||
int rev1=0, rev2=0;
|
||||
rev1 = msp_read(bktr, 0x12, 0x001e);
|
||||
rev2 = msp_read(bktr, 0x12, 0x001f);
|
||||
|
||||
sprintf(bktr->msp_version_string, "34%02d%c-%c%d",
|
||||
(rev2>>8)&0xff, (rev1&0xff)+'@', ((rev1>>8)&0xff)+'@', rev2&0x1f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Configure the MSP chip to Auto-detect the audio format */
|
||||
void msp_autodetect( bktr_ptr_t bktr ) {
|
||||
|
||||
if (strncmp("3430G", bktr->msp_version_string, 5) == 0){
|
||||
|
||||
/* For MSP3430G - countries with mono and DBX stereo */
|
||||
msp_write(bktr, 0x10, 0x0030,0x2003);/* Enable Auto format detection */
|
||||
msp_write(bktr, 0x10, 0x0020,0x0020);/* Standard Select Reg. = BTSC-Stereo*/
|
||||
msp_write(bktr, 0x12, 0x000E,0x2403);/* darned if I know */
|
||||
msp_write(bktr, 0x12, 0x0008,0x0320);/* Source select = (St or A) */
|
||||
/* & Ch. Matrix = St */
|
||||
msp_write(bktr, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */
|
||||
|
||||
} else {
|
||||
|
||||
/* For MSP3410 / 3415 - countries with mono, stereo using 2 FM channels
|
||||
and NICAM */
|
||||
msp_write(bktr, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */
|
||||
msp_write(bktr, 0x10, 0x0020,0x0001);/* Enable Auto format detection */
|
||||
msp_write(bktr, 0x10, 0x0021,0x0001);/* Auto selection of NICAM/MONO mode */
|
||||
}
|
||||
|
||||
/* uncomment the following line to enable the MSP34xx 1Khz Tone Generator */
|
||||
/* turn your speaker volume down low before trying this */
|
||||
/* msp_write(bktr, 0x12, 0x0014, 0x7f40); */
|
||||
}
|
76
sys/dev/bktr/bktr_audio.h
Normal file
76
sys/dev/bktr/bktr_audio.h
Normal file
@ -0,0 +1,76 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*
|
||||
* This is part of the Driver for Video Capture Cards (Frame grabbers)
|
||||
* and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879
|
||||
* chipset.
|
||||
* Copyright Roger Hardiman and Amancio Hasty.
|
||||
*
|
||||
* bktr_audio : This deals with controlling the audio on TV cards,
|
||||
* controlling the Audio Multiplexer (audio source selector).
|
||||
* controlling any MSP34xx stereo audio decoders.
|
||||
* initialising TDA98xx audio devices.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* 1. Redistributions of source code must retain the
|
||||
* Copyright (c) 1997 Amancio Hasty, 1999 Roger Hardiman
|
||||
* 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 and
|
||||
* Roger Hardiman
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Select Audio source, and allow muting
|
||||
*/
|
||||
int set_audio( bktr_ptr_t bktr, int mode );
|
||||
void temp_mute( bktr_ptr_t bktr, int flag );
|
||||
|
||||
|
||||
/*
|
||||
* Initialise any MSP or TDA devices
|
||||
*/
|
||||
void init_audio_devices( bktr_ptr_t bktr );
|
||||
|
||||
|
||||
/*
|
||||
* MSP34xx Audio Chip functions.
|
||||
*/
|
||||
void msp_autodetect( bktr_ptr_t bktr );
|
||||
void msp_read_id( bktr_ptr_t bktr );
|
||||
|
||||
|
||||
/*
|
||||
* TDA98xx Audio Chip functions.
|
||||
*/
|
||||
void init_BTSC( bktr_ptr_t bktr );
|
||||
int set_BTSC( bktr_ptr_t bktr, int control );
|
||||
|
||||
|
||||
|
1069
sys/dev/bktr/bktr_card.c
Normal file
1069
sys/dev/bktr/bktr_card.c
Normal file
File diff suppressed because it is too large
Load Diff
84
sys/dev/bktr/bktr_card.h
Normal file
84
sys/dev/bktr/bktr_card.h
Normal file
@ -0,0 +1,84 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*
|
||||
* This is part of the Driver for Video Capture Cards (Frame grabbers)
|
||||
* and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879
|
||||
* chipset.
|
||||
* Copyright Roger Hardiman and Amancio Hasty.
|
||||
*
|
||||
* bktr_card : This deals with identifying TV cards.
|
||||
* trying to find the card make and model of card.
|
||||
* trying to find the type of tuner fitted.
|
||||
* reading the configuration EEPROM.
|
||||
* locating i2c devices.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* 1. Redistributions of source code must retain the
|
||||
* Copyright (c) 1997 Amancio Hasty, 1999 Roger Hardiman
|
||||
* 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 and
|
||||
* Roger Hardiman
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* If probeCard() fails to detect the correct card on boot you can
|
||||
* override it by setting adding the following option to your kernel config
|
||||
* options OVERRIDE_CARD <card type>
|
||||
* eg options OVERRIDE CARD=1
|
||||
*
|
||||
* or using the sysclt hw.bt848.card
|
||||
* eg sysctl -w hw.bt848.card=1
|
||||
*
|
||||
* where <card type> is one of the following card defines.
|
||||
*/
|
||||
|
||||
#define CARD_UNKNOWN 0
|
||||
#define CARD_MIRO 1
|
||||
#define CARD_HAUPPAUGE 2
|
||||
#define CARD_STB 3
|
||||
#define CARD_INTEL 4 /* Also for VideoLogic Captivator PCI */
|
||||
#define CARD_IMS_TURBO 5
|
||||
#define CARD_AVER_MEDIA 6
|
||||
#define CARD_OSPREY 7
|
||||
#define CARD_NEC_PK 8
|
||||
#define CARD_IO_GV 9
|
||||
#define CARD_FLYVIDEO 10
|
||||
#define CARD_ZOLTRIX 11
|
||||
#define CARD_KISS 12
|
||||
#define CARD_VIDEO_HIGHWAY_XTREME 13
|
||||
#define Bt848_MAX_CARD 14
|
||||
|
||||
|
||||
int signCard( bktr_ptr_t bktr, int offset, int count, u_char* sig );
|
||||
void probeCard( bktr_ptr_t bktr, int verbose, int unit);
|
||||
|
||||
int writeEEProm( bktr_ptr_t bktr, int offset, int count, u_char *data );
|
||||
int readEEProm( bktr_ptr_t bktr, int offset, int count, u_char *data );
|
||||
|
File diff suppressed because it is too large
Load Diff
93
sys/dev/bktr/bktr_core.h
Normal file
93
sys/dev/bktr/bktr_core.h
Normal file
@ -0,0 +1,93 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*
|
||||
* This is part of the Driver for Video Capture Cards (Frame grabbers)
|
||||
* and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879
|
||||
* chipset.
|
||||
* Copyright Roger Hardiman and Amancio Hasty.
|
||||
*
|
||||
* bktr_core : This deals with the Bt848/849/878/879 PCI Frame Grabber,
|
||||
* Handles all the open, close, ioctl and read userland calls.
|
||||
* Sets the Bt848 registers and generates RISC pograms.
|
||||
* Controls the i2c bus and GPIO interface.
|
||||
* Contains the interface to the kernel.
|
||||
* (eg probe/attach and open/close/ioctl)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* 1. Redistributions of source code must retain the
|
||||
* Copyright (c) 1997 Amancio Hasty, 1999 Roger Hardiman
|
||||
* 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 and
|
||||
* Roger Hardiman
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
int i2cWrite( bktr_ptr_t bktr, int addr, int byte1, int byte2 );
|
||||
int i2cRead( bktr_ptr_t bktr, int addr );
|
||||
|
||||
void msp_reset( bktr_ptr_t bktr );
|
||||
unsigned int msp_read(bktr_ptr_t bktr, unsigned char dev, unsigned int addr);
|
||||
void msp_write( bktr_ptr_t bktr, unsigned char dev,
|
||||
unsigned int addr, unsigned int data);
|
||||
|
||||
|
||||
/*
|
||||
* Defines for userland processes blocked in this driver
|
||||
* For /dev/bktr[n] use memory address of bktr structure
|
||||
* For /dev/vbi[n] use memory address of bktr structure + 1
|
||||
* this is ok as the bktr structure is > 1 byte
|
||||
*/
|
||||
#define BKTR_SLEEP ((caddr_t)bktr )
|
||||
#define VBI_SLEEP ((caddr_t)bktr + 1)
|
||||
|
||||
|
||||
/* Prototypes for attatch and interrupt functions */
|
||||
void common_bktr_attach( bktr_ptr_t bktr, int unit,
|
||||
u_long pci_id, u_int rev );
|
||||
int common_bktr_intr( void *arg );
|
||||
|
||||
|
||||
/* Prototypes for open, close, read, mmap and ioctl calls */
|
||||
int video_open( bktr_ptr_t bktr );
|
||||
int video_close( bktr_ptr_t bktr );
|
||||
int video_read( bktr_ptr_t bktr, int unit, dev_t dev, struct uio *uio );
|
||||
int video_ioctl( bktr_ptr_t bktr, int unit,
|
||||
int cmd, caddr_t arg, struct proc* pr );
|
||||
|
||||
|
||||
int tuner_open( bktr_ptr_t bktr );
|
||||
int tuner_close( bktr_ptr_t bktr );
|
||||
int tuner_ioctl( bktr_ptr_t bktr, int unit,
|
||||
int cmd, caddr_t arg, struct proc* pr );
|
||||
|
||||
int vbi_open( bktr_ptr_t bktr );
|
||||
int vbi_close( bktr_ptr_t bktr );
|
||||
int vbi_read( bktr_ptr_t bktr, struct uio *uio, int ioflag );
|
||||
|
1200
sys/dev/bktr/bktr_os.c
Normal file
1200
sys/dev/bktr/bktr_os.c
Normal file
File diff suppressed because it is too large
Load Diff
58
sys/dev/bktr/bktr_os.h
Normal file
58
sys/dev/bktr/bktr_os.h
Normal file
@ -0,0 +1,58 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*
|
||||
* This is part of the Driver for Video Capture Cards (Frame grabbers)
|
||||
* and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879
|
||||
* chipset.
|
||||
* Copyright Roger Hardiman and Amancio Hasty.
|
||||
*
|
||||
* bktr_os : This has all the Operating System dependant code.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* 1. Redistributions of source code must retain the
|
||||
* Copyright (c) 1997 Amancio Hasty, 1999 Roger Hardiman
|
||||
* 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 and
|
||||
* Roger Hardiman
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
/******************************/
|
||||
/* *** Memory Allocation *** */
|
||||
/******************************/
|
||||
#if (defined(__FreeBSD__) || defined(__bsdi__))
|
||||
vm_offset_t get_bktr_mem( int unit, unsigned size );
|
||||
#endif
|
||||
|
||||
#if (defined(__NetBSD__) || defined(__OpenBSD__))
|
||||
vm_offset_t get_bktr_mem(bktr_ptr_t, bus_dmamap_t *, unsigned size);
|
||||
void free_bktr_mem(bktr_ptr_t, bus_dmamap_t, vm_offset_t);
|
||||
#endif
|
||||
|
@ -1,4 +1,6 @@
|
||||
/*
|
||||
* $FreeBSD$
|
||||
*
|
||||
* Copyright (c) 1999 Roger Hardiman
|
||||
* Copyright (c) 1998 Amancio Hasty
|
||||
* Copyright (c) 1995 Mark Tinguely and Jim Lowe
|
||||
@ -30,8 +32,17 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if (__FreeBSD_version >= 310000)
|
||||
#include <sys/bus.h>
|
||||
#include "smbus.h"
|
||||
#else
|
||||
#define NSMBUS 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef PCI_LATENCY_TIMER
|
||||
#define PCI_LATENCY_TIMER 0x0c /* pci timer register */
|
||||
#endif
|
||||
@ -582,6 +593,7 @@ struct bktr_softc {
|
||||
int xtal_pll_mode; /* Use XTAL or PLL mode for PAL/SECAM */ int remote_control; /* remote control detected */
|
||||
int remote_control_addr; /* remote control i2c address */
|
||||
char msp_version_string[9]; /* MSP version string 34xxx-xx */
|
||||
int msp_addr; /* MSP i2c address */
|
||||
|
||||
|
||||
};
|
||||
|
960
sys/dev/bktr/bktr_tuner.c
Normal file
960
sys/dev/bktr/bktr_tuner.c
Normal file
@ -0,0 +1,960 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*
|
||||
* This is part of the Driver for Video Capture Cards (Frame grabbers)
|
||||
* and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879
|
||||
* chipset.
|
||||
* Copyright Roger Hardiman and Amancio Hasty.
|
||||
*
|
||||
* bktr_tuner : This deals with controlling the tuner fitted to TV cards.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* 1. Redistributions of source code must retain the
|
||||
* Copyright (c) 1997 Amancio Hasty, 1999 Roger Hardiman
|
||||
* 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 and
|
||||
* Roger Hardiman
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/vnode.h>
|
||||
|
||||
#include <machine/clock.h> /* for DELAY */
|
||||
|
||||
#include <pci/pcivar.h>
|
||||
|
||||
#include <machine/ioctl_meteor.h>
|
||||
#include <machine/ioctl_bt848.h> /* extensions to ioctl_meteor.h */
|
||||
#include <dev/bktr/bktr_reg.h>
|
||||
#include <dev/bktr/bktr_tuner.h>
|
||||
#include <dev/bktr/bktr_card.h>
|
||||
#include <dev/bktr/bktr_core.h>
|
||||
|
||||
|
||||
|
||||
#if defined( TUNER_AFC )
|
||||
#define AFC_DELAY 10000 /* 10 millisend delay */
|
||||
#define AFC_BITS 0x07
|
||||
#define AFC_FREQ_MINUS_125 0x00
|
||||
#define AFC_FREQ_MINUS_62 0x01
|
||||
#define AFC_FREQ_CENTERED 0x02
|
||||
#define AFC_FREQ_PLUS_62 0x03
|
||||
#define AFC_FREQ_PLUS_125 0x04
|
||||
#define AFC_MAX_STEP (5 * FREQFACTOR) /* no more than 5 MHz */
|
||||
#endif /* TUNER_AFC */
|
||||
|
||||
|
||||
#define TTYPE_XXX 0
|
||||
#define TTYPE_NTSC 1
|
||||
#define TTYPE_NTSC_J 2
|
||||
#define TTYPE_PAL 3
|
||||
#define TTYPE_PAL_M 4
|
||||
#define TTYPE_PAL_N 5
|
||||
#define TTYPE_SECAM 6
|
||||
|
||||
#define TSA552x_CB_MSB (0x80)
|
||||
#define TSA552x_CB_CP (1<<6) /* set this for fast tuning */
|
||||
#define TSA552x_CB_T2 (1<<5) /* test mode - Normally set to 0 */
|
||||
#define TSA552x_CB_T1 (1<<4) /* test mode - Normally set to 0 */
|
||||
#define TSA552x_CB_T0 (1<<3) /* test mode - Normally set to 1 */
|
||||
#define TSA552x_CB_RSA (1<<2) /* 0 for 31.25 khz, 1 for 62.5 kHz */
|
||||
#define TSA552x_CB_RSB (1<<1) /* 0 for FM 50kHz steps, 1 = Use RSA*/
|
||||
#define TSA552x_CB_OS (1<<0) /* Set to 0 for normal operation */
|
||||
|
||||
#define TSA552x_RADIO (TSA552x_CB_MSB | \
|
||||
TSA552x_CB_T0)
|
||||
|
||||
/* raise the charge pump voltage for fast tuning */
|
||||
#define TSA552x_FCONTROL (TSA552x_CB_MSB | \
|
||||
TSA552x_CB_CP | \
|
||||
TSA552x_CB_T0 | \
|
||||
TSA552x_CB_RSA | \
|
||||
TSA552x_CB_RSB)
|
||||
|
||||
/* lower the charge pump voltage for better residual oscillator FM */
|
||||
#define TSA552x_SCONTROL (TSA552x_CB_MSB | \
|
||||
TSA552x_CB_T0 | \
|
||||
TSA552x_CB_RSA | \
|
||||
TSA552x_CB_RSB)
|
||||
|
||||
/* The control value for the ALPS TSCH5 Tuner */
|
||||
#define TSCH5_FCONTROL 0x82
|
||||
#define TSCH5_RADIO 0x86
|
||||
|
||||
/* The control value for the ALPS TSBH1 Tuner */
|
||||
#define TSBH1_FCONTROL 0xce
|
||||
|
||||
|
||||
static const struct TUNER tuners[] = {
|
||||
/* XXX FIXME: fill in the band-switch crosspoints */
|
||||
/* NO_TUNER */
|
||||
{ "<no>", /* the 'name' */
|
||||
TTYPE_XXX, /* input type */
|
||||
{ 0x00, /* control byte for Tuner PLL */
|
||||
0x00,
|
||||
0x00,
|
||||
0x00 },
|
||||
{ 0x00, 0x00 }, /* band-switch crosspoints */
|
||||
{ 0x00, 0x00, 0x00,0x00} }, /* the band-switch values */
|
||||
|
||||
/* TEMIC_NTSC */
|
||||
{ "Temic NTSC", /* the 'name' */
|
||||
TTYPE_NTSC, /* input type */
|
||||
{ TSA552x_SCONTROL, /* control byte for Tuner PLL */
|
||||
TSA552x_SCONTROL,
|
||||
TSA552x_SCONTROL,
|
||||
0x00 },
|
||||
{ 0x00, 0x00}, /* band-switch crosspoints */
|
||||
{ 0x02, 0x04, 0x01, 0x00 } }, /* the band-switch values */
|
||||
|
||||
/* TEMIC_PAL */
|
||||
{ "Temic PAL", /* the 'name' */
|
||||
TTYPE_PAL, /* input type */
|
||||
{ TSA552x_SCONTROL, /* control byte for Tuner PLL */
|
||||
TSA552x_SCONTROL,
|
||||
TSA552x_SCONTROL,
|
||||
0x00 },
|
||||
{ 0x00, 0x00 }, /* band-switch crosspoints */
|
||||
{ 0x02, 0x04, 0x01, 0x00 } }, /* the band-switch values */
|
||||
|
||||
/* TEMIC_SECAM */
|
||||
{ "Temic SECAM", /* the 'name' */
|
||||
TTYPE_SECAM, /* input type */
|
||||
{ TSA552x_SCONTROL, /* control byte for Tuner PLL */
|
||||
TSA552x_SCONTROL,
|
||||
TSA552x_SCONTROL,
|
||||
0x00 },
|
||||
{ 0x00, 0x00 }, /* band-switch crosspoints */
|
||||
{ 0x02, 0x04, 0x01,0x00 } }, /* the band-switch values */
|
||||
|
||||
/* PHILIPS_NTSC */
|
||||
{ "Philips NTSC", /* the 'name' */
|
||||
TTYPE_NTSC, /* input type */
|
||||
{ TSA552x_SCONTROL, /* control byte for Tuner PLL */
|
||||
TSA552x_SCONTROL,
|
||||
TSA552x_SCONTROL,
|
||||
0x00 },
|
||||
{ 0x00, 0x00 }, /* band-switch crosspoints */
|
||||
{ 0xa0, 0x90, 0x30, 0x00 } }, /* the band-switch values */
|
||||
|
||||
/* PHILIPS_PAL */
|
||||
{ "Philips PAL", /* the 'name' */
|
||||
TTYPE_PAL, /* input type */
|
||||
{ TSA552x_SCONTROL, /* control byte for Tuner PLL */
|
||||
TSA552x_SCONTROL,
|
||||
TSA552x_SCONTROL,
|
||||
0x00 },
|
||||
{ 0x00, 0x00 }, /* band-switch crosspoints */
|
||||
{ 0xa0, 0x90, 0x30, 0x00 } }, /* the band-switch values */
|
||||
|
||||
/* PHILIPS_SECAM */
|
||||
{ "Philips SECAM", /* the 'name' */
|
||||
TTYPE_SECAM, /* input type */
|
||||
{ TSA552x_SCONTROL, /* control byte for Tuner PLL */
|
||||
TSA552x_SCONTROL,
|
||||
TSA552x_SCONTROL,
|
||||
0x00 },
|
||||
{ 0x00, 0x00 }, /* band-switch crosspoints */
|
||||
{ 0xa0, 0x90, 0x30, 0x00 } }, /* the band-switch values */
|
||||
|
||||
/* TEMIC_PAL I */
|
||||
{ "Temic PAL I", /* the 'name' */
|
||||
TTYPE_PAL, /* input type */
|
||||
{ TSA552x_SCONTROL, /* control byte for Tuner PLL */
|
||||
TSA552x_SCONTROL,
|
||||
TSA552x_SCONTROL,
|
||||
0x00 },
|
||||
{ 0x00, 0x00 }, /* band-switch crosspoints */
|
||||
{ 0x02, 0x04, 0x01,0x00 } }, /* the band-switch values */
|
||||
|
||||
/* PHILIPS_PALI */
|
||||
{ "Philips PAL I", /* the 'name' */
|
||||
TTYPE_PAL, /* input type */
|
||||
{ TSA552x_SCONTROL, /* control byte for Tuner PLL */
|
||||
TSA552x_SCONTROL,
|
||||
TSA552x_SCONTROL,
|
||||
0x00 },
|
||||
{ 0x00, 0x00 }, /* band-switch crosspoints */
|
||||
{ 0xa0, 0x90, 0x30,0x00 } }, /* the band-switch values */
|
||||
|
||||
/* PHILIPS_FR1236_NTSC */
|
||||
{ "Philips FR1236 NTSC FM", /* the 'name' */
|
||||
TTYPE_NTSC, /* input type */
|
||||
{ TSA552x_FCONTROL, /* control byte for Tuner PLL */
|
||||
TSA552x_FCONTROL,
|
||||
TSA552x_FCONTROL,
|
||||
TSA552x_RADIO },
|
||||
{ 0x00, 0x00 }, /* band-switch crosspoints */
|
||||
{ 0xa0, 0x90, 0x30,0xa4 } }, /* the band-switch values */
|
||||
|
||||
/* PHILIPS_FR1216_PAL */
|
||||
{ "Philips FR1216 PAL FM" , /* the 'name' */
|
||||
TTYPE_PAL, /* input type */
|
||||
{ TSA552x_FCONTROL, /* control byte for Tuner PLL */
|
||||
TSA552x_FCONTROL,
|
||||
TSA552x_FCONTROL,
|
||||
TSA552x_RADIO },
|
||||
{ 0x00, 0x00 }, /* band-switch crosspoints */
|
||||
{ 0xa0, 0x90, 0x30, 0xa4 } }, /* the band-switch values */
|
||||
|
||||
/* PHILIPS_FR1236_SECAM */
|
||||
{ "Philips FR1236 SECAM FM", /* the 'name' */
|
||||
TTYPE_SECAM, /* input type */
|
||||
{ TSA552x_FCONTROL, /* control byte for Tuner PLL */
|
||||
TSA552x_FCONTROL,
|
||||
TSA552x_FCONTROL,
|
||||
TSA552x_RADIO },
|
||||
{ 0x00, 0x00 }, /* band-switch crosspoints */
|
||||
{ 0xa0, 0x90, 0x30, 0xa4 } }, /* the band-switch values */
|
||||
|
||||
/* ALPS TSCH5 NTSC */
|
||||
{ "ALPS TSCH5 NTSC FM", /* the 'name' */
|
||||
TTYPE_NTSC, /* input type */
|
||||
{ TSCH5_FCONTROL, /* control byte for Tuner PLL */
|
||||
TSCH5_FCONTROL,
|
||||
TSCH5_FCONTROL,
|
||||
TSCH5_RADIO },
|
||||
{ 0x00, 0x00 }, /* band-switch crosspoints */
|
||||
{ 0x14, 0x12, 0x11, 0x04 } }, /* the band-switch values */
|
||||
|
||||
/* ALPS TSBH1 NTSC */
|
||||
{ "ALPS TSBH1 NTSC", /* the 'name' */
|
||||
TTYPE_NTSC, /* input type */
|
||||
{ TSBH1_FCONTROL, /* control byte for Tuner PLL */
|
||||
TSBH1_FCONTROL,
|
||||
TSBH1_FCONTROL,
|
||||
0x00 },
|
||||
{ 0x00, 0x00 }, /* band-switch crosspoints */
|
||||
{ 0x01, 0x02, 0x08, 0x00 } } /* the band-switch values */
|
||||
};
|
||||
|
||||
|
||||
/* scaling factor for frequencies expressed as ints */
|
||||
#define FREQFACTOR 16
|
||||
|
||||
/*
|
||||
* Format:
|
||||
* entry 0: MAX legal channel
|
||||
* entry 1: IF frequency
|
||||
* expressed as fi{mHz} * 16,
|
||||
* eg 45.75mHz == 45.75 * 16 = 732
|
||||
* entry 2: [place holder/future]
|
||||
* entry 3: base of channel record 0
|
||||
* entry 3 + (x*3): base of channel record 'x'
|
||||
* entry LAST: NULL channel entry marking end of records
|
||||
*
|
||||
* Record:
|
||||
* int 0: base channel
|
||||
* int 1: frequency of base channel,
|
||||
* expressed as fb{mHz} * 16,
|
||||
* int 2: offset frequency between channels,
|
||||
* expressed as fo{mHz} * 16,
|
||||
*/
|
||||
|
||||
/*
|
||||
* North American Broadcast Channels:
|
||||
*
|
||||
* 2: 55.25 mHz - 4: 67.25 mHz
|
||||
* 5: 77.25 mHz - 6: 83.25 mHz
|
||||
* 7: 175.25 mHz - 13: 211.25 mHz
|
||||
* 14: 471.25 mHz - 83: 885.25 mHz
|
||||
*
|
||||
* IF freq: 45.75 mHz
|
||||
*/
|
||||
#define OFFSET 6.00
|
||||
static int nabcst[] = {
|
||||
83, (int)( 45.75 * FREQFACTOR), 0,
|
||||
14, (int)(471.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
7, (int)(175.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
5, (int)( 77.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
2, (int)( 55.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
0
|
||||
};
|
||||
#undef OFFSET
|
||||
|
||||
/*
|
||||
* North American Cable Channels, IRC:
|
||||
*
|
||||
* 2: 55.25 mHz - 4: 67.25 mHz
|
||||
* 5: 77.25 mHz - 6: 83.25 mHz
|
||||
* 7: 175.25 mHz - 13: 211.25 mHz
|
||||
* 14: 121.25 mHz - 22: 169.25 mHz
|
||||
* 23: 217.25 mHz - 94: 643.25 mHz
|
||||
* 95: 91.25 mHz - 99: 115.25 mHz
|
||||
*
|
||||
* IF freq: 45.75 mHz
|
||||
*/
|
||||
#define OFFSET 6.00
|
||||
static int irccable[] = {
|
||||
99, (int)( 45.75 * FREQFACTOR), 0,
|
||||
95, (int)( 91.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
23, (int)(217.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
14, (int)(121.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
7, (int)(175.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
5, (int)( 77.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
2, (int)( 55.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
0
|
||||
};
|
||||
#undef OFFSET
|
||||
|
||||
/*
|
||||
* North American Cable Channels, HRC:
|
||||
*
|
||||
* 2: 54 mHz - 4: 66 mHz
|
||||
* 5: 78 mHz - 6: 84 mHz
|
||||
* 7: 174 mHz - 13: 210 mHz
|
||||
* 14: 120 mHz - 22: 168 mHz
|
||||
* 23: 216 mHz - 94: 642 mHz
|
||||
* 95: 90 mHz - 99: 114 mHz
|
||||
*
|
||||
* IF freq: 45.75 mHz
|
||||
*/
|
||||
#define OFFSET 6.00
|
||||
static int hrccable[] = {
|
||||
99, (int)( 45.75 * FREQFACTOR), 0,
|
||||
95, (int)( 90.00 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
23, (int)(216.00 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
14, (int)(120.00 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
7, (int)(174.00 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
5, (int)( 78.00 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
2, (int)( 54.00 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
0
|
||||
};
|
||||
#undef OFFSET
|
||||
|
||||
/*
|
||||
* Western European broadcast channels:
|
||||
*
|
||||
* (there are others that appear to vary between countries - rmt)
|
||||
*
|
||||
* here's the table Philips provides:
|
||||
* caution, some of the offsets don't compute...
|
||||
*
|
||||
* 1 4525 700 N21
|
||||
*
|
||||
* 2 4825 700 E2
|
||||
* 3 5525 700 E3
|
||||
* 4 6225 700 E4
|
||||
*
|
||||
* 5 17525 700 E5
|
||||
* 6 18225 700 E6
|
||||
* 7 18925 700 E7
|
||||
* 8 19625 700 E8
|
||||
* 9 20325 700 E9
|
||||
* 10 21025 700 E10
|
||||
* 11 21725 700 E11
|
||||
* 12 22425 700 E12
|
||||
*
|
||||
* 13 5375 700 ITA
|
||||
* 14 6225 700 ITB
|
||||
*
|
||||
* 15 8225 700 ITC
|
||||
*
|
||||
* 16 17525 700 ITD
|
||||
* 17 18325 700 ITE
|
||||
*
|
||||
* 18 19225 700 ITF
|
||||
* 19 20125 700 ITG
|
||||
* 20 21025 700 ITH
|
||||
*
|
||||
* 21 47125 800 E21
|
||||
* 22 47925 800 E22
|
||||
* 23 48725 800 E23
|
||||
* 24 49525 800 E24
|
||||
* 25 50325 800 E25
|
||||
* 26 51125 800 E26
|
||||
* 27 51925 800 E27
|
||||
* 28 52725 800 E28
|
||||
* 29 53525 800 E29
|
||||
* 30 54325 800 E30
|
||||
* 31 55125 800 E31
|
||||
* 32 55925 800 E32
|
||||
* 33 56725 800 E33
|
||||
* 34 57525 800 E34
|
||||
* 35 58325 800 E35
|
||||
* 36 59125 800 E36
|
||||
* 37 59925 800 E37
|
||||
* 38 60725 800 E38
|
||||
* 39 61525 800 E39
|
||||
* 40 62325 800 E40
|
||||
* 41 63125 800 E41
|
||||
* 42 63925 800 E42
|
||||
* 43 64725 800 E43
|
||||
* 44 65525 800 E44
|
||||
* 45 66325 800 E45
|
||||
* 46 67125 800 E46
|
||||
* 47 67925 800 E47
|
||||
* 48 68725 800 E48
|
||||
* 49 69525 800 E49
|
||||
* 50 70325 800 E50
|
||||
* 51 71125 800 E51
|
||||
* 52 71925 800 E52
|
||||
* 53 72725 800 E53
|
||||
* 54 73525 800 E54
|
||||
* 55 74325 800 E55
|
||||
* 56 75125 800 E56
|
||||
* 57 75925 800 E57
|
||||
* 58 76725 800 E58
|
||||
* 59 77525 800 E59
|
||||
* 60 78325 800 E60
|
||||
* 61 79125 800 E61
|
||||
* 62 79925 800 E62
|
||||
* 63 80725 800 E63
|
||||
* 64 81525 800 E64
|
||||
* 65 82325 800 E65
|
||||
* 66 83125 800 E66
|
||||
* 67 83925 800 E67
|
||||
* 68 84725 800 E68
|
||||
* 69 85525 800 E69
|
||||
*
|
||||
* 70 4575 800 IA
|
||||
* 71 5375 800 IB
|
||||
* 72 6175 800 IC
|
||||
*
|
||||
* 74 6925 700 S01
|
||||
* 75 7625 700 S02
|
||||
* 76 8325 700 S03
|
||||
*
|
||||
* 80 10525 700 S1
|
||||
* 81 11225 700 S2
|
||||
* 82 11925 700 S3
|
||||
* 83 12625 700 S4
|
||||
* 84 13325 700 S5
|
||||
* 85 14025 700 S6
|
||||
* 86 14725 700 S7
|
||||
* 87 15425 700 S8
|
||||
* 88 16125 700 S9
|
||||
* 89 16825 700 S10
|
||||
* 90 23125 700 S11
|
||||
* 91 23825 700 S12
|
||||
* 92 24525 700 S13
|
||||
* 93 25225 700 S14
|
||||
* 94 25925 700 S15
|
||||
* 95 26625 700 S16
|
||||
* 96 27325 700 S17
|
||||
* 97 28025 700 S18
|
||||
* 98 28725 700 S19
|
||||
* 99 29425 700 S20
|
||||
*
|
||||
*
|
||||
* Channels S21 - S41 are taken from
|
||||
* http://gemma.apple.com:80/dev/technotes/tn/tn1012.html
|
||||
*
|
||||
* 100 30325 800 S21
|
||||
* 101 31125 800 S22
|
||||
* 102 31925 800 S23
|
||||
* 103 32725 800 S24
|
||||
* 104 33525 800 S25
|
||||
* 105 34325 800 S26
|
||||
* 106 35125 800 S27
|
||||
* 107 35925 800 S28
|
||||
* 108 36725 800 S29
|
||||
* 109 37525 800 S30
|
||||
* 110 38325 800 S31
|
||||
* 111 39125 800 S32
|
||||
* 112 39925 800 S33
|
||||
* 113 40725 800 S34
|
||||
* 114 41525 800 S35
|
||||
* 115 42325 800 S36
|
||||
* 116 43125 800 S37
|
||||
* 117 43925 800 S38
|
||||
* 118 44725 800 S39
|
||||
* 119 45525 800 S40
|
||||
* 120 46325 800 S41
|
||||
*
|
||||
* 121 3890 000 IFFREQ
|
||||
*
|
||||
*/
|
||||
static int weurope[] = {
|
||||
121, (int)( 38.90 * FREQFACTOR), 0,
|
||||
100, (int)(303.25 * FREQFACTOR), (int)(8.00 * FREQFACTOR),
|
||||
90, (int)(231.25 * FREQFACTOR), (int)(7.00 * FREQFACTOR),
|
||||
80, (int)(105.25 * FREQFACTOR), (int)(7.00 * FREQFACTOR),
|
||||
74, (int)( 69.25 * FREQFACTOR), (int)(7.00 * FREQFACTOR),
|
||||
21, (int)(471.25 * FREQFACTOR), (int)(8.00 * FREQFACTOR),
|
||||
17, (int)(183.25 * FREQFACTOR), (int)(9.00 * FREQFACTOR),
|
||||
16, (int)(175.25 * FREQFACTOR), (int)(9.00 * FREQFACTOR),
|
||||
15, (int)(82.25 * FREQFACTOR), (int)(8.50 * FREQFACTOR),
|
||||
13, (int)(53.75 * FREQFACTOR), (int)(8.50 * FREQFACTOR),
|
||||
5, (int)(175.25 * FREQFACTOR), (int)(7.00 * FREQFACTOR),
|
||||
2, (int)(48.25 * FREQFACTOR), (int)(7.00 * FREQFACTOR),
|
||||
0
|
||||
};
|
||||
|
||||
/*
|
||||
* Japanese Broadcast Channels:
|
||||
*
|
||||
* 1: 91.25MHz - 3: 103.25MHz
|
||||
* 4: 171.25MHz - 7: 189.25MHz
|
||||
* 8: 193.25MHz - 12: 217.25MHz (VHF)
|
||||
* 13: 471.25MHz - 62: 765.25MHz (UHF)
|
||||
*
|
||||
* IF freq: 45.75 mHz
|
||||
* OR
|
||||
* IF freq: 58.75 mHz
|
||||
*/
|
||||
#define OFFSET 6.00
|
||||
#define IF_FREQ 45.75
|
||||
static int jpnbcst[] = {
|
||||
62, (int)(IF_FREQ * FREQFACTOR), 0,
|
||||
13, (int)(471.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
8, (int)(193.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
4, (int)(171.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
1, (int)( 91.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
0
|
||||
};
|
||||
#undef IF_FREQ
|
||||
#undef OFFSET
|
||||
|
||||
/*
|
||||
* Japanese Cable Channels:
|
||||
*
|
||||
* 1: 91.25MHz - 3: 103.25MHz
|
||||
* 4: 171.25MHz - 7: 189.25MHz
|
||||
* 8: 193.25MHz - 12: 217.25MHz
|
||||
* 13: 109.25MHz - 21: 157.25MHz
|
||||
* 22: 165.25MHz
|
||||
* 23: 223.25MHz - 63: 463.25MHz
|
||||
*
|
||||
* IF freq: 45.75 mHz
|
||||
*/
|
||||
#define OFFSET 6.00
|
||||
#define IF_FREQ 45.75
|
||||
static int jpncable[] = {
|
||||
63, (int)(IF_FREQ * FREQFACTOR), 0,
|
||||
23, (int)(223.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
22, (int)(165.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
13, (int)(109.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
8, (int)(193.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
4, (int)(171.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
1, (int)( 91.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
0
|
||||
};
|
||||
#undef IF_FREQ
|
||||
#undef OFFSET
|
||||
|
||||
/*
|
||||
* xUSSR Broadcast Channels:
|
||||
*
|
||||
* 1: 49.75MHz - 2: 59.25MHz
|
||||
* 3: 77.25MHz - 5: 93.25MHz
|
||||
* 6: 175.25MHz - 12: 223.25MHz
|
||||
* 13-20 - not exist
|
||||
* 21: 471.25MHz - 34: 575.25MHz
|
||||
* 35: 583.25MHz - 69: 855.25MHz
|
||||
*
|
||||
* Cable channels
|
||||
*
|
||||
* 70: 111.25MHz - 77: 167.25MHz
|
||||
* 78: 231.25MHz -107: 463.25MHz
|
||||
*
|
||||
* IF freq: 38.90 MHz
|
||||
*/
|
||||
#define IF_FREQ 38.90
|
||||
static int xussr[] = {
|
||||
107, (int)(IF_FREQ * FREQFACTOR), 0,
|
||||
78, (int)(231.25 * FREQFACTOR), (int)(8.00 * FREQFACTOR),
|
||||
70, (int)(111.25 * FREQFACTOR), (int)(8.00 * FREQFACTOR),
|
||||
35, (int)(583.25 * FREQFACTOR), (int)(8.00 * FREQFACTOR),
|
||||
21, (int)(471.25 * FREQFACTOR), (int)(8.00 * FREQFACTOR),
|
||||
6, (int)(175.25 * FREQFACTOR), (int)(8.00 * FREQFACTOR),
|
||||
3, (int)( 77.25 * FREQFACTOR), (int)(8.00 * FREQFACTOR),
|
||||
1, (int)( 49.75 * FREQFACTOR), (int)(9.50 * FREQFACTOR),
|
||||
0
|
||||
};
|
||||
#undef IF_FREQ
|
||||
|
||||
/*
|
||||
* Australian broadcast channels
|
||||
*/
|
||||
#define OFFSET 7.00
|
||||
static int australia[] = {
|
||||
83, (int)( 45.00 * FREQFACTOR), 0,
|
||||
28, (int)(520.00 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
14, (int)(471.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
11, (int)(214.50 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
10, (int)(201.50 * FREQFACTOR), (int)( 13.00 * FREQFACTOR),
|
||||
7, (int)(174.00 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
3, (int)( 85.00 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
2, (int)( 56.00 * FREQFACTOR), (int)(OFFSET * FREQFACTOR),
|
||||
0
|
||||
};
|
||||
#undef OFFSET
|
||||
|
||||
static struct {
|
||||
int *ptr;
|
||||
char name[BT848_MAX_CHNLSET_NAME_LEN];
|
||||
} freqTable[] = {
|
||||
{NULL, ""},
|
||||
{nabcst, "nabcst"},
|
||||
{irccable, "cableirc"},
|
||||
{hrccable, "cablehrc"},
|
||||
{weurope, "weurope"},
|
||||
{jpnbcst, "jpnbcst"},
|
||||
{jpncable, "jpncable"},
|
||||
{xussr, "xussr"},
|
||||
{australia, "australia"},
|
||||
|
||||
};
|
||||
|
||||
#define TBL_CHNL freqTable[ bktr->tuner.chnlset ].ptr[ x ]
|
||||
#define TBL_BASE_FREQ freqTable[ bktr->tuner.chnlset ].ptr[ x + 1 ]
|
||||
#define TBL_OFFSET freqTable[ bktr->tuner.chnlset ].ptr[ x + 2 ]
|
||||
static int
|
||||
frequency_lookup( bktr_ptr_t bktr, int channel )
|
||||
{
|
||||
int x;
|
||||
|
||||
/* check for "> MAX channel" */
|
||||
x = 0;
|
||||
if ( channel > TBL_CHNL )
|
||||
return( -1 );
|
||||
|
||||
/* search the table for data */
|
||||
for ( x = 3; TBL_CHNL; x += 3 ) {
|
||||
if ( channel >= TBL_CHNL ) {
|
||||
return( TBL_BASE_FREQ +
|
||||
((channel - TBL_CHNL) * TBL_OFFSET) );
|
||||
}
|
||||
}
|
||||
|
||||
/* not found, must be below the MIN channel */
|
||||
return( -1 );
|
||||
}
|
||||
#undef TBL_OFFSET
|
||||
#undef TBL_BASE_FREQ
|
||||
#undef TBL_CHNL
|
||||
|
||||
|
||||
#define TBL_IF freqTable[ bktr->tuner.chnlset ].ptr[ 1 ]
|
||||
|
||||
|
||||
/* Initialise the tuner structures in the bktr_softc */
|
||||
/* This is needed as the tuner details are no longer globally declared */
|
||||
|
||||
void select_tuner( bktr_ptr_t bktr, int tuner_type ) {
|
||||
if (tuner_type < Bt848_MAX_TUNER) {
|
||||
bktr->card.tuner = &tuners[ tuner_type ];
|
||||
} else {
|
||||
bktr->card.tuner = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tuner Notes:
|
||||
* Programming the tuner properly is quite complicated.
|
||||
* Here are some notes, based on a FM1246 data sheet for a PAL-I tuner.
|
||||
* The tuner (front end) covers 45.75 Mhz - 855.25 Mhz and an FM band of
|
||||
* 87.5 Mhz to 108.0 Mhz.
|
||||
*
|
||||
* RF and IF. RF = radio frequencies, it is the transmitted signal.
|
||||
* IF is the Intermediate Frequency (the offset from the base
|
||||
* signal where the video, color, audio and NICAM signals are.
|
||||
*
|
||||
* Eg, Picture at 38.9 Mhz, Colour at 34.47 MHz, sound at 32.9 MHz
|
||||
* NICAM at 32.348 Mhz.
|
||||
* Strangely enough, there is an IF (intermediate frequency) for
|
||||
* FM Radio which is 10.7 Mhz.
|
||||
*
|
||||
* The tuner also works in Bands. Philips bands are
|
||||
* FM radio band 87.50 to 108.00 MHz
|
||||
* Low band 45.75 to 170.00 MHz
|
||||
* Mid band 170.00 to 450.00 MHz
|
||||
* High band 450.00 to 855.25 MHz
|
||||
*
|
||||
*
|
||||
* Now we need to set the PLL on the tuner to the required freuqncy.
|
||||
* It has a programmable divisor.
|
||||
* For TV we want
|
||||
* N = 16 (freq RF(pc) + freq IF(pc)) pc is picture carrier and RF and IF
|
||||
* are in MHz.
|
||||
|
||||
* For RADIO we want a different equation.
|
||||
* freq IF is 10.70 MHz (so the data sheet tells me)
|
||||
* N = (freq RF + freq IF) / step size
|
||||
* The step size must be set to 50 khz (so the data sheet tells me)
|
||||
* (note this is 50 kHz, the other things are in MHz)
|
||||
* so we end up with N = 20x(freq RF + 10.7)
|
||||
*
|
||||
*/
|
||||
|
||||
#define LOW_BAND 0
|
||||
#define MID_BAND 1
|
||||
#define HIGH_BAND 2
|
||||
#define FM_RADIO_BAND 3
|
||||
|
||||
|
||||
/* Check if these are correct for other than Philips PAL */
|
||||
#define STATUSBIT_COLD 0x80
|
||||
#define STATUSBIT_LOCK 0x40
|
||||
#define STATUSBIT_TV 0x20
|
||||
#define STATUSBIT_STEREO 0x10 /* valid if FM (aka not TV) */
|
||||
#define STATUSBIT_ADC 0x07
|
||||
|
||||
/*
|
||||
* set the frequency of the tuner
|
||||
* If 'type' is TV_FREQUENCY, the frequency is freq MHz*16
|
||||
* If 'type' is FM_RADIO_FREQUENCY, the frequency is freq MHz * 100
|
||||
* (note *16 gives is 4 bits of fraction, eg steps of nnn.0625)
|
||||
*
|
||||
*/
|
||||
int
|
||||
tv_freq( bktr_ptr_t bktr, int frequency, int type )
|
||||
{
|
||||
const struct TUNER* tuner;
|
||||
u_char addr;
|
||||
u_char control;
|
||||
u_char band;
|
||||
int N;
|
||||
int band_select = 0;
|
||||
|
||||
tuner = bktr->card.tuner;
|
||||
if ( tuner == NULL )
|
||||
return( -1 );
|
||||
|
||||
if (type == TV_FREQUENCY) {
|
||||
/*
|
||||
* select the band based on frequency
|
||||
* XXX FIXME: get the cross-over points from the tuner struct
|
||||
*/
|
||||
if ( frequency < (160 * FREQFACTOR ) )
|
||||
band_select = LOW_BAND;
|
||||
else if ( frequency < (454 * FREQFACTOR ) )
|
||||
band_select = MID_BAND;
|
||||
else
|
||||
band_select = HIGH_BAND;
|
||||
|
||||
#if defined( TEST_TUNER_AFC )
|
||||
if ( bktr->tuner.afc )
|
||||
frequency -= 4;
|
||||
#endif
|
||||
/*
|
||||
* N = 16 * { fRF(pc) + fIF(pc) }
|
||||
* or N = 16* fRF(pc) + 16*fIF(pc) }
|
||||
* where:
|
||||
* pc is picture carrier, fRF & fIF are in MHz
|
||||
*
|
||||
* fortunatly, frequency is passed in as MHz * 16
|
||||
* and the TBL_IF frequency is also stored in MHz * 16
|
||||
*/
|
||||
N = frequency + TBL_IF;
|
||||
|
||||
/* set the address of the PLL */
|
||||
addr = bktr->card.tuner_pllAddr;
|
||||
control = tuner->pllControl[ band_select ];
|
||||
band = tuner->bandAddrs[ band_select ];
|
||||
|
||||
if(!(band && control)) /* Don't try to set un- */
|
||||
return(-1); /* supported modes. */
|
||||
|
||||
if ( frequency > bktr->tuner.frequency ) {
|
||||
i2cWrite( bktr, addr, (N>>8) & 0x7f, N & 0xff );
|
||||
i2cWrite( bktr, addr, control, band );
|
||||
}
|
||||
else {
|
||||
i2cWrite( bktr, addr, control, band );
|
||||
i2cWrite( bktr, addr, (N>>8) & 0x7f, N & 0xff );
|
||||
}
|
||||
|
||||
#if defined( TUNER_AFC )
|
||||
if ( bktr->tuner.afc == TRUE ) {
|
||||
if ( (N = do_afc( bktr, addr, N )) < 0 ) {
|
||||
/* AFC failed, restore requested frequency */
|
||||
N = frequency + TBL_IF;
|
||||
i2cWrite( bktr, addr, (N>>8) & 0x7f, N & 0xff );
|
||||
}
|
||||
else
|
||||
frequency = N - TBL_IF;
|
||||
}
|
||||
#endif /* TUNER_AFC */
|
||||
|
||||
bktr->tuner.frequency = frequency;
|
||||
}
|
||||
|
||||
if ( type == FM_RADIO_FREQUENCY ) {
|
||||
band_select = FM_RADIO_BAND;
|
||||
|
||||
/*
|
||||
* N = { fRF(pc) + fIF(pc) }/step_size
|
||||
* The step size is 50kHz for FM radio.
|
||||
* (eg after 102.35MHz comes 102.40 MHz)
|
||||
* fIF is 10.7 MHz (as detailed in the specs)
|
||||
*
|
||||
* frequency is passed in as MHz * 100
|
||||
*
|
||||
* So, we have N = (frequency/100 + 10.70) /(50/1000)
|
||||
*/
|
||||
N = (frequency + 1070)/5;
|
||||
|
||||
/* set the address of the PLL */
|
||||
addr = bktr->card.tuner_pllAddr;
|
||||
control = tuner->pllControl[ band_select ];
|
||||
band = tuner->bandAddrs[ band_select ];
|
||||
|
||||
if(!(band && control)) /* Don't try to set un- */
|
||||
return(-1); /* supported modes. */
|
||||
|
||||
/* band |= bktr->tuner.radio_mode;*/
|
||||
/* tuner.radio_mode is set in
|
||||
* the ioctls RADIO_SETMODE
|
||||
* and RADIO_GETMODE */
|
||||
|
||||
i2cWrite( bktr, addr, control, band );
|
||||
i2cWrite( bktr, addr, (N>>8) & 0x7f, N & 0xff );
|
||||
|
||||
bktr->tuner.frequency = (N * 5) - 1070;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if defined( TUNER_AFC )
|
||||
/*
|
||||
*
|
||||
*/
|
||||
int
|
||||
do_afc( bktr_ptr_t bktr, int addr, int frequency )
|
||||
{
|
||||
int step;
|
||||
int status;
|
||||
int origFrequency;
|
||||
|
||||
origFrequency = frequency;
|
||||
|
||||
/* wait for first setting to take effect */
|
||||
tsleep( BKTR_SLEEP, PZERO, "tuning", hz/8 );
|
||||
|
||||
if ( (status = i2cRead( bktr, addr + 1 )) < 0 )
|
||||
return( -1 );
|
||||
|
||||
#if defined( TEST_TUNER_AFC )
|
||||
printf( "\nOriginal freq: %d, status: 0x%02x\n", frequency, status );
|
||||
#endif
|
||||
for ( step = 0; step < AFC_MAX_STEP; ++step ) {
|
||||
if ( (status = i2cRead( bktr, addr + 1 )) < 0 )
|
||||
goto fubar;
|
||||
if ( !(status & 0x40) ) {
|
||||
#if defined( TEST_TUNER_AFC )
|
||||
printf( "no lock!\n" );
|
||||
#endif
|
||||
goto fubar;
|
||||
}
|
||||
|
||||
switch( status & AFC_BITS ) {
|
||||
case AFC_FREQ_CENTERED:
|
||||
#if defined( TEST_TUNER_AFC )
|
||||
printf( "Centered, freq: %d, status: 0x%02x\n", frequency, status );
|
||||
#endif
|
||||
return( frequency );
|
||||
|
||||
case AFC_FREQ_MINUS_125:
|
||||
case AFC_FREQ_MINUS_62:
|
||||
#if defined( TEST_TUNER_AFC )
|
||||
printf( "Low, freq: %d, status: 0x%02x\n", frequency, status );
|
||||
#endif
|
||||
--frequency;
|
||||
break;
|
||||
|
||||
case AFC_FREQ_PLUS_62:
|
||||
case AFC_FREQ_PLUS_125:
|
||||
#if defined( TEST_TUNER_AFC )
|
||||
printf( "Hi, freq: %d, status: 0x%02x\n", frequency, status );
|
||||
#endif
|
||||
++frequency;
|
||||
break;
|
||||
}
|
||||
|
||||
i2cWrite( bktr, addr,
|
||||
(frequency>>8) & 0x7f, frequency & 0xff );
|
||||
DELAY( AFC_DELAY );
|
||||
}
|
||||
|
||||
fubar:
|
||||
i2cWrite( bktr, addr,
|
||||
(origFrequency>>8) & 0x7f, origFrequency & 0xff );
|
||||
|
||||
return( -1 );
|
||||
}
|
||||
#endif /* TUNER_AFC */
|
||||
#undef TBL_IF
|
||||
|
||||
|
||||
/*
|
||||
* Get the Tuner status and signal strength
|
||||
*/
|
||||
int get_tuner_status( bktr_ptr_t bktr ) {
|
||||
return i2cRead( bktr, bktr->card.tuner_pllAddr + 1 );
|
||||
}
|
||||
|
||||
/*
|
||||
* set the channel of the tuner
|
||||
*/
|
||||
int
|
||||
tv_channel( bktr_ptr_t bktr, int channel )
|
||||
{
|
||||
int frequency;
|
||||
|
||||
/* calculate the frequency according to tuner type */
|
||||
if ( (frequency = frequency_lookup( bktr, channel )) < 0 )
|
||||
return( -1 );
|
||||
|
||||
/* set the new frequency */
|
||||
if ( tv_freq( bktr, frequency, TV_FREQUENCY ) < 0 )
|
||||
return( -1 );
|
||||
|
||||
/* OK to update records */
|
||||
return( (bktr->tuner.channel = channel) );
|
||||
}
|
||||
|
||||
/*
|
||||
* get channelset name
|
||||
*/
|
||||
int
|
||||
tuner_getchnlset(struct bktr_chnlset *chnlset)
|
||||
{
|
||||
if (( chnlset->index < CHNLSET_MIN ) ||
|
||||
( chnlset->index > CHNLSET_MAX ))
|
||||
return( EINVAL );
|
||||
|
||||
memcpy(&chnlset->name, &freqTable[chnlset->index].name,
|
||||
BT848_MAX_CHNLSET_NAME_LEN);
|
||||
|
||||
chnlset->max_channel=freqTable[chnlset->index].ptr[0];
|
||||
return( 0 );
|
||||
}
|
103
sys/dev/bktr/bktr_tuner.h
Normal file
103
sys/dev/bktr/bktr_tuner.h
Normal file
@ -0,0 +1,103 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*
|
||||
* This is part of the Driver for Video Capture Cards (Frame grabbers)
|
||||
* and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879
|
||||
* chipset.
|
||||
* Copyright Roger Hardiman and Amancio Hasty.
|
||||
*
|
||||
* bktr_tuner : This deals with controlling the tuner fitted to TV cards.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* 1. Redistributions of source code must retain the
|
||||
* Copyright (c) 1997 Amancio Hasty, 1999 Roger Hardiman
|
||||
* 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 and
|
||||
* Roger Hardiman
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Definitions for Tuners */
|
||||
|
||||
#define NO_TUNER 0
|
||||
#define TEMIC_NTSC 1
|
||||
#define TEMIC_PAL 2
|
||||
#define TEMIC_SECAM 3
|
||||
#define PHILIPS_NTSC 4
|
||||
#define PHILIPS_PAL 5
|
||||
#define PHILIPS_SECAM 6
|
||||
#define TEMIC_PALI 7
|
||||
#define PHILIPS_PALI 8
|
||||
#define PHILIPS_FR1236_NTSC 9 /* These have FM radio support */
|
||||
#define PHILIPS_FR1216_PAL 10 /* These have FM radio support */
|
||||
#define PHILIPS_FR1236_SECAM 11 /* These have FM radio support */
|
||||
#define ALPS_TSCH5 12
|
||||
#define ALPS_TSBH1 13
|
||||
#define Bt848_MAX_TUNER 14
|
||||
|
||||
/* experimental code for Automatic Frequency Control */
|
||||
#define TUNER_AFC
|
||||
|
||||
/*
|
||||
* Fill in the tuner entries in the bktr_softc based on the selected tuner
|
||||
* type (from the list of tuners above)
|
||||
*/
|
||||
void select_tuner( bktr_ptr_t bktr, int tuner_type );
|
||||
|
||||
|
||||
/*
|
||||
* The Channel Set maps TV channels eg Ch 36, Ch 51, onto frequencies
|
||||
* and is country specific.
|
||||
*/
|
||||
int tuner_getchnlset( struct bktr_chnlset *chnlset );
|
||||
|
||||
/*
|
||||
* tv_channel sets the tuner to channel 'n' using the current Channel Set
|
||||
* tv_freq sets the tuner to a specific frequency for TV or for FM Radio
|
||||
* get_tuner_status can be used to get the signal strength.
|
||||
*/
|
||||
#define TV_FREQUENCY 0
|
||||
#define FM_RADIO_FREQUENCY 1
|
||||
int tv_channel( bktr_ptr_t bktr, int channel );
|
||||
int tv_freq( bktr_ptr_t bktr, int frequency, int type );
|
||||
int get_tuner_status( bktr_ptr_t bktr );
|
||||
|
||||
#if defined( TUNER_AFC )
|
||||
int do_afc( bktr_ptr_t bktr, int addr, int frequency );
|
||||
#endif /* TUNER_AFC */
|
||||
|
||||
|
||||
/*
|
||||
* This is for start-up convenience only, NOT mandatory.
|
||||
*/
|
||||
#if !defined( DEFAULT_CHNLSET )
|
||||
#define DEFAULT_CHNLSET CHNLSET_WEUROPE
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user