aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2010-04-01 11:24:35 +0200
committerGerd Hoffmann <kraxel@redhat.com>2010-04-01 11:24:35 +0200
commitfc44df6ca9cad3b3e154f38c3a43397afacbc82b (patch)
tree99127cbf018a1c3e0c39b283ffc0934cf548323f
parente258bb27135e755ea57c6d1e83e298d640913fc1 (diff)
v3.07
-rw-r--r--Changes589
-rw-r--r--KNOWN_PROBLEMS12
-rw-r--r--MAKEDEV.v4l (renamed from bttv/driver/MAKEDEV)8
-rw-r--r--Makefile.in159
-rw-r--r--Makefile.kradio64
-rw-r--r--Miro_gpio.txt8
-rw-r--r--Programming-FAQ109
-rw-r--r--README235
-rw-r--r--README.bttv173
-rw-r--r--README.de13
-rw-r--r--README.lirc22
-rw-r--r--Sound-FAQ90
-rw-r--r--TODO20
-rw-r--r--Trouble-Shooting101
-rw-r--r--UPDATE_TO_v3.033
-rw-r--r--Xawtv.ad186
-rw-r--r--acconfig.h6
-rw-r--r--bttv/doc/ICs37
-rw-r--r--bttv/doc/PROBLEMS62
-rw-r--r--bttv/doc/README.Hauppauge29
-rw-r--r--bttv/doc/README.MIRO3
-rw-r--r--bttv/doc/README.PCI36
-rw-r--r--bttv/doc/README.RADIO15
-rw-r--r--bttv/driver/MODULES61
-rw-r--r--bttv/driver/Makefile58
-rw-r--r--bttv/driver/bt848.h348
-rw-r--r--bttv/driver/bttv.c3300
-rw-r--r--bttv/driver/bttv.h211
-rw-r--r--bttv/driver/i2c.c433
-rw-r--r--bttv/driver/i2c.h173
-rw-r--r--bttv/driver/i2c_chardev.c309
-rw-r--r--bttv/driver/msp3400.c1129
-rw-r--r--bttv/driver/msp3400.h23
-rw-r--r--bttv/driver/tuner.c271
-rw-r--r--bttv/driver/tuner.h49
-rw-r--r--bttv/driver/update43
-rw-r--r--bttv/driver/videodev.c375
-rw-r--r--bttv/driver/videodev.h214
-rw-r--r--bttv/experimental/Makefile61
-rw-r--r--bttv/experimental/README12
-rw-r--r--bttv/experimental/algo-bit.c893
-rw-r--r--bttv/experimental/algo-bit.h38
-rw-r--r--bttv/experimental/bt848.h348
-rw-r--r--bttv/experimental/bttv.c3261
-rw-r--r--bttv/experimental/bttv.h212
-rw-r--r--bttv/experimental/i2c.c385
-rw-r--r--bttv/experimental/i2c.h246
-rw-r--r--bttv/experimental/tuner.c270
-rw-r--r--bttv/experimental/tuner.h49
-rw-r--r--bttv/experimental/update40
-rw-r--r--bttv/experimental/videodev.c375
-rw-r--r--build-test58
-rw-r--r--capture-test65
-rw-r--r--channel.c466
-rw-r--r--channel.h52
-rw-r--r--config.h.in12
-rwxr-xr-xconfigure673
-rw-r--r--configure.in98
-rw-r--r--contrib/frequencies-europe133
-rw-r--r--contrib/frequencies-japan72
-rw-r--r--contrib/hauppauge-eeprom147
-rw-r--r--contrib/mash/README33
-rw-r--r--fbtv.c659
-rw-r--r--font/Makefile38
-rw-r--r--font/Makefile.in57
-rw-r--r--font/fonts.dir4
-rw-r--r--font/led-koi8.bdf7904
-rw-r--r--font/led-latin1.bdf (renamed from font/led-fixed.bdf)0
-rw-r--r--font/led-latin2.bdf6948
-rw-r--r--grab-one.c301
-rw-r--r--grab-v4l.c659
-rw-r--r--grab.h48
-rw-r--r--grabber-bttv-0.5.6.cc356
-rw-r--r--grabber-video4linux.cc496
-rw-r--r--i2c/Makefile17
-rw-r--r--i2c/Makefile.in17
-rw-r--r--i2c/detect.c76
-rw-r--r--i2c/eeprom.c280
-rw-r--r--i2c/ir.c227
-rw-r--r--i2c/scan.c79
-rw-r--r--kradio.cpp433
-rw-r--r--kradio.h82
-rw-r--r--kradio.kdelnk13
-rw-r--r--kradio.lsm17
-rw-r--r--main.c1725
-rw-r--r--man/Makefile.in27
-rw-r--r--man/fbtv.man143
-rw-r--r--man/v4l-conf.man87
-rw-r--r--man/v4lctl.man1
-rw-r--r--man/xawtv-remote.man119
-rw-r--r--man/xawtv.man285
-rw-r--r--mixer.c108
-rw-r--r--oldstuff/kraxel-tvee.h (renamed from kraxel-tvee.h)0
-rw-r--r--oldstuff/set-tv.c (renamed from set-tv.c)69
-rw-r--r--oldstuff/set-tv.man25
-rw-r--r--oldstuff/streamer-old.c702
-rw-r--r--radio.c56
-rw-r--r--radio/Makefile.in38
-rw-r--r--radio/radio-old.c223
-rw-r--r--radio/radio.c339
-rw-r--r--radio/radio.man61
-rw-r--r--speaker_off.xpm27
-rw-r--r--speaker_on.xpm27
-rw-r--r--src/Makefile.in84
-rw-r--r--src/Xawtv.ad456
-rw-r--r--src/byteorder.h12
-rw-r--r--src/capture.c318
-rw-r--r--src/capture.h14
-rw-r--r--src/channel.c595
-rw-r--r--src/channel.c.orig567
-rw-r--r--src/channel.h78
-rw-r--r--src/colorspace.c443
-rw-r--r--src/colorspace.c.rej29
-rw-r--r--src/colorspace.h43
-rw-r--r--src/commands.c938
-rw-r--r--src/commands.h45
-rw-r--r--src/complete.c261
-rw-r--r--src/complete.h2
-rw-r--r--src/conf.c324
-rw-r--r--src/fbtools.c569
-rw-r--r--src/fbtools.h25
-rw-r--r--src/fbtv.c698
-rw-r--r--src/fix19
-rw-r--r--src/frequencies.c867
-rw-r--r--src/frequencies.h (renamed from channels.h)43
-rw-r--r--src/grab-v4l.c998
-rw-r--r--src/grab-v4l2.c923
-rw-r--r--src/grab.c409
-rw-r--r--src/grab.h92
-rw-r--r--src/lirc.c68
-rw-r--r--src/lirc.h2
-rw-r--r--src/log11
-rw-r--r--src/main.c2585
-rw-r--r--src/matrox.c227
-rw-r--r--src/matrox.h4
-rw-r--r--src/mjpeg.c245
-rw-r--r--src/mjpeg.h7
-rw-r--r--src/parseconfig.c198
-rw-r--r--src/parseconfig.h6
-rw-r--r--src/sound.c211
-rw-r--r--src/sound.h (renamed from mixer.h)7
-rw-r--r--src/streamer.c485
-rw-r--r--src/streamerdiff134
-rw-r--r--src/toolbox.c (renamed from toolbox.c)108
-rw-r--r--src/toolbox.h (renamed from toolbox.h)2
-rw-r--r--src/v4l-conf.c484
-rw-r--r--src/v4lctl.c82
-rw-r--r--src/wmhooks.c98
-rw-r--r--src/wmhooks.h2
-rw-r--r--src/writeavi.c412
-rw-r--r--src/writeavi.h31
-rw-r--r--src/writefile.c146
-rw-r--r--src/writefile.h5
-rw-r--r--src/x11.c (renamed from x11.c)401
-rw-r--r--src/x11.h31
-rw-r--r--src/xawtv-remote.c184
-rw-r--r--src/xscreensaver.c454
-rw-r--r--src/xscreensaver.h24
-rw-r--r--src/xv.c444
-rw-r--r--src/xv.h10
-rw-r--r--src/xvideo.c318
-rw-r--r--tools/Makefile.in55
-rw-r--r--tools/README36
-rw-r--r--tools/dump-mixers.c (renamed from dump-mixers.c)15
-rw-r--r--tools/propwatch.c500
-rw-r--r--tools/propwatch.man34
-rw-r--r--tools/record.c553
-rw-r--r--tools/showriff.c317
-rw-r--r--v4l-conf.c210
-rw-r--r--videodev.h (renamed from bttv/experimental/videodev.h)93
-rw-r--r--videodev2.h1154
-rw-r--r--vtx/Makefile14
-rw-r--r--vtx/README28
-rw-r--r--vtx/cct.h38
-rw-r--r--vtx/fileio.c163
-rw-r--r--vtx/fileio.h47
-rw-r--r--vtx/main.c160
-rw-r--r--vtx/misc.h41
-rw-r--r--vtx/sys/vtx.h151
-rw-r--r--vtx/vtx.cgi146
-rw-r--r--vtx/vtx.sh64
-rw-r--r--vtx/vtx_assert.h46
-rw-r--r--vtx/vtxdecode.c209
-rw-r--r--vtx/vtxdecode.h45
-rw-r--r--vtx/vtxtools.c140
-rw-r--r--vtx/vtxtools.h23
-rw-r--r--webcam/Makefile21
-rw-r--r--webcam/Makefile.in20
-rw-r--r--webcam/font_6x11.h3337
-rw-r--r--webcam/font_8x8.h2569
-rw-r--r--webcam/webcam.c525
-rw-r--r--webcam/webcam.cgi66
-rw-r--r--x11.h20
-rw-r--r--xawtv.kdelnk13
-rw-r--r--xawtv.man216
-rw-r--r--xawtv.spec95
-rw-r--r--xawtv.spec.in95
197 files changed, 46736 insertions, 20580 deletions
diff --git a/Changes b/Changes
index 9a33cef..669fe30 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,592 @@
+
+3.06 => 3.07
+============
+
+ * As usual, some bugfixes
+ * values for volume, contrast, color, ... can be specified in
+ percent too, just add '%' to the number: 50% == 32768
+ * more led fonts (latin2, koi8). Right now you have to set the
+ app-defaults by hand to make use of them, need some more elegant
+ way to switch charsets...
+ * Added the UHF frequencies to europe-cable. It's used at least in
+ Switzerland for cable TV.
+ * some changes in yuv-to-offscreen handling for fbtv due to bttv
+ changes.
+
+
+3.05 => 3.06
+============
+
+ * Aiee, there was a stale .nfs<longnumber> file in the 3.05 archive...
+
+
+3.04 => 3.05
+============
+
+ * new config options: turn on/off onscreen display, keypad mode,
+ mjpeg quality. Check the man page for details.
+ * Added XvPutImage support for grabdisplay mode. You'll need
+ XFree86 3.9.17 to compile this release with Xv support.
+ * rearranged the european frequency tables. They are splitted into
+ broadcast and cable tv now.
+
+
+3.03 => 3.04
+============
+
+ * fbtv font loader fixed. Nice showstopper, I should start the app at
+ least once next time...
+ * fbtv: ATI Mach64 backend scaler support works now with my revB iMac.
+
+Note: I still have some changes/minor bug reports in my incoming mailbox.
+Next release. I want to get this one out of the door quickly due to the
+fbtv problems.
+
+
+3.02 => 3.03
+============
+
+ * broke fbtv font loading.
+ * forgot writing Changes entries.
+
+
+3.01 => 3.02
+============
+
+ * some finetuning for the keypad stuff.
+ * G200 backend scaler support in fbtv.
+
+
+3.0 => 3.01
+===========
+
+ * Frequency table renaming was incomplete. The menu was'nt
+ updated.
+ * v4l-conf did'nt compile with 2.0.x kernel headers.
+ * -c switch (select device) was broken.
+ * added hard coded width limit for capture (buggy kernel bttv :-( )
+
+
+3.0rc1 => 3.0
+=============
+
+ * Added station selection by "two-digit" selection. All stations
+ are numbered in .xawtv order; entering two numbers within 5
+ seconds are interpreted as station number which should be tuned.
+ You'll have to use the keypad in xawtv. Should work with lirc too
+ (using the new "keypad" command).
+ * global spellfix s/lauch/launch/. Attention, this might affect
+ your config file too...
+ * channel editor fixes.
+ * F5-F12 (bright/color/... adjust by keyboard) is back.
+
+
+3.0beta9 => 3.0rc1
+==================
+
+ * updated v4l2 driver to the new interface.
+ * some finetuning in the v4l2 driver.
+ * cleaned up v4l-conf.c
+ * renamed the frequency tables: removed the TV norm from the name
+ to avoid confusion.
+ * the usual set of bugfixes.
+
+
+3.0beta8 => 3.0beta9
+====================
+
+ * webcam: can set input/norm now.
+ * webcam: new cgi script for continously updated image (netscape
+ only, uses serverpush).
+ * the usual set of bugfixes.
+ * write list index for avi files, mjpeg support (with some code
+ from Michael Nastvogel <michael.nastvogel-woerz@ipf.de>)
+ mjpeg is still buggy...
+ * added new frequency table for france (LOUIS-SIDNEY Rodolphe
+ <sidney@gcu-geot.insa-lyon.fr>)
+
+
+3.0beta7 => 3.0beta8
+====================
+
+ * add a new switch (-a) to v4l-conf for setting the base address.
+ This should make bttv configuration more easy if the X-Server
+ lacks DGA support.
+ * fixed the Makefiles for building in a subdirectory (i.e handle
+ "mkdir build; cd build; ../configure && make" correctly). Now
+ I can switch from ppc to i386 without "make distclean" :-)
+ * Plenty of fixes for the channel editor. Seems nobody uses it,
+ it must have been broken for weeks...
+ * fbtv+xawtv refuse to work when installed suid root now. This is
+ /not/ needed, only v4l-conf requires root priviliges.
+ * v4l2: added tuner support, minor fixes.
+ * added channel 36 for australia, this one was missing for some
+ reason...
+
+
+3.0beta6 => 3.0beta7
+====================
+
+ * Added autoscroll for the station menu. Xaw3d has some redraw
+ problems with this. Probably some library bug, it does not
+ happen with Xaw. Workaround idea anyone?
+ * Misc bugfixes.
+ * Documentation updates. To be continued...
+
+
+3.0beta5 => 3.0beta6
+====================
+
+ * minor appdefauls fixes (wheel-mouse was broken).
+ * config file parser rewritten. config file format is slightly
+ modified, check the xawtv man page.
+ * unbundled kradio to avoid the KDE compile hassle.
+ * fullscreen fixes.
+ * xawtv-remote supports multiple xawtv instances (querys all
+ xawtv windows, not just the first one it finds, new switch
+ '-i' to set the window ID when passing commands to xawtv).
+
+
+3.0beta4 => 3.0beta5
+====================
+
+ * Added support for qcams (capture via read() system call)
+ * yuv capture support (???, I've already deleted this mail)
+ * radio fixes (from debian bugtraq)
+
+
+3.0beta3 => 3.0beta4
+====================
+
+ * merged some new code for radio from Juli Merino <jmmv@bigfoot.com>
+ * wrote a man-page for radio
+ * added v4l-conf security fixes from Olaf Kirch <okir@lst.de>
+ * lirc bugfix.
+ * xawtv can use another than the default visual now. Not bugfree yet.
+
+
+3.0beta2 => 3.0beta3
+====================
+
+ * started updating the documentation.
+ * reorganized source code tree.
+ * removed the hardcoded maxsizes from grab-v4l.c
+ * rewrote the attribute (color/hue/... + audio) handling
+
+
+3.0beta1 => 3.0beta2
+====================
+
+ * ditched getopt(), using the Xt lib / X11 resources instead. This
+ has the effect that the options work a bit different now.
+ * added v4lctl utility. This allows to control alot v4l options from
+ the command line. Obsoletes set-tv.
+ * set-tv.c and streamer-old.c moved into the new "oldstuff" directory.
+ * alot of xawtv fixes -- more features are working again.
+ * fbtv is updated too. It should accept lirc commands now exactly like
+ xawtv.
+
+
+2.45 => 3.0beta1
+================
+
+ * Lot of internal changes. Separate the control code from the GUI.
+ Simplifies the the xawtv-remote and lirc support, makes xawtv and
+ fbtv share more code. Lot of stuff is broken currently...
+
+
+2.44 => 2.45
+============
+
+ * Added a 'back' key which switches back to the last station tuned in.
+ Mapped to BackSpace. Pressing backspace multiple times zaps
+ between the last two stations.
+ * The applications configured with "lauch=..." in ~/.xawtv are listed
+ in a window now ('L' displays it). Allocation bug in the config file
+ parser fixed.
+ * switched back from double to float for X-Resources.
+
+
+2.43 => 2.44
+============
+
+ * fbtv: added -q switch. This turns of status messages + clock, and
+ fbtv does'nt reserve space for the status line (i.e. you'll can get
+ true full screen)
+ * started lirc support (currently some debug code only...)
+ * changed float to double for X resources (Xaw scrollbars). This
+ fixes problems on alpha and seems to work fine on intel. Hope I
+ did'nt broke ppc...
+ * fixed the radio programs (mute on exit). Untested.
+ * webcam bugfix (switching to binary mode must be done _after_connecting).
+
+
+2.42 => 2.43
+============
+
+ * Xvideo updates
+ * some bttv changes to make it more compatible to the kernel
+ version, added patches from Greg Alexander <galexand@acm.org>.
+ * removed the "unmute-on-open", Updated the open/close for
+ radio too. bttv radio should behave like all other radio
+ drivers do (i.e. you have to open the device only if you
+ want to change some settings).
+ * Unbundled the bttv driver, my bttv code is available as
+ another tar file at the same location (bttv-0.6.3a currently).
+ * Errors (at least some :-) are reported with a dialog box now,
+ not only to stderr.
+ * channel handling is completely rewritten. If you change the frequency
+ table, all frequencies for the programmed stations are recalculated
+ now.
+ * added some missing channels for japan.
+ * streamer: the -i and -n switches work again.
+ * xawtv dumped core with nonaudio devices, fixed (Pauline Middelink
+ <middelin@polyware.nl>)
+ * updated videodev2.h
+
+
+2.41 => 2.42
+============
+
+ * DON'T PANIC
+
+
+2.40 => 2.41
+============
+
+ * completed avi recording code in xawtv.
+ * renamed streamer to streamer-old and streamer-new to streamer.
+ i.e. ther new streamer tool is the default now.
+ * internal changes (for scanline length != image width)
+ * added grabdisplay mode to fbtv.
+ * Added some SR* channels to frequency table "pal-europe-east" (they
+ are used in Poland). Hmm, maybe I should reorganize the whole
+ channel setup, it starts getting difficuilt to maintain this the way
+ it is implemented currently...
+ * Alpha cleanups (use long for pointers etc.) from
+ Ralf Uhlig <ralf@uhlig-online.de>
+ * mklinux support for v4l-conf (Takashi Oe)
+ * the "-x" option is gone, there are two new ones instead: "--nodga"
+ to disable DGA and "--novm" to disable VidMode.
+ * Added the capability to lauch programs from within xawtv.
+ * removed the "mute-on-close" from the bttv driver.
+
+
+2.39 => 2.40
+============
+
+ * Endian fixes from Takashi Oe (avi recording works now on big
+ endian boxes).
+ * xawtv can record avi movies directly. ^S brings you to this
+ dialog. Please don't complain that you are missing options, this
+ is on my TODO list. Everything you can set for streamer with
+ command line options will be available in xawtv too. That stuff
+ is work-in-progress, take the code as beta quality...
+ * Bug fixes and internal changes.
+ * security fixes from marc@suse.de: v4l-conf.c verifies the v4l major,
+ /tmp symlink fix for vtx.sh.
+ * msp3400 bug fixes, short programming (insmod option "simple=1")
+ should work now. With newer msp34xx chip versions you'll should
+ get stereo for NTSC TV and FM Radio.
+ * more Xvideo code.
+
+
+2.38 => 2.39
+============
+
+ * added --shift option to xawtv, this can be used to shift the
+ image if it is outside the xawtv window.
+ * added time display to fbtv.
+ * stay-on-top added (works with gnome-compilant WM's)
+ * patches from Takashi Oe for devices without audio/tuner support.
+ * Found a new cool rpm feature (this one is new, eh?):
+ "rpm -ta package.tar.gz" will build nice rpm. No extra spec
+ file needed any more :-)
+ * Started Xvideo support.
+ * A few internal changes.
+
+
+2.37 => 2.38
+============
+
+ * snapshot filename handling has changed: Files are saved with a
+ timestamp (YYYYMMDD-HHMMSS) and channel in the filename.
+ * xawtv is ^^^^ y2k compilant :-)
+ * new config file entry: "jpeg-quality"
+ * webcam utility updated. It's now working with the v4l2 winnov videum
+ driver at http://www.BerlinOnline.de/spass/live_kamera/
+ * good news for *.fr: more msp3400 fixes, NICAM/AM should finally
+ work now.
+
+
+2.36 => 2.37
+============
+
+ * fixed minor compile problems on 2.0.x.
+
+
+2.35 => 2.36
+============
+
+ * documentation updates, new FAQ for sound trouble.
+ * streamer fixes (the endian fixes for 2.33 broke streamer)
+ * driver synced up with bttv 0.6.3
+ * misc minor bug fixes
+
+
+2.34 => 2.35
+============
+
+ * updated bttv to 0.6.2 and fixed the 2.0.x compile problems.
+ * msp3400 problems with 2.2.0pre7+ fixed.
+
+
+2.33 => 2.34
+============
+
+ * new NTSC-HRC frequency table, contributed by
+ Erik Kiledal <ekiledal@home.com>
+ * 15 bpp was broken _again_. Fixed.
+ * driver: msp3400 updates. Tried to make nicam mono/stereo switching
+ work, but no success so far...
+ * bttv updated to 0.6.1
+ * DPMS support (turn it off for fullscreen TV), contributed by
+ Martin Denn <mdenn@schachtel.mz.rhein-main.de>
+
+
+2.32 => 2.33
+============
+
+ * more patches from Takashi Oe (endian fixes, make fbtv work with
+ DirectColor visual)
+ * slighly modified audio handling (mono/stereo/bilangual, the driver
+ returns the valid choices instead of the current state now). This
+ affects both xawtv and driver and is _not_ backward compatible.
+ * various minor changes.
+ * new shell script for browsing videotext pages. requires a
+ terminal with > 24 lines.
+
+
+2.31 => 2.32
+============
+
+ * bugfix: changed bytesex.h to edian.h in x11.c
+ * bugfix: overlay did'nt work without DGA.
+
+
+2.30 => 2.31
+============
+
+ * more cleanups, the minor overlay flaws should be fixed.
+ * coded up v4l2 overlay support -- completely untested.
+ * minor fbtv fixes.
+ * started to shuffle around some code from streamer. The
+ new version has another name (streamer-new) for now. It
+ can already handle v4l2, but can't be started from the
+ xawtv's frontend dialog box.
+ * remote display fixes (should work now if server and client
+ have different bytesex).
+ * Long options (thanks to Takashi Oe <toe@unlinfo.unl.edu>).
+ * "xawtv --help" prints all options.
+
+
+2.29 => 2.30
+============
+
+ * much improved v4l2 support, it should be useable now. Only
+ grabdisplay is supported so far, overlay-only drivers will not
+ work (yet).
+ * Some internal cleanups/rewrites, removed some hardcoded bttv
+ stuff. Probably introduced a few new bugs...
+ * pinned down the "segfault-on-exit" bug, credits to Electric Fence.
+ * added the "webcam" tool (does capture, annotate, jpeg-compress,
+ ftp-upload)
+ * added showriff, for those who want to look into *.wav and *.avi
+ files.
+ * bttv: msp3400 + tuner compile problems due to 2.1.127 changes
+ fixed.
+
+
+2.28 => 2.29
+============
+
+ * rpm spec file fixes
+ * minor msp3400 changes (for miro)
+ * automatically generated diff's against Ralph's bttv version.
+ * fixed the broken channel list length define (that
+ only-79-ntsc-channels bug)
+ * If there is a configuration problem, xawtv will disable overlay
+ and continue instead of exiting.
+ * remote display works. Don't try this unless you have a _real_
+ fast network or your own home network. Otherwise the network
+ admin will ask what you are doing within five minutes...
+ * started frontend dialog for streamer (Ctrl-S). Does already work,
+ but needs some more options to be really useful.
+ * started v4l2 support.
+
+
+2.27 => 2.28
+============
+
+ * The 'V' key toggles capture on/off now. If capture is switched
+ off, xawtv shows a static image.
+ * Added options to set TV norm and input to streamer. Webcam
+ cronjobs don't need set-tv any more :-)
+ * Picked up some patches from video4linux@phunk.org for the bttv
+ driver. The Miro PCTV pro might work in stereo, SECAM should work
+ again.
+ * Added autodetect for the Miro pro (untested).
+
+ * RPMified xawtv, thx to Mark Cooke <mpc@star.sr.bham.ac.uk> for the
+ initial spec file.
+ No, I'm not going to upload RPM's, neither source nor binaries.
+ I'll upload the spec file, so you can easily build your own RPM's.
+
+ * removed the experimental driver from the package, it will be
+ available separate.
+ * precompiled binaries are no longer included.
+
+
+2.26 => 2.27
+============
+
+ * fixed the msp34xx problem with new (bt878) Hauppauge boards.
+
+
+2.25 => 2.26
+============
+
+ * more driver PLL fixes
+ * added Hauppauge tuner autodetect (using eeprom)
+ * xawtv saves picture settings in channel switch now.
+
+
+2.24 => 2.25
+============
+
+ * Moved E2-E4 to E1-E3 by mistake in 2.22. Reverted this.
+ * radio is a nice curses application now.
+ * The driver should work again for PAL.
+
+
+2.23 => 2.24
+============
+
+ * v4l-conf changes
+ * bugfixes in config file parser and channel editor.
+
+
+2.22 => 2.23
+============
+
+ * bugfix: SExx channels did not work.
+ (thanks to Michael Vogt <M.Vogt@ping.de>)
+ * documentation updates.
+ * increased the AUDIO_MUTE_DELAY value in bttv.c, this should
+ reduce the channel-switch noise.
+ * bttv: added changes from patch-2.1.120
+
+
+2.21 => 2.22
+============
+
+ * up to date with bttv 0.5.15
+ * fbtv fixes and improvements (console switching works again)
+ * streamer has a new switch to enable audio recording (off by
+ default).
+ * Channels renamed again: S1 .. S20 is SE1 .. SE20 now. This
+ should be correct now. Reordered them (sorted by frequency
+ now).
+ * Channels map for east europe (PAL D/K) added.
+ * channel editor bugfixes
+
+
+2.20 => 2.21
+============
+
+ * Updated driver to 0.5.14, this one is NOT backward compatible older
+ versions.
+ * Updated Simon's i2c code.
+ * Updated the programs too.
+ * added avi recording to streamer.
+
+
+2.19 => 2.20
+============
+
+ * Makefile fixes
+ * Matrox off-by-1024 workaround improved.
+ * fbtv fixes, moved generic fb stuff to a separate file.
+ * grab-one is gone, there is streamer now. This one can
+ do streaming capture (and of cource still grab single
+ frames as special case). JPEG support added.
+
+2.18 => 2.19
+============
+
+ * added man-pages for set-tv and fbtv
+ * zapped SuSE and installed RH51, the included precompiled binaries
+ are glibc now.
+ * Unlocked the channel editor (overwrites the old config file now),
+ it is in the man-page now and has the hotkey 'E'. Be carefull, it
+ will kill all comments in the config file!
+
+
+2.17 => 2.18
+============
+
+ * added xawtv-remote ("remote control" for xawtv)
+ * hopefully completed channel list editor. But still in debugging
+ mode, it writes the config file to $HOME/.xawtv.out
+
+
+2.17 => 2.18
+============
+
+ * showstopper fixed: xawtv segfaults if there are channels without
+ hotkeys in your $HOME/.xawtv (thanks to
+ Enrico Scholz <enrico.scholz@wirtschaft.tu-chemnitz.de>)
+ * v4l-conf fixed (was broken again for non-DGA Servers line AccelX)
+
+
+2.16 => 2.17
+============
+
+ * started channel list editor (Ctrl-L for now, will be changed
+ later). Not completed, you can't save your changes yet.
+ * driver updates
+ * added session management to kradio. Sort of. The KDE session
+ management functions have a major design bug, probably this works
+ with the bug-compatible kwm only :-(
+ * updates README
+ * wrote Programming-FAQ
+ * And probably a few other changes I forgot about...
+
+
+2.15 => 2.16
+============
+
+ * fixed v4l-conf, handles 15bpp now
+ * configure changes: try "./configure --help", there are some
+ --enable-foo/--disable-foo options now (default for them is
+ enabled).
+ * moved some common code to separate source files.
+ * a few small driver fixes.
+ * added the -c switch to grab-one
+
+
+2.14 => 2.15
+============
+
+ * as allways, a few bug-fixes
+ * added the -c switch to set-tv
+ * i2c problems with hauppauge cards hopefully fixed now. Check
+ bttv driver's Makefile, the code disabled by default (we don't
+ know what happens with other boards...)
+ * msp3400 uses soundcore instead of sound module (no oss needed
+ any more, tnx to Thomas Sailer <sailer@ife.ee.ethz.ch>)
+
+
2.13 => 2.14
============
diff --git a/KNOWN_PROBLEMS b/KNOWN_PROBLEMS
new file mode 100644
index 0000000..67d4eac
--- /dev/null
+++ b/KNOWN_PROBLEMS
@@ -0,0 +1,12 @@
+
+Some people report xawtv segfaults with glibc 2.1
+(got success reports too). I don't know what the
+reason for this problem is. From the stack traces
+I've seen so far, I suspect it is a glibc bug or
+some incompatibility between glibc and the X11 libs.
+
+I've got one report that upgrading the X11 libs from
+3.3.2 to 3.3.3 fixed the problem.
+
+ Gerd
+
diff --git a/bttv/driver/MAKEDEV b/MAKEDEV.v4l
index 3988bec..6c29ba4 100644
--- a/bttv/driver/MAKEDEV
+++ b/MAKEDEV.v4l
@@ -22,7 +22,7 @@ makedev radio 64
makedev vtx 192
makedev vbi 224
-echo "*** old device names (for compatibility only) ***"
-makedev bttv 0
-makedev bttv-fm 64
-makedev bttv-vbi 224
+#echo "*** old device names (for compatibility only) ***"
+#makedev bttv 0
+#makedev bttv-fm 64
+#makedev bttv-vbi 224
diff --git a/Makefile.in b/Makefile.in
index 19912aa..48cc655 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,158 +1,35 @@
-bttvdir=@bttvdir@
-srcdir=@srcdir@
-VPATH=@srcdir@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
+SUBDIRS=src man radio font tools #i2c webcam
-bindir=$(exec_prefix)/bin
-mandir=$(prefix)/man
+all dep depend install clean distclean realclean::
+ set -e; for dir in $(SUBDIRS); do make -C $$dir $@; done
-kdebindir=$(KDEDIR)/bin
-kdelnkdir=$(KDEDIR)/share/applnk/Multimedia
-kradiodir=$(KDEDIR)/share/apps/kradio
-
-CC=@CC@
-CXX=@CXX@
-MOC=$(QTDIR)/bin/moc
-DEPEND=@DEPEND@
-INSTALL=@INSTALL@
-INSTALL_PROGRAM=@INSTALL_PROGRAM@
-INSTALL_DATA=@INSTALL_DATA@
-INSTALL_DIR=mkdir -p
-
-VERSION=$(shell basename `pwd`)
-VRADIO=$(subst xawtv,kradio,$(VERSION))
-
-CFLAGS=-g -Wall @CFLAGS@ -I. @X_CFLAGS@ -I$(bttvdir) -DVERSION='"$(VERSION)"'
-CXXFLAGS = $(CFLAGS) -I$(QTDIR)/include -I$(KDEDIR)/include
-LDLIBS=@X_LIBS@ -l@XAWLIB@ -lXt @X_PRE_LIBS@ -lXext -lXmu \
- -lX11 @X_EXTRA_LIBS@ @LIBS@
-
-PROGS=xawtv v4l-conf set-tv fbtv grab-one dump-mixers radio @KRADIO@
-
-SRCS= $(srcdir)/main.c\
- $(srcdir)/toolbox.c\
- $(srcdir)/mixer.c\
- $(srcdir)/channel.c\
- $(srcdir)/x11.c\
- $(srcdir)/grab-v4l.c
-OBJS= main.o toolbox.o mixer.o channel.o x11.o grab-v4l.o
-
-##########################################################################
-
-.SUFFIXES: .cpp .moc
-
-.cpp.o:
- $(CXX) -c $(CXXFLAGS) $<
-
-.h.moc:
- $(MOC) $< -o $@
-
-##########################################################################
-
-all: $(PROGS)
-
-xawtv: $(OBJS)
- $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDLIBS) @JPEG@
-
-v4l-conf: v4l-conf.c
- $(CC) $(CFLAGS) -o $@ $< @X_LIBS@ -lXext -lX11 @X_EXTRA_LIBS@ @LIBS@
-
-radio: radio.c
- $(CC) $(CFLAGS) -o $@ $<
-
-dump-mixers: dump-mixers.c
- $(CC) $(CFLAGS) -o $@ $<
-
-grab-one: grab-one.c
- $(CC) $(CFLAGS) -o $@ $<
-
-set-tv: set-tv.o channel.o mixer.o grab-v4l.o
- $(CC) $(CFLAGS) -o $@ $^
-
-fbtv: fbtv.o channel.o mixer.o grab-v4l.o
- $(CC) $(CFLAGS) -o $@ $^ @CURSES@ @JPEG@
-
-
-kradio: kradio.moc kradio.o
- $(CXX) -o $@ kradio.o -L$(QTDIR)/lib -L$(KDEDIR)/lib @X_LIBS@ \
- -lkdeui -lkdecore -lqt @X_PRE_LIBS@ -lXext -lX11 @X_EXTRA_LIBS@
-
-
-install: all
- $(INSTALL_PROGRAM) -s xawtv $(bindir)
- $(INSTALL_PROGRAM) -s set-tv $(bindir)
- $(INSTALL_PROGRAM) -s -m4711 -o root -g root v4l-conf $(bindir)
- $(INSTALL_DATA) xawtv.man $(mandir)/man1/xawtv.1
- $(INSTALL_DATA) Xawtv.ad @x_libraries@/X11/app-defaults/Xawtv
- make -C font install;
- if test "@KRADIO@" = "kradio"; then \
- $(INSTALL_PROGRAM) -s kradio $(kdebindir); \
- $(INSTALL_DATA) *.kdelnk $(kdelnkdir); \
- $(INSTALL_DIR) $(kradiodir)/toolbar; \
- $(INSTALL_DATA) *.xpm $(kradiodir)/toolbar; \
- fi
- if test -f fbtv; then \
- $(INSTALL_PROGRAM) -s fbtv $(bindir); \
- fi
-
-clean:
- -rm -f *.o *.moc *~ core* *.bak TAGS
-
-distclean: clean
- -rm -f config.cache config.h config.log config.status Makefile
+distclean realclean::
+ -rm -f *~ config.cache config.h config.log config.status Makefile
@echo "default:" > Makefile
@echo " ./configure && make dep && make" >> Makefile
- -strip $(PROGS)
-realclean: distclean
- -rm -f chan.h
- -rm -f $(PROGS)
-depend dep:
- $(DEPEND) -- $(CFLAGS) -- $(SRCS) $(SRCS2)
+###########################################
+# just for me, some maintaining jobs...
-#########################
-# just for me...
+DEST=$(HOME)/www/v4l
+RPM=/home/ftp/rpm
+VERSION=@XAWTV_VERSION@
-tags:
- etags *.[ch]
-
-check:
- ldd $(PROGS)
-
-tar:
+tar: distclean
find . -name snap0*.ppm -print | xargs -i rm -f
find . -name snap0*.jpeg -print | xargs -i rm -f
- make -C bttv/driver clean
- make -C font dist
- cd ..; tar cvzf $(VERSION).tar.gz $(VERSION)
+ make -C vtx distclean
+ cd ..;tar cvzf $(DEST)/xawtv-$(VERSION).tar.gz xawtv-$(VERSION)
+ rm -f $(RPM)/SOURCES/xawtv-*.tar.gz
+ cp $(DEST)/xawtv-$(VERSION).tar.gz $(RPM)/SOURCES
-diff:
+diff: distclean
echo $(VERSION)
(cd /tmp; tar xvzf `ls -t $(HOME)/2/src/Archives/xawtv-*.tar.gz | head -n 1`)
- (cd ..; diff -urN /tmp/xawtv-* $(VERSION) | gzip > $(VERSION).diff.gz)
+ (cd ..; diff -urN /tmp/xawtv-* xawtv-$(VERSION) | gzip > $(DEST)/xawtv-$(VERSION).diff.gz)
rm -rf /tmp/xawtv-*
-kdetar:
- mkdir /tmp/$(VRADIO)
- cp kradio.cpp kradio.h *.xpm kradio.kdelnk font/led-fixed.bdf /tmp/$(VRADIO)
- cp Makefile.kradio /tmp/$(VRADIO)/Makefile
- touch /tmp/$(VRADIO)/config.h
- echo "some hints for compiling kradio are in the Makefile" > /tmp/$(VRADIO)/README
- (cd /tmp; tar cvzf - $(VRADIO)) > ../$(VRADIO).tar.gz
- rm -rf /tmp/$(VRADIO)
-
-dist: distclean tar kdetar diff
-
-glibc: realclean
- CC=i486-pc-linux-gnuglibc2-gcc CXX=i486-pc-linux-gnuglibc2-g++ \
- ./configure
- make
-
-#-------------------------------------------------------------------------
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-
+dist: tar diff
diff --git a/Makefile.kradio b/Makefile.kradio
deleted file mode 100644
index dc4b08a..0000000
--- a/Makefile.kradio
+++ /dev/null
@@ -1,64 +0,0 @@
-# Makefile for the standalone-distributed kradio version
-# it is a extract from the xawtv package from
-# http://user.cs.tu-berlin.de/~kraxel/linux/#xawtv
-#
-# seems people do not find kradio if it is'nt on ftp.kde.org :-)
-#
-#
-# /dev/radio == char, major 81, minor 64
-#
-# kradio uses the video4linux radio interface. bttv
-# (either 0.5.x or the version included in 2.1.x)
-# uses this interface, I tested it with a WinTV/radio
-# card. You have to insmod bttv with "radio=1" as
-# module parameter.
-#
-# Make sure the $KDEDIR and $QTDIR variables are set
-# correctly, the make utility will pick them up from
-# the environment.
-#
-# Other 2.1.x radio drivers should work too.
-#
-##########################################################################
-
-kdebindir=$(KDEDIR)/bin
-kdelnkdir=$(KDEDIR)/share/applnk/Multimedia
-kradiodir=$(KDEDIR)/share/apps/kradio
-
-FONTDIR=/usr/X11R6/lib/X11/fonts/misc
-MOC=$(QTDIR)/bin/moc
-
-# for usage with bttv-0.5.x (instead of 2.1.x) you have to remove the
-# '-DUSE_KERNEL_VIDEODEV' and add '-I/wherever/the/bttv/driver/is'
-# instead. kradio needs the videodev.h include file.
-
-CXXFLAGS = -I$(QTDIR)/include -I$(KDEDIR)/include \
- -DUSE_KERNEL_VIDEODEV=1
-
-##########################################################################
-
-.SUFFIXES: .cpp .moc .bdf .pcf
-
-.cpp.o:
- $(CXX) -c $(CXXFLAGS) $<
-
-.h.moc:
- $(MOC) $< -o $@
-
-.bdf.pcf:
- bdftopcf -o $@ $<
-
-##########################################################################
-
-kradio: kradio.moc kradio.o
- $(CXX) -o $@ kradio.o -L$(QTDIR)/lib -L$(KDEDIR)/lib \
- -lkdeui -lkdecore -lqt -lXext -lX11
-
-install: kradio led-fixed.pcf
- install -s kradio $(kdebindir);
- install -m 644 kradio.kdelnk $(kdelnkdir);
- mkdir -p $(kradiodir)/toolbar;
- install -m 644 *.xpm $(kradiodir)/toolbar;
- install -m 644 led-fixed.pcf $(FONTDIR)
- (cd $(FONTDIR); mkfontdir)
- -xset fp rehash
diff --git a/Miro_gpio.txt b/Miro_gpio.txt
new file mode 100644
index 0000000..7d0030c
--- /dev/null
+++ b/Miro_gpio.txt
@@ -0,0 +1,8 @@
+
+MIRO pro: GPIO registers, Win95
+
+GPOE: 0000 0011 0000 0000 0000 1111 [03000F]
+-------------------------------------------------
+GPDATA: 1110 0100 0000 0111 1101 0010 [E407D2] (direct output)
+GPDATA: 1110 0110 0000 0111 1101 0001 [E607D1] (using MSP chip)
+
diff --git a/Programming-FAQ b/Programming-FAQ
new file mode 100644
index 0000000..2e51fa9
--- /dev/null
+++ b/Programming-FAQ
@@ -0,0 +1,109 @@
+
+mostly for bttv currently...
+
+
+Initialisation
+==============
+
+Grabbing does'nt work if the bt848 chip can't sync, you'll get errno
+== EAGAIN then (Overlay does work and gives snow). You have to make
+sure:
+
+ * The driver uses the correct Video Input (VIDIOCSCHAN)
+ * The driver uses the correct TV norm (VIDIOCSCHAN,VIDIOCSTUNER)
+ * For TV input: There is some station tuned in.
+
+With VIDIOCGCHAN you can ask for available input channels and
+informations about these.
+
+
+Simple grabbing with mmap()
+===========================
+
+With bttv you can mmap() the bttv memory. There is room for two
+frames, therefore you can get 2*BTTV_MAX_FBUF bytes mapped.
+
+ fd = open("/dev/video", ...);
+ /* ... initialisation ... */
+ map = mmap(0,BTTV_MAX_FBUF*2,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);
+
+Frame 0 starts at map, frame 1 at map+BTTV_MAX_FBUF.
+
+Ok, that's the preparation, now let's start grabbing. You have to
+fill the parameters (size, format, frame) into a struct video_mmap,
+and then do
+
+ ioctl(fd,VIDIOCMCAPTURE,&video_mmap);
+
+This instructs the driver to capture a frame. The ioctl will return
+immedantly, the driver will process your request asyncron (interrupt
+driven). If you want to get the result, you have to wait for it using
+
+ ioctl(fd,VIDIOCSYNC,&video_mmap.frame);
+
+If your request is still in progress, the ioctl will block until it is
+done. Otherwise it will return. That's all, now you have the result
+in the mmap()ed area.
+
+
+Advanced grabbing
+=================
+
+The scheme outlined above works fine for single frames. If you want
+do continuous grabbing and keep up with the full frame rate (25 fps
+for PAL), it is'nt that simple. As mentioned above, the driver has
+room for two frames. There is room for two grabbing requests too.
+
+The basic idea for handling full speed is to let work the bttv driver
+and the application in parallel. The application processes the
+picture in one of the frames, while the driver captures the next
+picture to the other one. Works this way:
+
+ /* ... initialisation ... */
+
+ ioctl(capture frame 0)
+
+loop:
+ ioctl(capture frame 1)
+ ioctl(sync frame 0)
+ /*
+ * this sync returns if the first request (for frame 0) is done
+ * the driver will continue with the next one (for frame 1),
+ * while the application can proccess frame 0. If the
+ * application is done, we reuse frame 0 for the next request ...
+ */
+ ioctl(capture frame 0)
+ ioctl(sync frame 1)
+ /*
+ * same procedure, but the other way around: driver captures
+ * to frame 0, application proccesses frame 1
+ */
+ goto loop;
+
+
+Pitfalls / driver changes
+=========================
+
+video4linux is work-in-progress, and there still some interface
+changes from time to time due to design bugs.
+
+One problem is that the TV norm (PAL/NTSC/...) is in struct
+video_tuner, not struct video_channel. That's bad if you have a board
+without tuner at all and a PAL video recorder connected to Composite1
+and a NTSC Camera to Composite2...
+Fixing this required changes in both structs and the VIDIOCSCHAN
+ioctl.
+
+Another one is that the VIDIOCSYNC ioctl had no argument at all, newer
+versions take the frame number as argument. The new scheme is more
+stable.
+
+The hard-coded frame size (BTTV_MAX_FBUF) is gone in newer versions,
+you should use the VIDIOCGMBUF ioctl to figure out the size at runtime.
+
+Happy hacking,
+
+ Gerd
+
+--
+Gerd Knorr <kraxel@goldbach.in-berlin.de>
diff --git a/README b/README
index 8d2d13e..d260f3b 100644
--- a/README
+++ b/README
@@ -6,23 +6,70 @@ This is a _simple_ xaw-based TV Program which uses the bttv driver or
video4linux (included in 2.1.x). Copy Policy is GNU GPL.
+before sending me email...
+==========================
+
+If you are upgrading from 2.x to 3.x, read the UPDATE_TO_v3.0
+file. There are a few incompatible changes you have to take care
+of.
+
+READ THE F*** MANUAL FIRST (this README file, Trouble-Shooting file,
+xawtv man page, bttv driver documentation, the Sound-FAQ)
+
+If you have problems after upgrading, please check the ChangeLog for
+hints first. Looking into the ChangeLog is a good idea in general,
+becauce it is updated for every release, the other files are updated
+less freqently...
+
+For problem/bug reports:
+
+ * emails with images attached will to to /dev/null.
+ * emails with the word "nagra" or "premiere" will go to /dev/null.
+ * emails with questions answered in the documentation will go to
+ /dev/null.
+ * emails which don't have any useful informations (like "xawtv
+ does'nt work, please help me") will go to /dev/null.
+
+"useful informations" includes at least:
+ - xawtv version
+ - kernel version
+ - driver version
+ - which grabber board
+ - which TV norms are used in your country.
+ - if xawtv prints errors, include these too.
+ - don't forget a description of your problem :-)
+
+If you are using bttv as driver:
+ - the insmod arguments for the modules
+ - the kernel messages printed by bttv while loading.
+
+If you are _really_sure_ some information is'nt important for your
+problem, you can skip it. But if in doubt, better include it...
+
+
+For patches/changes:
+ * Please add a comment what is changed and and why you changed it.
+ * Please send unified diffs ("diff -u") against the latest version.
+ * Please don't reformat my source code.
+
+
compile & install
=================
-There is modified bttv-0.5.8 in the bttv subdirectory. Only the
-driver itself is included. If you use the bttv for the first time, I
-recommend to get the whole bttv package from Ralph's page (see below)
-and check out the documentation. Some (very limited) informations can
-be found in the bttv/MODULES file.
+A simple
+
+ $ make
+
+should compile xawtv, v4l-conf, maybe kradio and a few other
+utilities. You can install the programs (as root) with:
-$ ./configure --with-bttv=/path/to/bttv/driver && make
+ # make install
-should compile xawtv, radio, maybe kradio and v4l-conf. If you omit
-the --with-bttv option, the driver in the bttv directory will be used.
+If you want build RPMs: No problem, just run
-You can install xawtv, v4l-conf and kradio (as root) with:
+ $ rpm -ta xawtv-3.xx.tar.gz
-# make install
+and install them the usual way with "rpm -i".
usage
@@ -31,16 +78,10 @@ usage
bttv
----
-Of cource you have to load the modules as very first thing. There is
-a script called "update" in the bttv/drivers directory. I use this
-one to load a new version while doing driver hacking. You can use it
-too, but check the module arguments before. They work for my setup,
-and probably do *not* for yours. The module arguments are documented
-in bttv/driver/MODULES.
-
-If you have some problems to make the driver work, check out the
-Trouble-Shooting file. Don't expect to get a answer for questions
-which are covered there.
+bttv is'nt bundled with xawtv any more. You can get my current bttv
+code as separate tar file from http://www.in-berlin.de/User/kraxel/v4l/
+Number scheme is Ralph's version it is based on plus a small letter
+(i.e. bttv-0.6.3e for example).
v4l-conf
@@ -49,121 +90,141 @@ v4l-conf
v4l-conf is a small tool which tells video4linux about the current
video mode (size and color depth). This requires root priviliges,
becauce it is easy to crash the box by passing bogous values there.
-It requires the X-Server up and running. It is a temporary hack, this
-problem probably will be solved in a better way later on (Alan plans
-to write a X-Server extention). Try "v4l-conf -h" for a short
-description.
+It requires the X-Server with DGA support up and running or a
+framebuffer device. It is a temporary hack, this problem will be
+solved in a better way with a X11 extention. The XFree86 snapshots
+(3.9.x) already have some working code.
-It is installed suid-root now, and xawtv runs it at startup. Should
-work out-of-the-box without extra configuration.
+Try "v4l-conf -h" for a short description. It is installed suid-root,
+and xawtv runs it at startup. Should work out-of-the-box without
+extra configuration. Normally you should'nt need to worry about it,
+but for debugging it is handy do run it from the shell and check the
+output.
xawtv
-----
-There is a man page now, check it out.
-
-xawtv will not work without the app-defaults. You'll get a error
-message about a zero-sized shell widget if the app-defaults are
-not correctly installed.
+There is a man page now, read it. Don't expect you can use xawtv
+without reading the documentation at least once. You are lost if you
+don't know the keyboard shortcuts, xawtv is'nt a mouse-only program.
-If you want to try xawtv without installing it, type...
+xawtv will not work without the app-defaults. If you want to try
+xawtv without installing it, use this...
$ XUSERFILESEARCHPATH=./%N.ad
$ export XUSERFILESEARCHPATH
$ ./xawtv
...to make sure xawtv finds the application defaults (the Xawtv.ad
-file).
+file). If v4l-conf is'nt installed too, you have to run it once
+(as root) before starting xawtv.
+
+
+xawtv-remote
+------------
+
+remote control for xawtv. Takes commands for xawtv as command line
+arguments. Check 'xawtv-remote -h' for details.
+
+ObSecurity: This uses X Properties, everyone who is allowed to connect
+to your X11 Display can control xawtv.
+
+There is a GUI (Qt) version at:
+http://www.ben2.ucla.edu/~wtho/xawtv-qremote/xawtv-qremote-0.01.tar.gz
fbtv
----
-TV program for the linux console. Runs on top of a graphic framebuffer,
-tested with vesafb (check vger CVS) so far. Shares config file
-($HOME/.xawtv) and (most) keyboard shortcuts with xawtv. Read the source
-code for details.
+TV program for the linux console. Runs on top of a framebuffer
+device, tested with vesafb (2.1.109+) so far. Check out man-page and
+source code for details.
-set-tv
+v4lctl
------
-Simple command line tuner. Reads like xawtv the config file $HOME/.xawtv.
-Expects a channel name on the command line. Assuming you have a station
-named [ZDF] in your $HOME/.xawtv file, "set-tv zdf" will tune in the
-channel defined there. That way you can tune in a station to grab
-teletext (or whatever) without starting up X11.
+This tool allows to control a v4l device from the command line. Check
+the man-page for details.
-It prints some useless messages about video resolution due to the fact that
-it shares alot of code with xawtv, maybe I fix this later.
-
-grab-one
+streamer
--------
-Command line tool for grabbing single pictures (full-size, PPM or raw).
-Try "grab-one -h" for a description.
+Command line tool for streaming capture (single frames work too).
+Try the '-h' switch for a description.
-dump-mixers
------------
+radio
+-----
-Just does what the name suggests: It simply dumps the current mixer
-settings to stdout. I used it to debug the msp3400 module, maybe
-someone finds this useful...
+You have to load the driver using "insmod bttv radio=1" for radio
+support. The MAKEDEV script should create the required /dev/radio*
+devices.
+radio is a console application (curses). up/down tune, 'q' quits,
+the function keys recall the programmed stations. radio reads the
+kradio config file. You can't configure anything with radio, you'll
+have to use kradio or vi for this. The config file format is
+documented in the man page.
-vic
----
+kradio (my KDE radio app) is'nt included any more, it is available as
+separate tarball now.
-The grabber-bttv-0.5.6.cc file is a grabber driver for vic, works with
-plain bttv-0.5.6. Up to 12 fps.
-There is newer version, grabber-video4linux.cc. This one runs with newer
-bttv versions (0.5.7/8) and the current kernel code.
+videotext / teletext
+--------------------
-Both versions are tested only with PAL. The "large" picture size probably
-doest'nt work with NTSC.
+There is a new videotext application for bttv: alevt. Your friendly
+sunsite mirror has it.
-If you plan to compile vic: It is'nt trivial, you should have some
-basic knowledge about C and writing/editing Makefiles.
+Ralph has written a software decoder for teletext. You can download
+it from his web-page. There is a program called videoteXt which can
+be used to view the teletext pages. A link to this package is on
+Ralphs page too.
+In the vtx subdirectory is a simple vtx2ascii converter, build quick&diry
+out of the videoteXt sources. Can output ascii (with and without
+ansi-colors) and html. A perl-cgi is included too.
-radio & kradio
---------------
-radio support is still very experimental. If you want to play with it:
-* You need a special file for it (/dev/bttv-fm, char dev, major 81,
- minor 64).
-* "insmod bttv radio=1"
+webcam
+------
-radio is a quite simple command line radio application. It just
-promps for a (FM) frequency.
+This is a webcam tool. Captures a image, annotates with a text +
+current time and uploads it to the webserver using ftp in an endless
+loop. Needs the ftp utility. Should survive dropped ftp-connections
+(webserver reboot) without problems.
-kradio is a more comfortable KDE application. There is a font in the
-font subdirectory, it is required for kradio (for a cool LED-Style
-display :-). Make sure the KDEDIR and QTDIR environment variables are
-set correctly.
+It is'nt compiled by default, you can compile it with "make webcam".
+All config options are compile time options, check out the #defines in
+webcam.c. For normal operation, webcam is simply started without
+arguments (and it should work until someone kills it). If the number
+of arguments is non-zero, webcam prints the complete communication
+with the ftp utility to stderr (for debugging purpurses).
-videotext / teletext
---------------------
+perl
+----
-Ralph has written a software decoder for teletext. You can donwload
-it from his web-page. There is a program called videoteXt which can
-be used to view the teletext pages. A link to this package is on
-Ralphs page too.
+Hint for all perl users/hackers: There is a Video::Capture::V4l module
+available at CPAN. It can do capture, vbi decoding, and it comes with a
+nifty tool to do a channel scan (decodes the station ID from vbi).
resources
=========
-http://www.cs.tu-berlin.de/~kraxel/linux/#xawtv - xawtv [me]
-http://www.thp.uni-koeln.de/~rjkm/linux/bttv.html - bttv driver [Ralph]
-http://roadrunner.swansea.uk.linux.org/v4l.shtml - video4linux [Alan]
+http://www.in-berlin.de/User/kraxel/xawtv.html - xawtv [me]
+http://user.exit.de/froese/ - alevt [Edgar]
+http://www.thp.uni-koeln.de/~rjkm/linux/bttv.html - bttv [Ralph]
+http://www.ee.up.ac.za/~justin/v4l2/ - bttv2 [Justin]
+http://roadrunner.swansea.uk.linux.org/v4l.shtml - v4l [Alan]
+http://millennium.diads.com/bdirks/v4l2.htm - v4l2 [Bill]
+http://www.tk.uni-linz.ac.at/~simon/private/i2c/ - i2c [Simon]
http://www-nrg.ee.lbl.gov/vic/ - vic
-http://www.kde.org - KDE
+http://FreeTV.Notrix.de
Have fun!
@@ -171,4 +232,4 @@ Have fun!
Gerd
--
-Gerd Knorr <kraxel@cs.tu-berlin.de>
+Gerd Knorr <kraxel@goldbach.in-berlin.de>
diff --git a/README.bttv b/README.bttv
new file mode 100644
index 0000000..46de961
--- /dev/null
+++ b/README.bttv
@@ -0,0 +1,173 @@
+
+Some hints to get the bttv driver up and running
+================================================
+
+You need configured kernel sources to compile the bttv driver. The
+driver uses some Makefile magic to compile the modules with your
+kernel's configuration (wrt. module-versions, SMP, ...). If you
+already have compiled the kernel at least once, you probably don't
+have do worry about this. If not, go to /usr/src/linux and run
+at least "make config". Even better, compile your own kernel, you'll
+never become a real hacker else ;-)
+
+Of cource you have to load the modules as very first thing. There is
+a script called "update" in the bttv/drivers directory. I use this
+one to load a new version while doing driver hacking. You can use it
+too, but check the module arguments before. They work for my setup,
+and probably do *not* for yours. The module arguments are documented
+below. The MAKEDEV.v4l script creates the special files (/dev/video,
+...) for the video4linux.
+
+To autoload the modules, stick something like this into
+/etc/modules.conf:
+
+# TV
+alias char-major-81 videodev
+alias char-major-81-0 bttv
+pre-install bttv modprobe -k msp3400; modprobe -k tuner
+options bttv radio=1
+options tuner type=5
+
+Again: this is for _my_ setup, you probably have to adjust the module
+parameters.
+
+
+See also
+========
+
+ * Trouble-Shooting - general tips for xawtv / bttv
+ * Sound-FAQ - A description how Sound works on bt8xx-based
+ boards and how one can make a new card work.
+
+
+****************************************************************************
+****************************************************************************
+
+insmod options for the bttv modules
+cut+paste from bttv-0.6.4e/driver/MODULES
+=========================================
+
+
+There are quite lot modules out here...
+
+videodev.o
+ this is the basic video4linux module, all video
+ drivers (incl. bttv) register themself here.
+
+i2c.o
+ the generic i2c module. It does much of the i2c bus
+ management, all other modules (except videodev.o)
+ use this one
+
+ insmod args:
+ scan=1 scan the bus for i2c devices
+ verbose=0 shut up i2c
+ i2c_debug=1 for debugging, it sticks the whole
+ (software) i2c bus traffic to the
+ syslog
+
+bttv.o
+ the bt848 (grabber chip) driver
+
+ insmod args:
+ remap=adr remap Bt848 memory to adr<<20
+ vidmem=base frame buffer address>>20 (of graphic card)
+ triton1=0/1 for Triton1 compatibility
+ Triton1 is automatically recognized
+ but this might also help with other chipsets
+ pll=0/1/2 pll settings
+ 0: don't use PLL
+ 1: 28 MHz crystal installed
+ 2: 35 MHz crystal installed
+ radio=0/1 card supports radio
+ card=n card type
+ 0: Auto-Detect
+ 1: Miro
+ 2: Hauppauge (old bt848 boards)
+ 3: STB
+ 4: Intel
+ 5: Diamond
+ 6: AVerMedia
+ 7: MATRIX Vision MV-Delta
+ 8: FlyVideo
+ 9: TurboTV
+ 10: Hauppauge (new bt878 boards)
+ 11: MIRO PCTV pro
+ 12: Terratec/Vobis TV-Boostar
+ 13: Newer Hauppauge WinCam (bt878)
+ 14: MAXI TV Video PCI2
+ 15: Terratec TerraTV+
+ 16: Aimslab VHX
+ 17: PXC200
+ 18: AVermedia98
+ 19: FlyVideo98 (newer FlyVideo cards)
+
+ remap, card, radio and pll accept up to four comma-separted arguments
+ (for multiple boards). The CARD and PLL defines from the Makefile
+ are used as defaults.
+
+msp3400.o
+ The driver for the msp34xx sound processor chips. If you have a
+ stereo card, you probably want to insmod this one.
+
+ insmod args:
+ debug=1/2 print some debug info to the syslog,
+ 2 is more verbose.
+ simple=1 Use the "short programming" method (newer
+ msp34xx versions support this).
+ once=1 Don't check the TV-stations Audio mode
+ every few seconds, but only once after
+ channel switches. This should workaround
+ the problems with disappearing sound.
+ amsound=1 Audio carrier is AM/NICAM at 6.5 Mhz. This
+ should improve things for french people, the
+ carrier autoscan seems to work with FM only...
+
+tea6300.o
+ The driver for the tea6300 fader chip. If you have a stereo
+ card and the msp3400.o doesn't work, you might want to try this
+ one. This chip is seen on most STB TV/FM cards (usually from
+ Gateway OEM sold surplus on auction sites).
+
+ insmod args:
+ debug=1 print some debug info to the syslog.
+
+tda8425.o
+ The driver for the tda8425 fader chip. This driver used to be
+ part of bttv.c, so if your sound used to work but does not
+ anymore, try loading this module.
+
+ insmod args:
+ debug=1 print some debug info to the syslog.
+
+tda9855.o
+ The driver for the tda9855 audio chip. Afaik, only the
+ Diamond DTV2000 has this chip.
+
+ insmod args:
+ debug=1 print some debug info to the syslog.
+
+tuner.o
+ The tuner driver. You need this unless you want to use only
+ with a camera or external tuner ...
+
+ insmod args:
+ debug=1 print some debug info to the syslog
+ type=n type of the tuner chip. n as follows:
+ 0: Temic PAL tuner
+ 1: Philips PAL_I tuner
+ 2: Philips NTSC tuner
+ 3: Philips SECAM tuner
+ 4: no tuner
+ 5: Philips PAL tuner
+ 6: Temic NTSC tuner
+ 7: Temic PAL tuner
+
+i2c_chardev.o
+ provides a character device for i2c bus access. Works for 2.1.x
+ only, not compiled by default.
+
+
+To load the tuner+msp3400 modules with kerneld/kmod, you should use
+"modprobe -k tuner; modprobe -k msp3400" in pre-install for bttv.
+
diff --git a/README.de b/README.de
index da51a30..c4bf924 100644
--- a/README.de
+++ b/README.de
@@ -3,11 +3,11 @@ small is beautiful
==================
Also das hier ist ein _einfaches_ Xaw-basiertes Fernseh-Programm für
-die vom bttv-Treiber unterstützten bt848-Karten. Sender konfigurieren
-oder gar automatisch suchen is nich, ist alles per Hand in's config-file
-reinzuhacken. Maus kann auch erst mal ein Stück weg gelegt werden; bunte
-Buttons zum draufklicken gibt es auch nicht. Ich mag keinen überflüssigen
-Schnickschnack auf'm Bildschirm :-)
+die vom bttv-Treiber unterstützten bt848-Karten. Inzwischen etwas
+user-freundlicher als die früheren Versionen. Trotzdem sollte man
+sich unbedingt die man-page anschauen, da stehen (unter anderem) die
+Tastatur-shortcuts drin. Und ohne Tastatur kann man nicht mal einen
+Sender einstellen ...
copy policy ist GNU GPL.
@@ -18,6 +18,7 @@ compilieren, installieren & benutzen
Weil ich zu faul bin, alles in zwei Sprachen zu updaten, gibts fortan
nur noch ein englisches README + englische man-page.
-Sorry.
+Sorry folks.
Gerd
+
diff --git a/README.lirc b/README.lirc
new file mode 100644
index 0000000..f7d0473
--- /dev/null
+++ b/README.lirc
@@ -0,0 +1,22 @@
+
+For lirc support you have to install lirc-0.6.0pre1 or newer. There
+is a library with the lirc client code now. You can get it from the
+lirc snapshot directory:
+ http://fsinfo.cs.uni-sb.de/~columbus/lirc/software/snapshots/
+
+xawtv and fbtv accept the same commands via lirc as with xawtv-remote,
+i.e. if you stick the following lines into your .lircrc ...
+
+ begin
+ prog = xawtv
+ button = MUTE
+ config = volume mute
+ end
+
+... this should have the same effect like "xawtv-remote volume mute".
+Check the xawtv-remote manpage for a more complete list.
+
+And please don't ask /me/ how to make lirc work, I don't use it.
+
+ Gerd
+
diff --git a/Sound-FAQ b/Sound-FAQ
new file mode 100644
index 0000000..5b9b940
--- /dev/null
+++ b/Sound-FAQ
@@ -0,0 +1,90 @@
+
+bttv and sound mini howto
+=========================
+
+There are alot of different bt848/849/878/879 based boards available.
+Making video work often is not a big deal, because this is handled
+completely by the bt8xx chip, which is common on all boards. But
+sound is handled in slightly different ways on each board.
+
+To handle the grabber boards correctly, there is a array tvcards[] in
+bttv.c, which holds the informations required for each board. Sound
+will work only, if the correct entry is used (for video it often makes
+no difference). The bttv driver prints a line to the kernel log,
+telling which card type is used. Like this one:
+
+ bttv0: model: BT848(Hauppauge old)
+
+You should verify this is correct. If it is'nt, you have to pass the
+correct board type as insmod argument, "insmod bttv card=2" for
+example. The file MODULES in the driver directory has a list of valid
+arguments. If your card is'nt listed there, you might check the
+source code for new entries which are not listed yet. If there is'nt
+one for your card, you can check if one of the existing entries does
+work for you (just trial and error...).
+
+Some boards have an extra processor for sound to do stereo decoding
+and other nice features. The msp34xx chips are used by Hauppauge for
+example. If your board has one, you might have to load a helper
+module like msp3400.o to make sound work. If there is'nt one for the
+chip used on your board: Bad luck. Start writing a new one. Well,
+you might want to check the video4linux mailing list archive first...
+
+Of course you need a correctly installed soundcard unless you have the
+speakers connected directly to the grabber board. Hint: check the
+mixer settings too...
+
+
+How sound works in detail
+=========================
+
+Still does'nt work? Looks like some driver hacking is required.
+Below is a do-it-yourself description for you.
+
+The bt8xx chips have 32 general purpose pins, and registers to control
+these pins. One register is the output enable register
+(BT848_GPIO_OUT_EN), it says which pins are actively driven by the
+bt848 chip. Another one is the data register (BT848_GPIO_DATA), where
+you can get/set the status if these pins. They can be used for input
+and output.
+
+All grabber board vendors use these pins to control an external chip
+which does the sound routing. But every board is a little different.
+These pins are also used by some companies to drive remote control
+receiver chips.
+
+As mentioned above, there is a array which holds the required
+informations for each known board. You basically have to create a new
+line for your board. What is in there:
+
+struct tvcard
+{
+ char *name;
+ int inputs; /* number of video inputs */
+ int tuner; /* which of them is the tuner */
+ int svhs; /* which of them is the svhs input */
+ u32 gpiomask;
+ u32 muxsel[8]; /* video mux */
+ u32 audiomux[6]; /* audio mux: Tuner, Radio, external, internal, mute, stereo */
+ u32 gpiomask2; /* GPIO MUX mask (this is video) */
+};
+
+gpiomask has all bits set which are used to control the audio mux.
+This value basically goes to the gpio output enable register. It is
+also used to mask bits when switching the audio mux (which is done by
+read-modify-write on the gpio data register).
+
+What you have to do is figure out the correct values for gpiomask and
+the audiomux array. If you have Windows and the drivers four your
+card installed, you might to check out if you can read these registers
+values used by the windows driver. A tool to do this is available
+from ftp://telepresence.dmem.strath.ac.uk/pub/bt848/winutil
+If you hav'nt Windows installed, this is a trial and error game...
+
+Good luck,
+
+ Gerd
+
+
+PS: If you have a new working entry, mail it to Ralph. So it can be
+ included into next driver version...
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..571b32a
--- /dev/null
+++ b/TODO
@@ -0,0 +1,20 @@
+
+TODO list isn't exactly right for this. It is more a collection of
+ideas I'm thinking about. It *might* mean I have plans to implement
+this in near future.
+
+ * frequency= option for .xawtv
+ * volume= option for .xawtv
+ * videotext decoder (for station ID, maybe subtitles)
+ * grayscale avi recording (anybody knows how to do this? 256 color
+ with a gray palette?)
+ * keep-aspect-ratio option
+ * switch to another toolkit, Xaw keyboard/menu support sucks
+ (gtk maybe?)
+ * use threads (instead of fork()ing off children)
+ * mjpeg compression has alot of (partly design) problems, have to think
+ about how to handle this in a clever way...
+ * config file args for avi-params, numerate movies?
+ * grab-v4l: use more than two buffers
+ * i18n
+
diff --git a/Trouble-Shooting b/Trouble-Shooting
index fb0b207..754caf0 100644
--- a/Trouble-Shooting
+++ b/Trouble-Shooting
@@ -5,40 +5,60 @@ Here are a few hints if you have trouble to make bttv & xawtv work:
general
=======
-* Check the PROBLEMS file in Ralph's bttv Documentation
+* I STRONGLY recommend to build the driver as module, if you are using
+ the driver version included in the linux kernel. All the insmod
+ options only available if you build the driver as module. You'll
+ need them to configure the driver if autodetection does'nt work.
-* There are a few known incompatibilities, see below.
+* Just in case you don't know: With the "dmesg" command you can
+ display the (last 4k of) kernel/module messages.
+
+* Check if your board is recognized correctly. The bttv driver
+ should print a line like this one:
+
+ bttv0: model: BT848(Hauppauge old)
+
+ If your card is'nt recognized correctly, you have to specify
+ the board type as insmod argument (card=x, see bttv/driver/MODULES
+ for a list).
+
+* If your board is'nt listed there, you can check if it is compatible
+ with another one which is already in the list (trial-and-error for
+ all valid card numbers...).
* The insmod options for the modules are documented in the
MODULES file. Use the "verbose=" and "debug=" args to make
the modules more verbose.
-* Just in case you don't know: With the "dmesg" command you can
- display the (last 4k of) kernel/module messages.
+
+* Check the PROBLEMS file in Ralph's bttv Documentation
+
+* There are a few known incompatibilities, see below.
* Try a newer version of the X-Server (if available).
* If you upgrade xawtv and something does'nt work any more, please
check the Changes file before sending bug reports...
-* There are some X-Servers with a buggy XF86VidMode extention around.
- xawtv has a "-x" switch do disable the usage of the XFree extentions,
- this should fix the hangs on startup.
+* Seems the XF86VidMode extention is rarely used and not very well
+ tested with some X-Servers. If you have strange effects while
+ switching fullscreen on and/or off, try to disable the VidMode
+ usage with the "-novm" switch. If xawtv hangs on startup (while
+ asking the Server for available resolutions), using "-novm" should
+ help too.
video
=====
-* Make sure capture is turned on (xtvscreen starts up with capture
- off)
+* Make sure capture is turned on (xtvscreen starts up with capture off)
* Black screen, no picture at all: Bad, probably the video frame buffer
address is wrong.
- The bttv module has a vidmem=0x??? argument, so you can pass the
- correct one. xawtv should print it (if the X-Server supports DGA),
- you can check the X-Server startup messages and /proc/pci too.
- Note: The vidmem= arg will be shiftet by 20 bits, you need the first
- three (hex-)digits of the frame buffer address only!!!
+ Setting the address is done by the v4l-conf module based on the
+ information from the DGA-Extention of the X-Server. If your
+ X-Server doesn't support DGA, you'll have to configure the driver
+ manually with the "v4l-conf -a address".
* Black screen after some time of normal operation: try to reload the
bttv module.
@@ -49,6 +69,10 @@ video
the Grabber card, so the interaction between Grabber and Graphics
board already works fine.
+* grabber board seems not to sync correctly: try to change the PLL
+ settings. You can load bttv with the insmod argument pll=[0,1,2].
+ See bttv/driver/MODULES for details.
+
* noisy, sort-of-white screen: There is no TV Station tuned in.
Possible reasons:
- There is really no station present on that channel...
@@ -58,26 +82,32 @@ video
details.
- Wrong channel map (the channel-to-freqency mapping is
different in different countries)
- - some trouble with the i2c bus, see below
+ - some trouble with the i2c bus, i/o error messages in the syslog.
+ If this is a Hauppauge board, check the kernel messages to see
+ if it was correctly identified as Hauppauge. If not, try
+ "insmod bttv card=2"
-* Trouble with TrueColor mode: It's impossible to find what color depth
- the X-Server uses internally, you might have to use the -b switch to
- tell if it runs 24 or 32 bpp. Both xawtv and v4l-conf have this switch.
+* Trouble with TrueColor mode (image spread across the screen): It's
+ impossible to find what color depth the X-Server uses internally,
+ you might have to use the -b switch to tell if it runs 24 or 32 bpp.
+ Both xawtv and v4l-conf have this switch.
+
+* Picture is fine, but it some pixels off the window (matrox board,
+ eh?). This is a design bug in the DGA extention. A workaround
+ is the -shift=xxx option. Play with different values for xxx
+ until it fits, 1024 is a good start.
sound
=====
-* it might be nessesary to initialize the sound card with a
- "insmod sound" to get sound at all.
-
-* With stereo cards you need the msp3400 module.
+* With old Hauppauge boards (bt848-based) it might be needed to load
+ the bttv module with "card=2". Try this if your board is'nt
+ correctly autodetected as Hauppauge.
- There is some trouble with the MIRO cards: They can do both
- mono (without msp3400 chip) & stereo (using msp3400), but nobody
- knows how to kick them into stereo mode.
- Result: it works even without msp3400, but loading the msp3400
- does'nt give stereo sound...
+* it might be nessesary to initialize the sound card with a
+ "insmod sound" to get sound at all. Double-check the mixer
+ settings.
* For radio support (WinTV/Radio) you have to do "insmod radio=1"
@@ -86,7 +116,8 @@ if it still does'nt work... -- hardware problems/conflicts
============================================================
* As far I know, the bttv driver can't do IRQ sharing, make sure it
- has its own interrupt.
+ has its own interrupt. Try to play with the BIOS settings, or swap
+ PCI boards if nothing else works...
* There are reports that the tuner works only if the *graphic board*
has its own IRQ. Don't ask me why...
@@ -105,17 +136,6 @@ if it still does'nt work... -- hardware problems/conflicts
Known problems / incompatibilities
==================================
-o There are some problems with the i2c bus sometimes (you'll get
- i2c i/o error messages in the syslog). I got all sorts of
- strange reports about this problem. Seems at least some boards
- (my one is fine) don't work reliably if they get hot or something
- like that...
-
- One (but maybe not the only) reason for these i2c bus problems
- are memory conflicts. Playing around with the remap insmod
- option might help.
-
-
[Alan on linux-kernel]
o Some SiS boards it doesnt work on. I don't know if it works on
@@ -141,5 +161,4 @@ More hints/suggestions/corrections/updates are welcome,
--
-Gerd Knorr <kraxel@cs.tu-berlin.de>
-
+Gerd Knorr <kraxel@goldbach.in-berlin.de>
diff --git a/UPDATE_TO_v3.0 b/UPDATE_TO_v3.0
new file mode 100644
index 0000000..a67930e
--- /dev/null
+++ b/UPDATE_TO_v3.0
@@ -0,0 +1,33 @@
+
+Incompatible changes in 3.0
+===========================
+
+ * The config file format has changed. There are three new sections:
+ [global], [defaults] and [launch]. Global settings go to the [global]
+ section, the default settings for the channels to [defaults]. Tools
+ which should be started from xawtv go to the [launch] section now.
+ Check the xawtv man page for more details.
+
+ * The command line options all have one dash only ('-debug'). Thats X11
+ style (like '-geometry' and '-font'), I will not switch to GNU style
+ options. xawtv uses the Xt options parser, this has the nice side
+ effect that there are X11 ressources now for all options, i.e. you
+ can turn them on permantly by adding entries to your .Xdefaults file.
+ [ FIXME: add them to the xawtv manpage ]
+
+ * The frequency tables are all renamed. I've removed the TV norm from
+ the name to avoid confusion. They are now named after regions,
+ optionally with "-bcast" or "-cable" appended to indicate if the table
+ is for cable TV or for broadcast.
+
+ * set-tv is gone, there is the more powerfull tool v4lctl instead.
+ Check the v4lctl man page for details.
+
+ * I've unbundled kradio and moved it (with a improved configure script)
+ into another tarball. It caused compile trouble often becauce it
+ requires KDE devel packages and a C++ compiler. People often hav'nt
+ found the '--disable-kradio' switch which fixes these problems :-(
+ The ncurses-based radio tool is still included.
+
+This file lists only changes which are not backward-compatible to the
+2.x versions. Check the Changes file for a more complete list.
diff --git a/Xawtv.ad b/Xawtv.ad
deleted file mode 100644
index 0ffb0c0..0000000
--- a/Xawtv.ad
+++ /dev/null
@@ -1,186 +0,0 @@
-! ----------------------------------------------------------------------------
-! general settings
-
-*beNiceToColormap: false
-*shadowWidth: 1
-*highlightThickness: 1
-
-*foreground: black
-*background: lightgray
-*font: 7x13bold
-*justify: left
-
-*menu.translations: #override \n\
- <Motion>: highlight()
-
-
-! ----------------------------------------------------------------------------
-! TV Window
-
-xawtv.tv.width: 384
-xawtv.tv.height: 288
-xawtv.winGravity: Static
-xawtv.translations: #override \n\
- <Message>WM_PROTOCOLS: CloseMain()
-
-xawtv.tv.background: black
-xawtv.tv.translations: #override \n\
- <Key>0: SetRes(audio,0) \n\
- <Key>1: SetRes(audio,1) \n\
- <Key>2: SetRes(audio,2) \n\
- <Key>3: SetRes(audio,3) \n\
- <Key>4: SetRes(audio,4) \n\
- <Key>F5: SetRes(bright,-512) \n\
- <Key>F6: SetRes(bright,+512) \n\
- <Key>F7: SetRes(hue,-512) \n\
- <Key>F8: SetRes(hue,+512) \n\
- <Key>F9: SetRes(contrast,-512) \n\
- <Key>F10: SetRes(contrast,+512) \n\
- <Key>F11: SetRes(color,-512) \n\
- <Key>F12: SetRes(color,+512) \n\
- <Key>C: Channels() \n\
- <Key>O: Options() \n\
- <Btn1Up>: Channel() \n\
- <Btn2Up>: SetChannel(next) \n\
- <Btn3Up>: Options() \n\
- <Key>Escape: CloseMain() \n\
- \
- <Key>Q: CloseMain() \n\
- <Key>KP_Add: Volume(inc) \n\
- <Key>KP_Subtract: Volume(dec) \n\
- <Key>KP_Enter: Volume(mute) \n\
- <Key>A: Volume(mute) \n\
- <Key>M: Pointer() \n\
- <Key>F: FullScreen() \n\
- Ctrl<Key>Z: Zap(fast) \n\
- <Key>Z: Zap() \n\
- Ctrl<Key>G: Snap(ppm,win) \n\
- Ctrl<Key>J: Snap(jpeg,win) \n\
- <Key>G: Snap(ppm,full) \n\
- <Key>J: Snap(jpeg,full) \n\
- Ctrl<Key>Up: Scan() \n\
- <Key>Up: Tune(next) \n\
- <Key>Down: Tune(prev) \n\
- <Key>Right: Tune(fine_up) \n\
- <Key>Left: Tune(fine_down) \n\
- <Key>Page_Up: SetChannel(next) \n\
- <Key>Page_Down: SetChannel(prev) \n\
- <Key>V: SetRes(capture,toggle)
-
-
-! ----------------------------------------------------------------------------
-! Options window
-
-Options.paned.internalBorderWidth: 0
-Options.paned*Scrollbar.orientation: horizontal
-Options.paned*Scrollbar.length: 150
-Options.paned*Scrollbar.width: 150
-Options.paned*Scrollbar.minimumThumb: 3
-
-Options.translations: #override \n\
- <Message>WM_PROTOCOLS: Options()
-
-Options*mute.label: Audio (un)mute A
-Options*ptr.label: Mouse Pointer on/off M
-Options*fs.label: Full Screen on/off F
-Options*grabppm.label: Grab Image (ppm) G
-Options*grabjpeg.label: Grab Image (jpeg) J
-Options*chanwin.label: Channel Window C
-Options*zap.label: Channel Hopping Z
-
-Options*cap.label: Capture >
-Options*norm.label: TV norm >
-Options*input.label: Video source >
-Options*freq.label: Frequency table >
-Options*audio.label: Audio >
-Options*quit.label: Quit Q
-
-Options*auto.label: autodetect
-Options*mono.label: mono
-Options*stereo.label: stereo
-Options*lang1.label: Language 1
-Options*lang2.label: Language 2
-
-Options*bright.l.label: Bright
-Options*hue.l.label: Hue
-Options*contrast.l.label: Contrast
-Options*color.l.label: Color
-Options*volume.l.label: Volume
-
-Options.paned.translations: #override\n\
- <Key>Escape: Options() \n\
- \
- <Key>Q: CloseMain() \n\
- <Key>KP_Add: Volume(inc) \n\
- <Key>KP_Subtract: Volume(dec) \n\
- <Key>KP_Enter: Volume(mute) \n\
- <Key>A: Volume(mute) \n\
- <Key>M: Pointer() \n\
- <Key>F: FullScreen() \n\
- Ctrl<Key>Z: Zap(fast) \n\
- <Key>Z: Zap() \n\
- Ctrl<Key>G: Snap(ppm,win) \n\
- Ctrl<Key>J: Snap(jpeg,win) \n\
- <Key>G: Snap(ppm,full) \n\
- <Key>J: Snap(jpeg,full) \n\
- Ctrl<Key>Up: Scan() \n\
- <Key>Up: Tune(next) \n\
- <Key>Down: Tune(prev) \n\
- <Key>Right: Tune(fine_up) \n\
- <Key>Left: Tune(fine_down) \n\
- <Key>Page_Up: SetChannel(next) \n\
- <Key>Page_Down: SetChannel(prev) \n\
- <Key>V: SetRes(capture,toggle)
-
-! ----------------------------------------------------------------------------
-! Channel window
-
-Channels.viewport.useRight: true
-Channels.viewport.channelbox.hSpace: 0
-Channels.viewport.channelbox.vSpace: 0
-Channels.viewport.channelbox.background: black
-Channels.viewport.channelbox.Command.shadowWidth: 0
-Channels.viewport.channelbox.Command.justify: center
-Channels.viewport.channelbox.Command.foreground: yellow
-Channels.viewport.channelbox.Command.background: black
-
-Channels.viewport.translations: #override\n\
- <Key>Escape: Channels() \n\
- \
- <Key>Q: CloseMain() \n\
- <Key>KP_Add: Volume(inc) \n\
- <Key>KP_Subtract: Volume(dec) \n\
- <Key>KP_Enter: Volume(mute) \n\
- <Key>A: Volume(mute) \n\
- <Key>M: Pointer() \n\
- <Key>F: FullScreen() \n\
- Ctrl<Key>Z: Zap(fast) \n\
- <Key>Z: Zap() \n\
- Ctrl<Key>G: Snap(ppm,win) \n\
- Ctrl<Key>J: Snap(jpeg,win) \n\
- <Key>G: Snap(ppm,full) \n\
- <Key>J: Snap(jpeg,full) \n\
- Ctrl<Key>Up: Scan() \n\
- <Key>Up: Tune(next) \n\
- <Key>Down: Tune(prev) \n\
- <Key>Right: Tune(fine_up) \n\
- <Key>Left: Tune(fine_down) \n\
- <Key>Page_Up: SetChannel(next) \n\
- <Key>Page_Down: SetChannel(prev) \n\
- <Key>V: SetRes(capture,toggle)
-
-! ----------------------------------------------------------------------------
-! Onscreen window
-
-xawtv.onscreen.allowShellResize: true
-xawtv.onscreen.label.resize: true
-
-xawtv.onscreen*background: black
-xawtv.onscreen*borderColor: black
-xawtv.onscreen*foreground: lightgreen
-xawtv.onscreen*shadowWidth: 0
-xawtv.onscreen.label.justify: left
-xawtv.onscreen.label.font: -*-ledfixed-medium-r-semicondensed--39-*
-
-! ----------------------------------------------------------------------------
-
diff --git a/acconfig.h b/acconfig.h
index cfacfb0..334dcef 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -1,8 +1,8 @@
-/* use kernel include (videodev.h) */
-#undef USE_KERNEL_VIDEODEV
-
/* MIT shared memory extention */
#undef HAVE_MITSHM
/* jpeg lib */
#undef HAVE_LIBJPEG
+
+/* lirc lib */
+#undef HAVE_LIBLIRC_CLIENT
diff --git a/bttv/doc/ICs b/bttv/doc/ICs
deleted file mode 100644
index 5c4c74e..0000000
--- a/bttv/doc/ICs
+++ /dev/null
@@ -1,37 +0,0 @@
-all boards:
-
-Brooktree Bt848KPF: video capture chip
-
-
-
-Miro PCTV:
-
-Philips or Temic Tuner
-
-
-
-Hauppauge Win/TV pci (version 405):
-
-Microchip 24LC02B or
-Philips 8582E2Y: 256 Byte EEPROM with configuration information
- I2C 0xa0-0xa1, (24LC02B also responds to 0xa2-0xaf)
-Philips SAA5246AGP/E: Videotext decoder chip, I2C 0x22-0x23
-TDA9800: sound decoder
-Winbond W24257AS-35: 32Kx8 CMOS static RAM (Videotext buffer mem)
-14052B: analog switch for selection of sound source
-
-PAL:
-TDA5737: VHF, hyperband and UHF mixer/oscillator for TV and VCR 3-band tuners
-TSA5522: 1.4 GHz I2C-bus controlled synthesizer, I2C 0xc2-0xc3
-
-NTSC:
-TDA5731: VHF, hyperband and UHF mixer/oscillator for TV and VCR 3-band tuners
-TSA5518: no datasheet available on Philips site
-
-
-
-STB TV pci:
-
-???
-if you want better support for STB cards send me info!
-Look at the board! What chips are on it?
diff --git a/bttv/doc/PROBLEMS b/bttv/doc/PROBLEMS
deleted file mode 100644
index 6148f85..0000000
--- a/bttv/doc/PROBLEMS
+++ /dev/null
@@ -1,62 +0,0 @@
-- Start capturing by pressing "c" or by selecting it via a menu!
-
-- Start capturing by pressing "c" or by selecting it via a menu!!!
-
-- The memory of some S3 cards is not recognized right:
-
- First of all, if you are not using Xfree-3.2 or newer, upgrade AT LEAST to
- XFree-3.2A! This solved the problem for most people.
-
- Start up X11 like this: "XF86_S3 -probeonly" and write down where the
- linear frame buffer is.
- If it is different to the address found by bttv install bttv like this:
- "insmod bttv vidmem=0xfb0"
- if the linear frame buffer is at 0xfb000000 (i.e. omit the last 5 zeros!)
-
- Some S3 cards even take up 64MB of memory but only report 32MB to the BIOS.
- If this 64MB area overlaps the IO memory of the Bt848 you also have to
- remap this. E.g.: insmod bttv vidmem=0xfb0 remap=0xfa0
-
- If the videomemory is found at the right place and there are no address
- conflicts but still no picture (or the computer even crashes.),
- try disabling features of your PCI chipset in the BIOS Setup.
-
- Frank Kapahnke <frank@kapahnke.prima.ruhr.de> also reported that problems
- with his S3 868 went away when he upgraded to XFree 3.2.
-
-
-- I still only get a black picture with my S3 card!
-
- Even with XFree-3.2A some people have problems with their S3 cards
- (mostly with Trio 64 but also with some others)
- Get the free demo version of Accelerated X from www.xinside.com and try
- bttv with it. bttv seems to work with most S3 cards with Accelerated X.
-
- Since I do not know much (better make that almost nothing) about VGA card
- programming I do not know the reason for this.
- Looks like XFree does something different when setting up the video memory?
- Maybe somebody can enlighten me?
- Would be nice if somebody could get this to work with XFree since
- Accelerated X costs more than some of the grabber cards ...
-
- Better linear frame buffer support for S3 cards will probably be in
- XFree 4.0.
-
-- Grabbing is not switched off when changing consoles with XFree.
- That's because XFree and some AcceleratedX versions do not send unmap
- events.
-
-- Some popup windows (e.g. of the window manager) are not refreshed.
-
- Disable backing store by starting X with the option "-bs"
-
-- When using 32bpp in XFree or 24+8bpp mode in AccelX 3.1 the system
- can sometimes lock up if you use more than 1 bt848 card at the same time.
- You will always get pixel errors when e.g. using more than 1 card in full
- screen mode. Maybe we need something faster than the PCI bus ...
-
-
-- Some S3 cards and the Matrox Mystique will produce pixel erros with
- full resolution in 32bit mode.
-
-- Some video cards have problems with Accelerated X 4.1 \ No newline at end of file
diff --git a/bttv/doc/README.Hauppauge b/bttv/doc/README.Hauppauge
deleted file mode 100644
index 0076ed8..0000000
--- a/bttv/doc/README.Hauppauge
+++ /dev/null
@@ -1,29 +0,0 @@
-The current I2C-Code could by accident overwrite the configuration EEPROM on
-Hauppauge boards!!!
-(E.g. the videotext driver and the bt848 driver do not know about each other.
-This might cause unwanted states on the I2C bus which overwrite the EEPROM)
-
-Back up this EEPROM before doing anything else by typing:
-(do this AFTER installing bttv.o with "make ins" but BEFORE starting the
-X application)
-
-make readee
-readee > tvee.h
-
-If you encounter any problems in Windows95 (like "PNP component not found" ...)
-go back into linux, load bttv and type:
-
-make writeee
-writeee
-
-to write the backed up contents.
-If you backed up your EEPROM as described above, this will restore it to its
-original state.
-A detailed description of the meaning of the EEPROM bytes by
-Hauppauge would of course be even more helpful!
-
-If you have board type 405 and you did not make a backup, my tvee.h file in
-mytvee.h might be of help.
-
-Forget about all of the above if you do not have a Hauppauge board.
-
diff --git a/bttv/doc/README.MIRO b/bttv/doc/README.MIRO
deleted file mode 100644
index e74fc4a..0000000
--- a/bttv/doc/README.MIRO
+++ /dev/null
@@ -1,3 +0,0 @@
-The right tuner type should automatically be detected.
-Look in your kernel log files to see which one bttv thinks it is.
-
diff --git a/bttv/doc/README.PCI b/bttv/doc/README.PCI
deleted file mode 100644
index 1ae8276..0000000
--- a/bttv/doc/README.PCI
+++ /dev/null
@@ -1,36 +0,0 @@
-Because some people were asking about the bandwidth the Bt848 might use up
-on the PCI bus I did a little benchmark.
-
-"bonnie -s 200" with a Fireball TM 3.8 Gb using Busmaster DMA on an ASUS P6NP5
-
-without capturing:
-
- -------Sequential Output-------- ---Sequential Input-- --Random--
- -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---
-Machine MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU /sec %CPU
- 200 5353 76.6 5898 16.9 2363 12.1 5889 51.3 6416 10.2 37.8 0.9
-
-
-while capturing full screen PAL (786x576) with 24bpp:
-
- -------Sequential Output-------- ---Sequential Input-- --Random--
- -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---
-Machine MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU /sec %CPU
- 200 5619 69.3 5939 16.9 2334 12.0 5859 50.9 6441 10.5 37.9 0.9
-
-The differences are small and probably within the normal error margin of
-bonnie.
-So, one bt848 card does not have much(any?) impact on the normal operation
-of a Linux system.
-If you have several cards running this will look very differently!
-The same is probably true if your Linux box is used as a file server
-with 15 (or 30) SCSI drives.
-
-I tested having 2 Bt848 cards grabbing in 32 bit mode (That's almost 100MB/s!)
-while running bonnie.
-The xtvscreen windows showed severe pixel errors.
-After a while the ide driver failed to use DMA and switched DMA off.
-It continued running but the results where bad.
-
-
-
diff --git a/bttv/doc/README.RADIO b/bttv/doc/README.RADIO
deleted file mode 100644
index 53d04f5..0000000
--- a/bttv/doc/README.RADIO
+++ /dev/null
@@ -1,15 +0,0 @@
-Support is in now:
- - Turn on the "big red switch" of the sound processor.
- - two ioctls to access (some) registers of the sound processor.
- - a function in the TV-Widget which monitors the signal quality
- and does the mono/stereo switching.
-
-So you should have TV with (stereo) sound now. Radio does _not_ work.
-It probably does not work with sat receivers. I can't test this and
-therefore hav'nt added support for it yet. If someone needs this and
-can help testing the sat stuff, drop me a note.
-
- Gerd
-
---
-Gerd Knorr <kraxel@cs.tu-berlin.de>
diff --git a/bttv/driver/MODULES b/bttv/driver/MODULES
deleted file mode 100644
index 161e68b..0000000
--- a/bttv/driver/MODULES
+++ /dev/null
@@ -1,61 +0,0 @@
-
-There are quite lot modules out here...
-
-videodev.o
- this is the basic video4linux module, all video
- drivers (incl. bttv) register themself here.
-
-i2c.o
- the generic i2c module. It does much of the i2c bus
- management, all other modules (except videodev.o)
- use this one
-
- insmod args:
- scan=1 scan the whole bus for i2c devices
- verbose=0 shut up i2c
- i2c_debug=1 for debugging, it sticks the whole
- (software) i2c bus traffic to the
- syslog
-
-bttv.o
- the bt848 (grabber chip) driver
-
- insmod args:
- remap=adr remap Bt848 memory to adr<<20
- vidmem=base frame buffer address>>20 (of graphic card)
- triton1=0/1 for Triton1 compatibility
- Triton1 is automatically recognized
- but this might also help with other chipsets
-
-msp3400.o
- The driver for the msp3400c sound proccesor. If you have a
- stereo card, you probably want to insmod this one.
-
- insmod args:
- debug=1 print some debug info to the syslog
-
-tuner.o
- The tuner driver. You need this unless you want to use only
- with a camera or external tuner ...
-
- insmod args:
- debug=1 print some debug info to the syslog
- type=n type of the tuner chip. n as follows:
- 0: Temic PAL tuner
- 1: Philips PAL_I tuner
- 2: Philips NTSC tuner
- 3: Philips SECAM tuner
- 4: no tuner
- 5: Philips PAL tuner
- 6: Temic NTSC tuner
- 7: Temic PAL tuner
-
-
-You can't load the i2c chip driver modules (tuner,msp3400) with kerneld,
-you should modprobe them within a boot script.
-
-NEW: Well, you can't without a kernel patch. There is a tiny kernel patch
- for 2.0.33. With the request_module() in bttv.c enabled (you have to
- change a "#if 0" to "#if 1" at the end of bttv.c) and a patched kernel
- loading _all_ the modules on demand works just fine.
-
diff --git a/bttv/driver/Makefile b/bttv/driver/Makefile
deleted file mode 100644
index afe08bd..0000000
--- a/bttv/driver/Makefile
+++ /dev/null
@@ -1,58 +0,0 @@
-#################################################
-# config
-
-# 0: Temic PAL tuner
-# 1: Philips PAL_I tuner
-# 2: Philips NTSC tuner
-# 3: Philips SECAM tuner
-# 4: no tuner
-# 5: Philips PAL tuner
-# 6: Temic NTSC tuner
-# 7: Temic PAL tuner
-TUNER=0
-
-# 0: Auto-Detect
-# 1: Miro
-# 2: Hauppauge
-# 3: STB
-# 4: Intel
-# 5: Diamond
-# 6: AVerMedia
-# 7: MATRIX Vision MV-Delta
-# 8: FlyVideo
-CARD=0
-
-# Official major device number is 81
-# Older kernels might have problems with such high numbers.
-# But I rather recommend updating to kernel 2.0.31 or higher.
-BTTV_MAJOR=81
-
-# currently running kernel
-CURRENT=$(shell uname -r)
-
-# where the kernel sources are located
-#KERNEL_LOCATION=/usr/src/kernel/$(CURRENT)
-#KERNEL_LOCATION=/usr/src/kernel/vger
-KERNEL_LOCATION=/usr/src/linux
-
-
-#################################################
-# some magic for using linux kernel settings
-# when compiling module(s)
-
-M_OBJS = bttv.o msp3400.o tuner.o #i2c_chardev.o
-MX_OBJS = i2c.o videodev.o
-EXTRA_CFLAGS = -DTUNER_DEFAULT=$(TUNER) -DCARD_DEFAULT=$(CARD) \
- -DBTTV_MAJOR=$(BTTV_MAJOR) $(INTERFACE) #-DUSE_PLL
-
-here:
- DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR modules)
-
-install:
- su -c "cp -v $(M_OBJS) $(MX_OBJS) /lib/modules/$(CURRENT)/misc"
-
-clean:
- -rm -f $(M_OBJS) $(MX_OBJS) .*.o.flags *~
-
-include $(KERNEL_LOCATION)/Rules.make
-
diff --git a/bttv/driver/bt848.h b/bttv/driver/bt848.h
deleted file mode 100644
index 0956360..0000000
--- a/bttv/driver/bt848.h
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- bt848.h - Bt848 register offsets
-
- Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _BT848_H_
-#define _BT848_H_
-
-#ifndef PCI_VENDOR_ID_BROOKTREE
-#define PCI_VENDOR_ID_BROOKTREE 0x109e
-#endif
-#ifndef PCI_DEVICE_ID_BT848
-#define PCI_DEVICE_ID_BT848 0x350
-#endif
-#ifndef PCI_DEVICE_ID_BT849
-#define PCI_DEVICE_ID_BT849 0x351
-#endif
-#ifndef PCI_DEVICE_ID_BT878
-#define PCI_DEVICE_ID_BT878 0x36e
-#endif
-#ifndef PCI_DEVICE_ID_BT879
-#define PCI_DEVICE_ID_BT879 0x36f
-#endif
-
-
-/* Brooktree 848 registers */
-
-#define BT848_DSTATUS 0x000
-#define BT848_DSTATUS_PRES (1<<7)
-#define BT848_DSTATUS_HLOC (1<<6)
-#define BT848_DSTATUS_FIELD (1<<5)
-#define BT848_DSTATUS_NUML (1<<4)
-#define BT848_DSTATUS_CSEL (1<<3)
-#define BT848_DSTATUS_PLOCK (1<<2)
-#define BT848_DSTATUS_LOF (1<<1)
-#define BT848_DSTATUS_COF (1<<0)
-
-#define BT848_IFORM 0x004
-#define BT848_IFORM_HACTIVE (1<<7)
-#define BT848_IFORM_MUXSEL (3<<5)
-#define BT848_IFORM_MUX0 (2<<5)
-#define BT848_IFORM_MUX1 (3<<5)
-#define BT848_IFORM_MUX2 (1<<5)
-#define BT848_IFORM_XTSEL (3<<3)
-#define BT848_IFORM_XT0 (1<<3)
-#define BT848_IFORM_XT1 (2<<3)
-#define BT848_IFORM_XTAUTO (3<<3)
-#define BT848_IFORM_XTBOTH (3<<3)
-#define BT848_IFORM_NTSC 1
-#define BT848_IFORM_NTSC_J 2
-#define BT848_IFORM_PAL_BDGHI 3
-#define BT848_IFORM_PAL_M 4
-#define BT848_IFORM_PAL_N 5
-#define BT848_IFORM_SECAM 6
-#define BT848_IFORM_PAL_NC 7
-#define BT848_IFORM_AUTO 0
-#define BT848_IFORM_NORM 7
-
-#define BT848_TDEC 0x008
-#define BT848_TDEC_DEC_FIELD (1<<7)
-#define BT848_TDEC_FLDALIGN (1<<6)
-#define BT848_TDEC_DEC_RAT (0x1f)
-
-#define BT848_E_CROP 0x00C
-#define BT848_O_CROP 0x08C
-
-#define BT848_E_VDELAY_LO 0x010
-#define BT848_O_VDELAY_LO 0x090
-
-#define BT848_E_VACTIVE_LO 0x014
-#define BT848_O_VACTIVE_LO 0x094
-
-#define BT848_E_HDELAY_LO 0x018
-#define BT848_O_HDELAY_LO 0x098
-
-#define BT848_E_HACTIVE_LO 0x01C
-#define BT848_O_HACTIVE_LO 0x09C
-
-#define BT848_E_HSCALE_HI 0x020
-#define BT848_O_HSCALE_HI 0x0A0
-
-#define BT848_E_HSCALE_LO 0x024
-#define BT848_O_HSCALE_LO 0x0A4
-
-#define BT848_BRIGHT 0x028
-
-#define BT848_E_CONTROL 0x02C
-#define BT848_O_CONTROL 0x0AC
-#define BT848_CONTROL_LNOTCH (1<<7)
-#define BT848_CONTROL_COMP (1<<6)
-#define BT848_CONTROL_LDEC (1<<5)
-#define BT848_CONTROL_CBSENSE (1<<4)
-#define BT848_CONTROL_CON_MSB (1<<2)
-#define BT848_CONTROL_SAT_U_MSB (1<<1)
-#define BT848_CONTROL_SAT_V_MSB (1<<0)
-
-#define BT848_CONTRAST_LO 0x030
-#define BT848_SAT_U_LO 0x034
-#define BT848_SAT_V_LO 0x038
-#define BT848_HUE 0x03C
-
-#define BT848_E_SCLOOP 0x040
-#define BT848_O_SCLOOP 0x0C0
-#define BT848_SCLOOP_CAGC (1<<6)
-#define BT848_SCLOOP_CKILL (1<<5)
-#define BT848_SCLOOP_HFILT_AUTO (0<<3)
-#define BT848_SCLOOP_HFILT_CIF (1<<3)
-#define BT848_SCLOOP_HFILT_QCIF (2<<3)
-#define BT848_SCLOOP_HFILT_ICON (3<<3)
-
-#define BT848_SCLOOP_PEAK (1<<7)
-#define BT848_SCLOOP_HFILT_MINP (1<<3)
-#define BT848_SCLOOP_HFILT_MEDP (2<<3)
-#define BT848_SCLOOP_HFILT_MAXP (3<<3)
-
-
-#define BT848_OFORM 0x048
-#define BT848_OFORM_RANGE (1<<7)
-#define BT848_OFORM_CORE0 (0<<5)
-#define BT848_OFORM_CORE8 (1<<5)
-#define BT848_OFORM_CORE16 (2<<5)
-#define BT848_OFORM_CORE32 (3<<5)
-
-#define BT848_E_VSCALE_HI 0x04C
-#define BT848_O_VSCALE_HI 0x0CC
-#define BT848_VSCALE_YCOMB (1<<7)
-#define BT848_VSCALE_COMB (1<<6)
-#define BT848_VSCALE_INT (1<<5)
-#define BT848_VSCALE_HI 15
-
-#define BT848_E_VSCALE_LO 0x050
-#define BT848_O_VSCALE_LO 0x0D0
-#define BT848_TEST 0x054
-#define BT848_ADELAY 0x060
-#define BT848_BDELAY 0x064
-
-#define BT848_ADC 0x068
-#define BT848_ADC_RESERVED (2<<6)
-#define BT848_ADC_SYNC_T (1<<5)
-#define BT848_ADC_AGC_EN (1<<4)
-#define BT848_ADC_CLK_SLEEP (1<<3)
-#define BT848_ADC_Y_SLEEP (1<<2)
-#define BT848_ADC_C_SLEEP (1<<1)
-#define BT848_ADC_CRUSH (1<<0)
-
-#define BT848_E_VTC 0x06C
-#define BT848_O_VTC 0x0EC
-#define BT848_VTC_HSFMT (1<<7)
-#define BT848_VTC_VFILT_2TAP 0
-#define BT848_VTC_VFILT_3TAP 1
-#define BT848_VTC_VFILT_4TAP 2
-#define BT848_VTC_VFILT_5TAP 3
-
-#define BT848_SRESET 0x07C
-
-#define BT848_COLOR_FMT 0x0D4
-#define BT848_COLOR_FMT_O_RGB32 (0<<4)
-#define BT848_COLOR_FMT_O_RGB24 (1<<4)
-#define BT848_COLOR_FMT_O_RGB16 (2<<4)
-#define BT848_COLOR_FMT_O_RGB15 (3<<4)
-#define BT848_COLOR_FMT_O_YUY2 (4<<4)
-#define BT848_COLOR_FMT_O_BtYUV (5<<4)
-#define BT848_COLOR_FMT_O_Y8 (6<<4)
-#define BT848_COLOR_FMT_O_RGB8 (7<<4)
-#define BT848_COLOR_FMT_O_YCrCb422 (8<<4)
-#define BT848_COLOR_FMT_O_YCrCb411 (9<<4)
-#define BT848_COLOR_FMT_O_RAW (14<<4)
-#define BT848_COLOR_FMT_E_RGB32 0
-#define BT848_COLOR_FMT_E_RGB24 1
-#define BT848_COLOR_FMT_E_RGB16 2
-#define BT848_COLOR_FMT_E_RGB15 3
-#define BT848_COLOR_FMT_E_YUY2 4
-#define BT848_COLOR_FMT_E_BtYUV 5
-#define BT848_COLOR_FMT_E_Y8 6
-#define BT848_COLOR_FMT_E_RGB8 7
-#define BT848_COLOR_FMT_E_YCrCb422 8
-#define BT848_COLOR_FMT_E_YCrCb411 9
-#define BT848_COLOR_FMT_E_RAW 14
-
-#define BT848_COLOR_FMT_RGB32 0x00
-#define BT848_COLOR_FMT_RGB24 0x11
-#define BT848_COLOR_FMT_RGB16 0x22
-#define BT848_COLOR_FMT_RGB15 0x33
-#define BT848_COLOR_FMT_YUY2 0x44
-#define BT848_COLOR_FMT_BtYUV 0x55
-#define BT848_COLOR_FMT_Y8 0x66
-#define BT848_COLOR_FMT_RGB8 0x77
-#define BT848_COLOR_FMT_YCrCb422 0x88
-#define BT848_COLOR_FMT_YCrCb411 0x99
-#define BT848_COLOR_FMT_RAW 0xee
-
-#define BT848_COLOR_CTL 0x0D8
-#define BT848_COLOR_CTL_EXT_FRMRATE (1<<7)
-#define BT848_COLOR_CTL_COLOR_BARS (1<<6)
-#define BT848_COLOR_CTL_RGB_DED (1<<5)
-#define BT848_COLOR_CTL_GAMMA (1<<4)
-#define BT848_COLOR_CTL_WSWAP_ODD (1<<3)
-#define BT848_COLOR_CTL_WSWAP_EVEN (1<<2)
-#define BT848_COLOR_CTL_BSWAP_ODD (1<<1)
-#define BT848_COLOR_CTL_BSWAP_EVEN (1<<0)
-
-#define BT848_CAP_CTL 0x0DC
-#define BT848_CAP_CTL_DITH_FRAME (1<<4)
-#define BT848_CAP_CTL_CAPTURE_VBI_ODD (1<<3)
-#define BT848_CAP_CTL_CAPTURE_VBI_EVEN (1<<2)
-#define BT848_CAP_CTL_CAPTURE_ODD (1<<1)
-#define BT848_CAP_CTL_CAPTURE_EVEN (1<<0)
-
-#define BT848_VBI_PACK_SIZE 0x0E0
-
-#define BT848_VBI_PACK_DEL 0x0E4
-#define BT848_VBI_PACK_DEL_VBI_HDELAY 0xfc
-#define BT848_VBI_PACK_DEL_EXT_FRAME 2
-#define BT848_VBI_PACK_DEL_VBI_PKT_HI 1
-
-
-#define BT848_INT_STAT 0x100
-#define BT848_INT_MASK 0x104
-
-#define BT848_INT_ETBF (1<<23)
-
-#define BT848_INT_RISCS (0xf<<28)
-#define BT848_INT_RISC_EN (1<<27)
-#define BT848_INT_RACK (1<<25)
-#define BT848_INT_FIELD (1<<24)
-#define BT848_INT_SCERR (1<<19)
-#define BT848_INT_OCERR (1<<18)
-#define BT848_INT_PABORT (1<<17)
-#define BT848_INT_RIPERR (1<<16)
-#define BT848_INT_PPERR (1<<15)
-#define BT848_INT_FDSR (1<<14)
-#define BT848_INT_FTRGT (1<<13)
-#define BT848_INT_FBUS (1<<12)
-#define BT848_INT_RISCI (1<<11)
-#define BT848_INT_GPINT (1<<9)
-#define BT848_INT_I2CDONE (1<<8)
-#define BT848_INT_VPRES (1<<5)
-#define BT848_INT_HLOCK (1<<4)
-#define BT848_INT_OFLOW (1<<3)
-#define BT848_INT_HSYNC (1<<2)
-#define BT848_INT_VSYNC (1<<1)
-#define BT848_INT_FMTCHG (1<<0)
-
-
-#define BT848_GPIO_DMA_CTL 0x10C
-#define BT848_GPIO_DMA_CTL_GPINTC (1<<15)
-#define BT848_GPIO_DMA_CTL_GPINTI (1<<14)
-#define BT848_GPIO_DMA_CTL_GPWEC (1<<13)
-#define BT848_GPIO_DMA_CTL_GPIOMODE (3<<11)
-#define BT848_GPIO_DMA_CTL_GPCLKMODE (1<<10)
-#define BT848_GPIO_DMA_CTL_PLTP23_4 (0<<6)
-#define BT848_GPIO_DMA_CTL_PLTP23_8 (1<<6)
-#define BT848_GPIO_DMA_CTL_PLTP23_16 (2<<6)
-#define BT848_GPIO_DMA_CTL_PLTP23_32 (3<<6)
-#define BT848_GPIO_DMA_CTL_PLTP1_4 (0<<4)
-#define BT848_GPIO_DMA_CTL_PLTP1_8 (1<<4)
-#define BT848_GPIO_DMA_CTL_PLTP1_16 (2<<4)
-#define BT848_GPIO_DMA_CTL_PLTP1_32 (3<<4)
-#define BT848_GPIO_DMA_CTL_PKTP_4 (0<<2)
-#define BT848_GPIO_DMA_CTL_PKTP_8 (1<<2)
-#define BT848_GPIO_DMA_CTL_PKTP_16 (2<<2)
-#define BT848_GPIO_DMA_CTL_PKTP_32 (3<<2)
-#define BT848_GPIO_DMA_CTL_RISC_ENABLE (1<<1)
-#define BT848_GPIO_DMA_CTL_FIFO_ENABLE (1<<0)
-
-#define BT848_I2C 0x110
-#define BT848_I2C_DIV (0xf<<4)
-#define BT848_I2C_SYNC (1<<3)
-#define BT848_I2C_W3B (1<<2)
-#define BT848_I2C_SCL (1<<1)
-#define BT848_I2C_SDA (1<<0)
-
-
-#define BT848_RISC_STRT_ADD 0x114
-#define BT848_GPIO_OUT_EN 0x118
-#define BT848_GPIO_REG_INP 0x11C
-#define BT848_RISC_COUNT 0x120
-#define BT848_GPIO_DATA 0x200
-
-
-/* Bt848 RISC commands */
-
-/* only for the SYNC RISC command */
-#define BT848_FIFO_STATUS_FM1 0x06
-#define BT848_FIFO_STATUS_FM3 0x0e
-#define BT848_FIFO_STATUS_SOL 0x02
-#define BT848_FIFO_STATUS_EOL4 0x01
-#define BT848_FIFO_STATUS_EOL3 0x0d
-#define BT848_FIFO_STATUS_EOL2 0x09
-#define BT848_FIFO_STATUS_EOL1 0x05
-#define BT848_FIFO_STATUS_VRE 0x04
-#define BT848_FIFO_STATUS_VRO 0x0c
-#define BT848_FIFO_STATUS_PXV 0x00
-
-#define BT848_RISC_RESYNC (1<<15)
-
-/* WRITE and SKIP */
-/* disable which bytes of each DWORD */
-#define BT848_RISC_BYTE0 (1<<12)
-#define BT848_RISC_BYTE1 (1<<13)
-#define BT848_RISC_BYTE2 (1<<14)
-#define BT848_RISC_BYTE3 (1<<15)
-#define BT848_RISC_BYTE_ALL (0x0f<<12)
-#define BT848_RISC_BYTE_NONE 0
-/* cause RISCI */
-#define BT848_RISC_IRQ (1<<24)
-/* RISC command is last one in this line */
-#define BT848_RISC_EOL (1<<26)
-/* RISC command is first one in this line */
-#define BT848_RISC_SOL (1<<27)
-
-#define BT848_RISC_WRITE (0x01<<28)
-#define BT848_RISC_SKIP (0x02<<28)
-#define BT848_RISC_WRITEC (0x05<<28)
-#define BT848_RISC_JUMP (0x07<<28)
-#define BT848_RISC_SYNC (0x08<<28)
-
-#define BT848_RISC_WRITE123 (0x09<<28)
-#define BT848_RISC_SKIP123 (0x0a<<28)
-#define BT848_RISC_WRITE1S23 (0x0b<<28)
-
-
-
-/* Bt848A and Bt849 only !! */
-#define BT848_TGLB 0x080
-#define BT848_TGCTRL 0x084
-#define BT848_FCAP 0x0E8
-#define BT848_PLL_F_LO 0x0F0
-#define BT848_PLL_F_HI 0x0F4
-#define BT848_PLL_XCI 0x0F8
-
-
-#endif
diff --git a/bttv/driver/bttv.c b/bttv/driver/bttv.c
deleted file mode 100644
index 7d1185b..0000000
--- a/bttv/driver/bttv.c
+++ /dev/null
@@ -1,3300 +0,0 @@
-/*
- bttv - Bt848 frame grabber driver
-
- Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
- & Marcus Metzler (mocm@thp.uni-koeln.de)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Modified to put the RISC code writer in the kernel and to fit a
- common (and I hope safe) kernel interface. When we have an X extension
- all will now be really sweet.
-
- TODO:
-
- * move norm from tuner to channel struct!?
- composite source from a satellite tuner can deliver different norms
- depending on tuned channel
- * mmap VBI data?
- * use new PCI routines
- * fix RAW Composite grabbing for NTSC
- * allow for different VDELAYs
- (larger to get Videodat in VBI and smaller to get the whole
- picture in RAW grabbing)
- * extra modules for tda9850, tda8425, any volunteers???
- * right border clipping is still buggy
- (decide which clipping code to use and throw the other out ...)
-*/
-
-#include <linux/module.h>
-#include <linux/bios32.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/kernel.h>
-#include <linux/major.h>
-#include <linux/malloc.h>
-#include <linux/mm.h>
-#include <linux/pci.h>
-#include <linux/signal.h>
-#include <asm/io.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <linux/sched.h>
-#include <asm/segment.h>
-#include <linux/types.h>
-#include <linux/wrapper.h>
-
-#include "videodev.h"
-#include <linux/version.h>
-#if LINUX_VERSION_CODE >= 0x020100
-#include <asm/uaccess.h>
-#else
-#define signal_pending(current) (current->signal & ~current->blocked)
-#define sigfillset(set)
-
-static inline unsigned long
-copy_to_user(void *to, const void *from, unsigned long n)
-{
- memcpy_tofs(to,from,n);
- return 0;
-}
-
-static inline unsigned long
-copy_from_user(void *to, const void *from, unsigned long n)
-{
- memcpy_fromfs(to,from,n);
- return 0;
-}
-#define ioremap vremap
-#define iounmap vfree
-#endif
-
-#include "i2c.h"
-#include "bttv.h"
-#include "tuner.h"
-
-#define DEBUG(x) /* Debug driver */
-#define IDEBUG(x) /* Debug interrupt handler */
-
-#if LINUX_VERSION_CODE >= 0x020117
-MODULE_PARM(remap,"i");
-MODULE_PARM(vidmem,"i");
-MODULE_PARM(triton1,"i");
-MODULE_PARM(radio,"i");
-MODULE_PARM(card,"i");
-#endif
-
-static int find_vga(void);
-static void bt848_set_risc_jmps(struct bttv *btv);
-
-/* Anybody who uses more than four? */
-#define BTTV_MAX 4
-
-static unsigned int vidmem=0; /* manually set video mem address */
-static int triton1=0;
-
-static unsigned int remap[BTTV_MAX]; /* remap Bt848 */
-static unsigned int radio[BTTV_MAX];
-static unsigned int card[BTTV_MAX] = { CARD_DEFAULT };
-
-static int bttv_num; /* number of Bt848s in use */
-static struct bttv bttvs[BTTV_MAX];
-
-#define I2C_TIMING (0x7<<4)
-#define I2C_COMMAND (I2C_TIMING | BT848_I2C_SCL | BT848_I2C_SDA)
-
-#define I2C_DELAY 10
-#define I2C_SET(CTRL,DATA) \
- { btwrite((CTRL<<1)|(DATA), BT848_I2C); udelay(I2C_DELAY); }
-#define I2C_GET() (btread(BT848_I2C)&1)
-
-#define AUDIO_MUTE_DELAY 10000
-#define FREQ_CHANGE_DELAY 20000
-#define EEPROM_WRITE_DELAY 20000
-
-/*******************************/
-/* Memory management functions */
-/*******************************/
-
-/* convert virtual user memory address to physical address */
-/* (virt_to_phys only works for kmalloced kernel memory) */
-
-static inline unsigned long uvirt_to_phys(unsigned long adr)
-{
- pgd_t *pgd;
- pmd_t *pmd;
- pte_t *ptep, pte;
-
- pgd = pgd_offset(current->mm, adr);
- if (pgd_none(*pgd))
- return 0;
- pmd = pmd_offset(pgd, adr);
- if (pmd_none(*pmd))
- return 0;
- ptep = pte_offset(pmd, adr/*&(~PGDIR_MASK)*/);
- pte = *ptep;
- if(pte_present(pte))
- return
- virt_to_phys((void *)(pte_page(pte)|(adr&(PAGE_SIZE-1))));
- return 0;
-}
-
-static inline unsigned long uvirt_to_bus(unsigned long adr)
-{
- /* printk("adr: 0x%8x, ",adr);
- printk("phys: 0x%8x, ",(uvirt_to_phys(adr)));
- printk("bus: 0x%8x\n",virt_to_bus(phys_to_virt(uvirt_to_phys(adr))));
- */
- return virt_to_bus(phys_to_virt(uvirt_to_phys(adr)));
-}
-
-/* convert virtual kernel memory address to physical address */
-/* (virt_to_phys only works for kmalloced kernel memory) */
-
-static inline unsigned long kvirt_to_phys(unsigned long adr)
-{
- return uvirt_to_phys(VMALLOC_VMADDR(adr));
-}
-
-static inline unsigned long kvirt_to_bus(unsigned long adr)
-{
- return uvirt_to_bus(VMALLOC_VMADDR(adr));
-}
-
-static void * rvmalloc(unsigned long size)
-{
- void * mem;
- unsigned long adr, page;
-
- mem=vmalloc(size);
- if (mem)
- {
- adr=(unsigned long) mem;
- while (size > 0)
- {
- page = kvirt_to_phys(adr);
- mem_map_reserve(MAP_NR(phys_to_virt(page)));
- adr+=PAGE_SIZE;
- size-=PAGE_SIZE;
- }
- }
- return mem;
-}
-
-static void rvfree(void * mem, unsigned long size)
-{
- unsigned long adr, page;
-
- if (mem)
- {
- adr=(unsigned long) mem;
- while (size > 0)
- {
- page = kvirt_to_phys(adr);
- mem_map_unreserve(MAP_NR(phys_to_virt(page)));
- adr+=PAGE_SIZE;
- size-=PAGE_SIZE;
- }
- vfree(mem);
- }
-}
-
-/*
- * Create the giant waste of buffer space we need for now
- * until we get DMA to user space sorted out (probably 2.3.x)
- *
- * We only create this as and when someone uses mmap
- */
-
-static int fbuffer_alloc(struct bttv *btv)
-{
- if(!btv->fbuffer)
- btv->fbuffer=(unsigned char *) rvmalloc(2*BTTV_MAX_FBUF);
- else
- printk(KERN_ERR "bttv%d: Double alloc of fbuffer!\n",
- btv->nr);
- if(!btv->fbuffer)
- return -ENOBUFS;
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-/* I2C functions */
-
-/* software I2C functions */
-
-static void i2c_setlines(struct i2c_bus *bus,int ctrl,int data)
-{
- struct bttv *btv = (struct bttv*)bus->data;
- btwrite((ctrl<<1)|data, BT848_I2C);
- udelay(I2C_DELAY);
-}
-
-static int i2c_getdataline(struct i2c_bus *bus)
-{
- struct bttv *btv = (struct bttv*)bus->data;
- return btread(BT848_I2C)&1;
-}
-
-/* hardware I2C functions */
-
-/* read I2C */
-static int I2CRead(struct i2c_bus *bus, unsigned char addr)
-{
- u32 i;
- u32 stat;
- struct bttv *btv = (struct bttv*)bus->data;
-
- /* clear status bit ; BT848_INT_RACK is ro */
- btwrite(BT848_INT_I2CDONE, BT848_INT_STAT);
-
- btwrite(((addr & 0xff) << 24) | I2C_COMMAND, BT848_I2C);
-
- /*
- * Timeout for I2CRead is 1 second (this should be enough, really!)
- */
- for (i=1000; i; i--)
- {
- stat=btread(BT848_INT_STAT);
- if (stat & BT848_INT_I2CDONE)
- break;
-#if LINUX_VERSION_CODE >= 0x020199
- mdelay(1);
-#else
- udelay(1000);
-#endif
- }
-
- if (!i)
- {
- printk(KERN_DEBUG "bttv%d: I2CRead timeout\n",
- btv->nr);
- return -1;
- }
- if (!(stat & BT848_INT_RACK))
- return -2;
-
- i=(btread(BT848_I2C)>>8)&0xff;
- return i;
-}
-
-/* set both to write both bytes, reset it to write only b1 */
-
-static int I2CWrite(struct i2c_bus *bus, unsigned char addr, unsigned char b1,
- unsigned char b2, int both)
-{
- u32 i;
- u32 data;
- u32 stat;
- struct bttv *btv = (struct bttv*)bus->data;
-
- /* clear status bit; BT848_INT_RACK is ro */
- btwrite(BT848_INT_I2CDONE, BT848_INT_STAT);
-
- data=((addr & 0xff) << 24) | ((b1 & 0xff) << 16) | I2C_COMMAND;
- if (both)
- {
- data|=((b2 & 0xff) << 8);
- data|=BT848_I2C_W3B;
- }
-
- btwrite(data, BT848_I2C);
-
- for (i=0x1000; i; i--)
- {
- stat=btread(BT848_INT_STAT);
- if (stat & BT848_INT_I2CDONE)
- break;
-#if LINUX_VERSION_CODE >= 0x020199
- mdelay(1);
-#else
- udelay(1000);
-#endif
- }
-
- if (!i)
- {
- printk(KERN_DEBUG "bttv%d: I2CWrite timeout\n",
- btv->nr);
- return -1;
- }
- if (!(stat & BT848_INT_RACK))
- return -2;
-
- return 0;
-}
-
-/* read EEPROM */
-static void readee(struct i2c_bus *bus, unsigned char *eedata)
-{
- int i, k;
-
- if (I2CWrite(bus, 0xa0, 0, -1, 0)<0)
- {
- printk(KERN_WARNING "bttv: readee error\n");
- return;
- }
-
- for (i=0; i<256; i++)
- {
- k=I2CRead(bus, 0xa1);
- if (k<0)
- {
- printk(KERN_WARNING "bttv: readee error\n");
- break;
- }
- eedata[i]=k;
- }
-}
-
-/* write EEPROM */
-static void writeee(struct i2c_bus *bus, unsigned char *eedata)
-{
- int i;
-
- for (i=0; i<256; i++)
- {
- if (I2CWrite(bus, 0xa0, i, eedata[i], 1)<0)
- {
- printk(KERN_WARNING "bttv: writeee error (%d)\n", i);
- break;
- }
- udelay(EEPROM_WRITE_DELAY);
- }
-}
-
-void attach_inform(struct i2c_bus *bus, int id)
-{
- struct bttv *btv = (struct bttv*)bus->data;
- int tunertype;
-
- switch (id)
- {
- case I2C_DRIVERID_MSP3400:
- btv->have_msp3400 = 1;
- break;
- case I2C_DRIVERID_TUNER:
- btv->have_tuner = 1;
- if (btv->type == BTTV_MIRO)
- {
- tunertype=((btread(BT848_GPIO_DATA)>>10)-1)&7;
- i2c_control_device(&(btv->i2c), I2C_DRIVERID_TUNER,
- TUNER_SET_TYPE,&tunertype);
- }
- break;
- }
-}
-
-void detach_inform(struct i2c_bus *bus, int id)
-{
- struct bttv *btv = (struct bttv*)bus->data;
-
- switch (id)
- {
- case I2C_DRIVERID_MSP3400:
- btv->have_msp3400 = 0;
- break;
- case I2C_DRIVERID_TUNER:
- btv->have_tuner = 0;
- break;
- }
-}
-
-static struct i2c_bus bttv_i2c_bus_template =
-{
- "bt848",
- I2C_BUSID_BT848,
- NULL,
-
-#if LINUX_VERSION_CODE >= 0x020100
- SPIN_LOCK_UNLOCKED,
-#endif
-
- attach_inform,
- detach_inform,
-
- i2c_setlines,
- i2c_getdataline,
- I2CRead,
- I2CWrite,
-};
-
-/* ----------------------------------------------------------------------- */
-
-
-struct tvcard
-{
- int inputs;
- int tuner;
- int svhs;
- u32 gpiomask;
- u32 muxsel[8];
- u32 audiomux[6]; /* Tuner, Radio, internal, external, mute, stereo */
- u32 gpiomask2; /* GPIO MUX mask */
-};
-
-static struct tvcard tvcards[] =
-{
- /* default */
- { 3, 0, 2, 0, { 2, 3, 1, 1}, { 0, 0, 0, 0, 0}},
- /* MIRO */
- { 4, 0, 2,15, { 2, 3, 1, 1}, { 2, 0, 0, 0,10}},
- /* Hauppauge */
- { 3, 0, 2, 7, { 2, 3, 1, 1}, { 0, 1, 2, 3, 4}},
- /* STB */
- { 3, 0, 2, 7, { 2, 3, 1, 1}, { 4, 0, 2, 3, 1}},
- /* Intel??? */
- { 3, 0, 2, 7, { 2, 3, 1, 1}, { 0, 1, 2, 3, 4}},
- /* Diamond DTV2000 */
- { 3, 0, 2, 3, { 2, 3, 1, 1}, { 0, 1, 0, 1, 3}},
- /* AVerMedia TVPhone */
- { 3, 0, 2,15, { 2, 3, 1, 1}, {12, 0,11,11, 0}},
- /* Matrix Vision MV-Delta */
- { 5,-1, 3, 0, { 2, 3, 1, 0, 0}},
- /* Fly Video II */
- { 3, 0, 2, 0xc00, { 2, 3, 1, 1},
- {0, 0xc00, 0x800, 0x400, 0xc00, 0}},
-};
-#define TVCARDS (sizeof(tvcards)/sizeof(tvcard))
-
-static void audio(struct bttv *btv, int mode)
-{
- btaor(tvcards[btv->type].gpiomask, ~tvcards[btv->type].gpiomask,
- BT848_GPIO_OUT_EN);
-
- switch (mode)
- {
- case AUDIO_MUTE:
- btv->audio|=AUDIO_MUTE;
- break;
- case AUDIO_UNMUTE:
- btv->audio&=~AUDIO_MUTE;
- mode=btv->audio;
- break;
- case AUDIO_OFF:
- mode=AUDIO_OFF;
- break;
- case AUDIO_ON:
- mode=btv->audio;
- break;
- default:
- btv->audio&=AUDIO_MUTE;
- btv->audio|=mode;
- break;
- }
- /* if audio mute or not in H-lock, turn audio off */
- if ((btv->audio&AUDIO_MUTE)
-#if 0
- ||
- (!btv->radio && !(btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC))
-#endif
- )
- mode=AUDIO_OFF;
- if ((mode == 0) && (btv->radio))
- mode = 1;
- btaor(tvcards[btv->type].audiomux[mode],
- ~tvcards[btv->type].gpiomask, BT848_GPIO_DATA);
-}
-
-
-extern inline void bt848_dma(struct bttv *btv, uint state)
-{
- if (state)
- btor(3, BT848_GPIO_DMA_CTL);
- else
- btand(~3, BT848_GPIO_DMA_CTL);
-}
-
-
-static void bt848_cap(struct bttv *btv, uint state)
-{
- if (state)
- {
- btv->cap|=3;
- bt848_set_risc_jmps(btv);
- }
- else
- {
- btv->cap&=~3;
- bt848_set_risc_jmps(btv);
- }
-}
-
-
-/* If Bt848a or Bt849, use PLL for PAL/SECAM and crystal for NTSC*/
-
-static int set_pll(struct bttv *btv)
-{
- int i;
-
- if (!btv->pll)
- return 0;
- if ((btread(BT848_IFORM)&BT848_IFORM_XT0))
- {
- /* printk ("switching PLL off\n");*/
- btwrite(0x00,BT848_TGCTRL);
- btwrite(0x00,BT848_PLL_XCI);
- btv->pll&=~2;
- return 0;
- }
-
- /* do not set pll again if already active */
- if (btv->pll&2)
- return 1;
-
- /* printk ("setting PLL for PAL/SECAM\n");*/
-
- btwrite(0x00,BT848_TGCTRL);
- btwrite(0xf9,BT848_PLL_F_LO);
- btwrite(0xdc,BT848_PLL_F_HI);
- btwrite(0x8e,BT848_PLL_XCI);
-
- /* Ugh ugh ugh .. schedule ? */
- udelay(100000);
- for (i=0; i<100; i++)
- {
- if ((btread(BT848_DSTATUS)&BT848_DSTATUS_PLOCK))
- btwrite(0,BT848_DSTATUS);
- else
- {
- btwrite(0x08,BT848_TGCTRL);
- btv->pll|=2;
- return 1;
- }
-#if LINUX_VERSION_CODE >= 0x020199
- mdelay(10);
-#else
- udelay(10000);
-#endif
- }
- return -1;
-}
-
-static void bt848_muxsel(struct bttv *btv, unsigned int input)
-{
- btaor(tvcards[btv->type].gpiomask2,~tvcards[btv->type].gpiomask2,
- BT848_GPIO_OUT_EN);
-
- /* This seems to get rid of some synchronization problems */
- btand(~(3<<5), BT848_IFORM);
- udelay(10000);
-
-
- input %= tvcards[btv->type].inputs;
- if (input==tvcards[btv->type].svhs)
- {
- btor(BT848_CONTROL_COMP, BT848_E_CONTROL);
- btor(BT848_CONTROL_COMP, BT848_O_CONTROL);
- }
- else
- {
- btand(~BT848_CONTROL_COMP, BT848_E_CONTROL);
- btand(~BT848_CONTROL_COMP, BT848_O_CONTROL);
- }
- btaor((tvcards[btv->type].muxsel[input&7]&3)<<5, ~(3<<5), BT848_IFORM);
- audio(btv, (input!=tvcards[btv->type].tuner) ?
- AUDIO_EXTERN : AUDIO_TUNER);
- btaor(tvcards[btv->type].muxsel[input]>>4,
- ~tvcards[btv->type].gpiomask2, BT848_GPIO_DATA);
-}
-
-
-#define VBIBUF_SIZE 65536
-
-/* Maximum sample number per VBI line is 2044, can NTSC deliver this?
- Note that we write 2048-aligned to keep alignment to memory pages
-*/
-#define VBI_SPL 2044
-
-/* RISC command to write one VBI data line */
-#define VBI_RISC BT848_RISC_WRITE|VBI_SPL|BT848_RISC_EOL|BT848_RISC_SOL
-
-static void make_vbitab(struct bttv *btv)
-{
- int i;
- unsigned int *po=(unsigned int *) btv->vbi_odd;
- unsigned int *pe=(unsigned int *) btv->vbi_even;
-
- DEBUG(printk(KERN_DEBUG "vbiodd: 0x%08x\n",(int)btv->vbi_odd));
- DEBUG(printk(KERN_DEBUG "vbievn: 0x%08x\n",(int)btv->vbi_even));
- DEBUG(printk(KERN_DEBUG "po: 0x%08x\n",(int)po));
- DEBUG(printk(KERN_DEBUG "pe: 0x%08x\n",(int)pe));
-
- *(po++)=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1; *(po++)=0;
- for (i=0; i<16; i++)
- {
- *(po++)=VBI_RISC;
- *(po++)=kvirt_to_bus((unsigned long)btv->vbibuf+i*2048);
- }
- *(po++)=BT848_RISC_JUMP;
- *(po++)=virt_to_bus(btv->risc_jmp+4);
-
- *(pe++)=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1; *(pe++)=0;
- for (i=16; i<32; i++)
- {
- *(pe++)=VBI_RISC;
- *(pe++)=kvirt_to_bus((unsigned long)btv->vbibuf+i*2048);
- }
- *(pe++)=BT848_RISC_JUMP|BT848_RISC_IRQ|(0x01<<16);
- *(pe++)=virt_to_bus(btv->risc_jmp+10);
- DEBUG(printk(KERN_DEBUG "po: 0x%08x\n",(int)po));
- DEBUG(printk(KERN_DEBUG "pe: 0x%08x\n",(int)pe));
-}
-
-int fmtbppx2[16] = {
- 8, 6, 4, 4, 4, 3, 2, 2, 4, 3, 0, 0, 0, 0, 2, 0
-};
-int palette2fmt[] = {
- 0,
- BT848_COLOR_FMT_Y8,
- BT848_COLOR_FMT_RGB8,
- BT848_COLOR_FMT_RGB16,
- BT848_COLOR_FMT_RGB24,
- BT848_COLOR_FMT_RGB32,
- BT848_COLOR_FMT_RGB15,
-};
-
-static int make_rawrisctab(struct bttv *btv, unsigned int *ro,
- unsigned int *re, unsigned int *vbuf)
-{
- unsigned long line;
- unsigned long bpl=1024; /* bytes per line */
- unsigned long vadr=(unsigned long) vbuf;
-
- *(ro++)=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1; *(ro++)=0;
- *(re++)=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1; *(re++)=0;
-
- /* In PAL 650 blocks of 256 DWORDs are sampled, but only if VDELAY
- is 2 and without separate VBI grabbing.
- We'll have to handle this inside the IRQ handler ... */
-
- for (line=0; line < 640; line++)
- {
- *(ro++)=BT848_RISC_WRITE|bpl|BT848_RISC_SOL|BT848_RISC_EOL;
- *(ro++)=kvirt_to_bus(vadr);
- *(re++)=BT848_RISC_WRITE|bpl|BT848_RISC_SOL|BT848_RISC_EOL;
- *(re++)=kvirt_to_bus(vadr+BTTV_MAX_FBUF/2);
- vadr+=bpl;
- }
-
- *(ro++)=BT848_RISC_JUMP;
- *(ro++)=btv->bus_vbi_even;
- *(re++)=BT848_RISC_JUMP|BT848_RISC_IRQ|(2<<16);
- *(re++)=btv->bus_vbi_odd;
-
- return 0;
-}
-
-
-static int make_vrisctab(struct bttv *btv, unsigned int *ro,
- unsigned int *re,
- unsigned int *vbuf, unsigned short width,
- unsigned short height, unsigned short fmt)
-{
- unsigned long line;
- unsigned long bpl; /* bytes per line */
- unsigned long bl;
- unsigned long todo;
- unsigned int **rp;
- int inter;
- unsigned long vadr=(unsigned long) vbuf;
-
-
- if (btv->gfmt==BT848_COLOR_FMT_RAW)
- return make_rawrisctab(btv, ro, re, vbuf);
-
- inter = (height>btv->win.cropheight/2) ? 1 : 0;
- bpl=width*fmtbppx2[fmt&0xf]/2;
-
- *(ro++)=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1; *(ro++)=0;
- *(re++)=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1; *(re++)=0;
-
- for (line=0; line < (height<<(1^inter)); line++)
- {
- if (inter)
- rp= (line&1) ? &re : &ro;
- else
- rp= (line>height) ? &re : &ro;
-
- bl=PAGE_SIZE-((PAGE_SIZE-1)&vadr);
- if (bpl<=bl)
- {
- *((*rp)++)=BT848_RISC_WRITE|BT848_RISC_SOL|
- BT848_RISC_EOL|bpl;
- *((*rp)++)=kvirt_to_bus(vadr);
- vadr+=bpl;
- }
- else
- {
- todo=bpl;
- *((*rp)++)=BT848_RISC_WRITE|BT848_RISC_SOL|bl;
- *((*rp)++)=kvirt_to_bus(vadr);
- vadr+=bl;
- todo-=bl;
- while (todo>PAGE_SIZE)
- {
- *((*rp)++)=BT848_RISC_WRITE|PAGE_SIZE;
- *((*rp)++)=kvirt_to_bus(vadr);
- vadr+=PAGE_SIZE;
- todo-=PAGE_SIZE;
- }
- *((*rp)++)=BT848_RISC_WRITE|BT848_RISC_EOL|todo;
- *((*rp)++)=kvirt_to_bus(vadr);
- vadr+=todo;
- }
- }
-
- *(ro++)=BT848_RISC_JUMP;
- *(ro++)=btv->bus_vbi_even;
- *(re++)=BT848_RISC_JUMP|BT848_RISC_IRQ|(2<<16);
- *(re++)=btv->bus_vbi_odd;
-
- return 0;
-}
-
-/* does this really make a difference ???? */
-#define BURST_MAX 4096
-
-static inline void write_risc_segment(unsigned int **rp, unsigned long line_adr, unsigned int command,
- int *x, uint dx, uint bpp, uint width)
-{
- unsigned int flags, len;
-
- if (!dx)
- return;
- len=dx*bpp;
-
-#ifdef LIMIT_DMA
- if (command==BT848_RISC_WRITEC)
- {
- unsigned int dx2=BURST_MAX/bpp;
- while (len>BURST_MAX)
- {
- write_risc_segment(rp, line_adr, command,
- &x,dx2, bpp, width);
- dx-=dx2;
- len=dx*bpp;
- }
- }
-#endif
-
- /* mask upper 8 bits for 24+8 bit overlay modes */
- flags = ((bpp==4) ? BT848_RISC_BYTE3 : 0);
-
- if (*x==0)
- {
- if (command==BT848_RISC_SKIP)
- {
- if (dx<width)
- {
- flags|=BT848_RISC_BYTE_ALL;
- command=BT848_RISC_WRITE;
- }
- }
- else
- if (command==BT848_RISC_WRITEC)
- command=BT848_RISC_WRITE;
- flags|=BT848_RISC_SOL;
- }
- if (*x+dx==width)
- flags|=BT848_RISC_EOL;
- *((*rp)++)=command|flags|len;
- if (command==BT848_RISC_WRITE)
- *((*rp)++)=line_adr+*x*bpp;
- *x+=dx;
-}
-
-static void make_clip_tab(struct bttv *btv, struct cliprec *cr, int count)
-{
- int i,ncr;
- int yy, y, x, dx;
- struct cliprec first, *cur, *cur2, *nx, first2, *prev, *nx2;
- int bpp, bpl, width, height, inter;
- unsigned int **rp,*ro,*re;
- unsigned long adr;
- int cx,cx2,cy,cy2;
-
- inter=(btv->win.interlace&1)^1;
- bpp=btv->win.bpp;
- bpl=btv->win.bpl;
- ncr=btv->ncr;
- ro=btv->risc_odd;
- re=btv->risc_even;
- width=btv->win.width;
- height=btv->win.height;
- adr=btv->win.vidadr+btv->win.x*bpp+btv->win.y*bpl;
-
- /* clip clipping rects against viewing window AND screen
- so we do not have to rely on the user program
- */
- cx=(btv->win.x<0) ? (-btv->win.x) : 0;
- cy=(btv->win.y<0) ? (-btv->win.y) : 0;
- cx2=(btv->win.x+width>btv->win.swidth) ?
- (btv->win.swidth-btv->win.x) : width;
- cy2=(btv->win.y+height>btv->win.sheight) ?
- (btv->win.sheight-btv->win.y) : height;
- first.next=NULL;
- for (i=0; i<ncr; i++)
- {
- if (cr[i].y<cy)
- {
- if (cr[i].y2<cy)
- continue;
- cr[i].y=cy;
- }
- if (cr[i].y2>=cy2)
- {
- if (cr[i].y>=cy2)
- continue;
- cr[i].y2=cy2-1;
- }
- if (cr[i].x<cx)
- {
- if (cr[i].x2<cx)
- continue;
- cr[i].x=cx;
- }
- if (cr[i].x2>=cx2)
- {
- if (cr[i].x>=cx2)
- continue;
- cr[i].x2=cx2-1;
- }
- cur=&first;
- while ((nx=cur->next) && (cr[i].y > cur->next->y))
- cur=nx;
- cur->next=&(cr[i]);
- cr[i].next=nx;
- }
- first2.next=NULL;
-
- *(ro++)=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1; *(ro++)=0;
- *(re++)=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1; *(re++)=0;
-
- /* loop through all lines */
- for (yy=0; yy<(height<<inter); yy++)
- {
- y=yy>>inter;
- rp= (yy&1) ? &re : &ro;
-
- /* remove rects with y2 > y */
- if ((cur=first2.next))
- {
- prev=&first2;
- do
- {
- if (cur->y2 < y)
- prev->next=cur->next;
- else
- prev=cur;
- }
- while ((cur=cur->next));
- }
-
- /* add rect to second (x-sorted) list if rect.y == y */
- if ((cur=first.next))
- {
- while ((cur) && (cur->y == y))
- {
- first.next=cur->next;
- cur2=&first2;
- while ((nx2=cur2->next) && (cur->x > cur2->next->x))
- cur2=nx2;
- cur2->next=cur;
- cur->next=nx2;
- cur=first.next;
- }
- }
- x=0;
- if ((btv->win.y+y<=0)||(btv->win.y+y>=btv->win.sheight))
- write_risc_segment(rp, adr, BT848_RISC_SKIP, &x,
- width, bpp, width);
- else
- {
- dx=cx;
- for (cur2=first2.next; cur2; cur2=cur2->next)
- {
- if (x+dx < cur2->x)
- {
- write_risc_segment(rp, adr, BT848_RISC_SKIP,
- &x, dx, bpp, width);
- dx=cur2->x-x;
- write_risc_segment(rp, adr, BT848_RISC_WRITEC,
- &x, dx, bpp, width);
- dx=cur2->x2-x+1;
- }
- else if (x+dx < cur2->x2)
- dx=cur2->x2-x+1;
- }
- if (cx2<width)
- {
- write_risc_segment(rp, adr, BT848_RISC_SKIP,
- &x, dx, bpp, width);
- write_risc_segment(rp, adr, BT848_RISC_WRITEC,
- &x, cx2-x, bpp, width);
- dx=width-x;
- }
- write_risc_segment(rp, adr, BT848_RISC_SKIP,
- &x, dx, bpp, width);
- write_risc_segment(rp, adr, BT848_RISC_WRITEC,
- &x, width-x, bpp, width);
- }
- if ((!inter)||(yy&1))
- adr+=bpl;
- }
-
- *(ro++)=BT848_RISC_JUMP;
- *(ro++)=btv->bus_vbi_even;
- *(re++)=BT848_RISC_JUMP;
- *(re++)=btv->bus_vbi_odd;
-}
-
-/*
- * Set the registers for the size we have specified. Don't bother
- * trying to understand this without the BT848 manual in front of
- * you [AC].
- *
- * PS: The manual is free for download in .pdf format from
- * www.brooktree.com - nicely done those folks.
- */
-
-struct tvnorm
-{
- u16 swidth, sheight; /* scaled standard width, height */
- u16 totalwidth;
- u8 adelay, bdelay, iform;
- u32 scaledtwidth;
- u16 hdelayx1, hactivex1;
- u16 vdelay;
-};
-
-static struct tvnorm tvnorms[] = {
- /* PAL-BDGHI */
- //{ 1024, 576, 1135, 0x7f, 0x72, (BT848_IFORM_PAL_BDGHI|BT848_IFORM_XT1),
- // 1135, 100, 1024, 0x20},
-
- { 914, 576, 1135, 0x7f, 0x72, (BT848_IFORM_PAL_BDGHI|BT848_IFORM_XT1),
- 1135, 186+16, 914, 0x20},
-/*
- { 768, 576, 1135, 0x7f, 0x72, (BT848_IFORM_PAL_BDGHI|BT848_IFORM_XT1),
- 944, 186, 922, 0x20},
-*/
- /* NTSC */
- { 640, 480, 910, 0x68, 0x5d, (BT848_IFORM_NTSC|BT848_IFORM_XT0),
- 780, 135, 754, 0x16},
- /* SECAM */
- { 768, 576, 1135, 0x7f, 0xb0, (BT848_IFORM_SECAM|BT848_IFORM_XT1),
- 944, 186, 922, 0x20},
- /* PAL-M */
- { 640, 480, 910, 0x68, 0x5d, (BT848_IFORM_PAL_M|BT848_IFORM_XT0),
- 780, 135, 754, 0x16},
- /* PAL-N */
- { 768, 576, 1135, 0x7f, 0x72, (BT848_IFORM_PAL_N|BT848_IFORM_XT1),
- 944, 186, 922, 0x20},
- /* PAL-NC */
- { 768, 576, 1135, 0x7f, 0x72, (BT848_IFORM_PAL_NC|BT848_IFORM_XT0),
- 944, 186, 922, 0x20},
- /* NTSC-Japan */
- { 640, 480, 910, 0x68, 0x5d, (BT848_IFORM_NTSC_J|BT848_IFORM_XT0),
- 780, 135, 754, 0x16},
-};
-#define TVNORMS (sizeof(tvnorms)/sizeof(tvnorm))
-
-
-/* set geometry for even/odd frames
- just if you are wondering:
- handling of even and odd frames will be separated, e.g. for grabbing
- the even ones as RGB into videomem and the others as YUV in main memory for
- compressing and sending to the video conferencing partner.
-
-*/
-static inline void bt848_set_eogeo(struct bttv *btv, int odd, u8 vtc,
- u16 hscale, u16 vscale,
- u16 hactive, u16 vactive,
- u16 hdelay, u16 vdelay,
- u8 crop)
-{
- int off = odd ? 0x80 : 0x00;
-
- btwrite(vtc, BT848_E_VTC+off);
- btwrite(hscale>>8, BT848_E_HSCALE_HI+off);
- btwrite(hscale&0xff, BT848_E_HSCALE_LO+off);
- btaor((vscale>>8), 0xe0, BT848_E_VSCALE_HI+off);
- btwrite(vscale&0xff, BT848_E_VSCALE_LO+off);
- btwrite(hactive&0xff, BT848_E_HACTIVE_LO+off);
- btwrite(hdelay&0xff, BT848_E_HDELAY_LO+off);
- btwrite(vactive&0xff, BT848_E_VACTIVE_LO+off);
- btwrite(vdelay&0xff, BT848_E_VDELAY_LO+off);
- btwrite(crop, BT848_E_CROP+off);
-}
-
-
-static void bt848_set_geo(struct bttv *btv, u16 width, u16 height, u16 fmt)
-{
- u16 vscale, hscale;
- u32 xsf, sr;
- u16 hdelay, vdelay;
- u16 hactive, vactive;
- u16 inter;
- u8 crop, vtc;
- struct tvnorm *tvn;
-
- if (!width || !height)
- return;
-
- tvn=&tvnorms[btv->win.norm];
-
- btv->win.cropheight=tvn->sheight;
- btv->win.cropwidth=tvn->swidth;
-
-/*
- if (btv->win.cropwidth>tvn->cropwidth)
- btv->win.cropwidth=tvn->cropwidth;
- if (btv->win.cropheight>tvn->cropheight)
- btv->win.cropheight=tvn->cropheight;
-
- if (width>btv->win.cropwidth)
- width=btv->win.cropwidth;
- if (height>btv->win.cropheight)
- height=btv->win.cropheight;
-*/
- btwrite(tvn->adelay, BT848_ADELAY);
- btwrite(tvn->bdelay, BT848_BDELAY);
- btaor(tvn->iform,~(BT848_IFORM_NORM|BT848_IFORM_XTBOTH), BT848_IFORM);
-
- set_pll(btv);
-
- btwrite(fmt, BT848_COLOR_FMT);
- hactive=width;
-
- vtc=0;
- /* Some people say interpolation looks bad ... */
- /* vtc = (hactive < 193) ? 2 : ((hactive < 385) ? 1 : 0); */
-
- btv->win.interlace = (height>btv->win.cropheight/2) ? 1 : 0;
- inter=(btv->win.interlace&1)^1;
- xsf = (hactive*tvn->scaledtwidth)/btv->win.cropwidth;
- hscale = ((tvn->totalwidth*4096UL)/xsf-4096);
- vdelay=btv->win.cropy+tvn->vdelay;
-
- hdelay=(tvn->hdelayx1*tvn->scaledtwidth)/tvn->totalwidth;
- hdelay=((hdelay+btv->win.cropx)*hactive)/btv->win.cropwidth;
- hdelay&=0x3fe;
-
- sr=((btv->win.cropheight>>inter)*512)/height-512;
- vscale=(0x10000UL-sr)&0x1fff;
- vactive=btv->win.cropheight;
- crop=((hactive>>8)&0x03)|((hdelay>>6)&0x0c)|
- ((vactive>>4)&0x30)|((vdelay>>2)&0xc0);
- vscale|= btv->win.interlace ? (BT848_VSCALE_INT<<8) : 0;
-
- bt848_set_eogeo(btv, 0, vtc, hscale, vscale, hactive, vactive,
- hdelay, vdelay, crop);
- bt848_set_eogeo(btv, 1, vtc, hscale, vscale, hactive, vactive,
- hdelay, vdelay, crop);
-
-}
-
-
-int bpp2fmt[4] = {
- BT848_COLOR_FMT_RGB8, BT848_COLOR_FMT_RGB16,
- BT848_COLOR_FMT_RGB24, BT848_COLOR_FMT_RGB32
-};
-
-static void bt848_set_winsize(struct bttv *btv)
-{
- unsigned short format;
-
- btv->win.color_fmt = format =
- (btv->win.depth==15) ? BT848_COLOR_FMT_RGB15 :
- bpp2fmt[(btv->win.bpp-1)&3];
-
- /* RGB8 seems to be a 9x5x5 GRB color cube starting at
- * color 16. Why the h... can't they even mention this in the
- * datasheet??? [AC - because its a standard format so I guess
- * it never occured them]
- * Enable dithering in this mode
- */
- if (format==BT848_COLOR_FMT_RGB8)
- btand(~BT848_CAP_CTL_DITH_FRAME, BT848_CAP_CTL);
- else
- btor(BT848_CAP_CTL_DITH_FRAME, BT848_CAP_CTL);
-
- bt848_set_geo(btv, btv->win.width, btv->win.height, format);
-}
-
-/*
- * Set TSA5522 synthesizer frequency in 1/16 Mhz steps
- */
-
-static void set_freq(struct bttv *btv, unsigned short freq)
-{
- int fixme = freq; /* XXX */
- int oldAudio = btv->audio;
-
- audio(btv, AUDIO_MUTE);
- udelay(AUDIO_MUTE_DELAY);
-
- if (btv->radio)
- {
- if (btv->have_tuner)
- i2c_control_device(&(btv->i2c), I2C_DRIVERID_TUNER,
- TUNER_SET_RADIOFREQ,&fixme);
-
- if (btv->have_msp3400) {
- i2c_control_device(&(btv->i2c),I2C_DRIVERID_MSP3400,
- MSP_SET_RADIO,0);
- i2c_control_device(&(btv->i2c),I2C_DRIVERID_MSP3400,
- MSP_NEWCHANNEL,0);
- }
- }
- else
- {
- if (btv->have_tuner)
- i2c_control_device(&(btv->i2c), I2C_DRIVERID_TUNER,
- TUNER_SET_TVFREQ,&fixme);
-
- if (btv->have_msp3400) {
- i2c_control_device(&(btv->i2c),I2C_DRIVERID_MSP3400,
- MSP_SET_TVNORM,&(btv->win.norm));
- i2c_control_device(&(btv->i2c),I2C_DRIVERID_MSP3400,
- MSP_NEWCHANNEL,0);
- }
- }
-
- if (!(oldAudio & AUDIO_MUTE)) {
- udelay(FREQ_CHANGE_DELAY);
- audio(btv, AUDIO_UNMUTE);
- }
-}
-
-
-/*
- * Grab into virtual memory.
- * Currently only does double buffering. Do we need more?
- */
-
-static int vgrab(struct bttv *btv, struct video_mmap *mp)
-{
- unsigned int *ro, *re;
- unsigned int *vbuf;
-
- if(btv->fbuffer==NULL)
- {
- if(fbuffer_alloc(btv))
- return -ENOBUFS;
- }
- if (btv->grabbing >= MAX_GBUFFERS)
- return -ENOBUFS;
-
- /*
- * No grabbing past the end of the buffer!
- */
-
- if(mp->frame>1 || mp->frame <0)
- return -EINVAL;
-
- if(mp->height <0 || mp->width <0)
- return -EINVAL;
-
- if(mp->height>576 || mp->width>768)
- return -EINVAL;
-
- /*
- * FIXME: Check the format of the grab here. This is probably
- * also less restrictive than the normal overlay grabs. Stuff
- * like QCIF has meaning as a capture.
- */
-
- /*
- * Ok load up the BT848
- */
-
- vbuf=(unsigned int *)(btv->fbuffer+BTTV_MAX_FBUF*mp->frame);
- if (!(btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC))
- return -EAGAIN;
- ro=btv->grisc+(((btv->grabcount++)&1) ? 4096 :0);
- re=ro+2048;
- btv->gwidth=mp->width;
- btv->gheight=mp->height;
- btv->gfmt=mp->format;
- make_vrisctab(btv, ro, re, vbuf, btv->gwidth, btv->gheight, btv->gfmt);
- /* bt848_set_risc_jmps(btv); */
- btor(3, BT848_CAP_CTL);
- btor(3, BT848_GPIO_DMA_CTL);
- btv->frame_stat[mp->frame] = GBUFFER_GRABBING;
- if (btv->grabbing) {
- btv->gro_next=virt_to_bus(ro);
- btv->gre_next=virt_to_bus(re);
- btv->grf_next=mp->frame;
- } else {
- btv->gro=virt_to_bus(ro);
- btv->gre=virt_to_bus(re);
- btv->grf=mp->frame;
- }
- if (!(btv->grabbing++))
- btv->risc_jmp[12]=BT848_RISC_JUMP|(0x8<<16)|BT848_RISC_IRQ;
- /* interruptible_sleep_on(&btv->capq); */
- return 0;
-}
-
-static long bttv_write(struct video_device *v, const char *buf, unsigned long count, int nonblock)
-{
- return -EINVAL;
-}
-
-static long bttv_read(struct video_device *v, char *buf, unsigned long count, int nonblock)
-{
- struct bttv *btv= (struct bttv *)v;
- int q,todo;
-
- todo=count;
- while (todo && todo>(q=VBIBUF_SIZE-btv->vbip))
- {
- if(copy_to_user((void *) buf, (void *) btv->vbibuf+btv->vbip, q))
- return -EFAULT;
- todo-=q;
- buf+=q;
-
- cli();
- if (todo && q==VBIBUF_SIZE-btv->vbip)
- {
- if(nonblock)
- {
- sti();
- if(count==todo)
- return -EWOULDBLOCK;
- return count-todo;
- }
- interruptible_sleep_on(&btv->vbiq);
- sti();
- if(signal_pending(current))
- {
- if(todo==count)
- return -EINTR;
- else
- return count-todo;
- }
- }
- }
- if (todo)
- {
- if(copy_to_user((void *) buf, (void *) btv->vbibuf+btv->vbip, todo))
- return -EFAULT;
- btv->vbip+=todo;
- }
- return count;
-}
-
-/*
- * Open a bttv card. Right now the flags stuff is just playing
- */
-
-static int bttv_open(struct video_device *dev, int flags)
-{
- struct bttv *btv = (struct bttv *)dev;
- int users, i;
-
- switch (flags)
- {
- case 0:
- if (btv->user)
- return -EBUSY;
- btv->user++;
- audio(btv, AUDIO_UNMUTE);
- for (i=users=0; i<bttv_num; i++)
- users+=bttvs[i].user;
- if (users==1)
- find_vga();
- btv->fbuffer=NULL;
- if (!btv->fbuffer)
- btv->fbuffer=(unsigned char *) rvmalloc(2*BTTV_MAX_FBUF);
- if (!btv->fbuffer)
- {
- btv->user--;
- return -EINVAL;
- }
- btv->grabbing = 0;
- btv->grab = 0;
- btv->lastgrab = 0;
- break;
- case 1:
- break;
- }
- MOD_INC_USE_COUNT;
- return 0;
-}
-
-static void bttv_close(struct video_device *dev)
-{
- struct bttv *btv=(struct bttv *)dev;
-
- btv->user--;
- audio(btv, AUDIO_MUTE);
- btv->cap&=~3;
- bt848_set_risc_jmps(btv);
-
- if(btv->fbuffer)
- rvfree((void *) btv->fbuffer, 2*BTTV_MAX_FBUF);
- btv->fbuffer=0;
- MOD_DEC_USE_COUNT;
-}
-
-
-/***********************************/
-/* ioctls and supporting functions */
-/***********************************/
-
-extern inline void bt848_bright(struct bttv *btv, uint bright)
-{
- btwrite(bright&0xff, BT848_BRIGHT);
-}
-
-extern inline void bt848_hue(struct bttv *btv, uint hue)
-{
- btwrite(hue&0xff, BT848_HUE);
-}
-
-extern inline void bt848_contrast(struct bttv *btv, uint cont)
-{
- unsigned int conthi;
-
- conthi=(cont>>6)&4;
- btwrite(cont&0xff, BT848_CONTRAST_LO);
- btaor(conthi, ~4, BT848_E_CONTROL);
- btaor(conthi, ~4, BT848_O_CONTROL);
-}
-
-extern inline void bt848_sat_u(struct bttv *btv, unsigned long data)
-{
- u32 datahi;
-
- datahi=(data>>7)&2;
- btwrite(data&0xff, BT848_SAT_U_LO);
- btaor(datahi, ~2, BT848_E_CONTROL);
- btaor(datahi, ~2, BT848_O_CONTROL);
-}
-
-static inline void bt848_sat_v(struct bttv *btv, unsigned long data)
-{
- u32 datahi;
-
- datahi=(data>>8)&1;
- btwrite(data&0xff, BT848_SAT_V_LO);
- btaor(datahi, ~1, BT848_E_CONTROL);
- btaor(datahi, ~1, BT848_O_CONTROL);
-}
-
-
-/*
- * Cliprect -> risc table.
- *
- * FIXME: This is generating wrong code when we have some kinds of
- * rectangle lists. If you generate overlapped rectangles then it
- * gets a bit confused. Since we add the frame buffer clip rectangles
- * we need to fix this. Better yet to rewrite this function.
- */
-
-static void write_risc_data(struct bttv *btv, struct video_clip *vp, int count)
-{
- int i;
- u32 yy, y, x, dx, ox;
- u32 *rmem, *rmem2;
- struct video_clip first, *cur, *cur2, *nx, first2, *prev, *nx2;
- u32 *rp, rpo=0, rpe=0, p, bpsl;
- u32 *rpp;
- u32 mask;
- int interlace;
- int depth;
-
- rmem=(u32 *)btv->risc_odd;
- rmem2=(u32 *)btv->risc_even;
- depth=btv->win.bpp;
-
- /* create y-sorted list */
-
- first.next=NULL;
- for (i=0; i<count; i++)
- {
- cur=&first;
- while ((nx=cur->next) && (vp[i].y > cur->next->y))
- cur=nx;
- cur->next=&(vp[i]);
- vp[i].next=nx;
- }
- first2.next=NULL;
-
- rmem[rpo++]=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1|(0xf<<20);
- rmem[rpo++]=0;
-
- rmem2[rpe++]=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1;
- rmem2[rpe++]=0;
-
-
- /*
- * 32bit depth frame buffers need extra flags setting
- */
-
- if (depth==4)
- mask=BT848_RISC_BYTE3;
- else
- mask=0;
-
- bpsl=btv->win.width*btv->win.bpp;
- p=btv->win.vidadr+btv->win.x*btv->win.bpp+
- btv->win.y*btv->win.bpl;
-
- interlace=btv->win.interlace;
-
- /*
- * Loop through all lines
- */
-
- for (yy=0; yy<(btv->win.height<<(1^interlace)); yy++)
- {
- y=yy>>(1^interlace);
-
- /*
- * Even or odd frame generation. We have to
- * write the RISC instructions to the right stream.
- */
-
- if(!(y&1))
- {
- rp=&rpo;
- rpp=rmem;
- }
- else
- {
- rp=&rpe;
- rpp=rmem2;
- }
-
-
- /*
- * first2 is the header of a list of "active" rectangles. We add
- * rectangles as we hit their top and remove them as they fall off
- * the bottom
- */
-
- /* remove rects with y2 > y */
- if ((cur=first2.next))
- {
- prev=&first2;
- do
- {
- if (cur->y+cur->height < y)
- prev->next=cur->next;
- else
- prev=cur;
- }
- while ((cur=cur->next));
- }
-
- /*
- * Fixme - we have to handle overlapped rectangles
- * here, but the overlap might be partial
- */
-
- /* add rect to second (x-sorted) list if rect.y == y */
- if ((cur=first.next))
- {
- while ((cur) && (cur->y == y))
- {
- first.next=cur->next;
- cur2=&first2;
- while ((nx2=cur2->next) && (cur->x > cur2->next->x))
- cur2=nx2;
- cur2->next=cur;
- cur->next=nx2;
- cur=first.next;
- }
- }
-
-
- /*
- * Begin writing the RISC script
- */
-
- dx=x=0;
-
- /*
- * Starting at x position 0 on a new scan line
- * write to location p, don't yet write the number
- * of pixels for the instruction
- */
-
- rpp[(*rp)++]=BT848_RISC_WRITE|BT848_RISC_SOL;
- rpp[(*rp)++]=p;
-
- /*
- * For each rectangle we have in the "active" list - sorted left to
- * right..
- */
-
- for (cur2=first2.next; cur2; cur2=cur2->next)
- {
- /*
- * If we are to the left of the first drawing area
- */
-
- if (x+dx < cur2->x)
- {
- /* Bytes pending ? */
- if (dx)
- {
- /* For a delta away from the start we need to write a SKIP */
- if (x)
- rpp[(*rp)++]=BT848_RISC_SKIP|(dx*depth);
- else
- /* Rewrite the start of line WRITE to a SKIP */
- rpp[(*rp)-2]|=BT848_RISC_BYTE_ALL|(dx*depth);
- /* Move X to the next point (drawing start) */
- x=x+dx;
- }
- /* Ok how far are we from the start of the next rectangle ? */
- dx=cur2->x-x;
- /* dx is now the size of data to write */
-
- /* If this isnt the left edge generate a "write continue" */
- if (x)
- rpp[(*rp)++]=BT848_RISC_WRITEC|(dx*depth)|mask;
- else
- /* Fill in the byte count on the initial WRITE */
- rpp[(*rp)-2]|=(dx*depth)|mask;
- /* Move to the start of the rectangle */
- x=cur2->x;
- /* x is our left dx is byte size of hole */
- dx=cur2->width+1;
- }
- else
- /* Already in a clip zone.. set dx */
- if (x+dx < cur2->x+cur2->width)
- dx=cur2->x+cur2->width-x+1;
- }
- /* now treat the rest of the line */
- ox=x;
- if (dx)
- {
- /* Complete the SKIP to eat to the end of the gap */
- if (x)
- rpp[(*rp)++]=BT848_RISC_SKIP|(dx*depth);
- else
- /* Rewrite to SKIP start to this point */
- rpp[(*rp)-2]|=BT848_RISC_BYTE_ALL|(dx*depth);
- x=x+dx;
- }
-
- /*
- * Not at the right hand edge ?
- */
-
- if ((dx=btv->win.width-x)!=0)
- {
- /* Write to edge of display */
- if (x)
- rpp[(*rp)++]=BT848_RISC_WRITEC|(dx*depth)|BT848_RISC_EOL|mask;
- else
- /* Entire frame is a write - patch first order */
- rpp[(*rp)-2]|=(dx*depth)|BT848_RISC_EOL|mask;
- }
- else
- {
- /* End of line if needed */
- if (ox)
- rpp[(*rp)-1]|=BT848_RISC_EOL|mask;
- else
- {
- /* Skip the line : write a SKIP + start/end of line marks */
- (*rp)--;
- rpp[(*rp)-1]=BT848_RISC_SKIP|
- (btv->win.width*depth)|
- BT848_RISC_EOL|BT848_RISC_SOL;
- }
- }
- /*
- * Move the video render pointer on a line
- */
- if (interlace||(y&1))
- p+=btv->win.bpl;
- }
-
- /*
- * Attach the interframe jumps
- */
-
- rmem[rpo++]=BT848_RISC_JUMP;
- rmem[rpo++]=btv->bus_vbi_even;
-
- rmem2[rpe++]=BT848_RISC_JUMP;
- rmem2[rpe++]=btv->bus_vbi_odd;
-}
-
-/*
- * Helper for adding clips.
- */
-
-static void new_risc_clip(struct video_window *vw, struct video_clip *vcp, int x, int y, int w, int h)
-{
- vcp[vw->clipcount].x=x;
- vcp[vw->clipcount].y=y;
- vcp[vw->clipcount].width=w;
- vcp[vw->clipcount].height=h;
- vw->clipcount++;
-}
-
-
-/*
- * ioctl routine
- */
-
-
-static int bttv_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
-{
- unsigned char eedata[256];
- struct bttv *btv=(struct bttv *)dev;
- static int lastchan=0,i;
-
- switch (cmd)
- {
- case VIDIOCGCAP:
- {
- struct video_capability b;
- strcpy(b.name,btv->video_dev.name);
- b.type = VID_TYPE_CAPTURE|
- VID_TYPE_TUNER|
- VID_TYPE_TELETEXT|
- VID_TYPE_OVERLAY|
- VID_TYPE_CLIPPING|
- VID_TYPE_FRAMERAM|
- VID_TYPE_SCALES;
- b.channels = 4; /* tv , input, svhs */
- b.audios = 4; /* tv, input, svhs */
- b.maxwidth = 768;
- b.maxheight = 576;
- b.minwidth = 32;
- b.minheight = 32;
- if(copy_to_user(arg,&b,sizeof(b)))
- return -EFAULT;
- return 0;
- }
- case VIDIOCGCHAN:
- {
- struct video_channel v;
- if(copy_from_user(&v, arg,sizeof(v)))
- return -EFAULT;
- v.flags=VIDEO_VC_AUDIO;
- v.tuners=0;
- v.type=VIDEO_TYPE_CAMERA;
-#if 0
- v.mode = btv->win.norm;
-#endif
- switch(v.channel)
- {
- case 0:
- strcpy(v.name,"Television");
- v.flags|=VIDEO_VC_TUNER;
- v.type=VIDEO_TYPE_TV;
- v.tuners=1;
- break;
- case 1:
- strcpy(v.name,"Composite1");
- break;
- case 2:
- strcpy(v.name,"Composite2");
- break;
- case 3:
- strcpy(v.name,"SVHS");
- break;
- default:
- return -EINVAL;
- }
- if(copy_to_user(arg,&v,sizeof(v)))
- return -EFAULT;
- return 0;
- }
- /*
- * Each channel has 1 tuner
- */
- case VIDIOCSCHAN:
- {
- int v;
- if(copy_from_user(&v, arg, sizeof(v)))
- return -EFAULT;
- bt848_muxsel(btv, v);
- lastchan=v;
- return 0;
- }
- case VIDIOCGTUNER:
- {
- struct video_tuner v;
- if(copy_from_user(&v,arg,sizeof(v))!=0)
- return -EFAULT;
- if(v.tuner||lastchan) /* Only tuner 0 */
- return -EINVAL;
- strcpy(v.name, "Television");
- v.rangelow=0;
- v.rangehigh=0xFFFFFFFF;
- v.flags=VIDEO_TUNER_PAL|VIDEO_TUNER_NTSC;
- v.mode = btv->win.norm;
- if(copy_to_user(arg,&v,sizeof(v)))
- return -EFAULT;
- return 0;
- }
- /* We have but tuner 0 */
- case VIDIOCSTUNER:
- {
- /* FIXME: norm should be in video_channel struct
- composite source can have different norms too
- */
-
- struct video_tuner v;
- if(copy_from_user(&v, arg, sizeof(v)))
- return -EFAULT;
- /* Only 1 channel has a tuner */
- /*if(v.tuner!=tvcards[btv->type].tuner || lastchan)
- return -EINVAL;*/
- if(v.mode!=VIDEO_MODE_PAL&&v.mode!=VIDEO_MODE_NTSC
- &&v.mode!=VIDEO_MODE_SECAM)
- return -EOPNOTSUPP;
- btv->win.norm = v.mode;
- bt848_set_winsize(btv);
- return 0;
- }
- case VIDIOCGPICT:
- {
- struct video_picture p=btv->picture;
- if(btv->win.depth==8)
- p.palette=VIDEO_PALETTE_HI240;
- if(btv->win.depth==15)
- p.palette=VIDEO_PALETTE_RGB555;
- if(btv->win.depth==16)
- p.palette=VIDEO_PALETTE_RGB565;
- if(btv->win.depth==24)
- p.palette=VIDEO_PALETTE_RGB24;
- if(btv->win.depth==32)
- p.palette=VIDEO_PALETTE_RGB32;
-
- if(copy_to_user(arg, &p, sizeof(p)))
- return -EFAULT;
- return 0;
- }
- case VIDIOCSPICT:
- {
- struct video_picture p;
- int format;
- if(copy_from_user(&p, arg,sizeof(p)))
- return -EFAULT;
- /* We want -128 to 127 we get 0-65535 */
- bt848_bright(btv, (p.brightness>>8)-128);
- /* 0-511 for the colour */
- bt848_sat_u(btv, p.colour>>7);
- bt848_sat_v(btv, ((p.colour>>7)*201L)/237);
- /* -128 to 127 */
- bt848_hue(btv, (p.hue>>8)-128);
- /* 0-511 */
- bt848_contrast(btv, p.contrast>>7);
- btv->picture = p;
-
- /* set palette if bpp matches */
- if (p.palette < sizeof(palette2fmt)/sizeof(int)) {
- format = palette2fmt[p.palette];
- if (fmtbppx2[format&0x0f]/2 == btv->win.bpp)
- btv->win.color_fmt = format;
- }
- return 0;
- }
- case VIDIOCSWIN:
- {
- struct video_window vw;
- struct video_clip *vcp;
- int on;
-
- if(copy_from_user(&vw,arg,sizeof(vw)))
- return -EFAULT;
-
- if(vw.flags)
- return -EINVAL;
-
- btv->win.x=vw.x;
- btv->win.y=vw.y;
- btv->win.width=vw.width;
- btv->win.height=vw.height;
-
- if(btv->win.height>btv->win.cropheight/2)
- btv->win.interlace=1;
- else
- btv->win.interlace=0;
-
- on=(btv->cap&3)?1:0;
-
- bt848_cap(btv,0);
- bt848_set_winsize(btv);
-
- if(vw.clipcount>256)
- return -EDOM; /* Too many! */
-
- /*
- * Do any clips.
- */
-
- vcp=vmalloc(sizeof(struct video_clip)*(vw.clipcount+4));
- if(vcp==NULL)
- return -ENOMEM;
- if(vw.clipcount && copy_from_user(vcp,vw.clips,sizeof(struct video_clip)*vw.clipcount))
- return -EFAULT;
- /*
- * Impose display clips
- */
- if(btv->win.x<0)
- new_risc_clip(&vw, vcp, 0, 0, -btv->win.x, btv->win.height-1);
- if(btv->win.y<0)
- new_risc_clip(&vw, vcp, 0, 0, btv->win.width-1,-btv->win.y);
- if(btv->win.x+btv->win.width> btv->win.swidth)
- new_risc_clip(&vw, vcp, btv->win.swidth-btv->win.x, 0, btv->win.width-1, btv->win.height-1);
- if(btv->win.y+btv->win.height > btv->win.sheight)
- new_risc_clip(&vw, vcp, 0, btv->win.sheight-btv->win.y, btv->win.width-1, btv->win.height-1);
- /*
- * Question: Do we need to walk the clip list
- * and saw off any clips outside the window
- * frame or will write_risc_tab do the right
- * thing ?
- */
- write_risc_data(btv,vcp, vw.clipcount);
- vfree(vcp);
- if(on && btv->win.vidadr!=0)
- bt848_cap(btv,1);
- return 0;
- }
- case VIDIOCGWIN:
- {
- struct video_window vw;
- /* Oh for a COBOL move corresponding .. */
- vw.x=btv->win.x;
- vw.y=btv->win.y;
- vw.width=btv->win.width;
- vw.height=btv->win.height;
- vw.chromakey=0;
- vw.flags=0;
- if(btv->win.interlace)
- vw.flags|=VIDEO_WINDOW_INTERLACE;
- if(copy_to_user(arg,&vw,sizeof(vw)))
- return -EFAULT;
- return 0;
- }
- case VIDIOCCAPTURE:
- {
- int v;
- if(copy_from_user(&v, arg,sizeof(v)))
- return -EFAULT;
- if(v==0)
- {
- bt848_cap(btv,0);
- }
- else
- {
- if(btv->win.vidadr==0 || btv->win.width==0
- || btv->win.height==0)
- return -EINVAL;
- bt848_cap(btv,1);
- }
- return 0;
- }
- case VIDIOCGFBUF:
- {
- struct video_buffer v;
- v.base=(void *)btv->win.vidadr;
- v.height=btv->win.sheight;
- v.width=btv->win.swidth;
- v.depth=btv->win.depth;
- v.bytesperline=btv->win.bpl;
- if(copy_to_user(arg, &v,sizeof(v)))
- return -EFAULT;
- return 0;
-
- }
- case VIDIOCSFBUF:
- {
- struct video_buffer v;
-#if LINUX_VERSION_CODE >= 0x020100
- if(!capable(CAP_SYS_ADMIN))
-#else
- if(!suser())
-#endif
- return -EPERM;
- if(copy_from_user(&v, arg,sizeof(v)))
- return -EFAULT;
- if(v.depth!=8 && v.depth!=16 && v.depth!=15
- && v.depth!=24 && v.depth!=32)
- return -EINVAL;
- if (v.base)
- {
- /* also handle virtual base addresses */
- if ((unsigned int)v.base>=0xe0000000UL)
- btv->win.vidadr=(uint)v.base;
- else
- btv->win.vidadr=
-#if LINUX_VERSION_CODE >= 0x020199
- __va(uvirt_to_bus((uint)v.base));
-#else
- PAGE_OFFSET|uvirt_to_bus((uint)v.base);
-#endif
- }
- btv->win.sheight=v.height;
- btv->win.swidth=v.width;
- btv->win.bpp=((v.depth+7)&0x38)/8;
- btv->win.depth=v.depth;
- btv->win.bpl=v.bytesperline;
-
- DEBUG(printk("Display at %p is %d by %d, bytedepth %d, bpl %d\n",
- v.base, v.width,v.height, btv->win.bpp, btv->win.bpl));
- bt848_set_winsize(btv);
- return 0;
- }
- case VIDIOCKEY:
- {
- /* Will be handled higher up .. */
- return 0;
- }
- case VIDIOCGFREQ:
- {
- unsigned long v=btv->win.freq;
- if(copy_to_user(arg,&v,sizeof(v)))
- return -EFAULT;
- return 0;
- }
- case VIDIOCSFREQ:
- {
- unsigned long v;
- if(copy_from_user(&v, arg, sizeof(v)))
- return -EFAULT;
- btv->win.freq=v;
- set_freq(btv, btv->win.freq);
- return 0;
- }
-
- case VIDIOCGAUDIO:
- {
- struct video_audio v;
- v=btv->audio_dev;
- v.flags&=~(VIDEO_AUDIO_MUTE|VIDEO_AUDIO_MUTABLE);
- v.flags|=VIDEO_AUDIO_MUTABLE;
- strcpy(v.name,"TV");
- if (btv->have_msp3400)
- {
- v.flags|=VIDEO_AUDIO_VOLUME |
- VIDEO_AUDIO_BASS |
- VIDEO_AUDIO_TREBLE;
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_MSP3400,
- MSP_GET_VOLUME,&(v.volume));
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_MSP3400,
- MSP_GET_BASS,&(v.bass));
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_MSP3400,
- MSP_GET_TREBLE,&(v.treble));
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_MSP3400,
- MSP_GET_STEREO,&(v.mode));
- }
- else v.mode = VIDEO_SOUND_MONO;
- if(copy_to_user(arg,&v,sizeof(v)))
- return -EFAULT;
- return 0;
- }
- case VIDIOCSAUDIO:
- {
- struct video_audio v;
- if(copy_from_user(&v,arg, sizeof(v)))
- return -EFAULT;
- if(v.flags&VIDEO_AUDIO_MUTE)
- audio(btv, AUDIO_MUTE);
- /* One audio source per tuner */
- if(v.audio!=0)
- return -EINVAL;
- bt848_muxsel(btv,v.audio);
- if(!(v.flags&VIDEO_AUDIO_MUTE))
- audio(btv, AUDIO_UNMUTE);
- if (btv->have_msp3400)
- {
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_MSP3400,
- MSP_SET_VOLUME,&(v.volume));
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_MSP3400,
- MSP_SET_BASS,&(v.bass));
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_MSP3400,
- MSP_SET_TREBLE,&(v.treble));
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_MSP3400,
- MSP_SET_STEREO,&(v.mode));
- }
- btv->audio_dev=v;
- return 0;
- }
- case VIDIOCSYNC_OLD:
-#if 0
- if (!btv->grabbing)
- return -EAGAIN;
-#endif
- if (btv->grab==btv->lastgrab)
- interruptible_sleep_on(&btv->capq);
- btv->lastgrab++;
- return 0;
- case VIDIOCSYNC:
- if(copy_from_user((void *)&i,arg,sizeof(int)))
- return -EFAULT;
- switch (btv->frame_stat[i]) {
- case GBUFFER_UNUSED:
- return -EINVAL;
- case GBUFFER_GRABBING:
- interruptible_sleep_on(&btv->capq);
- /* fall */
- case GBUFFER_DONE:
- btv->frame_stat[i] = GBUFFER_UNUSED;
- break;
- }
- return 0;
-
- case BTTV_WRITEE:
-#if LINUX_VERSION_CODE >= 0x020100
- if(!capable(CAP_SYS_ADMIN))
-#else
- if(!suser())
-#endif
- return -EPERM;
- if(copy_from_user((void *) eedata, (void *) arg, 256))
- return -EFAULT;
- writeee(&(btv->i2c), eedata);
- return 0;
-
- case BTTV_READEE:
-#if LINUX_VERSION_CODE >= 0x020100
- if(!capable(CAP_SYS_ADMIN))
-#else
- if(!suser())
-#endif
- return -EPERM;
- readee(&(btv->i2c), eedata);
- if(copy_to_user((void *) arg, (void *) eedata, 256))
- return -EFAULT;
- break;
-
- case BTTV_FIELDNR:
- if(copy_to_user((void *) arg, (void *) &btv->last_field,
- sizeof(btv->last_field)))
- return -EFAULT;
- break;
-
- case VIDIOCMCAPTURE:
- {
- struct video_mmap vm;
- if(copy_from_user((void *) &vm, (void *) arg, sizeof(vm)))
- return -EFAULT;
- if (btv->frame_stat[vm.frame] == GBUFFER_GRABBING)
- return -EBUSY;
- return vgrab(btv, &vm);
- }
- default:
- return -ENOIOCTLCMD;
- }
- return 0;
-}
-
-static int bttv_init_done(struct video_device *dev)
-{
- return 0;
-}
-
-/*
- * This maps the vmalloced and reserved fbuffer to user space.
- *
- * FIXME:
- * - PAGE_READONLY should suffice!?
- * - remap_page_range is kind of inefficient for page by page remapping.
- * But e.g. pte_alloc() does not work in modules ... :-(
- */
-
-static int bttv_mmap(struct video_device *dev, const char *adr, unsigned long size)
-{
- struct bttv *btv=(struct bttv *)dev;
- unsigned long start=(unsigned long) adr;
- unsigned long page,pos;
-
- if (size>2*BTTV_MAX_FBUF)
- return -EINVAL;
- if (!btv->fbuffer)
- {
- if(fbuffer_alloc(btv))
- return -EINVAL;
- }
- pos=(unsigned long) btv->fbuffer;
- while (size > 0)
- {
- page = kvirt_to_phys(pos);
- if (remap_page_range(start, page, PAGE_SIZE, PAGE_SHARED))
- return -EAGAIN;
- start+=PAGE_SIZE;
- pos+=PAGE_SIZE;
- size-=PAGE_SIZE;
- }
- return 0;
-}
-
-static struct video_device bttv_template=
-{
- "UNSET",
- VID_TYPE_TUNER|VID_TYPE_CAPTURE|VID_TYPE_OVERLAY|VID_TYPE_TELETEXT,
- VID_HARDWARE_BT848,
- bttv_open,
- bttv_close,
- bttv_read,
- bttv_write,
- bttv_ioctl,
- bttv_mmap,
- bttv_init_done,
- NULL,
- 0,
- 0
-};
-
-
-static long vbi_read(struct video_device *v, char *buf, unsigned long count,
- int nonblock)
-{
- struct bttv *btv=(struct bttv *)(v-2);
- int q,todo;
-
- todo=count;
- while (todo && todo>(q=VBIBUF_SIZE-btv->vbip))
- {
- if(copy_to_user((void *) buf, (void *) btv->vbibuf+btv->vbip, q))
- return -EFAULT;
- todo-=q;
- buf+=q;
-
- cli();
- if (todo && q==VBIBUF_SIZE-btv->vbip)
- {
- if(nonblock)
- {
- sti();
- if(count==todo)
- return -EWOULDBLOCK;
- return count-todo;
- }
- interruptible_sleep_on(&btv->vbiq);
- sti();
- if(signal_pending(current))
- {
- if(todo==count)
- return -EINTR;
- else
- return count-todo;
- }
- }
- }
- if (todo)
- {
- if(copy_to_user((void *) buf, (void *) btv->vbibuf+btv->vbip, todo))
- return -EFAULT;
- btv->vbip+=todo;
- }
- return count;
-}
-
-static int vbi_open(struct video_device *dev, int flags)
-{
- struct bttv *btv=(struct bttv *)(dev-2);
-
- btv->vbip=VBIBUF_SIZE;
- btv->cap|=0x0c;
- bt848_set_risc_jmps(btv);
-
- MOD_INC_USE_COUNT;
- return 0;
-}
-
-static void vbi_close(struct video_device *dev)
-{
- struct bttv *btv=(struct bttv *)(dev-2);
-
- btv->cap&=~0x0c;
- bt848_set_risc_jmps(btv);
-
- MOD_DEC_USE_COUNT;
-}
-
-
-static int vbi_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
-{
- return -EINVAL;
-}
-
-static struct video_device vbi_template=
-{
- "bttv vbi",
- VID_TYPE_CAPTURE|VID_TYPE_TELETEXT,
- VID_HARDWARE_BT848,
- vbi_open,
- vbi_close,
- vbi_read,
- bttv_write,
- vbi_ioctl,
- NULL, /* no mmap yet */
- bttv_init_done,
- NULL,
- 0,
- 0
-};
-
-
-static int radio_open(struct video_device *dev, int flags)
-{
- struct bttv *btv = (struct bttv *)(dev-1);
-
- if (btv->user)
- return -EBUSY;
- btv->user++;
- set_freq(btv,400*16);
- btv->radio = 1;
- bt848_muxsel(btv,0);
- audio(btv, AUDIO_UNMUTE);
-
- MOD_INC_USE_COUNT;
- return 0;
-}
-
-static void radio_close(struct video_device *dev)
-{
- struct bttv *btv=(struct bttv *)(dev-1);
-
- btv->user--;
- btv->radio = 0;
- audio(btv, AUDIO_MUTE);
- MOD_DEC_USE_COUNT;
-}
-
-static long radio_read(struct video_device *v, char *buf, unsigned long count, int nonblock)
-{
- return -EINVAL;
-}
-
-static int radio_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
-{
- struct bttv *btv=(struct bttv *)(dev-1);
- static int lastchan=0;
- switch (cmd) {
- case VIDIOCGCAP:
- /* XXX */
- break;
- case VIDIOCGTUNER:
- {
- struct video_tuner v;
- if(copy_from_user(&v,arg,sizeof(v))!=0)
- return -EFAULT;
- if(v.tuner||lastchan) /* Only tuner 0 */
- return -EINVAL;
- strcpy(v.name, "Radio");
- v.rangelow=(int)(87.5*16);
- v.rangehigh=(int)(108.0*16);
- v.flags= 0; /* XXX */
- v.mode = 0; /* XXX */
- if(copy_to_user(arg,&v,sizeof(v)))
- return -EFAULT;
- return 0;
- }
- case VIDIOCSTUNER:
- {
- struct video_tuner v;
- if(copy_from_user(&v, arg, sizeof(v)))
- return -EFAULT;
- /* Only channel 0 has a tuner */
- if(v.tuner!=0 || lastchan)
- return -EINVAL;
- /* XXX anything to do ??? */
- return 0;
- }
- case VIDIOCGFREQ:
- case VIDIOCSFREQ:
- case VIDIOCGAUDIO:
- case VIDIOCSAUDIO:
- bttv_ioctl((struct video_device *)btv,cmd,arg);
- break;
- default:
- return -ENOIOCTLCMD;
- }
- return 0;
-}
-
-static struct video_device radio_template=
-{
- "bttv radio",
- VID_TYPE_TUNER,
- VID_HARDWARE_BT848,
- radio_open,
- radio_close,
- radio_read, /* just returns -EINVAL */
- bttv_write, /* just returns -EINVAL */
- radio_ioctl,
- NULL, /* no mmap */
- bttv_init_done, /* just returns 0 */
- NULL,
- 0,
- 0
-};
-
-
-struct vidbases
-{
- unsigned short vendor, device;
- char *name;
- uint badr;
-};
-
-static struct vidbases vbs[] = {
-/* This id is not defined in pci.h but this entry was mailed to me?!?
- { PCI_VENDOR_ID_ALLIANCE, PCI_DEVICE_ID_ALLIANCE_AT25,
- "Alliance AT25", PCI_BASE_ADDRESS_0},
-*/
- { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_210888GX,
- "ATI MACH64 Winturbo", PCI_BASE_ADDRESS_0},
- { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_215GT,
- "ATI MACH64 GT", PCI_BASE_ADDRESS_0},
- { PCI_VENDOR_ID_CIRRUS, 0, "Cirrus Logic", PCI_BASE_ADDRESS_0},
- { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TGA,
- "DEC DC21030", PCI_BASE_ADDRESS_0},
- { PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_MIL,
- "Matrox Millennium", PCI_BASE_ADDRESS_1},
- { PCI_VENDOR_ID_MATROX, 0x051a, "Matrox Mystique", PCI_BASE_ADDRESS_1},
- { PCI_VENDOR_ID_N9, PCI_DEVICE_ID_N9_I128,
- "Number Nine Imagine 128", PCI_BASE_ADDRESS_0},
- { PCI_VENDOR_ID_N9, PCI_DEVICE_ID_N9_I128_2,
- "Number Nine Imagine 128 Series 2", PCI_BASE_ADDRESS_0},
- { PCI_VENDOR_ID_S3, 0, "S3", PCI_BASE_ADDRESS_0},
- { PCI_VENDOR_ID_TSENG, 0, "TSENG", PCI_BASE_ADDRESS_0},
-};
-
-
-/* DEC TGA offsets stolen from XFree-3.2 */
-
-static uint dec_offsets[4] = {
- 0x200000,
- 0x804000,
- 0,
- 0x1004000
-};
-
-#define NR_CARDS (sizeof(vbs)/sizeof(struct vidbases))
-
-/* Scan for PCI display adapter
- if more than one card is present the last one is used for now */
-
-static int find_vga(void)
-{
- unsigned int devfn, class, vendev;
- unsigned short vendor, device, badr;
- int found=0, bus=0, i, tga_type;
- unsigned int vidadr=0;
-
-
- for (devfn = 0; devfn < 0xff; devfn++)
- {
- if (PCI_FUNC(devfn) != 0)
- continue;
- pcibios_read_config_dword(bus, devfn, PCI_VENDOR_ID, &vendev);
- if (vendev == 0xffffffff || vendev == 0x00000000)
- continue;
- pcibios_read_config_word(bus, devfn, PCI_VENDOR_ID, &vendor);
- pcibios_read_config_word(bus, devfn, PCI_DEVICE_ID, &device);
- pcibios_read_config_dword(bus, devfn, PCI_CLASS_REVISION, &class);
- class = class >> 16;
-/* if (class == PCI_CLASS_DISPLAY_VGA) {*/
- if ((class>>8) == PCI_BASE_CLASS_DISPLAY ||
- /* Number 9 GXE64Pro needs this */
- class == PCI_CLASS_NOT_DEFINED_VGA)
- {
- badr=0;
- printk(KERN_INFO "bttv: PCI display adapter: ");
- for (i=0; i<NR_CARDS; i++)
- {
- if (vendor==vbs[i].vendor)
- {
- if (vbs[i].device)
- if (vbs[i].device!=device)
- continue;
- printk("%s.\n", vbs[i].name);
- badr=vbs[i].badr;
- break;
- }
- }
- if (NR_CARDS == i)
- printk("UNKNOWN.\n");
- if (!badr)
- {
- printk(KERN_ERR "bttv: Unknown video memory base address.\n");
- continue;
- }
- pcibios_read_config_dword(bus, devfn, badr, &vidadr);
- if (vidadr & PCI_BASE_ADDRESS_SPACE_IO)
- {
- printk(KERN_ERR "bttv: Memory seems to be I/O memory.\n");
- printk(KERN_ERR "bttv: Check entry for your card type in bttv.c vidbases struct.\n");
- continue;
- }
- vidadr &= PCI_BASE_ADDRESS_MEM_MASK;
- if (!vidadr)
- {
- printk(KERN_ERR "bttv: Memory @ 0, must be something wrong!\n");
- continue;
- }
-
- if (vendor==PCI_VENDOR_ID_DEC)
- if (device==PCI_DEVICE_ID_DEC_TGA)
- {
- tga_type = (readl((unsigned long)vidadr) >> 12) & 0x0f;
- if (tga_type != 0 && tga_type != 1 && tga_type != 3)
- {
- printk(KERN_ERR "bttv: TGA type (0x%x) unrecognized!\n", tga_type);
- found--;
- }
- vidadr+=dec_offsets[tga_type];
- }
-
- DEBUG(printk(KERN_DEBUG "bttv: memory @ 0x%08x, ", vidadr));
- DEBUG(printk(KERN_DEBUG "devfn: 0x%04x.\n", devfn));
- found++;
- }
- }
-
- if (vidmem)
- {
- if (vidmem < 0x1000)
- vidadr=vidmem<<20;
- else
- vidadr=vidmem;
- printk(KERN_INFO "bttv: Video memory override: 0x%08x\n", vidadr);
- found=1;
- }
- for (i=0; i<BTTV_MAX; i++)
- bttvs[i].win.vidadr=vidadr;
-
- return found;
-}
-
-
-
-#define TRITON_PCON 0x50
-#define TRITON_BUS_CONCURRENCY (1<<0)
-#define TRITON_STREAMING (1<<1)
-#define TRITON_WRITE_BURST (1<<2)
-#define TRITON_PEER_CONCURRENCY (1<<3)
-
-static void handle_chipset(void)
-{
- int index;
-
- /* Just in case some nut set this to something dangerous */
- if (triton1)
- triton1=BT848_INT_ETBF;
-
- for (index = 0; index < 8; index++)
- {
- unsigned char bus, devfn;
- unsigned char b;
-
- /* Beware the SiS 85C496 my friend - rev 49 don't work with a bttv */
-
- if (!pcibios_find_device(PCI_VENDOR_ID_SI,
- PCI_DEVICE_ID_SI_496,
- index, &bus, &devfn))
- {
- printk(KERN_WARNING "BT848 and SIS 85C496 chipset don't always work together.\n");
- }
-
- if (!pcibios_find_device(PCI_VENDOR_ID_INTEL,
- PCI_DEVICE_ID_INTEL_82441,
- index, &bus, &devfn))
- {
- pcibios_read_config_byte(bus, devfn, 0x53, &b);
- DEBUG(printk(KERN_INFO "bttv: Host bridge: 82441FX Natoma, "));
- DEBUG(printk("bufcon=0x%02x\n",b));
- }
-
- if (!pcibios_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437,
- index, &bus, &devfn))
- {
- printk(KERN_INFO "bttv: Host bridge 82437FX Triton PIIX\n");
- triton1=BT848_INT_ETBF;
-
-#if 0
- /* The ETBF bit SHOULD make all this unnecessary */
- /* 430FX (Triton I) freezes with bus concurrency on -> switch it off */
- {
- unsigned char bo;
-
- pcibios_read_config_byte(bus, devfn, TRITON_PCON, &b);
- bo=b;
- DEBUG(printk(KERN_DEBUG "bttv: 82437FX: PCON: 0x%x\n",b));
-
- if(!(b & TRITON_BUS_CONCURRENCY))
- {
- printk(KERN_WARNING "bttv: 82437FX: disabling bus concurrency\n");
- b |= TRITON_BUS_CONCURRENCY;
- }
-
- if(b & TRITON_PEER_CONCURRENCY)
- {
- printk(KERN_WARNING "bttv: 82437FX: disabling peer concurrency\n");
- b &= ~TRITON_PEER_CONCURRENCY;
- }
- if(!(b & TRITON_STREAMING))
- {
- printk(KERN_WARNING "bttv: 82437FX: disabling streaming\n");
- b |= TRITON_STREAMING;
- }
-
- if (b!=bo)
- {
- pcibios_write_config_byte(bus, devfn, TRITON_PCON, b);
- printk(KERN_DEBUG "bttv: 82437FX: PCON changed to: 0x%x\n",b);
- }
- }
-#endif
- }
- }
-}
-
-
-static void init_tda8425(struct i2c_bus *bus)
-{
- I2CWrite(bus, I2C_TDA8425, TDA8425_VL, 0xFC, 1); /* volume left 0dB */
- I2CWrite(bus, I2C_TDA8425, TDA8425_VR, 0xFC, 1); /* volume right 0dB */
- I2CWrite(bus, I2C_TDA8425, TDA8425_BA, 0xF6, 1); /* bass 0dB */
- I2CWrite(bus, I2C_TDA8425, TDA8425_TR, 0xF6, 1); /* treble 0dB */
- I2CWrite(bus, I2C_TDA8425, TDA8425_S1, 0xCE, 1); /* mute off */
-}
-
-
-
-static void init_tda9850(struct i2c_bus *bus)
-{
- I2CWrite(bus, I2C_TDA9850, TDA9850_CON1, 0x08, 1); /* noise threshold st */
- I2CWrite(bus, I2C_TDA9850, TDA9850_CON2, 0x08, 1); /* noise threshold sap */
- I2CWrite(bus, I2C_TDA9850, TDA9850_CON3, 0x40, 1); /* stereo mode */
- I2CWrite(bus, I2C_TDA9850, TDA9850_CON4, 0x07, 1); /* 0 dB input gain?*/
- I2CWrite(bus, I2C_TDA9850, TDA9850_ALI1, 0x10, 1); /* wideband alignment? */
- I2CWrite(bus, I2C_TDA9850, TDA9850_ALI2, 0x10, 1); /* spectral alignment? */
- I2CWrite(bus, I2C_TDA9850, TDA9850_ALI3, 0x03, 1);
-}
-
-
-
-/* Figure out card and tuner type */
-
-static void idcard(int i)
-{
- struct bttv *btv = &bttvs[i];
-
- int tunertype;
- btwrite(0, BT848_GPIO_OUT_EN);
- DEBUG(printk(KERN_DEBUG "bttv%d: GPIO: 0x%08x\n", i, btread(BT848_GPIO_DATA)));
-
- /* Default the card to the user-selected one. */
- btv->type=card[i];
-
- /* If we were asked to auto-detect, then do so!
- Right now this will only recognize Miro, Hauppauge or STB
- */
- if (btv->type == BTTV_UNKNOWN)
- {
- btv->type=BTTV_MIRO;
-
- if (I2CRead(&(btv->i2c), I2C_HAUPEE)>=0)
- btv->type=BTTV_HAUPPAUGE;
- else
- if (I2CRead(&(btv->i2c), I2C_STBEE)>=0)
- btv->type=BTTV_STB;
- }
-
- if (I2CRead(&(btv->i2c), I2C_TDA9850) >=0)
- {
- btv->audio_chip = TDA9850;
- printk(KERN_INFO "bttv%d: audio chip: TDA9850\n",btv->nr);
- }
-
- if (I2CRead(&(btv->i2c), I2C_TDA8425) >=0)
- {
- btv->audio_chip = TDA8425;
- printk(KERN_INFO "bttv%d: audio chip: TDA8425\n",btv->nr);
- }
-
- switch(btv->audio_chip)
- {
- case TDA9850:
- init_tda9850(&(btv->i2c));
- break;
- case TDA8425:
- init_tda8425(&(btv->i2c));
- break;
- }
-
- /* How do I detect the tuner type for other cards but Miro ??? */
- printk(KERN_INFO "bttv%d: model: ",btv->nr);
- switch (btv->type)
- {
- case BTTV_MIRO:
- printk("MIRO\n");
- if (btv->have_tuner)
- {
- tunertype=((btread(BT848_GPIO_DATA)>>10)-1)&7;
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_TUNER,
- TUNER_SET_TYPE,&tunertype);
- }
- strcpy(btv->video_dev.name,"BT848(Miro)");
- break;
- case BTTV_HAUPPAUGE:
- printk("HAUPPAUGE\n");
- strcpy(btv->video_dev.name,"BT848(Hauppauge)");
- break;
- case BTTV_STB:
- printk("STB\n");
- strcpy(btv->video_dev.name,"BT848(STB)");
- break;
- case BTTV_INTEL:
- printk("Intel\n");
- strcpy(btv->video_dev.name,"BT848(Intel)");
- break;
- case BTTV_DIAMOND:
- printk("Diamond\n");
- strcpy(btv->video_dev.name,"BT848(Diamond)");
- break;
- case BTTV_AVERMEDIA:
- printk("AVerMedia\n");
- strcpy(btv->video_dev.name,"BT848(AVerMedia)");
- break;
- case BTTV_MATRIX_VISION:
- printk("MATRIX-Vision\n");
- strcpy(btv->video_dev.name,"BT848(MATRIX-Vision)");
- break;
- }
- audio(btv, AUDIO_MUTE);
-}
-
-
-
-static void bt848_set_risc_jmps(struct bttv *btv)
-{
- int flags=btv->cap;
-
- /* Sync to start of odd field */
- btv->risc_jmp[0]=BT848_RISC_SYNC|BT848_RISC_RESYNC|BT848_FIFO_STATUS_VRE;
- btv->risc_jmp[1]=0;
-
- /* Jump to odd vbi sub */
- btv->risc_jmp[2]=BT848_RISC_JUMP|(0x5<<20);
- if (flags&8)
- btv->risc_jmp[3]=virt_to_bus(btv->vbi_odd);
- else
- btv->risc_jmp[3]=virt_to_bus(btv->risc_jmp+4);
-
- /* Jump to odd sub */
- btv->risc_jmp[4]=BT848_RISC_JUMP|(0x6<<20);
- if (flags&2)
- btv->risc_jmp[5]=virt_to_bus(btv->risc_odd);
- else
- btv->risc_jmp[5]=virt_to_bus(btv->risc_jmp+6);
-
-
- /* Sync to start of even field */
- btv->risc_jmp[6]=BT848_RISC_SYNC|BT848_RISC_RESYNC|BT848_FIFO_STATUS_VRO;
- btv->risc_jmp[7]=0;
-
- /* Jump to even vbi sub */
- btv->risc_jmp[8]=BT848_RISC_JUMP;
- if (flags&4)
- btv->risc_jmp[9]=virt_to_bus(btv->vbi_even);
- else
- btv->risc_jmp[9]=virt_to_bus(btv->risc_jmp+10);
-
- /* Jump to even sub */
- btv->risc_jmp[10]=BT848_RISC_JUMP|(8<<20);
- if (flags&1)
- btv->risc_jmp[11]=virt_to_bus(btv->risc_even);
- else
- btv->risc_jmp[11]=virt_to_bus(btv->risc_jmp+12);
-
- btv->risc_jmp[12]=BT848_RISC_JUMP;
- btv->risc_jmp[13]=virt_to_bus(btv->risc_jmp);
-
- /* enable cpaturing and DMA */
- btaor(flags, ~0x0f, BT848_CAP_CTL);
- if (flags&0x0f)
- bt848_dma(btv, 3);
- else
- bt848_dma(btv, 0);
-}
-
-static int init_bt848(int i)
-{
- struct bttv *btv = &bttvs[i];
-
- btv->user=0;
-
- /* reset the bt848 */
- btwrite(0, BT848_SRESET);
- DEBUG(printk(KERN_DEBUG "bttv%d: bt848_mem: 0x%08x\n",i,(unsigned int) btv->bt848_mem));
-
- /* default setup for max. PAL size in a 1024xXXX hicolor framebuffer */
- btv->win.norm=0; /* change this to 1 for NTSC, 2 for SECAM */
- btv->win.interlace=1;
- btv->win.x=0;
- btv->win.y=0;
- btv->win.width=768; /* 640 */
- btv->win.height=576; /* 480 */
- btv->win.cropwidth=768; /* 640 */
- btv->win.cropheight=576; /* 480 */
- btv->win.cropx=0;
- btv->win.cropy=0;
- btv->win.bpp=2;
- btv->win.depth=16;
- btv->win.color_fmt=BT848_COLOR_FMT_RGB16;
- btv->win.bpl=1024*btv->win.bpp;
- btv->win.swidth=1024;
- btv->win.sheight=768;
- btv->cap=0;
-
- btv->gmode=0;
- btv->risc_odd=0;
- btv->risc_even=0;
- btv->risc_jmp=0;
- btv->vbibuf=0;
- btv->grisc=0;
- btv->grabbing=0;
- btv->grabcount=0;
- btv->grab=0;
- btv->lastgrab=0;
- btv->field=btv->last_field=0;
-
- /* i2c */
- memcpy(&(btv->i2c),&bttv_i2c_bus_template,sizeof(struct i2c_bus));
- sprintf(btv->i2c.name,"bt848-%d",i);
- btv->i2c.data = btv;
-
- if (!(btv->risc_odd=(unsigned int *) kmalloc(RISCMEM_LEN/2, GFP_KERNEL)))
- return -1;
- if (!(btv->risc_even=(unsigned int *) kmalloc(RISCMEM_LEN/2, GFP_KERNEL)))
- return -1;
- if (!(btv->risc_jmp =(unsigned int *) kmalloc(2048, GFP_KERNEL)))
- return -1;
- DEBUG(printk(KERN_DEBUG "risc_jmp: %p\n",btv->risc_jmp));
- btv->vbi_odd=btv->risc_jmp+16;
- btv->vbi_even=btv->vbi_odd+256;
- btv->bus_vbi_odd=virt_to_bus(btv->risc_jmp+12);
- btv->bus_vbi_even=virt_to_bus(btv->risc_jmp+6);
-
- btwrite(virt_to_bus(btv->risc_jmp+2), BT848_RISC_STRT_ADD);
- btv->vbibuf=(unsigned char *) vmalloc(VBIBUF_SIZE);
- if (!btv->vbibuf)
- return -1;
- if (!(btv->grisc=(unsigned int *) kmalloc(32768, GFP_KERNEL)))
- return -1;
-
- btv->fbuffer=NULL;
-
- bt848_muxsel(btv, 1);
- bt848_set_winsize(btv);
-
-/* btwrite(0, BT848_TDEC); */
- btwrite(0x10, BT848_COLOR_CTL);
- btwrite(0x00, BT848_CAP_CTL);
- btwrite(0xfc, BT848_GPIO_DMA_CTL);
-
- /* select direct input */
- btwrite(0x00, BT848_GPIO_REG_INP);
-
-
- btwrite(0xff, BT848_VBI_PACK_SIZE);
- btwrite(1, BT848_VBI_PACK_DEL);
-
-
- btwrite(BT848_IFORM_MUX1 | BT848_IFORM_XTAUTO | BT848_IFORM_PAL_BDGHI,
- BT848_IFORM);
-
- btwrite(0xd8, BT848_CONTRAST_LO);
- bt848_bright(btv, 0x10);
-
- btwrite(0x20, BT848_E_VSCALE_HI);
- btwrite(0x20, BT848_O_VSCALE_HI);
- btwrite(/*BT848_ADC_SYNC_T|*/
- BT848_ADC_RESERVED|BT848_ADC_CRUSH, BT848_ADC);
-
- btwrite(BT848_CONTROL_LDEC, BT848_E_CONTROL);
- btwrite(BT848_CONTROL_LDEC, BT848_O_CONTROL);
-
- btv->picture.colour=254<<7;
- btv->picture.brightness=128<<8;
- btv->picture.hue=128<<8;
- btv->picture.contrast=0xd8<<7;
-
- btwrite(0x00, BT848_E_SCLOOP);
- btwrite(0x00, BT848_O_SCLOOP);
-
- /* clear interrupt status */
- btwrite(0xfffffUL, BT848_INT_STAT);
-
- /* set interrupt mask */
- btwrite(triton1|
- /*BT848_INT_PABORT|BT848_INT_RIPERR|BT848_INT_PPERR|
- BT848_INT_FDSR|BT848_INT_FTRGT|eBT848_INT_FBUS|*/
- BT848_INT_VSYNC|
- BT848_INT_SCERR|
- BT848_INT_RISCI|BT848_INT_OCERR|BT848_INT_VPRES|
- BT848_INT_FMTCHG|BT848_INT_HLOCK,
- BT848_INT_MASK);
-
- make_vbitab(btv);
- bt848_set_risc_jmps(btv);
-
- /*
- * Now add the template and register the device unit.
- */
-
- memcpy(&btv->video_dev,&bttv_template, sizeof(bttv_template));
- memcpy(&btv->vbi_dev,&vbi_template, sizeof(vbi_template));
- memcpy(&btv->radio_dev,&radio_template,sizeof(radio_template));
- idcard(i);
-
- if(video_register_device(&btv->video_dev,VFL_TYPE_GRABBER)<0)
- return -1;
- if(video_register_device(&btv->vbi_dev,VFL_TYPE_VBI)<0)
- {
- video_unregister_device(&btv->video_dev);
- return -1;
- }
- if (radio)
- {
- if(video_register_device(&btv->radio_dev, VFL_TYPE_RADIO)<0)
- {
- video_unregister_device(&btv->vbi_dev);
- video_unregister_device(&btv->video_dev);
- return -1;
- }
- }
- i2c_register_bus(&btv->i2c);
-
- return 0;
-}
-
-static void bttv_irq(int irq, void *dev_id, struct pt_regs * regs)
-{
- u32 stat,astat;
- u32 dstat;
- int count;
- struct bttv *btv;
-
- btv=(struct bttv *)dev_id;
- count=0;
- while (1)
- {
- /* get/clear interrupt status bits */
- stat=btread(BT848_INT_STAT);
- astat=stat&btread(BT848_INT_MASK);
- if (!astat)
- return;
- btwrite(astat,BT848_INT_STAT);
- IDEBUG(printk ("bttv%d: astat %08x\n", btv->nr,astat));
- IDEBUG(printk ("bttv%d: stat %08x\n", btv->nr,stat));
-
- /* get device status bits */
- dstat=btread(BT848_DSTATUS);
-
- if (astat&BT848_INT_FMTCHG)
- {
- IDEBUG(printk ("bttv%d: IRQ_FMTCHG\n", btv->nr));
- /*btv->win.norm&=
- (dstat&BT848_DSTATUS_NUML) ? (~1) : (~0); */
- }
- if (astat&BT848_INT_VPRES)
- {
- IDEBUG(printk ("bttv%d: IRQ_VPRES\n", btv->nr));
- }
- if (astat&BT848_INT_VSYNC)
- {
- IDEBUG(printk ("bttv%d: IRQ_VSYNC\n",btv->nr));
- btv->field++;
- }
- if (astat&BT848_INT_SCERR) {
- IDEBUG(printk ("bttv%d: IRQ_SCERR\n", btv->nr));
- bt848_dma(btv, 0);
- bt848_dma(btv, 1);
- wake_up_interruptible(&btv->vbiq);
- wake_up_interruptible(&btv->capq);
-
- }
- if (astat&BT848_INT_RISCI)
- {
- IDEBUG(printk ("bttv%d: IRQ_RISCI\n", btv->nr));
-
- /* captured VBI frame */
- if (stat&(1<<28))
- {
- btv->vbip=0;
- wake_up_interruptible(&btv->vbiq);
- }
-
- /* captured full frame */
- if (stat&(2<<28))
- {
- btv->last_field=btv->field;
- btv->grab++;
- btv->frame_stat[btv->grf] = GBUFFER_DONE;
- if ((--btv->grabbing))
- {
- btv->gro = btv->gro_next;
- btv->gre = btv->gre_next;
- btv->grf = btv->grf_next;
- btv->risc_jmp[5]=btv->gro;
- btv->risc_jmp[11]=btv->gre;
- bt848_set_geo(btv, btv->gwidth,
- btv->gheight,
- btv->gfmt);
- } else {
- bt848_set_risc_jmps(btv);
- bt848_set_geo(btv, btv->win.width,
- btv->win.height,
- btv->win.color_fmt);
- }
- wake_up_interruptible(&btv->capq);
- break;
- }
- if (stat&(8<<28))
- {
- btv->risc_jmp[5]=btv->gro;
- btv->risc_jmp[11]=btv->gre;
- btv->risc_jmp[12]=BT848_RISC_JUMP;
- bt848_set_geo(btv, btv->gwidth, btv->gheight,
- btv->gfmt);
- }
- }
- if (astat&BT848_INT_OCERR)
- {
- IDEBUG(printk ("bttv%d: IRQ_OCERR\n", btv->nr));
- }
- if (astat&BT848_INT_PABORT)
- {
- IDEBUG(printk ("bttv%d: IRQ_PABORT\n", btv->nr));
- }
- if (astat&BT848_INT_RIPERR)
- {
- IDEBUG(printk ("bttv%d: IRQ_RIPERR\n", btv->nr));
- }
- if (astat&BT848_INT_PPERR)
- {
- IDEBUG(printk ("bttv%d: IRQ_PPERR\n", btv->nr));
- }
- if (astat&BT848_INT_FDSR)
- {
- IDEBUG(printk ("bttv%d: IRQ_FDSR\n", btv->nr));
- }
- if (astat&BT848_INT_FTRGT)
- {
- IDEBUG(printk ("bttv%d: IRQ_FTRGT\n", btv->nr));
- }
- if (astat&BT848_INT_FBUS)
- {
- IDEBUG(printk ("bttv%d: IRQ_FBUS\n", btv->nr));
- }
- if (astat&BT848_INT_HLOCK)
- {
- if ((dstat&BT848_DSTATUS_HLOC) || (btv->radio))
- audio(btv, AUDIO_ON);
- else
- audio(btv, AUDIO_OFF);
- }
-
- if (astat&BT848_INT_I2CDONE)
- {
- }
-
- count++;
- if (count > 10)
- printk (KERN_WARNING "bttv%d: irq loop %d\n",
- btv->nr,count);
- if (count > 20)
- {
- btwrite(0, BT848_INT_MASK);
- printk(KERN_ERR
- "bttv%d: IRQ lockup, cleared int mask\n",
- btv->nr);
- }
- }
-}
-
-
-
-/*
- * Scan for a Bt848 card, request the irq and map the io memory
- */
-
-static int find_bt848(void)
-{
- short pci_index;
- unsigned char command, latency;
- int result;
- unsigned char bus, devfn;
- struct bttv *btv;
-
- bttv_num=0;
-
- if (!pcibios_present())
- {
- DEBUG(printk(KERN_DEBUG "bttv%d: PCI-BIOS not present or not accessable!\n",bttv_num));
- return 0;
- }
-
- for (pci_index = 0;
- !pcibios_find_device(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT849,
- pci_index, &bus, &devfn)
- ||!pcibios_find_device(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT848,
- pci_index, &bus, &devfn)
- ||!pcibios_find_device(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT878,
- pci_index, &bus, &devfn)
- ||!pcibios_find_device(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT879,
- pci_index, &bus, &devfn);
- ++pci_index)
- {
- btv=&bttvs[bttv_num];
- btv->nr = bttv_num;
- btv->bus=bus;
- btv->devfn=devfn;
- btv->bt848_mem=NULL;
- btv->vbibuf=NULL;
- btv->risc_jmp=NULL;
- btv->vbi_odd=NULL;
- btv->vbi_even=NULL;
- btv->vbiq=NULL;
- btv->capq=NULL;
- btv->capqo=NULL;
- btv->capqe=NULL;
-
- btv->vbip=VBIBUF_SIZE;
-
- pcibios_read_config_word(btv->bus, btv->devfn, PCI_DEVICE_ID,
- &btv->id);
- pcibios_read_config_byte(btv->bus, btv->devfn,
- PCI_INTERRUPT_LINE, &btv->irq);
- pcibios_read_config_dword(btv->bus, btv->devfn, PCI_BASE_ADDRESS_0,
- &btv->bt848_adr);
-
- if (remap[bttv_num])
- {
- if (remap[bttv_num] < 0x1000)
- remap[bttv_num]<<=20;
- remap[bttv_num]&=PCI_BASE_ADDRESS_MEM_MASK;
- printk(KERN_INFO "bttv%d: remapping to : 0x%08x.\n",
- bttv_num,remap[bttv_num]);
- remap[bttv_num]|=btv->bt848_adr&(~PCI_BASE_ADDRESS_MEM_MASK);
- pcibios_write_config_dword(btv->bus, btv->devfn, PCI_BASE_ADDRESS_0,
- remap[bttv_num]);
- pcibios_read_config_dword(btv->bus, btv->devfn, PCI_BASE_ADDRESS_0,
- &btv->bt848_adr);
- }
-
- btv->bt848_adr&=PCI_BASE_ADDRESS_MEM_MASK;
- pcibios_read_config_byte(btv->bus, btv->devfn, PCI_CLASS_REVISION,
- &btv->revision);
- printk(KERN_INFO "bttv%d: Brooktree Bt%d (rev %d) ",
- bttv_num,btv->id, btv->revision);
- printk("bus: %d, devfn: %d, ",
- btv->bus, btv->devfn);
- printk("irq: %d, ",btv->irq);
- printk("memory: 0x%08x.\n", btv->bt848_adr);
-
- btv->pll=0;
-#ifdef USE_PLL
- if (!(btv->id==848 && btv->revision==0x11))
- {
- printk(KERN_INFO "bttv%d: internal PLL, single crystal operation enabled\n",bttv_num);
- btv->pll=1;
- }
-#endif
-
- btv->bt848_mem=ioremap(btv->bt848_adr, 0x1000);
-
- result = request_irq(btv->irq, bttv_irq,
- SA_SHIRQ | SA_INTERRUPT,"bttv",(void *)btv);
- if (result==-EINVAL)
- {
- printk(KERN_ERR "bttv%d: Bad irq number or handler\n",
- bttv_num);
- return -EINVAL;
- }
- if (result==-EBUSY)
- {
- printk(KERN_ERR "bttv%d: IRQ %d busy, change your PnP config in BIOS\n",bttv_num,btv->irq);
- return result;
- }
- if (result < 0)
- return result;
-
- /* Enable bus-mastering */
- pcibios_read_config_byte(btv->bus, btv->devfn, PCI_COMMAND, &command);
- command|=PCI_COMMAND_MASTER;
- pcibios_write_config_byte(btv->bus, btv->devfn, PCI_COMMAND, command);
- pcibios_read_config_byte(btv->bus, btv->devfn, PCI_COMMAND, &command);
- if (!(command&PCI_COMMAND_MASTER))
- {
- printk(KERN_ERR "bttv%d: PCI bus-mastering could not be enabled\n",bttv_num);
- return -1;
- }
- pcibios_read_config_byte(btv->bus, btv->devfn, PCI_LATENCY_TIMER,
- &latency);
- if (!latency)
- {
- latency=32;
- pcibios_write_config_byte(btv->bus, btv->devfn,
- PCI_LATENCY_TIMER, latency);
- }
- DEBUG(printk(KERN_DEBUG "bttv%d: latency: %02x\n",
- bttv_num, latency));
- bttv_num++;
- }
- if(bttv_num)
- printk(KERN_INFO "bttv: %d Bt848 card(s) found.\n", bttv_num);
- return bttv_num;
-}
-
-
-static void release_bttv(void)
-{
- u8 command;
- int i;
- struct bttv *btv;
-
- for (i=0;i<bttv_num; i++)
- {
- btv=&bttvs[i];
-
- /* turn off all capturing, DMA and IRQs */
-
- btand(~15, BT848_GPIO_DMA_CTL);
-
- /* first disable interrupts before unmapping the memory! */
- btwrite(0, BT848_INT_MASK);
- btwrite(0xffffffffUL,BT848_INT_STAT);
- btwrite(0x0, BT848_GPIO_OUT_EN);
-
- /* unregister i2c_bus */
- i2c_unregister_bus((&btv->i2c));
-
- /* disable PCI bus-mastering */
- pcibios_read_config_byte(btv->bus, btv->devfn, PCI_COMMAND, &command);
- command|=PCI_COMMAND_MASTER;
- pcibios_write_config_byte(btv->bus, btv->devfn, PCI_COMMAND, command);
-
- /* unmap and free memory */
- if (btv->grisc)
- kfree((void *) btv->grisc);
-
- if (btv->risc_odd)
- kfree((void *) btv->risc_odd);
-
- if (btv->risc_even)
- kfree((void *) btv->risc_even);
-
- DEBUG(printk(KERN_DEBUG "free: risc_jmp: 0x%08x.\n", btv->risc_jmp));
- if (btv->risc_jmp)
- kfree((void *) btv->risc_jmp);
-
- DEBUG(printk(KERN_DEBUG "bt848_vbibuf: 0x%08x.\n", btv->vbibuf));
- if (btv->vbibuf)
- vfree((void *) btv->vbibuf);
-
-
- free_irq(btv->irq,btv);
- DEBUG(printk(KERN_DEBUG "bt848_mem: 0x%08x.\n", btv->bt848_mem));
- if (btv->bt848_mem)
- iounmap(btv->bt848_mem);
-
- video_unregister_device(&btv->video_dev);
- video_unregister_device(&btv->vbi_dev);
- if (radio)
- video_unregister_device(&btv->radio_dev);
- }
-}
-
-#ifdef MODULE
-
-int init_module(void)
-{
-#else
-int init_bttv_cards(struct video_init *unused)
-{
-#endif
- int i;
-
- handle_chipset();
- if (find_bt848()<0)
- return -EIO;
-
- /* initialize Bt848s */
- for (i=0; i<bttv_num; i++)
- {
- if (init_bt848(i)<0)
- {
- release_bttv();
- return -EIO;
- }
- }
-
-#if 0
- /* load i2c chip drivers (requires a tiny patch for 2.0.x) */
- request_module("msp3400");
- request_module("tuner");
-#endif
-
- return 0;
-}
-
-
-
-#ifdef MODULE
-
-void cleanup_module(void)
-{
- release_bttv();
-}
-
-#endif
-
-/*
- * Local variables:
- * c-indent-level: 8
- * c-brace-imaginary-offset: 0
- * c-brace-offset: -8
- * c-argdecl-indent: 8
- * c-label-offset: -8
- * c-continued-statement-offset: 8
- * c-continued-brace-offset: 0
- * indent-tabs-mode: nil
- * tab-width: 8
- * End:
- */
diff --git a/bttv/driver/bttv.h b/bttv/driver/bttv.h
deleted file mode 100644
index 73bdcf0..0000000
--- a/bttv/driver/bttv.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- bttv - Bt848 frame grabber driver
-
- Copyright (C) 1996,97 Ralph Metzler (rjkm@thp.uni-koeln.de)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _BTTV_H_
-#define _BTTV_H_
-
-#define TEST_VBI
-
-#include <linux/types.h>
-#include <linux/wait.h>
-
-#include "i2c.h"
-#include "msp3400.h"
-#include "bt848.h"
-#include "videodev.h"
-
-#define MAX_CLIPRECS 100
-#define MAX_GBUFFERS 2
-#define RISCMEM_LEN (32744*2)
-
-/* maximum needed buffer size for extended VBI frame mode capturing */
-#define BTTV_MAX_FBUF 0x151000
-
-/* clipping rectangle */
-struct cliprec
-{
- int x, y, x2, y2;
- struct cliprec *next;
-};
-
-
-#ifdef __KERNEL__
-
-struct bttv_window
-{
- int x, y;
- ushort width, height;
- ushort bpp, bpl;
- ushort swidth, sheight;
- short cropx, cropy;
- ushort cropwidth, cropheight;
- unsigned int vidadr;
- ushort freq;
- int norm;
- int interlace;
- int color_fmt;
- ushort depth;
-};
-
-
-struct bttv
-{
- struct video_device video_dev;
- struct video_device radio_dev;
- struct video_device vbi_dev;
- struct video_picture picture; /* Current picture params */
- struct video_audio audio_dev; /* Current audio params */
-
- struct i2c_bus i2c;
- int have_msp3400;
- int have_tuner;
-
- unsigned int nr;
- unsigned short id;
- unsigned char bus; /* PCI bus the Bt848 is on */
- unsigned char devfn;
- unsigned char revision;
- unsigned char irq; /* IRQ used by Bt848 card */
- unsigned int bt848_adr; /* bus address of IO mem returned by PCI BIOS */
- unsigned char *bt848_mem; /* pointer to mapped IO memory */
- unsigned long busriscmem;
- u32 *riscmem;
-
- unsigned char *vbibuf;
- struct bttv_window win;
- int type; /* card type */
- int audio; /* audio mode */
- int user;
- int audio_chip;
- int radio;
-
- u32 *risc_jmp;
- u32 *vbi_odd;
- u32 *vbi_even;
- u32 bus_vbi_even;
- u32 bus_vbi_odd;
- struct wait_queue *vbiq;
- struct wait_queue *capq;
- struct wait_queue *capqo;
- struct wait_queue *capqe;
- int vbip;
-
- u32 *risc_odd;
- u32 *risc_even;
- int cap;
- struct cliprec *cliprecs;
- int ncr; /* number of clipping rectangles */
-
- struct gbuffer *ogbuffers;
- struct gbuffer *egbuffers;
- u16 gwidth, gheight, gfmt;
- u32 *grisc;
-
- unsigned long gro;
- unsigned long gre;
- unsigned long gro_next;
- unsigned long gre_next;
-
- int grf,grf_next; /* frame numbers in grab queue */
- int frame_stat[MAX_GBUFFERS];
-#define GBUFFER_UNUSED 0
-#define GBUFFER_GRABBING 1
-#define GBUFFER_DONE 2
-
- char *fbuffer;
- int gmode;
- int grabbing;
- int lastgrab;
- int grab;
- int grabcount;
-
- int pll;
- unsigned int field;
- unsigned int last_field; /* number of last grabbed field */
-};
-
-#endif
-
-/*The following should be done in more portable way. It depends on define
- of _ALPHA_BTTV in the Makefile.*/
-
-#ifdef _ALPHA_BTTV
-#define btwrite(dat,adr) writel((dat),(char *) (btv->bt848_adr+(adr)))
-#define btread(adr) readl(btv->bt848_adr+(adr))
-#else
-#define btwrite(dat,adr) writel((dat), (char *) (btv->bt848_mem+(adr)))
-#define btread(adr) readl(btv->bt848_mem+(adr))
-#endif
-
-#define btand(dat,adr) btwrite((dat) & btread(adr), adr)
-#define btor(dat,adr) btwrite((dat) | btread(adr), adr)
-#define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr)
-
-/* bttv ioctls */
-
-#define BTTV_READEE _IOW('v', BASE_VIDIOCPRIVATE+0, char [256])
-#define BTTV_WRITEE _IOR('v', BASE_VIDIOCPRIVATE+1, char [256])
-#define BTTV_GRAB _IOR('v' , BASE_VIDIOCPRIVATE+2, struct gbuf)
-#define BTTV_FIELDNR _IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int)
-
-
-#define BTTV_UNKNOWN 0x00
-#define BTTV_MIRO 0x01
-#define BTTV_HAUPPAUGE 0x02
-#define BTTV_STB 0x03
-#define BTTV_INTEL 0x04
-#define BTTV_DIAMOND 0x05
-#define BTTV_AVERMEDIA 0x06
-#define BTTV_MATRIX_VISION 0x07
-#define BTTV_FLYVIDEO 0x08
-
-#define AUDIO_TUNER 0x00
-#define AUDIO_RADIO 0x01
-#define AUDIO_EXTERN 0x02
-#define AUDIO_INTERN 0x03
-#define AUDIO_OFF 0x04
-#define AUDIO_ON 0x05
-#define AUDIO_MUTE 0x80
-#define AUDIO_UNMUTE 0x81
-
-#define TDA9850 0x01
-#define TDA8425 0x02
-
-#define I2C_TSA5522 0xc2
-#define I2C_TDA9850 0xb6
-#define I2C_TDA8425 0x82
-#define I2C_HAUPEE 0xa0
-#define I2C_STBEE 0xae
-
-#define TDA9850_CON1 0x04
-#define TDA9850_CON2 0x05
-#define TDA9850_CON3 0x06
-#define TDA9850_CON4 0x07
-#define TDA9850_ALI1 0x08
-#define TDA9850_ALI2 0x09
-#define TDA9850_ALI3 0x0a
-
-#define TDA8425_VL 0x00
-#define TDA8425_VR 0x01
-#define TDA8425_BA 0x02
-#define TDA8425_TR 0x03
-#define TDA8425_S1 0x08
-
-#endif
diff --git a/bttv/driver/i2c.c b/bttv/driver/i2c.c
deleted file mode 100644
index f8c8d55..0000000
--- a/bttv/driver/i2c.c
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * Generic i2c interface for linux
- *
- * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de>
- *
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/types.h>
-#include <linux/string.h>
-#include <linux/delay.h>
-#include <linux/locks.h>
-#include <linux/sched.h>
-#include <linux/malloc.h>
-
-#include "i2c.h"
-
-#define REGPRINT(x) if (verbose) (x)
-#define I2C_DEBUG(x) if (i2c_debug) (x)
-
-static int scan = 0;
-static int verbose = 1;
-static int i2c_debug = 0;
-
-#if LINUX_VERSION_CODE >= 0x020117
-MODULE_PARM(scan,"i");
-MODULE_PARM(verbose,"i");
-MODULE_PARM(i2c_debug,"i");
-#endif
-
-/* ----------------------------------------------------------------------- */
-
-static struct i2c_bus *busses[I2C_BUS_MAX];
-static struct i2c_driver *drivers[I2C_DRIVER_MAX];
-static int bus_count = 0, driver_count = 0;
-
-int i2c_init(void)
-{
- printk(KERN_INFO "i2c: initialized%s\n",
- scan ? " (i2c bus scan enabled)" : "");
- /* anything to do here ? */
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void i2c_attach_device(struct i2c_bus *bus, struct i2c_driver *driver)
-{
- unsigned long flags;
- struct i2c_device *device;
- int i,j,ack=1;
- unsigned char addr;
-
- /* probe for device */
- LOCK_I2C_BUS(bus);
- for (addr = driver->addr_l; addr <= driver->addr_h; addr += 2)
- {
- i2c_start(bus);
- ack = i2c_sendbyte(bus,addr,0);
- i2c_stop(bus);
- if (!ack)
- break;
- }
- UNLOCK_I2C_BUS(bus);
- if (ack)
- return;
-
- /* got answer */
- for (i = 0; i < I2C_DEVICE_MAX; i++)
- if (NULL == driver->devices[i])
- break;
- if (I2C_DEVICE_MAX == i)
- return;
-
- for (j = 0; j < I2C_DEVICE_MAX; j++)
- if (NULL == bus->devices[j])
- break;
- if (I2C_DEVICE_MAX == j)
- return;
-
- if (NULL == (device = kmalloc(sizeof(struct i2c_device),GFP_KERNEL)))
- return;
- device->bus = bus;
- device->driver = driver;
- device->addr = addr;
-
- /* Attach */
-
- if (driver->attach(device)!=0)
- {
- kfree(device);
- return;
- }
- driver->devices[i] = device;
- driver->devcount++;
- bus->devices[j] = device;
- bus->devcount++;
-
- if (bus->attach_inform)
- bus->attach_inform(bus,driver->id);
- REGPRINT(printk("i2c: device attached: %s (addr=0x%02x, bus=%s, driver=%s)\n",device->name,addr,bus->name,driver->name));
-}
-
-static void i2c_detach_device(struct i2c_device *device)
-{
- int i;
-
- if (device->bus->detach_inform)
- device->bus->detach_inform(device->bus,device->driver->id);
- device->driver->detach(device);
-
- for (i = 0; i < I2C_DEVICE_MAX; i++)
- if (device == device->driver->devices[i])
- break;
- if (I2C_DEVICE_MAX == i)
- {
- printk(KERN_WARNING "i2c: detach_device #1: device not found: %s\n",
- device->name);
- return;
- }
- device->driver->devices[i] = NULL;
- device->driver->devcount--;
-
- for (i = 0; i < I2C_DEVICE_MAX; i++)
- if (device == device->bus->devices[i])
- break;
- if (I2C_DEVICE_MAX == i)
- {
- printk(KERN_WARNING "i2c: detach_device #2: device not found: %s\n",
- device->name);
- return;
- }
- device->bus->devices[i] = NULL;
- device->bus->devcount--;
-
- REGPRINT(printk("i2c: device detached: %s (addr=0x%02x, bus=%s, driver=%s)\n",device->name,device->addr,device->bus->name,device->driver->name));
- kfree(device);
-}
-
-/* ----------------------------------------------------------------------- */
-
-int i2c_register_bus(struct i2c_bus *bus)
-{
- unsigned long flags;
- int i,ack;
-
- memset(bus->devices,0,sizeof(bus->devices));
- bus->devcount = 0;
-
- for (i = 0; i < I2C_BUS_MAX; i++)
- if (NULL == busses[i])
- break;
- if (I2C_BUS_MAX == i)
- return -ENOMEM;
-
- busses[i] = bus;
- bus_count++;
- REGPRINT(printk("i2c: bus registered: %s\n",bus->name));
-
- MOD_INC_USE_COUNT;
-
- if (scan)
- {
- /* scan whole i2c bus */
- LOCK_I2C_BUS(bus);
- for (i = 0; i < 256; i+=2)
- {
- i2c_start(bus);
- ack = i2c_sendbyte(bus,i,0);
- i2c_stop(bus);
- if (!ack)
- {
- printk(KERN_INFO "i2c: scanning bus %s: found device at addr=0x%02x\n",
- bus->name,i);
- }
- }
- UNLOCK_I2C_BUS(bus);
- }
-
- /* probe available drivers */
- for (i = 0; i < I2C_DRIVER_MAX; i++)
- if (drivers[i])
- i2c_attach_device(bus,drivers[i]);
- return 0;
-}
-
-int i2c_unregister_bus(struct i2c_bus *bus)
-{
- int i;
-
- /* detach devices */
- for (i = 0; i < I2C_DEVICE_MAX; i++)
- if (bus->devices[i])
- i2c_detach_device(bus->devices[i]);
-
- for (i = 0; i < I2C_BUS_MAX; i++)
- if (bus == busses[i])
- break;
- if (I2C_BUS_MAX == i)
- {
- printk(KERN_WARNING "i2c: unregister_bus #1: bus not found: %s\n",
- bus->name);
- return -ENODEV;
- }
-
- MOD_DEC_USE_COUNT;
-
- busses[i] = NULL;
- bus_count--;
- REGPRINT(printk("i2c: bus unregistered: %s\n",bus->name));
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int i2c_register_driver(struct i2c_driver *driver)
-{
- int i;
-
- memset(driver->devices,0,sizeof(driver->devices));
- driver->devcount = 0;
-
- for (i = 0; i < I2C_DRIVER_MAX; i++)
- if (NULL == drivers[i])
- break;
- if (I2C_DRIVER_MAX == i)
- return -ENOMEM;
-
- drivers[i] = driver;
- driver_count++;
-
- MOD_INC_USE_COUNT;
-
- REGPRINT(printk("i2c: driver registered: %s\n",driver->name));
-
- /* Probe available busses */
- for (i = 0; i < I2C_BUS_MAX; i++)
- if (busses[i])
- i2c_attach_device(busses[i],driver);
-
- return 0;
-}
-
-int i2c_unregister_driver(struct i2c_driver *driver)
-{
- int i;
-
- /* detach devices */
- for (i = 0; i < I2C_DEVICE_MAX; i++)
- if (driver->devices[i])
- i2c_detach_device(driver->devices[i]);
-
- for (i = 0; i < I2C_DRIVER_MAX; i++)
- if (driver == drivers[i])
- break;
- if (I2C_DRIVER_MAX == i)
- {
- printk(KERN_WARNING "i2c: unregister_driver: driver not found: %s\n",
- driver->name);
- return -ENODEV;
- }
-
- MOD_DEC_USE_COUNT;
-
- drivers[i] = NULL;
- driver_count--;
- REGPRINT(printk("i2c: driver unregistered: %s\n",driver->name));
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int i2c_control_device(struct i2c_bus *bus, int id,
- unsigned int cmd, void *arg)
-{
- int i;
-
- for (i = 0; i < I2C_DEVICE_MAX; i++)
- if (bus->devices[i] && bus->devices[i]->driver->id == id)
- break;
- if (i == I2C_DEVICE_MAX)
- return -ENODEV;
- if (NULL == bus->devices[i]->driver->command)
- return -ENODEV;
- return bus->devices[i]->driver->command(bus->devices[i],cmd,arg);
-}
-
-/* ----------------------------------------------------------------------- */
-
-#define I2C_SET(bus,ctrl,data) (bus->i2c_setlines(bus,ctrl,data))
-#define I2C_GET(bus) (bus->i2c_getdataline(bus))
-
-void i2c_start(struct i2c_bus *bus)
-{
- I2C_SET(bus,0,1);
- I2C_SET(bus,1,1);
- I2C_SET(bus,1,0);
- I2C_SET(bus,0,0);
- I2C_DEBUG(printk("%s: < ",bus->name));
-}
-
-void i2c_stop(struct i2c_bus *bus)
-{
- I2C_SET(bus,0,0);
- I2C_SET(bus,1,0);
- I2C_SET(bus,1,1);
- I2C_DEBUG(printk(">\n"));
-}
-
-void i2c_one(struct i2c_bus *bus)
-{
- I2C_SET(bus,0,1);
- I2C_SET(bus,1,1);
- I2C_SET(bus,0,1);
-}
-
-void i2c_zero(struct i2c_bus *bus)
-{
- I2C_SET(bus,0,0);
- I2C_SET(bus,1,0);
- I2C_SET(bus,0,0);
-}
-
-int i2c_ack(struct i2c_bus *bus)
-{
- int ack;
-
- I2C_SET(bus,0,1);
- I2C_SET(bus,1,1);
- ack = I2C_GET(bus);
- I2C_SET(bus,0,1);
- return ack;
-}
-
-int i2c_sendbyte(struct i2c_bus *bus,unsigned char data,int wait_for_ack)
-{
- int i, ack;
-
- I2C_SET(bus,0,0);
- for (i=7; i>=0; i--)
- (data&(1<<i)) ? i2c_one(bus) : i2c_zero(bus);
- if (wait_for_ack)
- udelay(wait_for_ack);
- ack=i2c_ack(bus);
- I2C_DEBUG(printk("%02x%c ",(int)data,ack?'-':'+'));
- return ack;
-}
-
-unsigned char i2c_readbyte(struct i2c_bus *bus,int last)
-{
- int i;
- unsigned char data=0;
-
- I2C_SET(bus,0,1);
- for (i=7; i>=0; i--)
- {
- I2C_SET(bus,1,1);
- if (I2C_GET(bus))
- data |= (1<<i);
- I2C_SET(bus,0,1);
- }
- last ? i2c_one(bus) : i2c_zero(bus);
- I2C_DEBUG(printk("=%02x%c ",(int)data,last?'-':'+'));
- return data;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int i2c_read(struct i2c_bus *bus, unsigned char addr)
-{
- int ret;
-
- if (bus->i2c_read)
- return bus->i2c_read(bus, addr);
-
- i2c_start(bus);
- i2c_sendbyte(bus,addr,0);
- ret = i2c_readbyte(bus,1);
- i2c_stop(bus);
- return ret;
-}
-
-int i2c_write(struct i2c_bus *bus, unsigned char addr,
- unsigned char data1, unsigned char data2, int both)
-{
- int ack;
-
- if (bus->i2c_write)
- return bus->i2c_write(bus, addr, data1, data2, both);
-
- i2c_start(bus);
- i2c_sendbyte(bus,addr,0);
- ack = i2c_sendbyte(bus,data1,0);
- if (both)
- ack = i2c_sendbyte(bus,data2,0);
- i2c_stop(bus);
- return ack ? -1 : 0 ;
-}
-
-/* ----------------------------------------------------------------------- */
-
-#ifdef MODULE
-
-#if LINUX_VERSION_CODE >= 0x020100
-EXPORT_SYMBOL(i2c_register_bus);
-EXPORT_SYMBOL(i2c_unregister_bus);
-EXPORT_SYMBOL(i2c_register_driver);
-EXPORT_SYMBOL(i2c_unregister_driver);
-EXPORT_SYMBOL(i2c_control_device);
-EXPORT_SYMBOL(i2c_start);
-EXPORT_SYMBOL(i2c_stop);
-EXPORT_SYMBOL(i2c_one);
-EXPORT_SYMBOL(i2c_zero);
-EXPORT_SYMBOL(i2c_ack);
-EXPORT_SYMBOL(i2c_sendbyte);
-EXPORT_SYMBOL(i2c_readbyte);
-EXPORT_SYMBOL(i2c_read);
-EXPORT_SYMBOL(i2c_write);
-#endif
-
-int init_module(void)
-{
- return i2c_init();
-}
-
-void cleanup_module(void)
-{
-}
-#endif
diff --git a/bttv/driver/i2c.h b/bttv/driver/i2c.h
deleted file mode 100644
index e2e6f21..0000000
--- a/bttv/driver/i2c.h
+++ /dev/null
@@ -1,173 +0,0 @@
-#ifndef I2C_H
-#define I2C_H
-
-/*
- * linux i2c interface. Works a little bit like the scsi subsystem.
- * There are:
- *
- * i2c the basic control module (like scsi_mod)
- * bus driver a driver with a i2c bus (hostadapter driver)
- * chip driver a driver for a chip connected
- * to a i2c bus (cdrom/hd driver)
- *
- * A device will be attached to one bus and one chip driver. Every chip
- * driver gets a unique ID.
- *
- * A chip driver can provide a ioctl-like callback for the
- * communication with other parts of the kernel (not every i2c chip is
- * useful without other devices, a TV card tuner for example).
- *
- * "i2c internal" parts of the structs: only the i2c module is allowed to
- * write to them, for others they are read-only.
- *
- */
-
-#define I2C_BUS_MAX 4 /* max # of bus drivers */
-#define I2C_DRIVER_MAX 8 /* max # of chip drivers */
-#define I2C_DEVICE_MAX 8 /* max # if devices per bus/driver */
-
-struct i2c_bus;
-struct i2c_driver;
-struct i2c_device;
-
-#define I2C_DRIVERID_MSP3400 1
-#define I2C_DRIVERID_TUNER 2
-#define I2C_DRIVERID_VIDEOTEXT 3
-
-#define I2C_BUSID_BT848 1 /* I2C bus on a BT848 */
-
-/*
- * struct for a driver for a i2c chip (tuner, soundprocessor,
- * videotext, ... ).
- *
- * a driver will register within the i2c module. The i2c module will
- * callback the driver (i2c_attach) for every device it finds on a i2c
- * bus at the specified address. If the driver decides to "accept"
- * the, device, it must return a struct i2c_device, and NULL
- * otherwise.
- *
- * i2c_detach = i2c_attach ** -1
- *
- * i2c_command will be used to pass commands to the driver in a
- * ioctl-line manner.
- *
- */
-
-struct i2c_driver
-{
- char name[32]; /* some useful label */
- int id; /* device type ID */
- unsigned char addr_l, addr_h; /* address range of the chip */
-
- int (*attach)(struct i2c_device *device);
- int (*detach)(struct i2c_device *device);
- int (*command)(struct i2c_device *device,unsigned int cmd, void *arg);
-
- /* i2c internal */
- struct i2c_device *devices[I2C_DEVICE_MAX];
- int devcount;
-};
-
-
-/*
- * this holds the informations about a i2c bus available in the system.
- *
- * a chip with a i2c bus interface (like bt848) registers the bus within
- * the i2c module. This struct provides functions to access the i2c bus.
- *
- * One must hold the spinlock to access the i2c bus (XXX: is the irqsave
- * required? Maybe better use a semaphore?).
- * [-AC-] having a spinlock_irqsave is only needed if we have drivers wishing
- * to bang their i2c bus from an interrupt.
- *
- * attach/detach_inform is a callback to inform the bus driver about
- * attached chip drivers.
- *
- */
-
-/* needed: unsigned long flags */
-
-#if LINUX_VERSION_CODE >= 0x020100
-#define LOCK_I2C_BUS(bus) spin_lock_irqsave(&(bus->bus_lock),flags);
-#define UNLOCK_I2C_BUS(bus) spin_unlock_irqrestore(&(bus->bus_lock),flags);
-#else
-#define LOCK_I2C_BUS(bus) { save_flags(flags); cli(); }
-#define UNLOCK_I2C_BUS(bus) { restore_flags(flags); }
-#endif
-
-struct i2c_bus
-{
- char name[32]; /* some useful label */
- int id;
- void *data; /* free for use by the bus driver */
-
-#if LINUX_VERSION_CODE >= 0x020100
- spinlock_t bus_lock;
-#endif
-
- /* attach/detach inform callbacks */
- void (*attach_inform)(struct i2c_bus *bus, int id);
- void (*detach_inform)(struct i2c_bus *bus, int id);
-
- /* Software I2C */
- void (*i2c_setlines)(struct i2c_bus *bus, int ctrl, int data);
- int (*i2c_getdataline)(struct i2c_bus *bus);
-
- /* Hardware I2C */
- int (*i2c_read)(struct i2c_bus *bus, unsigned char addr);
- int (*i2c_write)(struct i2c_bus *bus, unsigned char addr,
- unsigned char b1, unsigned char b2, int both);
-
- /* internal data for i2c module */
- struct i2c_device *devices[I2C_DEVICE_MAX];
- int devcount;
-};
-
-
-/*
- * This holds per-device data for a i2c device
- */
-
-struct i2c_device
-{
- char name[32]; /* some useful label */
- void *data; /* free for use by the chip driver */
- unsigned char addr; /* chip addr */
-
- /* i2c internal */
- struct i2c_bus *bus;
- struct i2c_driver *driver;
-};
-
-
-/* ------------------------------------------------------------------- */
-/* i2c module functions */
-
-/* register/unregister a i2c bus */
-int i2c_register_bus(struct i2c_bus *bus);
-int i2c_unregister_bus(struct i2c_bus *bus);
-
-/* register/unregister a chip driver */
-int i2c_register_driver(struct i2c_driver *driver);
-int i2c_unregister_driver(struct i2c_driver *driver);
-
-/* send a command to a chip using the ioctl-like callback interface */
-int i2c_control_device(struct i2c_bus *bus, int id,
- unsigned int cmd, void *arg);
-
-/* i2c bus access functions */
-void i2c_start(struct i2c_bus *bus);
-void i2c_stop(struct i2c_bus *bus);
-void i2c_one(struct i2c_bus *bus);
-void i2c_zero(struct i2c_bus *bus);
-int i2c_ack(struct i2c_bus *bus);
-
-int i2c_sendbyte(struct i2c_bus *bus,unsigned char data,int wait_for_ack);
-unsigned char i2c_readbyte(struct i2c_bus *bus,int last);
-
-/* i2c (maybe) hardware functions */
-int i2c_read(struct i2c_bus *bus, unsigned char addr);
-int i2c_write(struct i2c_bus *bus, unsigned char addr,
- unsigned char b1, unsigned char b2, int both);
-
-#endif /* I2C_H */
diff --git a/bttv/driver/i2c_chardev.c b/bttv/driver/i2c_chardev.c
deleted file mode 100644
index bba81d9..0000000
--- a/bttv/driver/i2c_chardev.c
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * 2.1.x only
- *
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/types.h>
-#include <linux/string.h>
-#include <linux/delay.h>
-#include <linux/locks.h>
-#include <linux/sched.h>
-#include <linux/malloc.h>
-#include <asm/uaccess.h>
-
-#include "i2c.h"
-
-/* ------------------------------------------------------------------------ */
-/* FIXME: stick this into a header file */
-
-/* ioctls */
-#define I2C_SLAVE 0x0706
-#define I2C_WRITE_SIZE 0x0712
-#define I2C_WRITE_BUF 0x0713
-#define I2C_RESET 0x07fd
-
-#define I2C_BUFFER_SIZE 64 /* buffer size for write b4 read */
-
-/* ----------------------------------------------------------------------- */
-/* this allows i2c bus access from userspace
- *
- * taken from the i2c package:
- * available from http://www.tk.uni-linz.ac.at/~simon/private/i2c/
- * written by Simon G. Vogl <simon@tk.uni-linz.ac.at>
- *
- * interface is binary compatible, the detect utility from the i2c package
- * finds all the chips on my hauppauge card, and eeprom tool reads happily
- * the content of the eeprom chip.
- *
- * Not all ioctl's implemented yet, only the most important stuff is in now.
- * Note: address handling (I2C_SLAVE ioctl) is different here:
- * 7bit address+direction bit instead of 8bit "write address"
- *
- */
-
-#define I2C_MAJOR 89 /* Device major number */
-
-#define MAX_BUSSES 8
-static struct i2c_bus *busses[MAX_BUSSES];
-
-/*
- * private information for each open file:
- */
-struct i2c_data {
- int address; /* address slave chip */
- int writelength; /* bytes to write before read */
- char buf[I2C_BUFFER_SIZE];/* write buffer */
-};
-
-
-static long long i2c_dev_lseek(struct file * file, long long offset,
- int origin)
-{
- return -ESPIPE;
-}
-
-
-static int i2c_dev_open(struct inode * inode, struct file * file)
-{
- unsigned int minor = MINOR(inode->i_rdev);
- struct i2c_data *data;
-
- if (!busses[minor])
- return -ENODEV;
-
- if (NULL == (data = kmalloc(sizeof(struct i2c_data),GFP_KERNEL)))
- return -ENOMEM;
-
- data->address = 0x00;
- file->private_data = data;
-
- MOD_INC_USE_COUNT;
- return 0;
-}
-
-static int i2c_dev_release(struct inode * inode, struct file * file)
-{
- struct i2c_data *data;
-
- data=(struct i2c_data *)file->private_data;
- kfree(data);
- file->private_data=NULL;
-
- MOD_DEC_USE_COUNT;
- return 0;
-}
-
-static ssize_t i2c_dev_write(struct file * file, const char * buf,
- size_t count, loff_t *ppos)
-{
- struct inode *inode = file->f_dentry->d_inode;
- unsigned int minor = MINOR(inode->i_rdev);
- const char *ptr = buf;
- struct i2c_data *data;
- int c,ret = 0;
- unsigned long flags;
-
- if (!busses[minor])
- return -EINVAL;
- data=(struct i2c_data *)file->private_data;
-
- LOCK_I2C_BUS(busses[minor]);
- i2c_start(busses[minor]);
- if (0 != i2c_sendbyte(busses[minor], data->address << 1, 0))
- goto ioerr;
- while (count > 0) {
- if (get_user(c,ptr))
- goto fault;
- if (0 != i2c_sendbyte(busses[minor],c,0))
- goto ioerr;
- ptr++;
- ret++;
- count--;
- }
- i2c_stop(busses[minor]);
- UNLOCK_I2C_BUS(busses[minor]);
-
- return ret;
-
-ioerr:
- i2c_stop(busses[minor]);
- UNLOCK_I2C_BUS(busses[minor]);
- return -EREMOTEIO;
-
-fault:
- i2c_stop(busses[minor]);
- UNLOCK_I2C_BUS(busses[minor]);
- return -EFAULT;
-}
-
-static ssize_t i2c_dev_read(struct file * file,char * buf,
- size_t count, loff_t *ppos)
-{
- struct inode *inode = file->f_dentry->d_inode;
- unsigned int minor = MINOR(inode->i_rdev);
- char *ptr = buf;
- struct i2c_data *data;
- int i,val,ret = 0;
- unsigned long flags;
-
- if (!busses[minor])
- return -EINVAL;
- data=(struct i2c_data *)file->private_data;
-
- LOCK_I2C_BUS(busses[minor]);
- if (data->writelength > 0) {
- i2c_start(busses[minor]);
- if (0 != i2c_sendbyte(busses[minor], data->address << 1, 0))
- goto ioerr;
- for (i = 0; i < data->writelength; i++) {
- if (0 != i2c_sendbyte(busses[minor],data->buf[i],0))
- goto ioerr;
- }
- }
- i2c_start(busses[minor]);
- if (0 != i2c_sendbyte(busses[minor], data->address << 1 | 0x01, 0))
- goto ioerr;
- while (count > 0) {
- val = i2c_readbyte(busses[minor], (count == 1) ? 1 : 0);
- if (put_user((char)(val),ptr))
- goto fault;
- ptr++;
- ret++;
- count--;
- }
- i2c_stop(busses[minor]);
- UNLOCK_I2C_BUS(busses[minor]);
-
- return ret;
-
-ioerr:
- i2c_stop(busses[minor]);
- UNLOCK_I2C_BUS(busses[minor]);
- return -EREMOTEIO;
-
-fault:
- i2c_stop(busses[minor]);
- UNLOCK_I2C_BUS(busses[minor]);
- return -EFAULT;
-}
-
-static int i2c_dev_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
-{
- unsigned int minor = MINOR(inode->i_rdev);
- struct i2c_data *data;
- int ret = 0;
- unsigned long flags;
-
- if (!busses[minor])
- return -EINVAL;
- data=(struct i2c_data*)file->private_data;
-
- switch (cmd) {
-#if 0
- case I2C_RETRIES:
- i2c_table[minor].retries = arg;
- break;
-#endif
- case I2C_SLAVE:
- data->address = arg;
- break;
- case I2C_WRITE_SIZE:
- if (arg >= I2C_BUFFER_SIZE)
- return -E2BIG;
- data->writelength = arg;
- break;
- case I2C_WRITE_BUF:
- copy_from_user(data->buf,(char*)arg,data->writelength);
- break;
- case I2C_RESET:
- LOCK_I2C_BUS(busses[minor]);
- i2c_reset(busses[minor]);
- UNLOCK_I2C_BUS(busses[minor]);
- break;
- default:
- ret = -EINVAL;
- }
- return ret;
-}
-
-static struct file_operations i2c_fops = {
- i2c_dev_lseek,
- i2c_dev_read,
- i2c_dev_write,
- NULL, /* i2c_readdir */
- NULL, /* i2c_select */
- i2c_dev_ioctl,
- NULL, /* i2c_mmap */
- i2c_dev_open,
- i2c_dev_release,
-};
-
-/* ----------------------------------------------------------------------- */
-
-static int chardev_attach(struct i2c_device *device)
-{
- int i;
-
- for (i = 0; i < MAX_BUSSES; i++)
- if (NULL == busses[i])
- break;
- if (i == MAX_BUSSES)
- return -1;
- busses[i] = device->bus;
- strcpy(device->name,"chardev");
- printk("i2c_chardev: attached bus %s to minor %d\n",busses[i]->name,i);
-
- return 0;
-}
-
-static int chardev_detach(struct i2c_device *device)
-{
- int i;
-
- for (i = 0; i < MAX_BUSSES; i++)
- if (device->bus == busses[i])
- break;
- if (i == MAX_BUSSES)
- return -1;
- printk("i2c_chardev: detached bus %s from minor %d\n",busses[i]->name,i);
- busses[i] = NULL;
-
- return 0;
-}
-
-struct i2c_driver i2c_driver_chardev = {
- "chardev", /* name */
- I2C_DRIVERID_CHARDEV, /* ID */
- 0, 0xfe, /* addr range */
-
- chardev_attach,
- chardev_detach,
- NULL
-};
-
-/* ----------------------------------------------------------------------- */
-
-#ifdef MODULE
-
-int init_module(void)
-{
- if (register_chrdev(I2C_MAJOR,"i2c",&i2c_fops)) {
- printk("i2c: unable to get major %d\n", I2C_MAJOR);
- return -EBUSY;
- }
- i2c_register_driver(&i2c_driver_chardev);
- return 0;
-}
-
-void cleanup_module(void)
-{
- i2c_unregister_driver(&i2c_driver_chardev);
- unregister_chrdev(I2C_MAJOR,"i2c");
-}
-
-#endif
-
diff --git a/bttv/driver/msp3400.c b/bttv/driver/msp3400.c
deleted file mode 100644
index d8e1e9d..0000000
--- a/bttv/driver/msp3400.c
+++ /dev/null
@@ -1,1129 +0,0 @@
-/*
- * programming the msp34* sound processor family
- *
- * (c) 1997,1998 Gerd Knorr <kraxel@cs.tu-berlin.de>
- *
- * what works and what doesn't:
- *
- * AM-Mono
- * probably doesn't (untested)
- *
- * FM-Mono
- * should work. The stereo modes are backward compatible to FM-mono,
- * therefore FM-Mono should be allways available.
- *
- * FM-Stereo (B/G, used in germany)
- * should work, with autodetect
- *
- * FM-Stereo (satellite)
- * should work, no autodetect (i.e. default is mono, but you can
- * switch to stereo -- untested)
- *
- * NICAM (B/G, used in UK, Scandinavia and Spain)
- * should work, with autodetect. Support for NICAM was added by
- * Pekka Pietikainen <pp@netppl.fi>
- *
- *
- * TODO:
- * - better SAT support
- *
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <linux/timer.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/malloc.h>
-/* #include <asm/smp_lock.h> */
-
-/* kernel_thread */
-#define __KERNEL_SYSCALLS__
-#include <linux/unistd.h>
-
-#include "i2c.h"
-#include "videodev.h"
-
-#include "msp3400.h"
-
-
-/* sound mixer stuff */
-#include <linux/config.h>
-
-#if LINUX_VERSION_CODE > 0x020140 /* need modular sound driver */
-# if defined(CONFIG_SOUND) || defined(CONFIG_SOUND_MODULE)
-# define REGISTER_MIXER 1
-# endif
-#endif
-
-
-int debug = 0; /* insmod parameter */
-
-struct msp3400c {
- struct i2c_bus *bus;
-
- int nicam;
- int mode;
- int norm;
- int stereo;
-
- int mixer;
- int left, right; /* volume */
- int bass, treble;
-
- /* thread */
- struct task_struct *thread;
- struct semaphore *wait;
- struct semaphore *notify;
- int active,restart,rmmod;
-
- int watch_stereo;
- struct timer_list wake_stereo;
-};
-
-#define VIDEO_MODE_RADIO 16 /* norm magic for radio mode */
-
-/* ---------------------------------------------------------------------- */
-
-#define dprintk if (debug) printk
-
-#if LINUX_VERSION_CODE < 0x020100
-/* 2.0.x */
-#define signal_pending(current) (current->signal & ~current->blocked)
-#define sigfillset(set)
-#define mdelay(x) udelay(1000*x)
-#else
-MODULE_PARM(debug,"i");
-#endif
-
-/* ---------------------------------------------------------------------- */
-
-#define I2C_MSP3400C 0x80
-#define I2C_MSP3400C_DEM 0x10
-#define I2C_MSP3400C_DFP 0x12
-
-/* ----------------------------------------------------------------------- */
-/* functions for talking to the MSP3400C Sound processor */
-
-static int msp3400c_reset(struct i2c_bus *bus)
-{
- int ret = 0;
-
- mdelay(2);
- i2c_start(bus);
- i2c_sendbyte(bus, I2C_MSP3400C,2000);
- i2c_sendbyte(bus, 0x00,0);
- i2c_sendbyte(bus, 0x80,0);
- i2c_sendbyte(bus, 0x00,0);
- i2c_stop(bus);
- mdelay(2);
- i2c_start(bus);
- if (0 != i2c_sendbyte(bus, I2C_MSP3400C,2000) ||
- 0 != i2c_sendbyte(bus, 0x00,0) ||
- 0 != i2c_sendbyte(bus, 0x00,0) ||
- 0 != i2c_sendbyte(bus, 0x00,0)) {
- ret = -1;
- printk(KERN_ERR "msp3400: chip reset failed, penguin on i2c bus?\n");
- }
- i2c_stop(bus);
- mdelay(2);
- return ret;
-}
-
-static int
-msp3400c_read(struct i2c_bus *bus, int dev, int addr)
-{
- int ret=0;
- short val = 0;
- i2c_start(bus);
- if (0 != i2c_sendbyte(bus, I2C_MSP3400C,2000) ||
- 0 != i2c_sendbyte(bus, dev+1, 0) ||
- 0 != i2c_sendbyte(bus, addr >> 8, 0) ||
- 0 != i2c_sendbyte(bus, addr & 0xff, 0)) {
- ret = -1;
- } else {
- i2c_start(bus);
- if (0 != i2c_sendbyte(bus, I2C_MSP3400C+1,2000)) {
- ret = -1;
- } else {
- val |= (int)i2c_readbyte(bus,0) << 8;
- val |= (int)i2c_readbyte(bus,1);
- }
- }
- i2c_stop(bus);
- if (-1 == ret) {
- printk(KERN_WARNING "msp3400: I/O error, trying reset (read %s 0x%x)\n",
- (dev == I2C_MSP3400C_DEM) ? "Demod" : "Audio", addr);
- msp3400c_reset(bus);
- }
- return val;
-}
-
-static int
-msp3400c_write(struct i2c_bus *bus, int dev, int addr, int val)
-{
- int ret = 0;
-
- i2c_start(bus);
- if (0 != i2c_sendbyte(bus, I2C_MSP3400C,2000) ||
- 0 != i2c_sendbyte(bus, dev, 0) ||
- 0 != i2c_sendbyte(bus, addr >> 8, 0) ||
- 0 != i2c_sendbyte(bus, addr & 0xff, 0) ||
- 0 != i2c_sendbyte(bus, val >> 8, 0) ||
- 0 != i2c_sendbyte(bus, val & 0xff, 0))
- ret = -1;
- i2c_stop(bus);
- if (-1 == ret) {
- printk(KERN_WARNING "msp3400: I/O error, trying reset (write %s 0x%x)\n",
- (dev == I2C_MSP3400C_DEM) ? "Demod" : "Audio", addr);
- msp3400c_reset(bus);
- }
- return ret;
-}
-
-/* ------------------------------------------------------------------------ */
-
-/* This macro is allowed for *constants* only, gcc must calculate it
- at compile time. Remember -- no floats in kernel mode */
-#define MSP_CARRIER(freq) ((int)((float)(freq/18.432)*(1<<24)))
-
-#define MSP_MODE_AM_DETECT 0
-#define MSP_MODE_FM_RADIO 2
-#define MSP_MODE_FM_TERRA 3
-#define MSP_MODE_FM_SAT 4
-#define MSP_MODE_FM_NICAM1 5
-#define MSP_MODE_FM_NICAM2 6
-
-static struct MSP_INIT_DATA_DEM {
- int fir1[6];
- int fir2[6];
- int cdo1;
- int cdo2;
- int ad_cv;
- int mode_reg;
- int dfp_src;
- int dfp_matrix;
-} msp_init_data[] = {
- /* AM (for carrier detect / msp3400) */
- { { 75, 19, 36, 35, 39, 40 }, { 75, 19, 36, 35, 39, 40 },
- MSP_CARRIER(5.5), MSP_CARRIER(5.5),
- 0x00d0, 0x0500, 0x0020, 0x3000},
-
- /* AM (for carrier detect / msp3410) */
- { { -1, -1, -8, 2, 59, 126 }, { -1, -1, -8, 2, 59, 126 },
- MSP_CARRIER(5.5), MSP_CARRIER(5.5),
- 0x00d0, 0x0100, 0x0020, 0x3000},
-
- /* FM Radio */
- { { -8, -8, 4, 6, 78, 107 }, { -8, -8, 4, 6, 78, 107 },
- MSP_CARRIER(10.7), MSP_CARRIER(10.7),
- 0x00d0, 0x0480, 0x0020, 0x3002 },
-
- /* Terrestial FM-mono */
- { { 3, 18, 27, 48, 66, 72 }, { 3, 18, 27, 48, 66, 72 },
- MSP_CARRIER(5.5), MSP_CARRIER(5.5),
- 0x00d0, 0x0480, 0x0030, 0x3000},
-
- /* Sat FM-mono */
- { { 1, 9, 14, 24, 33, 37 }, { 3, 18, 27, 48, 66, 72 },
- MSP_CARRIER(6.5), MSP_CARRIER(6.5),
- 0x00c6, 0x0480, 0x0000, 0x3000},
-
- /* NICAM B/G, D/K */
- { { -2, -8, -10, 10, 50, 86 }, { 3, 18, 27, 48, 66, 72 },
- MSP_CARRIER(5.5), MSP_CARRIER(5.5),
- 0x00d0, 0x0040, 0x0120, 0x3000},
-
- /* NICAM I */
- { { 2, 4, -6, -4, 40, 94 }, { 3, 18, 27, 48, 66, 72 },
- MSP_CARRIER(5.5), MSP_CARRIER(5.5),
- 0x00d0, 0x0040, 0x0120, 0x3000},
-};
-
-struct CARRIER_DETECT {
- int cdo;
- char *name;
-};
-
-static struct CARRIER_DETECT carrier_detect_main[] = {
- /* main carrier */
- { MSP_CARRIER(4.5), "4.5 NTSC" },
- { MSP_CARRIER(5.5), "5.5 PAL B/G" },
- { MSP_CARRIER(6.0), "6.0 PAL I" },
- { MSP_CARRIER(6.5), "6.5 PAL SAT / SECAM" }
-};
-
-static struct CARRIER_DETECT carrier_detect_55[] = {
- /* PAL B/G */
- { MSP_CARRIER(5.7421875), "5.742 PAL B/G FM-stereo" },
- { MSP_CARRIER(5.85), "5.85 PAL B/G NICAM" }
-};
-
-static struct CARRIER_DETECT carrier_detect_65[] = {
- /* PAL SAT / SECAM */
- { MSP_CARRIER(7.02), "7.02 PAL SAT FM-stereo s/b" },
- { MSP_CARRIER(7.20), "7.20 PAL SAT FM-stereo s" },
- { MSP_CARRIER(7.38), "7.38 PAL SAT FM-stereo b" },
-};
-
-#define CARRIER_COUNT(x) (sizeof(x)/sizeof(struct CARRIER_DETECT))
-
-/* ------------------------------------------------------------------------ */
-
-static void msp3400c_setcarrier(struct i2c_bus *bus, int cdo1, int cdo2)
-{
- msp3400c_write(bus,I2C_MSP3400C_DEM, 0x0093, cdo1 & 0xfff);
- msp3400c_write(bus,I2C_MSP3400C_DEM, 0x009b, cdo1 >> 12);
- msp3400c_write(bus,I2C_MSP3400C_DEM, 0x00a3, cdo2 & 0xfff);
- msp3400c_write(bus,I2C_MSP3400C_DEM, 0x00ab, cdo2 >> 12);
-}
-
-static void msp3400c_setvolume(struct i2c_bus *bus, int left, int right)
-{
- int vol,val,balance;
-
- vol = (left > right) ? left : right;
- val = (vol * 0x73 / 65535) << 8;
- balance = 0;
- if (vol > 0)
- balance = ((right-left) * 127) / vol;
-
- dprintk("msp3400: setvolume: %d:%d 0x%02x 0x%02x\n",
- left,right,val>>8,balance);
- msp3400c_write(bus,I2C_MSP3400C_DFP, 0x0000, val); /* loudspeaker */
- msp3400c_write(bus,I2C_MSP3400C_DFP, 0x0006, val); /* headphones */
- /* scart - on/off only */
- msp3400c_write(bus,I2C_MSP3400C_DFP, 0x0007, val ? 0x4000 : 0);
- msp3400c_write(bus,I2C_MSP3400C_DFP, 0x0001, balance << 8);
-}
-
-static void msp3400c_setbass(struct i2c_bus *bus, int bass)
-{
- int val = ((bass-32768) * 0x60 / 65535) << 8;
-
- dprintk("msp3400: setbass: %d 0x%02x\n",bass, val>>8);
- msp3400c_write(bus,I2C_MSP3400C_DFP, 0x0002, val); /* loudspeaker */
-}
-
-static void msp3400c_settreble(struct i2c_bus *bus, int treble)
-{
- int val = ((treble-32768) * 0x60 / 65535) << 8;
-
- dprintk("msp3400: settreble: %d 0x%02x\n",treble, val>>8);
- msp3400c_write(bus,I2C_MSP3400C_DFP, 0x0003, val); /* loudspeaker */
-}
-
-static void msp3400c_setmode(struct msp3400c *msp, int type)
-{
- int i;
-
- dprintk("msp3400: setmode: %d\n",type);
- msp->mode = type;
- msp->stereo = VIDEO_SOUND_MONO;
-
- msp3400c_write(msp->bus,I2C_MSP3400C_DEM, 0x00bb, /* ad_cv */
- msp_init_data[type].ad_cv);
-
- for (i = 5; i >= 0; i--) /* fir 1 */
- msp3400c_write(msp->bus,I2C_MSP3400C_DEM, 0x0001,
- msp_init_data[type].fir1[i]);
-
- msp3400c_write(msp->bus,I2C_MSP3400C_DEM, 0x0005, 0x0004); /* fir 2 */
- msp3400c_write(msp->bus,I2C_MSP3400C_DEM, 0x0005, 0x0040);
- msp3400c_write(msp->bus,I2C_MSP3400C_DEM, 0x0005, 0x0000);
- for (i = 5; i >= 0; i--)
- msp3400c_write(msp->bus,I2C_MSP3400C_DEM, 0x0005,
- msp_init_data[type].fir2[i]);
-
- msp3400c_write(msp->bus,I2C_MSP3400C_DEM, 0x0083, /* MODE_REG */
- msp_init_data[type].mode_reg);
-
- msp3400c_setcarrier(msp->bus, msp_init_data[type].cdo1,
- msp_init_data[type].cdo2);
-
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x0008,
- msp_init_data[type].dfp_src);
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x0009,
- msp_init_data[type].dfp_src);
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x000a,
- msp_init_data[type].dfp_src);
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x000e,
- msp_init_data[type].dfp_matrix);
-
- if (msp->nicam) {
- /* msp3410 needs some more initialization */
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x0010, 0x3000);
- }
-}
-
-static void msp3400c_setstereo(struct msp3400c *msp, int mode)
-{
- int nicam=0; /* channel source: FM/AM or nicam */
-
- /* switch demodulator */
- switch (msp->mode) {
- case MSP_MODE_FM_TERRA:
- dprintk("msp3400: B/G setstereo: %d\n",mode);
- msp->stereo = mode;
- msp3400c_setcarrier(msp->bus,MSP_CARRIER(5.7421875),MSP_CARRIER(5.5));
- switch (mode) {
- case VIDEO_SOUND_STEREO:
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x000e, 0x3001);
- break;
- case VIDEO_SOUND_MONO:
- case VIDEO_SOUND_LANG1:
- case VIDEO_SOUND_LANG2:
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x000e, 0x3000);
- break;
- }
- break;
- case MSP_MODE_FM_SAT:
- dprintk("msp3400: sat setstereo: %d\n",mode);
- msp->stereo = mode;
- switch (mode) {
- case VIDEO_SOUND_MONO:
- msp3400c_setcarrier(msp->bus, MSP_CARRIER(6.5), MSP_CARRIER(6.5));
- break;
- case VIDEO_SOUND_STEREO:
- msp3400c_setcarrier(msp->bus, MSP_CARRIER(7.2), MSP_CARRIER(7.02));
- break;
- case VIDEO_SOUND_LANG1:
- msp3400c_setcarrier(msp->bus, MSP_CARRIER(7.38), MSP_CARRIER(7.02));
- break;
- case VIDEO_SOUND_LANG2:
- msp3400c_setcarrier(msp->bus, MSP_CARRIER(7.38), MSP_CARRIER(7.02));
- break;
- }
- break;
- case MSP_MODE_FM_NICAM1:
- dprintk("msp3400: NICAM1 setstereo: %d\n",mode);
- msp->stereo = mode;
- msp3400c_setcarrier(msp->bus,MSP_CARRIER(5.85),MSP_CARRIER(5.5));
- nicam=0x0100;
- break;
- default:
- /* can't do stereo - abort here */
- return;
- }
-
- /* switch audio */
- switch (mode) {
- case VIDEO_SOUND_STEREO:
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x0008,0x0020|nicam);
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x0009,0x0020|nicam);
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x000a,0x0020|nicam);
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x0005,0x4000);
- break;
- case VIDEO_SOUND_MONO:
- case VIDEO_SOUND_LANG1:
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x0008,0x0000|nicam);
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x0009,0x0000|nicam);
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x000a,0x0000|nicam);
- break;
- case VIDEO_SOUND_LANG2:
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x0008,0x0010|nicam);
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x0009,0x0010|nicam);
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x000a,0x0010|nicam);
- break;
- }
-}
-
-/* ----------------------------------------------------------------------- */
-
-struct REGISTER_DUMP {
- int addr;
- char *name;
-};
-
-struct REGISTER_DUMP d1[] = {
- { 0x007e, "autodetect" },
- { 0x0023, "C_AD_BITS " },
- { 0x0038, "ADD_BITS " },
- { 0x003e, "CIB_BITS " },
- { 0x0057, "ERROR_RATE" },
-};
-
-/*
- * A kernel thread for msp3400 control -- we don't want to block the
- * in the ioctl while doing the sound carrier & stereo detect
- */
-
-static void msp3400c_stereo_wake(unsigned long data)
-{
- struct msp3400c *msp = (struct msp3400c*)data; /* XXX alpha ??? */
-
- if (!msp->active)
- up(msp->wait);
-}
-
-static int msp3400c_thread(void *data)
-{
- unsigned long flags;
- struct msp3400c *msp = data;
- struct semaphore sem = MUTEX_LOCKED;
-
- struct CARRIER_DETECT *cd;
- int count, max1,max2,val1,val2, val,this;
- int newstereo;
-
- /* lock_kernel(); */
-
- exit_mm(current);
- current->session = 1;
- current->pgrp = 1;
- sigfillset(&current->blocked);
- current->fs->umask = 0;
- strcpy(current->comm,"msp3400");
-
- msp->wait = &sem;
- msp->thread = current;
-
- /* unlock_kernel(); */
-
- dprintk("msp3400: thread: start\n");
- if(msp->notify != NULL)
- up(msp->notify);
-
- for (;;) {
- if (msp->rmmod)
- goto done;
- dprintk("msp3400: thread: sleep\n");
- down_interruptible(&sem);
- dprintk("msp3400: thread: wakeup\n");
- if (msp->rmmod || signal_pending(current))
- goto done;
-
- if (VIDEO_MODE_RADIO == msp->norm)
- continue; /* nothing to do */
-
- msp->active = 1;
-
- if (msp->watch_stereo) {
- /* do that stereo/multilang handling */
- LOCK_I2C_BUS(msp->bus);
- newstereo = msp->stereo;
- switch (msp->mode) {
- case MSP_MODE_FM_TERRA:
- val = msp3400c_read(msp->bus, I2C_MSP3400C_DFP, 0x18);
- dprintk("msp3400: stereo detect register: %d\n",val);
-
- if (val > 4096) {
- newstereo = VIDEO_SOUND_STEREO;
- } else if (val < -4096) {
- newstereo = VIDEO_SOUND_LANG1;
- } else {
- newstereo = VIDEO_SOUND_MONO;
- }
- break;
- case MSP_MODE_FM_NICAM1:
- val = msp3400c_read(msp->bus, I2C_MSP3400C_DEM, 0x23);
- switch ((val & 0x1e) >> 1) {
- case 0:
- case 8:
- newstereo = VIDEO_SOUND_STEREO;
- break;
- default:
- newstereo = VIDEO_SOUND_MONO;
- break;
- }
- break;
- }
- if (msp->stereo != newstereo) {
- dprintk("msp3400: watch: stereo %d ==> %d\n",
- msp->stereo,newstereo);
- msp3400c_setstereo(msp,newstereo);
- }
- UNLOCK_I2C_BUS(msp->bus);
- if (msp->watch_stereo) {
- del_timer(&msp->wake_stereo);
- msp->wake_stereo.expires = jiffies + 5*HZ;
- add_timer(&msp->wake_stereo);
- }
-
- msp->active = 0;
- continue;
- }
-
- restart:
- LOCK_I2C_BUS(msp->bus);
- msp3400c_setvolume(msp->bus, 0, 0);
- msp3400c_setmode(msp, MSP_MODE_AM_DETECT);
- val1 = val2 = max1 = max2 = 0;
- del_timer(&msp->wake_stereo);
- msp->watch_stereo = 0;
-
- /* carrier detect pass #1 -- main carrier */
- cd = carrier_detect_main; count = CARRIER_COUNT(carrier_detect_main);
- for (this = 0; this < count; this++) {
- msp3400c_setcarrier(msp->bus, cd[this].cdo,cd[this].cdo);
- UNLOCK_I2C_BUS(msp->bus);
-
- current->state = TASK_INTERRUPTIBLE;
- current->timeout = jiffies + HZ/25;
- schedule();
- if (signal_pending(current))
- goto done;
- if (msp->restart) {
- msp->restart = 0;
- goto restart;
- }
-
- LOCK_I2C_BUS(msp->bus);
- val = msp3400c_read(msp->bus, I2C_MSP3400C_DFP, 0x1b);
- if (val1 < val)
- val1 = val, max1 = this;
- dprintk("msp3400: carrier1 val: %5d / %s\n", val,cd[this].name);
- }
-
- /* carrier detect pass #2 -- second (stereo) carrier */
- switch (max1) {
- case 1: /* 5.5 */
- cd = carrier_detect_55; count = CARRIER_COUNT(carrier_detect_55);
- break;
- case 3: /* 6.5 */
- cd = carrier_detect_65; count = CARRIER_COUNT(carrier_detect_65);
- break;
- case 0: /* 4.5 */
- case 2: /* 6.0 */
- default:
- cd = NULL; count = 0;
- break;
- }
- for (this = 0; this < count; this++) {
- msp3400c_setcarrier(msp->bus, cd[this].cdo,cd[this].cdo);
- UNLOCK_I2C_BUS(msp->bus);
-
- current->state = TASK_INTERRUPTIBLE;
- current->timeout = jiffies + HZ/25;
- schedule();
- if (signal_pending(current))
- goto done;
- if (msp->restart) {
- msp->restart = 0;
- goto restart;
- }
-
- LOCK_I2C_BUS(msp->bus);
- val = msp3400c_read(msp->bus, I2C_MSP3400C_DFP, 0x1b);
- if (val2 < val)
- val2 = val, max2 = this;
- dprintk("msp3400: carrier2 val: %5d / %s\n", val,cd[this].name);
- }
-
- /* programm the msp3400 according to the results */
- switch (max1) {
- case 0: /* 4.5 */
- case 1: /* 5.5 */
- msp3400c_setmode(msp, MSP_MODE_FM_TERRA);
- msp3400c_setcarrier(msp->bus, carrier_detect_main[max1].cdo,
- carrier_detect_main[max1].cdo);
- if (max2 == 0) {
- /* B/G FM-stereo */
- msp3400c_setstereo(msp, VIDEO_SOUND_MONO);
- msp->watch_stereo = 1;
- }
- if (max2 == 1 && msp->nicam) {
- /* B/G NICAM */
- msp3400c_setmode(msp, MSP_MODE_FM_NICAM1);
- /* msp3400c_write(msp->bus, I2C_MSP3400C_DFP, 0x21, 0x01); */
- msp3400c_setcarrier(msp->bus, MSP_CARRIER(5.85),
- MSP_CARRIER(5.5));
- msp->watch_stereo = 1;
- }
- break;
- case 2: /* 6.0 */
- case 3: /* 6.5 */
- default:
- msp3400c_setmode(msp, MSP_MODE_FM_TERRA);
- msp3400c_setcarrier(msp->bus, carrier_detect_main[max1].cdo,
- carrier_detect_main[max1].cdo);
- msp3400c_setstereo(msp, VIDEO_SOUND_STEREO);
- break;
- }
-
- /* unmute */
- msp3400c_setvolume(msp->bus, msp->left, msp->right);
- UNLOCK_I2C_BUS(msp->bus);
-
- if (msp->watch_stereo) {
- del_timer(&msp->wake_stereo);
- msp->wake_stereo.expires = jiffies + HZ;
- add_timer(&msp->wake_stereo);
- }
- msp->active = 0;
- }
-
-done:
- dprintk("msp3400: thread: exit\n");
- msp->wait = NULL;
- msp->active = 0;
- msp->thread = NULL;
-
- if(msp->notify != NULL)
- up(msp->notify);
- return 0;
-}
-
-
-#if 0 /* not finished yet */
-
-static int msp3410d_thread(void *data)
-{
- unsigned long flags;
- struct msp3400c *msp = data;
- struct semaphore sem = MUTEX_LOCKED;
- int i, val;
-
- /* lock_kernel(); */
-
- exit_mm(current);
- current->session = 1;
- current->pgrp = 1;
- sigfillset(&current->blocked);
- current->fs->umask = 0;
- strcpy(current->comm,"msp3410 (nicam)");
-
- msp->wait = &sem;
- msp->thread = current;
-
- /* unlock_kernel(); */
-
- dprintk("msp3410: thread: start\n");
- if(msp->notify != NULL)
- up(msp->notify);
-
- for (;;) {
- if (msp->rmmod)
- goto done;
- dprintk("msp3410: thread: sleep\n");
- down_interruptible(&sem);
- dprintk("msp3410: thread: wakeup\n");
- if (msp->rmmod)
- goto done;
-
- if (VIDEO_MODE_RADIO == msp->norm)
- continue; /* nothing to do */
-
- msp->active = 1;
-
- restart:
- LOCK_I2C_BUS(msp->bus);
- /* mute */
- msp3400c_setvolume(msp->bus, 0);
- /* quick & dirty hack:
- get the audio proccessor into some useful state */
- msp3400c_setmode(msp, MSP_MODE_FM_NICAM1);
- /* kick autodetect */
- msp3400c_write(msp->bus, I2C_MSP3400C_DFP, 0x20, 0x01);
- msp3400c_write(msp->bus, I2C_MSP3400C_DFP, 0x21, 0x01);
- UNLOCK_I2C_BUS(msp->bus);
-
- /* wait 1 sec */
- current->state = TASK_INTERRUPTIBLE;
- current->timeout = jiffies + HZ;
- schedule();
- if (signal_pending(current))
- goto done;
- if (msp->restart) {
- msp->restart = 0;
- goto restart;
- }
-
- LOCK_I2C_BUS(msp->bus);
- /* debug register dump */
- for (i = 0; i < sizeof(d1)/sizeof(struct REGISTER_DUMP); i++) {
- val = msp3400c_read(msp->bus,I2C_MSP3400C_DEM,d1[i].addr);
- printk(KERN_DEBUG "msp3400: %s = 0x%x\n",d1[i].name,val);
- }
- /* unmute */
- msp3400c_setvolume(msp->bus, msp->volume);
- UNLOCK_I2C_BUS(msp->bus);
-
- msp->active = 0;
- }
-
-done:
- dprintk("msp3410: thread: exit\n");
- msp->wait = NULL;
- msp->active = 0;
- msp->thread = NULL;
-
- if(msp->notify != NULL)
- up(msp->notify);
- return 0;
-}
-#endif
-
-/* ----------------------------------------------------------------------- */
-/* mixer stuff -- with the modular sound driver in 2.1.x we can easily */
-/* register the msp3400 as mixer device */
-
-#ifdef REGISTER_MIXER
-
-#include <linux/soundcard.h>
-#include <../drivers/sound/sound_config.h>
-#include <../drivers/sound/dev_table.h>
-
-static int mix_to_v4l(int i)
-{
- int r;
-
- r = ((i & 0xff) * 65536 + 50) / 100;
- if (r > 65535) r = 65535;
- if (r < 0) r = 0;
- return r;
-}
-
-static int v4l_to_mix(int i)
-{
- int r;
-
- r = (i * 100 + 32768) / 65536;
- if (r > 100) r = 100;
- if (r < 0) r = 0;
- return r | (r << 8);
-}
-
-static int v4l_to_mix2(int l, int r)
-{
- r = (r * 100 + 32768) / 65536;
- if (r > 100) r = 100;
- if (r < 0) r = 0;
- l = (l * 100 + 32768) / 65536;
- if (l > 100) l = 100;
- if (l < 0) l = 0;
- return (r << 8) | l;
-}
-
-static int msp3400c_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
-{
- struct msp3400c *msp = mixer_devs[dev]->devc;
- unsigned long flags;
- int ret,val = 0;
-
- if (_SIOC_DIR(cmd) & _SIOC_WRITE)
- if (get_user(val, (int *)arg))
- return -EFAULT;
-
- switch (cmd) {
- case MIXER_READ(SOUND_MIXER_RECMASK):
- case MIXER_READ(SOUND_MIXER_CAPS):
- case MIXER_READ(SOUND_MIXER_RECSRC):
- case MIXER_WRITE(SOUND_MIXER_RECSRC):
- ret = 0;
- break;
-
- case MIXER_READ(SOUND_MIXER_STEREODEVS):
- ret = SOUND_MASK_VOLUME;
- break;
- case MIXER_READ(SOUND_MIXER_DEVMASK):
- ret = SOUND_MASK_VOLUME | SOUND_MASK_BASS | SOUND_MASK_TREBLE;
- break;
-
- case MIXER_WRITE(SOUND_MIXER_VOLUME):
- msp->left = mix_to_v4l(val);
- msp->right = mix_to_v4l(val >> 8);
- LOCK_I2C_BUS(msp->bus);
- msp3400c_setvolume(msp->bus,msp->left,msp->right);
- UNLOCK_I2C_BUS(msp->bus);
- /* fall */
- case MIXER_READ(SOUND_MIXER_VOLUME):
- ret = v4l_to_mix2(msp->left, msp->right);
- break;
-
- case MIXER_WRITE(SOUND_MIXER_BASS):
- msp->bass = mix_to_v4l(val);
- LOCK_I2C_BUS(msp->bus);
- msp3400c_setbass(msp->bus,msp->bass);
- UNLOCK_I2C_BUS(msp->bus);
- /* fall */
- case MIXER_READ(SOUND_MIXER_BASS):
- ret = v4l_to_mix(msp->bass);
- break;
-
- case MIXER_WRITE(SOUND_MIXER_TREBLE):
- msp->treble = mix_to_v4l(val);
- LOCK_I2C_BUS(msp->bus);
- msp3400c_settreble(msp->bus,msp->treble);
- UNLOCK_I2C_BUS(msp->bus);
- /* fall */
- case MIXER_READ(SOUND_MIXER_TREBLE):
- ret = v4l_to_mix(msp->treble);
- break;
-
- default:
- return -EINVAL;
- }
- if (put_user(ret, (int *)arg))
- return -EFAULT;
- return 0;
-}
-
-struct mixer_operations msp3400c_mixer = {
- "video4linux",
- "TV card sound (msp3400)",
- msp3400c_mixer_ioctl
-};
-
-static int msp3400c_mixer_init(struct msp3400c *msp)
-{
- int m;
-
- msp->mixer = m = sound_alloc_mixerdev();
- if (m == -1)
- return -1;
-
- mixer_devs[m] = (struct mixer_operations *)
- kmalloc(sizeof(struct mixer_operations), GFP_KERNEL);
- if (mixer_devs[m] == NULL) {
- printk(KERN_ERR "msp3400c: can't allocate memory\n");
- sound_unload_mixerdev(m);
- return -1;
- }
- memcpy(mixer_devs[m],&msp3400c_mixer,sizeof(struct mixer_operations));
- mixer_devs[m]->devc = msp;
- return 0;
-}
-
-static int msp3400c_mixer_close(struct msp3400c *msp)
-{
- int m = msp->mixer;
-
- if (m != -1 ) {
- sound_unload_mixerdev(m);
- kfree(mixer_devs[m]);
- }
- return 0;
-}
-
-#endif
-
-/* ----------------------------------------------------------------------- */
-
-static int msp3400c_attach(struct i2c_device *device)
-{
- unsigned long flags;
- struct semaphore sem = MUTEX_LOCKED;
- struct msp3400c *msp;
- int rev1,rev2;
-
- device->data = msp = kmalloc(sizeof(struct msp3400c),GFP_KERNEL);
- if (NULL == msp)
- return -ENOMEM;
- memset(msp,0,sizeof(struct msp3400c));
- msp->bus = device->bus;
- msp->left = 65535;
- msp->right = 65535;
- msp->bass = 32768;
- msp->treble = 32768;
-
- LOCK_I2C_BUS(msp->bus);
- if (-1 == msp3400c_reset(msp->bus)) {
- UNLOCK_I2C_BUS(msp->bus);
- kfree(msp);
- dprintk("msp3400: no chip found\n");
- return -1;
- }
-
- rev1 = msp3400c_read(msp->bus, I2C_MSP3400C_DFP, 0x1e);
- rev2 = msp3400c_read(msp->bus, I2C_MSP3400C_DFP, 0x1f);
- if (0 == rev1 && 0 == rev2) {
- UNLOCK_I2C_BUS(msp->bus);
- kfree(msp);
- printk("msp3400: error while reading chip version\n");
- return -1;
- }
-
- msp3400c_setmode(msp, MSP_MODE_FM_TERRA);
- msp3400c_setvolume(msp->bus, msp->left, msp->right);
- msp3400c_setbass(msp->bus, msp->bass);
- msp3400c_settreble(msp->bus, msp->treble);
-
-#if 0
- /* this will turn on a 1kHz beep - might be useful for debugging... */
- msp3400c_write(msp->bus,I2C_MSP3400C_DFP, 0x0014, 0x1040);
-#endif
- UNLOCK_I2C_BUS(msp->bus);
-
- sprintf(device->name,"MSP34%02d%c-%c%d",
- (rev2>>8)&0xff, (rev1&0xff)+'@', ((rev1>>8)&0xff)+'@', rev2&0x1f);
- msp->nicam = (((rev2>>8)&0xff) == 10) ? 1 : 0;
-
- /* timer for stereo checking */
- msp->wake_stereo.function = msp3400c_stereo_wake;
- msp->wake_stereo.data = (unsigned long)msp;
-
- /* startup control thread */
- MOD_INC_USE_COUNT;
- msp->notify = &sem;
- kernel_thread(msp3400c_thread, (void *)msp, 0);
- down(&sem);
- msp->notify = NULL;
- if (!msp->active)
- up(msp->wait);
-
- printk(KERN_INFO "msp3400: init: chip=%s",device->name);
- if (msp->nicam)
- printk(", has NICAM support");
-#ifdef REGISTER_MIXER
- if (0 == msp3400c_mixer_init(msp))
- printk(", registered as sound mixer");
-#endif
- printk("\n");
- return 0;
-}
-
-static int msp3400c_detach(struct i2c_device *device)
-{
- unsigned long flags;
- struct semaphore sem = MUTEX_LOCKED;
- struct msp3400c *msp = (struct msp3400c*)device->data;
-
-#ifdef REGISTER_MIXER
- msp3400c_mixer_close(msp);
-#endif
-
- /* shutdown control thread */
- del_timer(&msp->wake_stereo);
- if (msp->thread)
- {
- msp->notify = &sem;
- msp->rmmod = 1;
- if (!msp->active)
- up(msp->wait);
- down(&sem);
- msp->notify = NULL;
- }
-
- LOCK_I2C_BUS(msp->bus);
- msp3400c_reset(msp->bus);
- UNLOCK_I2C_BUS(msp->bus);
-
- kfree(msp);
- MOD_DEC_USE_COUNT;
- return 0;
-}
-
-static int msp3400c_command(struct i2c_device *device,
- unsigned int cmd, void *arg)
-{
- unsigned long flags;
- struct msp3400c *msp = (struct msp3400c*)device->data;
- int *iarg = (int*)arg;
-
- switch (cmd) {
- case MSP_SET_RADIO:
- msp->norm = VIDEO_MODE_RADIO;
- msp->watch_stereo=0;
- del_timer(&msp->wake_stereo);
- LOCK_I2C_BUS(msp->bus);
- msp3400c_setmode(msp,MSP_MODE_FM_RADIO);
- msp3400c_setcarrier(msp->bus, MSP_CARRIER(10.7),MSP_CARRIER(10.7));
- UNLOCK_I2C_BUS(msp->bus);
- break;
- case MSP_SET_TVNORM:
- msp->norm = *iarg;
- break;
- case MSP_NEWCHANNEL:
- msp->watch_stereo=0;
- del_timer(&msp->wake_stereo);
- if (!msp->active)
- up(msp->wait);
- else
- msp->restart = 1;
- break;
-
- case MSP_GET_VOLUME:
- *iarg = (msp->left > msp->right) ? msp->left : msp->right;
- break;
- case MSP_SET_VOLUME:
- msp->left = msp->right = *iarg;
- LOCK_I2C_BUS(msp->bus);
- msp3400c_setvolume(msp->bus,msp->left, msp->right);
- UNLOCK_I2C_BUS(msp->bus);
- break;
-
- case MSP_GET_BASS:
- *iarg = msp->bass;
- break;
- case MSP_SET_BASS:
- msp->bass = *iarg;
- LOCK_I2C_BUS(msp->bus);
- msp3400c_setbass(msp->bus,msp->bass);
- UNLOCK_I2C_BUS(msp->bus);
- break;
-
- case MSP_GET_TREBLE:
- *iarg = msp->treble;
- break;
- case MSP_SET_TREBLE:
- msp->treble = *iarg;
- LOCK_I2C_BUS(msp->bus);
- msp3400c_settreble(msp->bus,msp->treble);
- UNLOCK_I2C_BUS(msp->bus);
- break;
-
- case MSP_GET_STEREO:
- *iarg = msp->stereo;
- break;
- case MSP_SET_STEREO:
- if (*iarg) {
- msp->watch_stereo=0;
- del_timer(&msp->wake_stereo);
- LOCK_I2C_BUS(msp->bus);
- msp3400c_setstereo(msp,*iarg);
- UNLOCK_I2C_BUS(msp->bus);
- }
- break;
-
- case MSP_GET_DC:
- LOCK_I2C_BUS(msp->bus);
- *iarg = (int)msp3400c_read(msp->bus, I2C_MSP3400C_DFP, 0x1b) +
- (int)msp3400c_read(msp->bus, I2C_MSP3400C_DFP, 0x1c);
- UNLOCK_I2C_BUS(msp->bus);
- break;
-
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-struct i2c_driver i2c_driver_msp = {
- "msp3400", /* name */
- I2C_DRIVERID_MSP3400, /* ID */
- I2C_MSP3400C, I2C_MSP3400C, /* addr range */
-
- msp3400c_attach,
- msp3400c_detach,
- msp3400c_command
-};
-
-#ifdef MODULE
-int init_module(void)
-#else
- int msp3400c_init(void)
-#endif
-{
- i2c_register_driver(&i2c_driver_msp);
- return 0;
-}
-
-#ifdef MODULE
-void cleanup_module(void)
-{
- i2c_unregister_driver(&i2c_driver_msp);
-}
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
diff --git a/bttv/driver/msp3400.h b/bttv/driver/msp3400.h
deleted file mode 100644
index e4029c0..0000000
--- a/bttv/driver/msp3400.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef MSP3400_H
-#define MSP3400_H
-
-/* ---------------------------------------------------------------------- */
-
-#define MSP_SET_TVNORM _IOW('m',1,int) /* TV mode + PAL/SECAM/NTSC */
-#define MSP_SET_RADIO _IO('m',2) /* Radio mode */
-#define MSP_NEWCHANNEL _IO('m',3) /* indicate new channel */
-
-#define MSP_GET_VOLUME _IOR('m',4,int)
-#define MSP_SET_VOLUME _IOW('m',5,int)
-
-#define MSP_GET_STEREO _IOR('m',6,int)
-#define MSP_SET_STEREO _IOW('m',7,int)
-
-#define MSP_GET_DC _IOW('m',8,int)
-
-#define MSP_GET_BASS _IOR('m', 9,int)
-#define MSP_SET_BASS _IOW('m',10,int)
-#define MSP_GET_TREBLE _IOR('m',11,int)
-#define MSP_SET_TREBLE _IOW('m',12,int)
-
-#endif /* MSP3400_H */
diff --git a/bttv/driver/tuner.c b/bttv/driver/tuner.c
deleted file mode 100644
index 6f8a6e3..0000000
--- a/bttv/driver/tuner.c
+++ /dev/null
@@ -1,271 +0,0 @@
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <linux/timer.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/malloc.h>
-
-#include "i2c.h"
-#include "videodev.h"
-
-#include "tuner.h"
-
-int debug = 0; /* insmod parameter */
-int type = 0; /* tuner type */
-
-#define dprintk if (debug) printk
-
-#if LINUX_VERSION_CODE > 0x020100
-MODULE_PARM(debug,"i");
-MODULE_PARM(type,"i");
-#endif
-
-struct tuner
-{
- struct i2c_bus *bus; /* where is our chip */
- int addr;
-
- int type; /* chip type */
- int freq; /* keep track of the current settings */
- int radio;
-};
-
-/* ---------------------------------------------------------------------- */
-
-struct tunertype
-{
- char *name;
- unsigned char Vendor;
- unsigned char Type;
-
- unsigned short thresh1; /* frequency Range for UHF,VHF-L, VHF_H */
- unsigned short thresh2;
- unsigned char VHF_L;
- unsigned char VHF_H;
- unsigned char UHF;
- unsigned char config;
- unsigned char I2C;
- unsigned short IFPCoff;
-};
-
-/*
- * The floats in the tuner struct are computed at compile time
- * by gcc and cast back to integers. Thus we don't violate the
- * "no float in kernel" rule.
- */
-static struct tunertype tuners[] = {
- {"Temic PAL", TEMIC, PAL,
- 16*140.25,16*463.25,0x02,0x04,0x01,0x8e,0xc2,623},
- {"Philips PAL_I", Philips, PAL_I,
- 16*140.25,16*463.25,0xa0,0x90,0x30,0x8e,0xc0,623},
- {"Philips NTSC", Philips, NTSC,
- 16*157.25,16*451.25,0xA0,0x90,0x30,0x8e,0xc0,732},
- {"Philips SECAM", Philips, SECAM,
- 16*168.25,16*447.25,0xA7,0x97,0x37,0x8e,0xc0,623},
- {"NoTuner", NoTuner, NOTUNER,
- 0 ,0 ,0x00,0x00,0x00,0x00,0x00,000},
- {"Philips PAL", Philips, PAL,
- 16*168.25,16*447.25,0xA0,0x90,0x30,0x8e,0xc0,623},
- {"Temic NTSC", TEMIC, NTSC,
- 16*157.25,16*463.25,0x02,0x04,0x01,0x8e,0xc2,732},
- {"TEMIC PAL_I", TEMIC, PAL_I,
- 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,0xc2,623},
-};
-
-/* ---------------------------------------------------------------------- */
-
-static int tuner_getstatus (struct tuner *t)
-{
- return i2c_read(t->bus,t->addr+1);
-}
-
-#define TUNER_POR 0x80
-#define TUNER_FL 0x40
-#define TUNER_AFC 0x07
-
-static int tuner_islocked (struct tuner *t)
-{
- return (tuner_getstatus (t) & TUNER_FL);
-}
-
-static int tuner_afcstatus (struct tuner *t)
-{
- return (tuner_getstatus (t) & TUNER_AFC) - 2;
-}
-
-
-static void set_tv_freq(struct tuner *t, int freq)
-{
- unsigned long flags;
- u8 config;
- u16 div;
- struct tunertype *tun=&tuners[t->type];
-
- if (freq < tun->thresh1)
- config = tun->VHF_L;
- else if (freq < tun->thresh2)
- config = tun->VHF_H;
- else
- config = tun->UHF;
-
- div=freq + tun->IFPCoff;
- div&=0x7fff;
-
- LOCK_I2C_BUS(t->bus);
- if (i2c_write(t->bus, t->addr, (div>>8)&0x7f, div&0xff, 1)<0) {
- printk("tuner: i2c i/o error #1\n");
- } else {
- if (i2c_write(t->bus, t->addr, tun->config, config, 1))
- printk("tuner: i2c i/o error #2\n");
- }
- UNLOCK_I2C_BUS(t->bus);
-}
-
-static void set_radio_freq(struct tuner *t, int freq)
-{
- unsigned long flags;
- u8 config;
- u16 div;
- struct tunertype *tun=&tuners[type];
-
- config = 0xa5;
- div=freq + (int)(16*10.7);
- div&=0x7fff;
-
- LOCK_I2C_BUS(t->bus);
- if (i2c_write(t->bus, t->addr, (div>>8)&0x7f, div&0xff, 1)<0) {
- printk("tuner: i2c i/o error #1\n");
- } else {
- if (i2c_write(t->bus, t->addr, tun->config, config, 1))
- printk("tuner: i2c i/o error #2\n");
- }
- if (debug) {
- UNLOCK_I2C_BUS(t->bus);
- current->state = TASK_INTERRUPTIBLE;
- current->timeout = jiffies + HZ/10;
- schedule();
- LOCK_I2C_BUS(t->bus);
-
- if (tuner_islocked (t))
- printk ("tuner: PLL locked\n");
- else
- printk ("tuner: PLL not locked\n");
-
- printk ("tuner: AFC: %d\n", tuner_afcstatus (t));
- }
- UNLOCK_I2C_BUS(t->bus);
-}
-
-/* ---------------------------------------------------------------------- */
-
-static int tuner_attach(struct i2c_device *device)
-{
- struct tuner *t;
-
- /*
- * For now we only try and attach these tuners to the BT848
- * bus. This same module will however work different species
- * of card using these chips. Just change the constraints
- * (i2c doesn't have a totally clash free 'address' space)
- */
-
- if(device->bus->id!=I2C_BUSID_BT848)
- return -EINVAL;
-
- device->data = t = kmalloc(sizeof(struct tuner),GFP_KERNEL);
- if (NULL == t)
- return -ENOMEM;
- memset(t,0,sizeof(struct tuner));
- strcpy(device->name,"tuner");
- t->bus = device->bus;
- t->addr = device->addr;
- t->type = type;
- dprintk("tuner: type is %d (%s)\n",t->type,tuners[t->type].name);
-
- MOD_INC_USE_COUNT;
- return 0;
-}
-
-static int tuner_detach(struct i2c_device *device)
-{
- struct tuner *t = (struct tuner*)device->data;
- kfree(t);
- MOD_DEC_USE_COUNT;
- return 0;
-}
-
-static int tuner_command(struct i2c_device *device,
- unsigned int cmd, void *arg)
-{
- struct tuner *t = (struct tuner*)device->data;
- int *iarg = (int*)arg;
-
- switch (cmd)
- {
- case TUNER_SET_TYPE:
- t->type = *iarg;
- dprintk("tuner: type set to %d (%s)\n",
- t->type,tuners[t->type].name);
- break;
-
- case TUNER_SET_TVFREQ:
- dprintk("tuner: tv freq set to %d.%02d\n",
- (*iarg)/16,(*iarg)%16*100/16);
- set_tv_freq(t,*iarg);
- t->radio = 0;
- t->freq = *iarg;
- break;
-
- case TUNER_SET_RADIOFREQ:
- dprintk("tuner: radio freq set to %d.%02d\n",
- (*iarg)/16,(*iarg)%16*100/16);
- set_radio_freq(t,*iarg);
- t->radio = 1;
- t->freq = *iarg;
- break;
-
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-struct i2c_driver i2c_driver_tuner =
-{
- "tuner", /* name */
- I2C_DRIVERID_TUNER, /* ID */
- 0xc0, 0xce, /* addr range */
-
- tuner_attach,
- tuner_detach,
- tuner_command
-};
-
-#ifdef MODULE
-int init_module(void)
-#else
-int msp3400c_init(void)
-#endif
-{
- i2c_register_driver(&i2c_driver_tuner);
- return 0;
-}
-
-#ifdef MODULE
-void cleanup_module(void)
-{
- i2c_unregister_driver(&i2c_driver_tuner);
-}
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
diff --git a/bttv/driver/tuner.h b/bttv/driver/tuner.h
deleted file mode 100644
index 3fb77de..0000000
--- a/bttv/driver/tuner.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- tuner.h - definition for different tuners
-
- Copyright (C) 1997 Markus Schroeder (schroedm@uni-duesseldorf.de)
- minor modifications by Ralph Metzler (rjkm@thp.uni-koeln.de)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _TUNER_H
-#define _TUNER_H
-
-#define TUNER_TEMIC_PAL 0 /* Miro Gpio Coding -1 */
-#define TUNER_PHILIPS_PAL_I 1
-#define TUNER_PHILIPS_NTSC 2
-#define TUNER_PHILIPS_SECAM 3
-#define TUNER_ABSENT 4
-#define TUNER_PHILIPS_PAL 5
-#define TUNER_TEMIC_NTSC 6
-#define TUNER_TEMIC_PAL_I 7
-
-#define NOTUNER 0
-#define PAL 1
-#define PAL_I 2
-#define NTSC 3
-#define SECAM 4
-
-#define NoTuner 0
-#define Philips 1
-#define TEMIC 2
-#define Sony 3
-
-#define TUNER_SET_TYPE _IOW('t',1,int) /* set tuner type */
-#define TUNER_SET_TVFREQ _IOW('t',2,int) /* set tv freq */
-#define TUNER_SET_RADIOFREQ _IOW('t',3,int) /* set radio freq */
-
-#endif
diff --git a/bttv/driver/update b/bttv/driver/update
deleted file mode 100644
index 91db789..0000000
--- a/bttv/driver/update
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/sh
-
-if test "$UID" = "0"; then
- # running as root anyway, don't need sudo
- INSMOD="/sbin/insmod"
- RMMOD="/sbin/rmmod"
-else
- INSMOD="sudo /sbin/insmod"
- RMMOD="sudo /sbin/rmmod"
-fi
-
-# handy functions for rmmod/insmod
-function xrmmod () {
- grep -qe "^$1" /proc/modules || return
- echo rmmod $1
- $RMMOD $1 || exit 1
-}
-function xinsmod () {
- echo insmod $*
- $INSMOD -f $* || exit 1
-}
-
-# prepare for crashing the box -- flush dirty buffers
-sync; sleep 1; sync
-
-# kill old modules ...
-xrmmod bttv
-xrmmod msp3400
-xrmmod tuner
-xrmmod i2c_chardev
-xrmmod i2c-dev
-xrmmod algo-bit
-xrmmod i2c
-xrmmod videodev
-
-# ... and load the new ones
-xinsmod videodev
-xinsmod i2c verbose=1 scan=1 i2c_debug=0
-test -f i2c_chardev.o && xinsmod i2c_chardev
-xinsmod tuner debug=0 type=5
-xinsmod msp3400
-xinsmod bttv radio=1 vidmem=0xff0
-
diff --git a/bttv/driver/videodev.c b/bttv/driver/videodev.c
deleted file mode 100644
index 360058c..0000000
--- a/bttv/driver/videodev.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * Video capture interface for Linux
- *
- * A generic video device interface for the LINUX operating system
- * using a set of device structures/vectors for low level operations.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Author: Alan Cox, <alan@cymru.net>
- *
- * Fixes:
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include "videodev.h"
-
-#if LINUX_VERSION_CODE >= 0x020100
-#include <asm/uaccess.h>
-#endif
-#include <asm/system.h>
-
-
-#define VIDEO_NUM_DEVICES 256
-
-/*
- * Active devices
- */
-
-static struct video_device *video_device[VIDEO_NUM_DEVICES];
-
-#ifdef CONFIG_VIDEO_BT848
-extern int init_bttv_cards(struct video_init *);
-#endif
-#ifdef CONFIG_VIDEO_SAA5249
-extern int init_saa_5249(struct video_init *);
-#endif
-#ifdef CONFIG_VIDEO_CQCAM
-extern int init_colour_qcams(struct video_init *);
-#endif
-#ifdef CONFIG_VIDEO_BWQCAM
-extern int init_bw_qcams(struct video_init *);
-#endif
-#ifdef CONFIG_RADIO_AZTECH
-extern int aztech_init(struct video_init *);
-#endif
-#ifdef CONFIG_RADIO_RTRACK
-extern int rtrack_init(struct video_init *);
-#endif
-#ifdef CONFIG_RADIO_SF16FMI
-extern int fmi_init(struct video_init *);
-#endif
-
-static struct video_init video_init_list[]={
-#ifdef CONFIG_VIDEO_BT848
- {"bttv", init_bttv_cards},
-#endif
-#ifdef CONFIG_VIDEO_SAA5249
- {"saa5249", init_saa_5249},
-#endif
-#ifdef CONFIG_VIDEO_CQCAM
- {"c-qcam", init_colour_qcams},
-#endif
-#ifdef CONFIG_VIDEO_BWQCAM
- {"bw-qcam", init_bw_qcams},
-#endif
-#ifdef CONFIG_VIDEO_PMS
- {"PMS", init_pms_cards},
-#endif
- {"end", NULL}
-#ifdef CONFIG_RADIO_AZTECH
- {"Aztech", aztech_init},
-#endif
-#ifdef CONFIG_RADIO_RTRACK
- {"RTrack", rtrack_init},
-#endif
-#ifdef CONFIG_RADIO_SF16FMI
- {"SF16FMI", fmi_init},
-#endif
-};
-
-#if LINUX_VERSION_CODE >= 0x020100
-/*
- * Read will do some smarts later on. Buffer pin etc.
- */
-
-static ssize_t video_read(struct file *file,
- char *buf, size_t count, loff_t *ppos)
-{
- struct video_device *vfl=video_device[MINOR(file->f_dentry->d_inode->i_rdev)];
- if (vfl->read)
- return vfl->read(vfl, buf, count, file->f_flags&O_NONBLOCK);
- else
- return -EINVAL;
-}
-
-
-
-/*
- * Write for now does nothing. No reason it shouldnt do overlay setting
- * for some boards I guess..
- */
-
-static ssize_t video_write(struct file *file, const char *buf,
- size_t count, loff_t *ppos)
-{
- struct video_device *vfl=video_device[MINOR(file->f_dentry->d_inode->i_rdev)];
- if (vfl->write)
- return vfl->write(vfl, buf, count, file->f_flags&O_NONBLOCK);
- else
- return 0;
-}
-#else
-static int video_read(struct inode *ino,struct file *file,
- char *buf, int count)
-{
- int err;
- struct video_device *vfl=video_device[MINOR(ino->i_rdev)];
- if (vfl->read)
- return vfl->read(vfl, buf, count, file->f_flags&O_NONBLOCK);
- else
- return -EINVAL;
-}
-
-static int video_write(struct inode *ino,struct file *file, const char *buf,
- int count)
-{
- int err;
- struct video_device *vfl=video_device[MINOR(ino->i_rdev)];
- if (vfl->write)
- return vfl->write(vfl, buf, count, file->f_flags&O_NONBLOCK);
- else
- return 0;
-}
-#endif
-
-/*
- * Open a video device.
- */
-
-static int video_open(struct inode *inode, struct file *file)
-{
- unsigned int minor = MINOR(inode->i_rdev);
- int err;
- struct video_device *vfl;
-
- if(minor>=VIDEO_NUM_DEVICES)
- return -ENODEV;
-
- vfl=video_device[minor];
- if(vfl==NULL)
- return -ENODEV;
- if(vfl->busy)
- return -EBUSY;
- vfl->busy=1; /* In case vfl->open sleeps */
-
- if(vfl->open)
- {
- err=vfl->open(vfl,0); /* Tell the device it is open */
- if(err)
- {
- vfl->busy=0;
- return err;
- }
- }
- return 0;
-}
-
-/*
- * Last close of a video for Linux device
- */
-
-static int video_release(struct inode *inode, struct file *file)
-{
- struct video_device *vfl=video_device[MINOR(inode->i_rdev)];
- if(vfl->close)
- vfl->close(vfl);
- vfl->busy=0;
- return 0;
-}
-
-/*
- * Question: Should we be able to capture and then seek around the
- * image ?
- */
-
-#if LINUX_VERSION_CODE >= 0x020100
-static long long video_lseek(struct file * file,
- long long offset, int origin)
-{
- return -ESPIPE;
-}
-#else
-static long long video_lseek(struct inode *inode, struct file * file,
- long long offset, int origin)
-{
- return -ESPIPE;
-}
-#endif
-
-
-static int video_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
-{
- struct video_device *vfl=video_device[MINOR(inode->i_rdev)];
- int err=vfl->ioctl(vfl, cmd, (void *)arg);
-
- if(err!=-ENOIOCTLCMD)
- return err;
-
- switch(cmd)
- {
- default:
- return -EINVAL;
- }
-}
-
-/*
- * We need to do MMAP support
- */
-
-
-#if LINUX_VERSION_CODE >= 0x020100
-int video_mmap(struct file *file, struct vm_area_struct *vma)
-{
- struct video_device *vfl=video_device[MINOR(file->f_dentry->d_inode->i_rdev)];
-#else
-static int video_mmap(struct inode * ino, struct file * file,
- struct vm_area_struct * vma)
-{
- struct video_device *vfl=video_device[MINOR(ino->i_rdev)];
-#endif
- if(vfl->mmap)
- return vfl->mmap(vfl, (char *)vma->vm_start,
- (unsigned long)(vma->vm_end-vma->vm_start));
- return -EINVAL;
-}
-
-/*
- * Video For Linux device drivers request registration here.
- */
-
-int video_register_device(struct video_device *vfd, int type)
-{
- int i=0;
- int base;
- int err;
- int end;
-
- switch(type)
- {
- case VFL_TYPE_GRABBER:
- base=0;
- end=64;
- break;
- case VFL_TYPE_VTX:
- base=192;
- end=224;
- break;
- case VFL_TYPE_VBI:
- base=224;
- end=240;
- break;
- case VFL_TYPE_RADIO:
- base=64;
- end=128;
- break;
- default:
- return -1;
- }
-
- for(i=base;i<end;i++)
- {
- if(video_device[i]==NULL)
- {
- video_device[i]=vfd;
- vfd->minor=i;
- /* The init call may sleep so we book the slot out
- then call */
- MOD_INC_USE_COUNT;
- if (vfd->initialize)
- {
- err=vfd->initialize(vfd);
- if(err<0)
- {
- video_device[i]=NULL;
- MOD_DEC_USE_COUNT;
- return err;
- }
- }
- return 0;
- }
- }
- return -ENFILE;
-}
-
-/*
- * Unregister an unused video for linux device
- */
-
-void video_unregister_device(struct video_device *vfd)
-{
- if(video_device[vfd->minor]!=vfd)
- panic("vfd: bad unregister");
- video_device[vfd->minor]=NULL;
- MOD_DEC_USE_COUNT;
-}
-
-
-static struct file_operations video_fops=
-{
- video_lseek,
- video_read,
- video_write,
- NULL, /* readdir */
- NULL, /* poll */
- video_ioctl,
- video_mmap,
- video_open,
- video_release
-};
-
-/*
- * Initialise video for linux
- */
-
-int videodev_init(void)
-{
- struct video_init *vfli = video_init_list;
-
- printk(KERN_INFO "Linux video capture interface: v0.01 ALPHA\n");
- if(register_chrdev(VIDEO_MAJOR,"video_capture", &video_fops))
- {
- printk("video_dev: unable to get major %d\n", VIDEO_MAJOR);
- return -EIO;
- }
-
- /*
- * Init kernel installed video drivers
- */
-
- while(vfli->init!=NULL)
- {
- vfli->init(vfli);
- vfli++;
- }
- return 0;
-}
-
-#ifdef MODULE
-int init_module(void)
-{
- return videodev_init();
-}
-
-void cleanup_module(void)
-{
- unregister_chrdev(VIDEO_MAJOR, "video_capture");
-}
-
-#endif
-
-#if LINUX_VERSION_CODE >= 0x020100
-EXPORT_SYMBOL(video_register_device);
-EXPORT_SYMBOL(video_unregister_device);
-#endif
diff --git a/bttv/driver/videodev.h b/bttv/driver/videodev.h
deleted file mode 100644
index 6b13119..0000000
--- a/bttv/driver/videodev.h
+++ /dev/null
@@ -1,214 +0,0 @@
-#ifndef __LINUX_VIDEODEV_H
-#define __LINUX_VIDEODEV_H
-
-#ifdef __KERNEL__
-
-struct video_device
-{
- char name[32];
- int type;
- int hardware;
-
- int (*open)(struct video_device *, int mode);
- void (*close)(struct video_device *);
- long (*read)(struct video_device *, char *, unsigned long, int noblock);
- /* Do we need a write method ? */
- long (*write)(struct video_device *, const char *, unsigned long, int noblock);
- int (*ioctl)(struct video_device *, unsigned int , void *);
- int (*mmap)(struct video_device *, const char *, unsigned long);
- int (*initialize)(struct video_device *);
- void *priv; /* Used to be 'private' but that upsets C++ */
- int busy;
- int minor;
-};
-
-extern int videodev_init(void);
-#define VIDEO_MAJOR 81
-extern int video_register_device(struct video_device *, int type);
-
-#define VFL_TYPE_GRABBER 0
-#define VFL_TYPE_VBI 1
-#define VFL_TYPE_RADIO 2
-#define VFL_TYPE_VTX 3
-
-extern void video_unregister_device(struct video_device *);
-#endif
-
-
-#define VID_TYPE_CAPTURE 1 /* Can capture */
-#define VID_TYPE_TUNER 2 /* Can tune */
-#define VID_TYPE_TELETEXT 4 /* Does teletext */
-#define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */
-#define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */
-#define VID_TYPE_CLIPPING 32 /* Can clip */
-#define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */
-#define VID_TYPE_SCALES 128 /* Scalable */
-#define VID_TYPE_MONOCHROME 256 /* Monochrome only */
-
-struct video_capability
-{
- char name[32];
- int type;
- int channels; /* Num channels */
- int audios; /* Num audio devices */
- int maxwidth; /* Supported width */
- int maxheight; /* And height */
- int minwidth; /* Supported width */
- int minheight; /* And height */
-};
-
-
-struct video_channel
-{
- int channel;
- char name[32];
- int tuners;
- __u32 flags;
-#define VIDEO_VC_TUNER 1 /* Channel has a tuner */
-#define VIDEO_VC_AUDIO 2 /* Channel has audio */
- __u16 type;
-#define VIDEO_TYPE_TV 1
-#define VIDEO_TYPE_CAMERA 2
-};
-
-struct video_tuner
-{
- int tuner;
- char name[32];
- ulong rangelow, rangehigh; /* Tuner range */
- __u32 flags;
-#define VIDEO_TUNER_PAL 1
-#define VIDEO_TUNER_NTSC 2
-#define VIDEO_TUNER_SECAM 4
-#define VIDEO_TUNER_LOW 8 /* Uses KHz not MHz */
-#define VIDEO_TUNER_STEREO_ON 128 /* Tuner is seeing stereo */
- __u16 mode; /* PAL/NTSC/SECAM/OTHER */
-#define VIDEO_MODE_PAL 0
-#define VIDEO_MODE_NTSC 1
-#define VIDEO_MODE_SECAM 2
-#define VIDEO_MODE_AUTO 3
- __u16 signal; /* Signal strength 16bit scale */
-};
-
-struct video_picture
-{
- __u16 brightness;
- __u16 hue;
- __u16 colour;
- __u16 contrast;
- __u16 whiteness; /* Black and white only */
- __u16 depth; /* Capture depth */
- __u16 palette; /* Palette in use */
-#define VIDEO_PALETTE_GREY 1 /* Linear greyscale */
-#define VIDEO_PALETTE_HI240 2 /* High 240 cube (BT848) */
-#define VIDEO_PALETTE_RGB565 3 /* 565 16 bit RGB */
-#define VIDEO_PALETTE_RGB24 4 /* 24bit RGB */
-#define VIDEO_PALETTE_RGB32 5 /* 32bit RGB */
-#define VIDEO_PALETTE_RGB555 6 /* 555 15bit RGB */
-#define VIDEO_PALETTE_YUV422 7 /* YUV422 capture */
-};
-
-struct video_audio
-{
- int audio; /* Audio channel */
- __u16 volume; /* If settable */
- __u16 bass, treble;
- __u32 flags;
-#define VIDEO_AUDIO_MUTE 1
-#define VIDEO_AUDIO_MUTABLE 2
-#define VIDEO_AUDIO_VOLUME 4
-#define VIDEO_AUDIO_BASS 8
-#define VIDEO_AUDIO_TREBLE 16
- char name[16];
-#define VIDEO_SOUND_MONO 1
-#define VIDEO_SOUND_STEREO 2
-#define VIDEO_SOUND_LANG1 3
-#define VIDEO_SOUND_LANG2 4
- __u16 mode;
-};
-
-struct video_clip
-{
- __s32 x,y;
- __s32 width, height;
- struct video_clip *next; /* For user use/driver use only */
-};
-
-struct video_window
-{
- __u32 x,y;
- __u32 width,height;
- __u32 chromakey;
- __u32 flags;
- struct video_clip *clips; /* Set only */
- int clipcount;
-#define VIDEO_WINDOW_INTERLACE 1
-};
-
-struct video_buffer
-{
- void *base;
- int height,width;
- int depth;
- int bytesperline;
-};
-
-struct video_mmap
-{
- unsigned int frame; /* Frame (0 or 1) for double buffer */
- int height,width;
- unsigned int format;
-};
-
-struct video_key
-{
- __u8 key[8];
- __u32 flags;
-};
-
-#define VIDIOCGCAP _IOR('v',1,struct video_capability) /* Get capabilities */
-#define VIDIOCGCHAN _IOWR('v',2,struct video_channel) /* Get channel info (sources) */
-#define VIDIOCSCHAN _IOW('v',3,int) /* Set channel */
-#define VIDIOCGTUNER _IOWR('v',4,struct video_tuner) /* Get tuner abilities */
-#define VIDIOCSTUNER _IOW('v',5,struct video_tuner) /* Tune the tuner for the current channel */
-#define VIDIOCGPICT _IOR('v',6,struct video_picture) /* Get picture properties */
-#define VIDIOCSPICT _IOW('v',7,struct video_picture) /* Set picture properties */
-#define VIDIOCCAPTURE _IOW('v',8,int) /* Start, end capture */
-#define VIDIOCGWIN _IOR('v',9, struct video_window) /* Set the video overlay window */
-#define VIDIOCSWIN _IOW('v',10, struct video_window) /* Set the video overlay window - passes clip list for hardware smarts , chromakey etc */
-#define VIDIOCGFBUF _IOR('v',11, struct video_buffer) /* Get frame buffer */
-#define VIDIOCSFBUF _IOW('v',12, struct video_buffer) /* Set frame buffer - root only */
-#define VIDIOCKEY _IOR('v',13, struct video_key) /* Video key event - to dev 255 is to all - cuts capture on all DMA windows with this key (0xFFFFFFFF == all) */
-#define VIDIOCGFREQ _IOR('v',14, unsigned long) /* Set tuner */
-#define VIDIOCSFREQ _IOW('v',15, unsigned long) /* Set tuner */
-#define VIDIOCGAUDIO _IOR('v',16, struct video_audio) /* Get audio info */
-#define VIDIOCSAUDIO _IOW('v',17, struct video_audio) /* Audio source, mute etc */
-#define VIDIOCSYNC_OLD _IO('v',18) /* Sync with mmap grabbing */
-#define VIDIOCSYNC _IOW('v',18, int) /* Sync with mmap grabbing */
-#define VIDIOCMCAPTURE _IOW('v',19, struct video_mmap) /* Grab frames */
-
-
-#define BASE_VIDIOCPRIVATE 192 /* 192-255 are private */
-
-
-#define VID_HARDWARE_BT848 1
-#define VID_HARDWARE_QCAM_BW 2
-#define VID_HARDWARE_PMS 3
-#define VID_HARDWARE_QCAM_C 4
-#define VID_HARDWARE_PSEUDO 5
-#define VID_HARDWARE_SAA5249 6
-#define VID_HARDWARE_AZTECH 7
-#define VID_HARDWARE_SF16MI 8
-#define VID_HARDWARE_RTRACK 9
-
-/*
- * Initialiser list
- */
-
-struct video_init
-{
- char *name;
- int (*init)(struct video_init *);
-};
-
-#endif
diff --git a/bttv/experimental/Makefile b/bttv/experimental/Makefile
deleted file mode 100644
index 12ca401..0000000
--- a/bttv/experimental/Makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-#################################################
-# config
-
-# 0: Temic PAL tuner
-# 1: Philips PAL_I tuner
-# 2: Philips NTSC tuner
-# 3: Philips SECAM tuner
-# 4: no tuner
-# 5: Philips PAL tuner
-# 6: Temic NTSC tuner
-# 7: Temic PAL tuner
-TUNER=0
-
-# 0: Auto-Detect
-# 1: Miro
-# 2: Hauppauge
-# 3: STB
-# 4: Intel
-# 5: Diamond
-# 6: AVerMedia
-# 7: MATRIX Vision MV-Delta
-# 8: FlyVideo
-CARD=0
-
-# Official major device number is 81
-# Older kernels might have problems with such high numbers.
-# But I rather recommend updating to kernel 2.0.31 or higher.
-BTTV_MAJOR=81
-
-# currently running kernel
-CURRENT=$(shell uname -r)
-
-# where the kernel sources are located
-#KERNEL_LOCATION=/usr/src/kernel/$(CURRENT)
-#KERNEL_LOCATION=/usr/src/kernel/vger
-KERNEL_LOCATION=/usr/src/linux
-
-
-#################################################
-# some magic for using linux kernel settings
-# when compiling module(s)
-
-M_OBJS = bttv.o tuner.o
-MX_OBJS = videodev.o i2c.o algo-bit.o
-#EXTRA_CFLAGS = -DTUNER_DEFAULT=$(TUNER) -DCARD_DEFAULT=$(CARD) \
-# -DBTTV_MAJOR=$(BTTV_MAJOR) $(INTERFACE) #-DUSE_PLL
-EXTRA_CFLAGS = -DTUNER_DEFAULT=$(TUNER) -DCARD_DEFAULT=$(CARD) \
- -DBTTV_MAJOR=$(BTTV_MAJOR) $(INTERFACE) \
- -DVERIFY_HEADERS -DSLOW_STARTER
-
-here:
- DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR modules)
-
-install:
- su -c "cp -v $(M_OBJS) $(MX_OBJS) /lib/modules/$(CURRENT)/misc"
-
-clean:
- -rm -f $(M_OBJS) $(MX_OBJS) .*.o.flags *~
-
-include $(KERNEL_LOCATION)/Rules.make
-
diff --git a/bttv/experimental/README b/bttv/experimental/README
deleted file mode 100644
index c3137c3..0000000
--- a/bttv/experimental/README
+++ /dev/null
@@ -1,12 +0,0 @@
-This is a very first version of bttv with the new i2c code. Work in
-progress, plenty of known bugs, pre-alpha quality. No msp3400 support
-yet, only the tuner works. You should know what you are doing if you
-want to play with it. Tested only with 2.1.x
-
-You should use the update script to load/unload the modules, it knows
-which order works without a kernel Oops.
-
-You have been warned,
-
- Gerd
-
diff --git a/bttv/experimental/algo-bit.c b/bttv/experimental/algo-bit.c
deleted file mode 100644
index cc63bed..0000000
--- a/bttv/experimental/algo-bit.c
+++ /dev/null
@@ -1,893 +0,0 @@
-/* ------------------------------------------------------------------------- */
-/* adap-bit.c i2c driver algorithms for bit-shift adapters */
-/* ------------------------------------------------------------------------- */
-/* Copyright (C) 1995-97 Simon G. Vogl
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-/* ------------------------------------------------------------------------- */
-static char alg_rcsid[] = "$Id: algo-bit.c,v 1.1 1998/05/25 12:08:00 i2c Exp i2c $";
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/delay.h>
-#include <linux/malloc.h>
-#include <linux/version.h>
-
-
-#if LINUX_VERSION_CODE >= 0x020100
-# include <asm/uaccess.h>
-#else
-# include <asm/segment.h>
-#endif
-
-
-#include <linux/ioport.h>
-#include <linux/errno.h>
-#include <linux/sched.h>
-
-#include "i2c.h"
-#include "algo-bit.h"
-
-/* ----- global defines ---------------------------------------------------- */
-#define DEB(x) x /* should be reasonable open, close &c. */
-#define DEB2(x) /* low level debugging - very slow */
-#define DEBE(x) /* error messages */
-#define DEBI(x) /* ioctl and its arguments */
-#define DEBACK(x) x /* ack failed message */
-#define DEBSTAT(x) /* print several statistical values */
-
-#define DEBPROTO(x) x /* debug the protocol by showing transferred bytes*/
-
-/* debugging - slow down transfer to have a look at the data .. */
-/* I use this with two leds&resistors, each one connected to sda,scl */
-/* respectively. This makes sure that the algorithm works. Some chips */
-/* might not like this, as they have an internal timeout of some mils */
-/*
-#define SLO_IO jif=jiffies;while(jiffies<=jif+i2c_table[minor].veryslow)\
- if (need_resched) schedule();
-*/
-
-/* ----- global variables --------------------------------------------- */
-
-#ifdef SLO_IO
- int jif;
-#endif
-
-
-static int test=1; /* see if the line-setting functions work */
-static int scan=0; /* have a look at what's hanging 'round */
-/*
- * This array contains the hw-specific functions for
- * each port (hardware) type.
- */
-static struct bit_adapter *bit_adaps[BIT_ADAP_MAX];
-static int adap_count;
-static struct i2c_adapter *i2c_adaps[BIT_ADAP_MAX];
-
-/* --- setting states on the bus with the right timing: --------------- */
-
-#define setsda(adap,val) adap->setsda(adap->data, val)
-#define setscl(adap,val) adap->setscl(adap->data, val)
-#define getsda(adap) adap->getsda(adap->data)
-#define getscl(adap) adap->getscl(adap->data)
-
-static inline void sdalo(struct bit_adapter *adap)
-{
- setsda(adap,0);
- udelay(adap->udelay);
-}
-
-static inline void sdahi(struct bit_adapter *adap)
-{
- setsda(adap,1);
- udelay(adap->udelay);
-}
-
-static inline void scllo(struct bit_adapter *adap)
-{
- setscl(adap,0);
- udelay(adap->udelay);
-#ifdef SLO_IO
- SLO_IO
-#endif
-}
-
-/*
- * Raise scl line, and do checking for delays. This is necessary for slower
- * devices.
- */
-static inline int sclhi(struct bit_adapter *adap)
-{
- int start=jiffies;
-
- setscl(adap,1);
-
- udelay(adap->udelay);
- while (! getscl(adap) ) { /* wait till high */
- setscl(adap,1);
- if (start+adap->timeout <= jiffies) {
-/* DEBE(printk("i2c(bit): (%s) sclhi timed out after %d jiffies\n",
- adap->name, adap->timeout ) );
-*/ return -ETIMEDOUT;
- }
- if (need_resched)
- schedule();
- }
- DEBSTAT(printk("needed %ld jiffies\n", jiffies-start));
-#ifdef SLO_IO
- SLO_IO
-#endif
- return 0;
-}
-
-
-/* --- other auxiliary functions -------------------------------------- */
-static void i2c_start(struct bit_adapter *adap)
-{
- /* assert: scl, sda are high */
- DEBPROTO(printk("S "));
- sdalo(adap);
- scllo(adap);
-}
-
-static void i2c_repstart(struct bit_adapter *adap)
-{
- /* scl, sda may not be high */
- DEBPROTO(printk(" Sr "));
- setsda(adap,1);
- setscl(adap,1);
- udelay(adap->udelay);
-
- sdalo(adap); /* includes delay! */
- scllo(adap);
-}
-
-
-static void i2c_stop(struct bit_adapter *adap)
-{
- DEBPROTO(printk("P\n"));
- /* assert: scl is low */
- sdalo(adap);
- sclhi(adap);
- sdahi(adap);
-}
-
-/* send a byte without start cond., look for arbitration,
- check ackn. from slave */
-/* return 1 if ok */
-static int i2c_outb(struct bit_adapter *adap, char c)
-{
- int i;
- int sb;
- int ack;
-
- /* assert: scl is low */
- DEB2(printk(" i2c_outb:%2.2X\n",c&0xff));
- for ( i=7 ; i>=0 ; i-- ) {
- sb = c & ( 1 << i );
- setsda(adap,sb);
- udelay(adap->udelay);
- DEBPROTO(printk("%d",sb!=0));
- if (sclhi(adap)<0) { /* timed out */
- sdahi(adap); /* we don't want to block the net */
- return -ETIMEDOUT;
- };
-#if 0
- /* arbitrate here: */
- if ( sb && !getsda(adap) ){
- /* we lost the arbitration process -> give up */
- DEBE(printk("i2c(bit): %s i2c_outb: arbitration bailout! \n", adap->name ));
- return -ETIMEDOUT;
- }
- /* scllo(adap); */
-#endif
- setscl( adap, 0 );
- udelay(adap->udelay);
- }
- sdahi(adap);
- if (sclhi(adap)<0){ /* timeout */
- return -ETIMEDOUT;
- };
- /* read ack: SDA should be pulled down by slave */
- ack=getsda(adap); /* ack: sda is pulled low ->success. */
- DEB2(printk(" i2c_outb: getsda() = 0x%2.2x\n", !ack ));
-
- DEBPROTO( printk("[%2.2x]",c&0xff) );
- DEBPROTO(if (0==ack) printk(" A "); else printk(" NA ") );
- scllo(adap);
- return 0==ack; /* return 1 if device acked */
- /* assert: scl is low (sda undef) */
-}
-
-
-
-static int i2c_inb(struct bit_adapter *adap)
-{
- /* read byte via i2c port, without start/stop sequence */
- /* acknowledge is sent in i2c_read. */
- int i;
- char indata;
-
- /* assert: scl is low */
- DEB2(printk("i2c_inb.\n"));
-
- sdahi(adap);
- indata=0;
- for (i=0;i<8;i++) {
- if (sclhi(adap)<0) { /* timeout */
- return -ETIMEDOUT;
- };
- indata *= 2;
- if ( getsda(adap) )
- indata |= 0x01;
- scllo(adap);
- }
- /* assert: scl is low */
- DEBPROTO(printk(" %2.2x", indata & 0xff));
- return (int) (indata & 0xff);
-}
-
-
-/* ----- level 2: communication with the kernel ----- */
-#if 0
-
-static int i2c_write(struct inode * inode, struct file * file,
- const char * buf, int count)
-{
- unsigned struct bit_adapter *adap = ADAP(inode->i_rdev);
- char c,adr;
- const char *temp = buf;
- int retval,i;
- int wrcount=0;
- struct i2c_data *data;
-
- data=(struct i2c_data *)file->private_data;
- if (data && (data->magic==I2C_MAGIC))
- adr = (data->address);
- else
- return -EINVAL;
- /* slave address is in the lower 7 bits -> shift left to make */
- /* space for the data direction bit */
- adr <<= 1;
-
- DEB(printk("i2c%d: i2c_write: %d byte(s) to send\n", adap, count));
-
-#if LINUX_VERSION_CODE >= 0x020100
- /* check data buffer once */
- if ( !access_ok(VERIFY_READ,buf,count)) {
- printk("i2c%d: Error accessing user memory!\n",adap);
- return -ENOMEM;
- }
-#endif
-
- i2c_start(adap);
- i=0;
- while ( ! i2c_outb(adap,adr) ) {
- i2c_stop(adap);
- i++;
- i2c_start(adap);
- if (i>=i2c_table[adap].retries ) {
- DEBACK(printk("i2c%d: i2c_write: address ack failed.\n",adap));
- i2c_stop(adap);
- return -EREMOTEIO;
- };
- }
- while (count > 0) {
-#if LINUX_VERSION_CODE >= 0x020100
- __get_user(c,temp); /* we use the non-checking version */
-#else
- c = get_user(temp);
-#endif
- DEB2(printk("i2c%d: i2c_write: writing %2.2X\n",adap, c&0xff));
- retval = i2c_outb(adap,c);
- if (retval>0) {
- count--;
- temp++;
- wrcount++;
- } else { /* arbitration or no acknowledge */
- DEBE(printk("i2c%d: i2c_write: error - bailout.\n",adap));
- i2c_stop(adap);
- return -EREMOTEIO; /* got a better one ?? */
- }
- /* /usr/src/linux/include/asm/delay.h */
- __delay(i2c_table[adap].mdelay * (loops_per_sec / 1000) );
- }
- i2c_stop(adap);
- DEB2(printk(" i2c_write: wrote %d bytes.\n",wrcount));
- return wrcount;
-}
-
-
-static int i2c_read(struct inode * inode, struct file * file,
- char * buf, int count)
-{
- unsigned struct bit_adapter *adap = ADAP(inode->i_rdev);
- char *temp = buf;
- char adr;
- int i,inval;
- int writetries=0; /* try to write some rounds before giving up */
- int rdcount=0; /* counts bytes read */
- struct i2c_data *data;
-
- DEB(printk("i2c%d: ", adap ));
- DEB2(printk("i2c%d: i2c_read: %d byte(s) to read\n", adap, count));
- data=(struct i2c_data *)file->private_data;
- if (data && (data->magic==I2C_MAGIC))
- adr = (data->address);
- else
- return -EINVAL;
- /* slave address is in the lower 7 bits -> shift left to make */
- /* space for the data direction bit */
- adr <<= 1;
-
-#if LINUX_VERSION_CODE >= 0x020100
- /* check data buffer once */
- if ( !access_ok(VERIFY_WRITE,buf,count)) {
- printk("i2c%d: Error accessing user memory!\n",adap);
- return -ENOMEM;
- }
-#endif
-
- i2c_start(adap);
- i=0;
-
-newtry:
-
- if ( i2c_table[adap].flags & P_COMBI ) {
- /* This here is the repeated start condition stuff */
- int retval;
- /* for writing the subaddress, the R/W bit must be 0 */
- while (!i2c_outb(adap,adr)) { /* send address first */
- i2c_stop(adap);
- i++;
- if (i>=i2c_table[adap].retries ) {
- DEBACK(printk("i2c%d: i2c_read: address ack failed\n",adap));
- i2c_stop(adap);
- return -EREMOTEIO;
- };
- i2c_start(adap); /* try again */
- }
- /* successful, reset fail counter */
- i = 0;
- /* send data */
- for (i=0;i<data->writelength;i++) {
- retval = i2c_outb(adap,data->buf[i]);
- if ( !retval ) {
- writetries++;
- if (writetries>=i2c_table[adap].retries ) {
- DEBE(printk("i2c%d: i2c_read: write data failed\n",adap));
- i2c_stop(adap);
- return -EREMOTEIO;
- };
- goto newtry;
- }
- }
- i2c_repstart(adap);
- }
-
- /* send address and do a normal read */
- if ( !i2c_outb(adap,adr | 0x01) ) {
- i2c_stop(adap);
- i++;
- if ( i>=i2c_table[adap].retries ) {
- DEBACK(printk("i2c%d: i2c_read: address ack failed.\n",adap));
- i2c_stop(adap);
- return -EREMOTEIO;
- };
- i2c_start(adap);
- goto newtry;
- }
-
- while (count > 0) {
- inval = i2c_inb(adap);
- if (inval>=0) {
- /* write result into user's buffer (macro) */
-#if LINUX_VERSION_CODE >= 0x020100
- __put_user( (char)(inval) ,temp);
-#else
- put_user((char)(inval),temp);
-#endif
- rdcount++;
- }
- else { /* read timed out */
- DEBE(printk("i2c%d: i2c_read: i2c_inb timed out.\n",adap));
- break;
- }
-
- if ( count > 1 ) { /* send ack */
- sdalo(adap);
- DEBPROTO(printk(" Am "));
- } else {
- sdahi(adap); /* neg. ack on last byte */
- DEBPROTO(printk(" NAm "));
- }
- if (sclhi(adap)<0) { /* timeout */
- sdahi(adap);
- DEBE(printk("i2c%d: i2c_read: Timeout at ack\n", adap));
- return -ETIMEDOUT;
- };
- scllo(adap);
- sdahi(adap);
- temp++;
- count--;
- }
-
- i2c_stop(adap);
- DEB(printk("i2c%d: i2c_read: %d byte(s) read.\n", adap, rdcount ));
- return rdcount;
-}
-
-
-static int i2c_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
-{
- unsigned struct bit_adapter *adap = ADAP(inode->i_rdev);
- int retval = 0;
-
- switch ( cmd ) {
- case I2C_TIMEOUT:
- i2c_table[adap].timeout = arg;
- break;
- case I2C_UDELAY:
- i2c_table[adap].udelay = arg;
- case I2C_MDELAY:
- i2c_table[adap].mdelay = arg;
- break;
- case I2C_RETRIES:
- i2c_table[adap].retries = arg;
- break;
-#ifdef SLO_IO
- case I2C_V_SLOW:
- i2c_table[adap].veryslow = arg;
- break;
-#endif
- case I2C_RESET:
- setsda(adap,1);
- setscl(adap,1);
- break;
- default:
- retval = -EINVAL;
- }
- return retval;
-}
-#endif
-
-static int test_bus(struct bit_adapter *adap) {
- int scl,sda;
- scl=getscl(adap);
- sda=getsda(adap);
- printk("i2c(bit): Adapter: %s scl: %d sda: %d -- testing...\n",
- adap->name,getscl(adap),getsda(adap));
- if (!scl || !sda ) {
- printk("i2c(bit): %s seems to be busy.\n",adap->name);
- goto bailout;
- }
- sdalo(adap);
- printk("i2c(bit):1 scl: %d sda: %d \n",getscl(adap),getsda(adap));
- if ( 0 != getsda(adap) ) {
- printk("i2c(bit): %s SDA stuck high!\n",adap->name);
- sdahi(adap);
- goto bailout;
- }
- if ( 0 == getscl(adap) ) {
- printk("i2c(bit): %s SCL unexpected low while pulling SDA low!\n",
- adap->name);
- goto bailout;
- }
- sdahi(adap);
- printk("i2c(bit):2 scl: %d sda: %d \n",getscl(adap),getsda(adap));
- if ( 0 == getsda(adap) ) {
- printk("i2c(bit): %s SDA stuck low!\n",adap->name);
- sdahi(adap);
- goto bailout;
- }
- if ( 0 == getscl(adap) ) {
- printk("i2c(bit): %s SCL unexpected low while SDA high!\n",adap->name);
- goto bailout;
- }
- scllo(adap);
- printk("i2c(bit):3 scl: %d sda: %d \n",getscl(adap),getsda(adap));
- if ( 0 != getscl(adap) ) {
- printk("i2c(bit): %s SCL stuck high!\n",adap->name);
- sclhi(adap);
- goto bailout;
- }
- if ( 0 == getsda(adap) ) {
- printk("i2c(bit): %s SDA unexpected low while pulling SCL low!\n",
- adap->name);
- goto bailout;
- }
- sclhi(adap);
- printk("i2c(bit):4 scl: %d sda: %d \n",getscl(adap),getsda(adap));
- if ( 0 == getscl(adap) ) {
- printk("i2c(bit): %s SCL stuck low!\n",adap->name);
- sclhi(adap);
- goto bailout;
- }
- if ( 0 == getsda(adap) ) {
- printk("i2c(bit): %s SDA unexpected low while SCL high!\n",
- adap->name);
- goto bailout;
- }
- printk("i2c(bit): %s passed test.\n",adap->name);
- return 0;
-bailout:
- return -ENODEV;
-}
-
-/* ----- Utility functions
- */
-
-inline int try_address(struct bit_adapter *adap,unsigned char addr, int retries)
-{
- int i,ret = -1;
- for (i=0;;) {
- ret = i2c_outb(adap,addr);
- if (ret==1)
- break; /* success! */
- i2c_stop(adap);
- udelay(adap->udelay);
- if (++i >= retries)
- break;
- i2c_start(adap);
- udelay(adap->udelay);
- }
- DEB(if (i) printk("i2c(bit): needed %d retries for %d \n",i,addr));
- return ret;
-}
-
-
-static int bit_send(struct i2c_client *client,const char *buf, int count)
-{
- struct i2c_adapter *adapter=client->adapter;
- struct bit_adapter *adap=(struct bit_adapter*)adapter->data;
- char c;
- const char *temp = buf;
- int ret,retval,i;
- int wrcount=0;
- unsigned int flags=client->flags;
- /* slave address is in the lower 7 bits -> shift left to make */
- /* space for the data direction bit */
-
- DEB(printk("i2c(bit): %s i2c_write: %d byte(s) to send\n", adap->name, count));
-
- i2c_start(adap);
- i=0;
-
- /* first send address: */
- if ( flags & CF_TEN ) { /* a ten bit address */
- unsigned char addr = 0xf0 | ((flags>>15)&0x06);
- printk("addr0: %d, sub %d\n",(unsigned char)addr,((flags>>15)&0x06));
- /* try extended address code...*/
- ret = try_address(adap, (unsigned char)addr, adapter->retries);
- if (ret!=1) {
- printk("died at extended address code.\n");
- return -EREMOTEIO;
- }
- /* the remaining 8 bit address */
- ret = i2c_outb(adap,client->addr);
- if (ret != 1) {
- printk("died at 2nd address code.\n");
- return -EREMOTEIO;
- }
- /* okay, now we are set up to send data*/
- } else { /* normal 7bit address */
- char addr = ( client->addr << 1 );
- ret = try_address(adap, addr, adapter->retries);
- if (ret!=1)
- return -EREMOTEIO;
- }
-
- /* send the data */
- while (count > 0) {
- c = *temp;
- DEB2(printk("i2c(bit): %s i2c_write: writing %2.2X\n",adap->name, c&0xff));
- retval = i2c_outb(adap,c);
- if (retval>0) {
- count--;
- temp++;
- wrcount++;
- } else { /* arbitration or no acknowledge */
- DEBE(printk("i2c(bit): %s i2c_write: error - bailout.\n",adap->name));
- i2c_stop(adap);
- return -EREMOTEIO; /* got a better one ?? */
- }
- /* from asm/delay.h */
- __delay(adap->mdelay * (loops_per_sec / 1000) );
- }
- i2c_stop(adap);
- DEB2(printk(" i2c_write: wrote %d bytes.\n",wrcount));
- return wrcount;
-}
-
-
-static int bit_recv(struct i2c_client *client,char *buf,int count)
-{
- struct i2c_adapter *adapter = client->adapter;
- struct bit_adapter *adap = (struct bit_adapter*)adapter->data;
- char *temp = buf;
- unsigned int flags = client->flags;
- char addr;
- int ret=0,i,inval;
- int rdcount=0; /* counts bytes read */
-
- DEB2(printk("i2c(bit): %s i2c_read: %d byte(s) to read\n", adap->name, count));
-
- /* slave address is in the lower 7 bits -> shift left to make */
- /* space for the data direction bit */
-
-#if LINUX_VERSION_CODE >= 0x020100
- /* check data buffer once */
- if ( !access_ok(VERIFY_WRITE,buf,count)) {
- printk("i2c(bit): Error accessing user memory for bit_read!\n");
- return -ENOMEM;
- }
-#endif
- i2c_start(adap);
- i=0;
- DEB2(printk("i2c(bit): flags %#x\n",flags));
- /* first send address: */
- if ( (flags & CF_TEN) != 0 ) { /* a ten bit address */
- addr = 0xf0 | ((flags>>15)&0x06);
- printk("addr0: %d, sub %d\n",addr,((flags>>15)&0x06));
- /* try extended address code...*/
- ret = try_address(adap, addr, adapter->retries);
- if (ret!=1) {
- printk("died at extended address code.\n");
- return -EREMOTEIO;
- }
- /* the remaining 8 bit address */
- ret = i2c_outb(adap,client->addr);
- if (ret != 1) {
- printk("died at 2nd address code.\n");
- return -EREMOTEIO;
- }
- i2c_repstart(adap);
- /* okay, now switch into reading mode */
- addr |= 0x01;
- ret = try_address(adap, addr, adapter->retries);
- if (ret!=1) {
- printk("died at extended address code.\n");
- return -EREMOTEIO;
- }
- } else { /* normal 7bit address */
- addr = ( client->addr << 1 ) | 0x01;
- ret = try_address(adap, addr, adapter->retries);
- if (ret!=1)
- return -EREMOTEIO;
- }
-
- udelay(adap->udelay);
- /* now read the data */
- while (count > 0) {
- inval = i2c_inb(adap);
- if (inval>=0) {
- /* write result into user's buffer (macro) */
-#if LINUX_VERSION_CODE >= 0x020100
- __put_user( (char)(inval) ,temp);
-#else
- put_user((char)(inval),temp);
-#endif
- rdcount++;
- }
- else { /* read timed out */
- DEBE(printk("i2c(bit): i2c_read: i2c_inb timed out.\n"));
- break;
- }
-
- if ( count > 1 ) { /* send ack */
- sdalo(adap);
- DEBPROTO(printk(" Am "));
- } else {
- sdahi(adap); /* neg. ack on last byte */
- DEBPROTO(printk(" NAm "));
- }
- if (sclhi(adap)<0) { /* timeout */
- sdahi(adap);
- DEBE(printk("i2c(bit): i2c_read: Timeout at ack\n"));
- return -ETIMEDOUT;
- };
- scllo(adap);
- sdahi(adap);
- temp++;
- count--;
- }
-
- i2c_stop(adap);
- DEB(printk("i2c(bit): i2c_read: %d byte(s) read.\n", rdcount ));
- return rdcount;
-}
-
-static int bit_comb(struct i2c_client *client,char*r,const char*w,int i,int j, int k)
-{
- return 0;
-}
-
-
-static int algo_control(struct i2c_adapter *adapter,
- unsigned int cmd, unsigned long arg)
-{
- return 0;
-}
-
-static int client_register(struct i2c_client *client)
-{
- struct i2c_adapter *adapter = client->adapter;
- struct bit_adapter *adap = (struct bit_adapter*)adapter->data;
-
- if (adap->client_register != NULL)
- return adap->client_register(client);
- return 0;
-}
-
-int client_unregister(struct i2c_client *client)
-{
- struct i2c_adapter *adapter = client->adapter;
- struct bit_adapter *adap = (struct bit_adapter*)adapter->data;
-
- if (adap->client_unregister != NULL)
- return adap->client_unregister(client);
- return 0;
-}
-
-/* -----exported algorithm data: ------------------------------------- */
-
-struct i2c_algorithm bit_algo = {
- "Bit-shift algorithm",
- ALGO_BIT,
- bit_send, /* master_xmit */
- bit_recv, /* master_recv */
- bit_comb, /* master_comb */
- NULL, /* slave_xmit */
- NULL, /* slave_recv */
- algo_control, /* ioctl */
- client_register,
- client_unregister,
-};
-
-/*
- * registering functions to load algorithms at runtime
- */
-int i2c_bit_register_bus(struct bit_adapter *adap)
-{
- int i,ack;
- struct i2c_adapter *i2c_adap;
-
- for (i = 0; i < BIT_ADAP_MAX; i++)
- if (NULL == bit_adaps[i])
- break;
- if (BIT_ADAP_MAX == i)
- return -ENOMEM;
-
- bit_adaps[i] = adap;
- adap_count++;
- DEB(printk("i2c(bit): algorithm %s registered.\n",adap->name));
-
- MOD_INC_USE_COUNT;
-
- if (test) {
- int ret = test_bus(adap);
- if (ret<0)
- return -ENODEV;
- }
- /* register new adapter to i2c module... */
-
- i2c_adap = kmalloc(sizeof(struct i2c_adapter), GFP_KERNEL);
- i2c_adap->name = adap->name;
- i2c_adap->id = bit_algo.id | adap->id;
- i2c_adap->algo = &bit_algo;
- i2c_adap->data = adap;
- i2c_adap->flags = 0;
- i2c_adap->timeout = 100; /* default values, should */
- i2c_adap->retries = 3; /* be replaced by defines */
- i2c_adaps[i] = i2c_adap;
- i2c_register_adapter(i2c_adap);
-
- /* scan bus */
- printk(KERN_INFO "i2c(bit): scanning bus %s.\n", adap->name);
- if (scan)
- for (i = 0x00; i < 0xff; i+=2) {
- i2c_start(adap);
- ack = i2c_outb(adap,i);
- i2c_stop(adap);
- if (ack>0) {
- printk(KERN_INFO
- "i2c(bit): found chip at addr=0x%2x\n",i);
- }
- }
- return 0;
-}
-
-
-int i2c_bit_unregister_bus(struct bit_adapter *adap)
-{
- int i;
-
- for (i = 0; i < BIT_ADAP_MAX; i++)
- if ( adap == bit_adaps[i])
- break;
- if ( BIT_ADAP_MAX == i) {
- printk(KERN_WARNING "i2c(bit): could not unregister bus: %s\n",
- adap->name);
- return -ENODEV;
- }
-
- MOD_DEC_USE_COUNT;
-
- bit_adaps[i] = NULL;
- i2c_unregister_adapter(i2c_adaps[i]);
- kfree(i2c_adaps[i]);
- i2c_adaps[i] = NULL;
- adap_count--;
- DEB(printk("i2c(bit): adapter unregistered: %s\n",adap->name));
-
- return 0;
-}
-
-int algo_bit_init (void)
-{
- int i;
-
- for (i=0;i<BIT_ADAP_MAX;i++) {
- bit_adaps[i]=NULL;
- }
- adap_count=0;
- i2c_register_algorithm(&bit_algo);
- return 0;
-}
-
-#ifdef MODULE
-MODULE_PARM(test, "i");
-MODULE_PARM(scan, "i");
-
-/*
-EXPORT_SYMBOL(i2c_bit_register_bus);
-EXPORT_SYMBOL(i2c_bit_unregister_bus);
-*/
-
-int init_module(void)
-{
- return algo_bit_init();
-}
-
-void cleanup_module(void)
-{
- i2c_unregister_algorithm(&bit_algo);
-}
-#endif
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/bttv/experimental/algo-bit.h b/bttv/experimental/algo-bit.h
deleted file mode 100644
index 0cd97d8..0000000
--- a/bttv/experimental/algo-bit.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef ALGO_BIT_H
-#define AGLO_BIT_H 1
-
-/* --- Defines for bit-adapters --------------------------------------- */
-#include "i2c.h"
-/*
- * This struct contains the hw-dependent functions of bit-style adapters to
- * manipulate the line states, and to init any hw-specific features. This is
- * only used if you have more than one hw-type of adapter running.
- */
-struct bit_adapter {
- char *name; /* give it a nice name */
- unsigned int id; /* not used yet, maybe later */
- void *data; /* private data for lolevel routines */
- void (*setsda) (void *data, int state);
- void (*setscl) (void *data, int state);
- int (*getsda) (void *data);
- int (*getscl) (void *data);
-
- /* administrative calls */
- int (*client_register)(struct i2c_client *);
- int (*client_unregister)(struct i2c_client *);
-
- /* local settings */
- int udelay;
- int mdelay;
- int timeout;
-
-};
-
-extern struct bit_adapter *bit_adaps[];
-
-#define BIT_ADAP_MAX 16
-
-int i2c_bit_register_bus(struct bit_adapter *);
-int i2c_bit_unregister_bus(struct bit_adapter *);
-
-#endif /* ALGO_BIT_H */
diff --git a/bttv/experimental/bt848.h b/bttv/experimental/bt848.h
deleted file mode 100644
index 0956360..0000000
--- a/bttv/experimental/bt848.h
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- bt848.h - Bt848 register offsets
-
- Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _BT848_H_
-#define _BT848_H_
-
-#ifndef PCI_VENDOR_ID_BROOKTREE
-#define PCI_VENDOR_ID_BROOKTREE 0x109e
-#endif
-#ifndef PCI_DEVICE_ID_BT848
-#define PCI_DEVICE_ID_BT848 0x350
-#endif
-#ifndef PCI_DEVICE_ID_BT849
-#define PCI_DEVICE_ID_BT849 0x351
-#endif
-#ifndef PCI_DEVICE_ID_BT878
-#define PCI_DEVICE_ID_BT878 0x36e
-#endif
-#ifndef PCI_DEVICE_ID_BT879
-#define PCI_DEVICE_ID_BT879 0x36f
-#endif
-
-
-/* Brooktree 848 registers */
-
-#define BT848_DSTATUS 0x000
-#define BT848_DSTATUS_PRES (1<<7)
-#define BT848_DSTATUS_HLOC (1<<6)
-#define BT848_DSTATUS_FIELD (1<<5)
-#define BT848_DSTATUS_NUML (1<<4)
-#define BT848_DSTATUS_CSEL (1<<3)
-#define BT848_DSTATUS_PLOCK (1<<2)
-#define BT848_DSTATUS_LOF (1<<1)
-#define BT848_DSTATUS_COF (1<<0)
-
-#define BT848_IFORM 0x004
-#define BT848_IFORM_HACTIVE (1<<7)
-#define BT848_IFORM_MUXSEL (3<<5)
-#define BT848_IFORM_MUX0 (2<<5)
-#define BT848_IFORM_MUX1 (3<<5)
-#define BT848_IFORM_MUX2 (1<<5)
-#define BT848_IFORM_XTSEL (3<<3)
-#define BT848_IFORM_XT0 (1<<3)
-#define BT848_IFORM_XT1 (2<<3)
-#define BT848_IFORM_XTAUTO (3<<3)
-#define BT848_IFORM_XTBOTH (3<<3)
-#define BT848_IFORM_NTSC 1
-#define BT848_IFORM_NTSC_J 2
-#define BT848_IFORM_PAL_BDGHI 3
-#define BT848_IFORM_PAL_M 4
-#define BT848_IFORM_PAL_N 5
-#define BT848_IFORM_SECAM 6
-#define BT848_IFORM_PAL_NC 7
-#define BT848_IFORM_AUTO 0
-#define BT848_IFORM_NORM 7
-
-#define BT848_TDEC 0x008
-#define BT848_TDEC_DEC_FIELD (1<<7)
-#define BT848_TDEC_FLDALIGN (1<<6)
-#define BT848_TDEC_DEC_RAT (0x1f)
-
-#define BT848_E_CROP 0x00C
-#define BT848_O_CROP 0x08C
-
-#define BT848_E_VDELAY_LO 0x010
-#define BT848_O_VDELAY_LO 0x090
-
-#define BT848_E_VACTIVE_LO 0x014
-#define BT848_O_VACTIVE_LO 0x094
-
-#define BT848_E_HDELAY_LO 0x018
-#define BT848_O_HDELAY_LO 0x098
-
-#define BT848_E_HACTIVE_LO 0x01C
-#define BT848_O_HACTIVE_LO 0x09C
-
-#define BT848_E_HSCALE_HI 0x020
-#define BT848_O_HSCALE_HI 0x0A0
-
-#define BT848_E_HSCALE_LO 0x024
-#define BT848_O_HSCALE_LO 0x0A4
-
-#define BT848_BRIGHT 0x028
-
-#define BT848_E_CONTROL 0x02C
-#define BT848_O_CONTROL 0x0AC
-#define BT848_CONTROL_LNOTCH (1<<7)
-#define BT848_CONTROL_COMP (1<<6)
-#define BT848_CONTROL_LDEC (1<<5)
-#define BT848_CONTROL_CBSENSE (1<<4)
-#define BT848_CONTROL_CON_MSB (1<<2)
-#define BT848_CONTROL_SAT_U_MSB (1<<1)
-#define BT848_CONTROL_SAT_V_MSB (1<<0)
-
-#define BT848_CONTRAST_LO 0x030
-#define BT848_SAT_U_LO 0x034
-#define BT848_SAT_V_LO 0x038
-#define BT848_HUE 0x03C
-
-#define BT848_E_SCLOOP 0x040
-#define BT848_O_SCLOOP 0x0C0
-#define BT848_SCLOOP_CAGC (1<<6)
-#define BT848_SCLOOP_CKILL (1<<5)
-#define BT848_SCLOOP_HFILT_AUTO (0<<3)
-#define BT848_SCLOOP_HFILT_CIF (1<<3)
-#define BT848_SCLOOP_HFILT_QCIF (2<<3)
-#define BT848_SCLOOP_HFILT_ICON (3<<3)
-
-#define BT848_SCLOOP_PEAK (1<<7)
-#define BT848_SCLOOP_HFILT_MINP (1<<3)
-#define BT848_SCLOOP_HFILT_MEDP (2<<3)
-#define BT848_SCLOOP_HFILT_MAXP (3<<3)
-
-
-#define BT848_OFORM 0x048
-#define BT848_OFORM_RANGE (1<<7)
-#define BT848_OFORM_CORE0 (0<<5)
-#define BT848_OFORM_CORE8 (1<<5)
-#define BT848_OFORM_CORE16 (2<<5)
-#define BT848_OFORM_CORE32 (3<<5)
-
-#define BT848_E_VSCALE_HI 0x04C
-#define BT848_O_VSCALE_HI 0x0CC
-#define BT848_VSCALE_YCOMB (1<<7)
-#define BT848_VSCALE_COMB (1<<6)
-#define BT848_VSCALE_INT (1<<5)
-#define BT848_VSCALE_HI 15
-
-#define BT848_E_VSCALE_LO 0x050
-#define BT848_O_VSCALE_LO 0x0D0
-#define BT848_TEST 0x054
-#define BT848_ADELAY 0x060
-#define BT848_BDELAY 0x064
-
-#define BT848_ADC 0x068
-#define BT848_ADC_RESERVED (2<<6)
-#define BT848_ADC_SYNC_T (1<<5)
-#define BT848_ADC_AGC_EN (1<<4)
-#define BT848_ADC_CLK_SLEEP (1<<3)
-#define BT848_ADC_Y_SLEEP (1<<2)
-#define BT848_ADC_C_SLEEP (1<<1)
-#define BT848_ADC_CRUSH (1<<0)
-
-#define BT848_E_VTC 0x06C
-#define BT848_O_VTC 0x0EC
-#define BT848_VTC_HSFMT (1<<7)
-#define BT848_VTC_VFILT_2TAP 0
-#define BT848_VTC_VFILT_3TAP 1
-#define BT848_VTC_VFILT_4TAP 2
-#define BT848_VTC_VFILT_5TAP 3
-
-#define BT848_SRESET 0x07C
-
-#define BT848_COLOR_FMT 0x0D4
-#define BT848_COLOR_FMT_O_RGB32 (0<<4)
-#define BT848_COLOR_FMT_O_RGB24 (1<<4)
-#define BT848_COLOR_FMT_O_RGB16 (2<<4)
-#define BT848_COLOR_FMT_O_RGB15 (3<<4)
-#define BT848_COLOR_FMT_O_YUY2 (4<<4)
-#define BT848_COLOR_FMT_O_BtYUV (5<<4)
-#define BT848_COLOR_FMT_O_Y8 (6<<4)
-#define BT848_COLOR_FMT_O_RGB8 (7<<4)
-#define BT848_COLOR_FMT_O_YCrCb422 (8<<4)
-#define BT848_COLOR_FMT_O_YCrCb411 (9<<4)
-#define BT848_COLOR_FMT_O_RAW (14<<4)
-#define BT848_COLOR_FMT_E_RGB32 0
-#define BT848_COLOR_FMT_E_RGB24 1
-#define BT848_COLOR_FMT_E_RGB16 2
-#define BT848_COLOR_FMT_E_RGB15 3
-#define BT848_COLOR_FMT_E_YUY2 4
-#define BT848_COLOR_FMT_E_BtYUV 5
-#define BT848_COLOR_FMT_E_Y8 6
-#define BT848_COLOR_FMT_E_RGB8 7
-#define BT848_COLOR_FMT_E_YCrCb422 8
-#define BT848_COLOR_FMT_E_YCrCb411 9
-#define BT848_COLOR_FMT_E_RAW 14
-
-#define BT848_COLOR_FMT_RGB32 0x00
-#define BT848_COLOR_FMT_RGB24 0x11
-#define BT848_COLOR_FMT_RGB16 0x22
-#define BT848_COLOR_FMT_RGB15 0x33
-#define BT848_COLOR_FMT_YUY2 0x44
-#define BT848_COLOR_FMT_BtYUV 0x55
-#define BT848_COLOR_FMT_Y8 0x66
-#define BT848_COLOR_FMT_RGB8 0x77
-#define BT848_COLOR_FMT_YCrCb422 0x88
-#define BT848_COLOR_FMT_YCrCb411 0x99
-#define BT848_COLOR_FMT_RAW 0xee
-
-#define BT848_COLOR_CTL 0x0D8
-#define BT848_COLOR_CTL_EXT_FRMRATE (1<<7)
-#define BT848_COLOR_CTL_COLOR_BARS (1<<6)
-#define BT848_COLOR_CTL_RGB_DED (1<<5)
-#define BT848_COLOR_CTL_GAMMA (1<<4)
-#define BT848_COLOR_CTL_WSWAP_ODD (1<<3)
-#define BT848_COLOR_CTL_WSWAP_EVEN (1<<2)
-#define BT848_COLOR_CTL_BSWAP_ODD (1<<1)
-#define BT848_COLOR_CTL_BSWAP_EVEN (1<<0)
-
-#define BT848_CAP_CTL 0x0DC
-#define BT848_CAP_CTL_DITH_FRAME (1<<4)
-#define BT848_CAP_CTL_CAPTURE_VBI_ODD (1<<3)
-#define BT848_CAP_CTL_CAPTURE_VBI_EVEN (1<<2)
-#define BT848_CAP_CTL_CAPTURE_ODD (1<<1)
-#define BT848_CAP_CTL_CAPTURE_EVEN (1<<0)
-
-#define BT848_VBI_PACK_SIZE 0x0E0
-
-#define BT848_VBI_PACK_DEL 0x0E4
-#define BT848_VBI_PACK_DEL_VBI_HDELAY 0xfc
-#define BT848_VBI_PACK_DEL_EXT_FRAME 2
-#define BT848_VBI_PACK_DEL_VBI_PKT_HI 1
-
-
-#define BT848_INT_STAT 0x100
-#define BT848_INT_MASK 0x104
-
-#define BT848_INT_ETBF (1<<23)
-
-#define BT848_INT_RISCS (0xf<<28)
-#define BT848_INT_RISC_EN (1<<27)
-#define BT848_INT_RACK (1<<25)
-#define BT848_INT_FIELD (1<<24)
-#define BT848_INT_SCERR (1<<19)
-#define BT848_INT_OCERR (1<<18)
-#define BT848_INT_PABORT (1<<17)
-#define BT848_INT_RIPERR (1<<16)
-#define BT848_INT_PPERR (1<<15)
-#define BT848_INT_FDSR (1<<14)
-#define BT848_INT_FTRGT (1<<13)
-#define BT848_INT_FBUS (1<<12)
-#define BT848_INT_RISCI (1<<11)
-#define BT848_INT_GPINT (1<<9)
-#define BT848_INT_I2CDONE (1<<8)
-#define BT848_INT_VPRES (1<<5)
-#define BT848_INT_HLOCK (1<<4)
-#define BT848_INT_OFLOW (1<<3)
-#define BT848_INT_HSYNC (1<<2)
-#define BT848_INT_VSYNC (1<<1)
-#define BT848_INT_FMTCHG (1<<0)
-
-
-#define BT848_GPIO_DMA_CTL 0x10C
-#define BT848_GPIO_DMA_CTL_GPINTC (1<<15)
-#define BT848_GPIO_DMA_CTL_GPINTI (1<<14)
-#define BT848_GPIO_DMA_CTL_GPWEC (1<<13)
-#define BT848_GPIO_DMA_CTL_GPIOMODE (3<<11)
-#define BT848_GPIO_DMA_CTL_GPCLKMODE (1<<10)
-#define BT848_GPIO_DMA_CTL_PLTP23_4 (0<<6)
-#define BT848_GPIO_DMA_CTL_PLTP23_8 (1<<6)
-#define BT848_GPIO_DMA_CTL_PLTP23_16 (2<<6)
-#define BT848_GPIO_DMA_CTL_PLTP23_32 (3<<6)
-#define BT848_GPIO_DMA_CTL_PLTP1_4 (0<<4)
-#define BT848_GPIO_DMA_CTL_PLTP1_8 (1<<4)
-#define BT848_GPIO_DMA_CTL_PLTP1_16 (2<<4)
-#define BT848_GPIO_DMA_CTL_PLTP1_32 (3<<4)
-#define BT848_GPIO_DMA_CTL_PKTP_4 (0<<2)
-#define BT848_GPIO_DMA_CTL_PKTP_8 (1<<2)
-#define BT848_GPIO_DMA_CTL_PKTP_16 (2<<2)
-#define BT848_GPIO_DMA_CTL_PKTP_32 (3<<2)
-#define BT848_GPIO_DMA_CTL_RISC_ENABLE (1<<1)
-#define BT848_GPIO_DMA_CTL_FIFO_ENABLE (1<<0)
-
-#define BT848_I2C 0x110
-#define BT848_I2C_DIV (0xf<<4)
-#define BT848_I2C_SYNC (1<<3)
-#define BT848_I2C_W3B (1<<2)
-#define BT848_I2C_SCL (1<<1)
-#define BT848_I2C_SDA (1<<0)
-
-
-#define BT848_RISC_STRT_ADD 0x114
-#define BT848_GPIO_OUT_EN 0x118
-#define BT848_GPIO_REG_INP 0x11C
-#define BT848_RISC_COUNT 0x120
-#define BT848_GPIO_DATA 0x200
-
-
-/* Bt848 RISC commands */
-
-/* only for the SYNC RISC command */
-#define BT848_FIFO_STATUS_FM1 0x06
-#define BT848_FIFO_STATUS_FM3 0x0e
-#define BT848_FIFO_STATUS_SOL 0x02
-#define BT848_FIFO_STATUS_EOL4 0x01
-#define BT848_FIFO_STATUS_EOL3 0x0d
-#define BT848_FIFO_STATUS_EOL2 0x09
-#define BT848_FIFO_STATUS_EOL1 0x05
-#define BT848_FIFO_STATUS_VRE 0x04
-#define BT848_FIFO_STATUS_VRO 0x0c
-#define BT848_FIFO_STATUS_PXV 0x00
-
-#define BT848_RISC_RESYNC (1<<15)
-
-/* WRITE and SKIP */
-/* disable which bytes of each DWORD */
-#define BT848_RISC_BYTE0 (1<<12)
-#define BT848_RISC_BYTE1 (1<<13)
-#define BT848_RISC_BYTE2 (1<<14)
-#define BT848_RISC_BYTE3 (1<<15)
-#define BT848_RISC_BYTE_ALL (0x0f<<12)
-#define BT848_RISC_BYTE_NONE 0
-/* cause RISCI */
-#define BT848_RISC_IRQ (1<<24)
-/* RISC command is last one in this line */
-#define BT848_RISC_EOL (1<<26)
-/* RISC command is first one in this line */
-#define BT848_RISC_SOL (1<<27)
-
-#define BT848_RISC_WRITE (0x01<<28)
-#define BT848_RISC_SKIP (0x02<<28)
-#define BT848_RISC_WRITEC (0x05<<28)
-#define BT848_RISC_JUMP (0x07<<28)
-#define BT848_RISC_SYNC (0x08<<28)
-
-#define BT848_RISC_WRITE123 (0x09<<28)
-#define BT848_RISC_SKIP123 (0x0a<<28)
-#define BT848_RISC_WRITE1S23 (0x0b<<28)
-
-
-
-/* Bt848A and Bt849 only !! */
-#define BT848_TGLB 0x080
-#define BT848_TGCTRL 0x084
-#define BT848_FCAP 0x0E8
-#define BT848_PLL_F_LO 0x0F0
-#define BT848_PLL_F_HI 0x0F4
-#define BT848_PLL_XCI 0x0F8
-
-
-#endif
diff --git a/bttv/experimental/bttv.c b/bttv/experimental/bttv.c
deleted file mode 100644
index 14864a2..0000000
--- a/bttv/experimental/bttv.c
+++ /dev/null
@@ -1,3261 +0,0 @@
-/*
- bttv - Bt848 frame grabber driver
-
- Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
- & Marcus Metzler (mocm@thp.uni-koeln.de)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Modified to put the RISC code writer in the kernel and to fit a
- common (and I hope safe) kernel interface. When we have an X extension
- all will now be really sweet.
-
- TODO:
-
- * move norm from tuner to channel struct!?
- composite source from a satellite tuner can deliver different norms
- depending on tuned channel
- * mmap VBI data?
- * use new PCI routines
- * fix RAW Composite grabbing for NTSC
- * allow for different VDELAYs
- (larger to get Videodat in VBI and smaller to get the whole
- picture in RAW grabbing)
- * extra modules for tda9850, tda8425, any volunteers???
- * right border clipping is still buggy
- (decide which clipping code to use and throw the other out ...)
-*/
-
-#include <linux/module.h>
-#include <linux/bios32.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/kernel.h>
-#include <linux/major.h>
-#include <linux/malloc.h>
-#include <linux/mm.h>
-#include <linux/pci.h>
-#include <linux/signal.h>
-#include <asm/io.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <linux/sched.h>
-#include <asm/segment.h>
-#include <linux/types.h>
-#include <linux/wrapper.h>
-
-#include "videodev.h"
-#include <linux/version.h>
-#if LINUX_VERSION_CODE >= 0x020100
-#include <asm/uaccess.h>
-#else
-#define signal_pending(current) (current->signal & ~current->blocked)
-#define sigfillset(set)
-
-static inline unsigned long
-copy_to_user(void *to, const void *from, unsigned long n)
-{
- memcpy_tofs(to,from,n);
- return 0;
-}
-
-static inline unsigned long
-copy_from_user(void *to, const void *from, unsigned long n)
-{
- memcpy_fromfs(to,from,n);
- return 0;
-}
-#define ioremap vremap
-#define iounmap vfree
-#endif
-
-#include "i2c.h"
-#include "algo-bit.h"
-#include "bttv.h"
-#include "tuner.h"
-
-#define DEBUG(x) /* Debug driver */
-#define IDEBUG(x) /* Debug interrupt handler */
-
-static unsigned int remap=0; /* remap Bt848 */
-static unsigned int vidmem=0; /* manually set video mem address */
-static int triton1=0;
-static int radio=0;
-
-static unsigned int card=CARD_DEFAULT;
-
-#if LINUX_VERSION_CODE >= 0x020117
-MODULE_PARM(remap,"i");
-MODULE_PARM(vidmem,"i");
-MODULE_PARM(triton1,"i");
-MODULE_PARM(radio,"i");
-MODULE_PARM(card,"i");
-#endif
-
-static int find_vga(void);
-static void bt848_set_risc_jmps(struct bttv *btv);
-
-/* Anybody who uses more than four? */
-#define BTTV_MAX 4
-
-static int bttv_num; /* number of Bt848s in use */
-static struct bttv bttvs[BTTV_MAX];
-
-#define I2C_TIMING (0x7<<4)
-#define I2C_COMMAND (I2C_TIMING | BT848_I2C_SCL | BT848_I2C_SDA)
-
-#define I2C_DELAY 10
-
-#define AUDIO_MUTE_DELAY 10000
-#define FREQ_CHANGE_DELAY 20000
-#define EEPROM_WRITE_DELAY 20000
-
-/*******************************/
-/* Memory management functions */
-/*******************************/
-
-/* convert virtual user memory address to physical address */
-/* (virt_to_phys only works for kmalloced kernel memory) */
-
-static inline unsigned long uvirt_to_phys(unsigned long adr)
-{
- pgd_t *pgd;
- pmd_t *pmd;
- pte_t *ptep, pte;
-
- pgd = pgd_offset(current->mm, adr);
- if (pgd_none(*pgd))
- return 0;
- pmd = pmd_offset(pgd, adr);
- if (pmd_none(*pmd))
- return 0;
- ptep = pte_offset(pmd, adr/*&(~PGDIR_MASK)*/);
- pte = *ptep;
- if(pte_present(pte))
- return
- virt_to_phys((void *)(pte_page(pte)|(adr&(PAGE_SIZE-1))));
- return 0;
-}
-
-static inline unsigned long uvirt_to_bus(unsigned long adr)
-{
- /* printk("adr: 0x%8x, ",adr);
- printk("phys: 0x%8x, ",(uvirt_to_phys(adr)));
- printk("bus: 0x%8x\n",virt_to_bus(phys_to_virt(uvirt_to_phys(adr))));
- */
- return virt_to_bus(phys_to_virt(uvirt_to_phys(adr)));
-}
-
-/* convert virtual kernel memory address to physical address */
-/* (virt_to_phys only works for kmalloced kernel memory) */
-
-static inline unsigned long kvirt_to_phys(unsigned long adr)
-{
- return uvirt_to_phys(VMALLOC_VMADDR(adr));
-}
-
-static inline unsigned long kvirt_to_bus(unsigned long adr)
-{
- return uvirt_to_bus(VMALLOC_VMADDR(adr));
-}
-
-static void * rvmalloc(unsigned long size)
-{
- void * mem;
- unsigned long adr, page;
-
- mem=vmalloc(size);
- if (mem)
- {
- adr=(unsigned long) mem;
- while (size > 0)
- {
- page = kvirt_to_phys(adr);
- mem_map_reserve(MAP_NR(phys_to_virt(page)));
- adr+=PAGE_SIZE;
- size-=PAGE_SIZE;
- }
- }
- return mem;
-}
-
-static void rvfree(void * mem, unsigned long size)
-{
- unsigned long adr, page;
-
- if (mem)
- {
- adr=(unsigned long) mem;
- while (size > 0)
- {
- page = kvirt_to_phys(adr);
- mem_map_unreserve(MAP_NR(phys_to_virt(page)));
- adr+=PAGE_SIZE;
- size-=PAGE_SIZE;
- }
- vfree(mem);
- }
-}
-
-/*
- * Create the giant waste of buffer space we need for now
- * until we get DMA to user space sorted out (probably 2.3.x)
- *
- * We only create this as and when someone uses mmap
- */
-
-static int fbuffer_alloc(struct bttv *btv)
-{
- if(!btv->fbuffer)
- btv->fbuffer=(unsigned char *) rvmalloc(2*BTTV_MAX_FBUF);
- else
- printk(KERN_ERR "bttv: Double alloc of fbuffer!\n");
- if(!btv->fbuffer)
- return -ENOBUFS;
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-/* I2C functions */
-
-/* hardware I2C functions */
-
-/* read I2C */
-static int I2CRead(struct bttv *btv, unsigned char addr)
-{
- u32 i;
- u32 stat;
-
- /* clear status bit ; BT848_INT_RACK is ro */
- btwrite(BT848_INT_I2CDONE, BT848_INT_STAT);
-
- btwrite(((addr & 0xff) << 24) | I2C_COMMAND, BT848_I2C);
-
- /*
- * Timeout for I2CRead is 1 second (this should be enough, really!)
- */
- for (i=1000; i; i--)
- {
- stat=btread(BT848_INT_STAT);
- if (stat & BT848_INT_I2CDONE)
- break;
-#if LINUX_VERSION_CODE >= 0x020199
- mdelay(1);
-#else
- udelay(1000);
-#endif
- }
-
- if (!i)
- {
- printk(KERN_DEBUG "bttv: I2CRead timeout\n");
- return -1;
- }
- if (!(stat & BT848_INT_RACK))
- return -2;
-
- i=(btread(BT848_I2C)>>8)&0xff;
- return i;
-}
-
-/* set both to write both bytes, reset it to write only b1 */
-
-static int I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1,
- unsigned char b2, int both)
-{
- u32 i;
- u32 data;
- u32 stat;
-
- /* clear status bit; BT848_INT_RACK is ro */
- btwrite(BT848_INT_I2CDONE, BT848_INT_STAT);
-
- data=((addr & 0xff) << 24) | ((b1 & 0xff) << 16) | I2C_COMMAND;
- if (both)
- {
- data|=((b2 & 0xff) << 8);
- data|=BT848_I2C_W3B;
- }
-
- btwrite(data, BT848_I2C);
-
- for (i=0x1000; i; i--)
- {
- stat=btread(BT848_INT_STAT);
- if (stat & BT848_INT_I2CDONE)
- break;
-#if LINUX_VERSION_CODE >= 0x020199
- mdelay(1);
-#else
- udelay(1000);
-#endif
- }
-
- if (!i)
- {
- printk(KERN_DEBUG "bttv: I2CWrite timeout\n");
- return -1;
- }
- if (!(stat & BT848_INT_RACK))
- return -2;
-
- return 0;
-}
-
-#define I2C_VERY_VERBOSE 0
-
-static void bit_bt848_setscl(void *data, int state)
-{
- struct bttv *btv = (struct bttv*)data;
-
- if (state)
- btv->i2c_state |= 0x02;
- else
- btv->i2c_state &= ~0x02;
-#if I2C_VERY_VERBOSE
- printk("bttv i2c: set ctrl %d - c%d d%d\n",
- state,
- btv->i2c_state & 0x02 ? 1 : 0, btv->i2c_state & 0x01 ? 1 : 0);
-#endif
- btwrite(btv->i2c_state, BT848_I2C);
-}
-
-static void bit_bt848_setsda(void *data, int state)
-{
- struct bttv *btv = (struct bttv*)data;
-
- if (state)
- btv->i2c_state |= 0x01;
- else
- btv->i2c_state &= ~0x01;
-#if I2C_VERY_VERBOSE
- printk("bttv i2c: set data %d - c%d d%d\n",
- state,
- btv->i2c_state & 0x02 ? 1 : 0, btv->i2c_state & 0x01 ? 1 : 0);
-#endif
- btwrite(btv->i2c_state, BT848_I2C);
-}
-
-static int bit_bt848_getscl(void *data)
-{
- struct bttv *btv = (struct bttv*)data;
- int state;
-
- state = btread(BT848_I2C) & 0x02 ? 1 : 0;
-#if I2C_VERY_VERBOSE
- printk("bttv i2c: get ctrl %d - c%d d%d\n",
- state,
- btv->i2c_state & 0x02 ? 1 : 0, btv->i2c_state & 0x01 ? 1 : 0);
-#endif
- return state;
-}
-
-static int bit_bt848_getsda(void *data)
-{
- struct bttv *btv = (struct bttv*)data;
- int state;
- state = btread(BT848_I2C) & 0x01;
-#if I2C_VERY_VERBOSE
- printk("bttv i2c: get data %d - c%d d%d\n",
- state,
- btv->i2c_state & 0x02 ? 1 : 0, btv->i2c_state & 0x01 ? 1 : 0);
-#endif
- return state;
-}
-
-static int bit_bt848_reg(struct i2c_client *client)
-{
- struct bit_adapter *b = (struct bit_adapter*)client->adapter->data;
- struct bttv *btv = (struct bttv*)b->data;
-
- switch(client->id) {
- case I2C_DRIVERID_TUNER:
- btv->tuner = client;
- break;
- case I2C_DRIVERID_MSP3400:
- btv->msp3400 = client;
- break;
- }
- printk("bttv%d: i2c reg: %s (id 0x%x)\n",btv->nr,client->name,client->id);
- return 0;
-}
-
-static int bit_bt848_unreg(struct i2c_client *client)
-{
- struct bit_adapter *b = (struct bit_adapter*)client->adapter->data;
- struct bttv *btv = (struct bttv*)b->data;
-
- switch(client->id) {
- case I2C_DRIVERID_TUNER:
- btv->tuner = NULL;
- break;
- case I2C_DRIVERID_MSP3400:
- btv->msp3400 = NULL;
- break;
- }
- printk("bttv%d: i2c unreg: %s (id 0x%x)\n",btv->nr,client->name,client->id);
- return 0;
-}
-
-struct bit_adapter bit_bt848_ops_template = {
- "bt848 i2c adapter",
- HW_B_BT848,
- NULL,
- bit_bt848_setsda,
- bit_bt848_setscl,
- bit_bt848_getsda,
- bit_bt848_getscl,
- bit_bt848_reg,
- bit_bt848_unreg,
- I2C_DELAY, I2C_DELAY, I2C_DELAY*100
-};
-
-/* ----------------------------------------------------------------------- */
-
-struct tvcard
-{
- int inputs;
- int tuner;
- int svhs;
- u32 gpiomask;
- u32 muxsel[8];
- u32 audiomux[6]; /* Tuner, Radio, internal, external, mute, stereo */
- u32 gpiomask2; /* GPIO MUX mask */
-};
-
-static struct tvcard tvcards[] =
-{
- /* default */
- { 3, 0, 2, 0, { 2, 3, 1, 1}, { 0, 0, 0, 0, 0}},
- /* MIRO */
- { 4, 0, 2,15, { 2, 3, 1, 1}, { 2, 0, 0, 0,10}},
- /* Hauppauge */
- { 3, 0, 2, 7, { 2, 3, 1, 1}, { 0, 1, 2, 3, 4}},
- /* STB */
- { 3, 0, 2, 7, { 2, 3, 1, 1}, { 4, 0, 2, 3, 1}},
- /* Intel??? */
- { 3, 0, 2, 7, { 2, 3, 1, 1}, { 0, 1, 2, 3, 4}},
- /* Diamond DTV2000 */
- { 3, 0, 2, 3, { 2, 3, 1, 1}, { 0, 1, 0, 1, 3}},
- /* AVerMedia TVPhone */
- { 3, 0, 2,15, { 2, 3, 1, 1}, {12, 0,11,11, 0}},
- /* Matrix Vision MV-Delta */
- { 5,-1, 3, 0, { 2, 3, 1, 0, 0}},
- /* Fly Video II */
- { 3, 0, 2, 0xc00, { 2, 3, 1, 1},
- {0, 0xc00, 0x800, 0x400, 0xc00, 0}},
-};
-#define TVCARDS (sizeof(tvcards)/sizeof(tvcard))
-
-static void audio(struct bttv *btv, int mode)
-{
- btaor(tvcards[btv->type].gpiomask, ~tvcards[btv->type].gpiomask,
- BT848_GPIO_OUT_EN);
-
- switch (mode)
- {
- case AUDIO_MUTE:
- btv->audio|=AUDIO_MUTE;
- break;
- case AUDIO_UNMUTE:
- btv->audio&=~AUDIO_MUTE;
- mode=btv->audio;
- break;
- case AUDIO_OFF:
- mode=AUDIO_OFF;
- break;
- case AUDIO_ON:
- mode=btv->audio;
- break;
- default:
- btv->audio&=AUDIO_MUTE;
- btv->audio|=mode;
- break;
- }
- /* if audio mute or not in H-lock, turn audio off */
- if ((btv->audio&AUDIO_MUTE)
-#if 0
- ||
- (!btv->radio && !(btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC))
-#endif
- )
- mode=AUDIO_OFF;
- if ((mode == 0) && (btv->radio))
- mode = 1;
- btaor(tvcards[btv->type].audiomux[mode],
- ~tvcards[btv->type].gpiomask, BT848_GPIO_DATA);
-}
-
-
-extern inline void bt848_dma(struct bttv *btv, uint state)
-{
- if (state)
- btor(3, BT848_GPIO_DMA_CTL);
- else
- btand(~3, BT848_GPIO_DMA_CTL);
-}
-
-
-static void bt848_cap(struct bttv *btv, uint state)
-{
- if (state)
- {
- btv->cap|=3;
- bt848_set_risc_jmps(btv);
- }
- else
- {
- btv->cap&=~3;
- bt848_set_risc_jmps(btv);
- }
-}
-
-
-/* If Bt848a or Bt849, use PLL for PAL/SECAM and crystal for NTSC*/
-
-static int set_pll(struct bttv *btv)
-{
- int i;
-
- if (!btv->pll)
- return 0;
- if ((btread(BT848_IFORM)&BT848_IFORM_XT0))
- {
- /* printk ("switching PLL off\n");*/
- btwrite(0x00,BT848_TGCTRL);
- btwrite(0x00,BT848_PLL_XCI);
- btv->pll&=~2;
- return 0;
- }
-
- /* do not set pll again if already active */
- if (btv->pll&2)
- return 1;
-
- /* printk ("setting PLL for PAL/SECAM\n");*/
-
- btwrite(0x00,BT848_TGCTRL);
- btwrite(0xf9,BT848_PLL_F_LO);
- btwrite(0xdc,BT848_PLL_F_HI);
- btwrite(0x8e,BT848_PLL_XCI);
-
- /* Ugh ugh ugh .. schedule ? */
- udelay(100000);
- for (i=0; i<100; i++)
- {
- if ((btread(BT848_DSTATUS)&BT848_DSTATUS_PLOCK))
- btwrite(0,BT848_DSTATUS);
- else
- {
- btwrite(0x08,BT848_TGCTRL);
- btv->pll|=2;
- return 1;
- }
-#if LINUX_VERSION_CODE >= 0x020199
- mdelay(10);
-#else
- udelay(10000);
-#endif
- }
- return -1;
-}
-
-static void bt848_muxsel(struct bttv *btv, unsigned int input)
-{
- btaor(tvcards[btv->type].gpiomask2,~tvcards[btv->type].gpiomask2,
- BT848_GPIO_OUT_EN);
-
- /* This seems to get rid of some synchronization problems */
- btand(~(3<<5), BT848_IFORM);
- udelay(10000);
-
-
- input %= tvcards[btv->type].inputs;
- if (input==tvcards[btv->type].svhs)
- {
- btor(BT848_CONTROL_COMP, BT848_E_CONTROL);
- btor(BT848_CONTROL_COMP, BT848_O_CONTROL);
- }
- else
- {
- btand(~BT848_CONTROL_COMP, BT848_E_CONTROL);
- btand(~BT848_CONTROL_COMP, BT848_O_CONTROL);
- }
- btaor((tvcards[btv->type].muxsel[input&7]&3)<<5, ~(3<<5), BT848_IFORM);
- audio(btv, (input!=tvcards[btv->type].tuner) ?
- AUDIO_EXTERN : AUDIO_TUNER);
- btaor(tvcards[btv->type].muxsel[input]>>4,
- ~tvcards[btv->type].gpiomask2, BT848_GPIO_DATA);
-}
-
-
-#define VBIBUF_SIZE 65536
-
-/* Maximum sample number per VBI line is 2044, can NTSC deliver this?
- Note that we write 2048-aligned to keep alignment to memory pages
-*/
-#define VBI_SPL 2044
-
-/* RISC command to write one VBI data line */
-#define VBI_RISC BT848_RISC_WRITE|VBI_SPL|BT848_RISC_EOL|BT848_RISC_SOL
-
-static void make_vbitab(struct bttv *btv)
-{
- int i;
- unsigned int *po=(unsigned int *) btv->vbi_odd;
- unsigned int *pe=(unsigned int *) btv->vbi_even;
-
- DEBUG(printk(KERN_DEBUG "vbiodd: 0x%08x\n",(int)btv->vbi_odd));
- DEBUG(printk(KERN_DEBUG "vbievn: 0x%08x\n",(int)btv->vbi_even));
- DEBUG(printk(KERN_DEBUG "po: 0x%08x\n",(int)po));
- DEBUG(printk(KERN_DEBUG "pe: 0x%08x\n",(int)pe));
-
- *(po++)=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1; *(po++)=0;
- for (i=0; i<16; i++)
- {
- *(po++)=VBI_RISC;
- *(po++)=kvirt_to_bus((unsigned long)btv->vbibuf+i*2048);
- }
- *(po++)=BT848_RISC_JUMP;
- *(po++)=virt_to_bus(btv->risc_jmp+4);
-
- *(pe++)=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1; *(pe++)=0;
- for (i=16; i<32; i++)
- {
- *(pe++)=VBI_RISC;
- *(pe++)=kvirt_to_bus((unsigned long)btv->vbibuf+i*2048);
- }
- *(pe++)=BT848_RISC_JUMP|BT848_RISC_IRQ|(0x01<<16);
- *(pe++)=virt_to_bus(btv->risc_jmp+10);
- DEBUG(printk(KERN_DEBUG "po: 0x%08x\n",(int)po));
- DEBUG(printk(KERN_DEBUG "pe: 0x%08x\n",(int)pe));
-}
-
-int fmtbppx2[16] = {
- 8, 6, 4, 4, 4, 3, 2, 2, 4, 3, 0, 0, 0, 0, 2, 0
-};
-int palette2fmt[] = {
- 0,
- BT848_COLOR_FMT_Y8,
- BT848_COLOR_FMT_RGB8,
- BT848_COLOR_FMT_RGB16,
- BT848_COLOR_FMT_RGB24,
- BT848_COLOR_FMT_RGB32,
- BT848_COLOR_FMT_RGB15,
-};
-
-static int make_rawrisctab(struct bttv *btv, unsigned int *ro,
- unsigned int *re, unsigned int *vbuf)
-{
- unsigned long line;
- unsigned long bpl=1024; /* bytes per line */
- unsigned long vadr=(unsigned long) vbuf;
-
- *(ro++)=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1; *(ro++)=0;
- *(re++)=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1; *(re++)=0;
-
- /* In PAL 650 blocks of 256 DWORDs are sampled, but only if VDELAY
- is 2 and without separate VBI grabbing.
- We'll have to handle this inside the IRQ handler ... */
-
- for (line=0; line < 640; line++)
- {
- *(ro++)=BT848_RISC_WRITE|bpl|BT848_RISC_SOL|BT848_RISC_EOL;
- *(ro++)=kvirt_to_bus(vadr);
- *(re++)=BT848_RISC_WRITE|bpl|BT848_RISC_SOL|BT848_RISC_EOL;
- *(re++)=kvirt_to_bus(vadr+BTTV_MAX_FBUF/2);
- vadr+=bpl;
- }
-
- *(ro++)=BT848_RISC_JUMP;
- *(ro++)=btv->bus_vbi_even;
- *(re++)=BT848_RISC_JUMP|BT848_RISC_IRQ|(2<<16);
- *(re++)=btv->bus_vbi_odd;
-
- return 0;
-}
-
-
-static int make_vrisctab(struct bttv *btv, unsigned int *ro,
- unsigned int *re,
- unsigned int *vbuf, unsigned short width,
- unsigned short height, unsigned short fmt)
-{
- unsigned long line;
- unsigned long bpl; /* bytes per line */
- unsigned long bl;
- unsigned long todo;
- unsigned int **rp;
- int inter;
- unsigned long vadr=(unsigned long) vbuf;
-
-
- if (btv->gfmt==BT848_COLOR_FMT_RAW)
- return make_rawrisctab(btv, ro, re, vbuf);
-
- inter = (height>btv->win.cropheight/2) ? 1 : 0;
- bpl=width*fmtbppx2[fmt&0xf]/2;
-
- *(ro++)=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1; *(ro++)=0;
- *(re++)=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1; *(re++)=0;
-
- for (line=0; line < (height<<(1^inter)); line++)
- {
- if (inter)
- rp= (line&1) ? &re : &ro;
- else
- rp= (line>height) ? &re : &ro;
-
- bl=PAGE_SIZE-((PAGE_SIZE-1)&vadr);
- if (bpl<=bl)
- {
- *((*rp)++)=BT848_RISC_WRITE|BT848_RISC_SOL|
- BT848_RISC_EOL|bpl;
- *((*rp)++)=kvirt_to_bus(vadr);
- vadr+=bpl;
- }
- else
- {
- todo=bpl;
- *((*rp)++)=BT848_RISC_WRITE|BT848_RISC_SOL|bl;
- *((*rp)++)=kvirt_to_bus(vadr);
- vadr+=bl;
- todo-=bl;
- while (todo>PAGE_SIZE)
- {
- *((*rp)++)=BT848_RISC_WRITE|PAGE_SIZE;
- *((*rp)++)=kvirt_to_bus(vadr);
- vadr+=PAGE_SIZE;
- todo-=PAGE_SIZE;
- }
- *((*rp)++)=BT848_RISC_WRITE|BT848_RISC_EOL|todo;
- *((*rp)++)=kvirt_to_bus(vadr);
- vadr+=todo;
- }
- }
-
- *(ro++)=BT848_RISC_JUMP;
- *(ro++)=btv->bus_vbi_even;
- *(re++)=BT848_RISC_JUMP|BT848_RISC_IRQ|(2<<16);
- *(re++)=btv->bus_vbi_odd;
-
- return 0;
-}
-
-/* does this really make a difference ???? */
-#define BURST_MAX 4096
-
-static inline void write_risc_segment(unsigned int **rp, unsigned long line_adr, unsigned int command,
- int *x, uint dx, uint bpp, uint width)
-{
- unsigned int flags, len;
-
- if (!dx)
- return;
- len=dx*bpp;
-
-#ifdef LIMIT_DMA
- if (command==BT848_RISC_WRITEC)
- {
- unsigned int dx2=BURST_MAX/bpp;
- while (len>BURST_MAX)
- {
- write_risc_segment(rp, line_adr, command,
- &x,dx2, bpp, width);
- dx-=dx2;
- len=dx*bpp;
- }
- }
-#endif
-
- /* mask upper 8 bits for 24+8 bit overlay modes */
- flags = ((bpp==4) ? BT848_RISC_BYTE3 : 0);
-
- if (*x==0)
- {
- if (command==BT848_RISC_SKIP)
- {
- if (dx<width)
- {
- flags|=BT848_RISC_BYTE_ALL;
- command=BT848_RISC_WRITE;
- }
- }
- else
- if (command==BT848_RISC_WRITEC)
- command=BT848_RISC_WRITE;
- flags|=BT848_RISC_SOL;
- }
- if (*x+dx==width)
- flags|=BT848_RISC_EOL;
- *((*rp)++)=command|flags|len;
- if (command==BT848_RISC_WRITE)
- *((*rp)++)=line_adr+*x*bpp;
- *x+=dx;
-}
-
-static void make_clip_tab(struct bttv *btv, struct cliprec *cr, int count)
-{
- int i,ncr;
- int yy, y, x, dx;
- struct cliprec first, *cur, *cur2, *nx, first2, *prev, *nx2;
- int bpp, bpl, width, height, inter;
- unsigned int **rp,*ro,*re;
- unsigned long adr;
- int cx,cx2,cy,cy2;
-
- inter=(btv->win.interlace&1)^1;
- bpp=btv->win.bpp;
- bpl=btv->win.bpl;
- ncr=btv->ncr;
- ro=btv->risc_odd;
- re=btv->risc_even;
- width=btv->win.width;
- height=btv->win.height;
- adr=btv->win.vidadr+btv->win.x*bpp+btv->win.y*bpl;
-
- /* clip clipping rects against viewing window AND screen
- so we do not have to rely on the user program
- */
- cx=(btv->win.x<0) ? (-btv->win.x) : 0;
- cy=(btv->win.y<0) ? (-btv->win.y) : 0;
- cx2=(btv->win.x+width>btv->win.swidth) ?
- (btv->win.swidth-btv->win.x) : width;
- cy2=(btv->win.y+height>btv->win.sheight) ?
- (btv->win.sheight-btv->win.y) : height;
- first.next=NULL;
- for (i=0; i<ncr; i++)
- {
- if (cr[i].y<cy)
- {
- if (cr[i].y2<cy)
- continue;
- cr[i].y=cy;
- }
- if (cr[i].y2>=cy2)
- {
- if (cr[i].y>=cy2)
- continue;
- cr[i].y2=cy2-1;
- }
- if (cr[i].x<cx)
- {
- if (cr[i].x2<cx)
- continue;
- cr[i].x=cx;
- }
- if (cr[i].x2>=cx2)
- {
- if (cr[i].x>=cx2)
- continue;
- cr[i].x2=cx2-1;
- }
- cur=&first;
- while ((nx=cur->next) && (cr[i].y > cur->next->y))
- cur=nx;
- cur->next=&(cr[i]);
- cr[i].next=nx;
- }
- first2.next=NULL;
-
- *(ro++)=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1; *(ro++)=0;
- *(re++)=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1; *(re++)=0;
-
- /* loop through all lines */
- for (yy=0; yy<(height<<inter); yy++)
- {
- y=yy>>inter;
- rp= (yy&1) ? &re : &ro;
-
- /* remove rects with y2 > y */
- if ((cur=first2.next))
- {
- prev=&first2;
- do
- {
- if (cur->y2 < y)
- prev->next=cur->next;
- else
- prev=cur;
- }
- while ((cur=cur->next));
- }
-
- /* add rect to second (x-sorted) list if rect.y == y */
- if ((cur=first.next))
- {
- while ((cur) && (cur->y == y))
- {
- first.next=cur->next;
- cur2=&first2;
- while ((nx2=cur2->next) && (cur->x > cur2->next->x))
- cur2=nx2;
- cur2->next=cur;
- cur->next=nx2;
- cur=first.next;
- }
- }
- x=0;
- if ((btv->win.y+y<=0)||(btv->win.y+y>=btv->win.sheight))
- write_risc_segment(rp, adr, BT848_RISC_SKIP, &x,
- width, bpp, width);
- else
- {
- dx=cx;
- for (cur2=first2.next; cur2; cur2=cur2->next)
- {
- if (x+dx < cur2->x)
- {
- write_risc_segment(rp, adr, BT848_RISC_SKIP,
- &x, dx, bpp, width);
- dx=cur2->x-x;
- write_risc_segment(rp, adr, BT848_RISC_WRITEC,
- &x, dx, bpp, width);
- dx=cur2->x2-x+1;
- }
- else if (x+dx < cur2->x2)
- dx=cur2->x2-x+1;
- }
- if (cx2<width)
- {
- write_risc_segment(rp, adr, BT848_RISC_SKIP,
- &x, dx, bpp, width);
- write_risc_segment(rp, adr, BT848_RISC_WRITEC,
- &x, cx2-x, bpp, width);
- dx=width-x;
- }
- write_risc_segment(rp, adr, BT848_RISC_SKIP,
- &x, dx, bpp, width);
- write_risc_segment(rp, adr, BT848_RISC_WRITEC,
- &x, width-x, bpp, width);
- }
- if ((!inter)||(yy&1))
- adr+=bpl;
- }
-
- *(ro++)=BT848_RISC_JUMP;
- *(ro++)=btv->bus_vbi_even;
- *(re++)=BT848_RISC_JUMP;
- *(re++)=btv->bus_vbi_odd;
-}
-
-/*
- * Set the registers for the size we have specified. Don't bother
- * trying to understand this without the BT848 manual in front of
- * you [AC].
- *
- * PS: The manual is free for download in .pdf format from
- * www.brooktree.com - nicely done those folks.
- */
-
-struct tvnorm
-{
- u16 swidth, sheight; /* scaled standard width, height */
- u16 totalwidth;
- u8 adelay, bdelay, iform;
- u32 scaledtwidth;
- u16 hdelayx1, hactivex1;
- u16 vdelay;
-};
-
-static struct tvnorm tvnorms[] = {
- /* PAL-BDGHI */
- //{ 1024, 576, 1135, 0x7f, 0x72, (BT848_IFORM_PAL_BDGHI|BT848_IFORM_XT1),
- // 1135, 100, 1024, 0x20},
-
- { 914, 576, 1135, 0x7f, 0x72, (BT848_IFORM_PAL_BDGHI|BT848_IFORM_XT1),
- 1135, 186+16, 914, 0x20},
-/*
- { 768, 576, 1135, 0x7f, 0x72, (BT848_IFORM_PAL_BDGHI|BT848_IFORM_XT1),
- 944, 186, 922, 0x20},
-*/
- /* NTSC */
- { 640, 480, 910, 0x68, 0x5d, (BT848_IFORM_NTSC|BT848_IFORM_XT0),
- 780, 135, 754, 0x16},
- /* SECAM */
- { 768, 576, 1135, 0x7f, 0xb0, (BT848_IFORM_SECAM|BT848_IFORM_XT1),
- 944, 186, 922, 0x20},
- /* PAL-M */
- { 640, 480, 910, 0x68, 0x5d, (BT848_IFORM_PAL_M|BT848_IFORM_XT0),
- 780, 135, 754, 0x16},
- /* PAL-N */
- { 768, 576, 1135, 0x7f, 0x72, (BT848_IFORM_PAL_N|BT848_IFORM_XT1),
- 944, 186, 922, 0x20},
- /* PAL-NC */
- { 768, 576, 1135, 0x7f, 0x72, (BT848_IFORM_PAL_NC|BT848_IFORM_XT0),
- 944, 186, 922, 0x20},
- /* NTSC-Japan */
- { 640, 480, 910, 0x68, 0x5d, (BT848_IFORM_NTSC_J|BT848_IFORM_XT0),
- 780, 135, 754, 0x16},
-};
-#define TVNORMS (sizeof(tvnorms)/sizeof(tvnorm))
-
-
-/* set geometry for even/odd frames
- just if you are wondering:
- handling of even and odd frames will be separated, e.g. for grabbing
- the even ones as RGB into videomem and the others as YUV in main memory for
- compressing and sending to the video conferencing partner.
-
-*/
-static inline void bt848_set_eogeo(struct bttv *btv, int odd, u8 vtc,
- u16 hscale, u16 vscale,
- u16 hactive, u16 vactive,
- u16 hdelay, u16 vdelay,
- u8 crop)
-{
- int off = odd ? 0x80 : 0x00;
-
- btwrite(vtc, BT848_E_VTC+off);
- btwrite(hscale>>8, BT848_E_HSCALE_HI+off);
- btwrite(hscale&0xff, BT848_E_HSCALE_LO+off);
- btaor((vscale>>8), 0xe0, BT848_E_VSCALE_HI+off);
- btwrite(vscale&0xff, BT848_E_VSCALE_LO+off);
- btwrite(hactive&0xff, BT848_E_HACTIVE_LO+off);
- btwrite(hdelay&0xff, BT848_E_HDELAY_LO+off);
- btwrite(vactive&0xff, BT848_E_VACTIVE_LO+off);
- btwrite(vdelay&0xff, BT848_E_VDELAY_LO+off);
- btwrite(crop, BT848_E_CROP+off);
-}
-
-
-static void bt848_set_geo(struct bttv *btv, u16 width, u16 height, u16 fmt)
-{
- u16 vscale, hscale;
- u32 xsf, sr;
- u16 hdelay, vdelay;
- u16 hactive, vactive;
- u16 inter;
- u8 crop, vtc;
- struct tvnorm *tvn;
-
- if (!width || !height)
- return;
-
- tvn=&tvnorms[btv->win.norm];
-
- btv->win.cropheight=tvn->sheight;
- btv->win.cropwidth=tvn->swidth;
-
-/*
- if (btv->win.cropwidth>tvn->cropwidth)
- btv->win.cropwidth=tvn->cropwidth;
- if (btv->win.cropheight>tvn->cropheight)
- btv->win.cropheight=tvn->cropheight;
-
- if (width>btv->win.cropwidth)
- width=btv->win.cropwidth;
- if (height>btv->win.cropheight)
- height=btv->win.cropheight;
-*/
- btwrite(tvn->adelay, BT848_ADELAY);
- btwrite(tvn->bdelay, BT848_BDELAY);
- btaor(tvn->iform,~(BT848_IFORM_NORM|BT848_IFORM_XTBOTH), BT848_IFORM);
-
- set_pll(btv);
-
- btwrite(fmt, BT848_COLOR_FMT);
- hactive=width;
-
- vtc=0;
- /* Some people say interpolation looks bad ... */
- /* vtc = (hactive < 193) ? 2 : ((hactive < 385) ? 1 : 0); */
-
- btv->win.interlace = (height>btv->win.cropheight/2) ? 1 : 0;
- inter=(btv->win.interlace&1)^1;
- xsf = (hactive*tvn->scaledtwidth)/btv->win.cropwidth;
- hscale = ((tvn->totalwidth*4096UL)/xsf-4096);
- vdelay=btv->win.cropy+tvn->vdelay;
-
- hdelay=(tvn->hdelayx1*tvn->scaledtwidth)/tvn->totalwidth;
- hdelay=((hdelay+btv->win.cropx)*hactive)/btv->win.cropwidth;
- hdelay&=0x3fe;
-
- sr=((btv->win.cropheight>>inter)*512)/height-512;
- vscale=(0x10000UL-sr)&0x1fff;
- vactive=btv->win.cropheight;
- crop=((hactive>>8)&0x03)|((hdelay>>6)&0x0c)|
- ((vactive>>4)&0x30)|((vdelay>>2)&0xc0);
- vscale|= btv->win.interlace ? (BT848_VSCALE_INT<<8) : 0;
-
- bt848_set_eogeo(btv, 0, vtc, hscale, vscale, hactive, vactive,
- hdelay, vdelay, crop);
- bt848_set_eogeo(btv, 1, vtc, hscale, vscale, hactive, vactive,
- hdelay, vdelay, crop);
-
-}
-
-
-int bpp2fmt[4] = {
- BT848_COLOR_FMT_RGB8, BT848_COLOR_FMT_RGB16,
- BT848_COLOR_FMT_RGB24, BT848_COLOR_FMT_RGB32
-};
-
-static void bt848_set_winsize(struct bttv *btv)
-{
- unsigned short format;
-
- btv->win.color_fmt = format =
- (btv->win.depth==15) ? BT848_COLOR_FMT_RGB15 :
- bpp2fmt[(btv->win.bpp-1)&3];
-
- /* RGB8 seems to be a 9x5x5 GRB color cube starting at
- * color 16. Why the h... can't they even mention this in the
- * datasheet??? [AC - because its a standard format so I guess
- * it never occured them]
- * Enable dithering in this mode
- */
- if (format==BT848_COLOR_FMT_RGB8)
- btand(~BT848_CAP_CTL_DITH_FRAME, BT848_CAP_CTL);
- else
- btor(BT848_CAP_CTL_DITH_FRAME, BT848_CAP_CTL);
-
- bt848_set_geo(btv, btv->win.width, btv->win.height, format);
-}
-
-/*
- * Set TSA5522 synthesizer frequency in 1/16 Mhz steps
- */
-
-static void set_freq(struct bttv *btv, unsigned short freq)
-{
- int fixme = freq; /* XXX */
- int oldAudio = btv->audio;
-
- audio(btv, AUDIO_MUTE);
- udelay(AUDIO_MUTE_DELAY);
-
- if (btv->radio)
- {
- if (btv->tuner)
- btv->tuner->driver->command(btv->tuner,TUNER_SET_RADIOFREQ,&fixme);
-
-#if 0
- if (btv->have_msp3400) {
- i2c_control_device(&(btv->i2c),I2C_DRIVERID_MSP3400,
- MSP_SET_RADIO,0);
- i2c_control_device(&(btv->i2c),I2C_DRIVERID_MSP3400,
- MSP_NEWCHANNEL,0);
- }
-#endif
- }
- else
- {
- if (btv->tuner)
- btv->tuner->driver->command(btv->tuner,TUNER_SET_TVFREQ,&fixme);
-#if 0
- if (btv->have_msp3400) {
- i2c_control_device(&(btv->i2c),I2C_DRIVERID_MSP3400,
- MSP_SET_TVNORM,&(btv->win.norm));
- i2c_control_device(&(btv->i2c),I2C_DRIVERID_MSP3400,
- MSP_NEWCHANNEL,0);
- }
-#endif
- }
-
- if (!(oldAudio & AUDIO_MUTE)) {
- udelay(FREQ_CHANGE_DELAY);
- audio(btv, AUDIO_UNMUTE);
- }
-}
-
-
-/*
- * Grab into virtual memory.
- * Currently only does double buffering. Do we need more?
- */
-
-static int vgrab(struct bttv *btv, struct video_mmap *mp)
-{
- unsigned int *ro, *re;
- unsigned int *vbuf;
-
- if(btv->fbuffer==NULL)
- {
- if(fbuffer_alloc(btv))
- return -ENOBUFS;
- }
- if (btv->grabbing >= MAX_GBUFFERS)
- return -ENOBUFS;
-
- /*
- * No grabbing past the end of the buffer!
- */
-
- if(mp->frame>1 || mp->frame <0)
- return -EINVAL;
-
- if(mp->height <0 || mp->width <0)
- return -EINVAL;
-
- if(mp->height>576 || mp->width>768)
- return -EINVAL;
-
- /*
- * FIXME: Check the format of the grab here. This is probably
- * also less restrictive than the normal overlay grabs. Stuff
- * like QCIF has meaning as a capture.
- */
-
- /*
- * Ok load up the BT848
- */
-
- vbuf=(unsigned int *)(btv->fbuffer+BTTV_MAX_FBUF*mp->frame);
- if (!(btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC))
- return -EAGAIN;
- ro=btv->grisc+(((btv->grabcount++)&1) ? 4096 :0);
- re=ro+2048;
- btv->gwidth=mp->width;
- btv->gheight=mp->height;
- btv->gfmt=mp->format;
- make_vrisctab(btv, ro, re, vbuf, btv->gwidth, btv->gheight, btv->gfmt);
- /* bt848_set_risc_jmps(btv); */
- btor(3, BT848_CAP_CTL);
- btor(3, BT848_GPIO_DMA_CTL);
- btv->frame_stat[mp->frame] = GBUFFER_GRABBING;
- if (btv->grabbing) {
- btv->gro_next=virt_to_bus(ro);
- btv->gre_next=virt_to_bus(re);
- btv->grf_next=mp->frame;
- } else {
- btv->gro=virt_to_bus(ro);
- btv->gre=virt_to_bus(re);
- btv->grf=mp->frame;
- }
- if (!(btv->grabbing++))
- btv->risc_jmp[12]=BT848_RISC_JUMP|(0x8<<16)|BT848_RISC_IRQ;
- /* interruptible_sleep_on(&btv->capq); */
- return 0;
-}
-
-static long bttv_write(struct video_device *v, const char *buf, unsigned long count, int nonblock)
-{
- return -EINVAL;
-}
-
-static long bttv_read(struct video_device *v, char *buf, unsigned long count, int nonblock)
-{
- struct bttv *btv= (struct bttv *)v;
- int q,todo;
-
- todo=count;
- while (todo && todo>(q=VBIBUF_SIZE-btv->vbip))
- {
- if(copy_to_user((void *) buf, (void *) btv->vbibuf+btv->vbip, q))
- return -EFAULT;
- todo-=q;
- buf+=q;
-
- cli();
- if (todo && q==VBIBUF_SIZE-btv->vbip)
- {
- if(nonblock)
- {
- sti();
- if(count==todo)
- return -EWOULDBLOCK;
- return count-todo;
- }
- interruptible_sleep_on(&btv->vbiq);
- sti();
- if(signal_pending(current))
- {
- if(todo==count)
- return -EINTR;
- else
- return count-todo;
- }
- }
- }
- if (todo)
- {
- if(copy_to_user((void *) buf, (void *) btv->vbibuf+btv->vbip, todo))
- return -EFAULT;
- btv->vbip+=todo;
- }
- return count;
-}
-
-/*
- * Open a bttv card. Right now the flags stuff is just playing
- */
-
-static int bttv_open(struct video_device *dev, int flags)
-{
- struct bttv *btv = (struct bttv *)dev;
- int users, i;
-
- switch (flags)
- {
- case 0:
- if (btv->user)
- return -EBUSY;
- btv->user++;
- audio(btv, AUDIO_UNMUTE);
- for (i=users=0; i<bttv_num; i++)
- users+=bttvs[i].user;
- if (users==1)
- find_vga();
- btv->fbuffer=NULL;
- if (!btv->fbuffer)
- btv->fbuffer=(unsigned char *) rvmalloc(2*BTTV_MAX_FBUF);
- if (!btv->fbuffer)
- {
- btv->user--;
- return -EINVAL;
- }
- btv->grabbing = 0;
- btv->grab = 0;
- btv->lastgrab = 0;
- break;
- case 1:
- break;
- }
- MOD_INC_USE_COUNT;
- return 0;
-}
-
-static void bttv_close(struct video_device *dev)
-{
- struct bttv *btv=(struct bttv *)dev;
-
- btv->user--;
- audio(btv, AUDIO_MUTE);
- btv->cap&=~3;
- bt848_set_risc_jmps(btv);
-
- if(btv->fbuffer)
- rvfree((void *) btv->fbuffer, 2*BTTV_MAX_FBUF);
- btv->fbuffer=0;
- MOD_DEC_USE_COUNT;
-}
-
-
-/***********************************/
-/* ioctls and supporting functions */
-/***********************************/
-
-extern inline void bt848_bright(struct bttv *btv, uint bright)
-{
- btwrite(bright&0xff, BT848_BRIGHT);
-}
-
-extern inline void bt848_hue(struct bttv *btv, uint hue)
-{
- btwrite(hue&0xff, BT848_HUE);
-}
-
-extern inline void bt848_contrast(struct bttv *btv, uint cont)
-{
- unsigned int conthi;
-
- conthi=(cont>>6)&4;
- btwrite(cont&0xff, BT848_CONTRAST_LO);
- btaor(conthi, ~4, BT848_E_CONTROL);
- btaor(conthi, ~4, BT848_O_CONTROL);
-}
-
-extern inline void bt848_sat_u(struct bttv *btv, unsigned long data)
-{
- u32 datahi;
-
- datahi=(data>>7)&2;
- btwrite(data&0xff, BT848_SAT_U_LO);
- btaor(datahi, ~2, BT848_E_CONTROL);
- btaor(datahi, ~2, BT848_O_CONTROL);
-}
-
-static inline void bt848_sat_v(struct bttv *btv, unsigned long data)
-{
- u32 datahi;
-
- datahi=(data>>8)&1;
- btwrite(data&0xff, BT848_SAT_V_LO);
- btaor(datahi, ~1, BT848_E_CONTROL);
- btaor(datahi, ~1, BT848_O_CONTROL);
-}
-
-
-/*
- * Cliprect -> risc table.
- *
- * FIXME: This is generating wrong code when we have some kinds of
- * rectangle lists. If you generate overlapped rectangles then it
- * gets a bit confused. Since we add the frame buffer clip rectangles
- * we need to fix this. Better yet to rewrite this function.
- */
-
-static void write_risc_data(struct bttv *btv, struct video_clip *vp, int count)
-{
- int i;
- u32 yy, y, x, dx, ox;
- u32 *rmem, *rmem2;
- struct video_clip first, *cur, *cur2, *nx, first2, *prev, *nx2;
- u32 *rp, rpo=0, rpe=0, p, bpsl;
- u32 *rpp;
- u32 mask;
- int interlace;
- int depth;
-
- rmem=(u32 *)btv->risc_odd;
- rmem2=(u32 *)btv->risc_even;
- depth=btv->win.bpp;
-
- /* create y-sorted list */
-
- first.next=NULL;
- for (i=0; i<count; i++)
- {
- cur=&first;
- while ((nx=cur->next) && (vp[i].y > cur->next->y))
- cur=nx;
- cur->next=&(vp[i]);
- vp[i].next=nx;
- }
- first2.next=NULL;
-
- rmem[rpo++]=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1|(0xf<<20);
- rmem[rpo++]=0;
-
- rmem2[rpe++]=BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1;
- rmem2[rpe++]=0;
-
-
- /*
- * 32bit depth frame buffers need extra flags setting
- */
-
- if (depth==4)
- mask=BT848_RISC_BYTE3;
- else
- mask=0;
-
- bpsl=btv->win.width*btv->win.bpp;
- p=btv->win.vidadr+btv->win.x*btv->win.bpp+
- btv->win.y*btv->win.bpl;
-
- interlace=btv->win.interlace;
-
- /*
- * Loop through all lines
- */
-
- for (yy=0; yy<(btv->win.height<<(1^interlace)); yy++)
- {
- y=yy>>(1^interlace);
-
- /*
- * Even or odd frame generation. We have to
- * write the RISC instructions to the right stream.
- */
-
- if(!(y&1))
- {
- rp=&rpo;
- rpp=rmem;
- }
- else
- {
- rp=&rpe;
- rpp=rmem2;
- }
-
-
- /*
- * first2 is the header of a list of "active" rectangles. We add
- * rectangles as we hit their top and remove them as they fall off
- * the bottom
- */
-
- /* remove rects with y2 > y */
- if ((cur=first2.next))
- {
- prev=&first2;
- do
- {
- if (cur->y+cur->height < y)
- prev->next=cur->next;
- else
- prev=cur;
- }
- while ((cur=cur->next));
- }
-
- /*
- * Fixme - we have to handle overlapped rectangles
- * here, but the overlap might be partial
- */
-
- /* add rect to second (x-sorted) list if rect.y == y */
- if ((cur=first.next))
- {
- while ((cur) && (cur->y == y))
- {
- first.next=cur->next;
- cur2=&first2;
- while ((nx2=cur2->next) && (cur->x > cur2->next->x))
- cur2=nx2;
- cur2->next=cur;
- cur->next=nx2;
- cur=first.next;
- }
- }
-
-
- /*
- * Begin writing the RISC script
- */
-
- dx=x=0;
-
- /*
- * Starting at x position 0 on a new scan line
- * write to location p, don't yet write the number
- * of pixels for the instruction
- */
-
- rpp[(*rp)++]=BT848_RISC_WRITE|BT848_RISC_SOL;
- rpp[(*rp)++]=p;
-
- /*
- * For each rectangle we have in the "active" list - sorted left to
- * right..
- */
-
- for (cur2=first2.next; cur2; cur2=cur2->next)
- {
- /*
- * If we are to the left of the first drawing area
- */
-
- if (x+dx < cur2->x)
- {
- /* Bytes pending ? */
- if (dx)
- {
- /* For a delta away from the start we need to write a SKIP */
- if (x)
- rpp[(*rp)++]=BT848_RISC_SKIP|(dx*depth);
- else
- /* Rewrite the start of line WRITE to a SKIP */
- rpp[(*rp)-2]|=BT848_RISC_BYTE_ALL|(dx*depth);
- /* Move X to the next point (drawing start) */
- x=x+dx;
- }
- /* Ok how far are we from the start of the next rectangle ? */
- dx=cur2->x-x;
- /* dx is now the size of data to write */
-
- /* If this isnt the left edge generate a "write continue" */
- if (x)
- rpp[(*rp)++]=BT848_RISC_WRITEC|(dx*depth)|mask;
- else
- /* Fill in the byte count on the initial WRITE */
- rpp[(*rp)-2]|=(dx*depth)|mask;
- /* Move to the start of the rectangle */
- x=cur2->x;
- /* x is our left dx is byte size of hole */
- dx=cur2->width+1;
- }
- else
- /* Already in a clip zone.. set dx */
- if (x+dx < cur2->x+cur2->width)
- dx=cur2->x+cur2->width-x+1;
- }
- /* now treat the rest of the line */
- ox=x;
- if (dx)
- {
- /* Complete the SKIP to eat to the end of the gap */
- if (x)
- rpp[(*rp)++]=BT848_RISC_SKIP|(dx*depth);
- else
- /* Rewrite to SKIP start to this point */
- rpp[(*rp)-2]|=BT848_RISC_BYTE_ALL|(dx*depth);
- x=x+dx;
- }
-
- /*
- * Not at the right hand edge ?
- */
-
- if ((dx=btv->win.width-x)!=0)
- {
- /* Write to edge of display */
- if (x)
- rpp[(*rp)++]=BT848_RISC_WRITEC|(dx*depth)|BT848_RISC_EOL|mask;
- else
- /* Entire frame is a write - patch first order */
- rpp[(*rp)-2]|=(dx*depth)|BT848_RISC_EOL|mask;
- }
- else
- {
- /* End of line if needed */
- if (ox)
- rpp[(*rp)-1]|=BT848_RISC_EOL|mask;
- else
- {
- /* Skip the line : write a SKIP + start/end of line marks */
- (*rp)--;
- rpp[(*rp)-1]=BT848_RISC_SKIP|
- (btv->win.width*depth)|
- BT848_RISC_EOL|BT848_RISC_SOL;
- }
- }
- /*
- * Move the video render pointer on a line
- */
- if (interlace||(y&1))
- p+=btv->win.bpl;
- }
-
- /*
- * Attach the interframe jumps
- */
-
- rmem[rpo++]=BT848_RISC_JUMP;
- rmem[rpo++]=btv->bus_vbi_even;
-
- rmem2[rpe++]=BT848_RISC_JUMP;
- rmem2[rpe++]=btv->bus_vbi_odd;
-}
-
-/*
- * Helper for adding clips.
- */
-
-static void new_risc_clip(struct video_window *vw, struct video_clip *vcp, int x, int y, int w, int h)
-{
- vcp[vw->clipcount].x=x;
- vcp[vw->clipcount].y=y;
- vcp[vw->clipcount].width=w;
- vcp[vw->clipcount].height=h;
- vw->clipcount++;
-}
-
-
-/*
- * ioctl routine
- */
-
-
-static int bttv_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
-{
- struct bttv *btv=(struct bttv *)dev;
- static int lastchan=0,i;
-
- switch (cmd)
- {
- case VIDIOCGCAP:
- {
- struct video_capability b;
- strcpy(b.name,btv->video_dev.name);
- b.type = VID_TYPE_CAPTURE|
- VID_TYPE_TUNER|
- VID_TYPE_TELETEXT|
- VID_TYPE_OVERLAY|
- VID_TYPE_CLIPPING|
- VID_TYPE_FRAMERAM|
- VID_TYPE_SCALES;
- b.channels = 4; /* tv , input, svhs */
- b.audios = 4; /* tv, input, svhs */
- b.maxwidth = 768;
- b.maxheight = 576;
- b.minwidth = 32;
- b.minheight = 32;
- if(copy_to_user(arg,&b,sizeof(b)))
- return -EFAULT;
- return 0;
- }
- case VIDIOCGCHAN:
- {
- struct video_channel v;
- if(copy_from_user(&v, arg,sizeof(v)))
- return -EFAULT;
- v.flags=VIDEO_VC_AUDIO;
- v.tuners=0;
- v.type=VIDEO_TYPE_CAMERA;
-#if 0
- v.mode = btv->win.norm;
-#endif
- switch(v.channel)
- {
- case 0:
- strcpy(v.name,"Television");
- v.flags|=VIDEO_VC_TUNER;
- v.type=VIDEO_TYPE_TV;
- v.tuners=1;
- break;
- case 1:
- strcpy(v.name,"Composite1");
- break;
- case 2:
- strcpy(v.name,"Composite2");
- break;
- case 3:
- strcpy(v.name,"SVHS");
- break;
- default:
- return -EINVAL;
- }
- if(copy_to_user(arg,&v,sizeof(v)))
- return -EFAULT;
- return 0;
- }
- /*
- * Each channel has 1 tuner
- */
- case VIDIOCSCHAN:
- {
- int v;
- if(copy_from_user(&v, arg, sizeof(v)))
- return -EFAULT;
- bt848_muxsel(btv, v);
- lastchan=v;
- return 0;
- }
- case VIDIOCGTUNER:
- {
- struct video_tuner v;
- if(copy_from_user(&v,arg,sizeof(v))!=0)
- return -EFAULT;
- if(v.tuner||lastchan) /* Only tuner 0 */
- return -EINVAL;
- strcpy(v.name, "Television");
- v.rangelow=0;
- v.rangehigh=0xFFFFFFFF;
- v.flags=VIDEO_TUNER_PAL|VIDEO_TUNER_NTSC;
- v.mode = btv->win.norm;
- if(copy_to_user(arg,&v,sizeof(v)))
- return -EFAULT;
- return 0;
- }
- /* We have but tuner 0 */
- case VIDIOCSTUNER:
- {
- /* FIXME: norm should be in video_channel struct
- composite source can have different norms too
- */
-
- struct video_tuner v;
- if(copy_from_user(&v, arg, sizeof(v)))
- return -EFAULT;
- /* Only 1 channel has a tuner */
- /*if(v.tuner!=tvcards[btv->type].tuner || lastchan)
- return -EINVAL;*/
- if(v.mode!=VIDEO_MODE_PAL&&v.mode!=VIDEO_MODE_NTSC
- &&v.mode!=VIDEO_MODE_SECAM)
- return -EOPNOTSUPP;
- btv->win.norm = v.mode;
- bt848_set_winsize(btv);
- return 0;
- }
- case VIDIOCGPICT:
- {
- struct video_picture p=btv->picture;
- if(btv->win.depth==8)
- p.palette=VIDEO_PALETTE_HI240;
- if(btv->win.depth==15)
- p.palette=VIDEO_PALETTE_RGB555;
- if(btv->win.depth==16)
- p.palette=VIDEO_PALETTE_RGB565;
- if(btv->win.depth==24)
- p.palette=VIDEO_PALETTE_RGB24;
- if(btv->win.depth==32)
- p.palette=VIDEO_PALETTE_RGB32;
-
- if(copy_to_user(arg, &p, sizeof(p)))
- return -EFAULT;
- return 0;
- }
- case VIDIOCSPICT:
- {
- struct video_picture p;
- int format;
- if(copy_from_user(&p, arg,sizeof(p)))
- return -EFAULT;
- /* We want -128 to 127 we get 0-65535 */
- bt848_bright(btv, (p.brightness>>8)-128);
- /* 0-511 for the colour */
- bt848_sat_u(btv, p.colour>>7);
- bt848_sat_v(btv, ((p.colour>>7)*201L)/237);
- /* -128 to 127 */
- bt848_hue(btv, (p.hue>>8)-128);
- /* 0-511 */
- bt848_contrast(btv, p.contrast>>7);
- btv->picture = p;
-
- /* set palette if bpp matches */
- if (p.palette < sizeof(palette2fmt)/sizeof(int)) {
- format = palette2fmt[p.palette];
- if (fmtbppx2[format&0x0f]/2 == btv->win.bpp)
- btv->win.color_fmt = format;
- }
- return 0;
- }
- case VIDIOCSWIN:
- {
- struct video_window vw;
- struct video_clip *vcp;
- int on;
-
- if(copy_from_user(&vw,arg,sizeof(vw)))
- return -EFAULT;
-
- if(vw.flags)
- return -EINVAL;
-
- btv->win.x=vw.x;
- btv->win.y=vw.y;
- btv->win.width=vw.width;
- btv->win.height=vw.height;
-
- if(btv->win.height>btv->win.cropheight/2)
- btv->win.interlace=1;
- else
- btv->win.interlace=0;
-
- on=(btv->cap&3)?1:0;
-
- bt848_cap(btv,0);
- bt848_set_winsize(btv);
-
- if(vw.clipcount>256)
- return -EDOM; /* Too many! */
-
- /*
- * Do any clips.
- */
-
- vcp=vmalloc(sizeof(struct video_clip)*(vw.clipcount+4));
- if(vcp==NULL)
- return -ENOMEM;
- if(vw.clipcount && copy_from_user(vcp,vw.clips,sizeof(struct video_clip)*vw.clipcount))
- return -EFAULT;
- /*
- * Impose display clips
- */
- if(btv->win.x<0)
- new_risc_clip(&vw, vcp, 0, 0, -btv->win.x, btv->win.height-1);
- if(btv->win.y<0)
- new_risc_clip(&vw, vcp, 0, 0, btv->win.width-1,-btv->win.y);
- if(btv->win.x+btv->win.width> btv->win.swidth)
- new_risc_clip(&vw, vcp, btv->win.swidth-btv->win.x, 0, btv->win.width-1, btv->win.height-1);
- if(btv->win.y+btv->win.height > btv->win.sheight)
- new_risc_clip(&vw, vcp, 0, btv->win.sheight-btv->win.y, btv->win.width-1, btv->win.height-1);
- /*
- * Question: Do we need to walk the clip list
- * and saw off any clips outside the window
- * frame or will write_risc_tab do the right
- * thing ?
- */
- write_risc_data(btv,vcp, vw.clipcount);
- vfree(vcp);
- if(on && btv->win.vidadr!=0)
- bt848_cap(btv,1);
- return 0;
- }
- case VIDIOCGWIN:
- {
- struct video_window vw;
- /* Oh for a COBOL move corresponding .. */
- vw.x=btv->win.x;
- vw.y=btv->win.y;
- vw.width=btv->win.width;
- vw.height=btv->win.height;
- vw.chromakey=0;
- vw.flags=0;
- if(btv->win.interlace)
- vw.flags|=VIDEO_WINDOW_INTERLACE;
- if(copy_to_user(arg,&vw,sizeof(vw)))
- return -EFAULT;
- return 0;
- }
- case VIDIOCCAPTURE:
- {
- int v;
- if(copy_from_user(&v, arg,sizeof(v)))
- return -EFAULT;
- if(v==0)
- {
- bt848_cap(btv,0);
- }
- else
- {
- if(btv->win.vidadr==0 || btv->win.width==0
- || btv->win.height==0)
- return -EINVAL;
- bt848_cap(btv,1);
- }
- return 0;
- }
- case VIDIOCGFBUF:
- {
- struct video_buffer v;
- v.base=(void *)btv->win.vidadr;
- v.height=btv->win.sheight;
- v.width=btv->win.swidth;
- v.depth=btv->win.depth;
- v.bytesperline=btv->win.bpl;
- if(copy_to_user(arg, &v,sizeof(v)))
- return -EFAULT;
- return 0;
-
- }
- case VIDIOCSFBUF:
- {
- struct video_buffer v;
-#if LINUX_VERSION_CODE >= 0x020100
- if(!capable(CAP_SYS_ADMIN))
-#else
- if(!suser())
-#endif
- return -EPERM;
- if(copy_from_user(&v, arg,sizeof(v)))
- return -EFAULT;
- if(v.depth!=8 && v.depth!=16 && v.depth!=15
- && v.depth!=24 && v.depth!=32)
- return -EINVAL;
- if (v.base)
- {
- /* also handle virtual base addresses */
- if ((unsigned int)v.base>=0xe0000000UL)
- btv->win.vidadr=(uint)v.base;
- else
- btv->win.vidadr=
-#if LINUX_VERSION_CODE >= 0x020199
- __va(uvirt_to_bus((uint)v.base));
-#else
- PAGE_OFFSET|uvirt_to_bus((uint)v.base);
-#endif
- }
- btv->win.sheight=v.height;
- btv->win.swidth=v.width;
- btv->win.bpp=((v.depth+7)&0x38)/8;
- btv->win.depth=v.depth;
- btv->win.bpl=v.bytesperline;
-
- DEBUG(printk("Display at %p is %d by %d, bytedepth %d, bpl %d\n",
- v.base, v.width,v.height, btv->win.bpp, btv->win.bpl));
- bt848_set_winsize(btv);
- return 0;
- }
- case VIDIOCKEY:
- {
- /* Will be handled higher up .. */
- return 0;
- }
- case VIDIOCGFREQ:
- {
- unsigned long v=btv->win.freq;
- if(copy_to_user(arg,&v,sizeof(v)))
- return -EFAULT;
- return 0;
- }
- case VIDIOCSFREQ:
- {
- unsigned long v;
- if(copy_from_user(&v, arg, sizeof(v)))
- return -EFAULT;
- btv->win.freq=v;
- set_freq(btv, btv->win.freq);
- return 0;
- }
-
- case VIDIOCGAUDIO:
- {
- struct video_audio v;
- v=btv->audio_dev;
- v.flags&=~(VIDEO_AUDIO_MUTE|VIDEO_AUDIO_MUTABLE);
- v.flags|=VIDEO_AUDIO_MUTABLE;
- strcpy(v.name,"TV");
-#if 0
- if (btv->have_msp3400)
- {
- v.flags|=VIDEO_AUDIO_VOLUME |
- VIDEO_AUDIO_BASS |
- VIDEO_AUDIO_TREBLE;
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_MSP3400,
- MSP_GET_VOLUME,&(v.volume));
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_MSP3400,
- MSP_GET_BASS,&(v.bass));
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_MSP3400,
- MSP_GET_TREBLE,&(v.treble));
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_MSP3400,
- MSP_GET_STEREO,&(v.mode));
- }
- else
-#endif
- v.mode = VIDEO_SOUND_MONO;
- if(copy_to_user(arg,&v,sizeof(v)))
- return -EFAULT;
- return 0;
- }
- case VIDIOCSAUDIO:
- {
- struct video_audio v;
- if(copy_from_user(&v,arg, sizeof(v)))
- return -EFAULT;
- if(v.flags&VIDEO_AUDIO_MUTE)
- audio(btv, AUDIO_MUTE);
- /* One audio source per tuner */
- if(v.audio!=0)
- return -EINVAL;
- bt848_muxsel(btv,v.audio);
- if(!(v.flags&VIDEO_AUDIO_MUTE))
- audio(btv, AUDIO_UNMUTE);
-#if 0
- if (btv->have_msp3400)
- {
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_MSP3400,
- MSP_SET_VOLUME,&(v.volume));
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_MSP3400,
- MSP_SET_BASS,&(v.bass));
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_MSP3400,
- MSP_SET_TREBLE,&(v.treble));
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_MSP3400,
- MSP_SET_STEREO,&(v.mode));
- }
-#endif
- btv->audio_dev=v;
- return 0;
- }
- case VIDIOCSYNC_OLD:
-#if 0
- if (!btv->grabbing)
- return -EAGAIN;
-#endif
- if (btv->grab==btv->lastgrab)
- interruptible_sleep_on(&btv->capq);
- btv->lastgrab++;
- return 0;
- case VIDIOCSYNC:
- if(copy_from_user((void *)&i,arg,sizeof(int)))
- return -EFAULT;
- switch (btv->frame_stat[i]) {
- case GBUFFER_UNUSED:
- return -EINVAL;
- case GBUFFER_GRABBING:
- interruptible_sleep_on(&btv->capq);
- /* fall */
- case GBUFFER_DONE:
- btv->frame_stat[i] = GBUFFER_UNUSED;
- break;
- }
- return 0;
-
- case BTTV_FIELDNR:
- if(copy_to_user((void *) arg, (void *) &btv->last_field,
- sizeof(btv->last_field)))
- return -EFAULT;
- break;
-
- case VIDIOCMCAPTURE:
- {
- struct video_mmap vm;
- if(copy_from_user((void *) &vm, (void *) arg, sizeof(vm)))
- return -EFAULT;
- if (btv->frame_stat[vm.frame] == GBUFFER_GRABBING)
- return -EBUSY;
- return vgrab(btv, &vm);
- }
- default:
- return -ENOIOCTLCMD;
- }
- return 0;
-}
-
-static int bttv_init_done(struct video_device *dev)
-{
- return 0;
-}
-
-/*
- * This maps the vmalloced and reserved fbuffer to user space.
- *
- * FIXME:
- * - PAGE_READONLY should suffice!?
- * - remap_page_range is kind of inefficient for page by page remapping.
- * But e.g. pte_alloc() does not work in modules ... :-(
- */
-
-static int bttv_mmap(struct video_device *dev, const char *adr, unsigned long size)
-{
- struct bttv *btv=(struct bttv *)dev;
- unsigned long start=(unsigned long) adr;
- unsigned long page,pos;
-
- if (size>2*BTTV_MAX_FBUF)
- return -EINVAL;
- if (!btv->fbuffer)
- {
- if(fbuffer_alloc(btv))
- return -EINVAL;
- }
- pos=(unsigned long) btv->fbuffer;
- while (size > 0)
- {
- page = kvirt_to_phys(pos);
- if (remap_page_range(start, page, PAGE_SIZE, PAGE_SHARED))
- return -EAGAIN;
- start+=PAGE_SIZE;
- pos+=PAGE_SIZE;
- size-=PAGE_SIZE;
- }
- return 0;
-}
-
-static struct video_device bttv_template=
-{
- "UNSET",
- VID_TYPE_TUNER|VID_TYPE_CAPTURE|VID_TYPE_OVERLAY|VID_TYPE_TELETEXT,
- VID_HARDWARE_BT848,
- bttv_open,
- bttv_close,
- bttv_read,
- bttv_write,
- bttv_ioctl,
- bttv_mmap,
- bttv_init_done,
- NULL,
- 0,
- 0
-};
-
-
-static long vbi_read(struct video_device *v, char *buf, unsigned long count,
- int nonblock)
-{
- struct bttv *btv=(struct bttv *)(v-2);
- int q,todo;
-
- todo=count;
- while (todo && todo>(q=VBIBUF_SIZE-btv->vbip))
- {
- if(copy_to_user((void *) buf, (void *) btv->vbibuf+btv->vbip, q))
- return -EFAULT;
- todo-=q;
- buf+=q;
-
- cli();
- if (todo && q==VBIBUF_SIZE-btv->vbip)
- {
- if(nonblock)
- {
- sti();
- if(count==todo)
- return -EWOULDBLOCK;
- return count-todo;
- }
- interruptible_sleep_on(&btv->vbiq);
- sti();
- if(signal_pending(current))
- {
- if(todo==count)
- return -EINTR;
- else
- return count-todo;
- }
- }
- }
- if (todo)
- {
- if(copy_to_user((void *) buf, (void *) btv->vbibuf+btv->vbip, todo))
- return -EFAULT;
- btv->vbip+=todo;
- }
- return count;
-}
-
-static int vbi_open(struct video_device *dev, int flags)
-{
- struct bttv *btv=(struct bttv *)(dev-2);
-
- btv->vbip=VBIBUF_SIZE;
- btv->cap|=0x0c;
- bt848_set_risc_jmps(btv);
-
- MOD_INC_USE_COUNT;
- return 0;
-}
-
-static void vbi_close(struct video_device *dev)
-{
- struct bttv *btv=(struct bttv *)(dev-2);
-
- btv->cap&=~0x0c;
- bt848_set_risc_jmps(btv);
-
- MOD_DEC_USE_COUNT;
-}
-
-
-static int vbi_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
-{
- return -EINVAL;
-}
-
-static struct video_device vbi_template=
-{
- "bttv vbi",
- VID_TYPE_CAPTURE|VID_TYPE_TELETEXT,
- VID_HARDWARE_BT848,
- vbi_open,
- vbi_close,
- vbi_read,
- bttv_write,
- vbi_ioctl,
- NULL, /* no mmap yet */
- bttv_init_done,
- NULL,
- 0,
- 0
-};
-
-
-static int radio_open(struct video_device *dev, int flags)
-{
- struct bttv *btv = (struct bttv *)(dev-1);
-
- if (btv->user)
- return -EBUSY;
- btv->user++;
- set_freq(btv,400*16);
- btv->radio = 1;
- bt848_muxsel(btv,0);
- audio(btv, AUDIO_UNMUTE);
-
- MOD_INC_USE_COUNT;
- return 0;
-}
-
-static void radio_close(struct video_device *dev)
-{
- struct bttv *btv=(struct bttv *)(dev-1);
-
- btv->user--;
- btv->radio = 0;
- audio(btv, AUDIO_MUTE);
- MOD_DEC_USE_COUNT;
-}
-
-static long radio_read(struct video_device *v, char *buf, unsigned long count, int nonblock)
-{
- return -EINVAL;
-}
-
-static int radio_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
-{
- struct bttv *btv=(struct bttv *)(dev-1);
- static int lastchan=0;
- switch (cmd) {
- case VIDIOCGCAP:
- /* XXX */
- break;
- case VIDIOCGTUNER:
- {
- struct video_tuner v;
- if(copy_from_user(&v,arg,sizeof(v))!=0)
- return -EFAULT;
- if(v.tuner||lastchan) /* Only tuner 0 */
- return -EINVAL;
- strcpy(v.name, "Radio");
- v.rangelow=(int)(87.5*16);
- v.rangehigh=(int)(108.0*16);
- v.flags= 0; /* XXX */
- v.mode = 0; /* XXX */
- if(copy_to_user(arg,&v,sizeof(v)))
- return -EFAULT;
- return 0;
- }
- case VIDIOCSTUNER:
- {
- struct video_tuner v;
- if(copy_from_user(&v, arg, sizeof(v)))
- return -EFAULT;
- /* Only channel 0 has a tuner */
- if(v.tuner!=0 || lastchan)
- return -EINVAL;
- /* XXX anything to do ??? */
- return 0;
- }
- case VIDIOCGFREQ:
- case VIDIOCSFREQ:
- case VIDIOCGAUDIO:
- case VIDIOCSAUDIO:
- bttv_ioctl((struct video_device *)btv,cmd,arg);
- break;
- default:
- return -ENOIOCTLCMD;
- }
- return 0;
-}
-
-static struct video_device radio_template=
-{
- "bttv radio",
- VID_TYPE_TUNER,
- VID_HARDWARE_BT848,
- radio_open,
- radio_close,
- radio_read, /* just returns -EINVAL */
- bttv_write, /* just returns -EINVAL */
- radio_ioctl,
- NULL, /* no mmap */
- bttv_init_done, /* just returns 0 */
- NULL,
- 0,
- 0
-};
-
-
-struct vidbases
-{
- unsigned short vendor, device;
- char *name;
- uint badr;
-};
-
-static struct vidbases vbs[] = {
-/* This id is not defined in pci.h but this entry was mailed to me?!?
- { PCI_VENDOR_ID_ALLIANCE, PCI_DEVICE_ID_ALLIANCE_AT25,
- "Alliance AT25", PCI_BASE_ADDRESS_0},
-*/
- { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_210888GX,
- "ATI MACH64 Winturbo", PCI_BASE_ADDRESS_0},
- { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_215GT,
- "ATI MACH64 GT", PCI_BASE_ADDRESS_0},
- { PCI_VENDOR_ID_CIRRUS, 0, "Cirrus Logic", PCI_BASE_ADDRESS_0},
- { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TGA,
- "DEC DC21030", PCI_BASE_ADDRESS_0},
- { PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_MIL,
- "Matrox Millennium", PCI_BASE_ADDRESS_1},
- { PCI_VENDOR_ID_MATROX, 0x051a, "Matrox Mystique", PCI_BASE_ADDRESS_1},
- { PCI_VENDOR_ID_N9, PCI_DEVICE_ID_N9_I128,
- "Number Nine Imagine 128", PCI_BASE_ADDRESS_0},
- { PCI_VENDOR_ID_N9, PCI_DEVICE_ID_N9_I128_2,
- "Number Nine Imagine 128 Series 2", PCI_BASE_ADDRESS_0},
- { PCI_VENDOR_ID_S3, 0, "S3", PCI_BASE_ADDRESS_0},
- { PCI_VENDOR_ID_TSENG, 0, "TSENG", PCI_BASE_ADDRESS_0},
-};
-
-
-/* DEC TGA offsets stolen from XFree-3.2 */
-
-static uint dec_offsets[4] = {
- 0x200000,
- 0x804000,
- 0,
- 0x1004000
-};
-
-#define NR_CARDS (sizeof(vbs)/sizeof(struct vidbases))
-
-/* Scan for PCI display adapter
- if more than one card is present the last one is used for now */
-
-static int find_vga(void)
-{
- unsigned int devfn, class, vendev;
- unsigned short vendor, device, badr;
- int found=0, bus=0, i, tga_type;
- unsigned int vidadr=0;
-
-
- for (devfn = 0; devfn < 0xff; devfn++)
- {
- if (PCI_FUNC(devfn) != 0)
- continue;
- pcibios_read_config_dword(bus, devfn, PCI_VENDOR_ID, &vendev);
- if (vendev == 0xffffffff || vendev == 0x00000000)
- continue;
- pcibios_read_config_word(bus, devfn, PCI_VENDOR_ID, &vendor);
- pcibios_read_config_word(bus, devfn, PCI_DEVICE_ID, &device);
- pcibios_read_config_dword(bus, devfn, PCI_CLASS_REVISION, &class);
- class = class >> 16;
-/* if (class == PCI_CLASS_DISPLAY_VGA) {*/
- if ((class>>8) == PCI_BASE_CLASS_DISPLAY ||
- /* Number 9 GXE64Pro needs this */
- class == PCI_CLASS_NOT_DEFINED_VGA)
- {
- badr=0;
- printk(KERN_INFO "bttv: PCI display adapter: ");
- for (i=0; i<NR_CARDS; i++)
- {
- if (vendor==vbs[i].vendor)
- {
- if (vbs[i].device)
- if (vbs[i].device!=device)
- continue;
- printk("%s.\n", vbs[i].name);
- badr=vbs[i].badr;
- break;
- }
- }
- if (!badr)
- {
- printk(KERN_ERR "bttv: Unknown video memory base address.\n");
- continue;
- }
- pcibios_read_config_dword(bus, devfn, badr, &vidadr);
- if (vidadr & PCI_BASE_ADDRESS_SPACE_IO)
- {
- printk(KERN_ERR "bttv: Memory seems to be I/O memory.\n");
- printk(KERN_ERR "bttv: Check entry for your card type in bttv.c vidbases struct.\n");
- continue;
- }
- vidadr &= PCI_BASE_ADDRESS_MEM_MASK;
- if (!vidadr)
- {
- printk(KERN_ERR "bttv: Memory @ 0, must be something wrong!");
- continue;
- }
-
- if (vendor==PCI_VENDOR_ID_DEC)
- if (device==PCI_DEVICE_ID_DEC_TGA)
- {
- tga_type = (readl((unsigned long)vidadr) >> 12) & 0x0f;
- if (tga_type != 0 && tga_type != 1 && tga_type != 3)
- {
- printk(KERN_ERR "bttv: TGA type (0x%x) unrecognized!\n", tga_type);
- found--;
- }
- vidadr+=dec_offsets[tga_type];
- }
-
- DEBUG(printk(KERN_DEBUG "bttv: memory @ 0x%08x, ", vidadr));
- DEBUG(printk(KERN_DEBUG "devfn: 0x%04x.\n", devfn));
- found++;
- }
- }
-
- if (vidmem)
- {
- vidadr=vidmem<<20;
- printk(KERN_INFO "bttv: Video memory override: 0x%08x\n", vidadr);
- found=1;
- }
- for (i=0; i<BTTV_MAX; i++)
- bttvs[i].win.vidadr=vidadr;
-
- return found;
-}
-
-
-
-#define TRITON_PCON 0x50
-#define TRITON_BUS_CONCURRENCY (1<<0)
-#define TRITON_STREAMING (1<<1)
-#define TRITON_WRITE_BURST (1<<2)
-#define TRITON_PEER_CONCURRENCY (1<<3)
-
-static void handle_chipset(void)
-{
- int index;
-
- /* Just in case some nut set this to something dangerous */
- if (triton1)
- triton1=BT848_INT_ETBF;
-
- for (index = 0; index < 8; index++)
- {
- unsigned char bus, devfn;
- unsigned char b;
-
- /* Beware the SiS 85C496 my friend - rev 49 don't work with a bttv */
-
- if (!pcibios_find_device(PCI_VENDOR_ID_SI,
- PCI_DEVICE_ID_SI_496,
- index, &bus, &devfn))
- {
- printk(KERN_WARNING "BT848 and SIS 85C496 chipset don't always work together.\n");
- }
-
- if (!pcibios_find_device(PCI_VENDOR_ID_INTEL,
- PCI_DEVICE_ID_INTEL_82441,
- index, &bus, &devfn))
- {
- pcibios_read_config_byte(bus, devfn, 0x53, &b);
- DEBUG(printk(KERN_INFO "bttv: Host bridge: 82441FX Natoma, "));
- DEBUG(printk("bufcon=0x%02x\n",b));
- }
-
- if (!pcibios_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437,
- index, &bus, &devfn))
- {
- printk(KERN_INFO "bttv: Host bridge 82437FX Triton PIIX\n");
- triton1=BT848_INT_ETBF;
-
-#if 0
- /* The ETBF bit SHOULD make all this unnecessary */
- /* 430FX (Triton I) freezes with bus concurrency on -> switch it off */
- {
- unsigned char bo;
-
- pcibios_read_config_byte(bus, devfn, TRITON_PCON, &b);
- bo=b;
- DEBUG(printk(KERN_DEBUG "bttv: 82437FX: PCON: 0x%x\n",b));
-
- if(!(b & TRITON_BUS_CONCURRENCY))
- {
- printk(KERN_WARNING "bttv: 82437FX: disabling bus concurrency\n");
- b |= TRITON_BUS_CONCURRENCY;
- }
-
- if(b & TRITON_PEER_CONCURRENCY)
- {
- printk(KERN_WARNING "bttv: 82437FX: disabling peer concurrency\n");
- b &= ~TRITON_PEER_CONCURRENCY;
- }
- if(!(b & TRITON_STREAMING))
- {
- printk(KERN_WARNING "bttv: 82437FX: disabling streaming\n");
- b |= TRITON_STREAMING;
- }
-
- if (b!=bo)
- {
- pcibios_write_config_byte(bus, devfn, TRITON_PCON, b);
- printk(KERN_DEBUG "bttv: 82437FX: PCON changed to: 0x%x\n",b);
- }
- }
-#endif
- }
- }
-}
-
-static void init_tda8425(struct bttv *btv)
-{
- I2CWrite(btv, I2C_TDA8425, TDA8425_VL, 0xFC, 1); /* volume left 0dB */
- I2CWrite(btv, I2C_TDA8425, TDA8425_VR, 0xFC, 1); /* volume right 0dB */
- I2CWrite(btv, I2C_TDA8425, TDA8425_BA, 0xF6, 1); /* bass 0dB */
- I2CWrite(btv, I2C_TDA8425, TDA8425_TR, 0xF6, 1); /* treble 0dB */
- I2CWrite(btv, I2C_TDA8425, TDA8425_S1, 0xCE, 1); /* mute off */
-}
-
-static void init_tda9850(struct bttv *btv)
-{
- I2CWrite(btv, I2C_TDA9850, TDA9850_CON1, 0x08, 1); /* noise threshold st */
- I2CWrite(btv, I2C_TDA9850, TDA9850_CON2, 0x08, 1); /* noise threshold sap */
- I2CWrite(btv, I2C_TDA9850, TDA9850_CON3, 0x40, 1); /* stereo mode */
- I2CWrite(btv, I2C_TDA9850, TDA9850_CON4, 0x07, 1); /* 0 dB input gain?*/
- I2CWrite(btv, I2C_TDA9850, TDA9850_ALI1, 0x10, 1); /* wideband alignment? */
- I2CWrite(btv, I2C_TDA9850, TDA9850_ALI2, 0x10, 1); /* spectral alignment? */
- I2CWrite(btv, I2C_TDA9850, TDA9850_ALI3, 0x03, 1);
-}
-
-/* Figure out card and tuner type */
-
-static void idcard(struct bttv *btv)
-{
- int tunertype;
- btwrite(0, BT848_GPIO_OUT_EN);
- DEBUG(printk(KERN_DEBUG "bttv: GPIO: 0x%08x\n", btread(BT848_GPIO_DATA)));
-
- /* Default the card to the user-selected one. */
- btv->type=card;
-
- /* If we were asked to auto-detect, then do so!
- Right now this will only recognize Miro, Hauppauge or STB
- */
- if (btv->type == BTTV_UNKNOWN)
- {
- btv->type=BTTV_MIRO;
-
- if (I2CRead(btv, I2C_HAUPEE)>=0)
- btv->type=BTTV_HAUPPAUGE;
- else
- if (I2CRead(btv, I2C_STBEE)>=0)
- btv->type=BTTV_STB;
- }
-
- if (I2CRead(btv, I2C_TDA9850) >=0)
- {
- btv->audio_chip = TDA9850;
- printk(KERN_INFO "bttv%d: audio chip: TDA9850\n",btv->nr);
- }
-
- if (I2CRead(btv, I2C_TDA8425) >=0)
- {
- btv->audio_chip = TDA8425;
- printk(KERN_INFO "bttv%d: audio chip: TDA8425\n",btv->nr);
- }
-
- switch(btv->audio_chip)
- {
- case TDA9850:
- init_tda9850(btv);
- break;
- case TDA8425:
- init_tda8425(btv);
- break;
- }
-
- /* How do I detect the tuner type for other cards but Miro ??? */
- printk(KERN_INFO "bttv: model: ");
- switch (btv->type)
- {
- case BTTV_MIRO:
- printk("MIRO\n");
-#if 0
- if (btv->have_tuner)
- {
- tunertype=((btread(BT848_GPIO_DATA)>>10)-1)&7;
- i2c_control_device(&(btv->i2c),
- I2C_DRIVERID_TUNER,
- TUNER_SET_TYPE,&tunertype);
- }
-#endif
- strcpy(btv->video_dev.name,"BT848(Miro)");
- break;
- case BTTV_HAUPPAUGE:
- printk("HAUPPAUGE\n");
- strcpy(btv->video_dev.name,"BT848(Hauppauge)");
- break;
- case BTTV_STB:
- printk("STB\n");
- strcpy(btv->video_dev.name,"BT848(STB)");
- break;
- case BTTV_INTEL:
- printk("Intel\n");
- strcpy(btv->video_dev.name,"BT848(Intel)");
- break;
- case BTTV_DIAMOND:
- printk("Diamond\n");
- strcpy(btv->video_dev.name,"BT848(Diamond)");
- break;
- case BTTV_AVERMEDIA:
- printk("AVerMedia\n");
- strcpy(btv->video_dev.name,"BT848(AVerMedia)");
- break;
- case BTTV_MATRIX_VISION:
- printk("MATRIX-Vision\n");
- strcpy(btv->video_dev.name,"BT848(MATRIX-Vision)");
- break;
- }
- audio(btv, AUDIO_MUTE);
-}
-
-static void bt848_set_risc_jmps(struct bttv *btv)
-{
- int flags=btv->cap;
-
- /* Sync to start of odd field */
- btv->risc_jmp[0]=BT848_RISC_SYNC|BT848_RISC_RESYNC|BT848_FIFO_STATUS_VRE;
- btv->risc_jmp[1]=0;
-
- /* Jump to odd vbi sub */
- btv->risc_jmp[2]=BT848_RISC_JUMP|(0x5<<20);
- if (flags&8)
- btv->risc_jmp[3]=virt_to_bus(btv->vbi_odd);
- else
- btv->risc_jmp[3]=virt_to_bus(btv->risc_jmp+4);
-
- /* Jump to odd sub */
- btv->risc_jmp[4]=BT848_RISC_JUMP|(0x6<<20);
- if (flags&2)
- btv->risc_jmp[5]=virt_to_bus(btv->risc_odd);
- else
- btv->risc_jmp[5]=virt_to_bus(btv->risc_jmp+6);
-
-
- /* Sync to start of even field */
- btv->risc_jmp[6]=BT848_RISC_SYNC|BT848_RISC_RESYNC|BT848_FIFO_STATUS_VRO;
- btv->risc_jmp[7]=0;
-
- /* Jump to even vbi sub */
- btv->risc_jmp[8]=BT848_RISC_JUMP;
- if (flags&4)
- btv->risc_jmp[9]=virt_to_bus(btv->vbi_even);
- else
- btv->risc_jmp[9]=virt_to_bus(btv->risc_jmp+10);
-
- /* Jump to even sub */
- btv->risc_jmp[10]=BT848_RISC_JUMP|(8<<20);
- if (flags&1)
- btv->risc_jmp[11]=virt_to_bus(btv->risc_even);
- else
- btv->risc_jmp[11]=virt_to_bus(btv->risc_jmp+12);
-
- btv->risc_jmp[12]=BT848_RISC_JUMP;
- btv->risc_jmp[13]=virt_to_bus(btv->risc_jmp);
-
- /* enable cpaturing and DMA */
- btaor(flags, ~0x0f, BT848_CAP_CTL);
- if (flags&0x0f)
- bt848_dma(btv, 3);
- else
- bt848_dma(btv, 0);
-}
-
-static int init_bt848(int i)
-{
- struct bttv *btv = &bttvs[i];
-
- btv->user=0;
-
- /* reset the bt848 */
- btwrite(0, BT848_SRESET);
- DEBUG(printk(KERN_DEBUG "bttv%d: bt848_mem: 0x%08x\n",i,(unsigned int) btv->bt848_mem));
-
- /* default setup for max. PAL size in a 1024xXXX hicolor framebuffer */
- btv->win.norm=0; /* change this to 1 for NTSC, 2 for SECAM */
- btv->win.interlace=1;
- btv->win.x=0;
- btv->win.y=0;
- btv->win.width=768; /* 640 */
- btv->win.height=576; /* 480 */
- btv->win.cropwidth=768; /* 640 */
- btv->win.cropheight=576; /* 480 */
- btv->win.cropx=0;
- btv->win.cropy=0;
- btv->win.bpp=2;
- btv->win.depth=16;
- btv->win.color_fmt=BT848_COLOR_FMT_RGB16;
- btv->win.bpl=1024*btv->win.bpp;
- btv->win.swidth=1024;
- btv->win.sheight=768;
- btv->cap=0;
-
- btv->gmode=0;
- btv->risc_odd=0;
- btv->risc_even=0;
- btv->risc_jmp=0;
- btv->vbibuf=0;
- btv->grisc=0;
- btv->grabbing=0;
- btv->grabcount=0;
- btv->grab=0;
- btv->lastgrab=0;
- btv->field=btv->last_field=0;
-
- /* i2c */
- memcpy(&(btv->i2c),&bit_bt848_ops_template,sizeof(struct bit_adapter));
- sprintf(btv->i2c.name+strlen(btv->i2c.name)," #%d",i);
- btv->i2c.data = btv;
- bit_bt848_setscl(btv, 1);
- bit_bt848_setsda(btv, 1);
-
- if (!(btv->risc_odd=(unsigned int *) kmalloc(RISCMEM_LEN/2, GFP_KERNEL)))
- return -1;
- if (!(btv->risc_even=(unsigned int *) kmalloc(RISCMEM_LEN/2, GFP_KERNEL)))
- return -1;
- if (!(btv->risc_jmp =(unsigned int *) kmalloc(2048, GFP_KERNEL)))
- return -1;
- DEBUG(printk(KERN_DEBUG "risc_jmp: %p\n",btv->risc_jmp));
- btv->vbi_odd=btv->risc_jmp+16;
- btv->vbi_even=btv->vbi_odd+256;
- btv->bus_vbi_odd=virt_to_bus(btv->risc_jmp+12);
- btv->bus_vbi_even=virt_to_bus(btv->risc_jmp+6);
-
- btwrite(virt_to_bus(btv->risc_jmp+2), BT848_RISC_STRT_ADD);
- btv->vbibuf=(unsigned char *) vmalloc(VBIBUF_SIZE);
- if (!btv->vbibuf)
- return -1;
- if (!(btv->grisc=(unsigned int *) kmalloc(32768, GFP_KERNEL)))
- return -1;
-
- btv->fbuffer=NULL;
-
- bt848_muxsel(btv, 1);
- bt848_set_winsize(btv);
-
-/* btwrite(0, BT848_TDEC); */
- btwrite(0x10, BT848_COLOR_CTL);
- btwrite(0x00, BT848_CAP_CTL);
- btwrite(0xfc, BT848_GPIO_DMA_CTL);
-
- /* select direct input */
- btwrite(0x00, BT848_GPIO_REG_INP);
-
-
- btwrite(0xff, BT848_VBI_PACK_SIZE);
- btwrite(1, BT848_VBI_PACK_DEL);
-
-
- btwrite(BT848_IFORM_MUX1 | BT848_IFORM_XTAUTO | BT848_IFORM_PAL_BDGHI,
- BT848_IFORM);
-
- btwrite(0xd8, BT848_CONTRAST_LO);
- bt848_bright(btv, 0x10);
-
- btwrite(0x20, BT848_E_VSCALE_HI);
- btwrite(0x20, BT848_O_VSCALE_HI);
- btwrite(/*BT848_ADC_SYNC_T|*/
- BT848_ADC_RESERVED|BT848_ADC_CRUSH, BT848_ADC);
-
- btwrite(BT848_CONTROL_LDEC, BT848_E_CONTROL);
- btwrite(BT848_CONTROL_LDEC, BT848_O_CONTROL);
-
- btv->picture.colour=254<<7;
- btv->picture.brightness=128<<8;
- btv->picture.hue=128<<8;
- btv->picture.contrast=0xd8<<7;
-
- btwrite(0x00, BT848_E_SCLOOP);
- btwrite(0x00, BT848_O_SCLOOP);
-
- /* clear interrupt status */
- btwrite(0xfffffUL, BT848_INT_STAT);
-
- /* set interrupt mask */
- btwrite(triton1|
- /*BT848_INT_PABORT|BT848_INT_RIPERR|BT848_INT_PPERR|
- BT848_INT_FDSR|BT848_INT_FTRGT|eBT848_INT_FBUS|*/
- BT848_INT_VSYNC|
- BT848_INT_SCERR|
- BT848_INT_RISCI|BT848_INT_OCERR|BT848_INT_VPRES|
- BT848_INT_FMTCHG|BT848_INT_HLOCK,
- BT848_INT_MASK);
-
- make_vbitab(btv);
- bt848_set_risc_jmps(btv);
-
- /*
- * Now add the template and register the device unit.
- */
-
- memcpy(&btv->video_dev,&bttv_template, sizeof(bttv_template));
- memcpy(&btv->vbi_dev,&vbi_template, sizeof(vbi_template));
- memcpy(&btv->radio_dev,&radio_template,sizeof(radio_template));
- idcard(btv);
-
- if(video_register_device(&btv->video_dev,VFL_TYPE_GRABBER)<0)
- return -1;
- if(video_register_device(&btv->vbi_dev,VFL_TYPE_VBI)<0)
- {
- video_unregister_device(&btv->video_dev);
- return -1;
- }
- if (radio)
- {
- if(video_register_device(&btv->radio_dev, VFL_TYPE_RADIO)<0)
- {
- video_unregister_device(&btv->vbi_dev);
- video_unregister_device(&btv->video_dev);
- return -1;
- }
- }
- i2c_bit_register_bus(&btv->i2c);
-
- return 0;
-}
-
-static void bttv_irq(int irq, void *dev_id, struct pt_regs * regs)
-{
- u32 stat,astat;
- u32 dstat;
- int count;
- struct bttv *btv;
-
- btv=(struct bttv *)dev_id;
- count=0;
- while (1)
- {
- /* get/clear interrupt status bits */
- stat=btread(BT848_INT_STAT);
- astat=stat&btread(BT848_INT_MASK);
- if (!astat)
- return;
- btwrite(astat,BT848_INT_STAT);
- IDEBUG(printk ("bttv%d: astat %08x\n", btv->nr,astat));
- IDEBUG(printk ("bttv%d: stat %08x\n", btv->nr,stat));
-
- /* get device status bits */
- dstat=btread(BT848_DSTATUS);
-
- if (astat&BT848_INT_FMTCHG)
- {
- IDEBUG(printk ("bttv%d: IRQ_FMTCHG\n", btv->nr));
- /*btv->win.norm&=
- (dstat&BT848_DSTATUS_NUML) ? (~1) : (~0); */
- }
- if (astat&BT848_INT_VPRES)
- {
- IDEBUG(printk ("bttv%d: IRQ_VPRES\n", btv->nr));
- }
- if (astat&BT848_INT_VSYNC)
- {
- IDEBUG(printk ("bttv%d: IRQ_VSYNC\n",btv->nr));
- btv->field++;
- }
- if (astat&BT848_INT_SCERR) {
- IDEBUG(printk ("bttv%d: IRQ_SCERR\n", btv->nr));
- bt848_dma(btv, 0);
- bt848_dma(btv, 1);
- wake_up_interruptible(&btv->vbiq);
- wake_up_interruptible(&btv->capq);
-
- }
- if (astat&BT848_INT_RISCI)
- {
- IDEBUG(printk ("bttv%d: IRQ_RISCI\n", btv->nr));
-
- /* captured VBI frame */
- if (stat&(1<<28))
- {
- btv->vbip=0;
- wake_up_interruptible(&btv->vbiq);
- }
-
- /* captured full frame */
- if (stat&(2<<28))
- {
- btv->last_field=btv->field;
- btv->grab++;
- btv->frame_stat[btv->grf] = GBUFFER_DONE;
- if ((--btv->grabbing))
- {
- btv->gro = btv->gro_next;
- btv->gre = btv->gre_next;
- btv->grf = btv->grf_next;
- btv->risc_jmp[5]=btv->gro;
- btv->risc_jmp[11]=btv->gre;
- bt848_set_geo(btv, btv->gwidth,
- btv->gheight,
- btv->gfmt);
- } else {
- bt848_set_risc_jmps(btv);
- bt848_set_geo(btv, btv->win.width,
- btv->win.height,
- btv->win.color_fmt);
- }
- wake_up_interruptible(&btv->capq);
- break;
- }
- if (stat&(8<<28))
- {
- btv->risc_jmp[5]=btv->gro;
- btv->risc_jmp[11]=btv->gre;
- btv->risc_jmp[12]=BT848_RISC_JUMP;
- bt848_set_geo(btv, btv->gwidth, btv->gheight,
- btv->gfmt);
- }
- }
- if (astat&BT848_INT_OCERR)
- {
- IDEBUG(printk ("bttv%d: IRQ_OCERR\n", btv->nr));
- }
- if (astat&BT848_INT_PABORT)
- {
- IDEBUG(printk ("bttv%d: IRQ_PABORT\n", btv->nr));
- }
- if (astat&BT848_INT_RIPERR)
- {
- IDEBUG(printk ("bttv%d: IRQ_RIPERR\n", btv->nr));
- }
- if (astat&BT848_INT_PPERR)
- {
- IDEBUG(printk ("bttv%d: IRQ_PPERR\n", btv->nr));
- }
- if (astat&BT848_INT_FDSR)
- {
- IDEBUG(printk ("bttv%d: IRQ_FDSR\n", btv->nr));
- }
- if (astat&BT848_INT_FTRGT)
- {
- IDEBUG(printk ("bttv%d: IRQ_FTRGT\n", btv->nr));
- }
- if (astat&BT848_INT_FBUS)
- {
- IDEBUG(printk ("bttv%d: IRQ_FBUS\n", btv->nr));
- }
- if (astat&BT848_INT_HLOCK)
- {
- if ((dstat&BT848_DSTATUS_HLOC) || (btv->radio))
- audio(btv, AUDIO_ON);
- else
- audio(btv, AUDIO_OFF);
- }
-
- if (astat&BT848_INT_I2CDONE)
- {
- }
-
- count++;
- if (count > 10)
- printk (KERN_WARNING "bttv: irq loop %d\n", count);
- if (count > 20)
- {
- btwrite(0, BT848_INT_MASK);
- printk(KERN_ERR
- "bttv: IRQ lockup, cleared int mask\n");
- }
- }
-}
-
-
-
-/*
- * Scan for a Bt848 card, request the irq and map the io memory
- */
-
-static int find_bt848(void)
-{
- short pci_index;
- unsigned char command, latency;
- int result;
- unsigned char bus, devfn;
- struct bttv *btv;
-
- bttv_num=0;
-
- if (!pcibios_present())
- {
- DEBUG(printk(KERN_DEBUG "bttv: PCI-BIOS not present or not accessable!\n"));
- return 0;
- }
-
- for (pci_index = 0;
- !pcibios_find_device(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT849,
- pci_index, &bus, &devfn)
- ||!pcibios_find_device(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT848,
- pci_index, &bus, &devfn)
- ||!pcibios_find_device(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT878,
- pci_index, &bus, &devfn)
- ||!pcibios_find_device(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT879,
- pci_index, &bus, &devfn);
- ++pci_index)
- {
- btv=&bttvs[bttv_num];
- btv->nr = bttv_num;
- btv->bus=bus;
- btv->devfn=devfn;
- btv->bt848_mem=NULL;
- btv->vbibuf=NULL;
- btv->risc_jmp=NULL;
- btv->vbi_odd=NULL;
- btv->vbi_even=NULL;
- btv->vbiq=NULL;
- btv->capq=NULL;
- btv->capqo=NULL;
- btv->capqe=NULL;
-
- btv->vbip=VBIBUF_SIZE;
-
- pcibios_read_config_word(btv->bus, btv->devfn, PCI_DEVICE_ID,
- &btv->id);
- pcibios_read_config_byte(btv->bus, btv->devfn,
- PCI_INTERRUPT_LINE, &btv->irq);
- pcibios_read_config_dword(btv->bus, btv->devfn, PCI_BASE_ADDRESS_0,
- &btv->bt848_adr);
-
- if (remap&&(!bttv_num))
- {
- remap<<=20;
- remap&=PCI_BASE_ADDRESS_MEM_MASK;
- printk(KERN_INFO "Remapping to : 0x%08x.\n", remap);
- remap|=btv->bt848_adr&(~PCI_BASE_ADDRESS_MEM_MASK);
- pcibios_write_config_dword(btv->bus, btv->devfn, PCI_BASE_ADDRESS_0,
- remap);
- pcibios_read_config_dword(btv->bus, btv->devfn, PCI_BASE_ADDRESS_0,
- &btv->bt848_adr);
- }
-
- btv->bt848_adr&=PCI_BASE_ADDRESS_MEM_MASK;
- pcibios_read_config_byte(btv->bus, btv->devfn, PCI_CLASS_REVISION,
- &btv->revision);
- printk(KERN_INFO "bttv: Brooktree Bt%d (rev %d) ",
- btv->id, btv->revision);
- printk("bus: %d, devfn: %d, ",
- btv->bus, btv->devfn);
- printk("irq: %d, ",btv->irq);
- printk("memory: 0x%08x.\n", btv->bt848_adr);
-
- btv->pll=0;
-#ifdef USE_PLL
- if (!(btv->id==848 && btv->revision==0x11))
- {
-<<<<<<< old/bttv.c
- printk("bttv: internal PLL, single crystal operation enabled\n");
-||||||| /home/kraxel/2/src/xawtv-2.14/bttv/old-driver/bttv.c
- printk("bttv%d: internal PLL, single crystal operation enabled\n",bttv_num);
-=======
- printk(KERN_INFO "bttv%d: internal PLL, single crystal operation enabled\n",bttv_num);
->>>>>>> /home/kraxel/2/src/xawtv-2.14/bttv/driver/bttv.c
- btv->pll=1;
- }
-#endif
-
- btv->bt848_mem=ioremap(btv->bt848_adr, 0x1000);
-
- result = request_irq(btv->irq, bttv_irq,
- SA_SHIRQ | SA_INTERRUPT,"bttv",(void *)btv);
- if (result==-EINVAL)
- {
- printk(KERN_ERR "bttv: Bad irq number or handler\n");
- return -EINVAL;
- }
- if (result==-EBUSY)
- {
- printk(KERN_ERR "bttv: IRQ %d busy, change your PnP config in BIOS\n",btv->irq);
- return result;
- }
- if (result < 0)
- return result;
-
- /* Enable bus-mastering */
- pcibios_read_config_byte(btv->bus, btv->devfn, PCI_COMMAND, &command);
- command|=PCI_COMMAND_MASTER;
- pcibios_write_config_byte(btv->bus, btv->devfn, PCI_COMMAND, command);
- pcibios_read_config_byte(btv->bus, btv->devfn, PCI_COMMAND, &command);
- if (!(command&PCI_COMMAND_MASTER))
- {
- printk(KERN_ERR "bttv: PCI bus-mastering could not be enabled\n");
- return -1;
- }
- pcibios_read_config_byte(btv->bus, btv->devfn, PCI_LATENCY_TIMER,
- &latency);
- if (!latency)
- {
- latency=32;
- pcibios_write_config_byte(btv->bus, btv->devfn,
- PCI_LATENCY_TIMER, latency);
- }
- DEBUG(printk(KERN_DEBUG "bttv: latency: %02x\n", latency));
- bttv_num++;
- }
- if(bttv_num)
- printk(KERN_INFO "bttv: %d Bt848 card(s) found.\n", bttv_num);
- return bttv_num;
-}
-
-
-static void release_bttv(void)
-{
- u8 command;
- int i;
- struct bttv *btv;
-
- for (i=0;i<bttv_num; i++)
- {
- btv=&bttvs[i];
-
- /* turn off all capturing, DMA and IRQs */
-
- btand(~15, BT848_GPIO_DMA_CTL);
-
- /* first disable interrupts before unmapping the memory! */
- btwrite(0, BT848_INT_MASK);
- btwrite(0xffffffffUL,BT848_INT_STAT);
- btwrite(0x0, BT848_GPIO_OUT_EN);
-
- /* unregister i2c_bus */
- i2c_bit_unregister_bus((&btv->i2c));
-
- /* disable PCI bus-mastering */
- pcibios_read_config_byte(btv->bus, btv->devfn, PCI_COMMAND, &command);
- command|=PCI_COMMAND_MASTER;
- pcibios_write_config_byte(btv->bus, btv->devfn, PCI_COMMAND, command);
-
- /* unmap and free memory */
- if (btv->grisc)
- kfree((void *) btv->grisc);
-
- if (btv->risc_odd)
- kfree((void *) btv->risc_odd);
-
- if (btv->risc_even)
- kfree((void *) btv->risc_even);
-
- DEBUG(printk(KERN_DEBUG "free: risc_jmp: 0x%08x.\n", btv->risc_jmp));
- if (btv->risc_jmp)
- kfree((void *) btv->risc_jmp);
-
- DEBUG(printk(KERN_DEBUG "bt848_vbibuf: 0x%08x.\n", btv->vbibuf));
- if (btv->vbibuf)
- vfree((void *) btv->vbibuf);
-
-
- free_irq(btv->irq,btv);
- DEBUG(printk(KERN_DEBUG "bt848_mem: 0x%08x.\n", btv->bt848_mem));
- if (btv->bt848_mem)
- iounmap(btv->bt848_mem);
-
- video_unregister_device(&btv->video_dev);
- video_unregister_device(&btv->vbi_dev);
- if (radio)
- video_unregister_device(&btv->radio_dev);
- }
-}
-
-#ifdef MODULE
-
-int init_module(void)
-{
-#else
-int init_bttv_cards(struct video_init *unused)
-{
-#endif
- int i;
-
- handle_chipset();
- if (find_bt848()<0)
- return -EIO;
-
- /* initialize Bt848s */
- for (i=0; i<bttv_num; i++)
- {
- if (init_bt848(i)<0)
- {
- release_bttv();
- return -EIO;
- }
- }
-
-#if 0
- /* load i2c chip drivers (requires a tiny patch for 2.0.x) */
- request_module("msp3400");
- request_module("tuner");
-#endif
-
- return 0;
-}
-
-
-
-#ifdef MODULE
-
-void cleanup_module(void)
-{
- release_bttv();
-}
-
-#endif
-
-/*
- * Local variables:
- * c-indent-level: 8
- * c-brace-imaginary-offset: 0
- * c-brace-offset: -8
- * c-argdecl-indent: 8
- * c-label-offset: -8
- * c-continued-statement-offset: 8
- * c-continued-brace-offset: 0
- * indent-tabs-mode: nil
- * tab-width: 8
- * End:
- */
diff --git a/bttv/experimental/bttv.h b/bttv/experimental/bttv.h
deleted file mode 100644
index 886edde..0000000
--- a/bttv/experimental/bttv.h
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- bttv - Bt848 frame grabber driver
-
- Copyright (C) 1996,97 Ralph Metzler (rjkm@thp.uni-koeln.de)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _BTTV_H_
-#define _BTTV_H_
-
-#define TEST_VBI
-
-#include <linux/types.h>
-#include <linux/wait.h>
-
-#include "i2c.h"
-/* #include "msp3400.h" */
-#include "bt848.h"
-#include "videodev.h"
-
-#define MAX_CLIPRECS 100
-#define MAX_GBUFFERS 2
-#define RISCMEM_LEN (32744*2)
-
-/* maximum needed buffer size for extended VBI frame mode capturing */
-#define BTTV_MAX_FBUF 0x151000
-
-/* clipping rectangle */
-struct cliprec
-{
- int x, y, x2, y2;
- struct cliprec *next;
-};
-
-
-#ifdef __KERNEL__
-
-struct bttv_window
-{
- int x, y;
- ushort width, height;
- ushort bpp, bpl;
- ushort swidth, sheight;
- short cropx, cropy;
- ushort cropwidth, cropheight;
- unsigned int vidadr;
- ushort freq;
- int norm;
- int interlace;
- int color_fmt;
- ushort depth;
-};
-
-
-struct bttv
-{
- struct video_device video_dev;
- struct video_device radio_dev;
- struct video_device vbi_dev;
- struct video_picture picture; /* Current picture params */
- struct video_audio audio_dev; /* Current audio params */
-
- struct bit_adapter i2c;
- int i2c_state;
- struct i2c_client *msp3400;
- struct i2c_client *tuner;
-
- unsigned int nr;
- unsigned short id;
- unsigned char bus; /* PCI bus the Bt848 is on */
- unsigned char devfn;
- unsigned char revision;
- unsigned char irq; /* IRQ used by Bt848 card */
- unsigned int bt848_adr; /* bus address of IO mem returned by PCI BIOS */
- unsigned char *bt848_mem; /* pointer to mapped IO memory */
- unsigned long busriscmem;
- u32 *riscmem;
-
- unsigned char *vbibuf;
- struct bttv_window win;
- int type; /* card type */
- int audio; /* audio mode */
- int user;
- int audio_chip;
- int radio;
-
- u32 *risc_jmp;
- u32 *vbi_odd;
- u32 *vbi_even;
- u32 bus_vbi_even;
- u32 bus_vbi_odd;
- struct wait_queue *vbiq;
- struct wait_queue *capq;
- struct wait_queue *capqo;
- struct wait_queue *capqe;
- int vbip;
-
- u32 *risc_odd;
- u32 *risc_even;
- int cap;
- struct cliprec *cliprecs;
- int ncr; /* number of clipping rectangles */
-
- struct gbuffer *ogbuffers;
- struct gbuffer *egbuffers;
- u16 gwidth, gheight, gfmt;
- u32 *grisc;
-
- unsigned long gro;
- unsigned long gre;
- unsigned long gro_next;
- unsigned long gre_next;
-
- int grf,grf_next; /* frame numbers in grab queue */
- int frame_stat[MAX_GBUFFERS];
-#define GBUFFER_UNUSED 0
-#define GBUFFER_GRABBING 1
-#define GBUFFER_DONE 2
-
- char *fbuffer;
- int gmode;
- int grabbing;
- int lastgrab;
- int grab;
- int grabcount;
-
- int pll;
- unsigned int field;
- unsigned int last_field; /* number of last grabbed field */
-};
-
-#endif
-
-/*The following should be done in more portable way. It depends on define
- of _ALPHA_BTTV in the Makefile.*/
-
-#ifdef _ALPHA_BTTV
-#define btwrite(dat,adr) writel((dat),(char *) (btv->bt848_adr+(adr)))
-#define btread(adr) readl(btv->bt848_adr+(adr))
-#else
-#define btwrite(dat,adr) writel((dat), (char *) (btv->bt848_mem+(adr)))
-#define btread(adr) readl(btv->bt848_mem+(adr))
-#endif
-
-#define btand(dat,adr) btwrite((dat) & btread(adr), adr)
-#define btor(dat,adr) btwrite((dat) | btread(adr), adr)
-#define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr)
-
-/* bttv ioctls */
-
-#define BTTV_READEE _IOW('v', BASE_VIDIOCPRIVATE+0, char [256])
-#define BTTV_WRITEE _IOR('v', BASE_VIDIOCPRIVATE+1, char [256])
-#define BTTV_GRAB _IOR('v' , BASE_VIDIOCPRIVATE+2, struct gbuf)
-#define BTTV_FIELDNR _IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int)
-
-
-#define BTTV_UNKNOWN 0x00
-#define BTTV_MIRO 0x01
-#define BTTV_HAUPPAUGE 0x02
-#define BTTV_STB 0x03
-#define BTTV_INTEL 0x04
-#define BTTV_DIAMOND 0x05
-#define BTTV_AVERMEDIA 0x06
-#define BTTV_MATRIX_VISION 0x07
-#define BTTV_FLYVIDEO 0x08
-
-#define AUDIO_TUNER 0x00
-#define AUDIO_RADIO 0x01
-#define AUDIO_EXTERN 0x02
-#define AUDIO_INTERN 0x03
-#define AUDIO_OFF 0x04
-#define AUDIO_ON 0x05
-#define AUDIO_MUTE 0x80
-#define AUDIO_UNMUTE 0x81
-
-#define TDA9850 0x01
-#define TDA8425 0x02
-
-#define I2C_TSA5522 0xc2
-#define I2C_TDA9850 0xb6
-#define I2C_TDA8425 0x82
-#define I2C_HAUPEE 0xa0
-#define I2C_STBEE 0xae
-
-#define TDA9850_CON1 0x04
-#define TDA9850_CON2 0x05
-#define TDA9850_CON3 0x06
-#define TDA9850_CON4 0x07
-#define TDA9850_ALI1 0x08
-#define TDA9850_ALI2 0x09
-#define TDA9850_ALI3 0x0a
-
-#define TDA8425_VL 0x00
-#define TDA8425_VR 0x01
-#define TDA8425_BA 0x02
-#define TDA8425_TR 0x03
-#define TDA8425_S1 0x08
-
-#endif
diff --git a/bttv/experimental/i2c.c b/bttv/experimental/i2c.c
deleted file mode 100644
index 2bd52a7..0000000
--- a/bttv/experimental/i2c.c
+++ /dev/null
@@ -1,385 +0,0 @@
-/* ------------------------------------------------------------------------- */
-/* i2c.c - a device driver for the iic-bus interface */
-/* ------------------------------------------------------------------------- */
-/* Copyright (C) 1995-97 Simon G. Vogl
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-/* ------------------------------------------------------------------------- */
-#define RCSID "$Id: i2c.c,v 1.1 1998/05/25 12:08:09 i2c Exp i2c $"
-/* ------------------------------------------------------------------------- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/malloc.h>
-
-#include "i2c.h"
-
-/* ----- global defines ---------------------------------------------------- */
-#define DEB(x) /* should be reasonable open, close &c. */
-#define DEB2(x) /* low level debugging - very slow */
-#define DEBE(x) x /* error messages */
-#define DEBI(x) /* ioctl and its arguments */
-
-/* exclusive access to the bus */
-#define I2C_LOCK(adap) spin_lock_irqsave(&adap->lock,adap->lockflags)
-#define I2C_UNLOCK(adap) spin_unlock_irqrestore(&adap->lock,adap->lockflags)
-
-/* ----- global variables -------------------------------------------------- */
-
-/**** algorithm list */
-struct i2c_algorithm *algorithms[I2C_ALGO_MAX];
-static int algo_count;
-
-/**** algorithm list */
-struct i2c_adapter *adapters[I2C_ADAP_MAX];
-static int adap_count;
-
-/**** drivers list */
-struct i2c_driver *drivers[I2C_DRIVER_MAX];
-static int driver_count;
-
-/**** clients list */
-struct i2c_client *clients[I2C_CLIENT_MAX];
-static int client_count;
-
-/* ---------------------------------------------------
- * registering functions
- * ---------------------------------------------------
- */
-
-/* -----
- * Algorithms - used to access groups of similar hw adapters or
- * specific interfaces like the PCF8584 et al.
- */
-int i2c_register_algorithm(struct i2c_algorithm *algo)
-{
- int i;
-
- for (i = 0; i < I2C_ALGO_MAX; i++)
- if (NULL == algorithms[i])
- break;
- if (I2C_ALGO_MAX == i)
- return -ENOMEM;
-
- algorithms[i] = algo;
- algo_count++;
- MOD_INC_USE_COUNT;
- DEB(printk("i2c: algorithm %s registered.\n",algo->name));
- return 0;
-}
-
-
-int i2c_unregister_algorithm(struct i2c_algorithm *algo)
-{
- int i;
-
- for (i = 0; i < I2C_ALGO_MAX; i++)
- if (algo == algorithms[i])
- break;
- if (I2C_ALGO_MAX == i)
- {
- printk(KERN_WARNING "i2c: unregister_algorithm algo not found: %s\n",
- algo->name);
- return -ENODEV;
- }
-
- algorithms[i] = NULL;
- algo_count--;
- MOD_DEC_USE_COUNT;
- DEB(printk("i2c: algorithm unregistered: %s\n",algo->name));
- return 0;
-}
-
-
-/* -----
- * i2c_register_adapter is called from within the algorithm layer,
- * when a new hw adapter registers. A new device is register to be
- * available for clients.
- */
-int i2c_register_adapter(struct i2c_adapter *adap)
-{
- int i;
-
- for (i = 0; i < I2C_ADAP_MAX; i++)
- if (NULL == adapters[i])
- break;
- if (I2C_ADAP_MAX == i)
- return -ENOMEM;
-
- adapters[i] = adap;
- adap_count++;
-/* MOD_INC_USE_COUNT;*/
-
- /* init data types */
-
- adap->lock = (spinlock_t)SPIN_LOCK_UNLOCKED;
-
-
- /* inform drivers of new adapters */
- for (i=0;i<I2C_DRIVER_MAX;i++)
- if (drivers[i]!=NULL && drivers[i]->flags&DF_NOTIFY)
- drivers[i]->attach_adapter(adap);
-
- DEB(printk("i2c: adapter %s registered.\n",adap->name));
- return 0;
-}
-
-int i2c_unregister_adapter(struct i2c_adapter *adap)
-{
- int i;
-
- for (i = 0; i < I2C_ADAP_MAX; i++)
- if (adap == adapters[i])
- break;
- if (I2C_ADAP_MAX == i)
- {
- printk(KERN_WARNING "i2c: unregister_adapter adap not found: %s\n",
- adap->name);
- return -ENODEV;
- }
-
- adapters[i] = NULL;
- adap_count--;
-
-/* MOD_DEC_USE_COUNT;*/
-
- /* inform drivers */
- for (i=0;i<I2C_DRIVER_MAX;i++)
- if (drivers[i]!=NULL && drivers[i]->flags&DF_NOTIFY)
- drivers[i]->detach_adapter(adap);
-
- DEB(printk("i2c: adapter unregistered: %s\n",adap->name));
- return 0;
-}
-
-/* -----
- * What follows is the "upwards" interface: commands for talking to clients,
- * which implement the functions to access the physical information of the
- * chips.
- */
-
-int i2c_register_driver(struct i2c_driver *driver)
-{
- int i;
-
- for (i = 0; i < I2C_DRIVER_MAX; i++)
- if (NULL == drivers[i])
- break;
- if (I2C_DRIVER_MAX == i)
- return -ENOMEM;
-
- drivers[i] = driver;
- driver_count++;
- MOD_INC_USE_COUNT;
-
- if ( driver->flags&DF_NOTIFY )
- for (i=0;i<I2C_ADAP_MAX;i++)
- if (adapters[i]!=NULL)
- driver->attach_adapter(adapters[i]);
-
- DEB(printk("i2c: driver %s registered.\n",driver->name));
- return 0;
-}
-
-int i2c_unregister_driver(struct i2c_driver *driver)
-{
- int i;
-
- for (i = 0; i < I2C_DRIVER_MAX; i++)
- if (driver == drivers[i])
- break;
- if (I2C_DRIVER_MAX == i)
- {
- printk(KERN_WARNING "i2c: unregister_driver %s not found\n",
- driver->name);
- return -ENODEV;
- }
-
- drivers[i] = NULL;
- driver_count--;
- MOD_DEC_USE_COUNT;
- DEB(printk("i2c: driver unregistered: %s\n",driver->name));
- return 0;
-}
-
-
-int i2c_attach_client(struct i2c_client *client)
-{
- struct i2c_adapter *adapter = client->adapter;
- struct i2c_algorithm *algo = adapter->algo;
- int i;
-
- for (i = 0; i < I2C_CLIENT_MAX; i++)
- if (NULL == clients[i])
- break;
- if (I2C_CLIENT_MAX == i)
- return -ENOMEM;
-
- clients[i] = client;
- client_count++;
- if (algo->client_register != NULL)
- algo->client_register(client);
- DEB(printk("i2c: client %s registered.\n",client->name));
- return 0;
-}
-
-
-int i2c_detach_client(struct i2c_client *client)
-{
- struct i2c_adapter *adapter = client->adapter;
- struct i2c_algorithm *algo = adapter->algo;
- int i;
-
- for (i = 0; i < I2C_CLIENT_MAX; i++)
- if (client == clients[i])
- break;
- if (I2C_CLIENT_MAX == i)
- {
- printk(KERN_WARNING "i2c: unregister_client %s not found\n",
- client->name);
- return -ENODEV;
- }
-
- clients[i] = NULL;
- client_count--;
- if (algo->client_unregister != NULL)
- algo->client_unregister(client);
- DEB(printk("i2c: client unregistered: %s\n",client->name));
- return 0;
-}
-
-int i2c_init(void)
-{
- /* clear algorithms */
- memset(algorithms,0,sizeof(algorithms));
- memset(adapters,0,sizeof(adapters));
- memset(clients,0,sizeof(clients));
- memset(drivers,0,sizeof(drivers));
- algo_count=0;
- adap_count=0;
- client_count=0;
- driver_count=0;
-
- printk("i2c module initialized.\n");
- return 0;
-}
-
-
-/* ----------------------------------------------------
- * the functional interface to the i2c busses.
- * ----------------------------------------------------
- */
-
-int i2c_probe(struct i2c_adapter *adap, int low_addr, int hi_addr)
-{
- struct i2c_client client;
- int i;
-
- memset(&client,0,sizeof(client));
- client.adapter=adap;
- I2C_LOCK(adap);
- for (i = low_addr; i <= hi_addr; i++) {
- client.addr=i;
- if (0 == adap->algo->master_send(&client,NULL,0))
- break;
- }
- I2C_UNLOCK(adap);
- return (i <= hi_addr) ? i : -1;
-}
-
-int i2c_master_send(struct i2c_client *client,const char *buf ,int count)
-{
- int ret;
- struct i2c_adapter *adap=client->adapter;
- DEB(printk("master_send: writing %d bytes on %s.\n",
- count,client->adapter->name));
-
- I2C_LOCK(adap);
- ret = adap->algo->master_send(client,buf,count);
- I2C_UNLOCK(adap);
-
- return ret;
-}
-
-int i2c_master_recv(struct i2c_client *client, char *buf ,int count)
-{
- int ret;
- struct i2c_adapter *adap=client->adapter;
- DEB(printk("master_recv: reading %d bytes on %s.\n",
- count,client->adapter->name));
-
- I2C_LOCK(adap);
- ret = adap->algo->master_recv(client,buf,count);
- I2C_UNLOCK(adap);
- DEB2(printk("master_recv: read %d bytes\n",ret));
- return ret;
-}
-
-int i2c_master_comb(struct i2c_client *client, char *readbuf,const char *writebuf,
- int nread, int nwrite, int flags)
-{
- int ret;
- struct i2c_adapter *adap=client->adapter;
- DEB(printk("master_comb: %s - %d in %d out on %s.\n",
- flags?"rd,wr":"wr,rd",nread,nwrite,
- client->adapter->name));
-
- I2C_LOCK(adap);
- ret = adap->algo->master_comb(client,readbuf,writebuf,
- nread,nwrite,flags);
- I2C_UNLOCK(adap);
-
- return ret;
-}
-
-
-int i2c_control(struct i2c_client *client,
- unsigned int cmd, unsigned long arg)
-{
- int ret = 0;
- struct i2c_adapter *adap = client->adapter;
-
- DEBI(printk("i2c ioctl, cmd: 0x%x, arg: %#lx\n", cmd, arg));
- switch ( cmd ) {
- case I2C_RETRIES:
- adap->retries = arg;
- break;
- case I2C_TIMEOUT:
- adap->timeout = arg;
- break;
- default:
- if (adap->algo->algo_control!=NULL)
- ret = adap->algo->algo_control(adap,cmd,arg);
- }
- return ret;
-}
-
-
-#ifdef MODULE
-/*
-EXPORT_SYMBOL(i2c_register_algorithm);
-EXPORT_SYMBOL(i2c_unregister_algorithm);
-*/
-
-int init_module(void)
-{
- return i2c_init();
-}
-
-void cleanup_module(void)
-{
-}
-#endif
diff --git a/bttv/experimental/i2c.h b/bttv/experimental/i2c.h
deleted file mode 100644
index f2f321a..0000000
--- a/bttv/experimental/i2c.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/* ------------------------------------------------------------------------- */
-/* */
-/* i2c.h - definitions for the \iic-bus interface */
-/* */
-/* ------------------------------------------------------------------------- */
-/* Copyright (C) 1995 Simon G. Vogl
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-/* ------------------------------------------------------------------------- */
-#ifndef _I2C_H
-#define _I2C_H
-#include <asm/spinlock.h> /* for spinlock_t */
-
-/* --- General options ------------------------------------------------ */
-#define I2C_MAJOR 89 /* Device major number */
-
-#define I2C_ALGO_MAX 4
-#define I2C_ADAP_MAX 16
-#define I2C_DRIVER_MAX 16
-#define I2C_CLIENT_MAX 32
-
-struct i2c_algorithm;
-struct i2c_adapter;
-struct i2c_client;
-struct i2c_driver;
-
-/* ----- registration structures */
-struct i2c_algorithm {
- char *name; /* textual description */
- unsigned int id;
- int (*master_send)(struct i2c_client *,const char*,int);
- int (*master_recv)(struct i2c_client *,char*,int);
- int (*master_comb)(struct i2c_client *,char*,const char*,int,int,int);
-
- /* --- these optional/future use for some adapter types.*/
- int (*slave_send)(struct i2c_adapter *,char*,int);
- int (*slave_recv)(struct i2c_adapter *,char*,int);
-
- /* --- ioctl like call to set div. parameters. */
- int (*algo_control)(struct i2c_adapter *, unsigned int, unsigned long);
-
- /* --- administration stuff. */
- int (*client_register)(struct i2c_client *);
- int (*client_unregister)(struct i2c_client *);
-};
-
-
-/* i2c_adapter is the structure used to identify a physical i2c bus along
- * with the access algorithms necessary to access it.
- */
-struct i2c_adapter {
- char *name; /* some useful name to identify the adapter */
- unsigned int id;/* == is algo->id | hwdep.struct->id, */
- /* for registered values see below */
- struct i2c_algorithm *algo;/* the algorithm to access the bus */
-
- void *data; /* private data for the adapter */
- /* some data fields that are used by all types */
- /* these data fields are readonly to the public */
- /* and can be set via the i2c_ioctl call */
-
- /* data fields that are valid for all devices */
- spinlock_t lock;/* used to access the adapter exclusively */
- unsigned long lockflags;
- unsigned int flags;/* flags specifying div. data */
- int timeout;
- int retries;
-};
-
-/* i2c_client identifies a single device that is connected to an
- * i2c bus.
- */
-struct i2c_client {
- char *name;
- int id;
- unsigned int flags; /* div., see below */
- unsigned char addr; /* chip address - NOTE: 7bit */
- /* addresses are stored in the */
- /* _LOWER_ 7 bits of this char */
- /* 10 bit addresses use the full*/
- /* 8 bits & set the correct */
- /* flags in the flags field... */
- struct i2c_adapter *adapter; /* the adapter we sit on */
- struct i2c_driver *driver; /* and our access routines */
- void *data; /* for the clients */
-};
-
-/* a driver is capable of handling one or more physical devices present on
- * I2C adapters. This information is used to inform the driver of adapter
- * events.
- */
-
-struct i2c_driver {
- char *name;
- int id;
- unsigned char addr_l, addr_h; /* address range of the chip */
- unsigned int flags; /* div., see below */
-
- int (*attach_adapter)(struct i2c_adapter *);
- int (*detach_adapter)(struct i2c_client *);
- int (*command)(struct i2c_client *client,unsigned int cmd, void *arg);
-
-};
-
-/*flags for the driver struct:
- */
-#define DF_NOTIFY 0x01 /* notify on bus (de/a)ttaches */
-/* #define DF_SCAN 0x02 scan the addr_l-_h for chips */
-
-/*flags for the client struct:
- */
-#define CF_TEN 0x100000 /* we have a ten bit chip address */
-#define CF_TEN0 0x100000 /* herein lie the first 2 bits */
-#define CF_TEN1 0x110000
-#define CF_TEN2 0x120000
-#define CF_TEN3 0x130000
-#define TENMASK 0x130000
-
-
-/* ----- functions exported by i2c.o */
-
-/* administration...
- */
-extern int i2c_register_algorithm(struct i2c_algorithm *);
-extern int i2c_unregister_algorithm(struct i2c_algorithm *);
-
-extern int i2c_register_adapter(struct i2c_adapter *);
-extern int i2c_unregister_adapter(struct i2c_adapter *);
-
-extern int i2c_register_driver(struct i2c_driver *);
-extern int i2c_unregister_driver(struct i2c_driver *);
-
-extern int i2c_attach_client(struct i2c_client *);
-extern int i2c_detach_client(struct i2c_client *);
-extern int i2c_client_command(struct i2c_client *);
-
-/* ----- ioctl like call to set div. parameters
- */
-extern int i2c_control(struct i2c_client *,unsigned int, unsigned long);
-
-/* ----- data transfer
- */
-extern int i2c_probe(struct i2c_adapter *adap, int low_addr, int hi_addr);
-
-extern int i2c_master_send(struct i2c_client *,const char* ,int);
-extern int i2c_master_recv(struct i2c_client *,char* ,int);
-extern int i2c_master_comb(struct i2c_client *,char* ,const char* ,int, int, int);
-
-/* --- flags for master_comb - combined read/write sequences w/ rep.start */
-#define RD_AFTER_RW 0
-#define WR_AFTER_RD 1
-
- /*--- these optional/future use for some adapter types.*/
-extern int i2c_slave_send(struct i2c_client *,char*,int);
-extern int i2c_slave_recv(struct i2c_client *,char*,int);
-
-
-/* ----- commands for the ioctl like i2c_command call:
- * note that additional calls are defined in the algorithm and hw
- * dependent layers - these can be listed here, or see the
- * corresponding header files.
- */
- /* -> bit-adapter specific ioctls */
-#define I2C_RETRIES 0x0701 /* number times a device adress should */
- /* be polled when not acknowledging */
-#define I2C_TIMEOUT 0x0702 /* set timeout - call with int */
-
-
-/* this is for i2c-dev.c */
-#define I2C_SLAVE 0x0703 /* Change slave address */
- /* Attn.: Slave address is 7 bits long, */
- /* these are to be passed as the */
- /* lowest 7 bits in the arg. */
- /* for 10-bit addresses pass lower 8bits*/
-#define I2C_TENBIT 0x0704 /* with 0-3 as arg to this call */
- /* a value <0 resets to 7 bits */
-/* ... algo-bit.c recognizes */
-#define I2C_UDELAY 0x0705 /* set delay in microsecs between each */
- /* written byte (except address) */
-#define I2C_MDELAY 0x0706 /* millisec delay between written bytes */
-
-#if 0
-#define I2C_ADDR 0x0707 /* Change adapter's \iic address */
- /* ...not supported by all adap's */
-
-#define I2C_RESET 0x07fd /* reset adapter */
-#define I2C_CLEAR 0x07fe /* when lost, use to clear stale info */
-#define I2C_V_SLOW 0x07ff /* set jiffies delay call with int */
-
-#define I2C_INTR 0x0708 /* Pass interrupt number - 2be impl. */
-
-#endif
-
-/*
- * ---- Adapter types: Add a define statement & the struct ---------------
- *
- * First, we distinguish between several algorithms to access the hardware
- * interface types, as a PCF 8584 needs other care than a bit adapter.
- */
-
-#define ALGO_NONE 0x000
-#define ALGO_BIT 0x100 /* bit style adapters */
-#define ALGO_PCF 0x200 /* PCF 8584 style adapters */
-
-#define ALGO_MASK 0xf00 /* Mask for algorithms */
-#define ALGO_SHIFT 0x08 /* right shift to get index values */
-
-#define I2C_HW_ADAPS 0x100 /* number of different hw implements per*/
- /* algorithm layer module */
-#define I2C_HW_MASK 0xff /* space for indiv. hw implmentations */
-
-
-/* hw specific modules that are defined per algorithm layer
- */
-
-/* --- Bit algorithm adapters */
-#define HW_B_LP 0x00 /* Parallel port Philips style adapter */
-#define HW_B_LPC 0x01 /* Parallel port, over control reg. */
-#define HW_B_SER 0x02 /* Serial line interface */
-#define HW_B_ELV 0x03 /* ELV Card */
-#define HW_B_VELLE 0x04 /* Vellemann K8000 */
-#define HW_B_BT848 0x05 /* BT848 video boards */
-
-/* --- PCF 8584 based algorithms */
-#define HW_P_LP 0x00 /* Parallel port interface */
-#define HW_P_ISA 0x01 /* generic ISA Bus inteface card */
-#define HW_P_ELEK 0x02 /* Elektor ISA Bus inteface card */
-
-#define I2C_DRIVERID_MSP3400 1
-#define I2C_DRIVERID_TUNER 2
-#define I2C_DRIVERID_VIDEOTEXT 3
-
-
-#endif
diff --git a/bttv/experimental/tuner.c b/bttv/experimental/tuner.c
deleted file mode 100644
index 6de2b9a..0000000
--- a/bttv/experimental/tuner.c
+++ /dev/null
@@ -1,270 +0,0 @@
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <linux/timer.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/malloc.h>
-
-#include "i2c.h"
-#include "videodev.h"
-
-#include "tuner.h"
-
-int debug = 0; /* insmod parameter */
-int type = 0; /* tuner type */
-
-#define dprintk if (debug) printk
-
-#if LINUX_VERSION_CODE > 0x020100
-MODULE_PARM(debug,"i");
-MODULE_PARM(type,"i");
-#endif
-
-struct tuner {
- int type; /* chip type */
- int freq; /* keep track of the current settings */
- int radio;
-};
-
-static struct i2c_driver driver;
-static struct i2c_client client_template;
-
-/* ---------------------------------------------------------------------- */
-
-struct tunertype {
- char *name;
- unchar Vendor;
- unchar Type;
-
- ushort thresh1; /* frequency Range for UHF,VHF-L, VHF_H */
- ushort thresh2;
- unchar VHF_L;
- unchar VHF_H;
- unchar UHF;
- unchar config;
- unchar I2C;
- ushort IFPCoff;
-};
-
-/*
- * The floats in the tuner struct are computed at compile time
- * by gcc and cast back to integers. Thus we don't violate the
- * "no float in kernel" rule.
- */
-static struct tunertype tuners[] = {
- {"Temic PAL", TEMIC, PAL,
- 16*140.25,16*463.25,0x02,0x04,0x01,0x8e,0xc2,623},
- {"Philips PAL_I", Philips, PAL_I,
- 16*140.25,16*463.25,0xa0,0x90,0x30,0x8e,0xc0,623},
- {"Philips NTSC", Philips, NTSC,
- 16*157.25,16*451.25,0xA0,0x90,0x30,0x8e,0xc0,732},
- {"Philips SECAM", Philips, SECAM,
- 16*168.25,16*447.25,0xA7,0x97,0x37,0x8e,0xc0,623},
- {"NoTuner", NoTuner, NOTUNER,
- 0 ,0 ,0x00,0x00,0x00,0x00,0x00,000},
- {"Philips PAL", Philips, PAL,
- 16*168.25,16*447.25,0xA0,0x90,0x30,0x8e,0xc0,623},
- {"Temic NTSC", TEMIC, NTSC,
- 16*157.25,16*463.25,0x02,0x04,0x01,0x8e,0xc2,732},
- {"TEMIC PAL_I", TEMIC, PAL_I,
- 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,0xc2,623},
-};
-
-/* ---------------------------------------------------------------------- */
-
-static int tuner_getstatus (struct tuner *t)
-{
-#if 0
- return i2c_read(t->bus,t->addr+1);
-#endif
-}
-
-#define TUNER_POR 0x80
-#define TUNER_FL 0x40
-#define TUNER_AFC 0x07
-
-static int tuner_islocked (struct tuner *t)
-{
- return (tuner_getstatus (t) & TUNER_FL);
-}
-
-static int tuner_afcstatus (struct tuner *t)
-{
- return (tuner_getstatus (t) & TUNER_AFC) - 2;
-}
-
-static void set_tv_freq(struct i2c_client *client, int freq)
-{
- struct tuner *t = (struct tuner*)client->data;
- struct tunertype *tun = &tuners[t->type];
- unsigned char buffer[4];
- int rc;
- u8 config;
- u16 div;
-
- if (freq < tun->thresh1)
- config = tun->VHF_L;
- else if (freq < tun->thresh2)
- config = tun->VHF_H;
- else
- config = tun->UHF;
-
- div=freq + (int)(16*38.9);
- div&=0x7fff;
-
- buffer[0] = (div>>8) & 0x7f;
- buffer[1] = div & 0xff;
- buffer[2] = tun->config;
- buffer[3] = config;
- if (4 != (rc = i2c_master_send(client,buffer,4)))
- printk("tuner: i2c i/o error: rc == %d (should be 4)\n",rc);
-}
-
-static void set_radio_freq(struct i2c_client *client, int freq)
-{
- struct tuner *t = (struct tuner*)client->data;
- struct tunertype *tun = &tuners[t->type];
- unsigned char buffer[4];
- int rc;
- u8 config;
- u16 div;
-
- config = 0xa5;
- div=freq + (int)(16*10.7);
- div&=0x7fff;
-
- buffer[0] = (div>>8) & 0x7f;
- buffer[1] = div & 0xff;
- buffer[2] = tun->config;
- buffer[3] = config;
- if (4 != (rc = i2c_master_send(client,buffer,4)))
- printk("tuner: i2c i/o error: rc == %d (should be 4)\n",rc);
-}
-
-/* ---------------------------------------------------------------------- */
-
-static int
-tuner_attach(struct i2c_adapter *adap)
-{
- struct tuner *t;
- struct i2c_client *client;
- int addr;
-
- /* check bus */
- addr = i2c_probe(adap, 0xc0>>1, 0xde>>1);
- if (addr == -1)
- return -ENODEV;
- printk("tuner: chip found @ 0x%x\n",addr);
-
- client = (struct i2c_client *)kmalloc(sizeof(struct i2c_client),
- GFP_KERNEL);
- if (client==NULL)
- return -ENOMEM;
- memcpy(client,&client_template,sizeof(struct i2c_client));
- client->addr = addr;
- client->adapter = adap;
- client->data = t = kmalloc(sizeof(struct tuner),GFP_KERNEL);
- if (NULL == t) {
- kfree(client);
- return -ENOMEM;
- }
- memset(t,0,sizeof(struct tuner));
- t->type = type;
- i2c_attach_client(client);
- return 0;
-}
-
-static int
-tuner_detach(struct i2c_client *client)
-{
- struct tuner *t = (struct tuner*)client->data;
-
- i2c_detach_client(client);
- kfree(t);
- kfree(client);
- return 0;
-}
-
-static int
-tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
-{
- struct tuner *t = (struct tuner*)client->data;
- int *iarg = (int*)arg;
-
- switch (cmd) {
- case TUNER_SET_TYPE:
- t->type = *iarg;
- dprintk("tuner: type set to %d (%s)\n",
- t->type,tuners[t->type].name);
- break;
-
- case TUNER_SET_TVFREQ:
- dprintk("tuner: tv freq set to %d.%02d\n",
- (*iarg)/16,(*iarg)%16*100/16);
- set_tv_freq(client,*iarg);
- t->radio = 0;
- t->freq = *iarg;
- break;
-
- case TUNER_SET_RADIOFREQ:
- dprintk("tuner: radio freq set to %d.%02d\n",
- (*iarg)/16,(*iarg)%16*100/16);
- set_radio_freq(client,*iarg);
- t->radio = 1;
- t->freq = *iarg;
- break;
-
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static struct i2c_driver driver = {
- "i2c tv tuner driver",
- -1,
- 0xc0,0xde,
- DF_NOTIFY,
- tuner_attach,
- tuner_detach,
- tuner_command,
-};
-
-static struct i2c_client client_template =
-{
- "i2c tv tuner chip", /* name */
- I2C_DRIVERID_TUNER, /* ID */
- 0,
- 0,
- NULL,
- &driver
-};
-
-#ifdef MODULE
-int init_module(void)
-#else
-int tuner_init(void)
-#endif
-{
- i2c_register_driver(&driver);
- return 0;
-}
-
-#ifdef MODULE
-void cleanup_module(void)
-{
- i2c_unregister_driver(&driver);
-}
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
diff --git a/bttv/experimental/tuner.h b/bttv/experimental/tuner.h
deleted file mode 100644
index 3fb77de..0000000
--- a/bttv/experimental/tuner.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- tuner.h - definition for different tuners
-
- Copyright (C) 1997 Markus Schroeder (schroedm@uni-duesseldorf.de)
- minor modifications by Ralph Metzler (rjkm@thp.uni-koeln.de)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _TUNER_H
-#define _TUNER_H
-
-#define TUNER_TEMIC_PAL 0 /* Miro Gpio Coding -1 */
-#define TUNER_PHILIPS_PAL_I 1
-#define TUNER_PHILIPS_NTSC 2
-#define TUNER_PHILIPS_SECAM 3
-#define TUNER_ABSENT 4
-#define TUNER_PHILIPS_PAL 5
-#define TUNER_TEMIC_NTSC 6
-#define TUNER_TEMIC_PAL_I 7
-
-#define NOTUNER 0
-#define PAL 1
-#define PAL_I 2
-#define NTSC 3
-#define SECAM 4
-
-#define NoTuner 0
-#define Philips 1
-#define TEMIC 2
-#define Sony 3
-
-#define TUNER_SET_TYPE _IOW('t',1,int) /* set tuner type */
-#define TUNER_SET_TVFREQ _IOW('t',2,int) /* set tv freq */
-#define TUNER_SET_RADIOFREQ _IOW('t',3,int) /* set radio freq */
-
-#endif
diff --git a/bttv/experimental/update b/bttv/experimental/update
deleted file mode 100644
index b23592c..0000000
--- a/bttv/experimental/update
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/sh
-
-if test "$UID" = "0"; then
- # running as root anyway, don't need sudo
- INSMOD="/sbin/insmod"
- RMMOD="/sbin/rmmod"
-else
- INSMOD="sudo /sbin/insmod"
- RMMOD="sudo /sbin/rmmod"
-fi
-
-# handy functions for rmmod/insmod
-function xrmmod () {
- grep -qe "^$1" /proc/modules || return
- echo rmmod $1
- $RMMOD $1 || exit 1
-}
-function xinsmod () {
- echo insmod $*
- $INSMOD -f $* || exit 1
-}
-
-# prepare for crashing the box -- flush dirty buffers
-sync; sleep 1; sync
-
-# kill old modules ...
-xrmmod tuner
-xrmmod i2c-dev
-xrmmod bttv
-xrmmod algo-bit
-xrmmod i2c
-xrmmod videodev
-
-# ... and load the new ones
-xinsmod videodev
-xinsmod i2c.o
-xinsmod algo-bit.o test=1 scan=0
-xinsmod tuner debug=1 type=5
-xinsmod bttv radio=1 vidmem=0xff0
-
diff --git a/bttv/experimental/videodev.c b/bttv/experimental/videodev.c
deleted file mode 100644
index 360058c..0000000
--- a/bttv/experimental/videodev.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * Video capture interface for Linux
- *
- * A generic video device interface for the LINUX operating system
- * using a set of device structures/vectors for low level operations.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Author: Alan Cox, <alan@cymru.net>
- *
- * Fixes:
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include "videodev.h"
-
-#if LINUX_VERSION_CODE >= 0x020100
-#include <asm/uaccess.h>
-#endif
-#include <asm/system.h>
-
-
-#define VIDEO_NUM_DEVICES 256
-
-/*
- * Active devices
- */
-
-static struct video_device *video_device[VIDEO_NUM_DEVICES];
-
-#ifdef CONFIG_VIDEO_BT848
-extern int init_bttv_cards(struct video_init *);
-#endif
-#ifdef CONFIG_VIDEO_SAA5249
-extern int init_saa_5249(struct video_init *);
-#endif
-#ifdef CONFIG_VIDEO_CQCAM
-extern int init_colour_qcams(struct video_init *);
-#endif
-#ifdef CONFIG_VIDEO_BWQCAM
-extern int init_bw_qcams(struct video_init *);
-#endif
-#ifdef CONFIG_RADIO_AZTECH
-extern int aztech_init(struct video_init *);
-#endif
-#ifdef CONFIG_RADIO_RTRACK
-extern int rtrack_init(struct video_init *);
-#endif
-#ifdef CONFIG_RADIO_SF16FMI
-extern int fmi_init(struct video_init *);
-#endif
-
-static struct video_init video_init_list[]={
-#ifdef CONFIG_VIDEO_BT848
- {"bttv", init_bttv_cards},
-#endif
-#ifdef CONFIG_VIDEO_SAA5249
- {"saa5249", init_saa_5249},
-#endif
-#ifdef CONFIG_VIDEO_CQCAM
- {"c-qcam", init_colour_qcams},
-#endif
-#ifdef CONFIG_VIDEO_BWQCAM
- {"bw-qcam", init_bw_qcams},
-#endif
-#ifdef CONFIG_VIDEO_PMS
- {"PMS", init_pms_cards},
-#endif
- {"end", NULL}
-#ifdef CONFIG_RADIO_AZTECH
- {"Aztech", aztech_init},
-#endif
-#ifdef CONFIG_RADIO_RTRACK
- {"RTrack", rtrack_init},
-#endif
-#ifdef CONFIG_RADIO_SF16FMI
- {"SF16FMI", fmi_init},
-#endif
-};
-
-#if LINUX_VERSION_CODE >= 0x020100
-/*
- * Read will do some smarts later on. Buffer pin etc.
- */
-
-static ssize_t video_read(struct file *file,
- char *buf, size_t count, loff_t *ppos)
-{
- struct video_device *vfl=video_device[MINOR(file->f_dentry->d_inode->i_rdev)];
- if (vfl->read)
- return vfl->read(vfl, buf, count, file->f_flags&O_NONBLOCK);
- else
- return -EINVAL;
-}
-
-
-
-/*
- * Write for now does nothing. No reason it shouldnt do overlay setting
- * for some boards I guess..
- */
-
-static ssize_t video_write(struct file *file, const char *buf,
- size_t count, loff_t *ppos)
-{
- struct video_device *vfl=video_device[MINOR(file->f_dentry->d_inode->i_rdev)];
- if (vfl->write)
- return vfl->write(vfl, buf, count, file->f_flags&O_NONBLOCK);
- else
- return 0;
-}
-#else
-static int video_read(struct inode *ino,struct file *file,
- char *buf, int count)
-{
- int err;
- struct video_device *vfl=video_device[MINOR(ino->i_rdev)];
- if (vfl->read)
- return vfl->read(vfl, buf, count, file->f_flags&O_NONBLOCK);
- else
- return -EINVAL;
-}
-
-static int video_write(struct inode *ino,struct file *file, const char *buf,
- int count)
-{
- int err;
- struct video_device *vfl=video_device[MINOR(ino->i_rdev)];
- if (vfl->write)
- return vfl->write(vfl, buf, count, file->f_flags&O_NONBLOCK);
- else
- return 0;
-}
-#endif
-
-/*
- * Open a video device.
- */
-
-static int video_open(struct inode *inode, struct file *file)
-{
- unsigned int minor = MINOR(inode->i_rdev);
- int err;
- struct video_device *vfl;
-
- if(minor>=VIDEO_NUM_DEVICES)
- return -ENODEV;
-
- vfl=video_device[minor];
- if(vfl==NULL)
- return -ENODEV;
- if(vfl->busy)
- return -EBUSY;
- vfl->busy=1; /* In case vfl->open sleeps */
-
- if(vfl->open)
- {
- err=vfl->open(vfl,0); /* Tell the device it is open */
- if(err)
- {
- vfl->busy=0;
- return err;
- }
- }
- return 0;
-}
-
-/*
- * Last close of a video for Linux device
- */
-
-static int video_release(struct inode *inode, struct file *file)
-{
- struct video_device *vfl=video_device[MINOR(inode->i_rdev)];
- if(vfl->close)
- vfl->close(vfl);
- vfl->busy=0;
- return 0;
-}
-
-/*
- * Question: Should we be able to capture and then seek around the
- * image ?
- */
-
-#if LINUX_VERSION_CODE >= 0x020100
-static long long video_lseek(struct file * file,
- long long offset, int origin)
-{
- return -ESPIPE;
-}
-#else
-static long long video_lseek(struct inode *inode, struct file * file,
- long long offset, int origin)
-{
- return -ESPIPE;
-}
-#endif
-
-
-static int video_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
-{
- struct video_device *vfl=video_device[MINOR(inode->i_rdev)];
- int err=vfl->ioctl(vfl, cmd, (void *)arg);
-
- if(err!=-ENOIOCTLCMD)
- return err;
-
- switch(cmd)
- {
- default:
- return -EINVAL;
- }
-}
-
-/*
- * We need to do MMAP support
- */
-
-
-#if LINUX_VERSION_CODE >= 0x020100
-int video_mmap(struct file *file, struct vm_area_struct *vma)
-{
- struct video_device *vfl=video_device[MINOR(file->f_dentry->d_inode->i_rdev)];
-#else
-static int video_mmap(struct inode * ino, struct file * file,
- struct vm_area_struct * vma)
-{
- struct video_device *vfl=video_device[MINOR(ino->i_rdev)];
-#endif
- if(vfl->mmap)
- return vfl->mmap(vfl, (char *)vma->vm_start,
- (unsigned long)(vma->vm_end-vma->vm_start));
- return -EINVAL;
-}
-
-/*
- * Video For Linux device drivers request registration here.
- */
-
-int video_register_device(struct video_device *vfd, int type)
-{
- int i=0;
- int base;
- int err;
- int end;
-
- switch(type)
- {
- case VFL_TYPE_GRABBER:
- base=0;
- end=64;
- break;
- case VFL_TYPE_VTX:
- base=192;
- end=224;
- break;
- case VFL_TYPE_VBI:
- base=224;
- end=240;
- break;
- case VFL_TYPE_RADIO:
- base=64;
- end=128;
- break;
- default:
- return -1;
- }
-
- for(i=base;i<end;i++)
- {
- if(video_device[i]==NULL)
- {
- video_device[i]=vfd;
- vfd->minor=i;
- /* The init call may sleep so we book the slot out
- then call */
- MOD_INC_USE_COUNT;
- if (vfd->initialize)
- {
- err=vfd->initialize(vfd);
- if(err<0)
- {
- video_device[i]=NULL;
- MOD_DEC_USE_COUNT;
- return err;
- }
- }
- return 0;
- }
- }
- return -ENFILE;
-}
-
-/*
- * Unregister an unused video for linux device
- */
-
-void video_unregister_device(struct video_device *vfd)
-{
- if(video_device[vfd->minor]!=vfd)
- panic("vfd: bad unregister");
- video_device[vfd->minor]=NULL;
- MOD_DEC_USE_COUNT;
-}
-
-
-static struct file_operations video_fops=
-{
- video_lseek,
- video_read,
- video_write,
- NULL, /* readdir */
- NULL, /* poll */
- video_ioctl,
- video_mmap,
- video_open,
- video_release
-};
-
-/*
- * Initialise video for linux
- */
-
-int videodev_init(void)
-{
- struct video_init *vfli = video_init_list;
-
- printk(KERN_INFO "Linux video capture interface: v0.01 ALPHA\n");
- if(register_chrdev(VIDEO_MAJOR,"video_capture", &video_fops))
- {
- printk("video_dev: unable to get major %d\n", VIDEO_MAJOR);
- return -EIO;
- }
-
- /*
- * Init kernel installed video drivers
- */
-
- while(vfli->init!=NULL)
- {
- vfli->init(vfli);
- vfli++;
- }
- return 0;
-}
-
-#ifdef MODULE
-int init_module(void)
-{
- return videodev_init();
-}
-
-void cleanup_module(void)
-{
- unregister_chrdev(VIDEO_MAJOR, "video_capture");
-}
-
-#endif
-
-#if LINUX_VERSION_CODE >= 0x020100
-EXPORT_SYMBOL(video_register_device);
-EXPORT_SYMBOL(video_unregister_device);
-#endif
diff --git a/build-test b/build-test
new file mode 100644
index 0000000..4451c4f
--- /dev/null
+++ b/build-test
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+# signal when done
+function beep { echo -en "\007"; }
+trap beep EXIT
+
+
+##########################################################################
+# xawtv
+
+# cleanup first
+make distclean
+
+# make sure autoconf stuff is up-to-date
+autoconf || exit 1
+autoheader || exit 1
+
+# normal
+./configure && make || exit 1
+make distclean
+
+# no jpeg
+./configure --disable-jpeg && make || exit 1
+make distclean
+
+# no lirc
+./configure --disable-lirc && make || exit 1
+make distclean
+
+# no xfree extentions
+./configure --disable-xfree-ext && make || exit 1
+make distclean
+
+# no xvideo extention
+./configure --disable-xvideo && make || exit 1
+make distclean
+
+# library link order
+./configure && make CC="gcc -static" || exit 1
+make distclean
+
+# 2.0.x
+kernel=`echo /usr/src/kernel/2.0.*`
+./configure && make CC="gcc -I$kernel/include" || exit 1
+make distclean
+
+# egcs
+#CC=egcs ./configure && make || exit 1
+#make distclean
+
+
+##########################################################################
+# done
+
+echo
+echo "*** cool, compile test passed ***"
+echo
+exit 0
diff --git a/capture-test b/capture-test
new file mode 100644
index 0000000..86c8fd4
--- /dev/null
+++ b/capture-test
@@ -0,0 +1,65 @@
+#!/bin/sh
+#
+# test capture...
+#
+STREAMER=src/streamer
+PLAYBACK="xanim +f +Sr +Ze -Zr"
+DEST=/media/test
+#DEST=/usr/data/test
+
+################################################################
+# init
+
+test -d $DEST || mkdir $DEST
+
+function run () {
+ echo "*** $* ***"
+ $*
+ sleep 1
+}
+
+
+################################################################
+# still images
+
+# ppm
+run $STREAMER -o $DEST/image.ppm
+run $STREAMER -o $DEST/image.pgm
+
+# jpeg
+run $STREAMER -o $DEST/image.jpeg
+
+
+################################################################
+# movies
+
+# multiple images
+run $STREAMER -r2 -t5 -o $DEST/movie000.jpeg
+
+# avi
+for file in test15 test24 mjpeg; do rm -f $DEST/$file.avi; done
+run $STREAMER -am -r10 -t255 -f avi15 -o $DEST/test15.avi
+run $STREAMER -as -r10 -t255 -f avi24 -o $DEST/test24.avi
+run $STREAMER -am -r10 -t255 -f mjpeg -o $DEST/mjpeg.avi
+
+
+################################################################
+# raw data
+
+for format in rgb gray 422 422p 420p; do
+ run $STREAMER -d -f $format -o $DEST/$format.raw 2>&1 | grep ^grab:
+done
+
+################################################################
+# check
+
+xv $DEST/*.p[pg]m $DEST/*.jpeg
+$PLAYBACK $DEST/test15.avi
+$PLAYBACK $DEST/test24.avi
+$PLAYBACK $DEST/mjpeg.avi
+
+display -size 320x240 gray:$DEST/gray.raw
+display -size 320x240 rgb:$DEST/rgb.raw
+display -size 640x240 gray:$DEST/422.raw
+display -size 320x480 gray:$DEST/422p.raw
+display -size 320x360 gray:$DEST/420p.raw
diff --git a/channel.c b/channel.c
deleted file mode 100644
index 3e3576c..0000000
--- a/channel.c
+++ /dev/null
@@ -1,466 +0,0 @@
-/*
- channel for Bt848 frame grabber driver
-
- Copyright (C) 1996,97 Marcus Metzler (mocm@thp.uni-koeln.de)
-
- many changes by Gerd Knorr <kraxel@cs.tu-berlin.de>
- [ hmm, think by now nearly nothing left from the original code ... ]
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <math.h>
-
-#include <X11/Intrinsic.h>
-
-#include "grab.h"
-#include "channels.h"
-#include "channel.h"
-#include "mixer.h"
-
-/* ----------------------------------------------------------------------- */
-/* misc common stuff, not only channel related */
-
-struct CHANNEL defaults = { "defaults", NULL,
- "5", 0, 0, 0,
- CAPTURE_OVERLAY, 0, 0,
- 32768, 32768, 32768, 32768 };
-struct CHANNEL **channels = NULL;
-int count = 0;
-int have_mixer = 0;
-
-int cur_sender = -1, cur_channel = 5, cur_fine = 0;
-int cur_norm = -1, cur_input = -1;
-
-int chan_tab = 4;
-
-extern struct GRABBER *grabbers[];
-extern int grabber;
-extern int fs_width,fs_height,fs_xoff,fs_yoff,pix_width,pix_height;
-
-/* ----------------------------------------------------------------------- */
-
-int lookup_channel(char *channel)
-{
- int i,nr;
- char tag;
-
- if (isdigit(channel[0])) {
- tag = 0;
- nr = atoi(channel);
- } else {
- tag = channel[0];
- nr = atoi(channel+1);
- }
-
- for (i = 0; i < CHAN_ENTRIES; i++) {
- if (tag && !isdigit(tvtuner[i].name[0]))
- if (atoi(tvtuner[i].name+1) == nr && tvtuner[i].name[0] == tag)
- break;
- if (!tag && isdigit(tvtuner[i].name[0]))
- if (atoi(tvtuner[i].name) == nr)
- break;
- }
- if (i == CHAN_ENTRIES)
- return -1;
-
- return i;
-}
-
-int get_freq(int i)
-{
- if (!tvtuner[i].freq[chan_tab])
- return -1;
- return tvtuner[i].freq[chan_tab]*16/1000;
-}
-
-int cf2freq(char *name, int fine)
-{
- int i;
-
- if (-1 == (i = lookup_channel(name)))
- return -1;
- return get_freq(i)+fine;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static struct STRTAB captab[] = {
- { CAPTURE_OFF, "off" },
- { CAPTURE_OFF, "no" },
- { CAPTURE_OFF, "false" },
- { CAPTURE_OVERLAY, "on" },
- { CAPTURE_OVERLAY, "yes" },
- { CAPTURE_OVERLAY, "true" },
- { CAPTURE_OVERLAY, "overlay" },
- { CAPTURE_GRABDISPLAY, "grab" },
- { CAPTURE_GRABDISPLAY, "grabdisplay" },
- { -1, NULL, },
-};
-
-void
-read_config()
-{
- FILE *fp;
- char filename[100],line[100], tag[32], val[100], *h;
- int i,nr = 0;
- struct CHANNEL *current = &defaults;
-
- sprintf(filename,"%s/%s",getenv("HOME"),".xawtv");
- fp = fopen(filename,"r");
- if (NULL == fp) {
- fprintf(stderr,"can't open config file %s\n",filename);
- return;
- }
- while (NULL != fgets(line,99,fp)) {
- nr++;
- if (line[0] == '\n' || line[0] == '#' || line[0] == '%')
- continue;
- if (1 == sscanf(line,"[%99[^]]]",val)) {
- if (0 == (count % 16)) {
- if (!count)
- channels = malloc(sizeof(struct CHANNEL*)*16);
- else
- channels = realloc(channels,sizeof(struct CHANNEL*)*(count+16));
- }
- current = channels[count] = malloc(sizeof(struct CHANNEL));
- count++;
- memcpy(current,&defaults,sizeof(struct CHANNEL));
- current->name = strdup(val);
- continue;
- }
- if (2 != sscanf(line," %31[^= ] = %99[^\n]",tag,val)) {
- fprintf(stderr,"%s:%d: parse error\n",filename,nr);
- continue;
- }
- while (NULL != (h = strrchr(val,' ')))
- *h = '\0';
-
- if (0 == strcmp(tag,"key"))
- current->key = strdup(val);
-
- else if (0 == strcmp(tag,"capture")) {
- current->capture = str_to_int(val,captab);
- if (-1 == current->capture)
- fprintf(stderr,"%s:%d: invalid value for %s: %s\n",
- filename,nr,tag,val);
- } else if (0 == strcmp(tag,"source")) {
- current->source = str_to_int(val,grabbers[grabber]->inputs);
- if (-1 == current->source)
- fprintf(stderr,"%s:%d: invalid value for %s: %s\n",
- filename,nr,tag,val);
- } else if (0 == strcmp(tag,"norm")) {
- current->norm = str_to_int(val,grabbers[grabber]->norms);
- if (-1 == current->norm)
- fprintf(stderr,"%s:%d: invalid value for %s: %s\n",
- filename,nr,tag,val);
- } else if (0 == strcmp(tag,"channel")) {
- current->cname = strdup(val);
- current->channel = lookup_channel(current->cname);
- if (-1 == current->channel)
- fprintf(stderr,"%s:%d: invalid value for %s: %s\n",
- filename,nr,tag,val);
- }
- else if (0 == strcmp(tag,"fine"))
- current->fine = atoi(val);
-
- else if (0 == strcmp(tag,"color"))
- current->color = atoi(val);
- else if (0 == strcmp(tag,"bright"))
- current->bright = atoi(val);
- else if (0 == strcmp(tag,"hue"))
- current->hue = atoi(val);
- else if (0 == strcmp(tag,"contrast"))
- current->contrast = atoi(val);
-
- else if (0 == count && 0 == strcmp(tag,"mixer")) {
- if (-1 != mixer_open("/dev/mixer", val))
- have_mixer = 1;
- else
- fprintf(stderr,"%s:%d: invalid value for %s: %s\n",
- filename,nr,tag,val);
-
- } else if (0 == count && 0 == strcmp(tag,"freqtab")) {
- if (-1 != (i = str_to_int(val,chan_names)))
- chan_tab = i;
- else
- fprintf(stderr,"%s:%d: invalid value for %s: %s\n",
- filename,nr,tag,val);
-
- } else if (0 == count && 0 == strcmp(tag,"fullscreen")) {
- if (2 != sscanf(val,"%d x %d",&fs_width,&fs_height)) {
- fprintf(stderr,"%s:%d: invalid value for %s: %s\n",
- filename,nr,tag,val);
- fs_width = fs_height = 0;
- }
-
- } else if (0 == count && 0 == strcmp(tag,"pixsize")) {
- if (2 != sscanf(val,"%d x %d",&pix_width,&pix_height)) {
- fprintf(stderr,"%s:%d: invalid value for %s: %s\n",
- filename,nr,tag,val);
- pix_width = 128;
- pix_height = 96;
- }
-
- } else if (0 == count && 0 == strcmp(tag,"wm-off-by")) {
- if (2 != sscanf(val,"%d %d",&fs_xoff,&fs_yoff)) {
- fprintf(stderr,"%s:%d: invalid value for %s: %s\n",
- filename,nr,tag,val);
- fs_xoff = fs_yoff = 0;
- }
-
- } else {
- fprintf(stderr,"%s:%d: unknown tag %s\n",filename,nr,tag);
-
- }
- }
- fclose(fp);
-
- /* calculate channel frequencies */
- defaults.channel = lookup_channel(defaults.cname);
- defaults.freq = get_freq(defaults.channel) + defaults.fine;
- for (i = 0; i < count; i++)
- channels[i]->freq = get_freq(channels[i]->channel) + channels[i]->fine;
-}
-
-/* ----------------------------------------------------------------------- */
-
-struct STRTAB chan_names[] = {
- { 0, "ntsc-bcast" },
- { 1, "ntsc-cable" },
- { 2, "ntsc-bcast-jp" },
- { 3, "ntsc-cable-jp" },
- { 4, "pal-europe" },
- { 5, "pal-italy" },
- { 6, "pal-newzealand" },
- { 7, "pal-australia" },
- { 8, "pal-ireland" },
- { -1, NULL }
-};
-
-struct STRTAB booltab[] = {
- { 0, "no" },
- { 0, "false" },
- { 0, "off" },
- { 1, "yes" },
- { 1, "true" },
- { 1, "on" },
- { -1, NULL }
-};
-
-int
-str_to_int(char *str, struct STRTAB *tab)
-{
- int i;
-
- if (str[0] >= '0' && str[0] <= '9')
- return atoi(str);
- for (i = 0; tab[i].str != NULL; i++)
- if (0 == strcasecmp(str,tab[i].str))
- return(tab[i].nr);
- return -1;
-}
-
-/* ------------------------------------------------------------------------- */
-/* moved here from channels.h */
-
-/* NOTE : NTSC BROADCAST OVER 69 WERE RE-ALLOCATED CELLULAR, included anyway */
-
-struct freqlist tvtuner[] = {
-/* CH US-TV US-CATV JP-TV JP-CATV EUROPE ITALY NZ AU UHF_GHI */
-{"E2", { 0, 0, 0, 0, 48250, 0, 0, 0, 0}},
-{"E3", { 0, 0, 0, 0, 55250, 0, 0, 0, 0}},
-{"E4", { 0, 0, 0, 0, 62250, 0, 0, 0, 0}},
-{"E5", { 0, 0, 0, 0,175250, 0, 0, 0, 0}},
-{"E6", { 0, 0, 0, 0,182250, 0, 0, 0, 0}},
-{"E7", { 0, 0, 0, 0,189250, 0, 0, 0, 0}},
-{"E8", { 0, 0, 0, 0,196250, 0, 0, 0, 0}},
-{"E9", { 0, 0, 0, 0,203250, 0, 0, 0, 0}},
-{"E10",{ 0, 0, 0, 0,210250, 0, 0, 0, 0}},
-{"E11",{ 0, 0, 0, 0,217250, 0, 0, 0, 0}},
-{"E12",{ 0, 0, 0, 0,224250, 0, 0, 0, 0}},
-
-{"S1", { 0, 0, 0, 0, 69250, 0, 0, 0, 0}},
-{"S2", { 0, 0, 0, 0, 76250, 0, 0, 0, 0}},
-{"S3", { 0, 0, 0, 0, 83250, 0, 0, 0, 0}},
-
-{"S4", { 0, 0, 0, 0,126250, 0, 0, 0, 0}},
-{"S5", { 0, 0, 0, 0,133250, 0, 0, 0, 0}},
-{"S6", { 0, 0, 0, 0,140250, 0, 0, 0, 0}},
-{"S7", { 0, 0, 0, 0,147250, 0, 0, 0, 0}},
-{"S8", { 0, 0, 0, 0,154250, 0, 0, 0, 0}},
-{"S9", { 0, 0, 0, 0,161250, 0, 0, 0, 0}},
-{"S10",{ 0, 0, 0, 0,168250, 0, 0, 0, 0}},
-
-{"S11",{ 0, 0, 0, 0,231250, 0, 0, 0, 0}},
-{"S12",{ 0, 0, 0, 0,238250, 0, 0, 0, 0}},
-{"S13",{ 0, 0, 0, 0,245250, 0, 0, 0, 0}},
-{"S14",{ 0, 0, 0, 0,252250, 0, 0, 0, 0}},
-{"S15",{ 0, 0, 0, 0,259250, 0, 0, 0, 0}},
-{"S16",{ 0, 0, 0, 0,266250, 0, 0, 0, 0}},
-{"S17",{ 0, 0, 0, 0,273250, 0, 0, 0, 0}},
-{"S18",{ 0, 0, 0, 0,280250, 0, 0, 0, 0}},
-{"S19",{ 0, 0, 0, 0,287250, 0, 0, 0, 0}},
-{"S20",{ 0, 0, 0, 0,294250, 0, 0, 0, 0}},
-
-{"S21",{ 0, 0, 0, 0,303250, 0, 0, 0, 0}},
-{"S22",{ 0, 0, 0, 0,311250, 0, 0, 0, 0}},
-{"S23",{ 0, 0, 0, 0,319250, 0, 0, 0, 0}},
-{"S24",{ 0, 0, 0, 0,327250, 0, 0, 0, 0}},
-{"S25",{ 0, 0, 0, 0,335250, 0, 0, 0, 0}},
-
-{"0", { 0, 0, 0, 0, 0, 0, 0, 46250, 45750}},
-{"1", { 0, 73250, 91250, 0, 0, 0, 45250, 57250, 53750}},
-{"2", { 55250, 55250, 97250, 0, 0, 53750, 55250, 64250, 61750}},
-{"3", { 61250, 61250,103250, 0, 0, 62250, 62250, 86250,175250}},
-{"4", { 67250, 67250,171250, 0, 0, 82250,175250, 95250,183250}},
-{"5", { 77250, 77250,177250, 0, 0,175250,182250,102250,191250}},
-{"5A", { 0, 0, 0, 0, 0, 0, 0,138250, 0}},
-{"6", { 83250, 83250,183250, 0, 0,183750,189250,175250,199250}},
-{"7", {175250,175250,189250, 0, 0,192250,196250,182250,207250}},
-{"8", {181250,181250,193250, 0, 0,201250,203250,189250,215250}},
-{"9", {187250,187250,199250, 0, 0,210250,210250,196250, 0}},
-{"10", {193250,193250,205250, 0, 0,210250,217250,209250, 0}},
-{"11", {199250,199250,211250, 0, 0,217250, 0,216250, 0}},
-{"12", {205250,205250,217250, 0, 0,224250, 0, 0, 0}},
-
-{"13", {211250,211250, 0,109250, 0, 0, 0, 0, 0}},
-{"14", {471250,121250, 0,115250, 0, 0, 0, 0, 0}},
-{"15", {477250,127250, 0,121250, 0, 0, 0, 0, 0}},
-{"16", {483250,133250, 0,127250, 0, 0, 0, 0, 0}},
-{"17", {489250,139250, 0,133250, 0, 0, 0, 0, 0}},
-{"18", {495250,145250, 0,139250, 0, 0, 0, 0, 0}},
-{"19", {501250,151250, 0,145250, 0, 0, 0, 0, 0}},
-{"20", {507250,157250, 0,151250, 0, 0, 0, 0, 0}},
-
-{"21", {513250,163250, 0,157250,471250, 0, 0, 0,471250}},
-{"22", {519250,169250, 0,165250,479250, 0, 0, 0,479250}},
-{"23", {525250,217250, 0,223250,478250, 0, 0, 0,487250}},
-{"24", {531250,223250, 0,231250,495250, 0, 0, 0,495250}},
-{"25", {537250,229250, 0,237250,503250, 0, 0, 0,503250}},
-{"26", {543250,235250, 0,243250,511250, 0, 0, 0,511250}},
-{"27", {549250,241250, 0,249250,519250, 0, 0, 0,519250}},
-{"28", {555250,247250, 0,253250,527250, 0, 0, 0,527250}},
-{"29", {561250,253250, 0,259250,535250, 0, 0, 0,535250}},
-{"30", {567250,259250, 0,265250,543250, 0, 0, 0,543250}},
-{"31", {573250,265250, 0,271250,551250, 0, 0, 0,551250}},
-{"32", {579250,271250, 0,277250,559250, 0, 0, 0,559250}},
-{"33", {585250,277250, 0,283250,567250, 0, 0, 0,567250}},
-{"34", {591250,283250, 0,289250,575250, 0, 0, 0,575250}},
-{"35", {597250,289250, 0,295250,583250, 0, 0, 0,583250}},
-{"36", {603250,295250, 0,301250,591250, 0, 0, 0,591250}},
-{"37", {609250,301250, 0,307250,599250, 0, 0, 0,599250}},
-{"38", {615250,307250, 0,313250,607250, 0, 0, 0,607250}},
-{"39", {621250,313250, 0,319250,615250, 0, 0, 0,615250}},
-{"40", {627250,319250, 0,325250,623250, 0, 0, 0,623250}},
-{"41", {633250,325250, 0,331250,631250, 0, 0, 0,631250}},
-{"42", {639250,331250, 0,337250,639250, 0, 0, 0,639250}},
-{"43", {645250,337250, 0,343250,647250, 0, 0, 0,647250}},
-{"44", {651250,343250, 0,349250,655250, 0, 0, 0,655250}},
-{"45", {657250,349250,663250,355250,663250, 0, 0, 0,663250}},
-{"46", {663250,355250,669250,361250,671250, 0, 0, 0,671250}},
-{"47", {669250,361250,675250,367250,679250, 0, 0, 0,679250}},
-{"48", {675250,367250,681250,373250,687250, 0, 0, 0,687250}},
-{"49", {681250,373250,687250,379250,695250, 0, 0, 0,695250}},
-{"50", {687250,379250,693250,385250,703250, 0, 0, 0,703250}},
-{"51", {693250,385250,699250,391250,711250, 0, 0, 0,711250}},
-{"52", {699250,391250,705250,397250,719250, 0, 0, 0,719250}},
-{"53", {705250,397250,711250,403250,727250, 0, 0, 0,727250}},
-{"54", {711250,403250,717250,409250,735250, 0, 0, 0,735250}},
-{"55", {717250,409250,723250,415250,743250, 0, 0, 0,743250}},
-{"56", {723250,415250,729250,421250,751250, 0, 0, 0,751250}},
-{"57", {729250,421250,735250,427250,759250, 0, 0, 0,759250}},
-{"58", {735250,427250,741250,433250,767250, 0, 0, 0,767250}},
-{"59", {741250,433250,747250,439250,775250, 0, 0, 0,775250}},
-{"60", {747250,439250,753250,445250,783250, 0, 0, 0,783250}},
-{"61", {753250,445250,759250,451250,791250, 0, 0, 0,791250}},
-{"62", {759250,451250,765250,457250,799250, 0, 0, 0,799250}},
-{"63", {765250,457250, 0,463250,807250, 0, 0, 0,807250}},
-{"64", {771250,463250, 0, 0,815250, 0, 0, 0,815250}},
-{"65", {777250,469250, 0, 0,823250, 0, 0, 0,823250}},
-{"66", {783250,475250, 0, 0,831250, 0, 0, 0,831250}},
-{"67", {789250,481250, 0, 0,839250, 0, 0, 0,839250}},
-{"68", {795250,487250, 0, 0,847250, 0, 0, 0,847250}},
-{"69", {801250,493250, 0, 0,855250, 0, 0, 0,855250}},
-
-{"70", {807250,499250, 0, 0, 0, 0, 0, 0, 0}},
-{"71", {813250,505250, 0, 0, 0, 0, 0, 0, 0}},
-{"72", {819250,511250, 0, 0, 0, 0, 0, 0, 0}},
-{"73", {825250,517250, 0, 0, 0, 0, 0, 0, 0}},
-{"74", {831250,523250, 0, 0, 0, 0, 0, 0, 0}},
-{"75", {837250,529250, 0, 0, 0, 0, 0, 0, 0}},
-{"76", {843250,535250, 0, 0, 0, 0, 0, 0, 0}},
-{"77", {849250,541250, 0, 0, 0, 0, 0, 0, 0}},
-{"78", {855250,547250, 0, 0, 0, 0, 0, 0, 0}},
-{"79", {861250,553250, 0, 0, 0, 0, 0, 0, 0}},
-{"80", {867250,559250, 0, 0, 0, 0, 0, 0, 0}},
-{"81", {873250,565250, 0, 0, 0, 0, 0, 0, 0}},
-{"82", {879250,571250, 0, 0, 0, 0, 0, 0, 0}},
-{"83", {885250,577250, 0, 0, 0, 0, 0, 0, 0}},
-{"84", { 0,583250, 0, 0, 0, 0, 0, 0, 0}},
-{"85", { 0,589250, 0, 0, 0, 0, 0, 0, 0}},
-{"86", { 0,595250, 0, 0, 0, 0, 0, 0, 0}},
-{"87", { 0,601250, 0, 0, 0, 0, 0, 0, 0}},
-{"88", { 0,607250, 0, 0, 0, 0, 0, 0, 0}},
-{"89", { 0,613250, 0, 0, 0, 0, 0, 0, 0}},
-{"90", { 0,619250, 0, 0, 0, 0, 0, 0, 0}},
-{"91", { 0,625250, 0, 0, 0, 0, 0, 0, 0}},
-{"92", { 0,631250, 0, 0, 0, 0, 0, 0, 0}},
-{"93", { 0,637250, 0, 0, 0, 0, 0, 0, 0}},
-{"94", { 0,643250, 0, 0, 0, 0, 0, 0, 0}},
-{"95", { 0, 91250, 0, 0, 0, 0, 0, 0, 0}},
-{"96", { 0, 97250, 0, 0, 0, 0, 0, 0, 0}},
-{"97", { 0,103250, 0, 0, 0, 0, 0, 0, 0}},
-{"98", { 0,109250, 0, 0, 0, 0, 0, 0, 0}},
-{"99", { 0,115250, 0, 0, 0, 0, 0, 0, 0}},
-{"100",{ 0,649250, 0, 0, 0, 0, 0, 0, 0}},
-{"101",{ 0,655250, 0, 0, 0, 0, 0, 0, 0}},
-{"102",{ 0,661250, 0, 0, 0, 0, 0, 0, 0}},
-{"103",{ 0,667250, 0, 0, 0, 0, 0, 0, 0}},
-{"104",{ 0,673250, 0, 0, 0, 0, 0, 0, 0}},
-{"105",{ 0,679250, 0, 0, 0, 0, 0, 0, 0}},
-{"106",{ 0,685250, 0, 0, 0, 0, 0, 0, 0}},
-{"107",{ 0,691250, 0, 0, 0, 0, 0, 0, 0}},
-{"108",{ 0,697250, 0, 0, 0, 0, 0, 0, 0}},
-{"109",{ 0,703250, 0, 0, 0, 0, 0, 0, 0}},
-{"110",{ 0,709250, 0, 0, 0, 0, 0, 0, 0}},
-{"111",{ 0,715250, 0, 0, 0, 0, 0, 0, 0}},
-{"112",{ 0,721250, 0, 0, 0, 0, 0, 0, 0}},
-{"113",{ 0,727250, 0, 0, 0, 0, 0, 0, 0}},
-{"114",{ 0,733250, 0, 0, 0, 0, 0, 0, 0}},
-{"115",{ 0,739250, 0, 0, 0, 0, 0, 0, 0}},
-{"116",{ 0,745250, 0, 0, 0, 0, 0, 0, 0}},
-{"117",{ 0,751250, 0, 0, 0, 0, 0, 0, 0}},
-{"118",{ 0,757250, 0, 0, 0, 0, 0, 0, 0}},
-{"119",{ 0,763250, 0, 0, 0, 0, 0, 0, 0}},
-{"120",{ 0,769250, 0, 0, 0, 0, 0, 0, 0}},
-{"121",{ 0,775250, 0, 0, 0, 0, 0, 0, 0}},
-{"122",{ 0,781250, 0, 0, 0, 0, 0, 0, 0}},
-{"123",{ 0,787250, 0, 0, 0, 0, 0, 0, 0}},
-{"124",{ 0,793250, 0, 0, 0, 0, 0, 0, 0}},
-{"125",{ 0,799250, 0, 0, 0, 0, 0, 0, 0}},
-
-{"T7", { 0, 8250, 0, 0, 0, 0, 0, 0, 0}},
-{"T8", { 0, 14250, 0, 0, 0, 0, 0, 0, 0}},
-{"T9", { 0, 20250, 0, 0, 0, 0, 0, 0, 0}},
-{"T10",{ 0, 26250, 0, 0, 0, 0, 0, 0, 0}},
-{"T11",{ 0, 32250, 0, 0, 0, 0, 0, 0, 0}},
-{"T12",{ 0, 38250, 0, 0, 0, 0, 0, 0, 0}},
-{"T13",{ 0, 44250, 0, 0, 0, 0, 0, 0, 0}}
-};
diff --git a/channel.h b/channel.h
deleted file mode 100644
index 6a5da08..0000000
--- a/channel.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#define CAPTURE_OFF 0
-#define CAPTURE_OVERLAY 1
-#define CAPTURE_GRABDISPLAY 2
-
-struct CHANNEL {
- char *name;
- char *key;
-
- char *cname; /* name of the channel */
- int channel; /* index into tvtuner[] */
- int fine;
- int freq;
-
- int capture;
- int source;
- int norm;
-
- int color;
- int bright;
- int hue;
- int contrast;
-
- Pixmap pixmap;
- Widget button;
-
- int ckey;
-};
-
-extern struct CHANNEL defaults;
-extern struct CHANNEL **channels;
-extern int count;
-extern int have_mixer;
-
-extern int cur_sender, cur_channel, cur_fine, cur_norm, cur_input;
-
-extern int chan_tab;
-extern struct STRTAB chan_names[];
-
-int lookup_channel(char *channel);
-int get_freq(int i);
-int cf2freq(char *name, int fine);
-
-void read_config();
-
-/* ----------------------------------------------------------------------- */
-
-extern struct STRTAB booltab[];
-extern struct STRTAB normtab[];
-extern struct STRTAB srctab[];
-
-int str_to_int(char *str, struct STRTAB *tab);
-
diff --git a/config.h.in b/config.h.in
index 39a61c7..00fdfd2 100644
--- a/config.h.in
+++ b/config.h.in
@@ -3,15 +3,21 @@
/* Define if the X Window System is missing or not being used. */
#undef X_DISPLAY_MISSING
-/* use kernel include (videodev.h) */
-#undef USE_KERNEL_VIDEODEV
-
/* MIT shared memory extention */
#undef HAVE_MITSHM
/* jpeg lib */
#undef HAVE_LIBJPEG
+/* lirc lib */
+#undef HAVE_LIBLIRC_CLIENT
+
+/* Define if you have the Xdpms library (-lXdpms). */
+#undef HAVE_LIBXDPMS
+
+/* Define if you have the Xv library (-lXv). */
+#undef HAVE_LIBXV
+
/* Define if you have the Xxf86dga library (-lXxf86dga). */
#undef HAVE_LIBXXF86DGA
diff --git a/configure b/configure
index fe1a189..9f44a0e 100755
--- a/configure
+++ b/configure
@@ -1,7 +1,7 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.12
+# Generated automatically using autoconf version 2.13
# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
#
# This configure script is free software; the Free Software Foundation
@@ -12,9 +12,15 @@ ac_help=
ac_default_prefix=/usr/local
# Any additions from configure.in:
ac_help="$ac_help
- --with-x use the X Window System"
+ --enable-jpeg jpeg support (for snapshots)"
+ac_help="$ac_help
+ --enable-xfree-ext use XFree extentions (DGA,VidMode,DPMS)"
+ac_help="$ac_help
+ --enable-xvideo use the Xvideo extention"
+ac_help="$ac_help
+ --enable-lirc lirc support"
ac_help="$ac_help
- --with-bttv=/path give the path of the bttv package"
+ --with-x use the X Window System"
# Initialize some variables set by options.
# The variables have the same names as the options, with
@@ -53,6 +59,7 @@ mandir='${prefix}/man'
# Initialize some other variables.
subdirs=
MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
# Maximum number of lines to put in a shell here document.
ac_max_here_lines=12
@@ -336,7 +343,7 @@ EOF
verbose=yes ;;
-version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.12"
+ echo "configure generated by autoconf version 2.13"
exit 0 ;;
-with-* | --with-*)
@@ -454,7 +461,7 @@ echo > confdefs.h
# A filename unique to this package, relative to the directory that
# configure is in, which we can look for to find out if srcdir is correct.
-ac_unique_file=main.c
+ac_unique_file=xawtv.spec.in
# Find the source files, if location was not specified.
if test -z "$srcdir"; then
@@ -506,9 +513,11 @@ ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
+ac_exeext=
+ac_objext=o
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
# Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
@@ -524,18 +533,48 @@ fi
+
+
+# Check whether --enable-jpeg or --disable-jpeg was given.
+if test "${enable_jpeg+set}" = set; then
+ enableval="$enable_jpeg"
+ :
+fi
+
+# Check whether --enable-xfree-ext or --disable-xfree-ext was given.
+if test "${enable_xfree_ext+set}" = set; then
+ enableval="$enable_xfree_ext"
+ :
+fi
+
+# Check whether --enable-xvideo or --disable-xvideo was given.
+if test "${enable_xvideo+set}" = set; then
+ enableval="$enable_xvideo"
+ :
+fi
+
+# Check whether --enable-lirc or --disable-lirc was given.
+if test "${enable_lirc+set}" = set; then
+ enableval="$enable_lirc"
+ :
+fi
+
+
+
+
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:531: checking for $ac_word" >&5
+echo "configure:569: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_CC="gcc"
@@ -556,16 +595,17 @@ if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:560: checking for $ac_word" >&5
+echo "configure:599: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_prog_rejected=no
- for ac_dir in $PATH; do
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
@@ -600,25 +640,61 @@ else
echo "$ac_t""no" 1>&6
fi
+ if test -z "$CC"; then
+ case "`uname -s`" in
+ *win32* | *WIN32*)
+ # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:650: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="cl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+ esac
+ fi
test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:608: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:682: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
-cat > conftest.$ac_ext <<EOF
-#line 618 "configure"
+cat > conftest.$ac_ext << EOF
+
+#line 693 "configure"
#include "confdefs.h"
+
main(){return(0);}
EOF
-if { (eval echo configure:622: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:698: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@@ -632,18 +708,24 @@ else
ac_cv_prog_cc_works=no
fi
rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:642: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:724: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:647: checking whether we are using GNU C" >&5
+echo "configure:729: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -652,7 +734,7 @@ else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:656: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:738: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@@ -663,11 +745,15 @@ echo "$ac_t""$ac_cv_prog_gcc" 1>&6
if test $ac_cv_prog_gcc = yes; then
GCC=yes
- ac_test_CFLAGS="${CFLAGS+set}"
- ac_save_CFLAGS="$CFLAGS"
- CFLAGS=
- echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:671: checking whether ${CC-cc} accepts -g" >&5
+else
+ GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:757: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -682,20 +768,24 @@ rm -f conftest*
fi
echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
- if test "$ac_test_CFLAGS" = set; then
- CFLAGS="$ac_save_CFLAGS"
- elif test $ac_cv_prog_cc_g = yes; then
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
CFLAGS="-g -O2"
else
- CFLAGS="-O2"
+ CFLAGS="-g"
fi
else
- GCC=
- test "${CFLAGS+set}" = set || CFLAGS="-g"
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:699: checking how to run the C preprocessor" >&5
+echo "configure:789: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -710,14 +800,14 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 714 "configure"
+#line 804 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:720: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:810: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
else
@@ -727,14 +817,14 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 731 "configure"
+#line 821 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:737: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:827: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
else
@@ -742,158 +832,37 @@ else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
- CPP=/lib/cpp
-fi
-rm -f conftest*
-fi
-rm -f conftest*
- ac_cv_prog_CPP="$CPP"
-fi
- CPP="$ac_cv_prog_CPP"
-else
- ac_cv_prog_CPP="$CPP"
-fi
-echo "$ac_t""$CPP" 1>&6
-
-
-if test "$KDEDIR" != "" -a -d "$KDEDIR"; then
- KRADIO=kradio
- # for kradio we need c++
- for ac_prog in $CCC c++ g++ gcc CC cxx cc++
-do
-# Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:768: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CXX"; then
- ac_cv_prog_CXX="$CXX" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_CXX="$ac_prog"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-CXX="$ac_cv_prog_CXX"
-if test -n "$CXX"; then
- echo "$ac_t""$CXX" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-test -n "$CXX" && break
-done
-test -n "$CXX" || CXX="gcc"
-
-
-echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:799: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
-
-ac_ext=C
-# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CXX-g++} -o conftest $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cxx_cross
-
-cat > conftest.$ac_ext <<EOF
-#line 809 "configure"
+ CPP="${CC-cc} -nologo -E"
+ cat > conftest.$ac_ext <<EOF
+#line 838 "configure"
#include "confdefs.h"
-main(){return(0);}
+#include <assert.h>
+Syntax Error
EOF
-if { (eval echo configure:813: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
- ac_cv_prog_cxx_works=yes
- # If we can't run a trivial program, we are probably using a cross compiler.
- if (./conftest; exit) 2>/dev/null; then
- ac_cv_prog_cxx_cross=no
- else
- ac_cv_prog_cxx_cross=yes
- fi
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:844: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
else
+ echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
- ac_cv_prog_cxx_works=no
-fi
-rm -fr conftest*
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6
-if test $ac_cv_prog_cxx_works = no; then
- { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; }
-fi
-echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:839: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
-echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6
-cross_compiling=$ac_cv_prog_cxx_cross
-
-echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6
-echo "configure:844: checking whether we are using GNU C++" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.C <<EOF
-#ifdef __GNUC__
- yes;
-#endif
-EOF
-if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:853: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
- ac_cv_prog_gxx=yes
-else
- ac_cv_prog_gxx=no
-fi
+ rm -rf conftest*
+ CPP=/lib/cpp
fi
-
-echo "$ac_t""$ac_cv_prog_gxx" 1>&6
-
-if test $ac_cv_prog_gxx = yes; then
- GXX=yes
- ac_test_CXXFLAGS="${CXXFLAGS+set}"
- ac_save_CXXFLAGS="$CXXFLAGS"
- CXXFLAGS=
- echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6
-echo "configure:868: checking whether ${CXX-g++} accepts -g" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- echo 'void f(){}' > conftest.cc
-if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then
- ac_cv_prog_cxx_g=yes
-else
- ac_cv_prog_cxx_g=no
+rm -f conftest*
fi
rm -f conftest*
-
fi
-
-echo "$ac_t""$ac_cv_prog_cxx_g" 1>&6
- if test "$ac_test_CXXFLAGS" = set; then
- CXXFLAGS="$ac_save_CXXFLAGS"
- elif test $ac_cv_prog_cxx_g = yes; then
- CXXFLAGS="-g -O2"
- else
- CXXFLAGS="-O2"
- fi
-else
- GXX=
- test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
+rm -f conftest*
+ ac_cv_prog_CPP="$CPP"
fi
-
+ CPP="$ac_cv_prog_CPP"
else
- KRADIO=""
+ ac_cv_prog_CPP="$CPP"
fi
+echo "$ac_t""$CPP" 1>&6
ac_aux_dir=
@@ -922,28 +891,30 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
# SunOS /usr/etc/install
# IRIX /sbin/install
# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:930: checking for a BSD compatible install" >&5
+echo "configure:900: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
- IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
for ac_dir in $PATH; do
# Account for people who put trailing slashes in PATH elements.
case "$ac_dir/" in
/|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
*)
# OSF1 and SCO ODT 3.0 have their own names for install.
- for ac_prog in ginstall installbsd scoinst install; do
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
if test -f $ac_dir/$ac_prog; then
if test $ac_prog = install &&
grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
- # OSF/1 installbsd also uses dspmsg, but is usable.
:
else
ac_cv_path_install="$ac_dir/$ac_prog -c"
@@ -973,6 +944,8 @@ echo "$ac_t""$INSTALL" 1>&6
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
for ac_prog in gccmakedep makedepend
@@ -980,15 +953,16 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:984: checking for $ac_word" >&5
+echo "configure:957: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_DEPEND'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$DEPEND"; then
ac_cv_prog_DEPEND="$DEPEND" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_DEPEND="$ac_prog"
@@ -1011,12 +985,13 @@ test -n "$DEPEND" || DEPEND="true"
+
# If we find X, set shell vars x_includes and x_libraries to the
# paths, otherwise set no_x=yes.
# Uses ac_ vars as temps to allow command line to override cache and checks.
# --without-x overrides everything else, but does not touch the cache.
echo $ac_n "checking for X""... $ac_c" 1>&6
-echo "configure:1020: checking for X" >&5
+echo "configure:995: checking for X" >&5
# Check whether --with-x or --without-x was given.
if test "${with_x+set}" = set; then
@@ -1078,13 +1053,13 @@ if test "$ac_x_includes" = NO; then
# First, try using that file with no special directory specified.
cat > conftest.$ac_ext <<EOF
-#line 1082 "configure"
+#line 1057 "configure"
#include "confdefs.h"
#include <$x_direct_test_include>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1087: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1062: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
# We can compile using X headers with no special include directory.
@@ -1152,14 +1127,14 @@ if test "$ac_x_libraries" = NO; then
ac_save_LIBS="$LIBS"
LIBS="-l$x_direct_test_library $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1156 "configure"
+#line 1131 "configure"
#include "confdefs.h"
int main() {
${x_direct_test_function}()
; return 0; }
EOF
-if { (eval echo configure:1163: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1138: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
LIBS="$ac_save_LIBS"
# We can link X programs with no special library path.
@@ -1265,17 +1240,17 @@ else
case "`(uname -sr) 2>/dev/null`" in
"SunOS 5"*)
echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6
-echo "configure:1269: checking whether -R must be followed by a space" >&5
+echo "configure:1244: checking whether -R must be followed by a space" >&5
ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
cat > conftest.$ac_ext <<EOF
-#line 1272 "configure"
+#line 1247 "configure"
#include "confdefs.h"
int main() {
; return 0; }
EOF
-if { (eval echo configure:1279: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1254: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_R_nospace=yes
else
@@ -1291,14 +1266,14 @@ rm -f conftest*
else
LIBS="$ac_xsave_LIBS -R $x_libraries"
cat > conftest.$ac_ext <<EOF
-#line 1295 "configure"
+#line 1270 "configure"
#include "confdefs.h"
int main() {
; return 0; }
EOF
-if { (eval echo configure:1302: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1277: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_R_space=yes
else
@@ -1330,7 +1305,7 @@ rm -f conftest*
# libraries were built with DECnet support. And karl@cs.umb.edu says
# the Alpha needs dnet_stub (dnet does not exist).
echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
-echo "configure:1334: checking for dnet_ntoa in -ldnet" >&5
+echo "configure:1309: checking for dnet_ntoa in -ldnet" >&5
ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1338,7 +1313,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldnet $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1342 "configure"
+#line 1317 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1349,7 +1324,7 @@ int main() {
dnet_ntoa()
; return 0; }
EOF
-if { (eval echo configure:1353: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1328: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1371,7 +1346,7 @@ fi
if test $ac_cv_lib_dnet_dnet_ntoa = no; then
echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6
-echo "configure:1375: checking for dnet_ntoa in -ldnet_stub" >&5
+echo "configure:1350: checking for dnet_ntoa in -ldnet_stub" >&5
ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1379,7 +1354,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldnet_stub $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1383 "configure"
+#line 1358 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1390,7 +1365,7 @@ int main() {
dnet_ntoa()
; return 0; }
EOF
-if { (eval echo configure:1394: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1369: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1419,12 +1394,12 @@ fi
# The nsl library prevents programs from opening the X display
# on Irix 5.2, according to dickey@clark.net.
echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:1423: checking for gethostbyname" >&5
+echo "configure:1398: checking for gethostbyname" >&5
if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1428 "configure"
+#line 1403 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char gethostbyname(); below. */
@@ -1447,7 +1422,7 @@ gethostbyname();
; return 0; }
EOF
-if { (eval echo configure:1451: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1426: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_gethostbyname=yes"
else
@@ -1468,7 +1443,7 @@ fi
if test $ac_cv_func_gethostbyname = no; then
echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:1472: checking for gethostbyname in -lnsl" >&5
+echo "configure:1447: checking for gethostbyname in -lnsl" >&5
ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1476,7 +1451,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lnsl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1480 "configure"
+#line 1455 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1487,7 +1462,7 @@ int main() {
gethostbyname()
; return 0; }
EOF
-if { (eval echo configure:1491: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1466: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1517,12 +1492,12 @@ fi
# -lsocket must be given before -lnsl if both are needed.
# We assume that if connect needs -lnsl, so does gethostbyname.
echo $ac_n "checking for connect""... $ac_c" 1>&6
-echo "configure:1521: checking for connect" >&5
+echo "configure:1496: checking for connect" >&5
if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1526 "configure"
+#line 1501 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char connect(); below. */
@@ -1545,7 +1520,7 @@ connect();
; return 0; }
EOF
-if { (eval echo configure:1549: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1524: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_connect=yes"
else
@@ -1566,7 +1541,7 @@ fi
if test $ac_cv_func_connect = no; then
echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6
-echo "configure:1570: checking for connect in -lsocket" >&5
+echo "configure:1545: checking for connect in -lsocket" >&5
ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1574,7 +1549,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1578 "configure"
+#line 1553 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1585,7 +1560,7 @@ int main() {
connect()
; return 0; }
EOF
-if { (eval echo configure:1589: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1564: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1609,12 +1584,12 @@ fi
# gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
echo $ac_n "checking for remove""... $ac_c" 1>&6
-echo "configure:1613: checking for remove" >&5
+echo "configure:1588: checking for remove" >&5
if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1618 "configure"
+#line 1593 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char remove(); below. */
@@ -1637,7 +1612,7 @@ remove();
; return 0; }
EOF
-if { (eval echo configure:1641: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1616: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_remove=yes"
else
@@ -1658,7 +1633,7 @@ fi
if test $ac_cv_func_remove = no; then
echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
-echo "configure:1662: checking for remove in -lposix" >&5
+echo "configure:1637: checking for remove in -lposix" >&5
ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1666,7 +1641,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lposix $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1670 "configure"
+#line 1645 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1677,7 +1652,7 @@ int main() {
remove()
; return 0; }
EOF
-if { (eval echo configure:1681: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1656: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1701,12 +1676,12 @@ fi
# BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
echo $ac_n "checking for shmat""... $ac_c" 1>&6
-echo "configure:1705: checking for shmat" >&5
+echo "configure:1680: checking for shmat" >&5
if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1710 "configure"
+#line 1685 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char shmat(); below. */
@@ -1729,7 +1704,7 @@ shmat();
; return 0; }
EOF
-if { (eval echo configure:1733: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1708: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_shmat=yes"
else
@@ -1750,7 +1725,7 @@ fi
if test $ac_cv_func_shmat = no; then
echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
-echo "configure:1754: checking for shmat in -lipc" >&5
+echo "configure:1729: checking for shmat in -lipc" >&5
ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1758,7 +1733,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lipc $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1762 "configure"
+#line 1737 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1769,7 +1744,7 @@ int main() {
shmat()
; return 0; }
EOF
-if { (eval echo configure:1773: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1748: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1802,15 +1777,15 @@ fi
# libraries we check for below, so use a different variable.
# --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
-echo "configure:1806: checking for IceConnectionNumber in -lICE" >&5
+echo "configure:1781: checking for IceConnectionNumber in -lICE" >&5
ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
-LIBS="-lICE $LIBS"
+LIBS="-lICE $X_EXTRA_LIBS $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1814 "configure"
+#line 1789 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1821,7 +1796,7 @@ int main() {
IceConnectionNumber()
; return 0; }
EOF
-if { (eval echo configure:1825: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1800: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1855,7 +1830,7 @@ fi
echo $ac_n "checking for Xaw3dComputeTopShadowRGB in -lXaw3d""... $ac_c" 1>&6
-echo "configure:1859: checking for Xaw3dComputeTopShadowRGB in -lXaw3d" >&5
+echo "configure:1834: checking for Xaw3dComputeTopShadowRGB in -lXaw3d" >&5
ac_lib_var=`echo Xaw3d'_'Xaw3dComputeTopShadowRGB | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1863,7 +1838,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lXaw3d $X_LIBS $X_PRE_LIBS -lXext -lXmu -lXt -lX11 $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1867 "configure"
+#line 1842 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1874,7 +1849,7 @@ int main() {
Xaw3dComputeTopShadowRGB()
; return 0; }
EOF
-if { (eval echo configure:1878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1853: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1898,8 +1873,10 @@ fi
-echo $ac_n "checking for jpeg_start_compress in -ljpeg""... $ac_c" 1>&6
-echo "configure:1903: checking for jpeg_start_compress in -ljpeg" >&5
+JPEG=""
+if test "$enable_jpeg" != "no"; then
+ echo $ac_n "checking for jpeg_start_compress in -ljpeg""... $ac_c" 1>&6
+echo "configure:1880: checking for jpeg_start_compress in -ljpeg" >&5
ac_lib_var=`echo jpeg'_'jpeg_start_compress | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1907,7 +1884,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ljpeg $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1911 "configure"
+#line 1888 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1918,7 +1895,7 @@ int main() {
jpeg_start_compress()
; return 0; }
EOF
-if { (eval echo configure:1922: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1899: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1939,32 +1916,36 @@ EOF
JPEG="-ljpeg"
else
echo "$ac_t""no" 1>&6
-JPEG=""
fi
+else
+ echo "*** jpeg disabled"
+fi
-echo $ac_n "checking for initscr in -lncurses""... $ac_c" 1>&6
-echo "configure:1949: checking for initscr in -lncurses" >&5
-ac_lib_var=`echo ncurses'_'initscr | sed 'y%./+-%__p_%'`
+LIRC=""
+if test "$enable_lirc" != "no"; then
+ echo $ac_n "checking for lirc_init in -llirc_client""... $ac_c" 1>&6
+echo "configure:1930: checking for lirc_init in -llirc_client" >&5
+ac_lib_var=`echo lirc_client'_'lirc_init | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
-LIBS="-lncurses $LIBS"
+LIBS="-llirc_client $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1957 "configure"
+#line 1938 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
-char initscr();
+char lirc_init();
int main() {
-initscr()
+lirc_init()
; return 0; }
EOF
-if { (eval echo configure:1968: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1949: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1979,34 +1960,40 @@ LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
- CURSES="-lncurses"
+ cat >> confdefs.h <<\EOF
+#define HAVE_LIBLIRC_CLIENT 1
+EOF
+ LIRC="-llirc_client"
else
echo "$ac_t""no" 1>&6
-CURSES=""
fi
-if test "$CURSES" = ""; then
- echo $ac_n "checking for initscr in -lcurses""... $ac_c" 1>&6
-echo "configure:1991: checking for initscr in -lcurses" >&5
-ac_lib_var=`echo curses'_'initscr | sed 'y%./+-%__p_%'`
+else
+ echo "*** lirc disabled"
+fi
+
+if test "$enable_xfree_ext" != "no"; then
+ echo $ac_n "checking for XF86DGAQueryExtension in -lXxf86dga""... $ac_c" 1>&6
+echo "configure:1978: checking for XF86DGAQueryExtension in -lXxf86dga" >&5
+ac_lib_var=`echo Xxf86dga'_'XF86DGAQueryExtension | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
-LIBS="-lcurses $LIBS"
+LIBS="-lXxf86dga $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1999 "configure"
+#line 1986 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
-char initscr();
+char XF86DGAQueryExtension();
int main() {
-initscr()
+XF86DGAQueryExtension()
; return 0; }
EOF
-if { (eval echo configure:2010: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2021,35 +2008,39 @@ LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
- CURSES="-lcurses"
+ ac_tr_lib=HAVE_LIB`echo Xxf86dga | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-lXxf86dga $LIBS"
+
else
echo "$ac_t""no" 1>&6
-CURSES=""
-fi
-
fi
-echo $ac_n "checking for XF86DGAQueryExtension in -lXxf86dga""... $ac_c" 1>&6
-echo "configure:2034: checking for XF86DGAQueryExtension in -lXxf86dga" >&5
-ac_lib_var=`echo Xxf86dga'_'XF86DGAQueryExtension | sed 'y%./+-%__p_%'`
+ echo $ac_n "checking for XF86VidModeQueryExtension in -lXxf86vm""... $ac_c" 1>&6
+echo "configure:2025: checking for XF86VidModeQueryExtension in -lXxf86vm" >&5
+ac_lib_var=`echo Xxf86vm'_'XF86VidModeQueryExtension | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
-LIBS="-lXxf86dga $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS $LIBS"
+LIBS="-lXxf86vm $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2042 "configure"
+#line 2033 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
-char XF86DGAQueryExtension();
+char XF86VidModeQueryExtension();
int main() {
-XF86DGAQueryExtension()
+XF86VidModeQueryExtension()
; return 0; }
EOF
-if { (eval echo configure:2053: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2044: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2064,39 +2055,39 @@ LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
- ac_tr_lib=HAVE_LIB`echo Xxf86dga | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ ac_tr_lib=HAVE_LIB`echo Xxf86vm | sed -e 's/[^a-zA-Z0-9_]/_/g' \
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
cat >> confdefs.h <<EOF
#define $ac_tr_lib 1
EOF
- LIBS="-lXxf86dga $LIBS"
+ LIBS="-lXxf86vm $LIBS"
else
echo "$ac_t""no" 1>&6
fi
-echo $ac_n "checking for XF86VidModeQueryExtension in -lXxf86vm""... $ac_c" 1>&6
-echo "configure:2081: checking for XF86VidModeQueryExtension in -lXxf86vm" >&5
-ac_lib_var=`echo Xxf86vm'_'XF86VidModeQueryExtension | sed 'y%./+-%__p_%'`
+ echo $ac_n "checking for DPMSQueryExtension in -lXdpms""... $ac_c" 1>&6
+echo "configure:2072: checking for DPMSQueryExtension in -lXdpms" >&5
+ac_lib_var=`echo Xdpms'_'DPMSQueryExtension | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
-LIBS="-lXxf86vm $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS $LIBS"
+LIBS="-lXdpms $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2089 "configure"
+#line 2080 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
-char XF86VidModeQueryExtension();
+char DPMSQueryExtension();
int main() {
-XF86VidModeQueryExtension()
+DPMSQueryExtension()
; return 0; }
EOF
-if { (eval echo configure:2100: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2091: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2111,39 +2102,44 @@ LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
- ac_tr_lib=HAVE_LIB`echo Xxf86vm | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ ac_tr_lib=HAVE_LIB`echo Xdpms | sed -e 's/[^a-zA-Z0-9_]/_/g' \
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
cat >> confdefs.h <<EOF
#define $ac_tr_lib 1
EOF
- LIBS="-lXxf86vm $LIBS"
+ LIBS="-lXdpms $LIBS"
else
echo "$ac_t""no" 1>&6
fi
-echo $ac_n "checking for XShmAttach in -lXext""... $ac_c" 1>&6
-echo "configure:2128: checking for XShmAttach in -lXext" >&5
-ac_lib_var=`echo Xext'_'XShmAttach | sed 'y%./+-%__p_%'`
+else
+ echo "*** XFree extentions disabled"
+fi
+
+if test "$enable_xvideo" != "no"; then
+ echo $ac_n "checking for XvQueryExtension in -lXv""... $ac_c" 1>&6
+echo "configure:2124: checking for XvQueryExtension in -lXv" >&5
+ac_lib_var=`echo Xv'_'XvQueryExtension | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
-LIBS="-lXext $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS"
+LIBS="-lXv $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2136 "configure"
+#line 2132 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
-char XShmAttach();
+char XvQueryExtension();
int main() {
-XShmAttach()
+XvQueryExtension()
; return 0; }
EOF
-if { (eval echo configure:2147: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2143: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2158,61 +2154,69 @@ LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_MITSHM 1
+ ac_tr_lib=HAVE_LIB`echo Xv | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
EOF
+ LIBS="-lXv $LIBS"
+
else
echo "$ac_t""no" 1>&6
fi
-
-
-kernel_v4l=0
-bttv=0
-
-# Check whether --with-bttv or --without-bttv was given.
-if test "${with_bttv+set}" = set; then
- withval="$with_bttv"
- bttvdir="$withval"; bttv=1
else
- bttvdir="`pwd`/bttv/driver"
+ echo "*** Xvideo extention disabled"
fi
-
-if test "$bttv" != 1; then
- cat > conftest.$ac_ext <<EOF
-#line 2186 "configure"
+echo $ac_n "checking for XShmAttach in -lXext""... $ac_c" 1>&6
+echo "configure:2175: checking for XShmAttach in -lXext" >&5
+ac_lib_var=`echo Xext'_'XShmAttach | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lXext $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2183 "configure"
#include "confdefs.h"
-#include <linux/videodev.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char XShmAttach();
+
+int main() {
+XShmAttach()
+; return 0; }
EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "video_mmap" >/dev/null 2>&1; then
+if { (eval echo configure:2194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
- cat >> confdefs.h <<\EOF
-#define USE_KERNEL_VIDEODEV 1
-EOF
- kernel_v4l=1
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
+LIBS="$ac_save_LIBS"
fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<\EOF
+#define HAVE_MITSHM 1
+EOF
-echo
-if test "$kernel_v4l" = "1"; then
- echo "*** using kernel's video4linux driver"
- # dummy
- bttvdir=.
else
-
- if test -f "$bttvdir/bttv.h"; then
- echo "*** using bttv driver in $bttvdir"
- else
- echo "oops, no driver in $bttvdir"
- exit 1
- fi
+ echo "$ac_t""no" 1>&6
fi
-echo
+
+
+
+XAWTV_VERSION="`pwd | sed -e 's/.*xawtv-\([a-z0-9.]\+\).*/\1/'`"
+
trap '' 1 2 15
cat > confcache <<\EOF
@@ -2237,7 +2241,7 @@ EOF
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
(set) 2>&1 |
- case `(ac_space=' '; set) 2>&1` in
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
*ac_space=\ *)
# `set' does not quote correctly, so add quotes (double-quote substitution
# turns \\\\ into \\, and sed turns \\ into \).
@@ -2304,7 +2308,7 @@ do
echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
-version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version 2.12"
+ echo "$CONFIG_STATUS generated by autoconf version 2.13"
exit 0 ;;
-help | --help | --hel | --he | --h)
echo "\$ac_cs_usage"; exit 0 ;;
@@ -2315,7 +2319,8 @@ done
ac_given_srcdir=$srcdir
ac_given_INSTALL="$INSTALL"
-trap 'rm -fr `echo "Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+trap 'rm -fr `echo "Makefile src/Makefile tools/Makefile radio/Makefile
+ man/Makefile i2c/Makefile font/Makefile webcam/Makefile xawtv.spec config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
EOF
cat >> $CONFIG_STATUS <<EOF
@@ -2324,9 +2329,11 @@ sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
$ac_vpsub
$extrasub
+s%@SHELL@%$SHELL%g
s%@CFLAGS@%$CFLAGS%g
s%@CPPFLAGS@%$CPPFLAGS%g
s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
s%@DEFS@%$DEFS%g
s%@LDFLAGS@%$LDFLAGS%g
s%@LIBS@%$LIBS%g
@@ -2347,9 +2354,8 @@ s%@infodir@%$infodir%g
s%@mandir@%$mandir%g
s%@CC@%$CC%g
s%@CPP@%$CPP%g
-s%@CXX@%$CXX%g
-s%@KRADIO@%$KRADIO%g
s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
s%@INSTALL_DATA@%$INSTALL_DATA%g
s%@DEPEND@%$DEPEND%g
s%@X_CFLAGS@%$X_CFLAGS%g
@@ -2359,8 +2365,8 @@ s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g
s%@x_libraries@%$x_libraries%g
s%@XAWLIB@%$XAWLIB%g
s%@JPEG@%$JPEG%g
-s%@CURSES@%$CURSES%g
-s%@bttvdir@%$bttvdir%g
+s%@LIRC@%$LIRC%g
+s%@XAWTV_VERSION@%$XAWTV_VERSION%g
CEOF
EOF
@@ -2402,7 +2408,8 @@ EOF
cat >> $CONFIG_STATUS <<EOF
-CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
+CONFIG_FILES=\${CONFIG_FILES-"Makefile src/Makefile tools/Makefile radio/Makefile
+ man/Makefile i2c/Makefile font/Makefile webcam/Makefile xawtv.spec"}
EOF
cat >> $CONFIG_STATUS <<\EOF
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
diff --git a/configure.in b/configure.in
index 74f2d1b..19f5795 100644
--- a/configure.in
+++ b/configure.in
@@ -1,25 +1,33 @@
dnl ---------------------------------------------------------------------
dnl Process this file with autoconf to produce a configure script.
-AC_INIT(main.c)
+
+AC_INIT(xawtv.spec.in)
AC_CONFIG_HEADER(config.h)
+
+dnl ---------------------------------------------------------------------
+dnl Options
+
+AC_ARG_ENABLE(jpeg,
+ [ --enable-jpeg jpeg support (for snapshots)])
+AC_ARG_ENABLE(xfree-ext,
+ [ --enable-xfree-ext use XFree extentions (DGA,VidMode,DPMS)])
+AC_ARG_ENABLE(xvideo,
+ [ --enable-xvideo use the Xvideo extention])
+AC_ARG_ENABLE(lirc,
+ [ --enable-lirc lirc support])
+
+
dnl ---------------------------------------------------------------------
dnl Checks for programs.
+
AC_PROG_CC
AC_PROG_CPP
-if test "$KDEDIR" != "" -a -d "$KDEDIR"; then
- KRADIO=kradio
- # for kradio we need c++
- AC_PROG_CXX
-else
- KRADIO=""
-fi
-AC_SUBST(KRADIO)
-
AC_PROG_INSTALL
AC_CHECK_PROGS(DEPEND,gccmakedep makedepend,true)
+
dnl ---------------------------------------------------------------------
dnl X11 checks
@@ -39,51 +47,47 @@ AC_CHECK_LIB(Xaw3d, Xaw3dComputeTopShadowRGB,
AC_SUBST(XAWLIB)
AC_SUBST(JPEG)
-AC_CHECK_LIB(jpeg, jpeg_start_compress,AC_DEFINE(HAVE_LIBJPEG) JPEG="-ljpeg",JPEG="",)
+JPEG=""
+if test "$enable_jpeg" != "no"; then
+ AC_CHECK_LIB(jpeg, jpeg_start_compress,AC_DEFINE(HAVE_LIBJPEG) JPEG="-ljpeg",,)
+else
+ echo "*** jpeg disabled"
+fi
-AC_SUBST(CURSES)
-AC_CHECK_LIB(ncurses, initscr,CURSES="-lncurses",CURSES="",)
-if test "$CURSES" = ""; then
- AC_CHECK_LIB(curses, initscr,CURSES="-lcurses",CURSES="",)
+AC_SUBST(LIRC)
+LIRC=""
+if test "$enable_lirc" != "no"; then
+ AC_CHECK_LIB(lirc_client, lirc_init,
+ AC_DEFINE(HAVE_LIBLIRC_CLIENT) LIRC="-llirc_client",,)
+else
+ echo "*** lirc disabled"
fi
-AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension,,,
+if test "$enable_xfree_ext" != "no"; then
+ AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension,,,
$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
-AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension,,,
+ AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension,,,
$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
-AC_CHECK_LIB(Xext, XShmAttach,AC_DEFINE(HAVE_MITSHM),,
- $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS)
-
-dnl ---------------------------------------------------------------------
-dnl video dev checks
-
-kernel_v4l=0
-bttv=0
-
-AC_ARG_WITH(bttv,
- [ --with-bttv=/path give the path of the bttv package],
- [ bttvdir="$withval"; bttv=1 ], bttvdir="`pwd`/bttv/driver")
-
-if test "$bttv" != 1; then
- AC_EGREP_HEADER(video_mmap, linux/videodev.h,
- AC_DEFINE(USE_KERNEL_VIDEODEV) kernel_v4l=1,)
+ AC_CHECK_LIB(Xdpms, DPMSQueryExtension,,,
+ $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
+else
+ echo "*** XFree extentions disabled"
fi
-echo
-if test "$kernel_v4l" = "1"; then
- echo "*** using kernel's video4linux driver"
- # dummy
- bttvdir=.
+if test "$enable_xvideo" != "no"; then
+ AC_CHECK_LIB(Xv, XvQueryExtension,,,
+ $X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
else
- AC_SUBST(bttvdir)
- if test -f "$bttvdir/bttv.h"; then
- echo "*** using bttv driver in $bttvdir"
- else
- echo "oops, no driver in $bttvdir"
- exit 1
- fi
+ echo "*** Xvideo extention disabled"
fi
-echo
+
+AC_CHECK_LIB(Xext, XShmAttach,AC_DEFINE(HAVE_MITSHM),,
+ $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS)
+
+
+XAWTV_VERSION="`pwd | sed -e 's/.*xawtv-\([[a-z0-9.]]\+\).*/\1/'`"
+AC_SUBST(XAWTV_VERSION)
dnl ---------------------------------------------------------------------
-AC_OUTPUT(Makefile)
+AC_OUTPUT(Makefile src/Makefile tools/Makefile radio/Makefile
+ man/Makefile i2c/Makefile font/Makefile webcam/Makefile xawtv.spec)
diff --git a/contrib/frequencies-europe b/contrib/frequencies-europe
new file mode 100644
index 0000000..f449a84
--- /dev/null
+++ b/contrib/frequencies-europe
@@ -0,0 +1,133 @@
+From: Filip Streibl <streiblf@sms.paegas.cz>
+To: Gerd Knorr <kraxel@goldbach.isdn.cs.tu-berlin.de>
+Subject: Re: Freqs
+
++------+----------------------------+----------------------------+
+| | OIRT | CCIR |
+| Band +----+---------+------+------+----+---------+------+------+
+| |Cha-| Range |Vision|Sound |Cha-| Range |Vision|Sound |
+| |nnel| | | |nnel| | | |
++------+----+---------+------+------+----+---------+------+------+
+| I | R1 |48.5-56.5| 49.75| 56.25| E2 | 47-54 | 48.25| 53.75|
+| | R2 | 58-66 | 59.25| 65.75| E3 | 54-61 | 55.25| 60.75|
+| | | | | | E4 | 61-68 | 62.25| 67.75|
++------+----+---------+------+------+----+---------+------+------+
+| II | R3 | 76-84 | 77.25| 83.75|S01 | 68-75 | 69.25| 74.75|
+| | R4 | 84-92 | 85.25| 91.75|S02 | 75-82 | 76.25| 81.75|
+| | R5 | 92-100 | 93.25| 99.75|S03 | 82-89 | 83.25| 88.75|
++------+----+---------+------+------+----+---------+------+------+
+| S |SR1 | 110-118 |111.25|117.75|SE2 | 111-118 |112.25|117.75|
+| (low)|SR2 | 118-126 |119.25|125.75|SE3 | 118-125 |119.25|124.75|
+| |SR3 | 126-134 |127.25|133.75|SE4 | 125-132 |126.25|131.75|
+| |SR4 | 134-142 |135.25|141.75|SE5 | 132-139 |133.25|138.75|
+| |SR5 | 142-150 |143.25|149.75|SE6 | 139-146 |140.25|145.75|
+| |SR6 | 150-158 |151.25|157.75|SE7 | 146-153 |147.25|152.75|
+| |SR7 | 158-166 |159.25|165.75|SE8 | 153-160 |154.25|159.75|
+| |SR8 | 166-174 |167.25|173.75|SE9 | 160-167 |161.25|166.75|
+| | | | | |SE10| 167-174 |168.25|173.75|
++------+----+---------+------+------+----+---------+------+------+
+| III | R6 | 174-182 |175.25|181.75| E5 | 174-181 |175.25|180.75|
+| | R7 | 182-190 |183.25|189.75| E6 | 181-188 |182.25|187.75|
+| | R8 | 190-198 |191.25|197.75| E7 | 188-195 |189.25|194.75|
+| | R9 | 198-206 |199.25|205.75| E8 | 195-202 |196.25|201.75|
+| | R10| 206-214 |207.25|213.75| E9 | 202-209 |203.25|208.75|
+| | R11| 214-222 |215.25|221.75| E10| 209-216 |210.25|215.75|
+| | R12| 222-230 |223.25|229.75| E11| 216-223 |217.25|222.75|
+| | | | | | E12| 223-230 |224.25|229.75|
++------+----+---------+------+------+----+---------+------+------+
+| S |SR11| 230-238 |231.25|237.75|SE11| 230-237 |231.25|236.75|
+|(high)|SR12| 238-246 |239.25|245.75|SE12| 237-244 |238.25|243.75|
+| |SR13| 246-254 |247.25|253.75|SE13| 244-251 |245.25|250.75|
+| |SR14| 254-262 |255.25|261.75|SE14| 251-258 |252.25|257.75|
+| |SR15| 262-270 |263.25|269.75|SE15| 258-265 |259.25|264.75|
+| |SR16| 270-278 |271.25|277.75|SE16| 265-272 |266.25|271.75|
+| |SR17| 278-286 |279.25|285.75|SE17| 272-279 |273.25|278.75|
+| |SR18| 286-294 |287.25|293.75|SE18| 279-286 |280.25|285.75|
+| | | | | |SE19| 286-293 |287.25|292.75|
+| | | | | |SE20| 293-300 |294.25|299.75|
++------+----+---------+------+------+----+---------+------+------+
+| H | | | | |S21 | 302-310 |303.25|308.75|
+| | | | | |S22 | 310-318 |311.25|316.75|
+| | | | | |S23 | 318-326 |319.25|324.75|
+| | | | | |S24 | 326-334 |327.25|332.75|
+| | | | | |S25 | 334-342 |335.25|340.75|
+| | | | | |S26 | 342-350 |343.25|348.75|
+| | | | | |S27 | 350-358 |351.25|356.75|
+| | | | | |S28 | 358-366 |359.25|364.75|
+| | | | | |S29 | 366-374 |367.25|372.75|
+| | | | | |S30 | 374-382 |375.25|380.75|
+| | | | | |S31 | 382-390 |383.25|388.75|
+| | | | | |S32 | 390-398 |391.25|396.75|
+| | | | | |S33 | 398-406 |399.25|404.75|
+| | | | | |S34 | 406-414 |407.25|412.75|
+| | | | | |S35 | 414-422 |415.25|420.75|
+| | | | | |S36 | 422-430 |423.25|428.75|
+| | | | | |S37 | 430-438 |431.25|436.75|
+| | | | | |S38 | 438-446 |439.25|444.75|
+| | | | | |S39 | 446-454 |447.25|452.75|
+| | | | | |S40 | 454-462 |455.25|460.75|
+| | | | | |S41 | 462-470 |463.25|468.75|
++------+----+---------+------+------+----+---------+------+------+
+| IV | 21 | 470-478 |471.25|477.75| 21 | 470-478 |471.25|476.75|
+| | 22 | 478-486 |479.25|485.75| 22 | 478-486 |479.25|484.75|
+| | 23 | 486-494 |487.25|493.75| 23 | 486-494 |487.25|492.75|
+| | 24 | 494-502 |495.25|501.75| 24 | 494-502 |495.25|500.75|
+| | 25 | 502-510 |503.25|509.75| 25 | 502-510 |503.25|508.75|
+| | 26 | 510-518 |511.25|517.75| 26 | 510-518 |511.25|516.75|
+| | 27 | 518-526 |519.25|525.75| 27 | 518-526 |519.25|524.75|
+| | 28 | 526-534 |527.25|533.75| 28 | 526-534 |527.25|532.75|
+| | 29 | 534-542 |535.25|541.75| 29 | 534-542 |535.25|540.75|
+| | 30 | 542-550 |543.25|549.75| 30 | 542-550 |543.25|548.75|
+| | 31 | 550-558 |551.25|557.75| 31 | 550-558 |551.25|556.75|
+| | 32 | 558-566 |559.25|565.75| 32 | 558-566 |559.25|564.75|
+| | 33 | 566-574 |567.25|573.75| 33 | 566-574 |567.25|572.75|
+| | 34 | 574-582 |575.25|581.75| 34 | 574-582 |575.25|580.75|
+| | 35 | 582-590 |583.25|589.75| 35 | 582-590 |583.25|588.75|
+| | 36 | 590-598 |591.25|597.75| 36 | 590-598 |591.25|596.75|
+| | 37 | 598-606 |599.25|605.75| 37 | 598-606 |599.25|604.75|
++------+----+---------+------+------+----+---------+------+------+
+| V | 38 | 606-614 |607.25|613.75| 38 | 606-614 |607.25|612.75|
+| | 39 | 614-622 |615.25|621.75| 39 | 614-622 |615.25|620.75|
+| | 40 | 622-630 |623.25|629.75| 40 | 622-630 |623.25|628.75|
+| | 41 | 630-638 |631.25|637.75| 41 | 630-638 |631.25|636.75|
+| | 42 | 638-646 |639.25|645.75| 42 | 638-646 |639.25|644.75|
+| | 43 | 646-654 |647.25|653.75| 43 | 646-654 |647.25|652.75|
+| | 44 | 654-662 |655.25|661.75| 44 | 654-662 |655.25|660.75|
+| | 45 | 662-670 |663.25|669.75| 45 | 662-670 |663.25|668.75|
+| | 46 | 670-678 |671.25|677.75| 46 | 670-678 |671.25|676.75|
+| | 47 | 678-686 |679.25|685.75| 47 | 678-686 |679.25|684.75|
+| | 48 | 686-694 |687.25|693.75| 48 | 686-694 |687.25|692.75|
+| | 49 | 694-702 |695.25|701.75| 49 | 694-702 |695.25|700.75|
+| | 50 | 702-710 |703.25|709.75| 50 | 702-710 |703.25|708.75|
+| | 51 | 710-718 |711.25|717.75| 51 | 710-718 |711.25|716.75|
+| | 52 | 718-726 |719.25|725.75| 52 | 718-726 |719.25|724.75|
+| | 53 | 726-734 |727.25|733.75| 53 | 726-734 |727.25|732.75|
+| | 54 | 734-742 |735.25|741.75| 54 | 734-742 |735.25|740.75|
+| | 55 | 742-750 |743.25|749.75| 55 | 742-750 |743.25|748.75|
+| | 56 | 750-758 |751.25|757.75| 56 | 750-758 |751.25|756.75|
+| | 57 | 758-766 |759.25|765.75| 57 | 758-766 |759.25|764.75|
+| | 58 | 766-774 |767.25|773.75| 58 | 766-774 |767.25|772.75|
+| | 59 | 774-782 |775.25|781.75| 59 | 774-782 |775.25|780.75|
+| | 60 | 782-790 |783.25|789.75| 60 | 782-790 |783.25|788.75|
+| | 61 | 790-798 |791.25|797.75| 61 | 790-798 |791.25|796.75|
+| | 62 | 798-806 |799.25|805.75| 62 | 798-806 |799.25|804.75|
+| | 63 | 806-814 |807.25|813.75| 63 | 806-814 |807.25|812.75|
+| | 64 | 814-822 |815.25|821.75| 64 | 814-822 |815.25|820.75|
+| | 65 | 822-830 |823.25|829.75| 65 | 822-830 |823.25|828.75|
+| | 66 | 830-838 |831.25|837.75| 66 | 830-838 |831.25|836.75|
+| | 67 | 838-846 |839.25|845.75| 67 | 838-846 |839.25|844.75|
+| | 68 | 846-854 |847.25|853.75| 68 | 846-854 |847.25|852.75|
+| | 69 | 854-862 |855.25|861.75| | | | |
+| | 70 | 862-870 |863.25|869.75| | | | |
+| | 71 | 870-878 |871.25|877.75| | | | |
+| | 72 | 878-886 |879.25|885.75| | | | |
+| | 73 | 886-894 |887.25|893.75| | | | |
+| | 74 | 894-902 |895.25|901.75| | | | |
+| | 75 | 902-910 |903.25|909.75| | | | |
+| | 76 | 910-918 |911.25|917.75| | | | |
+| | 77 | 918-926 |919.25|925.75| | | | |
+| | 78 | 926-934 |927.25|933.75| | | | |
+| | 79 | 934-942 |935.25|941.75| | | | |
+| | 80 | 942-950 |943.25|949.75| | | | |
+| | 81 | 950-958 |951.25|957.75| | | | |
++------+----+---------+------+------+----+---------+------+------+
diff --git a/contrib/frequencies-japan b/contrib/frequencies-japan
new file mode 100644
index 0000000..e2cce4a
--- /dev/null
+++ b/contrib/frequencies-japan
@@ -0,0 +1,72 @@
+From: Seizo Mikami <s-mikami@mbd.sphere.ne.jp>
+
+< ntsc-bcast-jp >
++------+----+-------+-------+
+| Band |Cha-| Vision| Sound |
+| |nnel| | |
++------+----+-------+-------+
+| VHF | 1 | 91.25| 95.75|
+| | 2 | 97.25| 101.75|
+| | 3 | 103.25| 107.75|
+| | 4 | 171.25| 175.75|
+| | 5 | 177.25| 181.75|
+| | 6 | 183.25| 187.75|
+| | 7 | 189.25| 193.75|
+| | 8 | 193.25| 197.75|
+| | 9 | 199.25| 203.75|
+| | 10 | 205.25| 209.75|
+| | 11 | 211.25| 215.75|
+| | 12 | 217.25| 221.75|
++------+----+-------+-------+
+| UHF | 13 | 417.25| 421.75|
+| | 14 | 477.25| 481.75|
+| | 15 | 483.25| 487.75|
+| | 16 | 489.25| 493.75|
+| | 17 | 495.25| 499.75|
+| | 18 | 501.25| 505.75|
+| | 19 | 507.25| 511.75|
+| | 20 | 513.25| 517.75|
+| | 21 | 519.25| 523.75|
+| | 22 | 525.25| 529.75|
+| | 23 | 531.25| 535.75|
+| | 24 | 537.25| 541.75|
+| | 25 | 543.25| 547.75|
+| | 26 | 549.25| 553.75|
+| | 27 | 555.25| 559.75|
+| | 28 | 561.25| 565.75|
+| | 29 | 567.25| 571.75|
+| | 30 | 573.25| 577.75|
+| | 31 | 579.25| 583.75|
+| | 32 | 585.25| 589.75|
+| | 33 | 591.25| 595.75|
+| | 34 | 597.25| 601.75|
+| | 35 | 603.25| 607.75|
+| | 36 | 609.25| 613.75|
+| | 37 | 615.25| 619.75|
+| | 38 | 621.25| 625.75|
+| | 39 | 627.25| 631.75|
+| | 40 | 633.25| 637.75|
+| | 41 | 639.25| 643.75|
+| | 42 | 645.25| 649.75|
+| | 43 | 651.25| 655.75|
+| | 44 | 657.25| 661.75|
+| | 45 | 663.25| 667.75|
+| | 46 | 669.25| 673.75|
+| | 47 | 675.25| 679.75|
+| | 48 | 681.25| 685.75|
+| | 49 | 687.25| 691.75|
+| | 50 | 693.25| 697.75|
+| | 51 | 699.25| 703.75|
+| | 52 | 705.25| 709.75|
+| | 53 | 711.25| 715.75|
+| | 54 | 717.25| 721.75|
+| | 55 | 723.25| 727.75|
+| | 56 | 729.25| 733.75|
+| | 57 | 735.25| 739.75|
+| | 58 | 741.25| 745.75|
+| | 59 | 747.25| 751.75|
+| | 60 | 753.25| 757.75|
+| | 61 | 759.25| 763.75|
+| | 62 | 765.25| 769.75|
++------+----+-------+-------+
+
diff --git a/contrib/hauppauge-eeprom b/contrib/hauppauge-eeprom
new file mode 100644
index 0000000..0fd4a6e
--- /dev/null
+++ b/contrib/hauppauge-eeprom
@@ -0,0 +1,147 @@
+From roger@cs.strath.ac.uk Mon Nov 30 22:45:25 1998
+Date: Mon, 30 Nov 1998 16:47:15 +0000
+From: Roger Hardiman <roger@cs.strath.ac.uk>
+To: olivier.lahaye@cea.fr, roger@cs.strath.ac.uk
+Cc: kraxel@goldbach.in-berlin.de, video4linux@phunk.org
+Subject: Roger's complete Hauppauge EEPROM info
+
+Olivier, Gerd and V4L developers.
+
+Here is my list of the Hauppauge EEPROM contents which I built up for
+the
+FreeBSD bt848 driver.
+
+If you want further details, I can provide about 20 EEPROM contents
+dumps from
+different USA and European cards.
+I also have email contacts inside Hauppauge who can supply info when we
+require it.
+Special thanks to Steve Passe, Amancio Hasty and Randall Hopper and all
+the others
+who send in EEPROM contents to me or to the FreeBSD multimedia list.
+
+There are 5 datablocks, each can vary in size.
+
+Block 1
+=======
+This is of the format
+84 11 00 00 04 followed by 15 bytes
+or
+84 12 00 00 05 followed by 16 bytes
+
+In this block,
+byte 6 is the chipset type (see below)
+byte 9 is the tuner type (see below)
+byte 11 and 12 are the model number
+I'm sure byte 13 is the revision but I cannot decode it.
+
+There is also a byte which reports the ability to get Radio but I've
+forgotten it.
+
+
+Block 2
+=======
+84 0a 00 01 01 20 77 00 40
+This seems to be common for all cards
+
+Block 3
+=======
+84 then 3 bytes
+Bytes 1,2 and 3 are the serial number
+
+Block 4
+=======
+This varies if you have No Stereo decoder, TDA decoder or MSP decoder
+Within this block, byte 3 tells us the stereo decoder chip type (or no
+stereo decoder)
+
+If byte 3 is 00 == No stereo decoder chip. The block is 5 bytes. EG.
+74 02 01 00 03
+
+If byte 3 indicates a MSP chip, the block is 5 bytes, EG
+74 02 01 06 02
+
+If byte 3 indicates a TDA chip, the block is 8 bytes, EG
+77 02 01 03 03 43 17 12
+byte 5, 6 and 7 are used in programming the TDA (the TDA dbx alignment
+bytes).
+Each TDA chip needs different values found during card calibration at
+Hauppage.
+
+
+Block 5
+=======
+This is
+79 followed by a one byte checksum
+
+Free Space
+==========
+the remainer of the eeprom is either filled with 00 or with ff.
+
+
+
+Missing Info
+------------
+I cannot work out the bits which tell me
+a) presence of SVIDEO
+b) presence of Teletext decoder
+
+The decode table you need for the chip type, tuner type and steroe chip
+are
+Chipset byte
+0 Reserved
+1 BT815
+2 BT817
+3 BT819
+4 BT815A
+5 BT817A
+6 BT819A
+7 BT827
+8 BT829
+9 BT848
+a BT848A
+b BT849A
+c BT829A
+d BT827A
+e BT878
+f BT879
+10 BT880
+
+BUT only 0x09 and 0x0e have been used.
+
+
+Tuner Byte
+ 1 External
+ 2 Unspecified
+ 3 Phillips FI1216
+ 4 Phillips FI1216MF
+ 5 Phillips FI1236
+ 6 Phillips FI1246
+ 7 Phillips FI1256
+ 8 Phillips FI1216 MK2
+ 9 Phillips FI1216MF MK2
+ a Phillips FI1236 MK2
+ b Phillips FI1246 MK2
+ c Phillips FI1256 MK2
+ d Temic 4032FY5
+ e Temic 4002FH5
+ f Temic 4062FY5
+ 10 Phillips FR1216 MK2
+ 11 Phillips FR1216MF MK2
+ 12 Phillips FR1236 MK2
+ 13 Phillips FR1246 MK2
+ 14 Phillips FR1256 MK2
+ 15 Phillips FM1216
+ 16 Phillips FM1216MF
+ 17 Phillips FM1236
+ 18 Temic ???
+
+Stereo Decoder byte
+0 None
+1 TEA6300
+2 TEA6320
+3 TDA9850
+4 MSP3400C
+5 MSP3410D
+6 MSP3415
+7 MSP3430
diff --git a/contrib/mash/README b/contrib/mash/README
new file mode 100644
index 0000000..9b92bf1
--- /dev/null
+++ b/contrib/mash/README
@@ -0,0 +1,33 @@
+From hankm@netvideo.com Tue Aug 4 22:29:52 1998
+Date: Thu, 30 Jul 1998 16:47:28 -0700
+From: hankm@netvideo.com, Hank Magnuski <hankm@netvideo.com>
+To: mash-developers@mash.cs.berkeley.edu, rowe@bmrc.berkeley.edu
+Cc: kraxel@cs.tu-berlin.de, alan@cymru.net
+Subject: Video4Linux BTTV(Bt848) Driver for Mash
+
+I've taken the video-grabber code developed by
+Gerd Knorr and have Mashified it so that there is
+now a new Video-4-Linux BTTV (Bt848) video capture
+driver available for the Mash development environment.
+
+See
+
+ http://user.cs.tu-berlin.de/~kraxel/linux/
+
+under the section "Xawtv" for the low level BTTV driver
+that this package calls.
+
+You can, for example, construct a Mash version of Vic
+using this new code. More information on Mash is at
+
+ http://www-mash.cs.berkeley.edu/mash/
+
+Since I'm not a regular Mash developer (which is to say
+once step above clueless) any feedback or error reports
+would be appreciated.
+
+Hank
+
+ [Part 2, Application/X-GZIP 7.7KB]
+ [Unable to print this part]
+
diff --git a/fbtv.c b/fbtv.c
deleted file mode 100644
index 3cb0c19..0000000
--- a/fbtv.c
+++ /dev/null
@@ -1,659 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <time.h>
-#include <fcntl.h>
-#include <termios.h>
-#include <signal.h>
-#include <ctype.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <linux/fb.h>
-#include <X11/Intrinsic.h>
-#include <curses.h>
-
-#include "config.h"
-
-#ifdef HAVE_LIBJPEG
-# include "jpeglib.h"
-#endif
-
-#include "mixer.h"
-#include "channel.h"
-#include "channels.h"
-#include "grab.h"
-
-#define MAX(x,y) ((x)>(y)?(x):(y))
-#define MIN(x,y) ((x)<(y)?(x):(y))
-
-#define DEFAULT_DEVICE "/dev/fb0"
-
-/* ---------------------------------------------------------------------- */
-/* framebuffer */
-
-char *fbdev = NULL;
-int fd;
-struct fb_fix_screeninfo fix;
-struct fb_var_screeninfo var;
-unsigned char *map;
-
-unsigned short red[256], green[256], blue[256];
-unsigned short ored[256], ogreen[256], oblue[256];
-struct fb_cmap cmap = { 0, 256, red, green, blue };
-struct fb_cmap ocmap = { 0, 256, ored, ogreen, oblue };
-
-int x11_native_format,have_dga=1;
-int debug,sig;
-int fs_width,fs_height,fs_xoff,fs_yoff,pix_width,pix_height;
-int ww,hh;
-
-/* ---------------------------------------------------------------------- */
-
-/* PAL NTSC SECAM */
-static int maxwidth[] = { 768, 640, 768 };
-static int maxheight[] = { 576, 480, 576 };
-static int maxx,maxy /* current */;
-
-/*--- drivers -------------------------------------------------------------*/
-
-char *device = "/dev/video";
-
-extern struct GRABBER grab_v4l;
-struct GRABBER *grabbers[] = {
- &grab_v4l,
-};
-
-int grabber;
-
-/*--- channels ------------------------------------------------------------*/
-
-struct STRTAB *cmenu = NULL;
-char title[256];
-
-int cur_color;
-int cur_bright;
-int cur_hue;
-int cur_contrast;
-int cur_capture;
-
-int cur_mute = 0;
-int cur_volume = 65535;
-
-char *ppmfile;
-char *jpegfile;
-
-/* ---------------------------------------------------------------------- */
-
-void
-fb_gray_palette()
-{
- int i;
-
- for (i = 0; i < 256; i++) {
- red[i] = i * 255;
- green[i] = i * 255;
- blue[i] = i * 255;
- }
-}
-
-void
-fb_dither_palette(int r, int g, int b)
-{
- int rs, gs, bs, i;
-
- rs = 256 / (r - 1);
- gs = 256 / (g - 1);
- bs = 256 / (b - 1);
- for (i = 0; i < 256-16; i++) {
- green[i+16] = (gs * ((i / (r * b)) % g)) * 255;
- red[i+16] = (rs * ((i / b) % r)) * 255;
- blue[i+16] = (bs * ((i) % b)) * 255;
- }
-}
-
-void
-fb_cleanup(void)
-{
- if (var.bits_per_pixel == 8)
- if (-1 == ioctl(fd,FBIOPUTCMAP,&ocmap))
- perror("ioctl FBIOPUTCMAP");
- endwin();
-}
-
-void
-fb_init(int gray)
-{
- /* init framebuffer */
- if (-1 == (fd = open(fbdev,O_RDWR))) {
- fprintf(stderr,"open %s: %s\n",fbdev,strerror(errno));
- exit(1);
- }
- if (-1 == ioctl(fd,FBIOGET_FSCREENINFO,&fix)) {
- perror("ioctl FBIOGET_FSCREENINFO");
- exit(1);
- }
- if (-1 == ioctl(fd,FBIOGET_VSCREENINFO,&var)) {
- perror("ioctl FBIOGET_VSCREENINFO");
- exit(1);
- }
- if (fix.type != FB_TYPE_PACKED_PIXELS) {
- fprintf(stderr,"can handle only packed pixel frame buffers\n");
- exit(1);
- }
- map = mmap(NULL,fix.smem_len,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);
- if (-1 == (int)map) {
- perror("mmap");
- exit(1);
- }
- switch (var.bits_per_pixel) {
- case 8:
- if (-1 == ioctl(fd,FBIOGETCMAP,&ocmap))
- perror("ioctl FBIOGETCMAP");
- if (-1 == ioctl(fd,FBIOGETCMAP,&cmap))
- perror("ioctl FBIOGETCMAP");
- if (gray) {
- fb_gray_palette();
- x11_native_format = VIDEO_GRAY;
- } else {
- fb_dither_palette(5,9,5);
- x11_native_format = VIDEO_RGB08;
- }
- if (-1 == ioctl(fd,FBIOPUTCMAP,&cmap))
- perror("ioctl FBIOPUTCMAP");
- break;
- case 15:
- case 16:
- x11_native_format = (var.green.length == 6) ?
- VIDEO_RGB16 : VIDEO_RGB15;
- break;
- case 24:
- x11_native_format = VIDEO_RGB24;
- break;
- case 32:
- x11_native_format = VIDEO_RGB32;
- break;
- default:
- fprintf(stderr, "Oops: %i bit/pixel ???\n",
- var.bits_per_pixel);
- exit(1);
- }
-
- initscr();
- cbreak();
- noecho();
- keypad(stdscr,1);
- refresh();
-}
-
-/* ---------------------------------------------------------------------- */
-
-void
-ctrlc(int signal)
-{
- sig=1;
-}
-
-void
-change_audio(int mode)
-{
- if (grabbers[grabber]->grab_audio)
- grabbers[grabber]->grab_audio(-1,-1,&mode);
-}
-
-void set_capture(int j)
-{
- int x,y,w,h;
- cur_capture = j;
-
- if (j) {
- if (ww && hh) {
- w = ww;
- h = hh;
- x = var.xres_virtual-w;
- y = 0;
- } else {
- w = MIN(var.xres_virtual,maxx);
- h = MIN(var.yres_virtual,maxy);
- x = (var.xres_virtual-w)/2;
- y = (var.yres_virtual-h)/2;
- }
- grabbers[grabber]->grab_overlay(x,y,w,h,x11_native_format,NULL,0);
- } else
- grabbers[grabber]->grab_overlay(0,0,0,0,0,NULL,0);
-}
-
-void set_norm(int j)
-{
- cur_norm = j;
-
- grabbers[grabber]->grab_input(-1,cur_norm);
- maxx = maxwidth[cur_norm];
- maxy = maxheight[cur_norm];
-}
-
-void set_source(int j)
-{
- cur_input = j;
-
- grabbers[grabber]->grab_input(cur_input,-1);
-}
-
-void set_freqtab(int j)
-{
- chan_tab = j;
-}
-
-void
-set_picparams(int color, int bright, int hue, int contrast)
-{
- if (color != -1)
- cur_color = color;
- if (bright != -1)
- cur_bright = bright;
- if (hue != -1)
- cur_hue = hue;
- if (contrast != -1)
- cur_contrast = contrast;
- grabbers[grabber]->grab_picture(cur_color,cur_bright,cur_hue,cur_contrast);
-}
-
-void
-set_channel(struct CHANNEL *channel)
-{
- /* image parameters */
- set_picparams(channel->color, channel->bright,
- channel->hue, channel->contrast);
-