summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2006-03-16 20:37:51 -0500
committerMichael Krufky <mkrufky@linuxtv.org>2006-03-16 20:37:51 -0500
commitd30a31decd05aa55764418cce0b9cce695885439 (patch)
tree8fffef97b8b6d19639ed547eb7d6253b0f336e48
parente0449a4964c2aec77cf02c33d2a9375b647530ce (diff)
parent32027c8007a8b9e82f70f5eb52387db827ff8b2d (diff)
downloadmediapointer-dvb-s2-d30a31decd05aa55764418cce0b9cce695885439.tar.gz
mediapointer-dvb-s2-d30a31decd05aa55764418cce0b9cce695885439.tar.bz2
merged ~mkrufky/pending
From: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
-rw-r--r--README.HG75
-rw-r--r--linux/Documentation/video4linux/CARDLIST.cx881
-rw-r--r--linux/Documentation/video4linux/CARDLIST.saa71345
-rw-r--r--linux/Documentation/video4linux/CARDLIST.tuner5
-rw-r--r--linux/Documentation/video4linux/README.cpia22
-rw-r--r--linux/Documentation/video4linux/README.pvrusb2 (renamed from v4l_experimental/pvrusb2/README)2
-rw-r--r--linux/drivers/media/common/saa7146_core.c3
-rw-r--r--linux/drivers/media/common/saa7146_fops.c11
-rw-r--r--linux/drivers/media/common/saa7146_vbi.c8
-rw-r--r--linux/drivers/media/common/saa7146_video.c8
-rw-r--r--linux/drivers/media/dvb/cinergyT2/cinergyT2.c4
-rw-r--r--linux/drivers/media/dvb/dvb-core/demux.h2
-rw-r--r--linux/drivers/media/dvb/dvb-core/dmxdev.c692
-rw-r--r--linux/drivers/media/dvb/dvb-core/dmxdev.h22
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_frontend.h1
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.c2
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.h1
-rw-r--r--linux/drivers/media/dvb/dvb-usb/dtt200u.c4
-rw-r--r--linux/drivers/media/dvb/dvb-usb/dvb-usb-init.c2
-rw-r--r--linux/drivers/media/dvb/dvb-usb/dvb-usb.h2
-rw-r--r--linux/drivers/media/dvb/dvb-usb/vp7045.c2
-rw-r--r--linux/drivers/media/dvb/frontends/Kconfig12
-rw-r--r--linux/drivers/media/dvb/frontends/Makefile1
-rw-r--r--linux/drivers/media/dvb/frontends/bsbe1.h123
-rw-r--r--linux/drivers/media/dvb/frontends/dvb-pll.c15
-rw-r--r--linux/drivers/media/dvb/frontends/dvb-pll.h2
-rw-r--r--linux/drivers/media/dvb/frontends/lnbp21.h139
-rw-r--r--linux/drivers/media/dvb/frontends/zl10353.c323
-rw-r--r--linux/drivers/media/dvb/frontends/zl10353.h43
-rw-r--r--linux/drivers/media/dvb/frontends/zl10353_priv.h42
-rw-r--r--linux/drivers/media/dvb/ttpci/av7110.c122
-rw-r--r--linux/drivers/media/dvb/ttpci/av7110_hw.c3
-rw-r--r--linux/drivers/media/dvb/ttpci/budget-ci.c18
-rw-r--r--linux/drivers/media/dvb/ttpci/budget.c152
-rw-r--r--linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c3
-rw-r--r--linux/drivers/media/video/Kconfig64
-rw-r--r--linux/drivers/media/video/Makefile15
-rw-r--r--linux/drivers/media/video/bttv-cards.c10
-rw-r--r--linux/drivers/media/video/bttv-driver.c19
-rw-r--r--linux/drivers/media/video/bttv-risc.c9
-rw-r--r--linux/drivers/media/video/bttv-vbi.c6
-rw-r--r--linux/drivers/media/video/bttvp.h3
-rw-r--r--linux/drivers/media/video/compat_ioctl32.c89
-rw-r--r--linux/drivers/media/video/cpia2/Kconfig9
-rw-r--r--linux/drivers/media/video/cpia2/cpia2_v4l.c31
-rw-r--r--linux/drivers/media/video/cx25840/Kconfig9
-rw-r--r--linux/drivers/media/video/cx25840/Makefile2
-rw-r--r--linux/drivers/media/video/cx88/Kconfig39
-rw-r--r--linux/drivers/media/video/cx88/Makefile1
-rw-r--r--linux/drivers/media/video/cx88/cx88-alsa.c14
-rw-r--r--linux/drivers/media/video/cx88/cx88-blackbird.c5
-rw-r--r--linux/drivers/media/video/cx88/cx88-cards.c82
-rw-r--r--linux/drivers/media/video/cx88/cx88-core.c9
-rw-r--r--linux/drivers/media/video/cx88/cx88-dvb.c113
-rw-r--r--linux/drivers/media/video/cx88/cx88-input.c1
-rw-r--r--linux/drivers/media/video/cx88/cx88-mpeg.c65
-rw-r--r--linux/drivers/media/video/cx88/cx88-vbi.c7
-rw-r--r--linux/drivers/media/video/cx88/cx88-video.c52
-rw-r--r--linux/drivers/media/video/cx88/cx88.h9
-rw-r--r--linux/drivers/media/video/dpc7146.c402
-rw-r--r--linux/drivers/media/video/em28xx/Kconfig1
-rw-r--r--linux/drivers/media/video/em28xx/em28xx-video.c267
-rw-r--r--linux/drivers/media/video/font.h407
-rw-r--r--linux/drivers/media/video/hexium_gemini.c557
-rw-r--r--linux/drivers/media/video/hexium_orion.c523
-rw-r--r--linux/drivers/media/video/msp3400-kthreads.c6
-rw-r--r--linux/drivers/media/video/msp3400.h1
-rw-r--r--linux/drivers/media/video/mxb.c1037
-rw-r--r--linux/drivers/media/video/mxb.h42
-rw-r--r--linux/drivers/media/video/pvrusb2/Kconfig14
-rw-r--r--linux/drivers/media/video/pvrusb2/Makefile11
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-audio.c (renamed from v4l_experimental/pvrusb2/pvrusb2-audio.c)6
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-audio.h (renamed from v4l_experimental/pvrusb2/pvrusb2-audio.h)2
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-context.c (renamed from v4l_experimental/pvrusb2/pvrusb2-context.c)10
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-context.h (renamed from v4l_experimental/pvrusb2/pvrusb2-context.h)3
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-debug.h (renamed from v4l_experimental/pvrusb2/pvrusb2-debug.h)4
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-debugifc.c (renamed from v4l_experimental/pvrusb2/pvrusb2-debugifc.c)28
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-debugifc.h (renamed from v4l_experimental/pvrusb2/pvrusb2-debugifc.h)2
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-demod.c (renamed from v4l_experimental/pvrusb2/pvrusb2-demod.c)2
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-demod.h (renamed from v4l_experimental/pvrusb2/pvrusb2-demod.h)2
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-eeprom.c (renamed from v4l_experimental/pvrusb2/pvrusb2-eeprom.c)48
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-eeprom.h (renamed from v4l_experimental/pvrusb2/pvrusb2-eeprom.h)2
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-encoder.c (renamed from v4l_experimental/pvrusb2/pvrusb2-encoder.c)8
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-encoder.h (renamed from v4l_experimental/pvrusb2/pvrusb2-encoder.h)2
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h (renamed from v4l_experimental/pvrusb2/pvrusb2-hdw-internal.h)18
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-hdw.c (renamed from v4l_experimental/pvrusb2/pvrusb2-hdw.c)393
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-hdw.h (renamed from v4l_experimental/pvrusb2/pvrusb2-hdw.h)38
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c (renamed from v4l_experimental/pvrusb2/pvrusb2-i2c-chips-v4l2.c)7
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c (renamed from v4l_experimental/pvrusb2/pvrusb2-i2c-cmd-v4l2.c)23
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.h (renamed from v4l_experimental/pvrusb2/pvrusb2-i2c-cmd-v4l2.h)3
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c (renamed from v4l_experimental/pvrusb2/pvrusb2-i2c-core.c)49
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.h (renamed from v4l_experimental/pvrusb2/pvrusb2-i2c-core.h)2
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-io.c (renamed from v4l_experimental/pvrusb2/pvrusb2-io.c)20
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-io.h (renamed from v4l_experimental/pvrusb2/pvrusb2-io.h)8
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-ioread.c (renamed from v4l_experimental/pvrusb2/pvrusb2-ioread.c)2
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-ioread.h (renamed from v4l_experimental/pvrusb2/pvrusb2-ioread.h)2
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-main.c (renamed from v4l_experimental/pvrusb2/pvrusb2-main.c)17
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.c (renamed from v4l_experimental/pvrusb2/pvrusb2-sysfs.c)19
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.h (renamed from v4l_experimental/pvrusb2/pvrusb2-sysfs.h)4
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-tuner.c (renamed from v4l_experimental/pvrusb2/pvrusb2-tuner.c)2
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-tuner.h (renamed from v4l_experimental/pvrusb2/pvrusb2-tuner.h)2
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-util.h (renamed from v4l_experimental/pvrusb2/pvrusb2-util.h)18
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c (renamed from v4l_experimental/pvrusb2/pvrusb2-v4l2.c)36
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.h (renamed from v4l_experimental/pvrusb2/pvrusb2-v4l2.h)2
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c (renamed from v4l_experimental/pvrusb2/pvrusb2-video-v4l.c)6
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-video-v4l.h (renamed from v4l_experimental/pvrusb2/pvrusb2-video-v4l.h)2
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2.h (renamed from v4l_experimental/pvrusb2/pvrusb2.h)2
-rw-r--r--linux/drivers/media/video/saa7115.c107
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-alsa.c13
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-cards.c128
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-core.c28
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-oss.c12
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-ts.c9
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-vbi.c10
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-video.c12
-rw-r--r--linux/drivers/media/video/saa7134/saa7134.h5
-rw-r--r--linux/drivers/media/video/tda9840.c263
-rw-r--r--linux/drivers/media/video/tda9840.h35
-rw-r--r--linux/drivers/media/video/tea6415c.c232
-rw-r--r--linux/drivers/media/video/tea6415c.h39
-rw-r--r--linux/drivers/media/video/tea6420.c209
-rw-r--r--linux/drivers/media/video/tea6420.h17
-rw-r--r--linux/drivers/media/video/tuner-simple.c3
-rw-r--r--linux/drivers/media/video/tuner-types.c74
-rw-r--r--linux/drivers/media/video/v4l2-common.c6
-rw-r--r--linux/drivers/media/video/video-buf.c277
-rw-r--r--linux/drivers/media/video/vivi.c1543
-rw-r--r--linux/include/linux/dvb/video.h2
-rw-r--r--linux/include/linux/videodev2.h2
-rw-r--r--linux/include/media/saa7146_vv.h3
-rw-r--r--linux/include/media/tuner.h5
-rw-r--r--linux/include/media/v4l2-common.h1
-rw-r--r--linux/include/media/video-buf.h56
-rwxr-xr-xmailimport167
-rw-r--r--v4l/Make.config12
-rw-r--r--v4l/Makefile39
-rwxr-xr-xv4l/scripts/hghead.pl152
-rwxr-xr-xv4l/scripts/insmod.sh5
-rwxr-xr-xv4l/scripts/make_kconfig.pl37
-rwxr-xr-xv4l/scripts/usbaudio_setup.sh106
-rw-r--r--v4l_experimental/cx88-ivtv.c6
-rw-r--r--v4l_experimental/pvrusb2/.cvsignore7
-rw-r--r--v4l_experimental/pvrusb2/Makefile10
143 files changed, 8569 insertions, 1640 deletions
diff --git a/README.HG b/README.HG
index 77576602e..e661d493a 100644
--- a/README.HG
+++ b/README.HG
@@ -1,52 +1,53 @@
-Mauro Carvalho Chehab 2006 Jan 30
+Mauro Carvalho Chehab 2006 Mar 8
-This file describes the general procedures used by v4l-dvb maintainers.
-Some of these also applies to patch submitters.
+This file describes the general procedures used by v4l-dvb developers
+who are responsible for maintaining V4L/DVB drivers. Some of these
+also applies to patch submitters.
-We've moved from cvs to a modern SCM system that fits better into
+Current V4L/DVB tree uses a modern SCM system that fits better into
kernel development model, called Mercurial (aka hg).
-At http://selenic.com/mercurial you'll find quick-start info, a
-tutorial and FAQs.
+There are some tutorials, FAQs and other valuable informations at
+http://selenic.com/mercurial
Mercurial is a distributed SCM, which means every developer gets his
own full copy of the repository (including the complete revision
history), and can work and commit locally without network connection.
The resulting changesets can then be exchanged between repositories and
-finally published to the master repository in linuxtv.org.
+finally published to the master repository in linuxtv.org. A list of
+current available repositories is available at: http://linuxtv.org/hg
+
+The master repository with stable patches is available at:
+http://linuxtv/org/hg/v4l-dvb
Mercurial is organized with a master tag, called tip. This tag contains
the master repository that will be used by normal users and to generate
patches to kernel.
-The v4l-dvb mercurial repository is meant for development. It means
-that it might be broken from time to time, although all efforts should
-be done to avoid this. There are more "stable" snapshots at
-http://www.linuxtv.org/downloads/snapshot page.
-
-This file postulates some simple rules for maintaing hg tree, as stated
+This file postulates some simple rules for maintaing hg trees, as stated
below:
1) It is strongly recommended that each developer be active at IRC
channels (irc://irc.freenode.net) #v4l (for analog) and/or #linuxtv
(for digital). It helps to have more discussions at major changes;
-2) Minor changes, like simple card additions (for example a new card
- row at a card struct) can be applied directly by each developer;
+2) Each developer may have one or more development trees, for his daily
+ work. It is recommended to have a tree called 'v4l-dvb' for each
+ developer with their stable patches.
-3) Medium changes that needs modification on card coding or creating a
- new card type should be discussed first at the Mailing Lists
- video4linux-list@redhat.com (analog/common parts) and/or
- linux-dvb@linuxtv.org to allow other contributors to discuss about
- the way it will be included.
+3) After the patches are ready, developer should send an email to
+ v4l-dvb-maintainer list asking the maintainer to pull it from developer
+ repository, pushing it at master. The maintainer will analyse the patch
+ and publish at master hg if everything looks ok.
-4) Major changes that implies changing some core structs should be
- widely discussed on IRC, posted to the list, created a snapshot THEN
- committed to the tip branch. It is strongly recommended to use a branch
- or v4l_experimental area for such changes.
+4) Medium or major changes that needs modification on card coding, creating a
+ new card type or requiring changes at core structs should be discussed first
+ at the Mailing Lists video4linux-list@redhat.com (analog/common parts)
+ and/or linux-dvb@linuxtv.org and at IRC to allow other contributors to
+ discuss about the way it will be included.
-5) Every CVS maintainer should follow the "rules of thumb" of kernel
- development stated at Linux source code, especially:
+5) Every developer should follow the "rules of thumb" of kernel development
+ stated at Linux source code, especially:
Documentation/SubmittingPatches
Documentation/SubmittingDrivers
@@ -66,7 +67,7 @@ below:
hg add <files>
hg remove <files>
hg rename <source> <dest>
- hg addremove
+ hg addremove [<files>]
*Warning* hg addremove will add/removes all files, including object
files. Be careful! You can remove wrongly added files with hg remove.
@@ -79,14 +80,19 @@ below:
This command will preserve the changes at the files. So, a new
hg commit will redo the desired commit.
-9) To push the change to the *MASTER* repository you need to run:
+9) To push the change to the repository you need to run:
- make push
+ hg push <url>
10) To update from the master repository, it is needed to do:
make pull
+ After pulling from master, if there are some changes at local repository,
+ hg will require to merge it. This is done by
+ hg update -m
+ make commit
+
11) For hg to work properly, these vars should be defined (replacing
the names at the left):
@@ -185,7 +191,16 @@ below:
since the macro preprocessing script used to prepare kernel upstream
patches (v4l/scripts/gentree.pl) is not able to handle it.
-Cheers,
+18) To import contributed stuff, a script is provided at tree and allows easy
+ import of a mbox-based patch emails. This is done with:
+ ./mailimport <mbox file>
+ For it to work properly, git tools need to be installed at local machine,
+ since git have a gitimport script that is used by mailimport.
+ Also, hg have a feature, called mqueue, that allows having several patches
+ that can be applied/unapplied for testing. mailimport trusts on it to work,
+ so, this extension should be enabled for mailimport script to work.
+
+Good Work!
Mauro
Mauro Carvalho Chehab <mchehab .at. linuxtv .dot. org>
diff --git a/linux/Documentation/video4linux/CARDLIST.cx88 b/linux/Documentation/video4linux/CARDLIST.cx88
index d852ad4f9..3b39a91b2 100644
--- a/linux/Documentation/video4linux/CARDLIST.cx88
+++ b/linux/Documentation/video4linux/CARDLIST.cx88
@@ -44,3 +44,4 @@
43 -> KWorld/VStream XPert DVB-T with cx22702 [17de:08a1]
44 -> DViCO FusionHDTV DVB-T Dual Digital [18ac:db50,18ac:db54]
45 -> KWorld HardwareMpegTV XPert [17de:0840]
+ 46 -> DViCO FusionHDTV DVB-T Hybrid [18ac:db40,18ac:db44]
diff --git a/linux/Documentation/video4linux/CARDLIST.saa7134 b/linux/Documentation/video4linux/CARDLIST.saa7134
index 17ea5a031..8c7195455 100644
--- a/linux/Documentation/video4linux/CARDLIST.saa7134
+++ b/linux/Documentation/video4linux/CARDLIST.saa7134
@@ -86,6 +86,9 @@
85 -> AverTV DVB-T 777 [1461:2c05]
86 -> LifeView FlyDVB-T [5168:0301]
87 -> ADS Instant TV Duo Cardbus PTV331 [0331:1421]
- 88 -> Tevion DVB-T 220RF [17de:7201]
+ 88 -> Tevion/KWorld DVB-T 220RF [17de:7201]
89 -> ELSA EX-VISION 700TV [1048:226c]
90 -> Kworld ATSC110 [17de:7350]
+ 91 -> AVerMedia A169 B [1461:7360]
+ 92 -> AVerMedia A169 B1 [1461:6360]
+ 93 -> Medion 7134 Bridge #2 [16be:0005]
diff --git a/linux/Documentation/video4linux/CARDLIST.tuner b/linux/Documentation/video4linux/CARDLIST.tuner
index de48438d5..1bcdac67d 100644
--- a/linux/Documentation/video4linux/CARDLIST.tuner
+++ b/linux/Documentation/video4linux/CARDLIST.tuner
@@ -64,9 +64,10 @@ tuner=62 - Philips TEA5767HN FM Radio
tuner=63 - Philips FMD1216ME MK3 Hybrid Tuner
tuner=64 - LG TDVS-H062F/TUA6034
tuner=65 - Ymec TVF66T5-B/DFF
-tuner=66 - LG NTSC (TALN mini series)
+tuner=66 - LG TALN series
tuner=67 - Philips TD1316 Hybrid Tuner
tuner=68 - Philips TUV1236D ATSC/NTSC dual in
-tuner=69 - Tena TNF 5335 MF
+tuner=69 - Tena TNF 5335 and similar models
tuner=70 - Samsung TCPN 2121P30A
tuner=71 - Xceive xc3028
+tuner=72 - Thomson FE6600
diff --git a/linux/Documentation/video4linux/README.cpia2 b/linux/Documentation/video4linux/README.cpia2
index f3bd3439a..ce8213d28 100644
--- a/linux/Documentation/video4linux/README.cpia2
+++ b/linux/Documentation/video4linux/README.cpia2
@@ -70,7 +70,7 @@ line like this:
If the driver is compiled into the kernel, at boot time specify them
like this:
- cpia2=num_buffers:3,buffer_size:65535
+ cpia2.num_buffers=3 cpia2.buffer_size=65535
What buffer size should I use?
------------------------------
diff --git a/v4l_experimental/pvrusb2/README b/linux/Documentation/video4linux/README.pvrusb2
index 073491307..c73a32c34 100644
--- a/v4l_experimental/pvrusb2/README
+++ b/linux/Documentation/video4linux/README.pvrusb2
@@ -1,5 +1,5 @@
-$Id: README,v 1.2 2006/01/01 08:26:03 mcisely Exp $
+$Id$
Mike Isely <isely@pobox.com>
pvrusb2 driver
diff --git a/linux/drivers/media/common/saa7146_core.c b/linux/drivers/media/common/saa7146_core.c
index 71a5f1329..4233c2c2b 100644
--- a/linux/drivers/media/common/saa7146_core.c
+++ b/linux/drivers/media/common/saa7146_core.c
@@ -116,8 +116,7 @@ static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages)
pg = vmalloc_to_page(virt);
if (NULL == pg)
goto err;
- if (PageHighMem(pg))
- BUG();
+ BUG_ON(PageHighMem(pg));
sglist[i].page = pg;
sglist[i].length = PAGE_SIZE;
}
diff --git a/linux/drivers/media/common/saa7146_fops.c b/linux/drivers/media/common/saa7146_fops.c
index 480a34a26..2dde5a240 100644
--- a/linux/drivers/media/common/saa7146_fops.c
+++ b/linux/drivers/media/common/saa7146_fops.c
@@ -38,8 +38,7 @@ void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits)
struct saa7146_dev *dev = fh->dev;
struct saa7146_vv *vv = dev->vv_data;
- if ((fh->resources & bits) != bits)
- BUG();
+ BUG_ON((fh->resources & bits) != bits);
mutex_lock(&dev->lock);
fh->resources &= ~bits;
@@ -52,15 +51,15 @@ void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits)
/********************************************************************************/
/* common dma functions */
-void saa7146_dma_free(struct saa7146_dev *dev,struct saa7146_buf *buf)
+void saa7146_dma_free(struct saa7146_dev *dev,struct videobuf_queue *q,
+ struct saa7146_buf *buf)
{
DEB_EE(("dev:%p, buf:%p\n",dev,buf));
- if (in_interrupt())
- BUG();
+ BUG_ON(in_interrupt());
videobuf_waiton(&buf->vb,0,0);
- videobuf_dma_pci_unmap(dev->pci, &buf->vb.dma);
+ videobuf_dma_unmap(q, &buf->vb.dma);
videobuf_dma_free(&buf->vb.dma);
buf->vb.state = STATE_NEEDS_INIT;
}
diff --git a/linux/drivers/media/common/saa7146_vbi.c b/linux/drivers/media/common/saa7146_vbi.c
index 3d403a760..510594fbd 100644
--- a/linux/drivers/media/common/saa7146_vbi.c
+++ b/linux/drivers/media/common/saa7146_vbi.c
@@ -237,7 +237,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e
}
if (buf->vb.size != size)
- saa7146_dma_free(dev,buf);
+ saa7146_dma_free(dev,q,buf);
if (STATE_NEEDS_INIT == buf->vb.state) {
buf->vb.width = llength;
@@ -248,7 +248,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e
saa7146_pgtable_free(dev->pci, &buf->pt[2]);
saa7146_pgtable_alloc(dev->pci, &buf->pt[2]);
- err = videobuf_iolock(dev->pci,&buf->vb, NULL);
+ err = videobuf_iolock(q,&buf->vb, NULL);
if (err)
goto oops;
err = saa7146_pgtable_build_single(dev->pci, &buf->pt[2], buf->vb.dma.sglist, buf->vb.dma.sglen);
@@ -262,7 +262,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e
oops:
DEB_VBI(("error out.\n"));
- saa7146_dma_free(dev,buf);
+ saa7146_dma_free(dev,q,buf);
return err;
}
@@ -302,7 +302,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
struct saa7146_buf *buf = (struct saa7146_buf *)vb;
DEB_VBI(("vb:%p\n",vb));
- saa7146_dma_free(dev,buf);
+ saa7146_dma_free(dev,q,buf);
}
static struct videobuf_queue_ops vbi_qops = {
diff --git a/linux/drivers/media/common/saa7146_video.c b/linux/drivers/media/common/saa7146_video.c
index 4f1ccaee7..e24edb892 100644
--- a/linux/drivers/media/common/saa7146_video.c
+++ b/linux/drivers/media/common/saa7146_video.c
@@ -1276,7 +1276,7 @@ static int buffer_prepare(struct videobuf_queue *q,
buf->vb.field != field ||
buf->vb.field != fh->video_fmt.field ||
buf->fmt != &fh->video_fmt) {
- saa7146_dma_free(dev,buf);
+ saa7146_dma_free(dev,q,buf);
}
if (STATE_NEEDS_INIT == buf->vb.state) {
@@ -1305,7 +1305,7 @@ static int buffer_prepare(struct videobuf_queue *q,
saa7146_pgtable_alloc(dev->pci, &buf->pt[0]);
}
- err = videobuf_iolock(dev->pci,&buf->vb, &vv->ov_fb);
+ err = videobuf_iolock(q,&buf->vb, &vv->ov_fb);
if (err)
goto oops;
err = saa7146_pgtable_build(dev,buf);
@@ -1319,7 +1319,7 @@ static int buffer_prepare(struct videobuf_queue *q,
oops:
DEB_D(("error out.\n"));
- saa7146_dma_free(dev,buf);
+ saa7146_dma_free(dev,q,buf);
return err;
}
@@ -1364,7 +1364,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
struct saa7146_buf *buf = (struct saa7146_buf *)vb;
DEB_CAP(("vbuf:%p\n",vb));
- saa7146_dma_free(dev,buf);
+ saa7146_dma_free(dev,q,buf);
}
static struct videobuf_queue_ops video_qops = {
diff --git a/linux/drivers/media/dvb/cinergyT2/cinergyT2.c b/linux/drivers/media/dvb/cinergyT2/cinergyT2.c
index 10ed8b8c0..57ab7b0f3 100644
--- a/linux/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/linux/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -523,6 +523,9 @@ static int cinergyt2_open (struct inode *inode, struct file *file)
static void cinergyt2_unregister(struct cinergyt2 *cinergyt2)
{
+ dvb_net_release(&cinergyt2->dvbnet);
+ dvb_dmxdev_release(&cinergyt2->dmxdev);
+ dvb_dmx_release(&cinergyt2->demux);
dvb_unregister_device(cinergyt2->fedev);
dvb_unregister_adapter(&cinergyt2->adapter);
@@ -955,6 +958,7 @@ static int cinergyt2_probe (struct usb_interface *intf,
return 0;
bailout:
+ dvb_net_release(&cinergyt2->dvbnet);
dvb_dmxdev_release(&cinergyt2->dmxdev);
dvb_dmx_release(&cinergyt2->demux);
dvb_unregister_adapter(&cinergyt2->adapter);
diff --git a/linux/drivers/media/dvb/dvb-core/demux.h b/linux/drivers/media/dvb/dvb-core/demux.h
index 9f025825b..0c1d87c52 100644
--- a/linux/drivers/media/dvb/dvb-core/demux.h
+++ b/linux/drivers/media/dvb/dvb-core/demux.h
@@ -216,7 +216,7 @@ struct dmx_frontend {
/*--------------------------------------------------------------------------*/
/*
- * Flags OR'ed in the capabilites field of struct dmx_demux.
+ * Flags OR'ed in the capabilities field of struct dmx_demux.
*/
#define DMX_TS_FILTERING 1
diff --git a/linux/drivers/media/dvb/dvb-core/dmxdev.c b/linux/drivers/media/dvb/dvb-core/dmxdev.c
index 4c52c8521..09e96e9dd 100644
--- a/linux/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/linux/drivers/media/dvb/dvb-core/dmxdev.c
@@ -1,9 +1,8 @@
/*
* dmxdev.c - DVB demultiplexer device
*
- * Copyright (C) 2000 Ralph Metzler <ralph@convergence.de>
- * & Marcus Metzler <marcus@convergence.de>
- for convergence integrated media GmbH
+ * Copyright (C) 2000 Ralph Metzler & Marcus Metzler
+ * for convergence integrated media GmbH
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -32,7 +31,6 @@
#include <linux/wait.h>
#include <asm/uaccess.h>
#include <asm/system.h>
-
#include "dmxdev.h"
static int debug;
@@ -42,119 +40,83 @@ MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
#define dprintk if (debug) printk
-static inline void dvb_dmxdev_buffer_init(struct dmxdev_buffer *buffer)
+static int dvb_dmxdev_buffer_write(struct dvb_ringbuffer *buf,
+ const u8 *src, size_t len)
{
- buffer->data=NULL;
- buffer->size=8192;
- buffer->pread=0;
- buffer->pwrite=0;
- buffer->error=0;
- init_waitqueue_head(&buffer->queue);
-}
-
-static inline int dvb_dmxdev_buffer_write(struct dmxdev_buffer *buf, const u8 *src, int len)
-{
- int split;
- int free;
- int todo;
+ ssize_t free;
if (!len)
return 0;
if (!buf->data)
return 0;
- free=buf->pread-buf->pwrite;
- split=0;
- if (free<=0) {
- free+=buf->size;
- split=buf->size-buf->pwrite;
- }
- if (len>=free) {
+ free = dvb_ringbuffer_free(buf);
+ if (len > free) {
dprintk("dmxdev: buffer overflow\n");
- return -1;
+ return -EOVERFLOW;
}
- if (split>=len)
- split=0;
- todo=len;
- if (split) {
- memcpy(buf->data + buf->pwrite, src, split);
- todo-=split;
- buf->pwrite=0;
- }
- memcpy(buf->data + buf->pwrite, src+split, todo);
- buf->pwrite=(buf->pwrite+todo)%buf->size;
- return len;
+
+ return dvb_ringbuffer_write(buf, src, len);
}
-static ssize_t dvb_dmxdev_buffer_read(struct dmxdev_buffer *src,
- int non_blocking, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t dvb_dmxdev_buffer_read(struct dvb_ringbuffer *src,
+ int non_blocking, char __user *buf,
+ size_t count, loff_t *ppos)
{
- unsigned long todo=count;
- int split, avail, error;
+ size_t todo;
+ ssize_t avail;
+ ssize_t ret = 0;
if (!src->data)
return 0;
- if ((error=src->error)) {
- src->pwrite=src->pread;
- src->error=0;
- return error;
+ if (src->error) {
+ ret = src->error;
+ dvb_ringbuffer_flush(src);
+ return ret;
}
- if (non_blocking && (src->pwrite==src->pread))
- return -EWOULDBLOCK;
-
- while (todo>0) {
- if (non_blocking && (src->pwrite==src->pread))
- return (count-todo) ? (count-todo) : -EWOULDBLOCK;
+ for (todo = count; todo > 0; todo -= ret) {
+ if (non_blocking && dvb_ringbuffer_empty(src)) {
+ ret = -EWOULDBLOCK;
+ break;
+ }
- if (wait_event_interruptible(src->queue,
- (src->pread!=src->pwrite) ||
- (src->error))<0)
- return count-todo;
+ ret = wait_event_interruptible(src->queue,
+ !dvb_ringbuffer_empty(src) ||
+ (src->error != 0));
+ if (ret < 0)
+ break;
- if ((error=src->error)) {
- src->pwrite=src->pread;
- src->error=0;
- return error;
+ if (src->error) {
+ ret = src->error;
+ dvb_ringbuffer_flush(src);
+ break;
}
- split=src->size;
- avail=src->pwrite - src->pread;
- if (avail<0) {
- avail+=src->size;
- split=src->size - src->pread;
- }
- if (avail>todo)
- avail=todo;
- if (split<avail) {
- if (copy_to_user(buf, src->data+src->pread, split))
- return -EFAULT;
- buf+=split;
- src->pread=0;
- todo-=split;
- avail-=split;
- }
- if (avail) {
- if (copy_to_user(buf, src->data+src->pread, avail))
- return -EFAULT;
- src->pread = (src->pread + avail) % src->size;
- todo-=avail;
- buf+=avail;
- }
+ avail = dvb_ringbuffer_avail(src);
+ if (avail > todo)
+ avail = todo;
+
+ ret = dvb_ringbuffer_read(src, buf, avail, 1);
+ if (ret < 0)
+ break;
+
+ buf += ret;
}
- return count;
+
+ return (count - todo) ? (count - todo) : ret;
}
-static struct dmx_frontend * get_fe(struct dmx_demux *demux, int type)
+static struct dmx_frontend *get_fe(struct dmx_demux *demux, int type)
{
struct list_head *head, *pos;
- head=demux->get_frontends(demux);
+ head = demux->get_frontends(demux);
if (!head)
return NULL;
list_for_each(pos, head)
- if (DMX_FE_ENTRY(pos)->source==type)
+ if (DMX_FE_ENTRY(pos)->source == type)
return DMX_FE_ENTRY(pos);
return NULL;
@@ -166,37 +128,36 @@ static int dvb_dvr_open(struct inode *inode, struct file *file)
struct dmxdev *dmxdev = dvbdev->priv;
struct dmx_frontend *front;
- dprintk ("function : %s\n", __FUNCTION__);
+ dprintk("function : %s\n", __FUNCTION__);
if (mutex_lock_interruptible(&dmxdev->mutex))
return -ERESTARTSYS;
- if ((file->f_flags&O_ACCMODE)==O_RDWR) {
- if (!(dmxdev->capabilities&DMXDEV_CAP_DUPLEX)) {
+ if ((file->f_flags & O_ACCMODE) == O_RDWR) {
+ if (!(dmxdev->capabilities & DMXDEV_CAP_DUPLEX)) {
mutex_unlock(&dmxdev->mutex);
return -EOPNOTSUPP;
}
}
- if ((file->f_flags&O_ACCMODE)==O_RDONLY) {
- dvb_dmxdev_buffer_init(&dmxdev->dvr_buffer);
- dmxdev->dvr_buffer.size=DVR_BUFFER_SIZE;
- dmxdev->dvr_buffer.data=vmalloc(DVR_BUFFER_SIZE);
- if (!dmxdev->dvr_buffer.data) {
- mutex_unlock(&dmxdev->mutex);
- return -ENOMEM;
- }
+ if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
+ void *mem = vmalloc(DVR_BUFFER_SIZE);
+ if (!mem) {
+ mutex_unlock(&dmxdev->mutex);
+ return -ENOMEM;
+ }
+ dvb_ringbuffer_init(&dmxdev->dvr_buffer, mem, DVR_BUFFER_SIZE);
}
- if ((file->f_flags&O_ACCMODE)==O_WRONLY) {
- dmxdev->dvr_orig_fe=dmxdev->demux->frontend;
+ if ((file->f_flags & O_ACCMODE) == O_WRONLY) {
+ dmxdev->dvr_orig_fe = dmxdev->demux->frontend;
if (!dmxdev->demux->write) {
mutex_unlock(&dmxdev->mutex);
return -EOPNOTSUPP;
}
- front=get_fe(dmxdev->demux, DMX_MEMORY_FE);
+ front = get_fe(dmxdev->demux, DMX_MEMORY_FE);
if (!front) {
mutex_unlock(&dmxdev->mutex);
@@ -217,17 +178,17 @@ static int dvb_dvr_release(struct inode *inode, struct file *file)
if (mutex_lock_interruptible(&dmxdev->mutex))
return -ERESTARTSYS;
- if ((file->f_flags&O_ACCMODE)==O_WRONLY) {
+ if ((file->f_flags & O_ACCMODE) == O_WRONLY) {
dmxdev->demux->disconnect_frontend(dmxdev->demux);
dmxdev->demux->connect_frontend(dmxdev->demux,
dmxdev->dvr_orig_fe);
}
- if ((file->f_flags&O_ACCMODE)==O_RDONLY) {
+ if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
if (dmxdev->dvr_buffer.data) {
- void *mem=dmxdev->dvr_buffer.data;
+ void *mem = dmxdev->dvr_buffer.data;
mb();
spin_lock_irq(&dmxdev->lock);
- dmxdev->dvr_buffer.data=NULL;
+ dmxdev->dvr_buffer.data = NULL;
spin_unlock_irq(&dmxdev->lock);
vfree(mem);
}
@@ -237,7 +198,7 @@ static int dvb_dvr_release(struct inode *inode, struct file *file)
}
static ssize_t dvb_dvr_write(struct file *file, const char __user *buf,
- size_t count, loff_t *ppos)
+ size_t count, loff_t *ppos)
{
struct dvb_device *dvbdev = file->private_data;
struct dmxdev *dmxdev = dvbdev->priv;
@@ -245,60 +206,62 @@ static ssize_t dvb_dvr_write(struct file *file, const char __user *buf,
if (!dmxdev->demux->write)
return -EOPNOTSUPP;
- if ((file->f_flags&O_ACCMODE)!=O_WRONLY)
+ if ((file->f_flags & O_ACCMODE) != O_WRONLY)
return -EINVAL;
if (mutex_lock_interruptible(&dmxdev->mutex))
return -ERESTARTSYS;
- ret=dmxdev->demux->write(dmxdev->demux, buf, count);
+ ret = dmxdev->demux->write(dmxdev->demux, buf, count);
mutex_unlock(&dmxdev->mutex);
return ret;
}
static ssize_t dvb_dvr_read(struct file *file, char __user *buf, size_t count,
- loff_t *ppos)
+ loff_t *ppos)
{
struct dvb_device *dvbdev = file->private_data;
struct dmxdev *dmxdev = dvbdev->priv;
int ret;
//mutex_lock(&dmxdev->mutex);
- ret= dvb_dmxdev_buffer_read(&dmxdev->dvr_buffer,
- file->f_flags&O_NONBLOCK,
- buf, count, ppos);
+ ret = dvb_dmxdev_buffer_read(&dmxdev->dvr_buffer,
+ file->f_flags & O_NONBLOCK,
+ buf, count, ppos);
//mutex_unlock(&dmxdev->mutex);
return ret;
}
-static inline void dvb_dmxdev_filter_state_set(struct dmxdev_filter *dmxdevfilter, int state)
+static inline void dvb_dmxdev_filter_state_set(struct dmxdev_filter
+ *dmxdevfilter, int state)
{
spin_lock_irq(&dmxdevfilter->dev->lock);
- dmxdevfilter->state=state;
+ dmxdevfilter->state = state;
spin_unlock_irq(&dmxdevfilter->dev->lock);
}
-static int dvb_dmxdev_set_buffer_size(struct dmxdev_filter *dmxdevfilter, unsigned long size)
+static int dvb_dmxdev_set_buffer_size(struct dmxdev_filter *dmxdevfilter,
+ unsigned long size)
{
- struct dmxdev_buffer *buf=&dmxdevfilter->buffer;
+ struct dvb_ringbuffer *buf = &dmxdevfilter->buffer;
void *mem;
- if (buf->size==size)
+ if (buf->size == size)
return 0;
- if (dmxdevfilter->state>=DMXDEV_STATE_GO)
+ if (dmxdevfilter->state >= DMXDEV_STATE_GO)
return -EBUSY;
spin_lock_irq(&dmxdevfilter->dev->lock);
- mem=buf->data;
- buf->data=NULL;
- buf->size=size;
- buf->pwrite=buf->pread=0;
+ mem = buf->data;
+ buf->data = NULL;
+ buf->size = size;
+ dvb_ringbuffer_flush(buf);
spin_unlock_irq(&dmxdevfilter->dev->lock);
vfree(mem);
if (buf->size) {
- mem=vmalloc(dmxdevfilter->buffer.size);
+ mem = vmalloc(dmxdevfilter->buffer.size);
if (!mem)
return -ENOMEM;
spin_lock_irq(&dmxdevfilter->dev->lock);
- buf->data=mem;
+ buf->data = mem;
spin_unlock_irq(&dmxdevfilter->dev->lock);
}
return 0;
@@ -306,31 +269,33 @@ static int dvb_dmxdev_set_buffer_size(struct dmxdev_filter *dmxdevfilter, unsign
static void dvb_dmxdev_filter_timeout(unsigned long data)
{
- struct dmxdev_filter *dmxdevfilter=(struct dmxdev_filter *)data;
+ struct dmxdev_filter *dmxdevfilter = (struct dmxdev_filter *)data;
- dmxdevfilter->buffer.error=-ETIMEDOUT;
+ dmxdevfilter->buffer.error = -ETIMEDOUT;
spin_lock_irq(&dmxdevfilter->dev->lock);
- dmxdevfilter->state=DMXDEV_STATE_TIMEDOUT;
+ dmxdevfilter->state = DMXDEV_STATE_TIMEDOUT;
spin_unlock_irq(&dmxdevfilter->dev->lock);
wake_up(&dmxdevfilter->buffer.queue);
}
static void dvb_dmxdev_filter_timer(struct dmxdev_filter *dmxdevfilter)
{
- struct dmx_sct_filter_params *para=&dmxdevfilter->params.sec;
+ struct dmx_sct_filter_params *para = &dmxdevfilter->params.sec;
del_timer(&dmxdevfilter->timer);
if (para->timeout) {
- dmxdevfilter->timer.function=dvb_dmxdev_filter_timeout;
- dmxdevfilter->timer.data=(unsigned long) dmxdevfilter;
- dmxdevfilter->timer.expires=jiffies+1+(HZ/2+HZ*para->timeout)/1000;
+ dmxdevfilter->timer.function = dvb_dmxdev_filter_timeout;
+ dmxdevfilter->timer.data = (unsigned long)dmxdevfilter;
+ dmxdevfilter->timer.expires =
+ jiffies + 1 + (HZ / 2 + HZ * para->timeout) / 1000;
add_timer(&dmxdevfilter->timer);
}
}
static int dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
- const u8 *buffer2, size_t buffer2_len,
- struct dmx_section_filter *filter, enum dmx_success success)
+ const u8 *buffer2, size_t buffer2_len,
+ struct dmx_section_filter *filter,
+ enum dmx_success success)
{
struct dmxdev_filter *dmxdevfilter = filter->priv;
int ret;
@@ -340,68 +305,68 @@ static int dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
return 0;
}
spin_lock(&dmxdevfilter->dev->lock);
- if (dmxdevfilter->state!=DMXDEV_STATE_GO) {
+ if (dmxdevfilter->state != DMXDEV_STATE_GO) {
spin_unlock(&dmxdevfilter->dev->lock);
return 0;
}
del_timer(&dmxdevfilter->timer);
dprintk("dmxdev: section callback %02x %02x %02x %02x %02x %02x\n",
buffer1[0], buffer1[1],
- buffer1[2], buffer1[3],
- buffer1[4], buffer1[5]);
- ret=dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer1, buffer1_len);
- if (ret==buffer1_len) {
- ret=dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer2, buffer2_len);
+ buffer1[2], buffer1[3], buffer1[4], buffer1[5]);
+ ret = dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer1,
+ buffer1_len);
+ if (ret == buffer1_len) {
+ ret = dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer2,
+ buffer2_len);
}
- if (ret<0) {
- dmxdevfilter->buffer.pwrite=dmxdevfilter->buffer.pread;
- dmxdevfilter->buffer.error=-EOVERFLOW;
+ if (ret < 0) {
+ dvb_ringbuffer_flush(&dmxdevfilter->buffer);
+ dmxdevfilter->buffer.error = ret;
}
- if (dmxdevfilter->params.sec.flags&DMX_ONESHOT)
- dmxdevfilter->state=DMXDEV_STATE_DONE;
+ if (dmxdevfilter->params.sec.flags & DMX_ONESHOT)
+ dmxdevfilter->state = DMXDEV_STATE_DONE;
spin_unlock(&dmxdevfilter->dev->lock);
wake_up(&dmxdevfilter->buffer.queue);
return 0;
}
static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
- const u8 *buffer2, size_t buffer2_len,
- struct dmx_ts_feed *feed, enum dmx_success success)
+ const u8 *buffer2, size_t buffer2_len,
+ struct dmx_ts_feed *feed,
+ enum dmx_success success)
{
struct dmxdev_filter *dmxdevfilter = feed->priv;
- struct dmxdev_buffer *buffer;
+ struct dvb_ringbuffer *buffer;
int ret;
spin_lock(&dmxdevfilter->dev->lock);
- if (dmxdevfilter->params.pes.output==DMX_OUT_DECODER) {
+ if (dmxdevfilter->params.pes.output == DMX_OUT_DECODER) {
spin_unlock(&dmxdevfilter->dev->lock);
return 0;
}
- if (dmxdevfilter->params.pes.output==DMX_OUT_TAP)
- buffer=&dmxdevfilter->buffer;
+ if (dmxdevfilter->params.pes.output == DMX_OUT_TAP)
+ buffer = &dmxdevfilter->buffer;
else
- buffer=&dmxdevfilter->dev->dvr_buffer;
+ buffer = &dmxdevfilter->dev->dvr_buffer;
if (buffer->error) {
spin_unlock(&dmxdevfilter->dev->lock);
wake_up(&buffer->queue);
return 0;
}
- ret=dvb_dmxdev_buffer_write(buffer, buffer1, buffer1_len);
- if (ret==buffer1_len)
- ret=dvb_dmxdev_buffer_write(buffer, buffer2, buffer2_len);
- if (ret<0) {
- buffer->pwrite=buffer->pread;
- buffer->error=-EOVERFLOW;
+ ret = dvb_dmxdev_buffer_write(buffer, buffer1, buffer1_len);
+ if (ret == buffer1_len)
+ ret = dvb_dmxdev_buffer_write(buffer, buffer2, buffer2_len);
+ if (ret < 0) {
+ dvb_ringbuffer_flush(buffer);
+ buffer->error = ret;
}
spin_unlock(&dmxdevfilter->dev->lock);
wake_up(&buffer->queue);
return 0;
}
-
/* stop feed but only mark the specified filter as stopped (state set) */
-
static int dvb_dmxdev_feed_stop(struct dmxdev_filter *dmxdevfilter)
{
dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_SET);
@@ -420,20 +385,16 @@ static int dvb_dmxdev_feed_stop(struct dmxdev_filter *dmxdevfilter)
return 0;
}
-
/* start feed associated with the specified filter */
-
static int dvb_dmxdev_feed_start(struct dmxdev_filter *filter)
{
- dvb_dmxdev_filter_state_set (filter, DMXDEV_STATE_GO);
+ dvb_dmxdev_filter_state_set(filter, DMXDEV_STATE_GO);
switch (filter->type) {
case DMXDEV_TYPE_SEC:
return filter->feed.sec->start_filtering(filter->feed.sec);
- break;
case DMXDEV_TYPE_PES:
return filter->feed.ts->start_filtering(filter->feed.ts);
- break;
default:
return -EINVAL;
}
@@ -441,32 +402,31 @@ static int dvb_dmxdev_feed_start(struct dmxdev_filter *filter)
return 0;
}
-
/* restart section feed if it has filters left associated with it,
otherwise release the feed */
-
static int dvb_dmxdev_feed_restart(struct dmxdev_filter *filter)
{
int i;
struct dmxdev *dmxdev = filter->dev;
u16 pid = filter->params.sec.pid;
- for (i=0; i<dmxdev->filternum; i++)
- if (dmxdev->filter[i].state>=DMXDEV_STATE_GO &&
- dmxdev->filter[i].type==DMXDEV_TYPE_SEC &&
- dmxdev->filter[i].pid==pid) {
+ for (i = 0; i < dmxdev->filternum; i++)
+ if (dmxdev->filter[i].state >= DMXDEV_STATE_GO &&
+ dmxdev->filter[i].type == DMXDEV_TYPE_SEC &&
+ dmxdev->filter[i].params.sec.pid == pid) {
dvb_dmxdev_feed_start(&dmxdev->filter[i]);
return 0;
}
- filter->dev->demux->release_section_feed(dmxdev->demux, filter->feed.sec);
+ filter->dev->demux->release_section_feed(dmxdev->demux,
+ filter->feed.sec);
return 0;
}
static int dvb_dmxdev_filter_stop(struct dmxdev_filter *dmxdevfilter)
{
- if (dmxdevfilter->state<DMXDEV_STATE_GO)
+ if (dmxdevfilter->state < DMXDEV_STATE_GO)
return 0;
switch (dmxdevfilter->type) {
@@ -476,36 +436,36 @@ static int dvb_dmxdev_filter_stop(struct dmxdev_filter *dmxdevfilter)
dvb_dmxdev_feed_stop(dmxdevfilter);
if (dmxdevfilter->filter.sec)
dmxdevfilter->feed.sec->
- release_filter(dmxdevfilter->feed.sec,
- dmxdevfilter->filter.sec);
+ release_filter(dmxdevfilter->feed.sec,
+ dmxdevfilter->filter.sec);
dvb_dmxdev_feed_restart(dmxdevfilter);
- dmxdevfilter->feed.sec=NULL;
+ dmxdevfilter->feed.sec = NULL;
break;
case DMXDEV_TYPE_PES:
if (!dmxdevfilter->feed.ts)
break;
dvb_dmxdev_feed_stop(dmxdevfilter);
dmxdevfilter->dev->demux->
- release_ts_feed(dmxdevfilter->dev->demux,
- dmxdevfilter->feed.ts);
- dmxdevfilter->feed.ts=NULL;
+ release_ts_feed(dmxdevfilter->dev->demux,
+ dmxdevfilter->feed.ts);
+ dmxdevfilter->feed.ts = NULL;
break;
default:
- if (dmxdevfilter->state==DMXDEV_STATE_ALLOCATED)
+ if (dmxdevfilter->state == DMXDEV_STATE_ALLOCATED)
return 0;
return -EINVAL;
}
- dmxdevfilter->buffer.pwrite=dmxdevfilter->buffer.pread=0;
+
+ dvb_ringbuffer_flush(&dmxdevfilter->buffer);
return 0;
}
static inline int dvb_dmxdev_filter_reset(struct dmxdev_filter *dmxdevfilter)
{
- if (dmxdevfilter->state<DMXDEV_STATE_SET)
+ if (dmxdevfilter->state < DMXDEV_STATE_SET)
return 0;
- dmxdevfilter->type=DMXDEV_TYPE_NONE;
- dmxdevfilter->pid=0xffff;
+ dmxdevfilter->type = DMXDEV_TYPE_NONE;
dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_ALLOCATED);
return 0;
}
@@ -522,32 +482,33 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter)
if (filter->state >= DMXDEV_STATE_GO)
dvb_dmxdev_filter_stop(filter);
- if (!(mem = filter->buffer.data)) {
+ if (!filter->buffer.data) {
mem = vmalloc(filter->buffer.size);
+ if (!mem)
+ return -ENOMEM;
spin_lock_irq(&filter->dev->lock);
- filter->buffer.data=mem;
+ filter->buffer.data = mem;
spin_unlock_irq(&filter->dev->lock);
- if (!filter->buffer.data)
- return -ENOMEM;
}
- filter->buffer.pwrite = filter->buffer.pread = 0;
+ dvb_ringbuffer_flush(&filter->buffer);
switch (filter->type) {
case DMXDEV_TYPE_SEC:
{
- struct dmx_sct_filter_params *para=&filter->params.sec;
- struct dmx_section_filter **secfilter=&filter->filter.sec;
- struct dmx_section_feed **secfeed=&filter->feed.sec;
+ struct dmx_sct_filter_params *para = &filter->params.sec;
+ struct dmx_section_filter **secfilter = &filter->filter.sec;
+ struct dmx_section_feed **secfeed = &filter->feed.sec;
+
+ *secfilter = NULL;
+ *secfeed = NULL;
- *secfilter=NULL;
- *secfeed=NULL;
/* find active filter/feed with same PID */
- for (i=0; i<dmxdev->filternum; i++) {
+ for (i = 0; i < dmxdev->filternum; i++) {
if (dmxdev->filter[i].state >= DMXDEV_STATE_GO &&
- dmxdev->filter[i].pid == para->pid &&
- dmxdev->filter[i].type == DMXDEV_TYPE_SEC) {
+ dmxdev->filter[i].type == DMXDEV_TYPE_SEC &&
+ dmxdev->filter[i].params.sec.pid == para->pid) {
*secfeed = dmxdev->filter[i].feed.sec;
break;
}
@@ -555,21 +516,20 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter)
/* if no feed found, try to allocate new one */
if (!*secfeed) {
- ret=dmxdev->demux->allocate_section_feed(dmxdev->demux,
- secfeed,
- dvb_dmxdev_section_callback);
- if (ret<0) {
- printk ("DVB (%s): could not alloc feed\n",
- __FUNCTION__);
+ ret = dmxdev->demux->allocate_section_feed(dmxdev->demux,
+ secfeed,
+ dvb_dmxdev_section_callback);
+ if (ret < 0) {
+ printk("DVB (%s): could not alloc feed\n",
+ __FUNCTION__);
return ret;
}
- ret=(*secfeed)->set(*secfeed, para->pid, 32768,
- (para->flags & DMX_CHECK_CRC) ? 1 : 0);
-
- if (ret<0) {
- printk ("DVB (%s): could not set feed\n",
- __FUNCTION__);
+ ret = (*secfeed)->set(*secfeed, para->pid, 32768,
+ (para->flags & DMX_CHECK_CRC) ? 1 : 0);
+ if (ret < 0) {
+ printk("DVB (%s): could not set feed\n",
+ __FUNCTION__);
dvb_dmxdev_feed_restart(filter);
return ret;
}
@@ -577,41 +537,38 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter)
dvb_dmxdev_feed_stop(filter);
}
- ret=(*secfeed)->allocate_filter(*secfeed, secfilter);
-
+ ret = (*secfeed)->allocate_filter(*secfeed, secfilter);
if (ret < 0) {
dvb_dmxdev_feed_restart(filter);
filter->feed.sec->start_filtering(*secfeed);
- dprintk ("could not get filter\n");
+ dprintk("could not get filter\n");
return ret;
}
(*secfilter)->priv = filter;
memcpy(&((*secfilter)->filter_value[3]),
- &(para->filter.filter[1]), DMX_FILTER_SIZE-1);
+ &(para->filter.filter[1]), DMX_FILTER_SIZE - 1);
memcpy(&(*secfilter)->filter_mask[3],
- &para->filter.mask[1], DMX_FILTER_SIZE-1);
+ &para->filter.mask[1], DMX_FILTER_SIZE - 1);
memcpy(&(*secfilter)->filter_mode[3],
- &para->filter.mode[1], DMX_FILTER_SIZE-1);
+ &para->filter.mode[1], DMX_FILTER_SIZE - 1);
- (*secfilter)->filter_value[0]=para->filter.filter[0];
- (*secfilter)->filter_mask[0]=para->filter.mask[0];
- (*secfilter)->filter_mode[0]=para->filter.mode[0];
- (*secfilter)->filter_mask[1]=0;
- (*secfilter)->filter_mask[2]=0;
+ (*secfilter)->filter_value[0] = para->filter.filter[0];
+ (*secfilter)->filter_mask[0] = para->filter.mask[0];
+ (*secfilter)->filter_mode[0] = para->filter.mode[0];
+ (*secfilter)->filter_mask[1] = 0;
+ (*secfilter)->filter_mask[2] = 0;
filter->todo = 0;
- ret = filter->feed.sec->start_filtering (filter->feed.sec);
-
+ ret = filter->feed.sec->start_filtering(filter->feed.sec);
if (ret < 0)
return ret;
dvb_dmxdev_filter_timer(filter);
break;
}
-
case DMXDEV_TYPE_PES:
{
struct timespec timeout = { 0 };
@@ -623,41 +580,41 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter)
struct dmx_ts_feed **tsfeed = &filter->feed.ts;
filter->feed.ts = NULL;
- otype=para->output;
+ otype = para->output;
- ts_pes=(enum dmx_ts_pes) para->pes_type;
+ ts_pes = (enum dmx_ts_pes)para->pes_type;
- if (ts_pes<DMX_PES_OTHER)
- ts_type=TS_DECODER;
+ if (ts_pes < DMX_PES_OTHER)
+ ts_type = TS_DECODER;
else
- ts_type=0;
+ ts_type = 0;
if (otype == DMX_OUT_TS_TAP)
ts_type |= TS_PACKET;
if (otype == DMX_OUT_TAP)
- ts_type |= TS_PAYLOAD_ONLY|TS_PACKET;
+ ts_type |= TS_PAYLOAD_ONLY | TS_PACKET;
- ret=dmxdev->demux->allocate_ts_feed(dmxdev->demux,
- tsfeed,
- dvb_dmxdev_ts_callback);
- if (ret<0)
+ ret = dmxdev->demux->allocate_ts_feed(dmxdev->demux,
+ tsfeed,
+ dvb_dmxdev_ts_callback);
+ if (ret < 0)
return ret;
- (*tsfeed)->priv = (void *) filter;
+ (*tsfeed)->priv = filter;
ret = (*tsfeed)->set(*tsfeed, para->pid, ts_type, ts_pes,
32768, timeout);
-
if (ret < 0) {
- dmxdev->demux->release_ts_feed(dmxdev->demux, *tsfeed);
+ dmxdev->demux->release_ts_feed(dmxdev->demux,
+ *tsfeed);
return ret;
}
ret = filter->feed.ts->start_filtering(filter->feed.ts);
-
if (ret < 0) {
- dmxdev->demux->release_ts_feed(dmxdev->demux, *tsfeed);
+ dmxdev->demux->release_ts_feed(dmxdev->demux,
+ *tsfeed);
return ret;
}
@@ -684,32 +641,31 @@ static int dvb_demux_open(struct inode *inode, struct file *file)
if (mutex_lock_interruptible(&dmxdev->mutex))
return -ERESTARTSYS;
- for (i=0; i<dmxdev->filternum; i++)
- if (dmxdev->filter[i].state==DMXDEV_STATE_FREE)
+ for (i = 0; i < dmxdev->filternum; i++)
+ if (dmxdev->filter[i].state == DMXDEV_STATE_FREE)
break;
- if (i==dmxdev->filternum) {
+ if (i == dmxdev->filternum) {
mutex_unlock(&dmxdev->mutex);
return -EMFILE;
}
- dmxdevfilter=&dmxdev->filter[i];
+ dmxdevfilter = &dmxdev->filter[i];
mutex_init(&dmxdevfilter->mutex);
- dmxdevfilter->dvbdev=dmxdev->dvbdev;
- file->private_data=dmxdevfilter;
+ file->private_data = dmxdevfilter;
- dvb_dmxdev_buffer_init(&dmxdevfilter->buffer);
- dmxdevfilter->type=DMXDEV_TYPE_NONE;
+ dvb_ringbuffer_init(&dmxdevfilter->buffer, NULL, 8192);
+ dmxdevfilter->type = DMXDEV_TYPE_NONE;
dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_ALLOCATED);
- dmxdevfilter->feed.ts=NULL;
+ dmxdevfilter->feed.ts = NULL;
init_timer(&dmxdevfilter->timer);
mutex_unlock(&dmxdev->mutex);
return 0;
}
-
-static int dvb_dmxdev_filter_free(struct dmxdev *dmxdev, struct dmxdev_filter *dmxdevfilter)
+static int dvb_dmxdev_filter_free(struct dmxdev *dmxdev,
+ struct dmxdev_filter *dmxdevfilter)
{
if (mutex_lock_interruptible(&dmxdev->mutex))
return -ERESTARTSYS;
@@ -723,10 +679,10 @@ static int dvb_dmxdev_filter_free(struct dmxdev *dmxdev, struct dmxdev_filter *d
dvb_dmxdev_filter_reset(dmxdevfilter);
if (dmxdevfilter->buffer.data) {
- void *mem=dmxdevfilter->buffer.data;
+ void *mem = dmxdevfilter->buffer.data;
spin_lock_irq(&dmxdev->lock);
- dmxdevfilter->buffer.data=NULL;
+ dmxdevfilter->buffer.data = NULL;
spin_unlock_irq(&dmxdev->lock);
vfree(mem);
}
@@ -742,120 +698,120 @@ static inline void invert_mode(dmx_filter_t *filter)
{
int i;
- for (i=0; i<DMX_FILTER_SIZE; i++)
- filter->mode[i]^=0xff;
+ for (i = 0; i < DMX_FILTER_SIZE; i++)
+ filter->mode[i] ^= 0xff;
}
-
static int dvb_dmxdev_filter_set(struct dmxdev *dmxdev,
- struct dmxdev_filter *dmxdevfilter,
- struct dmx_sct_filter_params *params)
+ struct dmxdev_filter *dmxdevfilter,
+ struct dmx_sct_filter_params *params)
{
- dprintk ("function : %s\n", __FUNCTION__);
+ dprintk("function : %s\n", __FUNCTION__);
dvb_dmxdev_filter_stop(dmxdevfilter);
- dmxdevfilter->type=DMXDEV_TYPE_SEC;
- dmxdevfilter->pid=params->pid;
+ dmxdevfilter->type = DMXDEV_TYPE_SEC;
memcpy(&dmxdevfilter->params.sec,
params, sizeof(struct dmx_sct_filter_params));
invert_mode(&dmxdevfilter->params.sec.filter);
dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_SET);
- if (params->flags&DMX_IMMEDIATE_START)
+ if (params->flags & DMX_IMMEDIATE_START)
return dvb_dmxdev_filter_start(dmxdevfilter);
return 0;
}
static int dvb_dmxdev_pes_filter_set(struct dmxdev *dmxdev,
- struct dmxdev_filter *dmxdevfilter,
- struct dmx_pes_filter_params *params)
+ struct dmxdev_filter *dmxdevfilter,
+ struct dmx_pes_filter_params *params)
{
dvb_dmxdev_filter_stop(dmxdevfilter);
- if (params->pes_type>DMX_PES_OTHER || params->pes_type<0)
+ if (params->pes_type > DMX_PES_OTHER || params->pes_type < 0)
return -EINVAL;
- dmxdevfilter->type=DMXDEV_TYPE_PES;
- dmxdevfilter->pid=params->pid;
- memcpy(&dmxdevfilter->params, params, sizeof(struct dmx_pes_filter_params));
+ dmxdevfilter->type = DMXDEV_TYPE_PES;
+ memcpy(&dmxdevfilter->params, params,
+ sizeof(struct dmx_pes_filter_params));
dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_SET);
- if (params->flags&DMX_IMMEDIATE_START)
+ if (params->flags & DMX_IMMEDIATE_START)
return dvb_dmxdev_filter_start(dmxdevfilter);
return 0;
}
static ssize_t dvb_dmxdev_read_sec(struct dmxdev_filter *dfil,
- struct file *file, char __user *buf, size_t count, loff_t *ppos)
+ struct file *file, char __user *buf,
+ size_t count, loff_t *ppos)
{
int result, hcount;
- int done=0;
-
- if (dfil->todo<=0) {
- hcount=3+dfil->todo;
- if (hcount>count)
- hcount=count;
- result=dvb_dmxdev_buffer_read(&dfil->buffer, file->f_flags&O_NONBLOCK,
- buf, hcount, ppos);
- if (result<0) {
- dfil->todo=0;
+ int done = 0;
+
+ if (dfil->todo <= 0) {
+ hcount = 3 + dfil->todo;
+ if (hcount > count)
+ hcount = count;
+ result = dvb_dmxdev_buffer_read(&dfil->buffer,
+ file->f_flags & O_NONBLOCK,
+ buf, hcount, ppos);
+ if (result < 0) {
+ dfil->todo = 0;
return result;
}
- if (copy_from_user(dfil->secheader-dfil->todo, buf, result))
+ if (copy_from_user(dfil->secheader - dfil->todo, buf, result))
return -EFAULT;
- buf+=result;
- done=result;
- count-=result;
- dfil->todo-=result;
- if (dfil->todo>-3)
+ buf += result;
+ done = result;
+ count -= result;
+ dfil->todo -= result;
+ if (dfil->todo > -3)
return done;
- dfil->todo=((dfil->secheader[1]<<8)|dfil->secheader[2])&0xfff;
+ dfil->todo = ((dfil->secheader[1] << 8) | dfil->secheader[2]) & 0xfff;
if (!count)
return done;
}
- if (count>dfil->todo)
- count=dfil->todo;
- result=dvb_dmxdev_buffer_read(&dfil->buffer, file->f_flags&O_NONBLOCK,
- buf, count, ppos);
- if (result<0)
+ if (count > dfil->todo)
+ count = dfil->todo;
+ result = dvb_dmxdev_buffer_read(&dfil->buffer,
+ file->f_flags & O_NONBLOCK,
+ buf, count, ppos);
+ if (result < 0)
return result;
- dfil->todo-=result;
- return (result+done);
+ dfil->todo -= result;
+ return (result + done);
}
-
static ssize_t
-dvb_demux_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
+dvb_demux_read(struct file *file, char __user *buf, size_t count,
+ loff_t *ppos)
{
- struct dmxdev_filter *dmxdevfilter= file->private_data;
- int ret=0;
+ struct dmxdev_filter *dmxdevfilter = file->private_data;
+ int ret;
if (mutex_lock_interruptible(&dmxdevfilter->mutex))
return -ERESTARTSYS;
- if (dmxdevfilter->type==DMXDEV_TYPE_SEC)
- ret=dvb_dmxdev_read_sec(dmxdevfilter, file, buf, count, ppos);
+ if (dmxdevfilter->type == DMXDEV_TYPE_SEC)
+ ret = dvb_dmxdev_read_sec(dmxdevfilter, file, buf, count, ppos);
else
- ret=dvb_dmxdev_buffer_read(&dmxdevfilter->buffer,
- file->f_flags&O_NONBLOCK,
- buf, count, ppos);
+ ret = dvb_dmxdev_buffer_read(&dmxdevfilter->buffer,
+ file->f_flags & O_NONBLOCK,
+ buf, count, ppos);
mutex_unlock(&dmxdevfilter->mutex);
return ret;
}
-
static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, void *parg)
{
struct dmxdev_filter *dmxdevfilter = file->private_data;
- struct dmxdev *dmxdev=dmxdevfilter->dev;
- unsigned long arg=(unsigned long) parg;
- int ret=0;
+ struct dmxdev *dmxdev = dmxdevfilter->dev;
+ unsigned long arg = (unsigned long)parg;
+ int ret = 0;
if (mutex_lock_interruptible(&dmxdev->mutex))
return -ERESTARTSYS;
@@ -866,7 +822,7 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
mutex_unlock(&dmxdev->mutex);
return -ERESTARTSYS;
}
- if (dmxdevfilter->state<DMXDEV_STATE_SET)
+ if (dmxdevfilter->state < DMXDEV_STATE_SET)
ret = -EINVAL;
else
ret = dvb_dmxdev_filter_start(dmxdevfilter);
@@ -878,7 +834,7 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
mutex_unlock(&dmxdev->mutex);
return -ERESTARTSYS;
}
- ret=dvb_dmxdev_filter_stop(dmxdevfilter);
+ ret = dvb_dmxdev_filter_stop(dmxdevfilter);
mutex_unlock(&dmxdevfilter->mutex);
break;
@@ -887,8 +843,7 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
mutex_unlock(&dmxdev->mutex);
return -ERESTARTSYS;
}
- ret = dvb_dmxdev_filter_set(dmxdev, dmxdevfilter,
- (struct dmx_sct_filter_params *)parg);
+ ret = dvb_dmxdev_filter_set(dmxdev, dmxdevfilter, parg);
mutex_unlock(&dmxdevfilter->mutex);
break;
@@ -897,8 +852,7 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
mutex_unlock(&dmxdev->mutex);
return -ERESTARTSYS;
}
- ret=dvb_dmxdev_pes_filter_set(dmxdev, dmxdevfilter,
- (struct dmx_pes_filter_params *)parg);
+ ret = dvb_dmxdev_pes_filter_set(dmxdev, dmxdevfilter, parg);
mutex_unlock(&dmxdevfilter->mutex);
break;
@@ -907,7 +861,7 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
mutex_unlock(&dmxdev->mutex);
return -ERESTARTSYS;
}
- ret=dvb_dmxdev_set_buffer_size(dmxdevfilter, arg);
+ ret = dvb_dmxdev_set_buffer_size(dmxdevfilter, arg);
mutex_unlock(&dmxdevfilter->mutex);
break;
@@ -916,10 +870,10 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
case DMX_GET_PES_PIDS:
if (!dmxdev->demux->get_pes_pids) {
- ret=-EINVAL;
+ ret = -EINVAL;
break;
}
- dmxdev->demux->get_pes_pids(dmxdev->demux, (u16 *)parg);
+ dmxdev->demux->get_pes_pids(dmxdev->demux, parg);
break;
case DMX_GET_CAPS:
@@ -940,17 +894,18 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
case DMX_GET_STC:
if (!dmxdev->demux->get_stc) {
- ret=-EINVAL;
+ ret = -EINVAL;
break;
}
ret = dmxdev->demux->get_stc(dmxdev->demux,
- ((struct dmx_stc *)parg)->num,
- &((struct dmx_stc *)parg)->stc,
- &((struct dmx_stc *)parg)->base);
+ ((struct dmx_stc *)parg)->num,
+ &((struct dmx_stc *)parg)->stc,
+ &((struct dmx_stc *)parg)->base);
break;
default:
- ret=-EINVAL;
+ ret = -EINVAL;
+ break;
}
mutex_unlock(&dmxdev->mutex);
return ret;
@@ -962,8 +917,7 @@ static int dvb_demux_ioctl(struct inode *inode, struct file *file,
return dvb_usercopy(inode, file, cmd, arg, dvb_demux_do_ioctl);
}
-
-static unsigned int dvb_demux_poll (struct file *file, poll_table *wait)
+static unsigned int dvb_demux_poll(struct file *file, poll_table *wait)
{
struct dmxdev_filter *dmxdevfilter = file->private_data;
unsigned int mask = 0;
@@ -981,13 +935,12 @@ static unsigned int dvb_demux_poll (struct file *file, poll_table *wait)
if (dmxdevfilter->buffer.error)
mask |= (POLLIN | POLLRDNORM | POLLPRI | POLLERR);
- if (dmxdevfilter->buffer.pread != dmxdevfilter->buffer.pwrite)
+ if (!dvb_ringbuffer_empty(&dmxdevfilter->buffer))
mask |= (POLLIN | POLLRDNORM | POLLPRI);
return mask;
}
-
static int dvb_demux_release(struct inode *inode, struct file *file)
{
struct dmxdev_filter *dmxdevfilter = file->private_data;
@@ -996,32 +949,28 @@ static int dvb_demux_release(struct inode *inode, struct file *file)
return dvb_dmxdev_filter_free(dmxdev, dmxdevfilter);
}
-
static struct file_operations dvb_demux_fops = {
- .owner = THIS_MODULE,
- .read = dvb_demux_read,
- .ioctl = dvb_demux_ioctl,
- .open = dvb_demux_open,
- .release = dvb_demux_release,
- .poll = dvb_demux_poll,
+ .owner = THIS_MODULE,
+ .read = dvb_demux_read,
+ .ioctl = dvb_demux_ioctl,
+ .open = dvb_demux_open,
+ .release = dvb_demux_release,
+ .poll = dvb_demux_poll,
};
-
static struct dvb_device dvbdev_demux = {
- .priv = NULL,
- .users = 1,
- .writers = 1,
- .fops = &dvb_demux_fops
+ .priv = NULL,
+ .users = 1,
+ .writers = 1,
+ .fops = &dvb_demux_fops
};
-
static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, void *parg)
+ unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
struct dmxdev *dmxdev = dvbdev->priv;
-
- int ret=0;
+ int ret;
if (mutex_lock_interruptible(&dmxdev->mutex))
return -ERESTARTSYS;
@@ -1029,39 +978,38 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
switch (cmd) {
case DMX_SET_BUFFER_SIZE:
// FIXME: implement
- ret=0;
+ ret = 0;
break;
default:
- ret=-EINVAL;
+ ret = -EINVAL;
+ break;
}
mutex_unlock(&dmxdev->mutex);
return ret;
}
-
static int dvb_dvr_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+ unsigned int cmd, unsigned long arg)
{
return dvb_usercopy(inode, file, cmd, arg, dvb_dvr_do_ioctl);
}
-
-static unsigned int dvb_dvr_poll (struct file *file, poll_table *wait)
+static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait)
{
struct dvb_device *dvbdev = file->private_data;
struct dmxdev *dmxdev = dvbdev->priv;
unsigned int mask = 0;
- dprintk ("function : %s\n", __FUNCTION__);
+ dprintk("function : %s\n", __FUNCTION__);
poll_wait(file, &dmxdev->dvr_buffer.queue, wait);
- if ((file->f_flags&O_ACCMODE) == O_RDONLY) {
+ if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
if (dmxdev->dvr_buffer.error)
mask |= (POLLIN | POLLRDNORM | POLLPRI | POLLERR);
- if (dmxdev->dvr_buffer.pread!=dmxdev->dvr_buffer.pwrite)
+ if (!dvb_ringbuffer_empty(&dmxdev->dvr_buffer))
mask |= (POLLIN | POLLRDNORM | POLLPRI);
} else
mask |= (POLLOUT | POLLWRNORM | POLLPRI);
@@ -1069,61 +1017,63 @@ static unsigned int dvb_dvr_poll (struct file *file, poll_table *wait)
return mask;
}
-
static struct file_operations dvb_dvr_fops = {
- .owner = THIS_MODULE,
- .read = dvb_dvr_read,
- .write = dvb_dvr_write,
- .ioctl = dvb_dvr_ioctl,
- .open = dvb_dvr_open,
- .release = dvb_dvr_release,
- .poll = dvb_dvr_poll,
+ .owner = THIS_MODULE,
+ .read = dvb_dvr_read,
+ .write = dvb_dvr_write,
+ .ioctl = dvb_dvr_ioctl,
+ .open = dvb_dvr_open,
+ .release = dvb_dvr_release,
+ .poll = dvb_dvr_poll,
};
static struct dvb_device dvbdev_dvr = {
- .priv = NULL,
- .users = 1,
- .writers = 1,
- .fops = &dvb_dvr_fops
+ .priv = NULL,
+ .users = 1,
+ .writers = 1,
+ .fops = &dvb_dvr_fops
};
-int
-dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter)
+int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter)
{
int i;
if (dmxdev->demux->open(dmxdev->demux) < 0)
return -EUSERS;
- dmxdev->filter = vmalloc(dmxdev->filternum*sizeof(struct dmxdev_filter));
+ dmxdev->filter = vmalloc(dmxdev->filternum * sizeof(struct dmxdev_filter));
if (!dmxdev->filter)
return -ENOMEM;
mutex_init(&dmxdev->mutex);
spin_lock_init(&dmxdev->lock);
- for (i=0; i<dmxdev->filternum; i++) {
- dmxdev->filter[i].dev=dmxdev;
- dmxdev->filter[i].buffer.data=NULL;
- dvb_dmxdev_filter_state_set(&dmxdev->filter[i], DMXDEV_STATE_FREE);
+ for (i = 0; i < dmxdev->filternum; i++) {
+ dmxdev->filter[i].dev = dmxdev;
+ dmxdev->filter[i].buffer.data = NULL;
+ dvb_dmxdev_filter_state_set(&dmxdev->filter[i],
+ DMXDEV_STATE_FREE);
}
- dvb_register_device(dvb_adapter, &dmxdev->dvbdev, &dvbdev_demux, dmxdev, DVB_DEVICE_DEMUX);
- dvb_register_device(dvb_adapter, &dmxdev->dvr_dvbdev, &dvbdev_dvr, dmxdev, DVB_DEVICE_DVR);
+ dvb_register_device(dvb_adapter, &dmxdev->dvbdev, &dvbdev_demux, dmxdev,
+ DVB_DEVICE_DEMUX);
+ dvb_register_device(dvb_adapter, &dmxdev->dvr_dvbdev, &dvbdev_dvr,
+ dmxdev, DVB_DEVICE_DVR);
- dvb_dmxdev_buffer_init(&dmxdev->dvr_buffer);
+ dvb_ringbuffer_init(&dmxdev->dvr_buffer, NULL, 8192);
return 0;
}
+
EXPORT_SYMBOL(dvb_dmxdev_init);
-void
-dvb_dmxdev_release(struct dmxdev *dmxdev)
+void dvb_dmxdev_release(struct dmxdev *dmxdev)
{
dvb_unregister_device(dmxdev->dvbdev);
dvb_unregister_device(dmxdev->dvr_dvbdev);
vfree(dmxdev->filter);
- dmxdev->filter=NULL;
+ dmxdev->filter = NULL;
dmxdev->demux->close(dmxdev->demux);
}
+
EXPORT_SYMBOL(dvb_dmxdev_release);
diff --git a/linux/drivers/media/dvb/dvb-core/dmxdev.h b/linux/drivers/media/dvb/dvb-core/dmxdev.h
index d1d34a71b..080abd9a9 100644
--- a/linux/drivers/media/dvb/dvb-core/dmxdev.h
+++ b/linux/drivers/media/dvb/dvb-core/dmxdev.h
@@ -39,8 +39,9 @@
#include "dvbdev.h"
#include "demux.h"
+#include "dvb_ringbuffer.h"
-enum dmxdevype {
+enum dmxdev_type {
DMXDEV_TYPE_NONE,
DMXDEV_TYPE_SEC,
DMXDEV_TYPE_PES,
@@ -55,18 +56,7 @@ enum dmxdev_state {
DMXDEV_STATE_TIMEDOUT
};
-struct dmxdev_buffer {
- u8 *data;
- int size;
- int pread;
- int pwrite;
- wait_queue_head_t queue;
- int error;
-};
-
struct dmxdev_filter {
- struct dvb_device *dvbdev;
-
union {
struct dmx_section_filter *sec;
} filter;
@@ -81,10 +71,10 @@ struct dmxdev_filter {
struct dmx_pes_filter_params pes;
} params;
- int type;
+ enum dmxdev_type type;
enum dmxdev_state state;
struct dmxdev *dev;
- struct dmxdev_buffer buffer;
+ struct dvb_ringbuffer buffer;
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
struct mutex mutex;
@@ -96,8 +86,6 @@ struct dmxdev_filter {
struct timer_list timer;
int todo;
u8 secheader[3];
-
- u16 pid;
};
@@ -113,7 +101,7 @@ struct dmxdev {
#define DMXDEV_CAP_DUPLEX 1
struct dmx_frontend *dvr_orig_fe;
- struct dmxdev_buffer dvr_buffer;
+ struct dvb_ringbuffer dvr_buffer;
#define DVR_BUFFER_SIZE (10*188*1024)
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_frontend.h b/linux/drivers/media/dvb/dvb-core/dvb_frontend.h
index 70a6d14ef..d5aee5ad6 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.h
+++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.h
@@ -104,6 +104,7 @@ struct dvb_frontend {
struct dvb_adapter *dvb;
void* demodulator_priv;
void* frontend_priv;
+ void* misc_priv;
};
extern int dvb_register_frontend(struct dvb_adapter* dvb,
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.c b/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.c
index 77ad2410f..c972fe014 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.c
+++ b/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.c
@@ -45,6 +45,7 @@ void dvb_ringbuffer_init(struct dvb_ringbuffer *rbuf, void *data, size_t len)
rbuf->pread=rbuf->pwrite=0;
rbuf->data=data;
rbuf->size=len;
+ rbuf->error=0;
init_waitqueue_head(&rbuf->queue);
@@ -87,6 +88,7 @@ ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf)
void dvb_ringbuffer_flush(struct dvb_ringbuffer *rbuf)
{
rbuf->pread = rbuf->pwrite;
+ rbuf->error = 0;
}
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.h b/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.h
index 6d2560972..d97714e75 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.h
+++ b/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.h
@@ -35,6 +35,7 @@ struct dvb_ringbuffer {
ssize_t size;
ssize_t pread;
ssize_t pwrite;
+ int error;
wait_queue_head_t queue;
spinlock_t lock;
diff --git a/linux/drivers/media/dvb/dvb-usb/dtt200u.c b/linux/drivers/media/dvb/dvb-usb/dtt200u.c
index d2ce5d52a..b25f65238 100644
--- a/linux/drivers/media/dvb/dvb-usb/dtt200u.c
+++ b/linux/drivers/media/dvb/dvb-usb/dtt200u.c
@@ -151,7 +151,7 @@ static struct dvb_usb_properties dtt200u_properties = {
.cold_ids = { &dtt200u_usb_table[0], NULL },
.warm_ids = { &dtt200u_usb_table[1], NULL },
},
- { 0 },
+ { NULL },
}
};
@@ -192,7 +192,7 @@ static struct dvb_usb_properties wt220u_properties = {
.cold_ids = { &dtt200u_usb_table[2], NULL },
.warm_ids = { &dtt200u_usb_table[3], NULL },
},
- { 0 },
+ { NULL },
}
};
diff --git a/linux/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/linux/drivers/media/dvb/dvb-usb/dvb-usb-init.c
index 4258a995d..a1705ecb9 100644
--- a/linux/drivers/media/dvb/dvb-usb/dvb-usb-init.c
+++ b/linux/drivers/media/dvb/dvb-usb/dvb-usb-init.c
@@ -47,7 +47,7 @@ static int dvb_usb_init(struct dvb_usb_device *d)
d->state = DVB_USB_STATE_INIT;
-/* check the capabilites and set appropriate variables */
+/* check the capabilities and set appropriate variables */
/* speed - when running at FULL speed we need a HW PID filter */
if (d->udev->speed == USB_SPEED_FULL && !(d->props.caps & DVB_USB_HAS_PID_FILTER)) {
diff --git a/linux/drivers/media/dvb/dvb-usb/dvb-usb.h b/linux/drivers/media/dvb/dvb-usb/dvb-usb.h
index bdf596c42..b14e842d0 100644
--- a/linux/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/linux/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -91,7 +91,7 @@ struct dvb_usb_device;
/**
* struct dvb_usb_properties - properties of a dvb-usb-device
- * @caps: capabilites of the DVB USB device.
+ * @caps: capabilities of the DVB USB device.
* @pid_filter_count: number of PID filter position in the optional hardware
* PID-filter.
*
diff --git a/linux/drivers/media/dvb/dvb-usb/vp7045.c b/linux/drivers/media/dvb/dvb-usb/vp7045.c
index 16aa00ec4..20beb2539 100644
--- a/linux/drivers/media/dvb/dvb-usb/vp7045.c
+++ b/linux/drivers/media/dvb/dvb-usb/vp7045.c
@@ -247,7 +247,7 @@ static struct dvb_usb_properties vp7045_properties = {
.cold_ids = { &vp7045_usb_table[2], NULL },
.warm_ids = { &vp7045_usb_table[3], NULL },
},
- { 0 },
+ { NULL },
}
};
diff --git a/linux/drivers/media/dvb/frontends/Kconfig b/linux/drivers/media/dvb/frontends/Kconfig
index c676b1e23..94233168d 100644
--- a/linux/drivers/media/dvb/frontends/Kconfig
+++ b/linux/drivers/media/dvb/frontends/Kconfig
@@ -116,6 +116,12 @@ config DVB_MT352
help
A DVB-T tuner module. Say Y when you want to support this frontend.
+config DVB_ZL10353
+ tristate "Zarlink ZL10353 based"
+ depends on DVB_CORE
+ help
+ A DVB-T tuner module. Say Y when you want to support this frontend.
+
config DVB_DIB3000MB
tristate "DiBcom 3000M-B"
depends on DVB_CORE
@@ -155,7 +161,7 @@ comment "ATSC (North American/Korean Terresterial DTV) frontends"
depends on DVB_CORE
config DVB_NXT200X
- tristate "Nextwave NXT2002/NXT2004 based"
+ tristate "NxtWave Communications NXT2002/NXT2004 based"
depends on DVB_CORE
select FW_LOADER
help
@@ -169,14 +175,14 @@ config DVB_NXT200X
or /lib/firmware (depending on configuration of firmware hotplug).
config DVB_OR51211
- tristate "or51211 based (pcHDTV HD2000 card)"
+ tristate "Oren OR51211 based"
depends on DVB_CORE
select FW_LOADER
help
An ATSC 8VSB tuner module. Say Y when you want to support this frontend.
config DVB_OR51132
- tristate "OR51132 based (pcHDTV HD3000 card)"
+ tristate "Oren OR51132 based"
depends on DVB_CORE
select FW_LOADER
help
diff --git a/linux/drivers/media/dvb/frontends/Makefile b/linux/drivers/media/dvb/frontends/Makefile
index 1af769cd9..d09b6071f 100644
--- a/linux/drivers/media/dvb/frontends/Makefile
+++ b/linux/drivers/media/dvb/frontends/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_DVB_TDA1004X) += tda1004x.o
obj-$(CONFIG_DVB_SP887X) += sp887x.o
obj-$(CONFIG_DVB_NXT6000) += nxt6000.o
obj-$(CONFIG_DVB_MT352) += mt352.o
+obj-$(CONFIG_DVB_ZL10353) += zl10353.o
obj-$(CONFIG_DVB_CX22702) += cx22702.o
obj-$(CONFIG_DVB_TDA10021) += tda10021.o
obj-$(CONFIG_DVB_STV0297) += stv0297.o
diff --git a/linux/drivers/media/dvb/frontends/bsbe1.h b/linux/drivers/media/dvb/frontends/bsbe1.h
new file mode 100644
index 000000000..78573b22a
--- /dev/null
+++ b/linux/drivers/media/dvb/frontends/bsbe1.h
@@ -0,0 +1,123 @@
+/*
+ * bsbe1.h - ALPS BSBE1 tuner support (moved from av7110.c)
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
+ *
+ *
+ * the project's page is at http://www.linuxtv.org
+ */
+
+#ifndef BSBE1_H
+#define BSBE1_H
+
+static u8 alps_bsbe1_inittab[] = {
+ 0x01, 0x15,
+ 0x02, 0x30,
+ 0x03, 0x00,
+ 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
+ 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
+ 0x06, 0x40, /* DAC not used, set to high impendance mode */
+ 0x07, 0x00, /* DAC LSB */
+ 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
+ 0x09, 0x00, /* FIFO */
+ 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
+ 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
+ 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
+ 0x10, 0x3f, // AGC2 0x3d
+ 0x11, 0x84,
+ 0x12, 0xb9,
+ 0x15, 0xc9, // lock detector threshold
+ 0x16, 0x00,
+ 0x17, 0x00,
+ 0x18, 0x00,
+ 0x19, 0x00,
+ 0x1a, 0x00,
+ 0x1f, 0x50,
+ 0x20, 0x00,
+ 0x21, 0x00,
+ 0x22, 0x00,
+ 0x23, 0x00,
+ 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
+ 0x29, 0x1e, // 1/2 threshold
+ 0x2a, 0x14, // 2/3 threshold
+ 0x2b, 0x0f, // 3/4 threshold
+ 0x2c, 0x09, // 5/6 threshold
+ 0x2d, 0x05, // 7/8 threshold
+ 0x2e, 0x01,
+ 0x31, 0x1f, // test all FECs
+ 0x32, 0x19, // viterbi and synchro search
+ 0x33, 0xfc, // rs control
+ 0x34, 0x93, // error control
+ 0x0f, 0x92,
+ 0xff, 0xff
+};
+
+
+static int alps_bsbe1_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
+{
+ u8 aclk = 0;
+ u8 bclk = 0;
+
+ if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
+ else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
+ else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
+ else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
+ else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
+ else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
+
+ stv0299_writereg(fe, 0x13, aclk);
+ stv0299_writereg(fe, 0x14, bclk);
+ stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
+ stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
+ stv0299_writereg(fe, 0x21, (ratio ) & 0xf0);
+
+ return 0;
+}
+
+static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
+{
+ int ret;
+ u8 data[4];
+ u32 div;
+ struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
+
+ if ((params->frequency < 950000) || (params->frequency > 2150000))
+ return -EINVAL;
+
+ div = (params->frequency + (125 - 1)) / 125; // round correctly
+ data[0] = (div >> 8) & 0x7f;
+ data[1] = div & 0xff;
+ data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
+ data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4;
+
+ ret = i2c_transfer(i2c, &msg, 1);
+ return (ret != 1) ? -EIO : 0;
+}
+
+static struct stv0299_config alps_bsbe1_config = {
+ .demod_address = 0x68,
+ .inittab = alps_bsbe1_inittab,
+ .mclk = 88000000UL,
+ .invert = 1,
+ .skip_reinit = 0,
+ .min_delay_ms = 100,
+ .set_symbol_rate = alps_bsbe1_set_symbol_rate,
+ .pll_set = alps_bsbe1_pll_set,
+};
+
+#endif
diff --git a/linux/drivers/media/dvb/frontends/dvb-pll.c b/linux/drivers/media/dvb/frontends/dvb-pll.c
index 4f682534d..b6e2c387a 100644
--- a/linux/drivers/media/dvb/frontends/dvb-pll.c
+++ b/linux/drivers/media/dvb/frontends/dvb-pll.c
@@ -404,6 +404,21 @@ struct dvb_pll_desc dvb_pll_philips_td1316 = {
};
EXPORT_SYMBOL(dvb_pll_philips_td1316);
+/* FE6600 used on DViCO Hybrid */
+struct dvb_pll_desc dvb_pll_thomson_fe6600 = {
+ .name = "Thomson FE6600",
+ .min = 44250000,
+ .max = 858000000,
+ .count = 4,
+ .entries = {
+ { 250000000, 36213333, 166667, 0xb4, 0x12 },
+ { 455000000, 36213333, 166667, 0xfe, 0x11 },
+ { 775500000, 36213333, 166667, 0xbc, 0x18 },
+ { 999999999, 36213333, 166667, 0xf4, 0x18 },
+ }
+};
+EXPORT_SYMBOL(dvb_pll_thomson_fe6600);
+
/* ----------------------------------------------------------- */
/* code */
diff --git a/linux/drivers/media/dvb/frontends/dvb-pll.h b/linux/drivers/media/dvb/frontends/dvb-pll.h
index 56c3cd76a..2b8461784 100644
--- a/linux/drivers/media/dvb/frontends/dvb-pll.h
+++ b/linux/drivers/media/dvb/frontends/dvb-pll.h
@@ -42,6 +42,8 @@ extern struct dvb_pll_desc dvb_pll_samsung_tbmv;
extern struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261;
extern struct dvb_pll_desc dvb_pll_philips_td1316;
+extern struct dvb_pll_desc dvb_pll_thomson_fe6600;
+
int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
u32 freq, int bandwidth);
diff --git a/linux/drivers/media/dvb/frontends/lnbp21.h b/linux/drivers/media/dvb/frontends/lnbp21.h
new file mode 100644
index 000000000..0dcbe61b6
--- /dev/null
+++ b/linux/drivers/media/dvb/frontends/lnbp21.h
@@ -0,0 +1,139 @@
+/*
+ * lnbp21.h - driver for lnb supply and control ic lnbp21
+ *
+ * Copyright (C) 2006 Oliver Endriss
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
+ *
+ *
+ * the project's page is at http://www.linuxtv.org
+ */
+
+#ifndef _LNBP21_H
+#define _LNBP21_H
+
+/* system register */
+#define LNBP21_OLF 0x01
+#define LNBP21_OTF 0x02
+#define LNBP21_EN 0x04
+#define LNBP21_VSEL 0x08
+#define LNBP21_LLC 0x10
+#define LNBP21_TEN 0x20
+#define LNBP21_ISEL 0x40
+#define LNBP21_PCL 0x80
+
+struct lnbp21 {
+ u8 config;
+ u8 override_or;
+ u8 override_and;
+ struct i2c_adapter *i2c;
+ void (*release_chain)(struct dvb_frontend* fe);
+};
+
+static int lnbp21_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
+{
+ struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv;
+ struct i2c_msg msg = { .addr = 0x08, .flags = 0,
+ .buf = &lnbp21->config,
+ .len = sizeof(lnbp21->config) };
+
+ lnbp21->config &= ~(LNBP21_VSEL | LNBP21_EN);
+
+ switch(voltage) {
+ case SEC_VOLTAGE_OFF:
+ break;
+ case SEC_VOLTAGE_13:
+ lnbp21->config |= LNBP21_EN;
+ break;
+ case SEC_VOLTAGE_18:
+ lnbp21->config |= (LNBP21_EN | LNBP21_VSEL);
+ break;
+ default:
+ return -EINVAL;
+ };
+
+ lnbp21->config |= lnbp21->override_or;
+ lnbp21->config &= lnbp21->override_and;
+
+ return (i2c_transfer(lnbp21->i2c, &msg, 1) == 1) ? 0 : -EIO;
+}
+
+static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
+{
+ struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv;
+ struct i2c_msg msg = { .addr = 0x08, .flags = 0,
+ .buf = &lnbp21->config,
+ .len = sizeof(lnbp21->config) };
+
+ if (arg)
+ lnbp21->config |= LNBP21_LLC;
+ else
+ lnbp21->config &= ~LNBP21_LLC;
+
+ lnbp21->config |= lnbp21->override_or;
+ lnbp21->config &= lnbp21->override_and;
+
+ return (i2c_transfer(lnbp21->i2c, &msg, 1) == 1) ? 0 : -EIO;
+}
+
+static void lnbp21_exit(struct dvb_frontend *fe)
+{
+ struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv;
+
+ /* LNBP power off */
+ lnbp21_set_voltage(fe, SEC_VOLTAGE_OFF);
+
+ /* free data & call next release routine */
+ fe->ops->release = lnbp21->release_chain;
+ kfree(fe->misc_priv);
+ fe->misc_priv = NULL;
+ if (fe->ops->release)
+ fe->ops->release(fe);
+}
+
+static int lnbp21_init(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear)
+{
+ struct lnbp21 *lnbp21 = kmalloc(sizeof(struct lnbp21), GFP_KERNEL);
+
+ if (!lnbp21)
+ return -ENOMEM;
+
+ /* default configuration */
+ lnbp21->config = LNBP21_ISEL;
+
+ /* bits which should be forced to '1' */
+ lnbp21->override_or = override_set;
+
+ /* bits which should be forced to '0' */
+ lnbp21->override_and = ~override_clear;
+
+ /* install release callback */
+ lnbp21->release_chain = fe->ops->release;
+ fe->ops->release = lnbp21_exit;
+
+ /* override frontend ops */
+ fe->ops->set_voltage = lnbp21_set_voltage;
+ fe->ops->enable_high_lnb_voltage = lnbp21_enable_high_lnb_voltage;
+
+ lnbp21->i2c = i2c;
+ fe->misc_priv = lnbp21;
+
+ return lnbp21_set_voltage(fe, SEC_VOLTAGE_OFF);
+}
+
+#endif
diff --git a/linux/drivers/media/dvb/frontends/zl10353.c b/linux/drivers/media/dvb/frontends/zl10353.c
new file mode 100644
index 000000000..10bb871fa
--- /dev/null
+++ b/linux/drivers/media/dvb/frontends/zl10353.c
@@ -0,0 +1,323 @@
+/*
+ * Driver for Zarlink DVB-T ZL10353 demodulator
+ *
+ * Copyright (C) 2006 Christopher Pascoe <c.pascoe@itee.uq.edu.au>
+ *
+ * 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 <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+
+#include "dvb_frontend.h"
+#include "zl10353_priv.h"
+#include "zl10353.h"
+
+struct zl10353_state {
+ struct i2c_adapter *i2c;
+ struct dvb_frontend frontend;
+ struct dvb_frontend_ops ops;
+
+ struct zl10353_config config;
+};
+
+#if 1
+static int debug_regs = 0;
+#endif
+
+static int zl10353_single_write(struct dvb_frontend *fe, u8 reg, u8 val)
+{
+ struct zl10353_state *state = fe->demodulator_priv;
+ u8 buf[2] = { reg, val };
+ struct i2c_msg msg = { .addr = state->config.demod_address, .flags = 0,
+ .buf = buf, .len = 2 };
+ int err = i2c_transfer(state->i2c, &msg, 1);
+ if (err != 1) {
+ printk("zl10353: write to reg %x failed (err = %d)!\n", reg, err);
+ return err;
+ }
+ return 0;
+}
+
+int zl10353_write(struct dvb_frontend *fe, u8 *ibuf, int ilen)
+{
+ int err, i;
+ for (i = 0; i < ilen - 1; i++)
+ if ((err = zl10353_single_write(fe, ibuf[0] + i, ibuf[i + 1])))
+ return err;
+
+ return 0;
+}
+
+static int zl10353_read_register(struct zl10353_state *state, u8 reg)
+{
+ int ret;
+ u8 b0[1] = { reg };
+ u8 b1[1] = { 0 };
+ struct i2c_msg msg[2] = { { .addr = state->config.demod_address,
+ .flags = 0,
+ .buf = b0, .len = 1 },
+ { .addr = state->config.demod_address,
+ .flags = I2C_M_RD,
+ .buf = b1, .len = 1 } };
+
+ ret = i2c_transfer(state->i2c, msg, 2);
+
+ if (ret != 2) {
+ printk("%s: readreg error (reg=%d, ret==%i)\n",
+ __FUNCTION__, reg, ret);
+ return ret;
+ }
+
+ return b1[0];
+}
+
+#if 1
+static void zl10353_dump_regs(struct dvb_frontend *fe)
+{
+ struct zl10353_state *state = fe->demodulator_priv;
+ char buf[52], buf2[4];
+ int ret;
+ u8 reg;
+
+ /* Dump all registers. */
+ for (reg = 0; ; reg++) {
+ if (reg % 16 == 0) {
+ if (reg)
+ printk(KERN_DEBUG "%s\n", buf);
+ sprintf(buf, "%02x: ", reg);
+ }
+ ret = zl10353_read_register(state, reg);
+ if (ret >= 0)
+ sprintf(buf2, "%02x ", (u8)ret);
+ else
+ strcpy(buf2, "-- ");
+ strcat(buf, buf2);
+ if (reg == 0xff)
+ break;
+ }
+ printk(KERN_DEBUG "%s\n", buf);
+}
+#endif
+
+static int zl10353_sleep(struct dvb_frontend *fe)
+{
+ static u8 zl10353_softdown[] = { 0x50, 0x0C, 0x44 };
+
+ zl10353_write(fe, zl10353_softdown, sizeof(zl10353_softdown));
+ return 0;
+}
+
+static int zl10353_set_parameters(struct dvb_frontend *fe,
+ struct dvb_frontend_parameters *param)
+{
+ struct zl10353_state *state = fe->demodulator_priv;
+ u8 pllbuf[6] = { 0x67 };
+
+ /* These settings set "auto-everything" and start the FSM. */
+ zl10353_single_write(fe, 0x55, 0x80);
+ udelay(200);
+ zl10353_single_write(fe, 0xEA, 0x01);
+ udelay(200);
+ zl10353_single_write(fe, 0xEA, 0x00);
+
+ zl10353_single_write(fe, 0x56, 0x28);
+ zl10353_single_write(fe, 0x89, 0x20);
+ zl10353_single_write(fe, 0x5E, 0x00);
+ zl10353_single_write(fe, 0x65, 0x5A);
+ zl10353_single_write(fe, 0x66, 0xE9);
+ zl10353_single_write(fe, 0x62, 0x0A);
+
+ state->config.pll_set(fe, param, pllbuf + 1);
+ zl10353_write(fe, pllbuf, sizeof(pllbuf));
+
+ zl10353_single_write(fe, 0x70, 0x01);
+ udelay(250);
+ zl10353_single_write(fe, 0xE4, 0x00);
+ zl10353_single_write(fe, 0xE5, 0x2A);
+ zl10353_single_write(fe, 0xE9, 0x02);
+ zl10353_single_write(fe, 0xE7, 0x40);
+ zl10353_single_write(fe, 0xE8, 0x10);
+
+ return 0;
+}
+
+static int zl10353_read_status(struct dvb_frontend *fe, fe_status_t *status)
+{
+ struct zl10353_state *state = fe->demodulator_priv;
+ int s6, s7, s8;
+
+ if ((s6 = zl10353_read_register(state, STATUS_6)) < 0)
+ return -EREMOTEIO;
+ if ((s7 = zl10353_read_register(state, STATUS_7)) < 0)
+ return -EREMOTEIO;
+ if ((s8 = zl10353_read_register(state, STATUS_8)) < 0)
+ return -EREMOTEIO;
+
+ *status = 0;
+ if (s6 & (1 << 2))
+ *status |= FE_HAS_CARRIER;
+ if (s6 & (1 << 1))
+ *status |= FE_HAS_VITERBI;
+ if (s6 & (1 << 5))
+ *status |= FE_HAS_LOCK;
+ if (s7 & (1 << 4))
+ *status |= FE_HAS_SYNC;
+ if (s8 & (1 << 6))
+ *status |= FE_HAS_SIGNAL;
+
+ if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) !=
+ (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC))
+ *status &= ~FE_HAS_LOCK;
+
+ return 0;
+}
+
+static int zl10353_read_snr(struct dvb_frontend *fe, u16 *snr)
+{
+ struct zl10353_state *state = fe->demodulator_priv;
+ u8 _snr;
+
+#if 1
+ if (debug_regs)
+ zl10353_dump_regs(fe);
+#endif
+
+ _snr = zl10353_read_register(state, SNR);
+ *snr = (_snr << 8) | _snr;
+
+ return 0;
+}
+
+static int zl10353_get_tune_settings(struct dvb_frontend *fe,
+ struct dvb_frontend_tune_settings
+ *fe_tune_settings)
+{
+ fe_tune_settings->min_delay_ms = 1000;
+ fe_tune_settings->step_size = 0;
+ fe_tune_settings->max_drift = 0;
+
+ return 0;
+}
+
+static int zl10353_init(struct dvb_frontend *fe)
+{
+ struct zl10353_state *state = fe->demodulator_priv;
+ u8 zl10353_reset_attach[6] = { 0x50, 0x03, 0x64, 0x46, 0x15, 0x0F };
+ int rc = 0;
+
+#if 1
+ if (debug_regs)
+ zl10353_dump_regs(fe);
+#endif
+
+ /* Do a "hard" reset if not already done */
+ if (zl10353_read_register(state, 0x50) != 0x03) {
+ rc = zl10353_write(fe, zl10353_reset_attach,
+ sizeof(zl10353_reset_attach));
+#if 1
+ if (debug_regs)
+ zl10353_dump_regs(fe);
+#endif
+ }
+
+ return 0;
+}
+
+static void zl10353_release(struct dvb_frontend *fe)
+{
+ struct zl10353_state *state = fe->demodulator_priv;
+
+ kfree(state);
+}
+
+static struct dvb_frontend_ops zl10353_ops;
+
+struct dvb_frontend *zl10353_attach(const struct zl10353_config *config,
+ struct i2c_adapter *i2c)
+{
+ struct zl10353_state *state = NULL;
+
+ /* allocate memory for the internal state */
+ state = kzalloc(sizeof(struct zl10353_state), GFP_KERNEL);
+ if (state == NULL)
+ goto error;
+
+ /* setup the state */
+ state->i2c = i2c;
+ memcpy(&state->config, config, sizeof(struct zl10353_config));
+ memcpy(&state->ops, &zl10353_ops, sizeof(struct dvb_frontend_ops));
+
+ /* check if the demod is there */
+ if (zl10353_read_register(state, CHIP_ID) != ID_ZL10353)
+ goto error;
+
+ /* create dvb_frontend */
+ state->frontend.ops = &state->ops;
+ state->frontend.demodulator_priv = state;
+
+ return &state->frontend;
+error:
+ kfree(state);
+ return NULL;
+}
+
+static struct dvb_frontend_ops zl10353_ops = {
+
+ .info = {
+ .name = "Zarlink ZL10353 DVB-T",
+ .type = FE_OFDM,
+ .frequency_min = 174000000,
+ .frequency_max = 862000000,
+ .frequency_stepsize = 166667,
+ .frequency_tolerance = 0,
+ .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
+ FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
+ FE_CAN_FEC_AUTO |
+ FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
+ FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
+ FE_CAN_HIERARCHY_AUTO | FE_CAN_RECOVER |
+ FE_CAN_MUTE_TS
+ },
+
+ .release = zl10353_release,
+
+ .init = zl10353_init,
+ .sleep = zl10353_sleep,
+
+ .set_frontend = zl10353_set_parameters,
+ .get_tune_settings = zl10353_get_tune_settings,
+
+ .read_status = zl10353_read_status,
+ .read_snr = zl10353_read_snr,
+};
+
+#if 1
+module_param(debug_regs, int, 0644);
+MODULE_PARM_DESC(debug_regs, "Turn on/off frontend register dumps (default:off).");
+#endif
+
+MODULE_DESCRIPTION("Zarlink ZL10353 DVB-T demodulator driver");
+MODULE_AUTHOR("Chris Pascoe");
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(zl10353_attach);
+EXPORT_SYMBOL(zl10353_write);
diff --git a/linux/drivers/media/dvb/frontends/zl10353.h b/linux/drivers/media/dvb/frontends/zl10353.h
new file mode 100644
index 000000000..5cc4ae718
--- /dev/null
+++ b/linux/drivers/media/dvb/frontends/zl10353.h
@@ -0,0 +1,43 @@
+/*
+ * Driver for Zarlink DVB-T ZL10353 demodulator
+ *
+ * Copyright (C) 2006 Christopher Pascoe <c.pascoe@itee.uq.edu.au>
+ *
+ * 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 ZL10353_H
+#define ZL10353_H
+
+#include <linux/dvb/frontend.h>
+
+struct zl10353_config
+{
+ /* demodulator's I2C address */
+ u8 demod_address;
+
+ /* function which configures the PLL buffer (for secondary I2C
+ * connected tuner) or tunes the PLL (for direct connected tuner) */
+ int (*pll_set)(struct dvb_frontend *fe,
+ struct dvb_frontend_parameters *params, u8 *pllbuf);
+};
+
+extern struct dvb_frontend* zl10353_attach(const struct zl10353_config *config,
+ struct i2c_adapter *i2c);
+
+extern int zl10353_write(struct dvb_frontend *fe, u8 *ibuf, int ilen);
+
+#endif /* ZL10353_H */
diff --git a/linux/drivers/media/dvb/frontends/zl10353_priv.h b/linux/drivers/media/dvb/frontends/zl10353_priv.h
new file mode 100644
index 000000000..b72224bd7
--- /dev/null
+++ b/linux/drivers/media/dvb/frontends/zl10353_priv.h
@@ -0,0 +1,42 @@
+/*
+ * Driver for Zarlink DVB-T ZL10353 demodulator
+ *
+ * Copyright (C) 2006 Christopher Pascoe <c.pascoe@itee.uq.edu.au>
+ *
+ * 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 _ZL10353_PRIV_
+#define _ZL10353_PRIV_
+
+#define ID_ZL10353 0x14
+
+enum zl10353_reg_addr {
+ INTERRUPT_0 = 0x00,
+ INTERRUPT_1 = 0x01,
+ INTERRUPT_2 = 0x02,
+ INTERRUPT_3 = 0x03,
+ INTERRUPT_4 = 0x04,
+ INTERRUPT_5 = 0x05,
+ STATUS_6 = 0x06,
+ STATUS_7 = 0x07,
+ STATUS_8 = 0x08,
+ STATUS_9 = 0x09,
+ SNR = 0x10,
+ CHIP_ID = 0x7F,
+};
+
+#endif /* _ZL10353_PRIV_ */
diff --git a/linux/drivers/media/dvb/ttpci/av7110.c b/linux/drivers/media/dvb/ttpci/av7110.c
index 90d53f962..106022c39 100644
--- a/linux/drivers/media/dvb/ttpci/av7110.c
+++ b/linux/drivers/media/dvb/ttpci/av7110.c
@@ -66,6 +66,9 @@
#include "av7110_ca.h"
#include "av7110_ipack.h"
+#include "bsbe1.h"
+#include "lnbp21.h"
+
#define TS_WIDTH 376
#define TS_HEIGHT 512
#define TS_BUFLEN (TS_WIDTH*TS_HEIGHT)
@@ -1087,11 +1090,9 @@ static int dvb_get_stc(struct dmx_demux *demux, unsigned int num,
struct av7110 *av7110;
/* pointer casting paranoia... */
- if (!demux)
- BUG();
+ BUG_ON(!demux);
dvbdemux = (struct dvb_demux *) demux->priv;
- if (!dvbdemux)
- BUG();
+ BUG_ON(!dvbdemux);
av7110 = (struct av7110 *) dvbdemux->priv;
dprintk(4, "%p\n", av7110);
@@ -1438,7 +1439,7 @@ static int check_firmware(struct av7110* av7110)
len = ntohl(*(u32*) ptr);
ptr += 4;
if (len >= 512) {
- printk("dvb-ttpci: dpram file is way to big.\n");
+ printk("dvb-ttpci: dpram file is way too big.\n");
return -EINVAL;
}
if (crc != crc32_le(0, ptr, len)) {
@@ -1672,105 +1673,6 @@ static struct stv0299_config alps_bsru6_config = {
};
-static u8 alps_bsbe1_inittab[] = {
- 0x01, 0x15,
- 0x02, 0x30,
- 0x03, 0x00,
- 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
- 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
- 0x06, 0x40, /* DAC not used, set to high impendance mode */
- 0x07, 0x00, /* DAC LSB */
- 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
- 0x09, 0x00, /* FIFO */
- 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
- 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
- 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
- 0x10, 0x3f, // AGC2 0x3d
- 0x11, 0x84,
- 0x12, 0xb9,
- 0x15, 0xc9, // lock detector threshold
- 0x16, 0x00,
- 0x17, 0x00,
- 0x18, 0x00,
- 0x19, 0x00,
- 0x1a, 0x00,
- 0x1f, 0x50,
- 0x20, 0x00,
- 0x21, 0x00,
- 0x22, 0x00,
- 0x23, 0x00,
- 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
- 0x29, 0x1e, // 1/2 threshold
- 0x2a, 0x14, // 2/3 threshold
- 0x2b, 0x0f, // 3/4 threshold
- 0x2c, 0x09, // 5/6 threshold
- 0x2d, 0x05, // 7/8 threshold
- 0x2e, 0x01,
- 0x31, 0x1f, // test all FECs
- 0x32, 0x19, // viterbi and synchro search
- 0x33, 0xfc, // rs control
- 0x34, 0x93, // error control
- 0x0f, 0x92,
- 0xff, 0xff
-};
-
-static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
-{
- int ret;
- u8 data[4];
- u32 div;
- struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
-
- if ((params->frequency < 950000) || (params->frequency > 2150000))
- return -EINVAL;
-
- div = (params->frequency + (125 - 1)) / 125; // round correctly
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
- data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4;
-
- ret = i2c_transfer(i2c, &msg, 1);
- return (ret != 1) ? -EIO : 0;
-}
-
-static struct stv0299_config alps_bsbe1_config = {
- .demod_address = 0x68,
- .inittab = alps_bsbe1_inittab,
- .mclk = 88000000UL,
- .invert = 1,
- .skip_reinit = 0,
- .min_delay_ms = 100,
- .set_symbol_rate = alps_bsru6_set_symbol_rate,
- .pll_set = alps_bsbe1_pll_set,
-};
-
-static int lnbp21_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
-{
- struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
- int ret;
- u8 data[1];
- struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = data, .len = sizeof(data) };
-
- switch(voltage) {
- case SEC_VOLTAGE_OFF:
- data[0] = 0x00;
- break;
- case SEC_VOLTAGE_13:
- data[0] = 0x44;
- break;
- case SEC_VOLTAGE_18:
- data[0] = 0x4c;
- break;
- default:
- return -EINVAL;
- };
-
- ret = i2c_transfer(&av7110->i2c_adap, &msg, 1);
- return (ret != 1) ? -EIO : 0;
-}
-
-
static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
{
struct av7110* av7110 = fe->dvb->priv;
@@ -2373,9 +2275,15 @@ static int frontend_init(struct av7110 *av7110)
/* ALPS BSBE1 */
av7110->fe = stv0299_attach(&alps_bsbe1_config, &av7110->i2c_adap);
if (av7110->fe) {
- av7110->fe->ops->set_voltage = lnbp21_set_voltage;
- av7110->fe->ops->dishnetwork_send_legacy_command = NULL;
- av7110->recover = dvb_s_recover;
+ if (lnbp21_init(av7110->fe, &av7110->i2c_adap, 0, 0)) {
+ printk("dvb-ttpci: LNBP21 not found!\n");
+ if (av7110->fe->ops->release)
+ av7110->fe->ops->release(av7110->fe);
+ av7110->fe = NULL;
+ } else {
+ av7110->fe->ops->dishnetwork_send_legacy_command = NULL;
+ av7110->recover = dvb_s_recover;
+ }
}
break;
}
diff --git a/linux/drivers/media/dvb/ttpci/av7110_hw.c b/linux/drivers/media/dvb/ttpci/av7110_hw.c
index 68153d967..668f6cc10 100644
--- a/linux/drivers/media/dvb/ttpci/av7110_hw.c
+++ b/linux/drivers/media/dvb/ttpci/av7110_hw.c
@@ -245,6 +245,9 @@ int av7110_bootarm(struct av7110 *av7110)
/* test DEBI */
iwdebi(av7110, DEBISWAP, DPRAM_BASE, 0x76543210, 4);
+ /* FIXME: Why does Nexus CA require 2x iwdebi for first init? */
+ iwdebi(av7110, DEBISWAP, DPRAM_BASE, 0x76543210, 4);
+
if ((ret=irdebi(av7110, DEBINOSWAP, DPRAM_BASE, 0, 4)) != 0x10325476) {
printk(KERN_ERR "dvb-ttpci: debi test in av7110_bootarm() failed: "
"%08x != %08x (check your BIOS 'Plug&Play OS' settings)\n",
diff --git a/linux/drivers/media/dvb/ttpci/budget-ci.c b/linux/drivers/media/dvb/ttpci/budget-ci.c
index b9b3cd9c0..09b972b9f 100644
--- a/linux/drivers/media/dvb/ttpci/budget-ci.c
+++ b/linux/drivers/media/dvb/ttpci/budget-ci.c
@@ -42,6 +42,8 @@
#include "stv0299.h"
#include "stv0297.h"
#include "tda1004x.h"
+#include "lnbp21.h"
+#include "bsbe1.h"
#define DEBIADDR_IR 0x1234
#define DEBIADDR_CICONTROL 0x0000
@@ -1069,6 +1071,20 @@ static void frontend_init(struct budget_ci *budget_ci)
break;
}
break;
+
+ case 0x1017: // TT S-1500 PCI
+ budget_ci->budget.dvb_frontend = stv0299_attach(&alps_bsbe1_config, &budget_ci->budget.i2c_adap);
+ if (budget_ci->budget.dvb_frontend) {
+ budget_ci->budget.dvb_frontend->ops->dishnetwork_send_legacy_command = NULL;
+ if (lnbp21_init(budget_ci->budget.dvb_frontend, &budget_ci->budget.i2c_adap, LNBP21_LLC, 0)) {
+ printk("%s: No LNBP21 found!\n", __FUNCTION__);
+ if (budget_ci->budget.dvb_frontend->ops->release)
+ budget_ci->budget.dvb_frontend->ops->release(budget_ci->budget.dvb_frontend);
+ budget_ci->budget.dvb_frontend = NULL;
+ }
+ }
+
+ break;
}
if (budget_ci->budget.dvb_frontend == NULL) {
@@ -1146,6 +1162,7 @@ static int budget_ci_detach(struct saa7146_dev *dev)
static struct saa7146_extension budget_extension;
+MAKE_BUDGET_INFO(ttbs2, "TT-Budget/S-1500 PCI", BUDGET_TT);
MAKE_BUDGET_INFO(ttbci, "TT-Budget/WinTV-NOVA-CI PCI", BUDGET_TT_HW_DISEQC);
MAKE_BUDGET_INFO(ttbt2, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT);
MAKE_BUDGET_INFO(ttbtci, "TT-Budget-T-CI PCI", BUDGET_TT);
@@ -1157,6 +1174,7 @@ static struct pci_device_id pci_tbl[] = {
MAKE_EXTENSION_PCI(ttbcci, 0x13c2, 0x1010),
MAKE_EXTENSION_PCI(ttbt2, 0x13c2, 0x1011),
MAKE_EXTENSION_PCI(ttbtci, 0x13c2, 0x1012),
+ MAKE_EXTENSION_PCI(ttbs2, 0x13c2, 0x1017),
{
.vendor = 0,
}
diff --git a/linux/drivers/media/dvb/ttpci/budget.c b/linux/drivers/media/dvb/ttpci/budget.c
index 238c77b52..bfb809250 100644
--- a/linux/drivers/media/dvb/ttpci/budget.c
+++ b/linux/drivers/media/dvb/ttpci/budget.c
@@ -41,6 +41,7 @@
#include "l64781.h"
#include "tda8083.h"
#include "s5h1420.h"
+#include "lnbp21.h"
static void Set22K (struct budget *budget, int state)
{
@@ -184,64 +185,6 @@ static int budget_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t m
return 0;
}
-static int lnbp21_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
-{
- struct budget* budget = (struct budget*) fe->dvb->priv;
- u8 buf;
- struct i2c_msg msg = { .addr = 0x08, .flags = I2C_M_RD, .buf = &buf, .len = sizeof(buf) };
-
- if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
-
- switch(voltage) {
- case SEC_VOLTAGE_13:
- buf = (buf & 0xf7) | 0x04;
- break;
-
- case SEC_VOLTAGE_18:
- buf = (buf & 0xf7) | 0x0c;
- break;
-
- case SEC_VOLTAGE_OFF:
- buf = buf & 0xf0;
- break;
- }
-
- msg.flags = 0;
- if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
-
- return 0;
-}
-
-static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend* fe, long arg)
-{
- struct budget* budget = (struct budget*) fe->dvb->priv;
- u8 buf;
- struct i2c_msg msg = { .addr = 0x08, .flags = I2C_M_RD, .buf = &buf, .len = sizeof(buf) };
-
- if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
-
- if (arg) {
- buf = buf | 0x10;
- } else {
- buf = buf & 0xef;
- }
-
- msg.flags = 0;
- if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
-
- return 0;
-}
-
-static int lnbp21_init(struct budget* budget)
-{
- u8 buf = 0x00;
- struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = &buf, .len = sizeof(buf) };
-
- if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1)
- return -EIO;
- return 0;
-}
-
static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
{
struct budget* budget = (struct budget*) fe->dvb->priv;
@@ -374,79 +317,6 @@ static struct stv0299_config alps_bsru6_config = {
.pll_set = alps_bsru6_pll_set,
};
-static u8 alps_bsbe1_inittab[] = {
- 0x01, 0x15,
- 0x02, 0x30,
- 0x03, 0x00,
- 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
- 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
- 0x06, 0x40, /* DAC not used, set to high impendance mode */
- 0x07, 0x00, /* DAC LSB */
- 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
- 0x09, 0x00, /* FIFO */
- 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
- 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
- 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
- 0x10, 0x3f, // AGC2 0x3d
- 0x11, 0x84,
- 0x12, 0xb9,
- 0x15, 0xc9, // lock detector threshold
- 0x16, 0x00,
- 0x17, 0x00,
- 0x18, 0x00,
- 0x19, 0x00,
- 0x1a, 0x00,
- 0x1f, 0x50,
- 0x20, 0x00,
- 0x21, 0x00,
- 0x22, 0x00,
- 0x23, 0x00,
- 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
- 0x29, 0x1e, // 1/2 threshold
- 0x2a, 0x14, // 2/3 threshold
- 0x2b, 0x0f, // 3/4 threshold
- 0x2c, 0x09, // 5/6 threshold
- 0x2d, 0x05, // 7/8 threshold
- 0x2e, 0x01,
- 0x31, 0x1f, // test all FECs
- 0x32, 0x19, // viterbi and synchro search
- 0x33, 0xfc, // rs control
- 0x34, 0x93, // error control
- 0x0f, 0x92, // 0x80 = inverse AGC
- 0xff, 0xff
-};
-
-static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
-{
- int ret;
- u8 data[4];
- u32 div;
- struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
-
- if ((params->frequency < 950000) || (params->frequency > 2150000))
- return -EINVAL;
-
- div = (params->frequency + (125 - 1)) / 125; // round correctly
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
- data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4;
-
- ret = i2c_transfer(i2c, &msg, 1);
- return (ret != 1) ? -EIO : 0;
-}
-
-static struct stv0299_config alps_bsbe1_config = {
- .demod_address = 0x68,
- .inittab = alps_bsbe1_inittab,
- .mclk = 88000000UL,
- .invert = 1,
- .skip_reinit = 0,
- .min_delay_ms = 100,
- .set_symbol_rate = alps_bsru6_set_symbol_rate,
- .pll_set = alps_bsbe1_pll_set,
-};
-
static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
{
struct budget* budget = (struct budget*) fe->dvb->priv;
@@ -580,20 +450,6 @@ static u8 read_pwm(struct budget* budget)
static void frontend_init(struct budget *budget)
{
switch(budget->dev->pci->subsystem_device) {
- case 0x1017:
- // try the ALPS BSBE1 now
- budget->dvb_frontend = stv0299_attach(&alps_bsbe1_config, &budget->i2c_adap);
- if (budget->dvb_frontend) {
- budget->dvb_frontend->ops->set_voltage = lnbp21_set_voltage;
- budget->dvb_frontend->ops->enable_high_lnb_voltage = lnbp21_enable_high_lnb_voltage;
- budget->dvb_frontend->ops->dishnetwork_send_legacy_command = NULL;
- if (lnbp21_init(budget)) {
- printk("%s: No LNBP21 found!\n", __FUNCTION__);
- goto error_out;
- }
- }
-
- break;
case 0x1003: // Hauppauge/TT Nova budget (stv0299/ALPS BSRU6(tsa5059) OR ves1893/ALPS BSRV2(sp5659))
case 0x1013:
// try the ALPS BSRV2 first of all
@@ -646,9 +502,7 @@ static void frontend_init(struct budget *budget)
case 0x1016: // Hauppauge/TT Nova-S SE (samsung s5h1420/????(tda8260))
budget->dvb_frontend = s5h1420_attach(&s5h1420_config, &budget->i2c_adap);
if (budget->dvb_frontend) {
- budget->dvb_frontend->ops->set_voltage = lnbp21_set_voltage;
- budget->dvb_frontend->ops->enable_high_lnb_voltage = lnbp21_enable_high_lnb_voltage;
- if (lnbp21_init(budget)) {
+ if (lnbp21_init(budget->dvb_frontend, &budget->i2c_adap, 0, 0)) {
printk("%s: No LNBP21 found!\n", __FUNCTION__);
goto error_out;
}
@@ -719,7 +573,6 @@ static int budget_detach (struct saa7146_dev* dev)
static struct saa7146_extension budget_extension;
-MAKE_BUDGET_INFO(ttbs2, "TT-Budget/WinTV-NOVA-S PCI (rev AL/alps bsbe1 lnbp21 frontend)", BUDGET_TT);
MAKE_BUDGET_INFO(ttbs, "TT-Budget/WinTV-NOVA-S PCI", BUDGET_TT);
MAKE_BUDGET_INFO(ttbc, "TT-Budget/WinTV-NOVA-C PCI", BUDGET_TT);
MAKE_BUDGET_INFO(ttbt, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT);
@@ -732,7 +585,6 @@ static struct pci_device_id pci_tbl[] = {
MAKE_EXTENSION_PCI(ttbc, 0x13c2, 0x1004),
MAKE_EXTENSION_PCI(ttbt, 0x13c2, 0x1005),
MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013),
- MAKE_EXTENSION_PCI(ttbs2, 0x13c2, 0x1017),
MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1016),
MAKE_EXTENSION_PCI(fsacs1,0x1131, 0x4f60),
MAKE_EXTENSION_PCI(fsacs0,0x1131, 0x4f61),
diff --git a/linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index 245db934f..69a550871 100644
--- a/linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -696,8 +696,7 @@ static void ttusb_process_frame(struct ttusb *ttusb, u8 * data, int len)
memcpy(ttusb->muxpack + ttusb->muxpack_ptr,
data, avail);
ttusb->muxpack_ptr += avail;
- if (ttusb->muxpack_ptr > 264)
- BUG();
+ BUG_ON(ttusb->muxpack_ptr > 264);
data += avail;
len -= avail;
/* determine length */
diff --git a/linux/drivers/media/video/Kconfig b/linux/drivers/media/video/Kconfig
index f6889f771..e9d536e63 100644
--- a/linux/drivers/media/video/Kconfig
+++ b/linux/drivers/media/video/Kconfig
@@ -26,6 +26,7 @@ config VIDEO_BT848
select VIDEO_IR
select VIDEO_TUNER
select VIDEO_TVEEPROM
+ select VIDEO_MSP3400
---help---
Support for BT848 based frame grabber/overlay boards. This includes
the Miro, Hauppauge and STB boards. Please read the material in
@@ -142,15 +143,7 @@ config VIDEO_CPIA_USB
otherwise say N. This will not work with the Creative Webcam III.
It is also available as a module (cpia_usb).
-config VIDEO_CPIA2
- tristate "CPiA2 Video For Linux"
- depends on VIDEO_DEV
- ---help---
- This is the video4linux driver for cameras based on Vision's CPiA2
- (Colour Processor Interface ASIC), such as the Digital Blue QX5
- Microscope. If you have one of these cameras, say Y here
-
- This driver is also available as a module (cpia2).
+source "drivers/media/video/cpia2/Kconfig"
config VIDEO_SAA5246A
tristate "SAA5246A, SAA5281 Teletext processor"
@@ -324,6 +317,8 @@ source "drivers/media/video/cx88/Kconfig"
source "drivers/media/video/em28xx/Kconfig"
+source "drivers/media/video/pvrusb2/Kconfig"
+
config VIDEO_OVCAMCHIP
tristate "OmniVision Camera Chip support"
depends on VIDEO_DEV && I2C
@@ -349,18 +344,53 @@ config VIDEO_M32R_AR_M64278
Say Y here to use the Renesas M64278E-800 camera module,
which supports VGA(640x480 pixcels) size of images.
-config VIDEO_AUDIO_DECODER
- tristate "Add support for additional audio chipsets"
+config VIDEO_MSP3400
+ tristate "Micronas MSP34xx audio decoders"
+ depends on VIDEO_DEV && I2C
+ ---help---
+ Support for the Micronas MSP34xx series of audio decoders.
+
+ To compile this driver as a module, choose M here: the
+ module will be called msp3400
+
+config VIDEO_CS53L32A
+ tristate "Cirrus Logic CS53L32A audio ADC"
+ depends on VIDEO_DEV && I2C && EXPERIMENTAL
+ ---help---
+ Support for the Cirrus Logic CS53L32A low voltage
+ stereo A/D converter.
+
+ To compile this driver as a module, choose M here: the
+ module will be called cs53l32a
+
+config VIDEO_WM8775
+ tristate "Wolfson Microelectronics WM8775 audio ADC"
+ depends on VIDEO_DEV && I2C && EXPERIMENTAL
+ ---help---
+ Support for the Wolfson Microelectronics WM8775
+ high performance stereo A/D Converter.
+
+ To compile this driver as a module, choose M here: the
+ module will be called wm8775
+
+source "drivers/media/video/cx25840/Kconfig"
+
+config VIDEO_SAA711X
+ tristate "Philips SAA7113/4/5 video decoders"
depends on VIDEO_DEV && I2C && EXPERIMENTAL
---help---
- Say Y here to compile drivers for WM8775 and CS53L32A audio
- decoders.
+ Support for the Philips SAA7113/4/5 video decoders.
+
+ To compile this driver as a module, choose M here: the
+ module will be called saa7115
-config VIDEO_DECODER
- tristate "Add support for additional video chipsets"
+config VIDEO_SAA7127
+ tristate "Philips SAA7127/9 digital video encoders"
depends on VIDEO_DEV && I2C && EXPERIMENTAL
---help---
- Say Y here to compile drivers for SAA7115, SAA7127 and CX25840
- video decoders.
+ Support for the Philips SAA7127/9 digital video encoders.
+
+ To compile this driver as a module, choose M here: the
+ module will be called saa7127
endmenu
diff --git a/linux/drivers/media/video/Makefile b/linux/drivers/media/video/Makefile
index 87b1ce6e2..2b88cfdd2 100644
--- a/linux/drivers/media/video/Makefile
+++ b/linux/drivers/media/video/Makefile
@@ -15,7 +15,7 @@ msp3400-objs := msp3400-driver.o msp3400-kthreads.o
obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-common.o v4l1-compat.o compat_ioctl32.o
-obj-$(CONFIG_VIDEO_BT848) += bttv.o msp3400.o tvaudio.o \
+obj-$(CONFIG_VIDEO_BT848) += bttv.o tvaudio.o \
tda7432.o tda9875.o ir-kbd-i2c.o
obj-$(CONFIG_SOUND_TVMIXER) += tvmixer.o
@@ -44,11 +44,14 @@ obj-$(CONFIG_VIDEO_MEYE) += meye.o
obj-$(CONFIG_VIDEO_SAA7134) += ir-kbd-i2c.o saa7134/
obj-$(CONFIG_VIDEO_CX88) += cx88/
obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
-obj-$(CONFIG_VIDEO_EM28XX) += saa711x.o tvp5150.o
-obj-$(CONFIG_VIDEO_AUDIO_DECODER) += wm8775.o cs53l32a.o
+obj-$(CONFIG_VIDEO_EM28XX) += tvp5150.o
+obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2/
+obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
+obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o
+obj-$(CONFIG_VIDEO_WM8775) += wm8775.o
obj-$(CONFIG_VIDEO_OVCAMCHIP) += ovcamchip/
obj-$(CONFIG_VIDEO_CPIA2) += cpia2/
-obj-$(CONFIG_VIDEO_MXB) += saa7111.o tuner.o tda9840.o tea6415c.o tea6420.o mxb.o
+obj-$(CONFIG_VIDEO_MXB) += saa7111.o tda9840.o tea6415c.o tea6420.o mxb.o
obj-$(CONFIG_VIDEO_HEXIUM_ORION) += hexium_orion.o
obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o
obj-$(CONFIG_VIDEO_DPC) += saa7111.o dpc7146.o
@@ -62,6 +65,8 @@ obj-$(CONFIG_VIDEO_TVEEPROM) += tveeprom.o
obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o
-obj-$(CONFIG_VIDEO_DECODER) += saa7115.o cx25840/ saa7127.o
+obj-$(CONFIG_VIDEO_CX25840) += cx25840/
+obj-$(CONFIG_VIDEO_SAA711X) += saa7115.o
+obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o
EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
diff --git a/linux/drivers/media/video/bttv-cards.c b/linux/drivers/media/video/bttv-cards.c
index b46f1118b..47131de0d 100644
--- a/linux/drivers/media/video/bttv-cards.c
+++ b/linux/drivers/media/video/bttv-cards.c
@@ -161,6 +161,8 @@ MODULE_PARM_DESC(card,"specify TV/grabber card model, see CARDLIST file for a li
MODULE_PARM_DESC(pll,"specify installed crystal (0=none, 28=28 MHz, 35=35 MHz)");
MODULE_PARM_DESC(tuner,"specify installed tuner type");
MODULE_PARM_DESC(autoload,"automatically load i2c modules like tuner.o, default is 1 (yes)");
+MODULE_PARM_DESC(no_overlay,"allow override overlay default (0 disables, 1 enables)"
+ " [some VIA/SIS chipsets are known to have problem with overlay]");
/* ----------------------------------------------------------------------- */
/* list of card IDs for bt878+ cards */
@@ -5044,12 +5046,14 @@ void __devinit bttv_check_chipset(void)
if (vsfx)
printk(KERN_INFO "bttv: Host bridge needs VSFX enabled.\n");
if (pcipci_fail) {
- printk(KERN_WARNING "bttv: BT848 and your chipset may not work together.\n");
+ printk(KERN_INFO "bttv: bttv and your chipset may not work "
+ "together.\n");
if (!no_overlay) {
- printk(KERN_WARNING "bttv: overlay will be disabled.\n");
+ printk(KERN_INFO "bttv: overlay will be disabled.\n");
no_overlay = 1;
} else {
- printk(KERN_WARNING "bttv: overlay forced. Use this option at your own risk.\n");
+ printk(KERN_INFO "bttv: overlay forced. Use this "
+ "option at your own risk.\n");
}
}
if (UNSET != latency)
diff --git a/linux/drivers/media/video/bttv-driver.c b/linux/drivers/media/video/bttv-driver.c
index 46aec8404..0b321480b 100644
--- a/linux/drivers/media/video/bttv-driver.c
+++ b/linux/drivers/media/video/bttv-driver.c
@@ -1423,7 +1423,7 @@ bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh,
free_btres(btv,fh,RESOURCE_OVERLAY);
if (NULL != old) {
dprintk("switch_overlay: old=%p state is %d\n",old,old->vb.state);
- bttv_dma_free(btv, old);
+ bttv_dma_free(&fh->cap,btv, old);
kfree(old);
}
dprintk("switch_overlay: done\n");
@@ -1433,7 +1433,8 @@ bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh,
/* ----------------------------------------------------------------------- */
/* video4linux (1) interface */
-static int bttv_prepare_buffer(struct bttv *btv, struct bttv_buffer *buf,
+static int bttv_prepare_buffer(struct videobuf_queue *q,struct bttv *btv,
+ struct bttv_buffer *buf,
const struct bttv_format *fmt,
unsigned int width, unsigned int height,
enum v4l2_field field)
@@ -1476,7 +1477,7 @@ static int bttv_prepare_buffer(struct bttv *btv, struct bttv_buffer *buf,
/* alloc risc memory */
if (STATE_NEEDS_INIT == buf->vb.state) {
redo_dma_risc = 1;
- if (0 != (rc = videobuf_iolock(btv->c.pci,&buf->vb,&btv->fbuf)))
+ if (0 != (rc = videobuf_iolock(q,&buf->vb,&btv->fbuf)))
goto fail;
}
@@ -1488,7 +1489,7 @@ static int bttv_prepare_buffer(struct bttv *btv, struct bttv_buffer *buf,
return 0;
fail:
- bttv_dma_free(btv,buf);
+ bttv_dma_free(q,btv,buf);
return rc;
}
@@ -1512,7 +1513,7 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
struct bttv_fh *fh = q->priv_data;
- return bttv_prepare_buffer(fh->btv, buf, fh->fmt,
+ return bttv_prepare_buffer(q,fh->btv, buf, fh->fmt,
fh->width, fh->height, field);
}
@@ -1536,7 +1537,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
struct bttv_fh *fh = q->priv_data;
- bttv_dma_free(fh->btv,buf);
+ bttv_dma_free(&fh->cap,fh->btv,buf);
}
static struct videobuf_queue_ops bttv_video_qops = {
@@ -2522,7 +2523,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
field = (vm->height > bttv_tvnorms[btv->tvnorm].sheight/2)
? V4L2_FIELD_INTERLACED
: V4L2_FIELD_BOTTOM;
- retval = bttv_prepare_buffer(btv,buf,
+ retval = bttv_prepare_buffer(&fh->cap,btv,buf,
format_by_palette(vm->format),
vm->width,vm->height,field);
if (0 != retval)
@@ -2554,8 +2555,8 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
retval = -EIO;
/* fall through */
case STATE_DONE:
- videobuf_dma_pci_sync(btv->c.pci,&buf->vb.dma);
- bttv_dma_free(btv,buf);
+ videobuf_dma_sync(&fh->cap,&buf->vb.dma);
+ bttv_dma_free(&fh->cap,btv,buf);
break;
default:
retval = -EINVAL;
diff --git a/linux/drivers/media/video/bttv-risc.c b/linux/drivers/media/video/bttv-risc.c
index 4efe74dd8..53dfe0f4d 100644
--- a/linux/drivers/media/video/bttv-risc.c
+++ b/linux/drivers/media/video/bttv-risc.c
@@ -277,6 +277,8 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc,
if (line > maxy)
btcx_calc_skips(line, ov->w.width, &maxy,
skips, &nskips, ov->clips, ov->nclips);
+ else
+ nskips = 0;
/* write out risc code */
for (start = 0, skip = 0; start < ov->w.width; start = end) {
@@ -512,12 +514,11 @@ bttv_risc_hook(struct bttv *btv, int slot, struct btcx_riscmem *risc,
}
void
-bttv_dma_free(struct bttv *btv, struct bttv_buffer *buf)
+bttv_dma_free(struct videobuf_queue *q,struct bttv *btv, struct bttv_buffer *buf)
{
- if (in_interrupt())
- BUG();
+ BUG_ON(in_interrupt());
videobuf_waiton(&buf->vb,0,0);
- videobuf_dma_pci_unmap(btv->c.pci, &buf->vb.dma);
+ videobuf_dma_unmap(q, &buf->vb.dma);
videobuf_dma_free(&buf->vb.dma);
btcx_riscmem_free(btv->c.pci,&buf->bottom);
btcx_riscmem_free(btv->c.pci,&buf->top);
diff --git a/linux/drivers/media/video/bttv-vbi.c b/linux/drivers/media/video/bttv-vbi.c
index d10d81f77..136218014 100644
--- a/linux/drivers/media/video/bttv-vbi.c
+++ b/linux/drivers/media/video/bttv-vbi.c
@@ -97,7 +97,7 @@ static int vbi_buffer_prepare(struct videobuf_queue *q,
return -EINVAL;
if (STATE_NEEDS_INIT == buf->vb.state) {
- if (0 != (rc = videobuf_iolock(btv->c.pci, &buf->vb, NULL)))
+ if (0 != (rc = videobuf_iolock(q, &buf->vb, NULL)))
goto fail;
if (0 != (rc = vbi_buffer_risc(btv,buf,fh->lines)))
goto fail;
@@ -110,7 +110,7 @@ static int vbi_buffer_prepare(struct videobuf_queue *q,
return 0;
fail:
- bttv_dma_free(btv,buf);
+ bttv_dma_free(q,btv,buf);
return rc;
}
@@ -137,7 +137,7 @@ static void vbi_buffer_release(struct videobuf_queue *q, struct videobuf_buffer
struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
dprintk("free %p\n",vb);
- bttv_dma_free(fh->btv,buf);
+ bttv_dma_free(&fh->cap,fh->btv,buf);
}
struct videobuf_queue_ops bttv_vbi_qops = {
diff --git a/linux/drivers/media/video/bttvp.h b/linux/drivers/media/video/bttvp.h
index 5d92d713e..d5469ad2b 100644
--- a/linux/drivers/media/video/bttvp.h
+++ b/linux/drivers/media/video/bttvp.h
@@ -200,7 +200,8 @@ int bttv_buffer_activate_video(struct bttv *btv,
struct bttv_buffer_set *set);
int bttv_buffer_activate_vbi(struct bttv *btv,
struct bttv_buffer *vbi);
-void bttv_dma_free(struct bttv *btv, struct bttv_buffer *buf);
+void bttv_dma_free(struct videobuf_queue *q, struct bttv *btv,
+ struct bttv_buffer *buf);
/* overlay handling */
int bttv_overlay_risc(struct bttv *btv, struct bttv_overlay *ov,
diff --git a/linux/drivers/media/video/compat_ioctl32.c b/linux/drivers/media/video/compat_ioctl32.c
index 9e9e9304b..8323dcf30 100644
--- a/linux/drivers/media/video/compat_ioctl32.c
+++ b/linux/drivers/media/video/compat_ioctl32.c
@@ -169,29 +169,32 @@ static int get_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user
if (kp->clipcount > 2048)
return -EINVAL;
if (kp->clipcount) {
- struct v4l2_clip32 *uclips = compat_ptr(up->clips);
- struct v4l2_clip *kclips;
+ struct v4l2_clip32 __user *uclips;
+ struct v4l2_clip __user *kclips;
int n = kp->clipcount;
+ compat_caddr_t p;
+ if (get_user(p, &up->clips))
+ return -EFAULT;
+ uclips = compat_ptr(p);
kclips = compat_alloc_user_space(n * sizeof(struct v4l2_clip));
kp->clips = kclips;
while (--n >= 0) {
- if (!access_ok(VERIFY_READ, &uclips->c, sizeof(uclips->c)) ||
- copy_from_user(&kclips->c, &uclips->c, sizeof(uclips->c)))
+ if (copy_in_user(&kclips->c, &uclips->c, sizeof(uclips->c)))
+ return -EFAULT;
+ if (put_user(n ? kclips + 1 : NULL, &kclips->next))
return -EFAULT;
- kclips->next = n ? kclips + 1 : 0;
uclips += 1;
kclips += 1;
}
} else
- kp->clips = 0;
+ kp->clips = NULL;
return 0;
}
static int put_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user *up)
{
- if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_window32)) ||
- copy_to_user(&up->w, &kp->w, sizeof(up->w)) ||
+ if (copy_to_user(&up->w, &kp->w, sizeof(up->w)) ||
put_user(kp->field, &up->field) ||
put_user(kp->chromakey, &up->chromakey) ||
put_user(kp->clipcount, &up->clipcount))
@@ -201,33 +204,29 @@ static int put_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user
static inline int get_v4l2_pix_format(struct v4l2_pix_format *kp, struct v4l2_pix_format __user *up)
{
- if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_pix_format)) ||
- copy_from_user(kp, up, sizeof(struct v4l2_pix_format)))
- return -EFAULT;
+ if (copy_from_user(kp, up, sizeof(struct v4l2_pix_format)))
+ return -EFAULT;
return 0;
}
static inline int put_v4l2_pix_format(struct v4l2_pix_format *kp, struct v4l2_pix_format __user *up)
{
- if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_pix_format)) ||
- copy_to_user(up, kp, sizeof(struct v4l2_pix_format)))
- return -EFAULT;
+ if (copy_to_user(up, kp, sizeof(struct v4l2_pix_format)))
+ return -EFAULT;
return 0;
}
static inline int get_v4l2_vbi_format(struct v4l2_vbi_format *kp, struct v4l2_vbi_format __user *up)
{
- if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_vbi_format)) ||
- copy_from_user(kp, up, sizeof(struct v4l2_vbi_format)))
- return -EFAULT;
+ if (copy_from_user(kp, up, sizeof(struct v4l2_vbi_format)))
+ return -EFAULT;
return 0;
}
static inline int put_v4l2_vbi_format(struct v4l2_vbi_format *kp, struct v4l2_vbi_format __user *up)
{
- if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_vbi_format)) ||
- copy_to_user(up, kp, sizeof(struct v4l2_vbi_format)))
- return -EFAULT;
+ if (copy_to_user(up, kp, sizeof(struct v4l2_vbi_format)))
+ return -EFAULT;
return 0;
}
@@ -281,18 +280,16 @@ static int put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user
static inline int get_v4l2_standard(struct v4l2_standard *kp, struct v4l2_standard __user *up)
{
- if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_standard)) ||
- copy_from_user(kp, up, sizeof(struct v4l2_standard)))
- return -EFAULT;
+ if (copy_from_user(kp, up, sizeof(struct v4l2_standard)))
+ return -EFAULT;
return 0;
}
static inline int put_v4l2_standard(struct v4l2_standard *kp, struct v4l2_standard __user *up)
{
- if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_standard)) ||
- copy_to_user(up, kp, sizeof(struct v4l2_standard)))
- return -EFAULT;
+ if (copy_to_user(up, kp, sizeof(struct v4l2_standard)))
+ return -EFAULT;
return 0;
}
@@ -330,18 +327,16 @@ static int put_v4l2_standard32(struct v4l2_standard *kp, struct v4l2_standard32
static inline int get_v4l2_tuner(struct v4l2_tuner *kp, struct v4l2_tuner __user *up)
{
- if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_tuner)) ||
- copy_from_user(kp, up, sizeof(struct v4l2_tuner)))
- return -EFAULT;
+ if (copy_from_user(kp, up, sizeof(struct v4l2_tuner)))
+ return -EFAULT;
return 0;
}
static inline int put_v4l2_tuner(struct v4l2_tuner *kp, struct v4l2_tuner __user *up)
{
- if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_tuner)) ||
- copy_to_user(up, kp, sizeof(struct v4l2_tuner)))
- return -EFAULT;
+ if (copy_to_user(up, kp, sizeof(struct v4l2_tuner)))
+ return -EFAULT;
return 0;
}
@@ -382,11 +377,13 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
break;
case V4L2_MEMORY_USERPTR:
{
- unsigned long tmp = (unsigned long)compat_ptr(up->m.userptr);
+ compat_long_t tmp;
- if(get_user(kp->length, &up->length) ||
- get_user(kp->m.userptr, &tmp))
- return -EFAULT;
+ if (get_user(kp->length, &up->length) ||
+ get_user(tmp, &up->m.userptr))
+ return -EFAULT;
+
+ kp->m.userptr = (unsigned long)compat_ptr(tmp);
}
break;
case V4L2_MEMORY_OVERLAY:
@@ -470,33 +467,29 @@ static int put_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_frame
static inline int get_v4l2_input32(struct v4l2_input *kp, struct v4l2_input __user *up)
{
- if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_input) - 4) ||
- copy_from_user(kp, up, sizeof(struct v4l2_input) - 4))
- return -EFAULT;
+ if (copy_from_user(kp, up, sizeof(struct v4l2_input) - 4))
+ return -EFAULT;
return 0;
}
static inline int put_v4l2_input32(struct v4l2_input *kp, struct v4l2_input __user *up)
{
- if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_input) - 4) ||
- copy_to_user(up, kp, sizeof(struct v4l2_input) - 4))
- return -EFAULT;
+ if (copy_to_user(up, kp, sizeof(struct v4l2_input) - 4))
+ return -EFAULT;
return 0;
}
static inline int get_v4l2_input(struct v4l2_input *kp, struct v4l2_input __user *up)
{
- if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_input)) ||
- copy_from_user(kp, up, sizeof(struct v4l2_input)))
- return -EFAULT;
+ if (copy_from_user(kp, up, sizeof(struct v4l2_input)))
+ return -EFAULT;
return 0;
}
static inline int put_v4l2_input(struct v4l2_input *kp, struct v4l2_input __user *up)
{
- if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_input)) ||
- copy_to_user(up, kp, sizeof(struct v4l2_input)))
- return -EFAULT;
+ if (copy_to_user(up, kp, sizeof(struct v4l2_input)))
+ return -EFAULT;
return 0;
}
diff --git a/linux/drivers/media/video/cpia2/Kconfig b/linux/drivers/media/video/cpia2/Kconfig
new file mode 100644
index 000000000..513cc0927
--- /dev/null
+++ b/linux/drivers/media/video/cpia2/Kconfig
@@ -0,0 +1,9 @@
+config VIDEO_CPIA2
+ tristate "CPiA2 Video For Linux"
+ depends on VIDEO_DEV && USB
+ ---help---
+ This is the video4linux driver for cameras based on Vision's CPiA2
+ (Colour Processor Interface ASIC), such as the Digital Blue QX5
+ Microscope. If you have one of these cameras, say Y here
+
+ This driver is also available as a module (cpia2).
diff --git a/linux/drivers/media/video/cpia2/cpia2_v4l.c b/linux/drivers/media/video/cpia2/cpia2_v4l.c
index c38681283..2ab1582fd 100644
--- a/linux/drivers/media/video/cpia2/cpia2_v4l.c
+++ b/linux/drivers/media/video/cpia2/cpia2_v4l.c
@@ -1629,7 +1629,7 @@ static int cpia2_do_ioctl(struct inode *inode, struct file *file,
}
switch (ioctl_nr) {
- case VIDIOCGCAP: /* query capabilites */
+ case VIDIOCGCAP: /* query capabilities */
retval = ioctl_cap_query(arg, cam);
break;
@@ -2054,7 +2054,7 @@ static void __init check_parameters(void)
* cpia2_init/module_init
*
*****************************************************************************/
-int __init cpia2_init(void)
+static int __init cpia2_init(void)
{
LOG("%s v%d.%d.%d\n",
ABOUT, CPIA2_MAJ_VER, CPIA2_MIN_VER, CPIA2_PATCH_VER);
@@ -2069,37 +2069,12 @@ int __init cpia2_init(void)
* cpia2_exit/module_exit
*
*****************************************************************************/
-void __exit cpia2_exit(void)
+static void __exit cpia2_exit(void)
{
cpia2_usb_cleanup();
schedule_timeout(2 * HZ);
}
-
-int __init cpia2_setup(char *str)
-{
- while(str) {
- if(!strncmp(str, "buffer_size:", 12)) {
- buffer_size = simple_strtoul(str + 13, &str, 10);
- } else if(!strncmp(str, "num_buffers:", 12)) {
- num_buffers = simple_strtoul(str + 13, &str, 10);
- } else if(!strncmp(str, "alternate:", 10)) {
- alternate = simple_strtoul(str + 11, &str, 10);
- } else if(!strncmp(str, "video_nr:", 9)) {
- video_nr = simple_strtoul(str + 10, &str, 10);
- } else if(!strncmp(str, "flicker_freq:",13)) {
- flicker_freq = simple_strtoul(str + 14, &str, 10);
- } else if(!strncmp(str, "flicker_mode:",13)) {
- flicker_mode = simple_strtoul(str + 14, &str, 10);
- } else {
- ++str;
- }
- }
- return 1;
-}
-
-__setup("cpia2=", cpia2_setup);
-
module_init(cpia2_init);
module_exit(cpia2_exit);
diff --git a/linux/drivers/media/video/cx25840/Kconfig b/linux/drivers/media/video/cx25840/Kconfig
new file mode 100644
index 000000000..854264e42
--- /dev/null
+++ b/linux/drivers/media/video/cx25840/Kconfig
@@ -0,0 +1,9 @@
+config VIDEO_CX25840
+ tristate "Conexant CX2584x audio/video decoders"
+ depends on VIDEO_DEV && I2C && EXPERIMENTAL
+ select FW_LOADER
+ ---help---
+ Support for the Conexant CX2584x audio/video decoders.
+
+ To compile this driver as a module, choose M here: the
+ module will be called cx25840
diff --git a/linux/drivers/media/video/cx25840/Makefile b/linux/drivers/media/video/cx25840/Makefile
index 543ebacdc..32a896c23 100644
--- a/linux/drivers/media/video/cx25840/Makefile
+++ b/linux/drivers/media/video/cx25840/Makefile
@@ -1,6 +1,6 @@
cx25840-objs := cx25840-core.o cx25840-audio.o cx25840-firmware.o \
cx25840-vbi.o
-obj-$(CONFIG_VIDEO_DECODER) += cx25840.o
+obj-$(CONFIG_VIDEO_CX25840) += cx25840.o
EXTRA_CFLAGS += -I$(src)/..
diff --git a/linux/drivers/media/video/cx88/Kconfig b/linux/drivers/media/video/cx88/Kconfig
index e99dfbbf3..e140996e6 100644
--- a/linux/drivers/media/video/cx88/Kconfig
+++ b/linux/drivers/media/video/cx88/Kconfig
@@ -15,20 +15,6 @@ config VIDEO_CX88
To compile this driver as a module, choose M here: the
module will be called cx8800
-config VIDEO_CX88_DVB
- tristate "DVB/ATSC Support for cx2388x based TV cards"
- depends on VIDEO_CX88 && DVB_CORE
- select VIDEO_BUF_DVB
- ---help---
- This adds support for DVB/ATSC cards based on the
- Connexant 2388x chip.
-
- To compile this driver as a module, choose M here: the
- module will be called cx88-dvb.
-
- You must also select one or more DVB/ATSC demodulators.
- If you are unsure which you need, choose all of them.
-
config VIDEO_CX88_ALSA
tristate "ALSA DMA audio support"
depends on VIDEO_CX88 && SND && EXPERIMENTAL
@@ -44,12 +30,27 @@ config VIDEO_CX88_ALSA
To compile this driver as a module, choose M here: the
module will be called cx88-alsa.
+config VIDEO_CX88_DVB
+ tristate "DVB/ATSC Support for cx2388x based TV cards"
+ depends on VIDEO_CX88 && DVB_CORE
+ select VIDEO_BUF_DVB
+ ---help---
+ This adds support for DVB/ATSC cards based on the
+ Connexant 2388x chip.
+
+ To compile this driver as a module, choose M here: the
+ module will be called cx88-dvb.
+
+ You must also select one or more DVB/ATSC demodulators.
+ If you are unsure which you need, choose all of them.
+
config VIDEO_CX88_DVB_ALL_FRONTENDS
bool "Build all supported frontends for cx2388x based TV cards"
default y
depends on VIDEO_CX88_DVB
select DVB_MT352
select VIDEO_CX88_VP3054
+ select DVB_ZL10353
select DVB_OR51132
select DVB_CX22702
select DVB_LGDT330X
@@ -81,6 +82,16 @@ config VIDEO_CX88_VP3054
which also require support for the VP-3054
Secondary I2C bus, such at DNTV Live! DVB-T Pro.
+config VIDEO_CX88_DVB_ZL10353
+ bool "Zarlink ZL10353 DVB-T Support"
+ default y
+ depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
+ select DVB_ZL10353
+ ---help---
+ This adds DVB-T support for cards based on the
+ Connexant 2388x chip and the ZL10353 demodulator,
+ successor to the Zarlink MT352.
+
config VIDEO_CX88_DVB_OR51132
bool "OR51132 ATSC Support"
default y
diff --git a/linux/drivers/media/video/cx88/Makefile b/linux/drivers/media/video/cx88/Makefile
index 2b902784f..6482b9aa6 100644
--- a/linux/drivers/media/video/cx88/Makefile
+++ b/linux/drivers/media/video/cx88/Makefile
@@ -17,6 +17,7 @@ extra-cflags-$(CONFIG_DVB_CX22702) += -DHAVE_CX22702=1
extra-cflags-$(CONFIG_DVB_OR51132) += -DHAVE_OR51132=1
extra-cflags-$(CONFIG_DVB_LGDT330X) += -DHAVE_LGDT330X=1
extra-cflags-$(CONFIG_DVB_MT352) += -DHAVE_MT352=1
+extra-cflags-$(CONFIG_DVB_ZL10353) += -DHAVE_ZL10353=1
extra-cflags-$(CONFIG_DVB_NXT200X) += -DHAVE_NXT200X=1
extra-cflags-$(CONFIG_DVB_CX24123) += -DHAVE_CX24123=1
extra-cflags-$(CONFIG_VIDEO_CX88_VP3054)+= -DHAVE_VP3054_I2C=1
diff --git a/linux/drivers/media/video/cx88/cx88-alsa.c b/linux/drivers/media/video/cx88/cx88-alsa.c
index e5b9007c2..8ecdb41af 100644
--- a/linux/drivers/media/video/cx88/cx88-alsa.c
+++ b/linux/drivers/media/video/cx88/cx88-alsa.c
@@ -317,7 +317,7 @@ static int dsp_buffer_free(snd_cx88_card_t *chip)
BUG_ON(!chip->dma_size);
dprintk(2,"Freeing buffer\n");
- videobuf_dma_pci_unmap(chip->pci, &chip->dma_risc);
+ videobuf_pci_dma_unmap(chip->pci, &chip->dma_risc);
videobuf_dma_free(&chip->dma_risc);
btcx_riscmem_free(chip->pci,&chip->buf->risc);
kfree(chip->buf);
@@ -443,7 +443,7 @@ static int snd_cx88_hw_params(snd_pcm_substream_t * substream,
videobuf_dma_init_kernel(&buf->vb.dma,PCI_DMA_FROMDEVICE,
(PAGE_ALIGN(buf->vb.size) >> PAGE_SHIFT));
- videobuf_dma_pci_map(chip->pci,&buf->vb.dma);
+ videobuf_pci_dma_map(chip->pci,&buf->vb.dma);
cx88_risc_databuffer(chip->pci, &buf->risc,
@@ -686,6 +686,11 @@ static int __devinit snd_cx88_create(snd_card_t *card, struct pci_dev *pci,
chip = (snd_cx88_card_t *) card->private_data;
core = cx88_core_get(pci);
+ if (NULL == core) {
+ err = -EINVAL;
+ kfree (chip);
+ return err;
+ }
if (!pci_dma_supported(pci,0xffffffff)) {
dprintk(0, "%s/1: Oops: no 32bit PCI DMA ???\n",core->name);
@@ -702,11 +707,6 @@ static int __devinit snd_cx88_create(snd_card_t *card, struct pci_dev *pci,
spin_lock_init(&chip->reg_lock);
cx88_reset(core);
- if (NULL == core) {
- err = -EINVAL;
- kfree (chip);
- return err;
- }
chip->core = core;
/* get irq */
diff --git a/linux/drivers/media/video/cx88/cx88-blackbird.c b/linux/drivers/media/video/cx88/cx88-blackbird.c
index fc4cadeaf..0ffef13d5 100644
--- a/linux/drivers/media/video/cx88/cx88-blackbird.c
+++ b/linux/drivers/media/video/cx88/cx88-blackbird.c
@@ -1361,7 +1361,7 @@ bb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
enum v4l2_field field)
{
struct cx8802_fh *fh = q->priv_data;
- return cx8802_buf_prepare(fh->dev, (struct cx88_buffer*)vb, field);
+ return cx8802_buf_prepare(q, fh->dev, (struct cx88_buffer*)vb, field);
}
static void
@@ -1374,8 +1374,7 @@ bb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
static void
bb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
{
- struct cx8802_fh *fh = q->priv_data;
- cx88_free_buffer(fh->dev->pci, (struct cx88_buffer*)vb);
+ cx88_free_buffer(q, (struct cx88_buffer*)vb);
}
static struct videobuf_queue_ops blackbird_qops = {
diff --git a/linux/drivers/media/video/cx88/cx88-cards.c b/linux/drivers/media/video/cx88/cx88-cards.c
index c2eb5b3ea..73b7ed14f 100644
--- a/linux/drivers/media/video/cx88/cx88-cards.c
+++ b/linux/drivers/media/video/cx88/cx88-cards.c
@@ -186,17 +186,18 @@ struct cx88_board cx88_boards[] = {
.input = {{
.type = CX88_VMUX_TELEVISION,
.vmux = 0,
- .gpio1 = 0x309f,
+ .gpio1 = 0xe09f,
},{
.type = CX88_VMUX_COMPOSITE1,
.vmux = 1,
- .gpio1 = 0x305f,
+ .gpio1 = 0xe05f,
},{
.type = CX88_VMUX_SVIDEO,
.vmux = 2,
- .gpio1 = 0x305f,
+ .gpio1 = 0xe05f,
}},
.radio = {
+ .gpio1 = 0xe0df,
.type = CX88_RADIO,
},
},
@@ -324,19 +325,19 @@ struct cx88_board cx88_boards[] = {
.input = {{
.type = CX88_VMUX_TELEVISION,
.vmux = 0,
- .gpio0 = 0xff00,
+ .gpio0 = 0xbff0,
},{
.type = CX88_VMUX_COMPOSITE1,
.vmux = 1,
- .gpio0 = 0xff03,
+ .gpio0 = 0xbff3,
},{
.type = CX88_VMUX_SVIDEO,
.vmux = 2,
- .gpio0 = 0xff03,
+ .gpio0 = 0xbff3,
}},
.radio = {
.type = CX88_RADIO,
- .gpio0 = 0xff00,
+ .gpio0 = 0xbff0,
},
},
[CX88_BOARD_ASUS_PVR_416] = {
@@ -1084,6 +1085,27 @@ struct cx88_board cx88_boards[] = {
.blackbird = 1,
#endif
},
+ [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID] = {
+ .name = "DViCO FusionHDTV DVB-T Hybrid",
+ .tuner_type = TUNER_THOMSON_FE6600,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .input = {{
+ .type = CX88_VMUX_TELEVISION,
+ .vmux = 0,
+ .gpio0 = 0x0000a75f,
+ },{
+ .type = CX88_VMUX_COMPOSITE1,
+ .vmux = 1,
+ .gpio0 = 0x0000a75b,
+ },{
+ .type = CX88_VMUX_SVIDEO,
+ .vmux = 2,
+ .gpio0 = 0x0000a75b,
+ }},
+ .dvb = 1,
+ },
};
const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards);
@@ -1294,6 +1316,14 @@ struct cx88_subid cx88_subids[] = {
.subvendor = 0x17de,
.subdevice = 0x0840,
.card = CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT,
+ },{
+ .subvendor = 0x18ac,
+ .subdevice = 0xdb40,
+ .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID,
+ },{
+ .subvendor = 0x18ac,
+ .subdevice = 0xdb44,
+ .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID,
},
};
const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
@@ -1413,6 +1443,40 @@ static void gdi_eeprom(struct cx88_core *core, u8 *eeprom_data)
}
/* ----------------------------------------------------------------------- */
+/* some DViCO specific stuff */
+
+static void dvico_fusionhdtv_hybrid_init(struct cx88_core *core)
+{
+ struct i2c_msg msg = { .addr = 0x45, .flags = 0 };
+ int i, err;
+ static u8 init_bufs[13][5] = {
+ { 0x10, 0x00, 0x20, 0x01, 0x03 },
+ { 0x10, 0x10, 0x01, 0x00, 0x21 },
+ { 0x10, 0x10, 0x10, 0x00, 0xCA },
+ { 0x10, 0x10, 0x12, 0x00, 0x08 },
+ { 0x10, 0x10, 0x13, 0x00, 0x0A },
+ { 0x10, 0x10, 0x16, 0x01, 0xC0 },
+ { 0x10, 0x10, 0x22, 0x01, 0x3D },
+ { 0x10, 0x10, 0x73, 0x01, 0x2E },
+ { 0x10, 0x10, 0x72, 0x00, 0xC5 },
+ { 0x10, 0x10, 0x71, 0x01, 0x97 },
+ { 0x10, 0x10, 0x70, 0x00, 0x0F },
+ { 0x10, 0x10, 0xB0, 0x00, 0x01 },
+ { 0x03, 0x0C },
+ };
+
+ for (i = 0; i < 13; i++) {
+ msg.buf = init_bufs[i];
+ msg.len = (i != 12 ? 5 : 2);
+ err = i2c_transfer(&core->i2c_adap, &msg, 1);
+ if (err != 1) {
+ printk("dvico_fusionhdtv_hybrid_init buf %d failed (err = %d)!\n", i, err);
+ return;
+ }
+ }
+}
+
+/* ----------------------------------------------------------------------- */
void cx88_card_list(struct cx88_core *core, struct pci_dev *pci)
{
@@ -1478,11 +1542,15 @@ void cx88_card_setup(struct cx88_core *core)
case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
+ case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
/* GPIO0:0 is hooked to mt352 reset pin */
cx_set(MO_GP0_IO, 0x00000101);
cx_clear(MO_GP0_IO, 0x00000001);
msleep(1);
cx_set(MO_GP0_IO, 0x00000101);
+ if (0 == core->i2c_rc &&
+ core->board == CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID)
+ dvico_fusionhdtv_hybrid_init(core);
break;
case CX88_BOARD_KWORLD_DVB_T:
case CX88_BOARD_DNTV_LIVE_DVB_T:
diff --git a/linux/drivers/media/video/cx88/cx88-core.c b/linux/drivers/media/video/cx88/cx88-core.c
index 24acfa2bd..9636dedcf 100644
--- a/linux/drivers/media/video/cx88/cx88-core.c
+++ b/linux/drivers/media/video/cx88/cx88-core.c
@@ -230,14 +230,13 @@ int cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
}
void
-cx88_free_buffer(struct pci_dev *pci, struct cx88_buffer *buf)
+cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf)
{
- if (in_interrupt())
- BUG();
+ BUG_ON(in_interrupt());
videobuf_waiton(&buf->vb,0,0);
- videobuf_dma_pci_unmap(pci, &buf->vb.dma);
+ videobuf_dma_unmap(q, &buf->vb.dma);
videobuf_dma_free(&buf->vb.dma);
- btcx_riscmem_free(pci, &buf->risc);
+ btcx_riscmem_free((struct pci_dev *)q->dev, &buf->risc);
buf->vb.state = STATE_NEEDS_INIT;
}
diff --git a/linux/drivers/media/video/cx88/cx88-dvb.c b/linux/drivers/media/video/cx88/cx88-dvb.c
index 068b2e886..2fdabe2f2 100644
--- a/linux/drivers/media/video/cx88/cx88-dvb.c
+++ b/linux/drivers/media/video/cx88/cx88-dvb.c
@@ -42,6 +42,9 @@
# include "cx88-vp3054-i2c.h"
# endif
#endif
+#ifdef HAVE_ZL10353
+# include "zl10353.h"
+#endif
#ifdef HAVE_CX22702
# include "cx22702.h"
#endif
@@ -89,7 +92,7 @@ static int dvb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
enum v4l2_field field)
{
struct cx8802_dev *dev = q->priv_data;
- return cx8802_buf_prepare(dev, (struct cx88_buffer*)vb,field);
+ return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
}
static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
@@ -100,8 +103,7 @@ static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
static void dvb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
{
- struct cx8802_dev *dev = q->priv_data;
- cx88_free_buffer(dev->pci, (struct cx88_buffer*)vb);
+ cx88_free_buffer(q, (struct cx88_buffer*)vb);
}
static struct videobuf_queue_ops dvb_qops = {
@@ -113,6 +115,21 @@ static struct videobuf_queue_ops dvb_qops = {
/* ------------------------------------------------------------------ */
+#if defined(HAVE_MT352) || defined(HAVE_ZL10353)
+static int zarlink_pll_set(struct dvb_frontend *fe,
+ struct dvb_frontend_parameters *params,
+ u8 *pllbuf)
+{
+ struct cx8802_dev *dev = fe->dvb->priv;
+
+ pllbuf[0] = dev->core->pll_addr << 1;
+ dvb_pll_configure(dev->core->pll_desc, pllbuf + 1,
+ params->frequency,
+ params->u.ofdm.bandwidth);
+ return 0;
+}
+#endif
+
#ifdef HAVE_MT352
static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
{
@@ -178,35 +195,22 @@ static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
return 0;
}
-static int mt352_pll_set(struct dvb_frontend* fe,
- struct dvb_frontend_parameters* params,
- u8* pllbuf)
-{
- struct cx8802_dev *dev= fe->dvb->priv;
-
- pllbuf[0] = dev->core->pll_addr << 1;
- dvb_pll_configure(dev->core->pll_desc, pllbuf+1,
- params->frequency,
- params->u.ofdm.bandwidth);
- return 0;
-}
-
static struct mt352_config dvico_fusionhdtv = {
.demod_address = 0x0F,
.demod_init = dvico_fusionhdtv_demod_init,
- .pll_set = mt352_pll_set,
+ .pll_set = zarlink_pll_set,
};
static struct mt352_config dntv_live_dvbt_config = {
.demod_address = 0x0f,
.demod_init = dntv_live_dvbt_demod_init,
- .pll_set = mt352_pll_set,
+ .pll_set = zarlink_pll_set,
};
static struct mt352_config dvico_fusionhdtv_dual = {
.demod_address = 0x0F,
.demod_init = dvico_dual_demod_init,
- .pll_set = mt352_pll_set,
+ .pll_set = zarlink_pll_set,
};
#ifdef HAVE_VP3054_I2C
@@ -296,6 +300,46 @@ static struct mt352_config dntv_live_dvbt_pro_config = {
#endif
#endif
+#ifdef HAVE_ZL10353
+static int dvico_hybrid_tune_pll(struct dvb_frontend *fe,
+ struct dvb_frontend_parameters *params,
+ u8 *pllbuf)
+{
+ struct cx8802_dev *dev= fe->dvb->priv;
+ struct i2c_msg msg =
+ { .addr = dev->core->pll_addr, .flags = 0,
+ .buf = pllbuf + 1, .len = 4 };
+ int err;
+
+ pllbuf[0] = dev->core->pll_addr << 1;
+ dvb_pll_configure(dev->core->pll_desc, pllbuf + 1,
+ params->frequency,
+ params->u.ofdm.bandwidth);
+
+ if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
+ printk(KERN_WARNING "cx88-dvb: %s error "
+ "(addr %02x <- %02x, err = %i)\n",
+ __FUNCTION__, pllbuf[0], pllbuf[1], err);
+ if (err < 0)
+ return err;
+ else
+ return -EREMOTEIO;
+ }
+
+ return 0;
+}
+
+static struct zl10353_config dvico_fusionhdtv_hybrid = {
+ .demod_address = 0x0F,
+ .pll_set = dvico_hybrid_tune_pll,
+};
+
+static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
+ .demod_address = 0x0F,
+ .pll_set = zarlink_pll_set,
+};
+#endif
+
#ifdef HAVE_CX22702
static struct cx22702_config connexant_refboard_config = {
.demod_address = 0x43,
@@ -502,16 +546,27 @@ static int dvb_register(struct cx8802_dev *dev)
&dev->core->i2c_adap);
break;
#endif
+#if defined(HAVE_MT352) || defined(HAVE_ZL10353)
+ case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
+ dev->core->pll_addr = 0x60;
+ dev->core->pll_desc = &dvb_pll_thomson_dtt7579;
#ifdef HAVE_MT352
- case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
- dev->core->pll_addr = 0x61;
- dev->core->pll_desc = &dvb_pll_lg_z201;
dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv,
&dev->core->i2c_adap);
+ if (dev->dvb.frontend != NULL)
+ break;
+#endif
+#ifdef HAVE_ZL10353
+ /* ZL10353 replaces MT352 on later cards */
+ dev->dvb.frontend = zl10353_attach(&dvico_fusionhdtv_plus_v1_1,
+ &dev->core->i2c_adap);
+#endif
break;
- case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
- dev->core->pll_addr = 0x60;
- dev->core->pll_desc = &dvb_pll_thomson_dtt7579;
+#endif /* HAVE_MT352 || HAVE_ZL10353 */
+#ifdef HAVE_MT352
+ case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
+ dev->core->pll_addr = 0x61;
+ dev->core->pll_desc = &dvb_pll_lg_z201;
dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv,
&dev->core->i2c_adap);
break;
@@ -542,6 +597,14 @@ static int dvb_register(struct cx8802_dev *dev)
&dev->core->i2c_adap);
break;
#endif
+#ifdef HAVE_ZL10353
+ case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
+ dev->core->pll_addr = 0x61;
+ dev->core->pll_desc = &dvb_pll_thomson_fe6600;
+ dev->dvb.frontend = zl10353_attach(&dvico_fusionhdtv_hybrid,
+ &dev->core->i2c_adap);
+ break;
+#endif
#ifdef HAVE_OR51132
case CX88_BOARD_PCHDTV_HD3000:
dev->dvb.frontend = or51132_attach(&pchdtv_hd3000,
diff --git a/linux/drivers/media/video/cx88/cx88-input.c b/linux/drivers/media/video/cx88/cx88-input.c
index 94b9ab35f..11d2e625a 100644
--- a/linux/drivers/media/video/cx88/cx88-input.c
+++ b/linux/drivers/media/video/cx88/cx88-input.c
@@ -188,6 +188,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
ir->mask_keydown = 0x02;
ir->polling = 5; /* ms */
break;
+ case CX88_BOARD_PROLINK_PLAYTVPVR:
case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO:
ir_codes = ir_codes_pixelview;
ir->gpio_addr = MO_GP1_IO;
diff --git a/linux/drivers/media/video/cx88/cx88-mpeg.c b/linux/drivers/media/video/cx88/cx88-mpeg.c
index a40d1bcd0..e0f9db668 100644
--- a/linux/drivers/media/video/cx88/cx88-mpeg.c
+++ b/linux/drivers/media/video/cx88/cx88-mpeg.c
@@ -162,10 +162,43 @@ static int cx8802_restart_queue(struct cx8802_dev *dev,
struct cx88_buffer *buf;
struct list_head *item;
- dprintk( 0, "cx8802_restart_queue\n" );
+ dprintk( 1, "cx8802_restart_queue\n" );
if (list_empty(&q->active))
{
- dprintk( 0, "cx8802_restart_queue: queue is empty\n" );
+ struct cx88_buffer *prev;
+ prev = NULL;
+
+ dprintk(1, "cx8802_restart_queue: queue is empty\n" );
+
+ for (;;) {
+ if (list_empty(&q->queued))
+ return 0;
+ buf = list_entry(q->queued.next, struct cx88_buffer, vb.queue);
+ if (NULL == prev) {
+ list_del(&buf->vb.queue);
+ list_add_tail(&buf->vb.queue,&q->active);
+ cx8802_start_dma(dev, q, buf);
+ buf->vb.state = STATE_ACTIVE;
+ buf->count = q->count++;
+ mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
+ dprintk(1,"[%p/%d] restart_queue - first active\n",
+ buf,buf->vb.i);
+
+ } else if (prev->vb.width == buf->vb.width &&
+ prev->vb.height == buf->vb.height &&
+ prev->fmt == buf->fmt) {
+ list_del(&buf->vb.queue);
+ list_add_tail(&buf->vb.queue,&q->active);
+ buf->vb.state = STATE_ACTIVE;
+ buf->count = q->count++;
+ prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
+ dprintk(1,"[%p/%d] restart_queue - move to active\n",
+ buf,buf->vb.i);
+ } else {
+ return 0;
+ }
+ prev = buf;
+ }
return 0;
}
@@ -183,8 +216,8 @@ static int cx8802_restart_queue(struct cx8802_dev *dev,
/* ------------------------------------------------------------------ */
-int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf,
- enum v4l2_field field)
+int cx8802_buf_prepare(struct videobuf_queue *q, struct cx8802_dev *dev,
+ struct cx88_buffer *buf, enum v4l2_field field)
{
int size = dev->ts_packet_size * dev->ts_packet_count;
int rc;
@@ -199,7 +232,7 @@ int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf,
buf->vb.size = size;
buf->vb.field = field /*V4L2_FIELD_TOP*/;
- if (0 != (rc = videobuf_iolock(dev->pci,&buf->vb,NULL)))
+ if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL)))
goto fail;
cx88_risc_databuffer(dev->pci, &buf->risc,
buf->vb.dma.sglist,
@@ -209,27 +242,27 @@ int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf,
return 0;
fail:
- cx88_free_buffer(dev->pci,buf);
+ cx88_free_buffer(q,buf);
return rc;
}
void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf)
{
struct cx88_buffer *prev;
- struct cx88_dmaqueue *q = &dev->mpegq;
+ struct cx88_dmaqueue *cx88q = &dev->mpegq;
dprintk( 1, "cx8802_buf_queue\n" );
/* add jump to stopper */
buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC);
- buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma);
+ buf->risc.jmp[1] = cpu_to_le32(cx88q->stopper.dma);
- if (list_empty(&q->active)) {
+ if (list_empty(&cx88q->active)) {
dprintk( 0, "queue is empty - first active\n" );
- list_add_tail(&buf->vb.queue,&q->active);
- cx8802_start_dma(dev, q, buf);
+ list_add_tail(&buf->vb.queue,&cx88q->active);
+ cx8802_start_dma(dev, cx88q, buf);
buf->vb.state = STATE_ACTIVE;
- buf->count = q->count++;
- mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
+ buf->count = cx88q->count++;
+ mod_timer(&cx88q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(0,"[%p/%d] %s - first active\n",
buf, buf->vb.i, __FUNCTION__);
#if 0
@@ -238,10 +271,10 @@ void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf)
} else {
dprintk( 1, "queue is not empty - append to active\n" );
- prev = list_entry(q->active.prev, struct cx88_buffer, vb.queue);
- list_add_tail(&buf->vb.queue,&q->active);
+ prev = list_entry(cx88q->active.prev, struct cx88_buffer, vb.queue);
+ list_add_tail(&buf->vb.queue,&cx88q->active);
buf->vb.state = STATE_ACTIVE;
- buf->count = q->count++;
+ buf->count = cx88q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
dprintk( 1, "[%p/%d] %s - append to active\n",
buf, buf->vb.i, __FUNCTION__);
diff --git a/linux/drivers/media/video/cx88/cx88-vbi.c b/linux/drivers/media/video/cx88/cx88-vbi.c
index 800624d7c..bb5ae86c8 100644
--- a/linux/drivers/media/video/cx88/cx88-vbi.c
+++ b/linux/drivers/media/video/cx88/cx88-vbi.c
@@ -177,7 +177,7 @@ vbi_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
buf->vb.size = size;
buf->vb.field = V4L2_FIELD_SEQ_TB;
- if (0 != (rc = videobuf_iolock(dev->pci,&buf->vb,NULL)))
+ if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL)))
goto fail;
cx88_risc_buffer(dev->pci, &buf->risc,
buf->vb.dma.sglist,
@@ -189,7 +189,7 @@ vbi_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
return 0;
fail:
- cx88_free_buffer(dev->pci,buf);
+ cx88_free_buffer(q,buf);
return rc;
}
@@ -229,9 +229,8 @@ vbi_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
static void vbi_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
{
struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb);
- struct cx8800_fh *fh = q->priv_data;
- cx88_free_buffer(fh->dev->pci,buf);
+ cx88_free_buffer(q,buf);
}
struct videobuf_queue_ops cx8800_vbi_qops = {
diff --git a/linux/drivers/media/video/cx88/cx88-video.c b/linux/drivers/media/video/cx88/cx88-video.c
index edd32f7c1..1bcd20d23 100644
--- a/linux/drivers/media/video/cx88/cx88-video.c
+++ b/linux/drivers/media/video/cx88/cx88-video.c
@@ -253,7 +253,7 @@ static struct cx88_ctrl cx8800_ctls[] = {
.minimum = 0x00,
.maximum = 0xff,
.step = 1,
- .default_value = 0,
+ .default_value = 0x7f,
.type = V4L2_CTRL_TYPE_INTEGER,
},
.off = 128,
@@ -281,7 +281,7 @@ static struct cx88_ctrl cx8800_ctls[] = {
.minimum = 0,
.maximum = 0xff,
.step = 1,
- .default_value = 0,
+ .default_value = 0x7f,
.type = V4L2_CTRL_TYPE_INTEGER,
},
.off = 128,
@@ -326,7 +326,7 @@ static struct cx88_ctrl cx8800_ctls[] = {
.minimum = 0,
.maximum = 0x3f,
.step = 1,
- .default_value = 0x1f,
+ .default_value = 0x3f,
.type = V4L2_CTRL_TYPE_INTEGER,
},
.reg = AUD_VOL_CTL,
@@ -392,8 +392,7 @@ static
void res_free(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bits)
{
struct cx88_core *core = dev->core;
- if ((fh->resources & bits) != bits)
- BUG();
+ BUG_ON((fh->resources & bits) != bits);
mutex_lock(&core->lock);
fh->resources &= ~bits;
@@ -591,7 +590,7 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
if (STATE_NEEDS_INIT == buf->vb.state) {
init_buffer = 1;
- if (0 != (rc = videobuf_iolock(dev->pci,&buf->vb,NULL)))
+ if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL)))
goto fail;
}
@@ -641,7 +640,7 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
return 0;
fail:
- cx88_free_buffer(dev->pci,buf);
+ cx88_free_buffer(q,buf);
return rc;
}
@@ -698,9 +697,8 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
{
struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb);
- struct cx8800_fh *fh = q->priv_data;
- cx88_free_buffer(fh->dev->pci,buf);
+ cx88_free_buffer(q,buf);
}
static struct videobuf_queue_ops cx8800_video_qops = {
@@ -1160,7 +1158,8 @@ static int get_control(struct cx88_core *core, struct v4l2_control *ctl)
value = c->sreg ? cx_sread(c->sreg) : cx_read(c->reg);
switch (ctl->id) {
case V4L2_CID_AUDIO_BALANCE:
- ctl->value = (value & 0x40) ? (value & 0x3f) : (0x40 - (value & 0x3f));
+ ctl->value = ((value & 0x7f) < 0x40) ? ((value & 0x7f) + 0x40)
+ : (0x7f - (value & 0x7f));
break;
case V4L2_CID_AUDIO_VOLUME:
ctl->value = 0x3f - (value & 0x3f);
@@ -1205,7 +1204,7 @@ static int set_control(struct cx88_core *core, struct v4l2_control *ctl)
mask=c->mask;
switch (ctl->id) {
case V4L2_CID_AUDIO_BALANCE:
- value = (ctl->value < 0x40) ? (0x40 - ctl->value) : ctl->value;
+ value = (ctl->value < 0x40) ? (0x7f - ctl->value) : (ctl->value - 0x40);
break;
case V4L2_CID_AUDIO_VOLUME:
value = 0x3f - (ctl->value & 0x3f);
@@ -1246,8 +1245,7 @@ static void init_controls(struct cx88_core *core)
for (i = 0; i < CX8800_CTLS; i++) {
ctrl.id=cx8800_ctls[i].v.id;
- ctrl.value=cx8800_ctls[i].v.default_value
- +cx8800_ctls[i].off;
+ ctrl.value=cx8800_ctls[i].v.default_value;
set_control(core, &ctrl);
}
}
@@ -1513,9 +1511,17 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
{
int err;
- dprintk(2, "CORE IOCTL: 0x%x\n", cmd );
- if (video_debug > 1)
- v4l_print_ioctl(core->name,cmd);
+ if (video_debug) {
+ if (video_debug > 1) {
+ if (_IOC_DIR(cmd) & _IOC_WRITE)
+ v4l_printk_ioctl_arg("cx88(w)",cmd, arg);
+ else if (!_IOC_DIR(cmd) & _IOC_READ) {
+ v4l_print_ioctl("cx88", cmd);
+ }
+ } else
+ v4l_print_ioctl(core->name,cmd);
+
+ }
switch (cmd) {
/* ---------- tv norms ---------- */
@@ -1752,7 +1758,19 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
static int video_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
- return video_usercopy(inode, file, cmd, arg, video_do_ioctl);
+ int retval;
+
+ retval=video_usercopy(inode, file, cmd, arg, video_do_ioctl);
+
+ if (video_debug > 1) {
+ if (retval < 0) {
+ v4l_print_ioctl("cx88(err)", cmd);
+ printk(KERN_DEBUG "cx88(err): errcode=%d\n",retval);
+ } else if (_IOC_DIR(cmd) & _IOC_READ)
+ v4l_printk_ioctl_arg("cx88(r)",cmd, (void *)arg);
+ }
+
+ return retval;
}
/* ----------------------------------------------------------- */
diff --git a/linux/drivers/media/video/cx88/cx88.h b/linux/drivers/media/video/cx88/cx88.h
index 7a7219377..889ca7c61 100644
--- a/linux/drivers/media/video/cx88/cx88.h
+++ b/linux/drivers/media/video/cx88/cx88.h
@@ -69,7 +69,7 @@
/* need "shadow" registers for some write-only ones ... */
#define SHADOW_AUD_VOL_CTL 1
#define SHADOW_AUD_BAL_CTL 2
-#define SHADOW_MAX 2
+#define SHADOW_MAX 3
/* FM Radio deemphasis type */
enum cx88_deemph_type {
@@ -198,6 +198,7 @@ extern struct sram_channel cx88_sram_channels[];
#define CX88_BOARD_KWORLD_DVB_T_CX22702 43
#define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL 44
#define CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT 45
+#define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID 46
enum cx88_itype {
CX88_VMUX_COMPOSITE1 = 1,
@@ -525,7 +526,7 @@ extern int
cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
u32 reg, u32 mask, u32 value);
extern void
-cx88_free_buffer(struct pci_dev *pci, struct cx88_buffer *buf);
+cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf);
extern void cx88_risc_disasm(struct cx88_core *core,
struct btcx_riscmem *risc);
@@ -617,8 +618,8 @@ void cx88_ir_irq(struct cx88_core *core);
/* ----------------------------------------------------------- */
/* cx88-mpeg.c */
-int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf,
- enum v4l2_field field);
+int cx8802_buf_prepare(struct videobuf_queue *q,struct cx8802_dev *dev,
+ struct cx88_buffer *buf, enum v4l2_field field);
void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf);
void cx8802_cancel_buffers(struct cx8802_dev *dev);
diff --git a/linux/drivers/media/video/dpc7146.c b/linux/drivers/media/video/dpc7146.c
new file mode 100644
index 000000000..5cce40af6
--- /dev/null
+++ b/linux/drivers/media/video/dpc7146.c
@@ -0,0 +1,402 @@
+/*
+ dpc7146.c - v4l2 driver for the dpc7146 demonstration board
+
+ Copyright (C) 2000-2003 Michael Hunold <michael@mihu.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.
+*/
+
+#define DEBUG_VARIABLE debug
+
+#include "compat.h"
+#include <media/saa7146_vv.h>
+#include <linux/video_decoder.h> /* for saa7111a */
+
+#define I2C_SAA7111A 0x24
+
+/* All unused bytes are reserverd. */
+#define SAA711X_CHIP_VERSION 0x00
+#define SAA711X_ANALOG_INPUT_CONTROL_1 0x02
+#define SAA711X_ANALOG_INPUT_CONTROL_2 0x03
+#define SAA711X_ANALOG_INPUT_CONTROL_3 0x04
+#define SAA711X_ANALOG_INPUT_CONTROL_4 0x05
+#define SAA711X_HORIZONTAL_SYNC_START 0x06
+#define SAA711X_HORIZONTAL_SYNC_STOP 0x07
+#define SAA711X_SYNC_CONTROL 0x08
+#define SAA711X_LUMINANCE_CONTROL 0x09
+#define SAA711X_LUMINANCE_BRIGHTNESS 0x0A
+#define SAA711X_LUMINANCE_CONTRAST 0x0B
+#define SAA711X_CHROMA_SATURATION 0x0C
+#define SAA711X_CHROMA_HUE_CONTROL 0x0D
+#define SAA711X_CHROMA_CONTROL 0x0E
+#define SAA711X_FORMAT_DELAY_CONTROL 0x10
+#define SAA711X_OUTPUT_CONTROL_1 0x11
+#define SAA711X_OUTPUT_CONTROL_2 0x12
+#define SAA711X_OUTPUT_CONTROL_3 0x13
+#define SAA711X_V_GATE_1_START 0x15
+#define SAA711X_V_GATE_1_STOP 0x16
+#define SAA711X_V_GATE_1_MSB 0x17
+#define SAA711X_TEXT_SLICER_STATUS 0x1A
+#define SAA711X_DECODED_BYTES_OF_TS_1 0x1B
+#define SAA711X_DECODED_BYTES_OF_TS_2 0x1C
+#define SAA711X_STATUS_BYTE 0x1F
+
+#define DPC_BOARD_CAN_DO_VBI(dev) (dev->revision != 0)
+
+static int debug = 0;
+module_param(debug, int, 0);
+MODULE_PARM_DESC(debug, "debug verbosity");
+
+static int dpc_num = 0;
+
+#define DPC_INPUTS 2
+static struct v4l2_input dpc_inputs[DPC_INPUTS] = {
+ { 0, "Port A", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 1, "Port B", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+};
+
+#define DPC_AUDIOS 0
+
+static struct saa7146_extension_ioctls ioctls[] = {
+ { VIDIOC_G_INPUT, SAA7146_EXCLUSIVE },
+ { VIDIOC_S_INPUT, SAA7146_EXCLUSIVE },
+ { VIDIOC_ENUMINPUT, SAA7146_EXCLUSIVE },
+ { VIDIOC_S_STD, SAA7146_AFTER },
+ { 0, 0 }
+};
+
+struct dpc
+{
+ struct video_device *video_dev;
+ struct video_device *vbi_dev;
+
+ struct i2c_adapter i2c_adapter;
+ struct i2c_client *saa7111a;
+
+ int cur_input; /* current input */
+};
+
+/* fixme: add vbi stuff here */
+static int dpc_probe(struct saa7146_dev* dev)
+{
+ struct dpc* dpc = NULL;
+ struct i2c_client *client;
+ struct list_head *item;
+
+ dpc = (struct dpc*)kmalloc(sizeof(struct dpc), GFP_KERNEL);
+ if( NULL == dpc ) {
+ printk("dpc_v4l2.o: dpc_probe: not enough kernel memory.\n");
+ return -ENOMEM;
+ }
+ memset(dpc, 0x0, sizeof(struct dpc));
+
+ /* FIXME: enable i2c-port pins, video-port-pins
+ video port pins should be enabled here ?! */
+ saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26));
+
+ dpc->i2c_adapter = (struct i2c_adapter) {
+ .class = I2C_CLASS_TV_ANALOG,
+ .name = "dpc7146",
+ };
+ saa7146_i2c_adapter_prepare(dev, &dpc->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
+ if(i2c_add_adapter(&dpc->i2c_adapter) < 0) {
+ DEB_S(("cannot register i2c-device. skipping.\n"));
+ kfree(dpc);
+ return -EFAULT;
+ }
+
+ /* loop through all i2c-devices on the bus and look who is there */
+ list_for_each(item,&dpc->i2c_adapter.clients) {
+ client = list_entry(item, struct i2c_client, list);
+ if( I2C_SAA7111A == client->addr )
+ dpc->saa7111a = client;
+ }
+
+ /* check if all devices are present */
+ if( 0 == dpc->saa7111a ) {
+ DEB_D(("dpc_v4l2.o: dpc_attach failed for this device.\n"));
+ i2c_del_adapter(&dpc->i2c_adapter);
+ kfree(dpc);
+ return -ENODEV;
+ }
+
+ /* all devices are present, probe was successful */
+ DEB_D(("dpc_v4l2.o: dpc_probe succeeded for this device.\n"));
+
+ /* we store the pointer in our private data field */
+ dev->ext_priv = dpc;
+
+ return 0;
+}
+
+/* bring hardware to a sane state. this has to be done, just in case someone
+ wants to capture from this device before it has been properly initialized.
+ the capture engine would badly fail, because no valid signal arrives on the
+ saa7146, thus leading to timeouts and stuff. */
+static int dpc_init_done(struct saa7146_dev* dev)
+{
+ struct dpc* dpc = (struct dpc*)dev->ext_priv;
+
+ DEB_D(("dpc_v4l2.o: dpc_init_done called.\n"));
+
+ /* initialize the helper ics to useful values */
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x00, 0x11);
+
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x02, 0xc0);
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x03, 0x30);
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x04, 0x00);
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x05, 0x00);
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x06, 0xde);
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x07, 0xad);
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x08, 0xa8);
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x09, 0x00);
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x0a, 0x80);
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x0b, 0x47);
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x0c, 0x40);
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x0d, 0x00);
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x0e, 0x03);
+
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x10, 0xd0);
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x11, 0x1c);
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x12, 0xc1);
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x13, 0x30);
+
+ i2c_smbus_write_byte_data(dpc->saa7111a, 0x1f, 0x81);
+
+ return 0;
+}
+
+static struct saa7146_ext_vv vv_data;
+
+/* this function only gets called when the probing was successful */
+static int dpc_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_data *info)
+{
+ struct dpc* dpc = (struct dpc*)dev->ext_priv;
+
+ DEB_D(("dpc_v4l2.o: dpc_attach called.\n"));
+
+ /* checking for i2c-devices can be omitted here, because we
+ already did this in "dpc_vl42_probe" */
+
+ saa7146_vv_init(dev,&vv_data);
+ if( 0 != saa7146_register_device(&dpc->video_dev, dev, "dpc", VFL_TYPE_GRABBER)) {
+ ERR(("cannot register capture v4l2 device. skipping.\n"));
+ return -1;
+ }
+
+ /* initialization stuff (vbi) (only for revision > 0 and for extensions which want it)*/
+ if( 0 != DPC_BOARD_CAN_DO_VBI(dev)) {
+ if( 0 != saa7146_register_device(&dpc->vbi_dev, dev, "dpc", VFL_TYPE_VBI)) {
+ ERR(("cannot register vbi v4l2 device. skipping.\n"));
+ }
+ }
+
+ i2c_use_client(dpc->saa7111a);
+
+ printk("dpc: found 'dpc7146 demonstration board'-%d.\n",dpc_num);
+ dpc_num++;
+
+ /* the rest */
+ dpc->cur_input = 0;
+ dpc_init_done(dev);
+
+ return 0;
+}
+
+static int dpc_detach(struct saa7146_dev* dev)
+{
+ struct dpc* dpc = (struct dpc*)dev->ext_priv;
+
+ DEB_EE(("dev:%p\n",dev));
+
+ i2c_release_client(dpc->saa7111a);
+
+ saa7146_unregister_device(&dpc->video_dev,dev);
+ if( 0 != DPC_BOARD_CAN_DO_VBI(dev)) {
+ saa7146_unregister_device(&dpc->vbi_dev,dev);
+ }
+ saa7146_vv_release(dev);
+
+ dpc_num--;
+
+ i2c_del_adapter(&dpc->i2c_adapter);
+ kfree(dpc);
+ return 0;
+}
+
+#ifdef axa
+int dpc_vbi_bypass(struct saa7146_dev* dev)
+{
+ struct dpc* dpc = (struct dpc*)dev->ext_priv;
+
+ int i = 1;
+
+ /* switch bypass in saa7111a */
+ if ( 0 != dpc->saa7111a->driver->command(dpc->saa7111a,SAA711X_VBI_BYPASS, &i)) {
+ printk("dpc_v4l2.o: VBI_BYPASS: could not address saa7111a.\n");
+ return -1;
+ }
+
+ return 0;
+}
+#endif
+
+static int dpc_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
+{
+ struct saa7146_dev *dev = fh->dev;
+ struct dpc* dpc = (struct dpc*)dev->ext_priv;
+/*
+ struct saa7146_vv *vv = dev->vv_data;
+*/
+ switch(cmd)
+ {
+ case VIDIOC_ENUMINPUT:
+ {
+ struct v4l2_input *i = arg;
+ DEB_EE(("VIDIOC_ENUMINPUT %d.\n",i->index));
+
+ if( i->index < 0 || i->index >= DPC_INPUTS) {
+ return -EINVAL;
+ }
+
+ memcpy(i, &dpc_inputs[i->index], sizeof(struct v4l2_input));
+
+ DEB_D(("dpc_v4l2.o: v4l2_ioctl: VIDIOC_ENUMINPUT %d.\n",i->index));
+ return 0;
+ }
+ case VIDIOC_G_INPUT:
+ {
+ int *input = (int *)arg;
+ *input = dpc->cur_input;
+
+ DEB_D(("dpc_v4l2.o: VIDIOC_G_INPUT: %d\n",*input));
+ return 0;
+ }
+ case VIDIOC_S_INPUT:
+ {
+ int input = *(int *)arg;
+
+ if (input < 0 || input >= DPC_INPUTS) {
+ return -EINVAL;
+ }
+
+ dpc->cur_input = input;
+
+ /* fixme: switch input here, switch audio, too! */
+// saa7146_set_hps_source_and_sync(dev, input_port_selection[input].hps_source, input_port_selection[input].hps_sync);
+ printk("dpc_v4l2.o: VIDIOC_S_INPUT: fixme switch input.\n");
+
+ return 0;
+ }
+ default:
+/*
+ DEB_D(("dpc_v4l2.o: v4l2_ioctl does not handle this ioctl.\n"));
+*/
+ return -ENOIOCTLCMD;
+ }
+ return 0;
+}
+
+static int std_callback(struct saa7146_dev* dev, struct saa7146_standard *std)
+{
+ return 0;
+}
+
+static struct saa7146_standard standard[] = {
+ {
+ .name = "PAL", .id = V4L2_STD_PAL,
+ .v_offset = 0x17, .v_field = 288,
+ .h_offset = 0x14, .h_pixels = 680,
+ .v_max_out = 576, .h_max_out = 768,
+ }, {
+ .name = "NTSC", .id = V4L2_STD_NTSC,
+ .v_offset = 0x16, .v_field = 240,
+ .h_offset = 0x06, .h_pixels = 708,
+ .v_max_out = 480, .h_max_out = 640,
+ }, {
+ .name = "SECAM", .id = V4L2_STD_SECAM,
+ .v_offset = 0x14, .v_field = 288,
+ .h_offset = 0x14, .h_pixels = 720,
+ .v_max_out = 576, .h_max_out = 768,
+ }
+};
+
+static struct saa7146_extension extension;
+
+static struct saa7146_pci_extension_data dpc = {
+ .ext_priv = "Multimedia eXtension Board",
+ .ext = &extension,
+};
+
+static struct pci_device_id pci_tbl[] = {
+ {
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7146,
+ .subvendor = 0x0000,
+ .subdevice = 0x0000,
+ .driver_data = (unsigned long)&dpc,
+ }, {
+ .vendor = 0,
+ }
+};
+
+MODULE_DEVICE_TABLE(pci, pci_tbl);
+
+static struct saa7146_ext_vv vv_data = {
+ .inputs = DPC_INPUTS,
+ .capabilities = V4L2_CAP_VBI_CAPTURE,
+ .stds = &standard[0],
+ .num_stds = sizeof(standard)/sizeof(struct saa7146_standard),
+ .std_callback = &std_callback,
+ .ioctls = &ioctls[0],
+ .ioctl = dpc_ioctl,
+};
+
+static struct saa7146_extension extension = {
+ .name = "dpc7146 demonstration board",
+ .flags = SAA7146_USE_I2C_IRQ,
+
+ .pci_tbl = &pci_tbl[0],
+ .module = THIS_MODULE,
+
+ .probe = dpc_probe,
+ .attach = dpc_attach,
+ .detach = dpc_detach,
+
+ .irq_mask = 0,
+ .irq_func = NULL,
+};
+
+static int __init dpc_init_module(void)
+{
+ if( 0 != saa7146_register_extension(&extension)) {
+ DEB_S(("failed to register extension.\n"));
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
+static void __exit dpc_cleanup_module(void)
+{
+ saa7146_unregister_extension(&extension);
+}
+
+module_init(dpc_init_module);
+module_exit(dpc_cleanup_module);
+
+MODULE_DESCRIPTION("video4linux-2 driver for the 'dpc7146 demonstration board'");
+MODULE_AUTHOR("Michael Hunold <michael@mihu.de>");
+MODULE_LICENSE("GPL");
diff --git a/linux/drivers/media/video/em28xx/Kconfig b/linux/drivers/media/video/em28xx/Kconfig
index 885fd0170..5a793ae7c 100644
--- a/linux/drivers/media/video/em28xx/Kconfig
+++ b/linux/drivers/media/video/em28xx/Kconfig
@@ -5,6 +5,7 @@ config VIDEO_EM28XX
select VIDEO_TUNER
select VIDEO_TVEEPROM
select VIDEO_IR
+ select VIDEO_SAA711X
---help---
This is a video4linux driver for Empia 28xx based TV cards.
diff --git a/linux/drivers/media/video/em28xx/em28xx-video.c b/linux/drivers/media/video/em28xx/em28xx-video.c
index 1dea158e7..64d395472 100644
--- a/linux/drivers/media/video/em28xx/em28xx-video.c
+++ b/linux/drivers/media/video/em28xx/em28xx-video.c
@@ -121,23 +121,6 @@ static struct em28xx_tvnorm tvnorms[] = {
}
};
-static const unsigned char saa7114_i2c_init[] = {
- 0x00,0x00,0x01,0x08,0x02,0xc4,0x03,0x30,0x04,0x90,0x05,0x90,0x06,0xeb,0x07,0xe0,
- 0x08,0x88,0x09,0x40,0x0a,0x80,0x0b,0x44,0x0c,0x40,0x0d,0x00,0x0e,0x81,0x0f,0x2a,
- 0x10,0x06,0x11,0x00,0x12,0xc8,0x13,0x80,0x14,0x00,0x15,0x11,0x16,0x01,0x17,0x42,
- 0x18,0x40,0x19,0x80,0x40,0x00,0x41,0xff,0x42,0xff,0x43,0xff,0x44,0xff,0x45,0xff,
- 0x46,0xff,0x47,0xff,0x48,0xff,0x49,0xff,0x4a,0xff,0x4b,0xff,0x4c,0xff,0x4d,0xff,
- 0x4e,0xff,0x4f,0xff,0x50,0xff,0x51,0xff,0x52,0xff,0x53,0xff,0x54,0x5f,0x55,0xff,
- 0x56,0xff,0x57,0xff,0x58,0x00,0x59,0x47,0x5a,0x03,0x5b,0x03,0x5d,0x3e,0x5e,0x00,
- 0x80,0x1c,0x83,0x01,0x84,0xa5,0x85,0x10,0x86,0x45,0x87,0x41,0x88,0xf0,0x88,0x00,
- 0x88,0xf0,0x90,0x00,0x91,0x08,0x92,0x00,0x93,0x80,0x94,0x08,0x95,0x00,0x96,0xc0,
- 0x97,0x02,0x98,0x13,0x99,0x00,0x9a,0x38,0x9b,0x01,0x9c,0x80,0x9d,0x02,0x9e,0x06,
- 0x9f,0x01,0xa0,0x01,0xa1,0x00,0xa2,0x00,0xa4,0x80,0xa5,0x36,0xa6,0x36,0xa8,0x67,
- 0xa9,0x04,0xaa,0x00,0xac,0x33,0xad,0x02,0xae,0x00,0xb0,0xcd,0xb1,0x04,0xb2,0xcd,
- 0xb3,0x04,0xb4,0x01,0xb8,0x00,0xb9,0x00,0xba,0x00,0xbb,0x00,0xbc,0x00,0xbd,0x00,
- 0xbe,0x00,0xbf,0x00
-};
-
#define TVNORMS ARRAY_SIZE(tvnorms)
/* supported controls */
@@ -164,77 +147,6 @@ static struct v4l2_queryctrl em28xx_qctrl[] = {
}
};
-/* FIXME: These are specific to saa711x - should be moved to its code */
-static struct v4l2_queryctrl saa711x_qctrl[] = {
- {
- .id = V4L2_CID_BRIGHTNESS,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Brightness",
- .minimum = -128,
- .maximum = 127,
- .step = 1,
- .default_value = 0,
- .flags = 0,
- },{
- .id = V4L2_CID_CONTRAST,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Contrast",
- .minimum = 0x0,
- .maximum = 0x1f,
- .step = 0x1,
- .default_value = 0x10,
- .flags = 0,
- },{
- .id = V4L2_CID_SATURATION,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Saturation",
- .minimum = 0x0,
- .maximum = 0x1f,
- .step = 0x1,
- .default_value = 0x10,
- .flags = 0,
- },{
-#if 0
-/* Control in the saa7113 and not in the em28xx */
- .id = V4L2_CID_HUE,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Hue",
- .minimum = 0x0,
- .maximum = 0x1f,
- .step = 0x1,
- .default_value = 0x10,
- .flags = 0,
- },{
-#endif
- .id = V4L2_CID_RED_BALANCE,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Red chroma balance",
- .minimum = -128,
- .maximum = 127,
- .step = 1,
- .default_value = 0,
- .flags = 0,
- },{
- .id = V4L2_CID_BLUE_BALANCE,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Blue chroma balance",
- .minimum = -128,
- .maximum = 127,
- .step = 1,
- .default_value = 0,
- .flags = 0,
- },{
- .id = V4L2_CID_GAMMA,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Gamma",
- .minimum = 0x0,
- .maximum = 0x3f,
- .step = 0x1,
- .default_value = 0x20,
- .flags = 0,
- }
-};
-
static struct usb_driver em28xx_usb_driver;
static DEFINE_MUTEX(em28xx_sysfs_lock);
@@ -279,55 +191,9 @@ static int em28xx_config(struct em28xx *dev)
static void em28xx_config_i2c(struct em28xx *dev)
{
struct v4l2_frequency f;
- struct video_decoder_init em28xx_vdi = {.data = NULL };
-
-#if 0
- if (dev->decoder == EM28XX_SAA7113) {
- const unsigned char saa7113_i2c_init[] = {
- 0x00, 0x00, /* PH7113_CHIP_VERSION 00 - ID byte */
- 0x01, 0x08, /* PH7113_INCREMENT_DELAY - (1) (1) (1) (1) IDEL3 IDEL2 IDELL1 IDEL0 */
- 0x02, 0xc2, /* PH7113_ANALOG_INPUT_CONTR_1 - FUSE1 FUSE0 GUDL1 GUDL0 MODE3 MODE2 MODE1 MODE0 */
- 0x03, 0x30, /* PH7113_ANALOG_INPUT_CONTR_2 - (1) HLNRS VBSL WPOFF HOLDG GAFIX GAI28 GAI18 */
- 0x04, 0x00, /* PH7113_ANALOG_INPUT_CONTR_3 - GAI17 GAI16 GAI15 GAI14 GAI13 GAI12 GAI11 GAI10 */
- 0x05, 0x00, /* PH7113_ANALOG_INPUT_CONTR_4 - GAI27 GAI26 GAI25 GAI24 GAI23 GAI22 GAI21 GAI20 */
- 0x06, 0x89, /* PH7113_HORIZONTAL_SYNC_START - HSB7 HSB6 HSB5 HSB4 HSB3 HSB2 HSB1 HSB0 */
- 0x07, 0x0d, /* PH7113_HORIZONTAL_SYNC_STOP - HSS7 HSS6 HSS5 HSS4 HSS3 HSS2 HSS1 HSS0 */
- 0x08, 0x88, /* PH7113_SYNC_CONTROL - AUFD FSEL FOET HTC1 HTC0 HPLL VNOI1 VNOI0 */
- 0x09, 0x01, /* PH7113_LUMINANCE_CONTROL - BYPS PREF BPSS1 BPSS0 VBLB UPTCV APER1 APER0 */
- 0x0a, 0x80, /* PH7113_LUMINANCE_BRIGHTNESS - BRIG7 BRIG6 BRIG5 BRIG4 BRIG3 BRIG2 BRIG1 BRIG0 */
- 0x0b, 0x47, /* PH7113_LUMINANCE_CONTRAST - CONT7 CONT6 CONT5 CONT4 CONT3 CONT2 CONT1 CONT0 */
- 0x0c, 0x40, /* PH7113_CHROMA_SATURATION - SATN7 SATN6 SATN5 SATN4 SATN3 SATN2 SATN1 SATN0 */
- 0x0d, 0x00, /* PH7113_CHROMA_HUE_CONTROL - HUEC7 HUEC6 HUEC5 HUEC4 HUEC3 HUEC2 HUEC1 HUEC0 */
- 0x0e, 0x01, /* PH7113_CHROMA_CONTROL - CDTO CSTD2 CSTD1 CSTD0 DCCF FCTC CHBW1 CHBW0 */
- 0x0f, 0x2a, /* PH7113_CHROMA_GAIN_CONTROL - ACGC CGAIN6 CGAIN5 CGAIN4 CGAIN3 CGAIN2 CGAIN1 CGAIN0 */
- 0x10, 0x08, /* PH7113_FORMAT_DELAY_CONTROL - OFTS1 OFTS0 HDEL1 HDEL0 VRLN YDEL2 YDEL1 YDEL0 */
- 0x11, 0x0c, /* PH7113_OUTPUT_CONTROL_1 - GPSW1 CM99 GPSW0 HLSEL OEYC OERT VIPB COLO */
- 0x12, 0x07, /* PH7113_OUTPUT_CONTROL_2 - RTSE13 RTSE12 RTSE11 RTSE10 RTSE03 RTSE02 RTSE01 RTSE00 */
- 0x13, 0x00, /* PH7113_OUTPUT_CONTROL_3 - ADLSB (1) (1) OLDSB FIDP (1) AOSL1 AOSL0 */
- 0x14, 0x00, /* RESERVED 14 - (1) (1) (1) (1) (1) (1) (1) (1) */
- 0x15, 0x00, /* PH7113_V_GATE1_START - VSTA7 VSTA6 VSTA5 VSTA4 VSTA3 VSTA2 VSTA1 VSTA0 */
- 0x16, 0x00, /* PH7113_V_GATE1_STOP - VSTO7 VSTO6 VSTO5 VSTO4 VSTO3 VSTO2 VSTO1 VSTO0 */
- 0x17, 0x00, /* PH7113_V_GATE1_MSB - (1) (1) (1) (1) (1) (1) VSTO8 VSTA8 */
- };
-
- em28xx_vdi.data = saa7113_i2c_init;
- em28xx_vdi.len = sizeof(saa7113_i2c_init);
- }
-#endif
-
- /* configure decoder */
- if(dev->model == EM2820_BOARD_MSI_VOX_USB_2){
- em28xx_vdi.data=saa7114_i2c_init;
- em28xx_vdi.len=sizeof(saa7114_i2c_init);
- }
-
-
- em28xx_i2c_call_clients(dev, DECODER_INIT, &em28xx_vdi);
- em28xx_i2c_call_clients(dev, DECODER_SET_INPUT, &dev->ctl_input);
-/* em28xx_i2c_call_clients(dev,DECODER_SET_PICTURE, &dev->vpic); */
-/* em28xx_i2c_call_clients(dev,DECODER_SET_NORM,&dev->tvnorm->id); */
-/* em28xx_i2c_call_clients(dev,DECODER_ENABLE_OUTPUT,&output); */
-/* em28xx_i2c_call_clients(dev,DECODER_DUMP, NULL); */
+ em28xx_i2c_call_clients(dev, VIDIOC_INT_RESET, NULL);
+ em28xx_i2c_call_clients(dev, VIDIOC_S_INPUT, &dev->ctl_input);
+ em28xx_i2c_call_clients(dev, VIDIOC_STREAMON, NULL);
/* configure tuner */
f.tuner = 0;
@@ -370,8 +236,7 @@ static void video_mux(struct em28xx *dev, int index)
dev->ctl_input = index;
dev->ctl_ainput = INPUT(index)->amux;
- em28xx_i2c_call_clients(dev, DECODER_SET_INPUT, &input);
-
+ em28xx_i2c_call_clients(dev, VIDIOC_S_INPUT, &input);
em28xx_videodbg("Setting input index=%d, vmux=%d, amux=%d\n",index,input,dev->ctl_ainput);
@@ -828,43 +693,6 @@ static int em28xx_get_ctrl(struct em28xx *dev, struct v4l2_control *ctrl)
}
}
-/*FIXME: should be moved to saa711x */
-static int saa711x_get_ctrl(struct em28xx *dev, struct v4l2_control *ctrl)
-{
- s32 tmp;
- switch (ctrl->id) {
- case V4L2_CID_BRIGHTNESS:
- if ((tmp = em28xx_brightness_get(dev)) < 0)
- return -EIO;
- ctrl->value = (s32) ((s8) tmp); /* FIXME: clenaer way to extend sign? */
- return 0;
- case V4L2_CID_CONTRAST:
- if ((ctrl->value = em28xx_contrast_get(dev)) < 0)
- return -EIO;
- return 0;
- case V4L2_CID_SATURATION:
- if ((ctrl->value = em28xx_saturation_get(dev)) < 0)
- return -EIO;
- return 0;
- case V4L2_CID_RED_BALANCE:
- if ((tmp = em28xx_v_balance_get(dev)) < 0)
- return -EIO;
- ctrl->value = (s32) ((s8) tmp); /* FIXME: clenaer way to extend sign? */
- return 0;
- case V4L2_CID_BLUE_BALANCE:
- if ((tmp = em28xx_u_balance_get(dev)) < 0)
- return -EIO;
- ctrl->value = (s32) ((s8) tmp); /* FIXME: clenaer way to extend sign? */
- return 0;
- case V4L2_CID_GAMMA:
- if ((ctrl->value = em28xx_gamma_get(dev)) < 0)
- return -EIO;
- return 0;
- default:
- return -EINVAL;
- }
-}
-
/*
* em28xx_set_ctrl()
* mute or set new saturation, brightness or contrast
@@ -887,27 +715,6 @@ static int em28xx_set_ctrl(struct em28xx *dev, const struct v4l2_control *ctrl)
}
}
-/*FIXME: should be moved to saa711x */
-static int saa711x_set_ctrl(struct em28xx *dev, const struct v4l2_control *ctrl)
-{
- switch (ctrl->id) {
- case V4L2_CID_BRIGHTNESS:
- return em28xx_brightness_set(dev, ctrl->value);
- case V4L2_CID_CONTRAST:
- return em28xx_contrast_set(dev, ctrl->value);
- case V4L2_CID_SATURATION:
- return em28xx_saturation_set(dev, ctrl->value);
- case V4L2_CID_RED_BALANCE:
- return em28xx_v_balance_set(dev, ctrl->value);
- case V4L2_CID_BLUE_BALANCE:
- return em28xx_u_balance_set(dev, ctrl->value);
- case V4L2_CID_GAMMA:
- return em28xx_gamma_set(dev, ctrl->value);
- default:
- return -EINVAL;
- }
-}
-
/*
* em28xx_stream_interrupt()
* stops streaming
@@ -1241,8 +1048,6 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
em28xx_set_norm(dev, dev->width, dev->height);
- em28xx_i2c_call_clients(dev, DECODER_SET_NORM,
- &tvnorms[i].mode);
em28xx_i2c_call_clients(dev, VIDIOC_S_STD,
&dev->tvnorm->id);
@@ -1353,24 +1158,11 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
}
}
}
- if (dev->decoder == EM28XX_TVP5150) {
- em28xx_i2c_call_clients(dev,cmd,qc);
- if (qc->type)
- return 0;
- else
- return -EINVAL;
- }
-#if 1 /* FIXME: Should be at saa711x */
- for (i = 0; i < ARRAY_SIZE(saa711x_qctrl); i++) {
- if (qc->id && qc->id == saa711x_qctrl[i].id) {
- memcpy(qc, &(saa711x_qctrl[i]),
- sizeof(*qc));
- return 0;
- }
- }
-#endif
-
- return -EINVAL;
+ em28xx_i2c_call_clients(dev,cmd,qc);
+ if (qc->type)
+ return 0;
+ else
+ return -EINVAL;
}
case VIDIOC_G_CTRL:
{
@@ -1380,12 +1172,8 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
if (!dev->has_msp34xx)
retval=em28xx_get_ctrl(dev, ctrl);
if (retval==-EINVAL) {
- if (dev->decoder == EM28XX_TVP5150) {
- em28xx_i2c_call_clients(dev,cmd,arg);
- return 0;
- }
-
- return saa711x_get_ctrl(dev, ctrl);
+ em28xx_i2c_call_clients(dev,cmd,arg);
+ return 0;
} else return retval;
}
case VIDIOC_S_CTRL:
@@ -1406,33 +1194,8 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
}
}
- if (dev->decoder == EM28XX_TVP5150) {
- em28xx_i2c_call_clients(dev,cmd,arg);
- return 0;
- } else if (!dev->has_msp34xx) {
- for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) {
- if (ctrl->id == em28xx_qctrl[i].id) {
- if (ctrl->value <
- em28xx_qctrl[i].minimum
- || ctrl->value >
- em28xx_qctrl[i].maximum)
- return -ERANGE;
- return em28xx_set_ctrl(dev, ctrl);
- }
- }
- for (i = 0; i < ARRAY_SIZE(saa711x_qctrl); i++) {
- if (ctrl->id == saa711x_qctrl[i].id) {
- if (ctrl->value <
- saa711x_qctrl[i].minimum
- || ctrl->value >
- saa711x_qctrl[i].maximum)
- return -ERANGE;
- return saa711x_set_ctrl(dev, ctrl);
- }
- }
- }
-
- return -EINVAL;
+ em28xx_i2c_call_clients(dev,cmd,arg);
+ return 0;
}
/* --- tuner ioctls ------------------------------------------ */
case VIDIOC_G_TUNER:
@@ -1924,7 +1687,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
#ifdef CONFIG_MODULES
/* request some modules */
if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
- request_module("saa711x");
+ request_module("saa7115");
if (dev->decoder == EM28XX_TVP5150)
request_module("tvp5150");
if (dev->has_tuner)
@@ -2107,7 +1870,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
model=id->driver_info;
- if (nr > EM28XX_MAXBOARDS) {
+ if (nr >= EM28XX_MAXBOARDS) {
printk (DRIVER_NAME ": Supports only %i em28xx boards.\n",EM28XX_MAXBOARDS);
em28xx_devused&=~(1<<nr);
return -ENOMEM;
diff --git a/linux/drivers/media/video/font.h b/linux/drivers/media/video/font.h
new file mode 100644
index 000000000..8b1fecc37
--- /dev/null
+++ b/linux/drivers/media/video/font.h
@@ -0,0 +1,407 @@
+static unsigned char rom8x16_bits[] = {
+/* Character 0 (0x30):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | ***** |
+ |** ** |
+ |** ** |
+ |** *** |
+ |** **** |
+ |**** ** |
+ |*** ** |
+ |** ** |
+ |** ** |
+ | ***** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x7c,
+0xc6,
+0xc6,
+0xce,
+0xde,
+0xf6,
+0xe6,
+0xc6,
+0xc6,
+0x7c,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 1 (0x31):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | ** |
+ | **** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ****** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x18,
+0x78,
+0x18,
+0x18,
+0x18,
+0x18,
+0x18,
+0x18,
+0x18,
+0x7e,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 2 (0x32):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | ***** |
+ |** ** |
+ |** ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ |** ** |
+ |******* |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x7c,
+0xc6,
+0xc6,
+0x06,
+0x0c,
+0x18,
+0x30,
+0x60,
+0xc6,
+0xfe,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 3 (0x33):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | ***** |
+ |** ** |
+ | ** |
+ | ** |
+ | **** |
+ | ** |
+ | ** |
+ | ** |
+ |** ** |
+ | ***** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x7c,
+0xc6,
+0x06,
+0x06,
+0x3c,
+0x06,
+0x06,
+0x06,
+0xc6,
+0x7c,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 4 (0x34):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | ** |
+ | *** |
+ | **** |
+ | ** ** |
+ |** ** |
+ |** ** |
+ |******* |
+ | ** |
+ | ** |
+ | **** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x0c,
+0x1c,
+0x3c,
+0x6c,
+0xcc,
+0xcc,
+0xfe,
+0x0c,
+0x0c,
+0x1e,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 5 (0x35):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ |******* |
+ |** |
+ |** |
+ |** |
+ |****** |
+ | ** |
+ | ** |
+ | ** |
+ |** ** |
+ | ***** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0xfe,
+0xc0,
+0xc0,
+0xc0,
+0xfc,
+0x06,
+0x06,
+0x06,
+0xc6,
+0x7c,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 6 (0x36):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | ***** |
+ |** ** |
+ |** |
+ |** |
+ |****** |
+ |** ** |
+ |** ** |
+ |** ** |
+ |** ** |
+ | ***** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x7c,
+0xc6,
+0xc0,
+0xc0,
+0xfc,
+0xc6,
+0xc6,
+0xc6,
+0xc6,
+0x7c,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 7 (0x37):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ |******* |
+ |** ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0xfe,
+0xc6,
+0x06,
+0x0c,
+0x18,
+0x30,
+0x30,
+0x30,
+0x30,
+0x30,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 8 (0x38):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | ***** |
+ |** ** |
+ |** ** |
+ |** ** |
+ | ***** |
+ |** ** |
+ |** ** |
+ |** ** |
+ |** ** |
+ | ***** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x7c,
+0xc6,
+0xc6,
+0xc6,
+0x7c,
+0xc6,
+0xc6,
+0xc6,
+0xc6,
+0x7c,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 9 (0x39):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | ***** |
+ |** ** |
+ |** ** |
+ |** ** |
+ |** ** |
+ | ****** |
+ | ** |
+ | ** |
+ |** ** |
+ | ***** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x7c,
+0xc6,
+0xc6,
+0xc6,
+0xc6,
+0x7e,
+0x06,
+0x06,
+0xc6,
+0x7c,
+0x00,
+0x00,
+0x00,
+0x00,
+/* Character : (0x3a):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | |
+ | |
+ | |
+ | ** |
+ | ** |
+ | |
+ | |
+ | ** |
+ | ** |
+ | |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x0c,
+0x0c,
+0x00,
+0x00,
+0x0c,
+0x0c,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+};
diff --git a/linux/drivers/media/video/hexium_gemini.c b/linux/drivers/media/video/hexium_gemini.c
new file mode 100644
index 000000000..24ae47cff
--- /dev/null
+++ b/linux/drivers/media/video/hexium_gemini.c
@@ -0,0 +1,557 @@
+/*
+ hexium_gemini.c - v4l2 driver for Hexium Gemini frame grabber cards
+
+ Visit http://www.mihu.de/linux/saa7146/ and follow the link
+ to "hexium" for further details about this card.
+
+ Copyright (C) 2003 Michael Hunold <michael@mihu.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.
+*/
+
+#define DEBUG_VARIABLE debug
+
+#include "compat.h"
+#include <media/saa7146_vv.h>
+
+static int debug = 0;
+module_param(debug, int, 0);
+MODULE_PARM_DESC(debug, "debug verbosity");
+
+/* global variables */
+static int hexium_num = 0;
+
+#define HEXIUM_GEMINI 4
+#define HEXIUM_GEMINI_DUAL 5
+
+#define HEXIUM_INPUTS 9
+static struct v4l2_input hexium_inputs[HEXIUM_INPUTS] = {
+ { 0, "CVBS 1", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 1, "CVBS 2", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 2, "CVBS 3", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 3, "CVBS 4", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 4, "CVBS 5", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 5, "CVBS 6", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 6, "Y/C 1", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 7, "Y/C 2", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 8, "Y/C 3", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+};
+
+#define HEXIUM_AUDIOS 0
+
+struct hexium_data
+{
+ s8 adr;
+ u8 byte;
+};
+
+static struct saa7146_extension_ioctls ioctls[] = {
+ { VIDIOC_G_INPUT, SAA7146_EXCLUSIVE },
+ { VIDIOC_S_INPUT, SAA7146_EXCLUSIVE },
+ { VIDIOC_QUERYCTRL, SAA7146_BEFORE },
+ { VIDIOC_ENUMINPUT, SAA7146_EXCLUSIVE },
+ { VIDIOC_S_STD, SAA7146_AFTER },
+ { VIDIOC_G_CTRL, SAA7146_BEFORE },
+ { VIDIOC_S_CTRL, SAA7146_BEFORE },
+ { 0, 0 }
+};
+
+#define HEXIUM_CONTROLS 1
+static struct v4l2_queryctrl hexium_controls[] = {
+ { V4L2_CID_PRIVATE_BASE, V4L2_CTRL_TYPE_BOOLEAN, "B/W", 0, 1, 1, 0, 0 },
+};
+
+#define HEXIUM_GEMINI_V_1_0 1
+#define HEXIUM_GEMINI_DUAL_V_1_0 2
+
+struct hexium
+{
+ int type;
+
+ struct video_device *video_dev;
+ struct i2c_adapter i2c_adapter;
+
+ int cur_input; /* current input */
+ v4l2_std_id cur_std; /* current standard */
+ int cur_bw; /* current black/white status */
+};
+
+/* Samsung KS0127B decoder default registers */
+static u8 hexium_ks0127b[0x100]={
+/*00*/ 0x00,0x52,0x30,0x40,0x01,0x0C,0x2A,0x10,
+/*08*/ 0x00,0x00,0x00,0x60,0x00,0x00,0x0F,0x06,
+/*10*/ 0x00,0x00,0xE4,0xC0,0x00,0x00,0x00,0x00,
+/*18*/ 0x14,0x9B,0xFE,0xFF,0xFC,0xFF,0x03,0x22,
+/*20*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*28*/ 0x00,0x00,0x00,0x00,0x00,0x2C,0x9B,0x00,
+/*30*/ 0x00,0x00,0x10,0x80,0x80,0x10,0x80,0x80,
+/*38*/ 0x01,0x04,0x00,0x00,0x00,0x29,0xC0,0x00,
+/*40*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*48*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*50*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*58*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*60*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*68*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*70*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*78*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*80*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*88*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*90*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*98*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*A0*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*A8*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*B0*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*B8*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*C0*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*C8*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*D0*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*D8*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*E0*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*E8*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*F0*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/*F8*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+
+static struct hexium_data hexium_pal[] = {
+ { 0x01, 0x52 }, { 0x12, 0x64 }, { 0x2D, 0x2C }, { 0x2E, 0x9B }, { -1 , 0xFF }
+};
+
+static struct hexium_data hexium_pal_bw[] = {
+ { 0x01, 0x52 }, { 0x12, 0x64 }, { 0x2D, 0x2C }, { 0x2E, 0x9B }, { -1 , 0xFF }
+};
+
+static struct hexium_data hexium_ntsc[] = {
+ { 0x01, 0x53 }, { 0x12, 0x04 }, { 0x2D, 0x23 }, { 0x2E, 0x81 }, { -1 , 0xFF }
+};
+
+static struct hexium_data hexium_ntsc_bw[] = {
+ { 0x01, 0x53 }, { 0x12, 0x04 }, { 0x2D, 0x23 }, { 0x2E, 0x81 }, { -1 , 0xFF }
+};
+
+static struct hexium_data hexium_secam[] = {
+ { 0x01, 0x52 }, { 0x12, 0x64 }, { 0x2D, 0x2C }, { 0x2E, 0x9B }, { -1 , 0xFF }
+};
+
+static struct hexium_data hexium_input_select[] = {
+ { 0x02, 0x60 },
+ { 0x02, 0x64 },
+ { 0x02, 0x61 },
+ { 0x02, 0x65 },
+ { 0x02, 0x62 },
+ { 0x02, 0x66 },
+ { 0x02, 0x68 },
+ { 0x02, 0x69 },
+ { 0x02, 0x6A },
+};
+
+/* fixme: h_offset = 0 for Hexium Gemini *Dual*, which
+ are currently *not* supported*/
+static struct saa7146_standard hexium_standards[] = {
+ {
+ .name = "PAL", .id = V4L2_STD_PAL,
+ .v_offset = 28, .v_field = 288,
+ .h_offset = 1, .h_pixels = 680,
+ .v_max_out = 576, .h_max_out = 768,
+ }, {
+ .name = "NTSC", .id = V4L2_STD_NTSC,
+ .v_offset = 28, .v_field = 240,
+ .h_offset = 1, .h_pixels = 640,
+ .v_max_out = 480, .h_max_out = 640,
+ }, {
+ .name = "SECAM", .id = V4L2_STD_SECAM,
+ .v_offset = 28, .v_field = 288,
+ .h_offset = 1, .h_pixels = 720,
+ .v_max_out = 576, .h_max_out = 768,
+ }
+};
+
+/* bring hardware to a sane state. this has to be done, just in case someone
+ wants to capture from this device before it has been properly initialized.
+ the capture engine would badly fail, because no valid signal arrives on the
+ saa7146, thus leading to timeouts and stuff. */
+static int hexium_init_done(struct saa7146_dev *dev)
+{
+ struct hexium *hexium = (struct hexium *) dev->ext_priv;
+ union i2c_smbus_data data;
+ int i = 0;
+
+ DEB_D(("hexium_init_done called.\n"));
+
+ /* initialize the helper ics to useful values */
+ for (i = 0; i < sizeof(hexium_ks0127b); i++) {
+ data.byte = hexium_ks0127b[i];
+ if (0 != i2c_smbus_xfer(&hexium->i2c_adapter, 0x6c, 0, I2C_SMBUS_WRITE, i, I2C_SMBUS_BYTE_DATA, &data)) {
+ printk("hexium_gemini: hexium_init_done() failed for address 0x%02x\n", i);
+ }
+ }
+
+ return 0;
+}
+
+static int hexium_set_input(struct hexium *hexium, int input)
+{
+ union i2c_smbus_data data;
+
+ DEB_D((".\n"));
+
+ data.byte = hexium_input_select[input].byte;
+ if (0 != i2c_smbus_xfer(&hexium->i2c_adapter, 0x6c, 0, I2C_SMBUS_WRITE, hexium_input_select[input].adr, I2C_SMBUS_BYTE_DATA, &data)) {
+ return -1;
+ }
+
+ return 0;
+}
+
+static int hexium_set_standard(struct hexium *hexium, struct hexium_data *vdec)
+{
+ union i2c_smbus_data data;
+ int i = 0;
+
+ DEB_D((".\n"));
+
+ while (vdec[i].adr != -1) {
+ data.byte = vdec[i].byte;
+ if (0 != i2c_smbus_xfer(&hexium->i2c_adapter, 0x6c, 0, I2C_SMBUS_WRITE, vdec[i].adr, I2C_SMBUS_BYTE_DATA, &data)) {
+ printk("hexium_init_done: hexium_set_standard() failed for address 0x%02x\n", i);
+ return -1;
+ }
+ i++;
+ }
+ return 0;
+}
+
+static struct saa7146_ext_vv vv_data;
+
+/* this function only gets called when the probing was successful */
+static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info)
+{
+ struct hexium *hexium = (struct hexium *) dev->ext_priv;
+
+ DEB_EE((".\n"));
+
+ hexium = (struct hexium *) kmalloc(sizeof(struct hexium), GFP_KERNEL);
+ if (NULL == hexium) {
+ printk("hexium_gemini: not enough kernel memory in hexium_attach().\n");
+ return -ENOMEM;
+ }
+ memset(hexium, 0x0, sizeof(struct hexium));
+ dev->ext_priv = hexium;
+
+ /* enable i2c-port pins */
+ saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26));
+
+ hexium->i2c_adapter = (struct i2c_adapter) {
+ .class = I2C_CLASS_TV_ANALOG,
+ .name = "hexium gemini",
+ };
+ saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
+ if (i2c_add_adapter(&hexium->i2c_adapter) < 0) {
+ DEB_S(("cannot register i2c-device. skipping.\n"));
+ kfree(hexium);
+ return -EFAULT;
+ }
+
+ /* set HWControl GPIO number 2 */
+ saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI);
+
+ saa7146_write(dev, DD1_INIT, 0x07000700);
+ saa7146_write(dev, DD1_STREAM_B, 0x00000000);
+ saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
+
+ /* the rest */
+ hexium->cur_input = 0;
+ hexium_init_done(dev);
+
+ hexium_set_standard(hexium, hexium_pal);
+ hexium->cur_std = V4L2_STD_PAL;
+
+ hexium_set_input(hexium, 0);
+ hexium->cur_input = 0;
+
+ saa7146_vv_init(dev, &vv_data);
+ if (0 != saa7146_register_device(&hexium->video_dev, dev, "hexium gemini", VFL_TYPE_GRABBER)) {
+ printk("hexium_gemini: cannot register capture v4l2 device. skipping.\n");
+ return -1;
+ }
+
+ printk("hexium_gemini: found 'hexium gemini' frame grabber-%d.\n", hexium_num);
+ hexium_num++;
+
+ return 0;
+}
+
+static int hexium_detach(struct saa7146_dev *dev)
+{
+ struct hexium *hexium = (struct hexium *) dev->ext_priv;
+
+ DEB_EE(("dev:%p\n", dev));
+
+ saa7146_unregister_device(&hexium->video_dev, dev);
+ saa7146_vv_release(dev);
+
+ hexium_num--;
+
+ i2c_del_adapter(&hexium->i2c_adapter);
+ kfree(hexium);
+ return 0;
+}
+
+static int hexium_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
+{
+ struct saa7146_dev *dev = fh->dev;
+ struct hexium *hexium = (struct hexium *) dev->ext_priv;
+/*
+ struct saa7146_vv *vv = dev->vv_data;
+*/
+ switch (cmd) {
+ case VIDIOC_ENUMINPUT:
+ {
+ struct v4l2_input *i = arg;
+ DEB_EE(("VIDIOC_ENUMINPUT %d.\n", i->index));
+
+ if (i->index < 0 || i->index >= HEXIUM_INPUTS) {
+ return -EINVAL;
+ }
+
+ memcpy(i, &hexium_inputs[i->index], sizeof(struct v4l2_input));
+
+ DEB_D(("v4l2_ioctl: VIDIOC_ENUMINPUT %d.\n", i->index));
+ return 0;
+ }
+ case VIDIOC_G_INPUT:
+ {
+ int *input = (int *) arg;
+ *input = hexium->cur_input;
+
+ DEB_D(("VIDIOC_G_INPUT: %d\n", *input));
+ return 0;
+ }
+ case VIDIOC_S_INPUT:
+ {
+ int input = *(int *) arg;
+
+ DEB_EE(("VIDIOC_S_INPUT %d.\n", input));
+
+ if (input < 0 || input >= HEXIUM_INPUTS) {
+ return -EINVAL;
+ }
+
+ hexium->cur_input = input;
+ hexium_set_input(hexium, input);
+
+ return 0;
+ }
+ /* the saa7146 provides some controls (brightness, contrast, saturation)
+ which gets registered *after* this function. because of this we have
+ to return with a value != 0 even if the function succeded.. */
+ case VIDIOC_QUERYCTRL:
+ {
+ struct v4l2_queryctrl *qc = arg;
+ int i;
+
+ for (i = HEXIUM_CONTROLS - 1; i >= 0; i--) {
+ if (hexium_controls[i].id == qc->id) {
+ *qc = hexium_controls[i];
+ DEB_D(("VIDIOC_QUERYCTRL %d.\n", qc->id));
+ return 0;
+ }
+ }
+ return -EAGAIN;
+ }
+ case VIDIOC_G_CTRL:
+ {
+ struct v4l2_control *vc = arg;
+ int i;
+
+ for (i = HEXIUM_CONTROLS - 1; i >= 0; i--) {
+ if (hexium_controls[i].id == vc->id) {
+ break;
+ }
+ }
+
+ if (i < 0) {
+ return -EAGAIN;
+ }
+
+ switch (vc->id) {
+ case V4L2_CID_PRIVATE_BASE:{
+ vc->value = hexium->cur_bw;
+ DEB_D(("VIDIOC_G_CTRL BW:%d.\n", vc->value));
+ return 0;
+ }
+ }
+ return -EINVAL;
+ }
+
+ case VIDIOC_S_CTRL:
+ {
+ struct v4l2_control *vc = arg;
+ int i = 0;
+
+ for (i = HEXIUM_CONTROLS - 1; i >= 0; i--) {
+ if (hexium_controls[i].id == vc->id) {
+ break;
+ }
+ }
+
+ if (i < 0) {
+ return -EAGAIN;
+ }
+
+ switch (vc->id) {
+ case V4L2_CID_PRIVATE_BASE:{
+ hexium->cur_bw = vc->value;
+ break;
+ }
+ }
+
+ DEB_D(("VIDIOC_S_CTRL BW:%d.\n", hexium->cur_bw));
+
+ if (0 == hexium->cur_bw && V4L2_STD_PAL == hexium->cur_std) {
+ hexium_set_standard(hexium, hexium_pal);
+ return 0;
+ }
+ if (0 == hexium->cur_bw && V4L2_STD_NTSC == hexium->cur_std) {
+ hexium_set_standard(hexium, hexium_ntsc);
+ return 0;
+ }
+ if (0 == hexium->cur_bw && V4L2_STD_SECAM == hexium->cur_std) {
+ hexium_set_standard(hexium, hexium_secam);
+ return 0;
+ }
+ if (1 == hexium->cur_bw && V4L2_STD_PAL == hexium->cur_std) {
+ hexium_set_standard(hexium, hexium_pal_bw);
+ return 0;
+ }
+ if (1 == hexium->cur_bw && V4L2_STD_NTSC == hexium->cur_std) {
+ hexium_set_standard(hexium, hexium_ntsc_bw);
+ return 0;
+ }
+ if (1 == hexium->cur_bw && V4L2_STD_SECAM == hexium->cur_std) {
+ /* fixme: is there no bw secam mode? */
+ return -EINVAL;
+ }
+
+ return -EINVAL;
+ }
+ default:
+/*
+ DEB_D(("hexium_ioctl() does not handle this ioctl.\n"));
+*/
+ return -ENOIOCTLCMD;
+ }
+ return 0;
+}
+
+static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *std)
+{
+ struct hexium *hexium = (struct hexium *) dev->ext_priv;
+
+ if (V4L2_STD_PAL == std->id) {
+ hexium_set_standard(hexium, hexium_pal);
+ hexium->cur_std = V4L2_STD_PAL;
+ return 0;
+ } else if (V4L2_STD_NTSC == std->id) {
+ hexium_set_standard(hexium, hexium_ntsc);
+ hexium->cur_std = V4L2_STD_NTSC;
+ return 0;
+ } else if (V4L2_STD_SECAM == std->id) {
+ hexium_set_standard(hexium, hexium_secam);
+ hexium->cur_std = V4L2_STD_SECAM;
+ return 0;
+ }
+
+ return -1;
+}
+
+static struct saa7146_extension hexium_extension;
+
+static struct saa7146_pci_extension_data hexium_gemini_4bnc = {
+ .ext_priv = "Hexium Gemini (4 BNC)",
+ .ext = &hexium_extension,
+};
+
+static struct saa7146_pci_extension_data hexium_gemini_dual_4bnc = {
+ .ext_priv = "Hexium Gemini Dual (4 BNC)",
+ .ext = &hexium_extension,
+};
+
+static struct pci_device_id pci_tbl[] = {
+ {
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7146,
+ .subvendor = 0x17c8,
+ .subdevice = 0x2401,
+ .driver_data = (unsigned long) &hexium_gemini_4bnc,
+ },
+ {
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7146,
+ .subvendor = 0x17c8,
+ .subdevice = 0x2402,
+ .driver_data = (unsigned long) &hexium_gemini_dual_4bnc,
+ },
+ {
+ .vendor = 0,
+ }
+};
+
+MODULE_DEVICE_TABLE(pci, pci_tbl);
+
+static struct saa7146_ext_vv vv_data = {
+ .inputs = HEXIUM_INPUTS,
+ .capabilities = 0,
+ .stds = &hexium_standards[0],
+ .num_stds = sizeof(hexium_standards) / sizeof(struct saa7146_standard),
+ .std_callback = &std_callback,
+ .ioctls = &ioctls[0],
+ .ioctl = hexium_ioctl,
+};
+
+static struct saa7146_extension hexium_extension = {
+ .name = "hexium gemini",
+ .flags = SAA7146_USE_I2C_IRQ,
+
+ .pci_tbl = &pci_tbl[0],
+ .module = THIS_MODULE,
+
+ .attach = hexium_attach,
+ .detach = hexium_detach,
+
+ .irq_mask = 0,
+ .irq_func = NULL,
+};
+
+static int __init hexium_init_module(void)
+{
+ if (0 != saa7146_register_extension(&hexium_extension)) {
+ DEB_S(("failed to register extension.\n"));
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
+static void __exit hexium_cleanup_module(void)
+{
+ saa7146_unregister_extension(&hexium_extension);
+}
+
+module_init(hexium_init_module);
+module_exit(hexium_cleanup_module);
+
+MODULE_DESCRIPTION("video4linux-2 driver for Hexium Gemini frame grabber cards");
+MODULE_AUTHOR("Michael Hunold <michael@mihu.de>");
+MODULE_LICENSE("GPL");
diff --git a/linux/drivers/media/video/hexium_orion.c b/linux/drivers/media/video/hexium_orion.c
new file mode 100644
index 000000000..776eeea1b
--- /dev/null
+++ b/linux/drivers/media/video/hexium_orion.c
@@ -0,0 +1,523 @@
+/*
+ hexium_orion.c - v4l2 driver for the Hexium Orion frame grabber cards
+
+ Visit http://www.mihu.de/linux/saa7146/ and follow the link
+ to "hexium" for further details about this card.
+
+ Copyright (C) 2003 Michael Hunold <michael@mihu.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.
+*/
+
+#define DEBUG_VARIABLE debug
+
+#include "compat.h"
+#include <media/saa7146_vv.h>
+
+static int debug = 0;
+module_param(debug, int, 0);
+MODULE_PARM_DESC(debug, "debug verbosity");
+
+/* global variables */
+static int hexium_num = 0;
+
+#define HEXIUM_HV_PCI6_ORION 1
+#define HEXIUM_ORION_1SVHS_3BNC 2
+#define HEXIUM_ORION_4BNC 3
+
+#define HEXIUM_INPUTS 9
+static struct v4l2_input hexium_inputs[HEXIUM_INPUTS] = {
+ { 0, "CVBS 1", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 1, "CVBS 2", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 2, "CVBS 3", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 3, "CVBS 4", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 4, "CVBS 5", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 5, "CVBS 6", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 6, "Y/C 1", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 7, "Y/C 2", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { 8, "Y/C 3", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+};
+
+#define HEXIUM_AUDIOS 0
+
+struct hexium_data
+{
+ s8 adr;
+ u8 byte;
+};
+
+static struct saa7146_extension_ioctls ioctls[] = {
+ { VIDIOC_G_INPUT, SAA7146_EXCLUSIVE },
+ { VIDIOC_S_INPUT, SAA7146_EXCLUSIVE },
+ { VIDIOC_ENUMINPUT, SAA7146_EXCLUSIVE },
+ { VIDIOC_S_STD, SAA7146_AFTER },
+ { 0, 0 }
+};
+
+struct hexium
+{
+ int type;
+ struct video_device *video_dev;
+ struct i2c_adapter i2c_adapter;
+
+ int cur_input; /* current input */
+};
+
+/* Philips SAA7110 decoder default registers */
+static u8 hexium_saa7110[53]={
+/*00*/ 0x4C,0x3C,0x0D,0xEF,0xBD,0xF0,0x00,0x00,
+/*08*/ 0xF8,0xF8,0x60,0x60,0x40,0x86,0x18,0x90,
+/*10*/ 0x00,0x2C,0x40,0x46,0x42,0x1A,0xFF,0xDA,
+/*18*/ 0xF0,0x8B,0x00,0x00,0x00,0x00,0x00,0x00,
+/*20*/ 0xD9,0x17,0x40,0x41,0x80,0x41,0x80,0x4F,
+/*28*/ 0xFE,0x01,0x0F,0x0F,0x03,0x01,0x81,0x03,
+/*30*/ 0x44,0x75,0x01,0x8C,0x03
+};
+
+static struct {
+ struct hexium_data data[8];
+} hexium_input_select[] = {
+{
+ { /* cvbs 1 */
+ { 0x06, 0x00 },
+ { 0x20, 0xD9 },
+ { 0x21, 0x17 }, // 0x16,
+ { 0x22, 0x40 },
+ { 0x2C, 0x03 },
+ { 0x30, 0x44 },
+ { 0x31, 0x75 }, // ??
+ { 0x21, 0x16 }, // 0x03,
+ }
+}, {
+ { /* cvbs 2 */
+ { 0x06, 0x00 },
+ { 0x20, 0x78 },
+ { 0x21, 0x07 }, // 0x03,
+ { 0x22, 0xD2 },
+ { 0x2C, 0x83 },
+ { 0x30, 0x60 },
+ { 0x31, 0xB5 }, // ?
+ { 0x21, 0x03 },
+ }
+}, {
+ { /* cvbs 3 */
+ { 0x06, 0x00 },
+ { 0x20, 0xBA },
+ { 0x21, 0x07 }, // 0x05,
+ { 0x22, 0x91 },
+ { 0x2C, 0x03 },
+ { 0x30, 0x60 },
+ { 0x31, 0xB5 }, // ??
+ { 0x21, 0x05 }, // 0x03,
+ }
+}, {
+ { /* cvbs 4 */
+ { 0x06, 0x00 },
+ { 0x20, 0xD8 },
+ { 0x21, 0x17 }, // 0x16,
+ { 0x22, 0x40 },
+ { 0x2C, 0x03 },
+ { 0x30, 0x44 },
+ { 0x31, 0x75 }, // ??
+ { 0x21, 0x16 }, // 0x03,
+ }
+}, {
+ { /* cvbs 5 */
+ { 0x06, 0x00 },
+ { 0x20, 0xB8 },
+ { 0x21, 0x07 }, // 0x05,
+ { 0x22, 0x91 },
+ { 0x2C, 0x03 },
+ { 0x30, 0x60 },
+ { 0x31, 0xB5 }, // ??
+ { 0x21, 0x05 }, // 0x03,
+ }
+}, {
+ { /* cvbs 6 */
+ { 0x06, 0x00 },
+ { 0x20, 0x7C },
+ { 0x21, 0x07 }, // 0x03
+ { 0x22, 0xD2 },
+ { 0x2C, 0x83 },
+ { 0x30, 0x60 },
+ { 0x31, 0xB5 }, // ??
+ { 0x21, 0x03 },
+ }
+}, {
+ { /* y/c 1 */
+ { 0x06, 0x80 },
+ { 0x20, 0x59 },
+ { 0x21, 0x17 },
+ { 0x22, 0x42 },
+ { 0x2C, 0xA3 },
+ { 0x30, 0x44 },
+ { 0x31, 0x75 },
+ { 0x21, 0x12 },
+ }
+}, {
+ { /* y/c 2 */
+ { 0x06, 0x80 },
+ { 0x20, 0x9A },
+ { 0x21, 0x17 },
+ { 0x22, 0xB1 },
+ { 0x2C, 0x13 },
+ { 0x30, 0x60 },
+ { 0x31, 0xB5 },
+ { 0x21, 0x14 },
+ }
+}, {
+ { /* y/c 3 */
+ { 0x06, 0x80 },
+ { 0x20, 0x3C },
+ { 0x21, 0x27 },
+ { 0x22, 0xC1 },
+ { 0x2C, 0x23 },
+ { 0x30, 0x44 },
+ { 0x31, 0x75 },
+ { 0x21, 0x21 },
+ }
+}
+};
+
+static struct saa7146_standard hexium_standards[] = {
+ {
+ .name = "PAL", .id = V4L2_STD_PAL,
+ .v_offset = 16, .v_field = 288,
+ .h_offset = 1, .h_pixels = 680,
+ .v_max_out = 576, .h_max_out = 768,
+ }, {
+ .name = "NTSC", .id = V4L2_STD_NTSC,
+ .v_offset = 16, .v_field = 240,
+ .h_offset = 1, .h_pixels = 640,
+ .v_max_out = 480, .h_max_out = 640,
+ }, {
+ .name = "SECAM", .id = V4L2_STD_SECAM,
+ .v_offset = 16, .v_field = 288,
+ .h_offset = 1, .h_pixels = 720,
+ .v_max_out = 576, .h_max_out = 768,
+ }
+};
+
+/* this is only called for old HV-PCI6/Orion cards
+ without eeprom */
+static int hexium_probe(struct saa7146_dev *dev)
+{
+ struct hexium *hexium = NULL;
+ union i2c_smbus_data data;
+ int err = 0;
+
+ DEB_EE((".\n"));
+
+ /* there are no hexium orion cards with revision 0 saa7146s */
+ if (0 == dev->revision) {
+ return -EFAULT;
+ }
+
+ hexium = (struct hexium *) kmalloc(sizeof(struct hexium), GFP_KERNEL);
+ if (NULL == hexium) {
+ printk("hexium_orion: hexium_probe: not enough kernel memory.\n");
+ return -ENOMEM;
+ }
+ memset(hexium, 0x0, sizeof(struct hexium));
+
+ /* enable i2c-port pins */
+ saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26));
+
+ saa7146_write(dev, DD1_INIT, 0x01000100);
+ saa7146_write(dev, DD1_STREAM_B, 0x00000000);
+ saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
+
+ hexium->i2c_adapter = (struct i2c_adapter) {
+ .class = I2C_CLASS_TV_ANALOG,
+ .name = "hexium orion",
+ };
+ saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
+ if (i2c_add_adapter(&hexium->i2c_adapter) < 0) {
+ DEB_S(("cannot register i2c-device. skipping.\n"));
+ kfree(hexium);
+ return -EFAULT;
+ }
+
+ /* set SAA7110 control GPIO 0 */
+ saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTHI);
+ /* set HWControl GPIO number 2 */
+ saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI);
+
+ mdelay(10);
+
+ /* detect newer Hexium Orion cards by subsystem ids */
+ if (0x17c8 == dev->pci->subsystem_vendor && 0x0101 == dev->pci->subsystem_device) {
+ printk("hexium_orion: device is a Hexium Orion w/ 1 SVHS + 3 BNC inputs.\n");
+ /* we store the pointer in our private data field */
+ dev->ext_priv = hexium;
+ hexium->type = HEXIUM_ORION_1SVHS_3BNC;
+ return 0;
+ }
+
+ if (0x17c8 == dev->pci->subsystem_vendor && 0x2101 == dev->pci->subsystem_device) {
+ printk("hexium_orion: device is a Hexium Orion w/ 4 BNC inputs.\n");
+ /* we store the pointer in our private data field */
+ dev->ext_priv = hexium;
+ hexium->type = HEXIUM_ORION_4BNC;
+ return 0;
+ }
+
+ /* check if this is an old hexium Orion card by looking at
+ a saa7110 at address 0x4e */
+ if (0 == (err = i2c_smbus_xfer(&hexium->i2c_adapter, 0x4e, 0, I2C_SMBUS_READ, 0x00, I2C_SMBUS_BYTE_DATA, &data))) {
+ printk("hexium_orion: device is a Hexium HV-PCI6/Orion (old).\n");
+ /* we store the pointer in our private data field */
+ dev->ext_priv = hexium;
+ hexium->type = HEXIUM_HV_PCI6_ORION;
+ return 0;
+ }
+
+ i2c_del_adapter(&hexium->i2c_adapter);
+ kfree(hexium);
+ return -EFAULT;
+}
+
+/* bring hardware to a sane state. this has to be done, just in case someone
+ wants to capture from this device before it has been properly initialized.
+ the capture engine would badly fail, because no valid signal arrives on the
+ saa7146, thus leading to timeouts and stuff. */
+static int hexium_init_done(struct saa7146_dev *dev)
+{
+ struct hexium *hexium = (struct hexium *) dev->ext_priv;
+ union i2c_smbus_data data;
+ int i = 0;
+
+ DEB_D(("hexium_init_done called.\n"));
+
+ /* initialize the helper ics to useful values */
+ for (i = 0; i < sizeof(hexium_saa7110); i++) {
+ data.byte = hexium_saa7110[i];
+ if (0 != i2c_smbus_xfer(&hexium->i2c_adapter, 0x4e, 0, I2C_SMBUS_WRITE, i, I2C_SMBUS_BYTE_DATA, &data)) {
+ printk("hexium_orion: failed for address 0x%02x\n", i);
+ }
+ }
+
+ return 0;
+}
+
+static int hexium_set_input(struct hexium *hexium, int input)
+{
+ union i2c_smbus_data data;
+ int i = 0;
+
+ DEB_D((".\n"));
+
+ for (i = 0; i < 8; i++) {
+ int adr = hexium_input_select[input].data[i].adr;
+ data.byte = hexium_input_select[input].data[i].byte;
+ if (0 != i2c_smbus_xfer(&hexium->i2c_adapter, 0x4e, 0, I2C_SMBUS_WRITE, adr, I2C_SMBUS_BYTE_DATA, &data)) {
+ return -1;
+ }
+ printk("%d: 0x%02x => 0x%02x\n",input, adr,data.byte);
+ }
+
+ return 0;
+}
+
+static struct saa7146_ext_vv vv_data;
+
+/* this function only gets called when the probing was successful */
+static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info)
+{
+ struct hexium *hexium = (struct hexium *) dev->ext_priv;
+
+ DEB_EE((".\n"));
+
+ saa7146_vv_init(dev, &vv_data);
+ if (0 != saa7146_register_device(&hexium->video_dev, dev, "hexium orion", VFL_TYPE_GRABBER)) {
+ printk("hexium_orion: cannot register capture v4l2 device. skipping.\n");
+ return -1;
+ }
+
+ printk("hexium_orion: found 'hexium orion' frame grabber-%d.\n", hexium_num);
+ hexium_num++;
+
+ /* the rest */
+ hexium->cur_input = 0;
+ hexium_init_done(dev);
+
+ return 0;
+}
+
+static int hexium_detach(struct saa7146_dev *dev)
+{
+ struct hexium *hexium = (struct hexium *) dev->ext_priv;
+
+ DEB_EE(("dev:%p\n", dev));
+
+ saa7146_unregister_device(&hexium->video_dev, dev);
+ saa7146_vv_release(dev);
+
+ hexium_num--;
+
+ i2c_del_adapter(&hexium->i2c_adapter);
+ kfree(hexium);
+ return 0;
+}
+
+static int hexium_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
+{
+ struct saa7146_dev *dev = fh->dev;
+ struct hexium *hexium = (struct hexium *) dev->ext_priv;
+/*
+ struct saa7146_vv *vv = dev->vv_data;
+*/
+ switch (cmd) {
+ case VIDIOC_ENUMINPUT:
+ {
+ struct v4l2_input *i = arg;
+ DEB_EE(("VIDIOC_ENUMINPUT %d.\n", i->index));
+
+ if (i->index < 0 || i->index >= HEXIUM_INPUTS) {
+ return -EINVAL;
+ }
+
+ memcpy(i, &hexium_inputs[i->index], sizeof(struct v4l2_input));
+
+ DEB_D(("v4l2_ioctl: VIDIOC_ENUMINPUT %d.\n", i->index));
+ return 0;
+ }
+ case VIDIOC_G_INPUT:
+ {
+ int *input = (int *) arg;
+ *input = hexium->cur_input;
+
+ DEB_D(("VIDIOC_G_INPUT: %d\n", *input));
+ return 0;
+ }
+ case VIDIOC_S_INPUT:
+ {
+ int input = *(int *) arg;
+
+ if (input < 0 || input >= HEXIUM_INPUTS) {
+ return -EINVAL;
+ }
+
+ hexium->cur_input = input;
+ hexium_set_input(hexium, input);
+
+ return 0;
+ }
+ default:
+/*
+ DEB_D(("hexium_ioctl() does not handle this ioctl.\n"));
+*/
+ return -ENOIOCTLCMD;
+ }
+ return 0;
+}
+
+static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *std)
+{
+ return 0;
+}
+
+static struct saa7146_extension extension;
+
+static struct saa7146_pci_extension_data hexium_hv_pci6 = {
+ .ext_priv = "Hexium HV-PCI6 / Orion",
+ .ext = &extension,
+};
+
+static struct saa7146_pci_extension_data hexium_orion_1svhs_3bnc = {
+ .ext_priv = "Hexium HV-PCI6 / Orion (1 SVHS/3 BNC)",
+ .ext = &extension,
+};
+
+static struct saa7146_pci_extension_data hexium_orion_4bnc = {
+ .ext_priv = "Hexium HV-PCI6 / Orion (4 BNC)",
+ .ext = &extension,
+};
+
+static struct pci_device_id pci_tbl[] = {
+ {
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7146,
+ .subvendor = 0x0000,
+ .subdevice = 0x0000,
+ .driver_data = (unsigned long) &hexium_hv_pci6,
+ },
+ {
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7146,
+ .subvendor = 0x17c8,
+ .subdevice = 0x0101,
+ .driver_data = (unsigned long) &hexium_orion_1svhs_3bnc,
+ },
+ {
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7146,
+ .subvendor = 0x17c8,
+ .subdevice = 0x2101,
+ .driver_data = (unsigned long) &hexium_orion_4bnc,
+ },
+ {
+ .vendor = 0,
+ }
+};
+
+MODULE_DEVICE_TABLE(pci, pci_tbl);
+
+static struct saa7146_ext_vv vv_data = {
+ .inputs = HEXIUM_INPUTS,
+ .capabilities = 0,
+ .stds = &hexium_standards[0],
+ .num_stds = sizeof(hexium_standards) / sizeof(struct saa7146_standard),
+ .std_callback = &std_callback,
+ .ioctls = &ioctls[0],
+ .ioctl = hexium_ioctl,
+};
+
+static struct saa7146_extension extension = {
+ .name = "hexium HV-PCI6/Orion",
+ .flags = 0, // SAA7146_USE_I2C_IRQ,
+
+ .pci_tbl = &pci_tbl[0],
+ .module = THIS_MODULE,
+
+ .probe = hexium_probe,
+ .attach = hexium_attach,
+ .detach = hexium_detach,
+
+ .irq_mask = 0,
+ .irq_func = NULL,
+};
+
+static int __init hexium_init_module(void)
+{
+ if (0 != saa7146_register_extension(&extension)) {
+ DEB_S(("failed to register extension.\n"));
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
+static void __exit hexium_cleanup_module(void)
+{
+ saa7146_unregister_extension(&extension);
+}
+
+module_init(hexium_init_module);
+module_exit(hexium_cleanup_module);
+
+MODULE_DESCRIPTION("video4linux-2 driver for Hexium Orion frame grabber cards");
+MODULE_AUTHOR("Michael Hunold <michael@mihu.de>");
+MODULE_LICENSE("GPL");
diff --git a/linux/drivers/media/video/msp3400-kthreads.c b/linux/drivers/media/video/msp3400-kthreads.c
index 387f76c9f..dd8dc256d 100644
--- a/linux/drivers/media/video/msp3400-kthreads.c
+++ b/linux/drivers/media/video/msp3400-kthreads.c
@@ -160,7 +160,7 @@ const char *msp_standard_std_name(int std)
return "unknown";
}
-void msp_set_source(struct i2c_client *client, u16 src)
+static void msp_set_source(struct i2c_client *client, u16 src)
{
struct msp_state *state = i2c_get_clientdata(client);
@@ -223,7 +223,7 @@ void msp3400c_set_mode(struct i2c_client *client, int mode)
/* Set audio mode. Note that the pre-'G' models do not support BTSC+SAP,
nor do they support stereo BTSC. */
-void msp3400c_set_audmode(struct i2c_client *client)
+static void msp3400c_set_audmode(struct i2c_client *client)
{
static char *strmode[] = { "mono", "stereo", "lang2", "lang1" };
struct msp_state *state = i2c_get_clientdata(client);
@@ -989,7 +989,7 @@ static void msp34xxg_detect_stereo(struct i2c_client *client)
status, is_stereo, is_bilingual, state->rxsubchans);
}
-void msp34xxg_set_audmode(struct i2c_client *client)
+static void msp34xxg_set_audmode(struct i2c_client *client)
{
struct msp_state *state = i2c_get_clientdata(client);
int source;
diff --git a/linux/drivers/media/video/msp3400.h b/linux/drivers/media/video/msp3400.h
index 80e26e68f..5bb277609 100644
--- a/linux/drivers/media/video/msp3400.h
+++ b/linux/drivers/media/video/msp3400.h
@@ -109,7 +109,6 @@ int msp_sleep(struct msp_state *state, int timeout);
/* msp3400-kthreads.c */
const char *msp_standard_std_name(int std);
-void msp_set_source(struct i2c_client *client, u16 src);
void msp_set_audmode(struct i2c_client *client);
void msp_detect_stereo(struct i2c_client *client);
int msp3400c_thread(void *data);
diff --git a/linux/drivers/media/video/mxb.c b/linux/drivers/media/video/mxb.c
new file mode 100644
index 000000000..cedefda72
--- /dev/null
+++ b/linux/drivers/media/video/mxb.c
@@ -0,0 +1,1037 @@
+/*
+ mxb - v4l2 driver for the Multimedia eXtension Board
+
+ Copyright (C) 1998-2006 Michael Hunold <michael@mihu.de>
+
+ Visit http://www.mihu.de/linux/saa7146/mxb/
+ for further details about this card.
+
+ 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 DEBUG_VARIABLE debug
+
+#include "compat.h"
+#include <media/saa7146_vv.h>
+#include <media/tuner.h>
+#include <media/v4l2-common.h>
+#include <linux/video_decoder.h>
+
+#include "mxb.h"
+#include "tea6415c.h"
+#include "tea6420.h"
+#include "tda9840.h"
+
+#define I2C_SAA7111 0x24
+
+#define MXB_BOARD_CAN_DO_VBI(dev) (dev->revision != 0)
+
+/* global variable */
+static int mxb_num = 0;
+
+/* initial frequence the tuner will be tuned to.
+ in verden (lower saxony, germany) 4148 is a
+ channel called "phoenix" */
+static int freq = 4148;
+module_param(freq, int, 0644);
+MODULE_PARM_DESC(freq, "initial frequency the tuner will be tuned to while setup");
+
+static int debug = 0;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
+
+#define MXB_INPUTS 4
+enum { TUNER, AUX1, AUX3, AUX3_YC };
+
+static struct v4l2_input mxb_inputs[MXB_INPUTS] = {
+ { TUNER, "Tuner", V4L2_INPUT_TYPE_TUNER, 1, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { AUX1, "AUX1", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { AUX3, "AUX3 Composite", V4L2_INPUT_TYPE_CAMERA, 4, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+ { AUX3_YC, "AUX3 S-Video", V4L2_INPUT_TYPE_CAMERA, 4, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 },
+};
+
+/* this array holds the information, which port of the saa7146 each
+ input actually uses. the mxb uses port 0 for every input */
+static struct {
+ int hps_source;
+ int hps_sync;
+} input_port_selection[MXB_INPUTS] = {
+ { SAA7146_HPS_SOURCE_PORT_A, SAA7146_HPS_SYNC_PORT_A },
+ { SAA7146_HPS_SOURCE_PORT_A, SAA7146_HPS_SYNC_PORT_A },
+ { SAA7146_HPS_SOURCE_PORT_A, SAA7146_HPS_SYNC_PORT_A },
+ { SAA7146_HPS_SOURCE_PORT_A, SAA7146_HPS_SYNC_PORT_A },
+};
+
+/* this array holds the information of the audio source (mxb_audios),
+ which has to be switched corresponding to the video source (mxb_channels) */
+static int video_audio_connect[MXB_INPUTS] =
+ { 0, 1, 3, 3 };
+
+/* these are the necessary input-output-pins for bringing one audio source
+(see above) to the CD-output */
+static struct tea6420_multiplex TEA6420_cd[MXB_AUDIOS+1][2] =
+ {
+ {{1,1,0},{1,1,0}}, /* Tuner */
+ {{5,1,0},{6,1,0}}, /* AUX 1 */
+ {{4,1,0},{6,1,0}}, /* AUX 2 */
+ {{3,1,0},{6,1,0}}, /* AUX 3 */
+ {{1,1,0},{3,1,0}}, /* Radio */
+ {{1,1,0},{2,1,0}}, /* CD-Rom */
+ {{6,1,0},{6,1,0}} /* Mute */
+ };
+
+/* these are the necessary input-output-pins for bringing one audio source
+(see above) to the line-output */
+static struct tea6420_multiplex TEA6420_line[MXB_AUDIOS+1][2] =
+ {
+ {{2,3,0},{1,2,0}},
+ {{5,3,0},{6,2,0}},
+ {{4,3,0},{6,2,0}},
+ {{3,3,0},{6,2,0}},
+ {{2,3,0},{3,2,0}},
+ {{2,3,0},{2,2,0}},
+ {{6,3,0},{6,2,0}} /* Mute */
+ };
+
+#define MAXCONTROLS 1
+static struct v4l2_queryctrl mxb_controls[] = {
+ { V4L2_CID_AUDIO_MUTE, V4L2_CTRL_TYPE_BOOLEAN, "Mute", 0, 1, 1, 0, 0 },
+};
+
+static struct saa7146_extension_ioctls ioctls[] = {
+ { VIDIOC_ENUMINPUT, SAA7146_EXCLUSIVE },
+ { VIDIOC_G_INPUT, SAA7146_EXCLUSIVE },
+ { VIDIOC_S_INPUT, SAA7146_EXCLUSIVE },
+ { VIDIOC_QUERYCTRL, SAA7146_BEFORE },
+ { VIDIOC_G_CTRL, SAA7146_BEFORE },
+ { VIDIOC_S_CTRL, SAA7146_BEFORE },
+ { VIDIOC_G_TUNER, SAA7146_EXCLUSIVE },
+ { VIDIOC_S_TUNER, SAA7146_EXCLUSIVE },
+ { VIDIOC_G_FREQUENCY, SAA7146_EXCLUSIVE },
+ { VIDIOC_S_FREQUENCY, SAA7146_EXCLUSIVE },
+ { VIDIOC_G_AUDIO, SAA7146_EXCLUSIVE },
+ { VIDIOC_S_AUDIO, SAA7146_EXCLUSIVE },
+ { MXB_S_AUDIO_CD, SAA7146_EXCLUSIVE }, /* custom control */
+ { MXB_S_AUDIO_LINE, SAA7146_EXCLUSIVE }, /* custom control */
+ { 0, 0 }
+};
+
+struct mxb
+{
+ struct video_device *video_dev;
+ struct video_device *vbi_dev;
+
+ struct i2c_adapter i2c_adapter;
+
+ struct i2c_client* saa7111a;
+ struct i2c_client* tda9840;
+ struct i2c_client* tea6415c;
+ struct i2c_client* tuner;
+ struct i2c_client* tea6420_1;
+ struct i2c_client* tea6420_2;
+
+ int cur_mode; /* current audio mode (mono, stereo, ...) */
+ int cur_input; /* current input */
+ int cur_mute; /* current mute status */
+ struct v4l2_frequency cur_freq; /* current frequency the tuner is tuned to */
+};
+
+static struct saa7146_extension extension;
+
+static int mxb_probe(struct saa7146_dev* dev)
+{
+ struct mxb* mxb = NULL;
+ struct i2c_client *client;
+ struct list_head *item;
+ int result;
+
+ if ((result = request_module("saa7111")) < 0) {
+ printk("mxb: saa7111 i2c module not available.\n");
+ return -ENODEV;
+ }
+ if ((result = request_module("tuner")) < 0) {
+ printk("mxb: tuner i2c module not available.\n");
+ return -ENODEV;
+ }
+ if ((result = request_module("tea6420")) < 0) {
+ printk("mxb: tea6420 i2c module not available.\n");
+ return -ENODEV;
+ }
+ if ((result = request_module("tea6415c")) < 0) {
+ printk("mxb: tea6415c i2c module not available.\n");
+ return -ENODEV;
+ }
+ if ((result = request_module("tda9840")) < 0) {
+ printk("mxb: tda9840 i2c module not available.\n");
+ return -ENODEV;
+ }
+
+ mxb = (struct mxb*)kmalloc(sizeof(struct mxb), GFP_KERNEL);
+ if( NULL == mxb ) {
+ DEB_D(("not enough kernel memory.\n"));
+ return -ENOMEM;
+ }
+ memset(mxb, 0x0, sizeof(struct mxb));
+
+ mxb->i2c_adapter = (struct i2c_adapter) {
+ .class = I2C_CLASS_TV_ANALOG,
+ .name = "mxb",
+ };
+
+ saa7146_i2c_adapter_prepare(dev, &mxb->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
+ if(i2c_add_adapter(&mxb->i2c_adapter) < 0) {
+ DEB_S(("cannot register i2c-device. skipping.\n"));
+ kfree(mxb);
+ return -EFAULT;
+ }
+
+ /* loop through all i2c-devices on the bus and look who is there */
+ list_for_each(item,&mxb->i2c_adapter.clients) {
+ client = list_entry(item, struct i2c_client, list);
+ if( I2C_TEA6420_1 == client->addr )
+ mxb->tea6420_1 = client;
+ if( I2C_TEA6420_2 == client->addr )
+ mxb->tea6420_2 = client;
+ if( I2C_TEA6415C_2 == client->addr )
+ mxb->tea6415c = client;
+ if( I2C_TDA9840 == client->addr )
+ mxb->tda9840 = client;
+ if( I2C_SAA7111 == client->addr )
+ mxb->saa7111a = client;
+ if( 0x60 == client->addr )
+ mxb->tuner = client;
+ }
+
+ /* check if all devices are present */
+ if( 0 == mxb->tea6420_1 || 0 == mxb->tea6420_2 || 0 == mxb->tea6415c
+ || 0 == mxb->tda9840 || 0 == mxb->saa7111a || 0 == mxb->tuner ) {
+
+ printk("mxb: did not find all i2c devices. aborting\n");
+ i2c_del_adapter(&mxb->i2c_adapter);
+ kfree(mxb);
+ return -ENODEV;
+ }
+
+ /* all devices are present, probe was successful */
+
+ /* we store the pointer in our private data field */
+ dev->ext_priv = mxb;
+
+ return 0;
+}
+
+/* some init data for the saa7740, the so-called 'sound arena module'.
+ there are no specs available, so we simply use some init values */
+static struct {
+ int length;
+ char data[9];
+} mxb_saa7740_init[] = {
+ { 3, { 0x80, 0x00, 0x00 } },{ 3, { 0x80, 0x89, 0x00 } },
+ { 3, { 0x80, 0xb0, 0x0a } },{ 3, { 0x00, 0x00, 0x00 } },
+ { 3, { 0x49, 0x00, 0x00 } },{ 3, { 0x4a, 0x00, 0x00 } },
+ { 3, { 0x4b, 0x00, 0x00 } },{ 3, { 0x4c, 0x00, 0x00 } },
+ { 3, { 0x4d, 0x00, 0x00 } },{ 3, { 0x4e, 0x00, 0x00 } },
+ { 3, { 0x4f, 0x00, 0x00 } },{ 3, { 0x50, 0x00, 0x00 } },
+ { 3, { 0x51, 0x00, 0x00 } },{ 3, { 0x52, 0x00, 0x00 } },
+ { 3, { 0x53, 0x00, 0x00 } },{ 3, { 0x54, 0x00, 0x00 } },
+ { 3, { 0x55, 0x00, 0x00 } },{ 3, { 0x56, 0x00, 0x00 } },
+ { 3, { 0x57, 0x00, 0x00 } },{ 3, { 0x58, 0x00, 0x00 } },
+ { 3, { 0x59, 0x00, 0x00 } },{ 3, { 0x5a, 0x00, 0x00 } },
+ { 3, { 0x5b, 0x00, 0x00 } },{ 3, { 0x5c, 0x00, 0x00 } },
+ { 3, { 0x5d, 0x00, 0x00 } },{ 3, { 0x5e, 0x00, 0x00 } },
+ { 3, { 0x5f, 0x00, 0x00 } },{ 3, { 0x60, 0x00, 0x00 } },
+ { 3, { 0x61, 0x00, 0x00 } },{ 3, { 0x62, 0x00, 0x00 } },
+ { 3, { 0x63, 0x00, 0x00 } },{ 3, { 0x64, 0x00, 0x00 } },
+ { 3, { 0x65, 0x00, 0x00 } },{ 3, { 0x66, 0x00, 0x00 } },
+ { 3, { 0x67, 0x00, 0x00 } },{ 3, { 0x68, 0x00, 0x00 } },
+ { 3, { 0x69, 0x00, 0x00 } },{ 3, { 0x6a, 0x00, 0x00 } },
+ { 3, { 0x6b, 0x00, 0x00 } },{ 3, { 0x6c, 0x00, 0x00 } },
+ { 3, { 0x6d, 0x00, 0x00 } },{ 3, { 0x6e, 0x00, 0x00 } },
+ { 3, { 0x6f, 0x00, 0x00 } },{ 3, { 0x70, 0x00, 0x00 } },
+ { 3, { 0x71, 0x00, 0x00 } },{ 3, { 0x72, 0x00, 0x00 } },
+ { 3, { 0x73, 0x00, 0x00 } },{ 3, { 0x74, 0x00, 0x00 } },
+ { 3, { 0x75, 0x00, 0x00 } },{ 3, { 0x76, 0x00, 0x00 } },
+ { 3, { 0x77, 0x00, 0x00 } },{ 3, { 0x41, 0x00, 0x42 } },
+ { 3, { 0x42, 0x10, 0x42 } },{ 3, { 0x43, 0x20, 0x42 } },
+ { 3, { 0x44, 0x30, 0x42 } },{ 3, { 0x45, 0x00, 0x01 } },
+ { 3, { 0x46, 0x00, 0x01 } },{ 3, { 0x47, 0x00, 0x01 } },
+ { 3, { 0x48, 0x00, 0x01 } },
+ { 9, { 0x01, 0x03, 0xc5, 0x5c, 0x7a, 0x85, 0x01, 0x00, 0x54 } },
+ { 9, { 0x21, 0x03, 0xc5, 0x5c, 0x7a, 0x85, 0x01, 0x00, 0x54 } },
+ { 9, { 0x09, 0x0b, 0xb4, 0x6b, 0x74, 0x85, 0x95, 0x00, 0x34 } },
+ { 9, { 0x29, 0x0b, 0xb4, 0x6b, 0x74, 0x85, 0x95, 0x00, 0x34 } },
+ { 9, { 0x11, 0x17, 0x43, 0x62, 0x68, 0x89, 0xd1, 0xff, 0xb0 } },
+ { 9, { 0x31, 0x17, 0x43, 0x62, 0x68, 0x89, 0xd1, 0xff, 0xb0 } },
+ { 9, { 0x19, 0x20, 0x62, 0x51, 0x5a, 0x95, 0x19, 0x01, 0x50 } },
+ { 9, { 0x39, 0x20, 0x62, 0x51, 0x5a, 0x95, 0x19, 0x01, 0x50 } },
+ { 9, { 0x05, 0x3e, 0xd2, 0x69, 0x4e, 0x9a, 0x51, 0x00, 0xf0 } },
+ { 9, { 0x25, 0x3e, 0xd2, 0x69, 0x4e, 0x9a, 0x51, 0x00, 0xf0 } },
+ { 9, { 0x0d, 0x3d, 0xa1, 0x40, 0x7d, 0x9f, 0x29, 0xfe, 0x14 } },
+ { 9, { 0x2d, 0x3d, 0xa1, 0x40, 0x7d, 0x9f, 0x29, 0xfe, 0x14 } },
+ { 9, { 0x15, 0x73, 0xa1, 0x50, 0x5d, 0xa6, 0xf5, 0xfe, 0x38 } },
+ { 9, { 0x35, 0x73, 0xa1, 0x50, 0x5d, 0xa6, 0xf5, 0xfe, 0x38 } },
+ { 9, { 0x1d, 0xed, 0xd0, 0x68, 0x29, 0xb4, 0xe1, 0x00, 0xb8 } },
+ { 9, { 0x3d, 0xed, 0xd0, 0x68, 0x29, 0xb4, 0xe1, 0x00, 0xb8 } },
+ { 3, { 0x80, 0xb3, 0x0a } },
+ {-1, { 0} }
+};
+
+static const unsigned char mxb_saa7111_init[] = {
+ 0x00, 0x00, /* 00 - ID byte */
+ 0x01, 0x00, /* 01 - reserved */
+
+ /*front end */
+ 0x02, 0xd8, /* 02 - FUSE=x, GUDL=x, MODE=x */
+ 0x03, 0x23, /* 03 - HLNRS=0, VBSL=1, WPOFF=0, HOLDG=0, GAFIX=0, GAI1=256, GAI2=256 */
+ 0x04, 0x00, /* 04 - GAI1=256 */
+ 0x05, 0x00, /* 05 - GAI2=256 */
+
+ /* decoder */
+ 0x06, 0xf0, /* 06 - HSB at xx(50Hz) / xx(60Hz) pixels after end of last line */
+ 0x07, 0x30, /* 07 - HSS at xx(50Hz) / xx(60Hz) pixels after end of last line */
+ 0x08, 0xa8, /* 08 - AUFD=x, FSEL=x, EXFIL=x, VTRC=x, HPLL=x, VNOI=x */
+ 0x09, 0x02, /* 09 - BYPS=x, PREF=x, BPSS=x, VBLB=x, UPTCV=x, APER=x */
+ 0x0a, 0x80, /* 0a - BRIG=128 */
+ 0x0b, 0x47, /* 0b - CONT=1.109 */
+ 0x0c, 0x40, /* 0c - SATN=1.0 */
+ 0x0d, 0x00, /* 0d - HUE=0 */
+ 0x0e, 0x01, /* 0e - CDTO=0, CSTD=0, DCCF=0, FCTC=0, CHBW=1 */
+ 0x0f, 0x00, /* 0f - reserved */
+ 0x10, 0xd0, /* 10 - OFTS=x, HDEL=x, VRLN=x, YDEL=x */
+ 0x11, 0x8c, /* 11 - GPSW=x, CM99=x, FECO=x, COMPO=x, OEYC=1, OEHV=1, VIPB=0, COLO=0 */
+ 0x12, 0x80, /* 12 - xx output control 2 */
+ 0x13, 0x30, /* 13 - xx output control 3 */
+ 0x14, 0x00, /* 14 - reserved */
+ 0x15, 0x15, /* 15 - VBI */
+ 0x16, 0x04, /* 16 - VBI */
+ 0x17, 0x00, /* 17 - VBI */
+};
+
+/* bring hardware to a sane state. this has to be done, just in case someone
+ wants to capture from this device before it has been properly initialized.
+ the capture engine would badly fail, because no valid signal arrives on the
+ saa7146, thus leading to timeouts and stuff. */
+static int mxb_init_done(struct saa7146_dev* dev)
+{
+ struct mxb* mxb = (struct mxb*)dev->ext_priv;
+ struct video_decoder_init init;
+ struct i2c_msg msg;
+ struct tuner_setup tun_setup;
+ v4l2_std_id std = V4L2_STD_PAL_BG;
+
+ int i = 0, err = 0;
+ struct tea6415c_multiplex vm;
+
+ /* select video mode in saa7111a */
+ i = VIDEO_MODE_PAL;
+ /* fixme: currently pointless: gets overwritten by configuration below */
+ mxb->saa7111a->driver->command(mxb->saa7111a,DECODER_SET_NORM, &i);
+
+ /* write configuration to saa7111a */
+ init.data = mxb_saa7111_init;
+ init.len = sizeof(mxb_saa7111_init);
+ mxb->saa7111a->driver->command(mxb->saa7111a,DECODER_INIT, &init);
+
+ /* select tuner-output on saa7111a */
+ i = 0;
+ mxb->saa7111a->driver->command(mxb->saa7111a,DECODER_SET_INPUT, &i);
+
+ /* enable vbi bypass */
+ i = 1;
+ mxb->saa7111a->driver->command(mxb->saa7111a,DECODER_SET_VBI_BYPASS, &i);
+
+ /* select a tuner type */
+ tun_setup.mode_mask = T_ANALOG_TV;
+ tun_setup.addr = ADDR_UNSET;
+ tun_setup.type = TUNER_PHILIPS_PAL;
+ mxb->tuner->driver->command(mxb->tuner,TUNER_SET_TYPE_ADDR, &tun_setup);
+ /* tune in some frequency on tuner */
+ mxb->cur_freq.tuner = 0;
+ mxb->cur_freq.type = V4L2_TUNER_ANALOG_TV;
+ mxb->cur_freq.frequency = freq;
+ mxb->tuner->driver->command(mxb->tuner, VIDIOC_S_FREQUENCY,
+ &mxb->cur_freq);
+
+ /* set a default video standard */
+ mxb->tuner->driver->command(mxb->tuner, VIDIOC_S_STD, &std);
+
+ /* mute audio on tea6420s */
+ mxb->tea6420_1->driver->command(mxb->tea6420_1,TEA6420_SWITCH, &TEA6420_line[6][0]);
+ mxb->tea6420_2->driver->command(mxb->tea6420_2,TEA6420_SWITCH, &TEA6420_line[6][1]);
+ mxb->tea6420_1->driver->command(mxb->tea6420_1,TEA6420_SWITCH, &TEA6420_cd[6][0]);
+ mxb->tea6420_2->driver->command(mxb->tea6420_2,TEA6420_SWITCH, &TEA6420_cd[6][1]);
+
+ /* switch to tuner-channel on tea6415c*/
+ vm.out = 17;
+ vm.in = 3;
+ mxb->tea6415c->driver->command(mxb->tea6415c,TEA6415C_SWITCH, &vm);
+
+ /* select tuner-output on multicable on tea6415c*/
+ vm.in = 3;
+ vm.out = 13;
+ mxb->tea6415c->driver->command(mxb->tea6415c,TEA6415C_SWITCH, &vm);
+
+ /* the rest for mxb */
+ mxb->cur_input = 0;
+ mxb->cur_mute = 1;
+
+ mxb->cur_mode = V4L2_TUNER_MODE_STEREO;
+ mxb->tda9840->driver->command(mxb->tda9840, TDA9840_SWITCH, &mxb->cur_mode);
+
+ /* check if the saa7740 (aka 'sound arena module') is present
+ on the mxb. if so, we must initialize it. due to lack of
+ informations about the saa7740, the values were reverse
+ engineered. */
+ msg.addr = 0x1b;
+ msg.flags = 0;
+ msg.len = mxb_saa7740_init[0].length;
+ msg.buf = &mxb_saa7740_init[0].data[0];
+
+ if( 1 == (err = i2c_transfer(&mxb->i2c_adapter, &msg, 1))) {
+ /* the sound arena module is a pos, that's probably the reason
+ philips refuses to hand out a datasheet for the saa7740...
+ it seems to screw up the i2c bus, so we disable fast irq
+ based i2c transactions here and rely on the slow and safe
+ polling method ... */
+ extension.flags &= ~SAA7146_USE_I2C_IRQ;
+ for(i = 1;;i++) {
+ if( -1 == mxb_saa7740_init[i].length ) {
+ break;
+ }
+
+ msg.len = mxb_saa7740_init[i].length;
+ msg.buf = &mxb_saa7740_init[i].data[0];
+ if( 1 != (err = i2c_transfer(&mxb->i2c_adapter, &msg, 1))) {
+ DEB_D(("failed to initialize 'sound arena module'.\n"));
+ goto err;
+ }
+ }
+ INFO(("'sound arena module' detected.\n"));
+ }
+err:
+ /* the rest for saa7146: you should definitely set some basic values
+ for the input-port handling of the saa7146. */
+
+ /* ext->saa has been filled by the core driver */
+
+ /* some stuff is done via variables */
+ saa7146_set_hps_source_and_sync(dev, input_port_selection[mxb->cur_input].hps_source, input_port_selection[mxb->cur_input].hps_sync);
+
+ /* some stuff is done via direct write to the registers */
+
+ /* this is ugly, but because of the fact that this is completely
+ hardware dependend, it should be done directly... */
+ saa7146_write(dev, DD1_STREAM_B, 0x00000000);
+ saa7146_write(dev, DD1_INIT, 0x02000200);
+ saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
+
+ return 0;
+}
+
+/* interrupt-handler. this gets called when irq_mask is != 0.
+ it must clear the interrupt-bits in irq_mask it has handled */
+/*
+void mxb_irq_bh(struct saa7146_dev* dev, u32* irq_mask)
+{
+ struct mxb* mxb = (struct mxb*)dev->ext_priv;
+}
+*/
+
+static struct saa7146_ext_vv vv_data;
+
+/* this function only gets called when the probing was successful */
+static int mxb_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_data *info)
+{
+ struct mxb* mxb = (struct mxb*)dev->ext_priv;
+
+ DEB_EE(("dev:%p\n",dev));
+
+ /* checking for i2c-devices can be omitted here, because we
+ already did this in "mxb_vl42_probe" */
+
+ saa7146_vv_init(dev,&vv_data);
+ if( 0 != saa7146_register_device(&mxb->video_dev, dev, "mxb", VFL_TYPE_GRABBER)) {
+ ERR(("cannot register capture v4l2 device. skipping.\n"));
+ return -1;
+ }
+
+ /* initialization stuff (vbi) (only for revision > 0 and for extensions which want it)*/
+ if( 0 != MXB_BOARD_CAN_DO_VBI(dev)) {
+ if( 0 != saa7146_register_device(&mxb->vbi_dev, dev, "mxb", VFL_TYPE_VBI)) {
+ ERR(("cannot register vbi v4l2 device. skipping.\n"));
+ }
+ }
+
+ i2c_use_client(mxb->tea6420_1);
+ i2c_use_client(mxb->tea6420_2);
+ i2c_use_client(mxb->tea6415c);
+ i2c_use_client(mxb->tda9840);
+ i2c_use_client(mxb->saa7111a);
+ i2c_use_client(mxb->tuner);
+
+ printk("mxb: found 'Multimedia eXtension Board'-%d.\n",mxb_num);
+
+ mxb_num++;
+ mxb_init_done(dev);
+ return 0;
+}
+
+static int mxb_detach(struct saa7146_dev* dev)
+{
+ struct mxb* mxb = (struct mxb*)dev->ext_priv;
+
+ DEB_EE(("dev:%p\n",dev));
+
+ i2c_release_client(mxb->tea6420_1);
+ i2c_release_client(mxb->tea6420_2);
+ i2c_release_client(mxb->tea6415c);
+ i2c_release_client(mxb->tda9840);
+ i2c_release_client(mxb->saa7111a);
+ i2c_release_client(mxb->tuner);
+
+ saa7146_unregister_device(&mxb->video_dev,dev);
+ if( 0 != MXB_BOARD_CAN_DO_VBI(dev)) {
+ saa7146_unregister_device(&mxb->vbi_dev,dev);
+ }
+ saa7146_vv_release(dev);
+
+ mxb_num--;
+
+ i2c_del_adapter(&mxb->i2c_adapter);
+ kfree(mxb);
+
+ return 0;
+}
+
+static int mxb_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
+{
+ struct saa7146_dev *dev = fh->dev;
+ struct mxb* mxb = (struct mxb*)dev->ext_priv;
+ struct saa7146_vv *vv = dev->vv_data;
+
+ switch(cmd) {
+ case VIDIOC_ENUMINPUT:
+ {
+ struct v4l2_input *i = arg;
+
+ DEB_EE(("VIDIOC_ENUMINPUT %d.\n",i->index));
+ if( i->index < 0 || i->index >= MXB_INPUTS) {
+ return -EINVAL;
+ }
+ memcpy(i, &mxb_inputs[i->index], sizeof(struct v4l2_input));
+
+ return 0;
+ }
+ /* the saa7146 provides some controls (brightness, contrast, saturation)
+ which gets registered *after* this function. because of this we have
+ to return with a value != 0 even if the function succeded.. */
+ case VIDIOC_QUERYCTRL:
+ {
+ struct v4l2_queryctrl *qc = arg;
+ int i;
+
+ for (i = MAXCONTROLS - 1; i >= 0; i--) {
+ if (mxb_controls[i].id == qc->id) {
+ *qc = mxb_controls[i];
+ DEB_D(("VIDIOC_QUERYCTRL %d.\n",qc->id));
+ return 0;
+ }
+ }
+ return -EAGAIN;
+ }
+ case VIDIOC_G_CTRL:
+ {
+ struct v4l2_control *vc = arg;
+ int i;
+
+ for (i = MAXCONTROLS - 1; i >= 0; i--) {
+ if (mxb_controls[i].id == vc->id) {
+ break;
+ }
+ }
+
+ if( i < 0 ) {
+ return -EAGAIN;
+ }
+
+ switch (vc->id ) {
+ case V4L2_CID_AUDIO_MUTE: {
+ vc->value = mxb->cur_mute;
+ DEB_D(("VIDIOC_G_CTRL V4L2_CID_AUDIO_MUTE:%d.\n",vc->value));
+ return 0;
+ }
+ }
+
+ DEB_EE(("VIDIOC_G_CTRL V4L2_CID_AUDIO_MUTE:%d.\n",vc->value));
+ return 0;
+ }
+
+ case VIDIOC_S_CTRL:
+ {
+ struct v4l2_control *vc = arg;
+ int i = 0;
+
+ for (i = MAXCONTROLS - 1; i >= 0; i--) {
+ if (mxb_controls[i].id == vc->id) {
+ break;
+ }
+ }
+
+ if( i < 0 ) {
+ return -EAGAIN;
+ }
+
+ switch (vc->id ) {
+ case V4L2_CID_AUDIO_MUTE: {
+ mxb->cur_mute = vc->value;
+ if( 0 == vc->value ) {
+ /* switch the audio-source */
+ mxb->tea6420_1->driver->command(mxb->tea6420_1,TEA6420_SWITCH, &TEA6420_line[video_audio_connect[mxb->cur_input]][0]);
+ mxb->tea6420_2->driver->command(mxb->tea6420_2,TEA6420_SWITCH, &TEA6420_line[video_audio_connect[mxb->cur_input]][1]);
+ } else {
+ mxb->tea6420_1->driver->command(mxb->tea6420_1,TEA6420_SWITCH, &TEA6420_line[6][0]);
+ mxb->tea6420_2->driver->command(mxb->tea6420_2,TEA6420_SWITCH, &TEA6420_line[6][1]);
+ }
+ DEB_EE(("VIDIOC_S_CTRL, V4L2_CID_AUDIO_MUTE: %d.\n",vc->value));
+ break;
+ }
+ }
+ return 0;
+ }
+ case VIDIOC_G_INPUT:
+ {
+ int *input = (int *)arg;
+ *input = mxb->cur_input;
+
+ DEB_EE(("VIDIOC_G_INPUT %d.\n",*input));
+ return 0;
+ }
+ case VIDIOC_S_INPUT:
+ {
+ int input = *(int *)arg;
+ struct tea6415c_multiplex vm;
+ int i = 0;
+
+ DEB_EE(("VIDIOC_S_INPUT %d.\n",input));
+
+ if (input < 0 || input >= MXB_INPUTS) {
+ return -EINVAL;
+ }
+
+ /* fixme: locke das setzen des inputs mit hilfe des mutexes
+ down(&dev->lock);
+ video_mux(dev,*i);
+ up(&dev->lock);
+ */
+
+ /* fixme: check if streaming capture
+ if ( 0 != dev->streaming ) {
+ DEB_D(("VIDIOC_S_INPUT illegal while streaming.\n"));
+ return -EPERM;
+ }
+ */
+
+ mxb->cur_input = input;
+
+ saa7146_set_hps_source_and_sync(dev, input_port_selection[input].hps_source, input_port_selection[input].hps_sync);
+
+ /* prepare switching of tea6415c and saa7111a;
+ have a look at the 'background'-file for further informations */
+ switch( input ) {
+
+ case TUNER:
+ {
+ i = 0;
+ vm.in = 3;
+ vm.out = 17;
+
+ if ( 0 != mxb->tea6415c->driver->command(mxb->tea6415c,TEA6415C_SWITCH, &vm)) {
+ printk("VIDIOC_S_INPUT: could not address tea6415c #1\n");
+ return -EFAULT;
+ }
+ /* connect tuner-output always to multicable */
+ vm.in = 3;
+ vm.out = 13;
+ break;
+ }
+ case AUX3_YC:
+ {
+ /* nothing to be done here. aux3_yc is
+ directly connected to the saa711a */
+ i = 5;
+ break;
+ }
+ case AUX3:
+ {
+ /* nothing to be done here. aux3 is
+ directly connected to the saa711a */
+ i = 1;
+ break;
+ }
+ case AUX1:
+ {
+ i = 0;
+ vm.in = 1;
+ vm.out = 17;
+ break;
+ }
+ }
+
+ /* switch video in tea6415c only if necessary */
+ switch( input ) {
+ case TUNER:
+ case AUX1:
+ {
+ if ( 0 != mxb->tea6415c->driver->command(mxb->tea6415c,TEA6415C_SWITCH, &vm)) {
+ printk("VIDIOC_S_INPUT: could not address tea6415c #3\n");
+ return -EFAULT;
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ /* switch video in saa7111a */
+ if ( 0 != mxb->saa7111a->driver->command(mxb->saa7111a,DECODER_SET_INPUT, &i)) {
+ printk("VIDIOC_S_INPUT: could not address saa7111a #1.\n");
+ }
+
+ /* switch the audio-source only if necessary */
+ if( 0 == mxb->cur_mute ) {
+ mxb->tea6420_1->driver->command(mxb->tea6420_1,TEA6420_SWITCH, &TEA6420_line[video_audio_connect[input]][0]);
+ mxb->tea6420_2->driver->command(mxb->tea6420_2,TEA6420_SWITCH, &TEA6420_line[video_audio_connect[input]][1]);
+ }
+
+ return 0;
+ }
+ case VIDIOC_G_TUNER:
+ {
+ struct v4l2_tuner *t = arg;
+ int byte = 0;
+
+ if( 0 != t->index ) {
+ DEB_D(("VIDIOC_G_TUNER: channel %d does not have a tuner attached.\n", t->index));
+ return -EINVAL;
+ }
+
+ DEB_EE(("VIDIOC_G_TUNER: %d\n", t->index));
+
+ memset(t,0,sizeof(*t));
+ strcpy(t->name, "Television");
+
+ t->type = V4L2_TUNER_ANALOG_TV;
+ t->capability = V4L2_TUNER_CAP_NORM | V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2 | V4L2_TUNER_CAP_SAP;
+ t->rangelow = 772; /* 48.25 MHZ / 62.5 kHz = 772, see fi1216mk2-specs, page 2 */
+ t->rangehigh = 13684; /* 855.25 MHz / 62.5 kHz = 13684 */
+ /* FIXME: add the real signal strength here */
+ t->signal = 0xffff;
+ t->afc = 0;
+
+ mxb->tda9840->driver->command(mxb->tda9840,TDA9840_DETECT, &byte);
+ t->audmode = mxb->cur_mode;
+
+ if( byte < 0 ) {
+ t->rxsubchans = V4L2_TUNER_SUB_MONO;
+ } else {
+ switch(byte) {
+ case TDA9840_MONO_DETECT: {
+ t->rxsubchans = V4L2_TUNER_SUB_MONO;
+ DEB_D(("VIDIOC_G_TUNER: V4L2_TUNER_MODE_MONO.\n"));
+ break;
+ }
+ case TDA9840_DUAL_DETECT: {
+ t->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
+ DEB_D(("VIDIOC_G_TUNER: V4L2_TUNER_MODE_LANG1.\n"));
+ break;
+ }
+ case TDA9840_STEREO_DETECT: {
+ t->rxsubchans = V4L2_TUNER_SUB_STEREO | V4L2_TUNER_SUB_MONO;
+ DEB_D(("VIDIOC_G_TUNER: V4L2_TUNER_MODE_STEREO.\n"));
+ break;
+ }
+ default: { /* TDA9840_INCORRECT_DETECT */
+ t->rxsubchans = V4L2_TUNER_MODE_MONO;
+ DEB_D(("VIDIOC_G_TUNER: TDA9840_INCORRECT_DETECT => V4L2_TUNER_MODE_MONO\n"));
+ break;
+ }
+ }
+ }
+
+ return 0;
+ }
+ case VIDIOC_S_TUNER:
+ {
+ struct v4l2_tuner *t = arg;
+ int result = 0;
+ int byte = 0;
+
+ if( 0 != t->index ) {
+ DEB_D(("VIDIOC_S_TUNER: channel %d does not have a tuner attached.\n",t->index));
+ return -EINVAL;
+ }
+
+ switch(t->audmode) {
+ case V4L2_TUNER_MODE_STEREO: {
+ mxb->cur_mode = V4L2_TUNER_MODE_STEREO;
+ byte = TDA9840_SET_STEREO;
+ DEB_D(("VIDIOC_S_TUNER: V4L2_TUNER_MODE_STEREO\n"));
+ break;
+ }
+ case V4L2_TUNER_MODE_LANG1: {
+ mxb->cur_mode = V4L2_TUNER_MODE_LANG1;
+ byte = TDA9840_SET_LANG1;
+ DEB_D(("VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG1\n"));
+ break;
+ }
+ case V4L2_TUNER_MODE_LANG2: {
+ mxb->cur_mode = V4L2_TUNER_MODE_LANG2;
+ byte = TDA9840_SET_LANG2;
+ DEB_D(("VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG2\n"));
+ break;
+ }
+ default: { /* case V4L2_TUNER_MODE_MONO: {*/
+ mxb->cur_mode = V4L2_TUNER_MODE_MONO;
+ byte = TDA9840_SET_MONO;
+ DEB_D(("VIDIOC_S_TUNER: TDA9840_SET_MONO\n"));
+ break;
+ }
+ }
+
+ if( 0 != (result = mxb->tda9840->driver->command(mxb->tda9840, TDA9840_SWITCH, &byte))) {
+ printk("VIDIOC_S_TUNER error. result:%d, byte:%d\n",result,byte);
+ }
+
+ return 0;
+ }
+ case VIDIOC_G_FREQUENCY:
+ {
+ struct v4l2_frequency *f = arg;
+
+ if(0 != mxb->cur_input) {
+ DEB_D(("VIDIOC_G_FREQ: channel %d does not have a tuner!\n",mxb->cur_input));
+ return -EINVAL;
+ }
+
+ *f = mxb->cur_freq;
+
+ DEB_EE(("VIDIOC_G_FREQ: freq:0x%08x.\n", mxb->cur_freq.frequency));
+ return 0;
+ }
+ case VIDIOC_S_FREQUENCY:
+ {
+ struct v4l2_frequency *f = arg;
+
+ if (0 != f->tuner)
+ return -EINVAL;
+
+ if (V4L2_TUNER_ANALOG_TV != f->type)
+ return -EINVAL;
+
+ if(0 != mxb->cur_input) {
+ DEB_D(("VIDIOC_S_FREQ: channel %d does not have a tuner!\n",mxb->cur_input));
+ return -EINVAL;
+ }
+
+ mxb->cur_freq = *f;
+ DEB_EE(("VIDIOC_S_FREQUENCY: freq:0x%08x.\n", mxb->cur_freq.frequency));
+
+ /* tune in desired frequency */
+ mxb->tuner->driver->command(mxb->tuner, VIDIOC_S_FREQUENCY, &mxb->cur_freq);
+
+ /* hack: changing the frequency should invalidate the vbi-counter (=> alevt) */
+ spin_lock(&dev->slock);
+ vv->vbi_fieldcount = 0;
+ spin_unlock(&dev->slock);
+
+ return 0;
+ }
+ case MXB_S_AUDIO_CD:
+ {
+ int i = *(int*)arg;
+
+ if( i < 0 || i >= MXB_AUDIOS ) {
+ DEB_D(("illegal argument to MXB_S_AUDIO_CD: i:%d.\n",i));
+ return -EINVAL;
+ }
+
+ DEB_EE(("MXB_S_AUDIO_CD: i:%d.\n",i));
+
+ mxb->tea6420_1->driver->command(mxb->tea6420_1,TEA6420_SWITCH, &TEA6420_cd[i][0]);
+ mxb->tea6420_2->driver->command(mxb->tea6420_2,TEA6420_SWITCH, &TEA6420_cd[i][1]);
+
+ return 0;
+ }
+ case MXB_S_AUDIO_LINE:
+ {
+ int i = *(int*)arg;
+
+ if( i < 0 || i >= MXB_AUDIOS ) {
+ DEB_D(("illegal argument to MXB_S_AUDIO_LINE: i:%d.\n",i));
+ return -EINVAL;
+ }
+
+ DEB_EE(("MXB_S_AUDIO_LINE: i:%d.\n",i));
+ mxb->tea6420_1->driver->command(mxb->tea6420_1,TEA6420_SWITCH, &TEA6420_line[i][0]);
+ mxb->tea6420_2->driver->command(mxb->tea6420_2,TEA6420_SWITCH, &TEA6420_line[i][1]);
+
+ return 0;
+ }
+ case VIDIOC_G_AUDIO:
+ {
+ struct v4l2_audio *a = arg;
+
+ if( a->index < 0 || a->index > MXB_INPUTS ) {
+ DEB_D(("VIDIOC_G_AUDIO %d out of range.\n",a->index));
+ return -EINVAL;
+ }
+
+ DEB_EE(("VIDIOC_G_AUDIO %d.\n",a->index));
+ memcpy(a, &mxb_audios[video_audio_connect[mxb->cur_input]], sizeof(struct v4l2_audio));
+
+ return 0;
+ }
+ case VIDIOC_S_AUDIO:
+ {
+ struct v4l2_audio *a = arg;
+ DEB_D(("VIDIOC_S_AUDIO %d.\n",a->index));
+ return 0;
+ }
+ default:
+/*
+ DEB2(printk("does not handle this ioctl.\n"));
+*/
+ return -ENOIOCTLCMD;
+ }
+ return 0;
+}
+
+static int std_callback(struct saa7146_dev* dev, struct saa7146_standard *std)
+{
+ struct mxb* mxb = (struct mxb*)dev->ext_priv;
+ int zero = 0;
+ int one = 1;
+
+ if(V4L2_STD_PAL_I == std->id ) {
+ v4l2_std_id std = V4L2_STD_PAL_I;
+ DEB_D(("VIDIOC_S_STD: setting mxb for PAL_I.\n"));
+ /* set the 7146 gpio register -- I don't know what this does exactly */
+ saa7146_write(dev, GPIO_CTRL, 0x00404050);
+ /* unset the 7111 gpio register -- I don't know what this does exactly */
+ mxb->saa7111a->driver->command(mxb->saa7111a,DECODER_SET_GPIO, &zero);
+ mxb->tuner->driver->command(mxb->tuner, VIDIOC_S_STD, &std);
+ } else {
+ v4l2_std_id std = V4L2_STD_PAL_BG;
+ DEB_D(("VIDIOC_S_STD: setting mxb for PAL/NTSC/SECAM.\n"));
+ /* set the 7146 gpio register -- I don't know what this does exactly */
+ saa7146_write(dev, GPIO_CTRL, 0x00404050);
+ /* set the 7111 gpio register -- I don't know what this does exactly */
+ mxb->saa7111a->driver->command(mxb->saa7111a,DECODER_SET_GPIO, &one);
+ mxb->tuner->driver->command(mxb->tuner, VIDIOC_S_STD, &std);
+ }
+ return 0;
+}
+
+static struct saa7146_standard standard[] = {
+ {
+ .name = "PAL-BG", .id = V4L2_STD_PAL_BG,
+ .v_offset = 0x17, .v_field = 288,
+ .h_offset = 0x14, .h_pixels = 680,
+ .v_max_out = 576, .h_max_out = 768,
+ }, {
+ .name = "PAL-I", .id = V4L2_STD_PAL_I,
+ .v_offset = 0x17, .v_field = 288,
+ .h_offset = 0x14, .h_pixels = 680,
+ .v_max_out = 576, .h_max_out = 768,
+ }, {
+ .name = "NTSC", .id = V4L2_STD_NTSC,
+ .v_offset = 0x16, .v_field = 240,
+ .h_offset = 0x06, .h_pixels = 708,
+ .v_max_out = 480, .h_max_out = 640,
+ }, {
+ .name = "SECAM", .id = V4L2_STD_SECAM,
+ .v_offset = 0x14, .v_field = 288,
+ .h_offset = 0x14, .h_pixels = 720,
+ .v_max_out = 576, .h_max_out = 768,
+ }
+};
+
+static struct saa7146_pci_extension_data mxb = {
+ .ext_priv = "Multimedia eXtension Board",
+ .ext = &extension,
+};
+
+static struct pci_device_id pci_tbl[] = {
+ {
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7146,
+ .subvendor = 0x0000,
+ .subdevice = 0x0000,
+ .driver_data = (unsigned long)&mxb,
+ }, {
+ .vendor = 0,
+ }
+};
+
+MODULE_DEVICE_TABLE(pci, pci_tbl);
+
+static struct saa7146_ext_vv vv_data = {
+ .inputs = MXB_INPUTS,
+ .capabilities = V4L2_CAP_TUNER | V4L2_CAP_VBI_CAPTURE,
+ .stds = &standard[0],
+ .num_stds = sizeof(standard)/sizeof(struct saa7146_standard),
+ .std_callback = &std_callback,
+ .ioctls = &ioctls[0],
+ .ioctl = mxb_ioctl,
+};
+
+static struct saa7146_extension extension = {
+ .name = MXB_IDENTIFIER,
+ .flags = SAA7146_USE_I2C_IRQ,
+
+ .pci_tbl = &pci_tbl[0],
+ .module = THIS_MODULE,
+
+ .probe = mxb_probe,
+ .attach = mxb_attach,
+ .detach = mxb_detach,
+
+ .irq_mask = 0,
+ .irq_func = NULL,
+};
+
+static int __init mxb_init_module(void)
+{
+ if( 0 != saa7146_register_extension(&extension)) {
+ DEB_S(("failed to register extension.\n"));
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
+static void __exit mxb_cleanup_module(void)
+{
+ saa7146_unregister_extension(&extension);
+}
+
+module_init(mxb_init_module);
+module_exit(mxb_cleanup_module);
+
+MODULE_DESCRIPTION("video4linux-2 driver for the Siemens-Nixdorf 'Multimedia eXtension board'");
+MODULE_AUTHOR("Michael Hunold <michael@mihu.de>");
+MODULE_LICENSE("GPL");
diff --git a/linux/drivers/media/video/mxb.h b/linux/drivers/media/video/mxb.h
new file mode 100644
index 000000000..400a57ba6
--- /dev/null
+++ b/linux/drivers/media/video/mxb.h
@@ -0,0 +1,42 @@
+#ifndef __MXB__
+#define __MXB__
+
+#define BASE_VIDIOC_MXB 10
+
+#define MXB_S_AUDIO_CD _IOW ('V', BASE_VIDIOC_PRIVATE+BASE_VIDIOC_MXB+0, int)
+#define MXB_S_AUDIO_LINE _IOW ('V', BASE_VIDIOC_PRIVATE+BASE_VIDIOC_MXB+1, int)
+
+#define MXB_IDENTIFIER "Multimedia eXtension Board"
+
+#define MXB_AUDIOS 6
+
+/* these are the available audio sources, which can switched
+ to the line- and cd-output individually */
+static struct v4l2_audio mxb_audios[MXB_AUDIOS] = {
+ {
+ .index = 0,
+ .name = "Tuner",
+ .capability = V4L2_AUDCAP_STEREO,
+ } , {
+ .index = 1,
+ .name = "AUX1",
+ .capability = V4L2_AUDCAP_STEREO,
+ } , {
+ .index = 2,
+ .name = "AUX2",
+ .capability = V4L2_AUDCAP_STEREO,
+ } , {
+ .index = 3,
+ .name = "AUX3",
+ .capability = V4L2_AUDCAP_STEREO,
+ } , {
+ .index = 4,
+ .name = "Radio (X9)",
+ .capability = V4L2_AUDCAP_STEREO,
+ } , {
+ .index = 5,
+ .name = "CD-ROM (X10)",
+ .capability = V4L2_AUDCAP_STEREO,
+ }
+};
+#endif
diff --git a/linux/drivers/media/video/pvrusb2/Kconfig b/linux/drivers/media/video/pvrusb2/Kconfig
new file mode 100644
index 000000000..9824ad267
--- /dev/null
+++ b/linux/drivers/media/video/pvrusb2/Kconfig
@@ -0,0 +1,14 @@
+config VIDEO_PVRUSB2
+ tristate "Hauppauge WinTV-PVR USB2 support"
+ depends on VIDEO_DEV && USB && I2C && EXPERIMENTAL
+ select FW_LOADER
+ select VIDEO_TUNER
+ select VIDEO_TVEEPROM
+ select VIDEO_SAA711X
+ select VIDEO_MSP3400
+ ---help---
+ This is a video4linux driver for Conexant 23416 based
+ usb2 personal video recorder devices.
+
+ To compile this driver as a module, choose M here: the
+ module will be called pvrusb2
diff --git a/linux/drivers/media/video/pvrusb2/Makefile b/linux/drivers/media/video/pvrusb2/Makefile
new file mode 100644
index 000000000..c83742fb1
--- /dev/null
+++ b/linux/drivers/media/video/pvrusb2/Makefile
@@ -0,0 +1,11 @@
+pvrusb2-objs := pvrusb2-i2c-core.o pvrusb2-i2c-cmd-v4l2.o \
+ pvrusb2-audio.o pvrusb2-i2c-chips-v4l2.o \
+ pvrusb2-encoder.o pvrusb2-video-v4l.o \
+ pvrusb2-eeprom.o pvrusb2-tuner.o pvrusb2-demod.o \
+ pvrusb2-main.o pvrusb2-hdw.o pvrusb2-v4l2.o \
+ pvrusb2-sysfs.o pvrusb2-context.o pvrusb2-io.o \
+ pvrusb2-ioread.o pvrusb2-debugifc.o
+
+obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2.o
+
+EXTRA_CFLAGS += -I$(src)/..
diff --git a/v4l_experimental/pvrusb2/pvrusb2-audio.c b/linux/drivers/media/video/pvrusb2/pvrusb2-audio.c
index 067a686e0..7e2fab330 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-audio.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-audio.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-audio.c,v 1.9 2006/01/23 07:00:31 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
* Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
@@ -155,7 +155,7 @@ static int msp3400_check(struct pvr2_msp3400_handler *ctxt)
unsigned long msk;
unsigned int idx;
- for (idx = 0; idx < sizeof(msp3400_ops)/sizeof(msp3400_ops[0]);
+ for (idx = 0; idx < sizeof(msp3400_ops)/sizeof(msp3400_ops[0]);
idx++) {
msk = 1 << idx;
if (ctxt->stale_mask & msk) continue;
@@ -172,7 +172,7 @@ static void msp3400_update(struct pvr2_msp3400_handler *ctxt)
unsigned long msk;
unsigned int idx;
- for (idx = 0; idx < sizeof(msp3400_ops)/sizeof(msp3400_ops[0]);
+ for (idx = 0; idx < sizeof(msp3400_ops)/sizeof(msp3400_ops[0]);
idx++) {
msk = 1 << idx;
if (!(ctxt->stale_mask & msk)) continue;
diff --git a/v4l_experimental/pvrusb2/pvrusb2-audio.h b/linux/drivers/media/video/pvrusb2/pvrusb2-audio.h
index 0a278927e..536339b68 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-audio.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-audio.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-audio.h,v 1.2 2006/01/01 08:26:03 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
* Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
diff --git a/v4l_experimental/pvrusb2/pvrusb2-context.c b/linux/drivers/media/video/pvrusb2/pvrusb2-context.c
index 1f8b400a0..0f0e14d01 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-context.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-context.c
@@ -1,5 +1,5 @@
/*
- * $Id: pvrusb2-context.c,v 1.3 2006/01/23 06:58:06 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
@@ -74,7 +74,9 @@ static void pvr2_context_setup(struct pvr2_context *mp)
struct pvr2_context *pvr2_context_create(
- struct usb_interface *intf,void (*setup_func)(struct pvr2_context *))
+ struct usb_interface *intf,
+ const struct usb_device_id *devid,
+ void (*setup_func)(struct pvr2_context *))
{
struct pvr2_context *mp = 0;
mp = kmalloc(sizeof(*mp),GFP_KERNEL);
@@ -83,7 +85,7 @@ struct pvr2_context *pvr2_context_create(
pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr_main id=%p",mp);
mp->setup_func = setup_func;
mutex_init(&mp->mutex);
- mp->hdw = pvr2_hdw_create(intf);
+ mp->hdw = pvr2_hdw_create(intf,devid);
if (!mp->hdw) {
pvr2_context_destroy(mp);
mp = 0;
@@ -183,7 +185,7 @@ void pvr2_channel_done(struct pvr2_channel *cp)
int pvr2_channel_claim_stream(struct pvr2_channel *cp,
- struct pvr2_context_stream *sp)
+ struct pvr2_context_stream *sp)
{
int code = 0;
pvr2_context_enter(cp->mc_head); do {
diff --git a/v4l_experimental/pvrusb2/pvrusb2-context.h b/linux/drivers/media/video/pvrusb2/pvrusb2-context.h
index 229a8ef0e..873622a0f 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-context.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-context.h
@@ -1,5 +1,5 @@
/*
- * $Id: pvrusb2-context.h,v 1.3 2006/01/23 06:58:06 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
@@ -77,6 +77,7 @@ void pvr2_context_enter(struct pvr2_context *);
void pvr2_context_exit(struct pvr2_context *);
struct pvr2_context *pvr2_context_create(struct usb_interface *intf,
+ const struct usb_device_id *devid,
void (*setup_func)(struct pvr2_context *));
void pvr2_context_disconnect(struct pvr2_context *);
diff --git a/v4l_experimental/pvrusb2/pvrusb2-debug.h b/linux/drivers/media/video/pvrusb2/pvrusb2-debug.h
index 70a143736..d95a8588e 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-debug.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-debug.h
@@ -1,5 +1,5 @@
/*
- * $Id: pvrusb2-debug.h,v 1.5 2006/01/14 22:09:52 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
@@ -22,7 +22,7 @@
extern int pvrusb2_debug;
-#define pvr2_trace(msk, fmt, arg...) do {if(msk & pvrusb2_debug) printk(KERN_INFO "pvrusb2 " fmt "\n", ##arg); } while (0)
+#define pvr2_trace(msk, fmt, arg...) do {if(msk & pvrusb2_debug) printk(KERN_INFO "pvrusb2: " fmt "\n", ##arg); } while (0)
/* These are listed in *rough* order of decreasing usefulness and
increasing noise level. */
diff --git a/v4l_experimental/pvrusb2/pvrusb2-debugifc.c b/linux/drivers/media/video/pvrusb2/pvrusb2-debugifc.c
index f56b96f56..bcfe468eb 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-debugifc.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-debugifc.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-debugifc.c,v 1.2 2006/01/01 08:26:03 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
@@ -41,7 +41,7 @@ static struct debugifc_mask_item mask_items[] = {
static unsigned int debugifc_count_whitespace(const char *buf,
- unsigned int count)
+ unsigned int count)
{
unsigned int scnt;
char ch;
@@ -58,7 +58,7 @@ static unsigned int debugifc_count_whitespace(const char *buf,
static unsigned int debugifc_count_nonwhitespace(const char *buf,
- unsigned int count)
+ unsigned int count)
{
unsigned int scnt;
char ch;
@@ -74,8 +74,8 @@ static unsigned int debugifc_count_nonwhitespace(const char *buf,
static unsigned int debugifc_isolate_word(const char *buf,unsigned int count,
- const char **wstrPtr,
- unsigned int *wlenPtr)
+ const char **wstrPtr,
+ unsigned int *wlenPtr)
{
const char *wptr;
unsigned int consume_cnt = 0;
@@ -102,7 +102,7 @@ static unsigned int debugifc_isolate_word(const char *buf,unsigned int count,
static int debugifc_parse_unsigned_number(const char *buf,unsigned int count,
- u32 *num_ptr)
+ u32 *num_ptr)
{
u32 result = 0;
u32 val;
@@ -138,7 +138,7 @@ static int debugifc_parse_unsigned_number(const char *buf,unsigned int count,
static int debugifc_match_keyword(const char *buf,unsigned int count,
- const char *keyword)
+ const char *keyword)
{
unsigned int kl;
if (!keyword) return 0;
@@ -163,7 +163,7 @@ static unsigned long debugifc_find_mask(const char *buf,unsigned int count)
static int debugifc_print_mask(char *buf,unsigned int sz,
- unsigned long msk,unsigned long val)
+ unsigned long msk,unsigned long val)
{
struct debugifc_mask_item *mip;
unsigned int idx;
@@ -184,9 +184,9 @@ static int debugifc_print_mask(char *buf,unsigned int sz,
}
static unsigned int debugifc_parse_subsys_mask(const char *buf,
- unsigned int count,
- unsigned long *mskPtr,
- unsigned long *valPtr)
+ unsigned int count,
+ unsigned long *mskPtr,
+ unsigned long *valPtr)
{
const char *wptr;
unsigned int consume_cnt = 0;
@@ -286,7 +286,7 @@ int pvr2_debugifc_print_info(struct pvr2_hdw *hdw,char *buf,unsigned int acnt)
int pvr2_debugifc_print_status(struct pvr2_hdw *hdw,
- char *buf,unsigned int acnt)
+ char *buf,unsigned int acnt)
{
int bcnt = 0;
int ccnt;
@@ -338,7 +338,7 @@ int pvr2_debugifc_print_status(struct pvr2_hdw *hdw,
int pvr2_debugifc_do1cmd(struct pvr2_hdw *hdw,const char *buf,
- unsigned int count)
+ unsigned int count)
{
const char *wptr;
unsigned int wlen;
@@ -444,7 +444,7 @@ int pvr2_debugifc_do1cmd(struct pvr2_hdw *hdw,const char *buf,
int pvr2_debugifc_docmd(struct pvr2_hdw *hdw,const char *buf,
- unsigned int count)
+ unsigned int count)
{
unsigned int bcnt = 0;
int ret;
diff --git a/v4l_experimental/pvrusb2/pvrusb2-debugifc.h b/linux/drivers/media/video/pvrusb2/pvrusb2-debugifc.h
index 59f4373d6..990b02d35 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-debugifc.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-debugifc.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-debugifc.h,v 1.1 2005/11/14 13:31:24 mchehab Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
diff --git a/v4l_experimental/pvrusb2/pvrusb2-demod.c b/linux/drivers/media/video/pvrusb2/pvrusb2-demod.c
index f7545b773..dca787dfa 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-demod.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-demod.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-demod.c,v 1.5 2006/01/22 03:48:34 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
* Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
diff --git a/v4l_experimental/pvrusb2/pvrusb2-demod.h b/linux/drivers/media/video/pvrusb2/pvrusb2-demod.h
index 0067872ea..4c4e40ffb 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-demod.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-demod.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-demod.h,v 1.1 2006/01/01 08:26:03 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
diff --git a/v4l_experimental/pvrusb2/pvrusb2-eeprom.c b/linux/drivers/media/video/pvrusb2/pvrusb2-eeprom.c
index 9df9fd3eb..60ee45ca2 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-eeprom.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-eeprom.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-eeprom.c,v 1.5 2006/01/14 19:09:50 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
* Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
@@ -86,21 +86,22 @@
*/
-#define PVR_EEPROM_I2C_ADDR 0x50
-
#include <media/tveeprom.h>
-/* We seem to only be interested in the back half of the EEPROM */
+/* We seem to only be interested in the last 128 bytes of the EEPROM */
#define EEPROM_SIZE 128
-#define EEPROM_OFFS 128
/* Grab EEPROM contents, needed for direct method. */
static u8 *pvr2_eeprom_fetch(struct pvr2_hdw *hdw)
{
struct i2c_msg msg[2];
u8 *eeprom;
- u8 offs;
+ u8 iadd[2];
+ u8 addr;
+ u16 eepromSize;
+ unsigned int offs;
int ret;
+ int mode16 = 0;
unsigned pcnt,tcnt;
eeprom = kmalloc(EEPROM_SIZE,GFP_KERNEL);
if (!eeprom) {
@@ -110,11 +111,28 @@ static u8 *pvr2_eeprom_fetch(struct pvr2_hdw *hdw)
return 0;
}
- msg[0].addr = PVR_EEPROM_I2C_ADDR;
+ trace_eeprom("Value for eeprom addr from controller was 0x%x",
+ hdw->eeprom_addr);
+ addr = hdw->eeprom_addr;
+ /* Seems that if the high bit is set, then the *real* eeprom
+ address is shifted right now bit position (noticed this in
+ newer PVR USB2 hardware) */
+ if (addr & 0x80) addr >>= 1;
+
+ /* FX2 documentation states that a 16bit-addressed eeprom is
+ expected if the I2C address is an odd number (yeah, this is
+ strange bit it's what they do) */
+ mode16 = (addr & 1);
+ eepromSize = (mode16 ? 4096 : 256);
+ trace_eeprom("Examining %d byte eeprom at location 0x%x"
+ " using %d bit addressing",eepromSize,addr,
+ mode16 ? 16 : 8);
+
+ msg[0].addr = addr;
msg[0].flags = 0;
- msg[0].len = 1;
- msg[0].buf = &offs;
- msg[1].addr = PVR_EEPROM_I2C_ADDR;
+ msg[0].len = mode16 ? 2 : 1;
+ msg[0].buf = iadd;
+ msg[1].addr = hdw->eeprom_addr;
msg[1].flags = I2C_M_RD;
/* We have to do the actual eeprom data fetch ourselves, because
@@ -125,7 +143,13 @@ static u8 *pvr2_eeprom_fetch(struct pvr2_hdw *hdw)
for (tcnt = 0; tcnt < EEPROM_SIZE; tcnt += pcnt) {
pcnt = 16;
if (pcnt + tcnt > EEPROM_SIZE) pcnt = EEPROM_SIZE-tcnt;
- offs = tcnt + EEPROM_OFFS;
+ offs = tcnt + (eepromSize - EEPROM_SIZE);
+ if (mode16) {
+ iadd[0] = offs >> 8;
+ iadd[1] = offs;
+ } else {
+ iadd[0] = offs;
+ }
msg[1].len = pcnt;
msg[1].buf = eeprom+tcnt;
if ((ret = i2c_transfer(
@@ -163,7 +187,7 @@ int pvr2_eeprom_analyze(struct pvr2_hdw *hdw)
{
struct i2c_client fake_client;
/* Newer version expects a useless client interface */
- fake_client.addr = PVR_EEPROM_I2C_ADDR;
+ fake_client.addr = hdw->eeprom_addr;
fake_client.adapter = &hdw->i2c_adap;
tveeprom_hauppauge_analog(&fake_client,&tvdata,eeprom);
}
diff --git a/v4l_experimental/pvrusb2/pvrusb2-eeprom.h b/linux/drivers/media/video/pvrusb2/pvrusb2-eeprom.h
index edc80b62e..061cecd91 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-eeprom.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-eeprom.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-eeprom.h,v 1.1 2005/11/14 13:31:24 mchehab Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
* Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
diff --git a/v4l_experimental/pvrusb2/pvrusb2-encoder.c b/linux/drivers/media/video/pvrusb2/pvrusb2-encoder.c
index 046cd9f1f..97931d3c4 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-encoder.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-encoder.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-encoder.c,v 1.5 2006/01/14 20:11:08 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
* Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
@@ -147,7 +147,7 @@ static int pvr2_read_encoder_words(struct pvr2_hdw *hdw,int statusFl,
static int pvr2_write_encoder_vcmd (struct pvr2_hdw *hdw, u8 cmd,
- int args, ...)
+ int args, ...)
{
unsigned int poll_count;
int ret = 0;
@@ -308,14 +308,14 @@ int pvr2_encoder_configure(struct pvr2_hdw *hdw)
the ivtv driver). But, if I leave them in, then mplayer
goes nuts with xrun errors. So for now we don't do this.
It sure would be nice to know what these are for. */
-#ifdef notdef
+#if 0
ret |= pvr2_write_encoder_vcmd(hdw, 0xdc, 1, 5);
ret |= pvr2_write_encoder_vcmd(hdw, 0xdc, 2, 3, 1);
ret |= pvr2_write_encoder_vcmd(hdw, 0xdc, 1, 8);
#endif
/* Strange compared to ivtv data. */
-#ifdef notdef
+#if 0
ret |= pvr2_write_encoder_vcmd(hdw, CX2341X_ENC_SET_NUM_VSYNC_LINES, 2,
0x0120, 0x0120);
ret |= pvr2_write_encoder_vcmd(hdw, CX2341X_ENC_SET_NUM_VSYNC_LINES, 2,
diff --git a/v4l_experimental/pvrusb2/pvrusb2-encoder.h b/linux/drivers/media/video/pvrusb2/pvrusb2-encoder.h
index 4a35e8ac0..01b5a0b89 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-encoder.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-encoder.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-encoder.h,v 1.1 2005/11/14 13:31:24 mchehab Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
* Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
diff --git a/v4l_experimental/pvrusb2/pvrusb2-hdw-internal.h b/linux/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
index c4b1cbdcd..1b161773b 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-hdw-internal.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-hdw-internal.h,v 1.6 2006/01/23 06:58:06 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
@@ -93,6 +93,10 @@ struct pvr2_decoder_ctrl {
#define FW1_STATE_RELOAD 3
#define FW1_STATE_OK 4
+/* Known major hardware variants, keyed from device ID */
+#define PVR2_HDW_TYPE_29XXX 0
+#define PVR2_HDW_TYPE_24XXX 1
+
/* This structure contains all state data directly needed to
manipulate the hardware (as opposed to complying with a kernel
interface) */
@@ -101,6 +105,9 @@ struct pvr2_hdw {
struct usb_device *usb_dev;
struct usb_interface *usb_intf;
+ /* Device type, one of PVR2_HDW_TYPE_xxxxx */
+ unsigned int hdw_type;
+
/* Video spigot */
struct pvr2_stream *vid_stream;
@@ -176,6 +183,10 @@ struct pvr2_hdw {
// Which subsystems are manipulated to enable streaming
unsigned long subsys_stream_mask;
+ // True if there is a request to trigger logging of state in each
+ // module.
+ int log_requested;
+
/* Tuner / frequency control stuff */
unsigned int tuner_type;
int tuner_updated;
@@ -188,6 +199,9 @@ struct pvr2_hdw {
be no v4l junk here). Probably a better way to do this. */
int v4l_minor_number;
+ /* Location of eeprom or a negative number if none */
+ int eeprom_addr;
+
enum pvr2_config config;
/* Information about what audio signal we're hearing */
@@ -200,7 +214,7 @@ struct pvr2_hdw {
};
int pvr2_hdw_set_ctl_value_internal(struct pvr2_hdw *hdw,
- unsigned int ctl_id,int value);
+ unsigned int ctl_id,int value);
int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw);
diff --git a/v4l_experimental/pvrusb2/pvrusb2-hdw.c b/linux/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 20206cff9..b87651e5a 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-hdw.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-hdw.c,v 1.13 2006/01/23 06:58:06 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
@@ -35,6 +35,19 @@
#include "pvrusb2-encoder.h"
#include "pvrusb2-debug.h"
+struct usb_device_id pvr2_device_table[] = {
+ [PVR2_HDW_TYPE_29XXX] = { USB_DEVICE(0x2040, 0x2900) },
+ [PVR2_HDW_TYPE_24XXX] = { USB_DEVICE(0x2040, 0x2400) },
+ { }
+};
+
+MODULE_DEVICE_TABLE(usb, pvr2_device_table);
+
+static const char *pvr2_device_names[] = {
+ [PVR2_HDW_TYPE_29XXX] = "WinTV PVR USB2 Model Category 29xxxx",
+ [PVR2_HDW_TYPE_24XXX] = "WinTV PVR USB2 Model Category 24xxxx",
+};
+
static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = 0};
DECLARE_MUTEX(pvr2_unit_sem);
@@ -43,14 +56,17 @@ static int initusbreset = 1;
static int procreload = 0;
static int tuner[PVR_NUM] = { [0 ... PVR_NUM-1] = -1 };
static int tolerance[PVR_NUM] = { [0 ... PVR_NUM-1] = 0 };
+static int init_pause_msec = 0;
module_param(ctlchg, int, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(ctlchg, "0=optimize ctl change 1=always accept new ctl value");
+module_param(init_pause_msec, int, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(init_pause_msec, "hardware initialization settling delay");
module_param(initusbreset, int, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(initusbreset, "Do USB reset device on probe");
module_param(procreload, int, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(procreload,
- "Attempt init failure recovery with firmware reload");
+ "Attempt init failure recovery with firmware reload");
module_param_array(tuner, int, NULL, 0444);
MODULE_PARM_DESC(tuner,"specify installed tuner type");
module_param_array(tolerance, int, NULL, 0444);
@@ -70,10 +86,6 @@ MODULE_PARM_DESC(tolerance,"specify stream error tolerance");
/* size of a firmware chunk */
#define FIRMWARE_CHUNK_SIZE 0x2000
-/* Various files we will load with firmware_entry */
-#define FIRMWARE1_FILE "pvrusb2.f1"
-#define FIRMWARE2_FILE "pvrusb2.f2"
-
typedef int (*pvr2_ctl_set_func)(struct pvr2_hdw *,int ctl_id,int val);
typedef int (*pvr2_ctl_get_func)(struct pvr2_hdw *,int ctl_id);
@@ -169,7 +181,7 @@ static int pvr2_ctl_get_subsys_mask(struct pvr2_hdw *hdw,int ctl_id);
static int pvr2_ctl_set_subsys_mask(struct pvr2_hdw *hdw,int ctl_id,int val);
static int pvr2_ctl_get_subsys_stream_mask(struct pvr2_hdw *hdw,int ctl_id);
static int pvr2_ctl_set_subsys_stream_mask(struct pvr2_hdw *hdw,int ctl_id,
- int val);
+ int val);
static struct pvr2_ctl_def control_defs[PVR2_CID_COUNT] =
{
@@ -296,7 +308,7 @@ static struct pvr2_ctl_def control_defs[PVR2_CID_COUNT] =
[PVR2_CID_FREQUENCY] = {
.name = "Tuner Frequency (Hz)",
.min_value = 55250000L,
- .max_value = 801250000L,
+ .max_value = 850000000L,
.default_value = 175250000L,
},
[PVR2_CID_HRES] = {
@@ -338,7 +350,7 @@ static struct pvr2_ctl_def control_defs[PVR2_CID_COUNT] =
[PVR2_CID_CHANPROG_FREQ] = {
.name = "Channel Program Frequency",
.min_value = 55250000L,
- .max_value = 801250000L,
+ .max_value = 850000000L,
.skip_init = !0,
.set_func = pvr2_ctl_set_chanprog_id,
.get_func = pvr2_ctl_get_chanprog_id,
@@ -421,6 +433,63 @@ int pvr2_hdw_get_unit_number(struct pvr2_hdw *hdw)
}
+/* Attempt to locate one of the given set of files. Messages are logged
+ appropriate to what has been found. The return value will be 0 or
+ greater on success (it will be the index of the file name found) and
+ fw_entry will be filled in. Otherwise a negative error is returned on
+ failure. If the return value is -ENOENT then no viable firmware file
+ could be located. */
+static int pvr2_locate_firmware(struct pvr2_hdw *hdw,
+ const struct firmware **fw_entry,
+ const char *fwtypename,
+ unsigned int fwcount,
+ const char *fwnames[])
+{
+ unsigned int idx;
+ int ret = -EINVAL;
+ for (idx = 0; idx < fwcount; idx++) {
+ ret = request_firmware(fw_entry,
+ fwnames[idx],
+ &hdw->usb_dev->dev);
+ if (!ret) {
+ trace_firmware("Located %s firmware: %s;"
+ " uploading...",
+ fwtypename,
+ fwnames[idx]);
+ return idx;
+ }
+ if (ret == -ENOENT) continue;
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "request_firmware fatal error with code=%d",ret);
+ return ret;
+ }
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "***WARNING***"
+ " Device %s firmware"
+ " seems to be missing.",
+ fwtypename);
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "Did you install the pvrusb2 firmware files"
+ " in their proper location?");
+ if (fwcount == 1) {
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "request_firmware unable to locate %s file %s",
+ fwtypename,fwnames[0]);
+ } else {
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "request_firmware unable to locate"
+ " one of the following %s files:",
+ fwtypename);
+ for (idx = 0; idx < fwcount; idx++) {
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "request_firmware: Failed to find %s",
+ fwnames[idx]);
+ }
+ }
+ return ret;
+}
+
+
/*
* pvr2_upload_firmware1().
*
@@ -438,27 +507,41 @@ int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
unsigned int pipe;
int ret;
u16 address;
- const char *firmware_file = FIRMWARE1_FILE;
-
+ static const char *fw_files_29xxx[] = {
+ "v4l-pvrusb2-29xxx-01.fw",
+ };
+ static const char *fw_files_24xxx[] = {
+ "v4l-pvrusb2-24xxx-01.fw",
+ };
+ static const struct {
+ const char **lst;
+ unsigned int cnt;
+ } fw_file_defs[] = {
+ [PVR2_HDW_TYPE_29XXX] = {
+ fw_files_29xxx,
+ sizeof(fw_files_29xxx)/sizeof(fw_files_29xxx[0]),
+ },
+ [PVR2_HDW_TYPE_24XXX] = {
+ fw_files_24xxx,
+ sizeof(fw_files_24xxx)/sizeof(fw_files_24xxx[0]),
+ },
+ };
hdw->fw1_state = FW1_STATE_FAILED; // default result
trace_firmware("pvr2_upload_firmware1");
+ ret = pvr2_locate_firmware(hdw,&fw_entry,"fx2 controller",
+ fw_file_defs[hdw->hdw_type].cnt,
+ fw_file_defs[hdw->hdw_type].lst);
+ if (ret < 0) {
+ if (ret == -ENOENT) hdw->fw1_state = FW1_STATE_MISSING;
+ return ret;
+ }
+
usb_settoggle(hdw->usb_dev, 0 & 0xf, !(0 & USB_DIR_IN), 0);
usb_clear_halt(hdw->usb_dev, usb_sndbulkpipe(hdw->usb_dev, 0 & 0x7f));
pipe = usb_sndctrlpipe(hdw->usb_dev, 0);
- ret = request_firmware(&fw_entry, firmware_file, &hdw->usb_dev->dev);
-
- if (ret) {
- pvr2_trace(PVR2_TRACE_ERROR_LEGS,
- "request_firmware failed for '%s' code=%d",
- firmware_file,ret);
- if (ret == -ENOENT) {
- hdw->fw1_state = FW1_STATE_MISSING;
- }
- return ret;
- }
if (fw_entry->size != 0x2000){
pvr2_trace(PVR2_TRACE_ERROR_LEGS,"wrong fx2 firmware size");
@@ -519,9 +602,20 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
unsigned int pipe, fw_len, fw_done;
int actual_length;
int ret = 0;
+ int fwidx;
+ static const char *fw_files[] = {
+ "v4l-cx2341x-enc.fw",
+ };
trace_firmware("pvr2_upload_firmware2");
+ ret = pvr2_locate_firmware(hdw,&fw_entry,"encoder",
+ sizeof(fw_files)/sizeof(fw_files[0]),
+ fw_files);
+ if (ret < 0) return ret;
+ fwidx = ret;
+ ret = 0;
+
/* First prepare firmware loading */
ret |= pvr2_hdw_cmd_soft_reset(hdw);
ret |= pvr2_write_register(hdw, 0x0048, 0xffffffff); /*interrupt mask*/
@@ -546,34 +640,19 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
if (ret) {
pvr2_trace(PVR2_TRACE_ERROR_LEGS,
"firmware2 upload prep failed, ret=%d",ret);
+ release_firmware(fw_entry);
return ret;
}
/* Now send firmware */
- ret = request_firmware(&fw_entry, FIRMWARE2_FILE, &hdw->usb_dev->dev);
-
- if (ret) {
- pvr2_trace(PVR2_TRACE_ERROR_LEGS,
- "request_firmware failed for '%s'", FIRMWARE2_FILE);
- if (ret == -ENOENT) {
- pvr2_trace(PVR2_TRACE_ERROR_LEGS,
- "***WARNING***"
- " Device encoder firmware"
- " seems to be missing.");
- pvr2_trace(PVR2_TRACE_ERROR_LEGS,
- "Did you install the pvrusb2 firmware files"
- " in their proper location?");
- }
- return ret;
- }
-
fw_len = fw_entry->size;
if (fw_len % FIRMWARE_CHUNK_SIZE) {
pvr2_trace(PVR2_TRACE_ERROR_LEGS,
- "size of %s must be a multiple of 8192B",
- FIRMWARE2_FILE);
+ "size of %s firmware"
+ " must be a multiple of 8192B",
+ fw_files[fwidx]);
release_firmware(fw_entry);
return -1;
}
@@ -603,7 +682,7 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
}
trace_firmware("upload of %s : %i / %i ",
- FIRMWARE2_FILE,fw_done,fw_len);
+ fw_files[fwidx],fw_done,fw_len);
kfree(fw_ptr);
release_firmware(fw_entry);
@@ -842,8 +921,8 @@ unsigned long pvr2_hdw_subsys_stream_get(struct pvr2_hdw *hdw)
void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
- unsigned long msk,
- unsigned long val)
+ unsigned long msk,
+ unsigned long val)
{
unsigned long val2;
msk &= PVR2_SUBSYS_ALL;
@@ -856,8 +935,8 @@ void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
void pvr2_hdw_subsys_stream_bit_chg(struct pvr2_hdw *hdw,
- unsigned long msk,
- unsigned long val)
+ unsigned long msk,
+ unsigned long val)
{
LOCK_TAKE(hdw->big_lock); do {
pvr2_hdw_subsys_stream_bit_chg_no_lock(hdw,msk,val);
@@ -906,7 +985,7 @@ int pvr2_hdw_set_streaming(struct pvr2_hdw *hdw,int enable_flag)
int pvr2_hdw_set_stream_type_no_lock(struct pvr2_hdw *hdw,
- enum pvr2_config config)
+ enum pvr2_config config)
{
unsigned long sm = hdw->subsys_enabled_mask;
if (!hdw->flag_ok) return -EIO;
@@ -952,10 +1031,55 @@ static unsigned int get_default_error_tolerance(struct pvr2_hdw *hdw)
}
+static int pvr2_hdw_check_firmware(struct pvr2_hdw *hdw)
+{
+ /* Try a harmless request to fetch the eeprom's address over
+ endpoint 1. See what happens. Only the full FX2 image can
+ respond to this. If this probe fails then likely the FX2
+ firmware needs be loaded. */
+ int result;
+ LOCK_TAKE(hdw->ctl_lock); do {
+ hdw->cmd_buffer[0] = 0xeb;
+ result = pvr2_send_request_ex(hdw,HZ*1,!0,
+ hdw->cmd_buffer,1,
+ hdw->cmd_buffer,1);
+ if (result < 0) break;
+ } while(0); LOCK_GIVE(hdw->ctl_lock);
+ if (result) {
+ pvr2_trace(PVR2_TRACE_INIT,
+ "Probe of device endpoint 1 result status %d",
+ result);
+ } else {
+ pvr2_trace(PVR2_TRACE_INIT,
+ "Probe of device endpoint 1 succeeded");
+ }
+ return result == 0;
+}
+
+
static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
{
+ int ret;
unsigned int idx;
- if (hdw->usb_intf->cur_altsetting->desc.bNumEndpoints == 0) {
+ int reloadFl = 0;
+ if (!reloadFl) {
+ reloadFl = (hdw->usb_intf->cur_altsetting->desc.bNumEndpoints
+ == 0);
+ if (reloadFl) {
+ pvr2_trace(PVR2_TRACE_INIT,
+ "USB endpoint config looks strange"
+ "; possibly firmware needs to be loaded");
+ }
+ }
+ if (!reloadFl) {
+ reloadFl = !pvr2_hdw_check_firmware(hdw);
+ if (reloadFl) {
+ pvr2_trace(PVR2_TRACE_INIT,
+ "Check for FX2 firmware failed"
+ "; possibly firmware needs to be loaded");
+ }
+ }
+ if (reloadFl) {
if (pvr2_upload_firmware1(hdw) != 0) {
pvr2_trace(PVR2_TRACE_ERROR_LEGS,
"Failure uploading firmware1");
@@ -987,8 +1111,16 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
pvr2_reset_ctl_endpoints(hdw);
if (!pvr2_hdw_dev_ok(hdw)) return;
- pvr2_eeprom_analyze(hdw);
+ ret = pvr2_hdw_get_eeprom_addr(hdw);
if (!pvr2_hdw_dev_ok(hdw)) return;
+ if (ret < 0) {
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "Unable to determine location of eeprom, skipping");
+ } else {
+ hdw->eeprom_addr = ret;
+ pvr2_eeprom_analyze(hdw);
+ if (!pvr2_hdw_dev_ok(hdw)) return;
+ }
if (!get_default_tuner_type(hdw)) {
pvr2_trace(PVR2_TRACE_INIT,
@@ -1059,21 +1191,17 @@ int pvr2_hdw_setup(struct pvr2_hdw *hdw)
" and reconnect.");
break;
}
+ pvr2_trace(
+ PVR2_TRACE_ERROR_LEGS,
+ "Device initialization was not successful.");
if (hdw->fw1_state == FW1_STATE_MISSING) {
pvr2_trace(
PVR2_TRACE_ERROR_LEGS,
- "***WARNING***"
- " Device microcontroller firmware"
- " seems to be missing.");
- pvr2_trace(
- PVR2_TRACE_ERROR_LEGS,
- "Did you install the pvrusb2 firmware"
- " files in their proper location?");
+ "Giving up since device"
+ " microcontroller firmware"
+ " appears to be missing.");
break;
}
- pvr2_trace(
- PVR2_TRACE_ERROR_LEGS,
- "Device initialization was not successful.");
}
if (procreload) {
pvr2_trace(
@@ -1099,22 +1227,37 @@ int pvr2_hdw_setup(struct pvr2_hdw *hdw)
" in order to recover.");
}
} while (0); LOCK_GIVE(hdw->big_lock);
+ pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_setup(hdw=%p) end",hdw);
return hdw->flag_init_ok;
}
/* Create and return a structure for interacting with the underlying
hardware */
-struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf)
+struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
+ const struct usb_device_id *devid)
{
unsigned int idx,cnt1,cnt2;
struct pvr2_hdw *hdw;
+ unsigned int hdw_type;
__u8 ifnum;
+ hdw_type = devid - pvr2_device_table;
+ if (hdw_type >=
+ sizeof(pvr2_device_names)/sizeof(pvr2_device_names[0])) {
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "Bogus device type of %u reported",hdw_type);
+ return 0;
+ }
+
hdw = kmalloc(sizeof(*hdw),GFP_KERNEL);
- pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_create: hdw=%p",hdw);
+ pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_create: hdw=%p, type \"%s\"",
+ hdw,pvr2_device_names[hdw_type]);
if (!hdw) goto fail;
memset(hdw,0,sizeof(*hdw));
+ hdw->hdw_type = hdw_type;
+
+ hdw->eeprom_addr = -1;
hdw->unit_number = -1;
hdw->v4l_minor_number = -1;
hdw->ctl_write_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL);
@@ -1342,7 +1485,7 @@ int pvr2_hdw_get_ctl_max_value(struct pvr2_hdw *hdw,unsigned int ctl_id)
/* Set current value for given control - normally this is just stored and
the hardware isn't updated until the commit function is called. */
int pvr2_hdw_set_ctl_value_internal(struct pvr2_hdw *hdw,
- unsigned int ctl_id,int value)
+ unsigned int ctl_id,int value)
{
if (ctl_id >= PVR2_CID_COUNT) return -EINVAL;
if (value < control_defs[ctl_id].min_value) return -EINVAL;
@@ -1377,8 +1520,8 @@ int pvr2_hdw_set_ctl_value(struct pvr2_hdw *hdw,unsigned int ctl_id,int value)
/* Retrieve string name for a given control value (returns a null pointer
for any invalid combinations). */
const char *pvr2_hdw_get_ctl_value_name(struct pvr2_hdw *hdw,
- unsigned int ctl_id,
- int value)
+ unsigned int ctl_id,
+ int value)
{
struct pvr2_ctl_def *cdef;
if (ctl_id >= PVR2_CID_COUNT) return 0;
@@ -1641,7 +1784,7 @@ static int pvr2_ctl_get_subsys_stream_mask(struct pvr2_hdw *hdw,int ctl_id)
static int pvr2_ctl_set_subsys_stream_mask(struct pvr2_hdw *hdw,int ctl_id,
- int val)
+ int val)
{
pvr2_hdw_subsys_stream_bit_chg_no_lock(hdw,~0,val);
return 0;
@@ -1697,6 +1840,16 @@ struct pvr2_stream *pvr2_hdw_get_video_stream(struct pvr2_hdw *hp)
}
+void pvr2_hdw_trigger_module_log(struct pvr2_hdw *hdw)
+{
+ LOCK_TAKE(hdw->big_lock); do {
+ hdw->log_requested = !0;
+ pvr2_i2c_core_check_stale(hdw);
+ hdw->log_requested = 0;
+ pvr2_i2c_core_sync(hdw);
+ } while (0); LOCK_GIVE(hdw->big_lock);
+}
+
void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *hdw, int enable_flag)
{
int ret;
@@ -1757,7 +1910,7 @@ int pvr2_hdw_cpufw_get_enabled(struct pvr2_hdw *hdw)
int pvr2_hdw_cpufw_get(struct pvr2_hdw *hdw,unsigned int offs,
- char *buf,unsigned int cnt)
+ char *buf,unsigned int cnt)
{
int ret = -EINVAL;
LOCK_TAKE(hdw->big_lock); do {
@@ -1853,31 +2006,33 @@ static void pvr2_ctl_timeout(unsigned long data)
}
-int pvr2_send_request(struct pvr2_hdw *hdw,
- void *write_data,unsigned int write_len,
- void *read_data,unsigned int read_len)
+int pvr2_send_request_ex(struct pvr2_hdw *hdw,
+ unsigned int timeout,int probe_fl,
+ void *write_data,unsigned int write_len,
+ void *read_data,unsigned int read_len)
{
unsigned int idx;
- int status;
+ int status = 0;
struct timer_list timer;
if (!hdw->ctl_lock_held) {
pvr2_trace(PVR2_TRACE_ERROR_LEGS,
"Attempted to execute control transfer"
" without lock!!");
- status = -EINVAL;
- goto done;
+ return -EDEADLK;
}
- if (!hdw->flag_ok) {
+ if ((!hdw->flag_ok) && !probe_fl) {
pvr2_trace(PVR2_TRACE_ERROR_LEGS,
"Attempted to execute control transfer"
" when device not ok");
return -EIO;
}
if (!(hdw->ctl_read_urb && hdw->ctl_write_urb)) {
- pvr2_trace(PVR2_TRACE_ERROR_LEGS,
- "Attempted to execute control transfer"
- " when USB is disconnected");
- return -EIO;
+ if (!probe_fl) {
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "Attempted to execute control transfer"
+ " when USB is disconnected");
+ }
+ return -ENOTTY;
}
/* Ensure that we have sane parameters */
@@ -1921,7 +2076,7 @@ int pvr2_send_request(struct pvr2_hdw *hdw,
hdw->ctl_write_pend_flag = 0;
hdw->ctl_read_pend_flag = 0;
init_timer(&timer);
- timer.expires = jiffies + HZ*4;
+ timer.expires = jiffies + timeout;
timer.data = (unsigned long)hdw;
timer.function = pvr2_ctl_timeout;
@@ -1952,6 +2107,7 @@ int pvr2_send_request(struct pvr2_hdw *hdw,
"Failed to submit write-control"
" URB status=%d",status);
hdw->ctl_write_pend_flag = 0;
+ goto done;
}
}
@@ -1978,6 +2134,7 @@ int pvr2_send_request(struct pvr2_hdw *hdw,
"Failed to submit read-control"
" URB status=%d",status);
hdw->ctl_read_pend_flag = 0;
+ goto done;
}
}
@@ -1999,6 +2156,10 @@ int pvr2_send_request(struct pvr2_hdw *hdw,
if (hdw->ctl_timeout_flag) {
status = -ETIMEDOUT;
+ if (!probe_fl) {
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "Timed out control-write");
+ }
goto done;
}
@@ -2011,19 +2172,24 @@ int pvr2_send_request(struct pvr2_hdw *hdw,
/* USB subsystem is reporting some kind of failure
on the write */
status = hdw->ctl_write_urb->status;
- pvr2_trace(PVR2_TRACE_ERROR_LEGS,
- "control-write URB failure, status=%d",
- status);
+ if (!probe_fl) {
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "control-write URB failure,"
+ " status=%d",
+ status);
+ }
goto done;
}
if (hdw->ctl_write_urb->actual_length < write_len) {
/* Failed to write enough data */
status = -EIO;
- pvr2_trace(PVR2_TRACE_ERROR_LEGS,
- "control-write URB short,"
- " expected=%d got=%d",
- write_len,
- hdw->ctl_write_urb->actual_length);
+ if (!probe_fl) {
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "control-write URB short,"
+ " expected=%d got=%d",
+ write_len,
+ hdw->ctl_write_urb->actual_length);
+ }
goto done;
}
}
@@ -2036,18 +2202,24 @@ int pvr2_send_request(struct pvr2_hdw *hdw,
/* USB subsystem is reporting some kind of failure
on the read */
status = hdw->ctl_read_urb->status;
- pvr2_trace(PVR2_TRACE_ERROR_LEGS,
- "control-read URB failure, status=%d",
- status);
+ if (!probe_fl) {
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "control-read URB failure,"
+ " status=%d",
+ status);
+ }
goto done;
}
if (hdw->ctl_read_urb->actual_length < read_len) {
/* Failed to read enough data */
status = -EIO;
- pvr2_trace(PVR2_TRACE_ERROR_LEGS,
- "control-read URB short,"
- " expected=%d got=%d",
- read_len,hdw->ctl_read_urb->actual_length);
+ if (!probe_fl) {
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "control-read URB short,"
+ " expected=%d got=%d",
+ read_len,
+ hdw->ctl_read_urb->actual_length);
+ }
goto done;
}
/* Transfer retrieved data out from internal buffer */
@@ -2059,13 +2231,22 @@ int pvr2_send_request(struct pvr2_hdw *hdw,
done:
hdw->cmd_debug_state = 0;
- if (status < 0) {
+ if ((status < 0) && (!probe_fl)) {
pvr2_hdw_render_useless_unlocked(hdw);
}
return status;
}
+int pvr2_send_request(struct pvr2_hdw *hdw,
+ void *write_data,unsigned int write_len,
+ void *read_data,unsigned int read_len)
+{
+ return pvr2_send_request_ex(hdw,HZ*4,0,
+ write_data,write_len,
+ read_data,read_len);
+}
+
int pvr2_write_register(struct pvr2_hdw *hdw, u16 reg, u32 data)
{
int ret;
@@ -2177,6 +2358,13 @@ void pvr2_hdw_device_reset(struct pvr2_hdw *hdw)
pvr2_trace(PVR2_TRACE_ERROR_LEGS,
"Failed to lock USB device ret=%d",ret);
}
+ if (init_pause_msec) {
+ pvr2_trace(PVR2_TRACE_INFO,
+ "Waiting %u msec for hardware to settle",
+ init_pause_msec);
+ msleep(init_pause_msec);
+ }
+
}
@@ -2247,7 +2435,7 @@ int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl)
void pvr2_hdw_get_debug_info(const struct pvr2_hdw *hdw,
- struct pvr2_hdw_debug_info *ptr)
+ struct pvr2_hdw_debug_info *ptr)
{
ptr->big_lock_held = hdw->big_lock_held;
ptr->ctl_lock_held = hdw->ctl_lock_held;
@@ -2327,6 +2515,21 @@ int pvr2_hdw_gpio_chg_out(struct pvr2_hdw *hdw,u32 msk,u32 val)
}
+int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
+{
+ int result;
+ LOCK_TAKE(hdw->ctl_lock); do {
+ hdw->cmd_buffer[0] = 0xeb;
+ result = pvr2_send_request(hdw,
+ hdw->cmd_buffer,1,
+ hdw->cmd_buffer,1);
+ if (result < 0) break;
+ result = hdw->cmd_buffer[0];
+ } while(0); LOCK_GIVE(hdw->ctl_lock);
+ return result;
+}
+
+
/*
Stuff for Emacs to see, in order to encourage consistent editing style:
*** Local Variables: ***
diff --git a/v4l_experimental/pvrusb2/pvrusb2-hdw.h b/linux/drivers/media/video/pvrusb2/pvrusb2-hdw.h
index d813d07d4..667c95a27 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-hdw.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-hdw.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-hdw.h,v 1.6 2006/01/14 21:11:17 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
@@ -145,7 +145,7 @@
#define PVR2_SUBSYS_ENC_RUN (1 << 4)
#define PVR2_SUBSYS_CFG_ALL ( \
- PVR2_SUBSYS_ENC_FIRMWARE | \
+ PVR2_SUBSYS_ENC_FIRMWARE | \
PVR2_SUBSYS_ENC_CFG )
#define PVR2_SUBSYS_RUN_ALL ( \
PVR2_SUBSYS_DIGITIZER_RUN | \
@@ -168,7 +168,8 @@ struct pvr2_hdw;
/* Create and return a structure for interacting with the underlying
hardware */
-struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf);
+struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
+ const struct usb_device_id *devid);
/* Poll for background activity (if any) */
void pvr2_hdw_poll(struct pvr2_hdw *);
@@ -235,7 +236,7 @@ const char *pvr2_hdw_get_ctl_name(struct pvr2_hdw *,unsigned int ctl_id);
/* Retrieve string name for a given control value (returns a null pointer
for any invalid combinations). */
const char *pvr2_hdw_get_ctl_value_name(struct pvr2_hdw *,
- unsigned int ctl_id,int value);
+ unsigned int ctl_id,int value);
/* Commit all control changes made up to this point */
int pvr2_hdw_commit_ctl(struct pvr2_hdw *);
@@ -269,7 +270,7 @@ struct pvr2_stream *pvr2_hdw_get_video_stream(struct pvr2_hdw *);
identified by bit positions within msk, and new state for each item is
identified by corresponding bit positions within val. */
void pvr2_hdw_subsys_bit_chg(struct pvr2_hdw *hdw,
- unsigned long msk,unsigned long val);
+ unsigned long msk,unsigned long val);
/* Shortcut for pvr2_hdw_subsys_bit_chg(hdw,msk,msk) */
void pvr2_hdw_subsys_bit_set(struct pvr2_hdw *hdw,unsigned long msk);
@@ -284,7 +285,7 @@ unsigned long pvr2_hdw_subsys_get(struct pvr2_hdw *);
/* Adjust mask of what get shut down when streaming is stopped. This is a
debugging aid. */
void pvr2_hdw_subsys_stream_bit_chg(struct pvr2_hdw *hdw,
- unsigned long msk,unsigned long val);
+ unsigned long msk,unsigned long val);
/* Retrieve mask indicating which pieces of hardware are disabled when
streaming is turned off. */
@@ -304,7 +305,7 @@ int pvr2_hdw_cpufw_get_enabled(struct pvr2_hdw *);
value is the number of bytes retrieved or zero if we're past the end or
an error otherwise (e.g. if firmware retrieval is not enabled). */
int pvr2_hdw_cpufw_get(struct pvr2_hdw *,unsigned int offs,
- char *buf,unsigned int cnt);
+ char *buf,unsigned int cnt);
/* Retrieve previously stored v4l minor device number */
int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *);
@@ -322,8 +323,17 @@ void pvr2_reset_ctl_endpoints(struct pvr2_hdw *hdw);
/* Issue a command and get a response from the device. LOTS of higher
level stuff is built on this. */
-int pvr2_send_request(struct pvr2_hdw *, void *, unsigned int,
- void *, unsigned int);
+int pvr2_send_request(struct pvr2_hdw *,
+ void *write_ptr,unsigned int write_len,
+ void *read_ptr,unsigned int read_len);
+
+/* Issue a command and get a response from the device. This extended
+ version includes a probe flag (which if set means that device errors
+ should not be logged or treated as fatal) and a timeout in jiffies.
+ This can be used to non-lethally probe the health of endpoint 1. */
+int pvr2_send_request_ex(struct pvr2_hdw *,unsigned int timeout,int probe_fl,
+ void *write_ptr,unsigned int write_len,
+ void *read_ptr,unsigned int read_len);
/* Slightly higher level device communication functions. */
int pvr2_write_register(struct pvr2_hdw *, u16, u32);
@@ -353,6 +363,9 @@ int pvr2_hdw_cmd_soft_reset(struct pvr2_hdw *);
/* Stop / start video stream transport */
int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl);
+/* Find I2C address of eeprom */
+int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *);
+
/* Direct manipulation of GPIO bits */
int pvr2_hdw_gpio_get_dir(struct pvr2_hdw *hdw,u32 *);
int pvr2_hdw_gpio_get_out(struct pvr2_hdw *hdw,u32 *);
@@ -385,13 +398,18 @@ struct pvr2_hdw_debug_info {
kind of locking and so it is not atomic and may yield inconsistent
results. This is *purely* a debugging aid. */
void pvr2_hdw_get_debug_info(const struct pvr2_hdw *hdw,
- struct pvr2_hdw_debug_info *);
+ struct pvr2_hdw_debug_info *);
+
+/* Cause modules to log their state once */
+void pvr2_hdw_trigger_module_log(struct pvr2_hdw *hdw);
/* Cause encoder firmware to be uploaded into the device. This is normally
done autonomously, but the interface is exported here because it is also
a debugging aid. */
int pvr2_upload_firmware2(struct pvr2_hdw *hdw);
+/* List of device types that we can match */
+extern struct usb_device_id pvr2_device_table[];
#endif /* __PVRUSB2_HDW_H */
diff --git a/v4l_experimental/pvrusb2/pvrusb2-i2c-chips-v4l2.c b/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
index ff8d38063..2d97653d5 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-i2c-chips-v4l2.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-i2c-chips-v4l2.c,v 1.3 2006/01/22 03:55:03 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
@@ -37,6 +37,7 @@
#define OP_FREQ 3
#define OP_AUDIORATE 4
#define OP_SIZE 5
+#define OP_LOG 6
static const struct pvr2_i2c_op * const ops[] = {
[OP_STANDARD] = &pvr2_i2c_op_v4l2_standard,
@@ -44,6 +45,7 @@ static const struct pvr2_i2c_op * const ops[] = {
[OP_VOLUME] = &pvr2_i2c_op_v4l2_volume,
[OP_FREQ] = &pvr2_i2c_op_v4l2_frequency,
[OP_SIZE] = &pvr2_i2c_op_v4l2_size,
+ [OP_LOG] = &pvr2_i2c_op_v4l2_log,
};
void pvr2_i2c_probe(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
@@ -54,7 +56,8 @@ void pvr2_i2c_probe(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
(1 << OP_BCSH) |
(1 << OP_VOLUME) |
(1 << OP_FREQ) |
- (1 << OP_SIZE));
+ (1 << OP_SIZE) |
+ (1 << OP_LOG));
if (id == I2C_DRIVERID_MSP3400) {
if (pvr2_i2c_msp3400_setup(hdw,cp)) {
diff --git a/v4l_experimental/pvrusb2/pvrusb2-i2c-cmd-v4l2.c b/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c
index 92f2dfa6a..69864782b 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-i2c-cmd-v4l2.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-i2c-cmd-v4l2.c,v 1.1 2006/01/01 08:26:03 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
* Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
@@ -218,6 +218,27 @@ const struct pvr2_i2c_op pvr2_i2c_op_v4l2_size = {
};
+static void do_log(struct pvr2_hdw *hdw)
+{
+ pvr2_trace(PVR2_TRACE_CHIPS,"i2c v4l2 do_log()");
+ pvr2_i2c_core_cmd(hdw,VIDIOC_LOG_STATUS,0);
+
+}
+
+
+static int check_log(struct pvr2_hdw *hdw)
+{
+ return hdw->log_requested != 0;
+}
+
+
+const struct pvr2_i2c_op pvr2_i2c_op_v4l2_log = {
+ .check = check_log,
+ .update = do_log,
+ .name = "v4l2_log",
+};
+
+
/*
Stuff for Emacs to see, in order to encourage consistent editing style:
*** Local Variables: ***
diff --git a/v4l_experimental/pvrusb2/pvrusb2-i2c-cmd-v4l2.h b/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.h
index 8c3945e93..fa0a3af7e 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-i2c-cmd-v4l2.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-i2c-cmd-v4l2.h,v 1.1 2006/01/01 08:26:03 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
* Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
@@ -31,6 +31,7 @@ extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_bcsh;
extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_volume;
extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_frequency;
extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_size;
+extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_log;
#endif /* __PVRUSB2_CMD_V4L2_H */
diff --git a/v4l_experimental/pvrusb2/pvrusb2-i2c-core.c b/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
index b45463a2d..8ec637e5e 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-i2c-core.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-i2c-core.c,v 1.5 2006/01/23 06:58:06 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
@@ -39,19 +39,26 @@ module_param(i2c_scan, int, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */
- u8 i2c_addr, /* I2C address we're talking to */
- u8 *data, /* Data to write */
- u16 length) /* Size of data to write */
+ u8 i2c_addr, /* I2C address we're talking to */
+ u8 *data, /* Data to write */
+ u16 length) /* Size of data to write */
{
/* Return value - default 0 means success */
int ret;
-#ifdef notdef
+#if 0
trace_i2c("pvr2_i2c_write");
#endif
if (!data) length = 0;
- if (length > (sizeof(hdw->cmd_buffer) - 3)) return -ENOTSUPP;
+ if (length > (sizeof(hdw->cmd_buffer) - 3)) {
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "Killing an I2C write to %u that is too large"
+ " (desired=%u limit=%u)",
+ i2c_addr,
+ length,(sizeof(hdw->cmd_buffer) - 3));
+ return -ENOTSUPP;
+ }
LOCK_TAKE(hdw->ctl_lock);
@@ -80,7 +87,7 @@ static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */
}
}
}
-#ifdef notdef
+#if 0
trace_i2c("i2c_write(%d) len=%d ret=%d stat=%d",i2c_addr,length,ret,
hdw->cmd_buffer[0]);
#endif
@@ -91,16 +98,16 @@ static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */
}
static int pvr2_i2c_read(struct pvr2_hdw *hdw, /* Context */
- u8 i2c_addr, /* I2C address we're talking to */
- u8 *data, /* Data to write */
- u16 dlen, /* Size of data to write */
- u8 *res, /* Where to put data we read */
- u16 rlen) /* Amount of data to read */
+ u8 i2c_addr, /* I2C address we're talking to */
+ u8 *data, /* Data to write */
+ u16 dlen, /* Size of data to write */
+ u8 *res, /* Where to put data we read */
+ u16 rlen) /* Amount of data to read */
{
/* Return value - default 0 means success */
int ret;
-#ifdef notdef
+#if 0
trace_i2c("pvr2_i2c_read");
#endif
@@ -138,7 +145,7 @@ static int pvr2_i2c_read(struct pvr2_hdw *hdw, /* Context */
}
}
-#ifdef notdef
+#if 0
trace_i2c("i2c_read(%d) wlen=%d rlen=%d ret=%d stat=%d",
i2c_addr,dlen,rlen,ret,hdw->cmd_buffer[0]);
#endif
@@ -160,8 +167,8 @@ static int pvr2_i2c_read(struct pvr2_hdw *hdw, /* Context */
/* This is a very, very limited I2C adapter implementation. We can only
support what we actually know will work on the device... */
static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
- struct i2c_msg msgs[],
- int num)
+ struct i2c_msg msgs[],
+ int num)
{
int ret = -ENOTSUPP;
struct pvr2_hdw *hdw = (struct pvr2_hdw *)(i2c_adap->algo_data);
@@ -282,14 +289,14 @@ static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
}
static int pvr2_i2c_control(struct i2c_adapter *adapter,
- unsigned int cmd, unsigned long arg)
+ unsigned int cmd, unsigned long arg)
{
return 0;
}
static u32 pvr2_i2c_functionality(struct i2c_adapter *adap)
{
- return I2C_FUNC_SMBUS_EMUL;
+ return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C;
}
static int pvr2_i2c_core_singleton(struct i2c_client *cp,
@@ -692,7 +699,7 @@ static int pvr2_i2c_detach_inform(struct i2c_client *client)
static struct i2c_algorithm pvr2_i2c_algo_template = {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
- .id = I2C_ALGO_BIT | I2C_HW_B_BT848,
+ .id = I2C_HW_B_BT848,
#endif
.master_xfer = pvr2_i2c_xfer,
.algo_control = pvr2_i2c_control,
@@ -702,11 +709,7 @@ static struct i2c_algorithm pvr2_i2c_algo_template = {
static struct i2c_adapter pvr2_i2c_adap_template = {
.owner = THIS_MODULE,
.class = I2C_CLASS_TV_ANALOG,
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
- .id = I2C_ALGO_BIT | I2C_HW_B_BT848,
-#else
.id = I2C_HW_B_BT848,
-#endif
.client_register = pvr2_i2c_attach_inform,
.client_unregister = pvr2_i2c_detach_inform,
};
diff --git a/v4l_experimental/pvrusb2/pvrusb2-i2c-core.h b/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.h
index 3e8f71962..e8af5b0ed 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-i2c-core.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-i2c-core.h,v 1.1 2006/01/01 08:26:03 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
diff --git a/v4l_experimental/pvrusb2/pvrusb2-io.c b/linux/drivers/media/video/pvrusb2/pvrusb2-io.c
index d53c63785..a6bc3befe 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-io.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-io.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-io.c,v 1.3 2006/01/23 06:58:06 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
@@ -36,7 +36,7 @@
// #define SANITY_CHECK_BUFFERS
-#ifdef notdef
+#if 0
#define BUFFER_CHECK(bp) do { \
if ((bp)->signature != BUFFER_SIG) { \
pvr2_trace(PVR2_TRACE_ERROR_LEGS, \
@@ -44,7 +44,7 @@
(bp),__FILE__,__LINE__); \
pvr2_buffer_describe(bp,"BadSig"); \
BUG(); \
- } \
+ } \
} while (0)
#endif
@@ -56,7 +56,7 @@
(bp),__FILE__,__LINE__); \
pvr2_buffer_describe(bp,"BadSig"); \
BUG(); \
- } \
+ } \
} while (0)
#else
#define BUFFER_CHECK(bp) do {} while(0)
@@ -278,8 +278,8 @@ static void pvr2_buffer_wipe(struct pvr2_buffer *bp)
}
static int pvr2_buffer_init(struct pvr2_buffer *bp,
- struct pvr2_stream *sp,
- unsigned int id)
+ struct pvr2_stream *sp,
+ unsigned int id)
{
memset(bp,0,sizeof(*bp));
bp->signature = BUFFER_SIG;
@@ -508,8 +508,8 @@ void pvr2_stream_destroy(struct pvr2_stream *sp)
}
void pvr2_stream_setup(struct pvr2_stream *sp,
- struct usb_device *dev,
- int endpoint,
+ struct usb_device *dev,
+ int endpoint,
unsigned int tolerance)
{
mutex_lock(&sp->mutex); do {
@@ -521,8 +521,8 @@ void pvr2_stream_setup(struct pvr2_stream *sp,
}
void pvr2_stream_set_callback(struct pvr2_stream *sp,
- pvr2_stream_callback func,
- void *data)
+ pvr2_stream_callback func,
+ void *data)
{
unsigned long irq_flags;
mutex_lock(&sp->mutex); do {
diff --git a/v4l_experimental/pvrusb2/pvrusb2-io.h b/linux/drivers/media/video/pvrusb2/pvrusb2-io.h
index 5dc72b1ef..65e11385b 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-io.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-io.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-io.h,v 1.2 2006/01/09 06:54:46 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
@@ -42,11 +42,11 @@ const char *pvr2_buffer_state_decode(enum pvr2_buffer_state);
struct pvr2_stream *pvr2_stream_create(void);
void pvr2_stream_destroy(struct pvr2_stream *);
void pvr2_stream_setup(struct pvr2_stream *,
- struct usb_device *dev,int endpoint,
+ struct usb_device *dev,int endpoint,
unsigned int tolerance);
void pvr2_stream_set_callback(struct pvr2_stream *,
- pvr2_stream_callback func,
- void *data);
+ pvr2_stream_callback func,
+ void *data);
/* Query / set the nominal buffer count */
int pvr2_stream_get_buffer_count(struct pvr2_stream *);
diff --git a/v4l_experimental/pvrusb2/pvrusb2-ioread.c b/linux/drivers/media/video/pvrusb2/pvrusb2-ioread.c
index 375dd8acb..4182d75b7 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-ioread.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-ioread.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-ioread.c,v 1.2 2006/01/23 06:58:06 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
diff --git a/v4l_experimental/pvrusb2/pvrusb2-ioread.h b/linux/drivers/media/video/pvrusb2/pvrusb2-ioread.h
index ec2a23325..e6205f123 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-ioread.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-ioread.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-ioread.h,v 1.1 2005/11/14 13:31:24 mchehab Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
diff --git a/v4l_experimental/pvrusb2/pvrusb2-main.c b/linux/drivers/media/video/pvrusb2/pvrusb2-main.c
index 72b5132e6..c554671af 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-main.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-main.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-main.c,v 1.7 2006/01/22 03:51:19 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
* Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
@@ -62,11 +62,6 @@ MODULE_PARM_DESC(debug, "Debug trace mask");
static struct pvr2_sysfs_class *class_ptr = 0;
-static struct usb_device_id pvr_table[] = {
- { USB_DEVICE(0x2040, 0x2900) },
- { }
-};
-
static void pvr_setup_attach(struct pvr2_context *pvr)
{
/* Create association with v4l layer */
@@ -80,7 +75,7 @@ static int pvr_probe(struct usb_interface *intf,
struct pvr2_context *pvr;
/* Create underlying hardware interface */
- pvr = pvr2_context_create(intf,pvr_setup_attach);
+ pvr = pvr2_context_create(intf,devid,pvr_setup_attach);
if (!pvr) {
pvr2_trace(PVR2_TRACE_ERROR_LEGS,
"Failed to create hdw handler");
@@ -116,7 +111,7 @@ static struct usb_driver pvr_driver = {
owner: THIS_MODULE,
#endif
name: "pvrusb2",
- id_table: pvr_table,
+ id_table: pvr2_device_table,
probe: pvr_probe,
disconnect: pvr_disconnect
};
@@ -166,7 +161,11 @@ static void __exit pvr_exit(void)
module_init(pvr_init);
module_exit(pvr_exit);
-MODULE_DEVICE_TABLE (usb, pvr_table);
+/* Mike Isely <mcisely@pobox.com> 11-Mar-2006: See pvrusb2-hdw.c for
+ MODULE_DEVICE_TABLE(). We have to declare that attribute there
+ because that's where the device table actually is now and it seems
+ that certain gcc configurations get angry if MODULE_DEVICE_TABLE()
+ is used on what ends up being an external symbol. */
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");
diff --git a/v4l_experimental/pvrusb2/pvrusb2-sysfs.c b/linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
index 7d17ee749..a9710b52c 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-sysfs.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-sysfs.c,v 1.2 2006/01/22 03:51:19 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
@@ -196,7 +196,7 @@ static ssize_t show_enum(int id,struct class_device *class_dev,char *buf)
}
static int store_val_any(int id,struct pvr2_sysfs *sfp,
- const char *buf,unsigned int count)
+ const char *buf,unsigned int count)
{
int val,minval,maxval;
int ch,ret;
@@ -293,7 +293,7 @@ static int store_val_any(int id,struct pvr2_sysfs *sfp,
}
static int store_val_multi(int id,struct pvr2_sysfs *sfp,
- const char *buf,unsigned int count)
+ const char *buf,unsigned int count)
{
unsigned int count2;
int ret;
@@ -311,7 +311,7 @@ static int store_val_multi(int id,struct pvr2_sysfs *sfp,
}
static ssize_t store_val_int(int id,struct class_device *class_dev,
- const char *buf,size_t count)
+ const char *buf,size_t count)
{
struct pvr2_sysfs *sfp;
int ret;
@@ -322,7 +322,7 @@ static ssize_t store_val_int(int id,struct class_device *class_dev,
}
static ssize_t store_val_enum(int id,struct class_device *class_dev,
- const char *buf,size_t count)
+ const char *buf,size_t count)
{
struct pvr2_sysfs *sfp;
int ret;
@@ -646,7 +646,7 @@ static ssize_t unit_number_show(struct class_device *class_dev,char *buf)
static void class_dev_create(struct pvr2_sysfs *sfp,
- struct pvr2_sysfs_class *class_ptr)
+ struct pvr2_sysfs_class *class_ptr)
{
struct usb_device *usb_dev;
struct class_device *class_dev;
@@ -707,7 +707,7 @@ static void pvr2_sysfs_internal_check(struct pvr2_channel *chp)
struct pvr2_sysfs *pvr2_sysfs_create(struct pvr2_context *mp,
- struct pvr2_sysfs_class *class_ptr)
+ struct pvr2_sysfs_class *class_ptr)
{
struct pvr2_sysfs *sfp;
sfp = kmalloc(sizeof(*sfp),GFP_KERNEL);
@@ -723,7 +723,7 @@ struct pvr2_sysfs *pvr2_sysfs_create(struct pvr2_context *mp,
static int pvr2_sysfs_hotplug(struct class_device *cd,char **envp,
- int numenvp,char *buf,int size)
+ int numenvp,char *buf,int size)
{
/* Even though we don't do anything here, we still need this function
because sysfs will still try to call it. */
@@ -766,6 +766,7 @@ static ssize_t debuginfo_show(struct class_device *class_dev,char *buf)
struct pvr2_sysfs *sfp;
sfp = (struct pvr2_sysfs *)class_dev->class_data;
if (!sfp) return -EINVAL;
+ pvr2_hdw_trigger_module_log(sfp->channel.hdw);
return pvr2_debugifc_print_info(sfp->channel.hdw,buf,PAGE_SIZE);
}
@@ -780,7 +781,7 @@ static ssize_t debugcmd_show(struct class_device *class_dev,char *buf)
static ssize_t debugcmd_store(struct class_device *class_dev,
- const char *buf,size_t count)
+ const char *buf,size_t count)
{
struct pvr2_sysfs *sfp;
int ret;
diff --git a/v4l_experimental/pvrusb2/pvrusb2-sysfs.h b/linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.h
index 20dcc3256..ff9373b47 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-sysfs.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-sysfs.h,v 1.1 2005/11/14 13:31:24 mchehab Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
@@ -32,7 +32,7 @@ struct pvr2_sysfs_class *pvr2_sysfs_class_create(void);
void pvr2_sysfs_class_destroy(struct pvr2_sysfs_class *);
struct pvr2_sysfs *pvr2_sysfs_create(struct pvr2_context *,
- struct pvr2_sysfs_class *);
+ struct pvr2_sysfs_class *);
#endif /* __PVRUSB2_SYSFS_H */
diff --git a/v4l_experimental/pvrusb2/pvrusb2-tuner.c b/linux/drivers/media/video/pvrusb2/pvrusb2-tuner.c
index 4a6f99177..f829c0acc 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-tuner.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-tuner.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-tuner.c,v 1.12 2006/01/22 03:48:34 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
* Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
diff --git a/v4l_experimental/pvrusb2/pvrusb2-tuner.h b/linux/drivers/media/video/pvrusb2/pvrusb2-tuner.h
index 83d92d06d..556f12aa9 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-tuner.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-tuner.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-tuner.h,v 1.2 2006/01/01 08:26:03 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
diff --git a/v4l_experimental/pvrusb2/pvrusb2-util.h b/linux/drivers/media/video/pvrusb2/pvrusb2-util.h
index e8c2cc940..e53aee416 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-util.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-util.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-util.h,v 1.1 2005/11/14 13:31:24 mchehab Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
@@ -23,18 +23,18 @@
#define PVR2_DECOMPOSE_LE(t,i,d) \
do { \
- (t)[i] = (d) & 0xff;\
- (t)[i+1] = ((d) >> 8) & 0xff;\
- (t)[i+2] = ((d) >> 16) & 0xff;\
- (t)[i+3] = ((d) >> 24) & 0xff;\
+ (t)[i] = (d) & 0xff;\
+ (t)[i+1] = ((d) >> 8) & 0xff;\
+ (t)[i+2] = ((d) >> 16) & 0xff;\
+ (t)[i+3] = ((d) >> 24) & 0xff;\
} while(0)
#define PVR2_DECOMPOSE_BE(t,i,d) \
do { \
- (t)[i+3] = (d) & 0xff;\
- (t)[i+2] = ((d) >> 8) & 0xff;\
- (t)[i+1] = ((d) >> 16) & 0xff;\
- (t)[i] = ((d) >> 24) & 0xff;\
+ (t)[i+3] = (d) & 0xff;\
+ (t)[i+2] = ((d) >> 8) & 0xff;\
+ (t)[i+1] = ((d) >> 16) & 0xff;\
+ (t)[i] = ((d) >> 24) & 0xff;\
} while(0)
#define PVR2_COMPOSE_LE(t,i) \
diff --git a/v4l_experimental/pvrusb2/pvrusb2-v4l2.c b/linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 0a78a6646..017d30ad0 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-v4l2.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-v4l2.c,v 1.9 2006/01/23 06:58:06 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
* Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
@@ -124,7 +124,7 @@ static struct v4l2_tuner pvr_v4l2_tuners[]= {
.afc = 0,
.reserved = {0,0,0,0}
}
-#ifdef notdef
+#if 0
{
.index = 1,
.name = "Radio Tuner",
@@ -306,7 +306,7 @@ static int cnv_cid_v4l2_pvr2(int id)
return -1;
}
-#ifdef notdef
+#if 0
static int cnv_cid_pvr2_v4l2(int id)
{
switch (id) {
@@ -342,7 +342,7 @@ static int cnv_cid_pvr2_v4l2(int id)
*
*/
static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, void *arg)
+ unsigned int cmd, void *arg)
{
struct pvr2_v4l2_fh *fh = file->private_data;
struct pvr2_v4l2 *vp = fh->vhead;
@@ -839,6 +839,12 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
break;
}
+ case VIDIOC_LOG_STATUS:
+ {
+ pvr2_hdw_trigger_module_log(hdw);
+ break;
+ }
+
default :
ret = v4l_compat_translate_ioctl(inode,file,cmd,
arg,pvr2_v4l2_do_ioctl);
@@ -871,8 +877,8 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
{
pvr2_trace(PVR2_TRACE_INIT,
- "Unregistering v4l video device (%s, minor=%d)",
- pvr2_config_get_name(dip->config),dip->vdev->minor);
+ "unregistering device video%d [%s]",
+ dip->vdev->minor,pvr2_config_get_name(dip->config));
video_unregister_device(dip->vdev);
}
@@ -899,7 +905,7 @@ void pvr2_v4l2_internal_check(struct pvr2_channel *chp)
int pvr2_v4l2_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+ unsigned int cmd, unsigned long arg)
{
/* Temporary hack : use ivtv api until a v4l2 one is available. */
@@ -1047,7 +1053,7 @@ static int pvr2_v4l2_iosetup(struct pvr2_v4l2_fh *fh)
static ssize_t pvr2_v4l2_read(struct file *file,
- char __user *buff, size_t count, loff_t *ppos)
+ char __user *buff, size_t count, loff_t *ppos)
{
struct pvr2_v4l2_fh *fh = file->private_data;
int ret;
@@ -1159,10 +1165,10 @@ static struct video_device vdev_template = {
static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
- struct pvr2_v4l2 *vp,
- enum pvr2_config cfg)
+ struct pvr2_v4l2 *vp,
+ enum pvr2_config cfg)
{
-#ifdef notdef
+#if 0
struct usb_device *usbdev;
#endif
int mindevnum;
@@ -1171,7 +1177,7 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
dip->v4lp = vp;
dip->config = cfg;
-#ifdef notdef
+#if 0
usbdev = pvr2_hdw_get_dev(vp->channel.mc_head->hdw);
#endif
@@ -1206,7 +1212,7 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
}
memcpy(dip->vdev,&vdev_template,sizeof(vdev_template));
-#ifdef notdef
+#if 0
/* ????? This relation may be problematic on a disconnect. Is this
really needed? I can't seem to find a reason for it. This
can't be a required thing - what if the video device being set
@@ -1226,8 +1232,8 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
err("Failed to register pvrusb2 v4l video device");
} else {
pvr2_trace(PVR2_TRACE_INIT,
- "Registered pvrusb2 v4l device, minor=%d",
- dip->vdev->minor);
+ "registered device video%d [%s]",
+ dip->vdev->minor,pvr2_config_get_name(dip->config));
}
pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
dip->vdev->minor);
diff --git a/v4l_experimental/pvrusb2/pvrusb2-v4l2.h b/linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.h
index 9dd446469..9a995e2d2 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-v4l2.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-v4l2.h,v 1.1 2005/11/14 13:31:24 mchehab Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
diff --git a/v4l_experimental/pvrusb2/pvrusb2-video-v4l.c b/linux/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c
index f4948a7a7..d0bc3682b 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-video-v4l.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-video-v4l.c,v 1.10 2006/01/22 03:48:34 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
* Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
@@ -131,7 +131,7 @@ static int decoder_check(struct pvr2_v4l_decoder *ctxt)
unsigned long msk;
unsigned int idx;
- for (idx = 0; idx < sizeof(decoder_ops)/sizeof(decoder_ops[0]);
+ for (idx = 0; idx < sizeof(decoder_ops)/sizeof(decoder_ops[0]);
idx++) {
msk = 1 << idx;
if (ctxt->stale_mask & msk) continue;
@@ -148,7 +148,7 @@ static void decoder_update(struct pvr2_v4l_decoder *ctxt)
unsigned long msk;
unsigned int idx;
- for (idx = 0; idx < sizeof(decoder_ops)/sizeof(decoder_ops[0]);
+ for (idx = 0; idx < sizeof(decoder_ops)/sizeof(decoder_ops[0]);
idx++) {
msk = 1 << idx;
if (!(ctxt->stale_mask & msk)) continue;
diff --git a/v4l_experimental/pvrusb2/pvrusb2-video-v4l.h b/linux/drivers/media/video/pvrusb2/pvrusb2-video-v4l.h
index b47e64791..1c0c98efb 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-video-v4l.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-video-v4l.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-video-v4l.h,v 1.3 2006/01/14 19:09:50 mcisely Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
* Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
diff --git a/v4l_experimental/pvrusb2/pvrusb2.h b/linux/drivers/media/video/pvrusb2/pvrusb2.h
index f4e99ad3b..074533e9c 100644
--- a/v4l_experimental/pvrusb2/pvrusb2.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2.h,v 1.1 2005/11/14 13:31:24 mchehab Exp $
+ * $Id$
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
* Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
diff --git a/linux/drivers/media/video/saa7115.c b/linux/drivers/media/video/saa7115.c
index aa3600ad9..4cb8a1c63 100644
--- a/linux/drivers/media/video/saa7115.c
+++ b/linux/drivers/media/video/saa7115.c
@@ -1,4 +1,4 @@
-/* saa7115 - Philips SAA7114/SAA7115 video decoder driver
+/* saa7115 - Philips SAA7113/SAA7114/SAA7115 video decoder driver
*
* Based on saa7114 driver by Maxim Yevtyushkin, which is based on
* the saa7111 driver by Dave Perks.
@@ -16,6 +16,7 @@
* (2/17/2003)
*
* VBI support (2004) and cleanups (2005) by Hans Verkuil <hverkuil@xs4all.nl>
+ * SAA7113 support by Mauro Carvalho Chehab <mchehab@infradead.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -46,8 +47,9 @@
#endif
#include <asm/div64.h>
-MODULE_DESCRIPTION("Philips SAA7114/SAA7115 video decoder driver");
-MODULE_AUTHOR("Maxim Yevtyushkin, Kevin Thayer, Chris Kennedy, Hans Verkuil");
+MODULE_DESCRIPTION("Philips SAA7113/SAA7114/SAA7115 video decoder driver");
+MODULE_AUTHOR( "Maxim Yevtyushkin, Kevin Thayer, Chris Kennedy, "
+ "Hans Verkuil, Mauro Carvalho Chehab");
MODULE_LICENSE("GPL");
static int debug = 0;
@@ -59,7 +61,10 @@ MODULE_PARM(debug, "i");
MODULE_PARM_DESC(debug, "Debug level (0-1)");
-static unsigned short normal_i2c[] = { 0x42 >> 1, 0x40 >> 1, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = {
+ 0x4a >>1, 0x48 >>1, /* SAA7113 */
+ 0x42 >> 1, 0x40 >> 1, /* SAA7114 and SAA7115 */
+ I2C_CLIENT_END };
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
@@ -112,10 +117,12 @@ static inline int saa7115_read(struct i2c_client *client, u8 reg)
Hauppauge driver sets. */
static const unsigned char saa7115_init_auto_input[] = {
+ /* Front-End Part */
0x01, 0x48, /* white peak control disabled */
0x03, 0x20, /* was 0x30. 0x20: long vertical blanking */
0x04, 0x90, /* analog gain set to 0 */
0x05, 0x90, /* analog gain set to 0 */
+ /* Decoder Part */
0x06, 0xeb, /* horiz sync begin = -21 */
0x07, 0xe0, /* horiz sync stop = -17 */
0x0a, 0x80, /* was 0x88. decoder brightness, 0x80 is itu standard */
@@ -134,6 +141,8 @@ static const unsigned char saa7115_init_auto_input[] = {
0x1b, 0x42, /* misc chroma control 0x42 = recommended */
0x1c, 0xa9, /* combfilter control 0xA9 = recommended */
0x1d, 0x01, /* combfilter control 0x01 = recommended */
+
+ /* Power Device Control */
0x88, 0xd0, /* reset device */
0x88, 0xf0, /* set device programmed, all in operational mode */
0x00, 0x00
@@ -349,6 +358,35 @@ static const unsigned char saa7115_cfg_vbi_off[] = {
0x00, 0x00
};
+#if 1 /* saa7113 init codes */
+static const unsigned char saa7113_init_auto_input[] = {
+ 0x01, 0x08, /* PH7113_INCREMENT_DELAY - (1) (1) (1) (1) IDEL3 IDEL2 IDELL1 IDEL0 */
+ 0x02, 0xc2, /* PH7113_ANALOG_INPUT_CONTR_1 - FUSE1 FUSE0 GUDL1 GUDL0 MODE3 MODE2 MODE1 MODE0 */
+ 0x03, 0x30, /* PH7113_ANALOG_INPUT_CONTR_2 - (1) HLNRS VBSL WPOFF HOLDG GAFIX GAI28 GAI18 */
+ 0x04, 0x00, /* PH7113_ANALOG_INPUT_CONTR_3 - GAI17 GAI16 GAI15 GAI14 GAI13 GAI12 GAI11 GAI10 */
+ 0x05, 0x00, /* PH7113_ANALOG_INPUT_CONTR_4 - GAI27 GAI26 GAI25 GAI24 GAI23 GAI22 GAI21 GAI20 */
+ 0x06, 0x89, /* PH7113_HORIZONTAL_SYNC_START - HSB7 HSB6 HSB5 HSB4 HSB3 HSB2 HSB1 HSB0 */
+ 0x07, 0x0d, /* PH7113_HORIZONTAL_SYNC_STOP - HSS7 HSS6 HSS5 HSS4 HSS3 HSS2 HSS1 HSS0 */
+ 0x08, 0x88, /* PH7113_SYNC_CONTROL - AUFD FSEL FOET HTC1 HTC0 HPLL VNOI1 VNOI0 */
+ 0x09, 0x01, /* PH7113_LUMINANCE_CONTROL - BYPS PREF BPSS1 BPSS0 VBLB UPTCV APER1 APER0 */
+ 0x0a, 0x80, /* PH7113_LUMINANCE_BRIGHTNESS - BRIG7 BRIG6 BRIG5 BRIG4 BRIG3 BRIG2 BRIG1 BRIG0 */
+ 0x0b, 0x47, /* PH7113_LUMINANCE_CONTRAST - CONT7 CONT6 CONT5 CONT4 CONT3 CONT2 CONT1 CONT0 */
+ 0x0c, 0x40, /* PH7113_CHROMA_SATURATION - SATN7 SATN6 SATN5 SATN4 SATN3 SATN2 SATN1 SATN0 */
+ 0x0d, 0x00, /* PH7113_CHROMA_HUE_CONTROL - HUEC7 HUEC6 HUEC5 HUEC4 HUEC3 HUEC2 HUEC1 HUEC0 */
+ 0x0e, 0x01, /* PH7113_CHROMA_CONTROL - CDTO CSTD2 CSTD1 CSTD0 DCCF FCTC CHBW1 CHBW0 */
+ 0x0f, 0x2a, /* PH7113_CHROMA_GAIN_CONTROL - ACGC CGAIN6 CGAIN5 CGAIN4 CGAIN3 CGAIN2 CGAIN1 CGAIN0 */
+ 0x10, 0x08, /* PH7113_FORMAT_DELAY_CONTROL - OFTS1 OFTS0 HDEL1 HDEL0 VRLN YDEL2 YDEL1 YDEL0 */
+ 0x11, 0x0c, /* PH7113_OUTPUT_CONTROL_1 - GPSW1 CM99 GPSW0 HLSEL OEYC OERT VIPB COLO */
+ 0x12, 0x07, /* PH7113_OUTPUT_CONTROL_2 - RTSE13 RTSE12 RTSE11 RTSE10 RTSE03 RTSE02 RTSE01 RTSE00 */
+ 0x13, 0x00, /* PH7113_OUTPUT_CONTROL_3 - ADLSB (1) (1) OLDSB FIDP (1) AOSL1 AOSL0 */
+ 0x14, 0x00, /* RESERVED 14 - (1) (1) (1) (1) (1) (1) (1) (1) */
+ 0x15, 0x00, /* PH7113_V_GATE1_START - VSTA7 VSTA6 VSTA5 VSTA4 VSTA3 VSTA2 VSTA1 VSTA0 */
+ 0x16, 0x00, /* PH7113_V_GATE1_STOP - VSTO7 VSTO6 VSTO5 VSTO4 VSTO3 VSTO2 VSTO1 VSTO0 */
+ 0x17, 0x00, /* PH7113_V_GATE1_MSB - (1) (1) (1) (1) (1) (1) VSTO8 VSTA8 */
+ 0x00, 0x00
+};
+#endif
+
static const unsigned char saa7115_init_misc[] = {
0x38, 0x03, /* audio stuff */
0x39, 0x10,
@@ -688,10 +726,39 @@ static void saa7115_set_v4lstd(struct i2c_client *client, v4l2_std_id std)
saa7115_writeregs(client, saa7115_cfg_50hz_video);
}
+ /* Register 0E - Bits D6-D4 on NO-AUTO mode
+ (SAA7113 doesn't have auto mode)
+ 50 Hz / 625 lines 60 Hz / 525 lines
+ 000 PAL BGDHI (4.43Mhz) NTSC M (3.58MHz)
+ 001 NTSC 4.43 (50 Hz) PAL 4.43 (60 Hz)
+ 010 Combination-PAL N (3.58MHz) NTSC 4.43 (60 Hz)
+ 011 NTSC N (3.58MHz) PAL M (3.58MHz)
+ 100 reserved NTSC-Japan (3.58MHz)
+ */
+ if (state->ident == V4L2_IDENT_SAA7113) {
+ u8 reg = saa7115_read(client, 0x0e) & 0x8f;
+
+ if (std & V4L2_STD_PAL) {
+ if (std == V4L2_STD_PAL_M) {
+ reg|=0x30;
+ } else if (std == V4L2_STD_PAL_N) {
+ reg|=0x20;
+ } else if (std == V4L2_STD_PAL_60) {
+ reg|=0x10;
+ }
+ } else if (std & V4L2_STD_NTSC) {
+ if (std == V4L2_STD_NTSC_M_JP) {
+ reg|=0x40;
+ }
+ }
+ saa7115_write(client, 0x0e, reg);
+ }
+
+
state->std = std;
/* restart task B if needed */
- if (taskb && state->ident == V4L2_IDENT_SAA7114) {
+ if (taskb && state->ident != V4L2_IDENT_SAA7115) {
saa7115_writeregs(client, saa7115_cfg_vbi_on);
}
@@ -714,7 +781,7 @@ static void saa7115_log_status(struct i2c_client *client)
int vcr;
v4l_info(client, "Audio frequency: %d Hz\n", state->audclk_freq);
- if (client->name[6] == '4') {
+ if (state->ident != V4L2_IDENT_SAA7115) {
/* status for the saa7114 */
reg1f = saa7115_read(client, 0x1f);
signalOk = (reg1f & 0xc1) == 0x81;
@@ -762,8 +829,8 @@ static void saa7115_set_lcr(struct i2c_client *client, struct v4l2_sliced_vbi_fo
u8 lcr[24];
int i, x;
- /* saa7114 doesn't yet support VBI */
- if (state->ident == V4L2_IDENT_SAA7114)
+ /* saa7113/71144 doesn't yet support VBI */
+ if (state->ident != V4L2_IDENT_SAA7115)
return;
for (i = 0; i <= 23; i++)
@@ -1280,14 +1347,12 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
saa7115_write(client, 0, 5);
chip_id = saa7115_read(client, 0) & 0x0f;
- if (chip_id != 4 && chip_id != 5) {
+ if (chip_id <3 && chip_id > 5) {
v4l_dbg(1, debug, client, "saa7115 not found\n");
kfree(client);
return 0;
}
- if (chip_id == 4) {
- snprintf(client->name, sizeof(client->name) - 1, "saa7114");
- }
+ snprintf(client->name, sizeof(client->name) - 1, "saa711%d",chip_id);
v4l_info(client, "saa711%d found @ 0x%x (%s)\n", chip_id, address << 1, adapter->name);
state = kzalloc(sizeof(struct saa7115_state), GFP_KERNEL);
@@ -1304,13 +1369,27 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
state->contrast = 64;
state->hue = 0;
state->sat = 64;
- state->ident = (chip_id == 4) ? V4L2_IDENT_SAA7114 : V4L2_IDENT_SAA7115;
+ switch (chip_id) {
+ case 3:
+ state->ident = V4L2_IDENT_SAA7113;
+ break;
+ case 4:
+ state->ident = V4L2_IDENT_SAA7114;
+ break;
+ default:
+ state->ident = V4L2_IDENT_SAA7115;
+ break;
+ }
+
state->audclk_freq = 48000;
v4l_dbg(1, debug, client, "writing init values\n");
/* init to 60hz/48khz */
- saa7115_writeregs(client, saa7115_init_auto_input);
+ if (state->ident==V4L2_IDENT_SAA7113)
+ saa7115_writeregs(client, saa7113_init_auto_input);
+ else
+ saa7115_writeregs(client, saa7115_init_auto_input);
saa7115_writeregs(client, saa7115_init_misc);
saa7115_writeregs(client, saa7115_cfg_60hz_fullres_x);
saa7115_writeregs(client, saa7115_cfg_60hz_fullres_y);
diff --git a/linux/drivers/media/video/saa7134/saa7134-alsa.c b/linux/drivers/media/video/saa7134/saa7134-alsa.c
index 5f1f32ecb..393a3a3bd 100644
--- a/linux/drivers/media/video/saa7134/saa7134-alsa.c
+++ b/linux/drivers/media/video/saa7134/saa7134-alsa.c
@@ -320,8 +320,7 @@ static int dsp_buffer_init(struct saa7134_dev *dev)
static int dsp_buffer_free(struct saa7134_dev *dev)
{
- if (!dev->dmasound.blksize)
- BUG();
+ BUG_ON(!dev->dmasound.blksize);
videobuf_dma_free(&dev->dmasound.dma);
@@ -519,7 +518,7 @@ static int snd_card_saa7134_hw_params(snd_pcm_substream_t * substream,
/* release the old buffer */
if (substream->runtime->dma_area) {
saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
- videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma);
+ videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
dsp_buffer_free(dev);
substream->runtime->dma_area = NULL;
}
@@ -535,12 +534,12 @@ static int snd_card_saa7134_hw_params(snd_pcm_substream_t * substream,
return err;
}
- if (0 != (err = videobuf_dma_pci_map(dev->pci, &dev->dmasound.dma))) {
+ if (0 != (err = videobuf_pci_dma_map(dev->pci, &dev->dmasound.dma))) {
dsp_buffer_free(dev);
return err;
}
if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt))) {
- videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma);
+ videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
dsp_buffer_free(dev);
return err;
}
@@ -549,7 +548,7 @@ static int snd_card_saa7134_hw_params(snd_pcm_substream_t * substream,
dev->dmasound.dma.sglen,
0))) {
saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
- videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma);
+ videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
dsp_buffer_free(dev);
return err;
}
@@ -583,7 +582,7 @@ static int snd_card_saa7134_hw_free(snd_pcm_substream_t * substream)
if (substream->runtime->dma_area) {
saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
- videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma);
+ videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
dsp_buffer_free(dev);
substream->runtime->dma_area = NULL;
}
diff --git a/linux/drivers/media/video/saa7134/saa7134-cards.c b/linux/drivers/media/video/saa7134/saa7134-cards.c
index fb804441d..45eef4148 100644
--- a/linux/drivers/media/video/saa7134/saa7134-cards.c
+++ b/linux/drivers/media/video/saa7134/saa7134-cards.c
@@ -538,7 +538,7 @@ struct saa7134_board saa7134_boards[] = {
.radio = {
.name = name_radio,
.amux = LINE2,
- },
+ },
},
[SAA7134_BOARD_MD7134] = {
.name = "Medion 7134",
@@ -2030,7 +2030,7 @@ struct saa7134_board saa7134_boards[] = {
[SAA7134_BOARD_FLYTV_DIGIMATRIX] = {
.name = "FlyTV mini Asus Digimatrix",
.audio_clock = 0x00200000,
- .tuner_type = TUNER_LG_NTSC_TALN_MINI,
+ .tuner_type = TUNER_LG_TALN,
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
@@ -2708,7 +2708,7 @@ struct saa7134_board saa7134_boards[] = {
}},
},
[SAA7134_BOARD_TEVION_DVBT_220RF] = {
- .name = "Tevion DVB-T 220RF",
+ .name = "Tevion/KWorld DVB-T 220RF",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_TDA8290,
.radio_type = UNSET,
@@ -2758,6 +2758,97 @@ struct saa7134_board saa7134_boards[] = {
.amux = LINE2,
}},
},
+ [SAA7134_BOARD_AVERMEDIA_A169_B] = {
+ /* AVerMedia A169 */
+ /* Rickard Osser <ricky@osser.se> */
+ /* This card has two saa7134 chips on it,
+ but only one of them is currently working. */
+ .name = "AVerMedia A169 B",
+ .audio_clock = 0x02187de7,
+ .tuner_type = TUNER_LG_TALN,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .gpiomask = 0x0a60000,
+#if 0
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 4,
+ .amux = TV,
+ .tv = 1,
+ .gpio = 0x00a68300,
+ },{
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE1,
+ },{
+ .name = name_comp2, /* Composite SVIDEO (B/W if signal is carried with SVIDEO) */
+ .vmux = 1,
+ .amux = LINE1,
+ },{
+ .name = name_svideo,
+ .vmux = 9, /* 9 is correct as S-VIDEO according to a169.inf! */
+ .amux = LINE1,
+ }},
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ .gpio = 0x00a68300,
+ },
+#endif
+ },
+ [SAA7134_BOARD_AVERMEDIA_A169_B1] = {
+ /* AVerMedia A169 */
+ /* Rickard Osser <ricky@osser.se> */
+ .name = "AVerMedia A169 B1",
+ .audio_clock = 0x02187de7,
+ .tuner_type = TUNER_LG_TALN,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .gpiomask = 0xca60000,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 4,
+ .amux = TV,
+ .tv = 1,
+ .gpio = 0x04a61000,
+#if 0
+ },{
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE1,
+#endif
+ },{
+ .name = name_comp2, /* Composite SVIDEO (B/W if signal is carried with SVIDEO) */
+ .vmux = 1,
+ .amux = LINE2,
+ },{
+ .name = name_svideo,
+ .vmux = 9, /* 9 is correct as S-VIDEO1 according to a169.inf! */
+ .amux = LINE1,
+ }},
+#if 0
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ .gpio = 0x0ca61000,
+ },
+#endif
+ },
+ [SAA7134_BOARD_MD7134_BRIDGE_2] = {
+ /* This card has two saa7134 chips on it,
+ but only one of them is currently working.
+ The programming for the primary decoder is
+ in SAA7134_BOARD_MD7134 */
+ .name = "Medion 7134 Bridge #2",
+ .audio_clock = 0x00187de7,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ },
};
const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
@@ -3265,6 +3356,24 @@ struct pci_device_id saa7134_pci_tbl[] = {
.subdevice = 0x7350,
.driver_data = SAA7134_BOARD_KWORLD_ATSC110,
},{
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
+ .subvendor = 0x1461,
+ .subdevice = 0x7360,
+ .driver_data = SAA7134_BOARD_AVERMEDIA_A169_B,
+ },{
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
+ .subvendor = 0x1461,
+ .subdevice = 0x6360,
+ .driver_data = SAA7134_BOARD_AVERMEDIA_A169_B1,
+ },{
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
+ .subvendor = 0x16be,
+ .subdevice = 0x0005,
+ .driver_data = SAA7134_BOARD_MD7134_BRIDGE_2,
+ },{
/* --- boards without eeprom + subsystem ID --- */
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
@@ -3407,9 +3516,9 @@ int saa7134_board_init1(struct saa7134_dev *dev)
break;
case SAA7134_BOARD_MD5044:
printk("%s: seems there are two different versions of the MD5044\n"
- "%s: (with the same ID) out there. If sound doesn't work for\n"
- "%s: you try the audio_clock_override=0x200000 insmod option.\n",
- dev->name,dev->name,dev->name);
+ "%s: (with the same ID) out there. If sound doesn't work for\n"
+ "%s: you try the audio_clock_override=0x200000 insmod option.\n",
+ dev->name,dev->name,dev->name);
break;
case SAA7134_BOARD_CINERGY400_CARDBUS:
/* power-up tuner chip */
@@ -3456,6 +3565,13 @@ int saa7134_board_init1(struct saa7134_dev *dev)
case SAA7134_BOARD_UPMOST_PURPLE_TV:
dev->has_remote = SAA7134_REMOTE_I2C;
break;
+ case SAA7134_BOARD_AVERMEDIA_A169_B:
+ case SAA7134_BOARD_MD7134_BRIDGE_2:
+ printk("%s: %s: dual saa713x broadcast decoders\n"
+ "%s: Sorry, none of the inputs to this chip are supported yet.\n"
+ "%s: Dual decoder functionality is disabled for now, use the other chip.\n",
+ dev->name,card(dev).name,dev->name,dev->name);
+ break;
}
return 0;
}
diff --git a/linux/drivers/media/video/saa7134/saa7134-core.c b/linux/drivers/media/video/saa7134/saa7134-core.c
index e23c6a42d..25bcf1830 100644
--- a/linux/drivers/media/video/saa7134/saa7134-core.c
+++ b/linux/drivers/media/video/saa7134/saa7134-core.c
@@ -70,6 +70,11 @@ static unsigned int latency = UNSET;
module_param(latency, int, 0444);
MODULE_PARM_DESC(latency,"pci latency timer");
+static int no_overlay=-1;
+module_param(no_overlay, int, 0444);
+MODULE_PARM_DESC(no_overlay,"allow override overlay default (0 disables, 1 enables)"
+ " [some VIA/SIS chipsets are known to have problem with overlay]");
+
static unsigned int video_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
static unsigned int vbi_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
static unsigned int radio_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
@@ -314,13 +319,12 @@ void saa7134_pgtable_free(struct pci_dev *pci, struct saa7134_pgtable *pt)
/* ------------------------------------------------------------------ */
-void saa7134_dma_free(struct saa7134_dev *dev,struct saa7134_buf *buf)
+void saa7134_dma_free(struct videobuf_queue *q,struct saa7134_buf *buf)
{
- if (in_interrupt())
- BUG();
+ BUG_ON(in_interrupt());
videobuf_waiton(&buf->vb,0,0);
- videobuf_dma_pci_unmap(dev->pci, &buf->vb.dma);
+ videobuf_dma_unmap(q, &buf->vb.dma);
videobuf_dma_free(&buf->vb.dma);
buf->vb.state = STATE_NEEDS_INIT;
}
@@ -906,6 +910,22 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
latency = 0x0A;
}
#endif
+ if (pci_pci_problems & PCIPCI_FAIL) {
+ printk(KERN_INFO "%s: quirk: this driver and your "
+ "chipset may not work together"
+ " in overlay mode.\n",dev->name);
+ if (!no_overlay) {
+ printk(KERN_INFO "%s: quirk: overlay "
+ "mode will be disabled.\n",
+ dev->name);
+ no_overlay = 1;
+ } else {
+ printk(KERN_INFO "%s: quirk: overlay "
+ "mode will be forced. Use this"
+ " option at your own risk.\n",
+ dev->name);
+ }
+ }
}
if (UNSET != latency) {
printk(KERN_INFO "%s: setting pci latency timer to %d\n",
diff --git a/linux/drivers/media/video/saa7134/saa7134-oss.c b/linux/drivers/media/video/saa7134/saa7134-oss.c
index 742692ab2..a88f8b5bb 100644
--- a/linux/drivers/media/video/saa7134/saa7134-oss.c
+++ b/linux/drivers/media/video/saa7134/saa7134-oss.c
@@ -103,8 +103,7 @@ static int dsp_buffer_init(struct saa7134_dev *dev)
{
int err;
- if (!dev->dmasound.bufsize)
- BUG();
+ BUG_ON(!dev->dmasound.bufsize);
videobuf_dma_init(&dev->dmasound.dma);
err = videobuf_dma_init_kernel(&dev->dmasound.dma, PCI_DMA_FROMDEVICE,
(dev->dmasound.bufsize + PAGE_SIZE) >> PAGE_SHIFT);
@@ -115,8 +114,7 @@ static int dsp_buffer_init(struct saa7134_dev *dev)
static int dsp_buffer_free(struct saa7134_dev *dev)
{
- if (!dev->dmasound.blksize)
- BUG();
+ BUG_ON(!dev->dmasound.blksize);
videobuf_dma_free(&dev->dmasound.dma);
dev->dmasound.blocks = 0;
dev->dmasound.blksize = 0;
@@ -145,7 +143,7 @@ static int dsp_rec_start(struct saa7134_dev *dev)
unsigned long flags;
/* prepare buffer */
- if (0 != (err = videobuf_dma_pci_map(dev->pci,&dev->dmasound.dma)))
+ if (0 != (err = videobuf_pci_dma_map(dev->pci,&dev->dmasound.dma)))
return err;
if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt)))
goto fail1;
@@ -234,7 +232,7 @@ static int dsp_rec_start(struct saa7134_dev *dev)
fail2:
saa7134_pgtable_free(dev->pci,&dev->dmasound.pt);
fail1:
- videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma);
+ videobuf_pci_dma_unmap(dev->pci,&dev->dmasound.dma);
return err;
}
@@ -252,7 +250,7 @@ static int dsp_rec_stop(struct saa7134_dev *dev)
/* unlock buffer */
saa7134_pgtable_free(dev->pci,&dev->dmasound.pt);
- videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma);
+ videobuf_pci_dma_unmap(dev->pci,&dev->dmasound.dma);
return 0;
}
diff --git a/linux/drivers/media/video/saa7134/saa7134-ts.c b/linux/drivers/media/video/saa7134/saa7134-ts.c
index fdb2d9261..1f9c2fe98 100644
--- a/linux/drivers/media/video/saa7134/saa7134-ts.c
+++ b/linux/drivers/media/video/saa7134/saa7134-ts.c
@@ -91,7 +91,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
return -EINVAL;
if (buf->vb.size != size) {
- saa7134_dma_free(dev,buf);
+ saa7134_dma_free(q,buf);
}
if (STATE_NEEDS_INIT == buf->vb.state) {
@@ -100,7 +100,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
buf->vb.size = size;
buf->pt = &dev->ts.pt_ts;
- err = videobuf_iolock(dev->pci,&buf->vb,NULL);
+ err = videobuf_iolock(q,&buf->vb,NULL);
if (err)
goto oops;
err = saa7134_pgtable_build(dev->pci,buf->pt,
@@ -128,7 +128,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
return 0;
oops:
- saa7134_dma_free(dev,buf);
+ saa7134_dma_free(q,buf);
return err;
}
@@ -154,10 +154,9 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
{
- struct saa7134_dev *dev = q->priv_data;
struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
- saa7134_dma_free(dev,buf);
+ saa7134_dma_free(q,buf);
}
struct videobuf_queue_ops saa7134_ts_qops = {
diff --git a/linux/drivers/media/video/saa7134/saa7134-vbi.c b/linux/drivers/media/video/saa7134/saa7134-vbi.c
index 125a6c838..44909bd1f 100644
--- a/linux/drivers/media/video/saa7134/saa7134-vbi.c
+++ b/linux/drivers/media/video/saa7134/saa7134-vbi.c
@@ -143,7 +143,7 @@ static int buffer_prepare(struct videobuf_queue *q,
return -EINVAL;
if (buf->vb.size != size)
- saa7134_dma_free(dev,buf);
+ saa7134_dma_free(q,buf);
if (STATE_NEEDS_INIT == buf->vb.state) {
buf->vb.width = llength;
@@ -151,7 +151,7 @@ static int buffer_prepare(struct videobuf_queue *q,
buf->vb.size = size;
buf->pt = &fh->pt_vbi;
- err = videobuf_iolock(dev->pci,&buf->vb,NULL);
+ err = videobuf_iolock(q,&buf->vb,NULL);
if (err)
goto oops;
err = saa7134_pgtable_build(dev->pci,buf->pt,
@@ -167,7 +167,7 @@ static int buffer_prepare(struct videobuf_queue *q,
return 0;
oops:
- saa7134_dma_free(dev,buf);
+ saa7134_dma_free(q,buf);
return err;
}
@@ -204,11 +204,9 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
{
- struct saa7134_fh *fh = q->priv_data;
- struct saa7134_dev *dev = fh->dev;
struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
- saa7134_dma_free(dev,buf);
+ saa7134_dma_free(q,buf);
}
struct videobuf_queue_ops saa7134_vbi_qops = {
diff --git a/linux/drivers/media/video/saa7134/saa7134-video.c b/linux/drivers/media/video/saa7134/saa7134-video.c
index daab08493..8ab71eeb1 100644
--- a/linux/drivers/media/video/saa7134/saa7134-video.c
+++ b/linux/drivers/media/video/saa7134/saa7134-video.c
@@ -493,8 +493,7 @@ int res_locked(struct saa7134_dev *dev, unsigned int bit)
static
void res_free(struct saa7134_dev *dev, struct saa7134_fh *fh, unsigned int bits)
{
- if ((fh->resources & bits) != bits)
- BUG();
+ BUG_ON((fh->resources & bits) != bits);
mutex_lock(&dev->lock);
fh->resources &= ~bits;
@@ -998,7 +997,7 @@ static int buffer_prepare(struct videobuf_queue *q,
buf->vb.size != size ||
buf->vb.field != field ||
buf->fmt != fh->fmt) {
- saa7134_dma_free(dev,buf);
+ saa7134_dma_free(q,buf);
}
if (STATE_NEEDS_INIT == buf->vb.state) {
@@ -1009,7 +1008,7 @@ static int buffer_prepare(struct videobuf_queue *q,
buf->fmt = fh->fmt;
buf->pt = &fh->pt_cap;
- err = videobuf_iolock(dev->pci,&buf->vb,&dev->ovbuf);
+ err = videobuf_iolock(q,&buf->vb,&dev->ovbuf);
if (err)
goto oops;
err = saa7134_pgtable_build(dev->pci,buf->pt,
@@ -1024,7 +1023,7 @@ static int buffer_prepare(struct videobuf_queue *q,
return 0;
oops:
- saa7134_dma_free(dev,buf);
+ saa7134_dma_free(q,buf);
return err;
}
@@ -1050,10 +1049,9 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
{
- struct saa7134_fh *fh = q->priv_data;
struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
- saa7134_dma_free(fh->dev,buf);
+ saa7134_dma_free(q,buf);
}
static struct videobuf_queue_ops video_qops = {
diff --git a/linux/drivers/media/video/saa7134/saa7134.h b/linux/drivers/media/video/saa7134/saa7134.h
index b72306e59..5cfd9a777 100644
--- a/linux/drivers/media/video/saa7134/saa7134.h
+++ b/linux/drivers/media/video/saa7134/saa7134.h
@@ -228,6 +228,9 @@ struct saa7134_format {
#define SAA7134_BOARD_TEVION_DVBT_220RF 88
#define SAA7134_BOARD_ELSA_700TV 89
#define SAA7134_BOARD_KWORLD_ATSC110 90
+#define SAA7134_BOARD_AVERMEDIA_A169_B 91
+#define SAA7134_BOARD_AVERMEDIA_A169_B1 92
+#define SAA7134_BOARD_MD7134_BRIDGE_2 93
#define SAA7134_MAXBOARDS 8
#define SAA7134_INPUT_MAX 8
@@ -597,7 +600,7 @@ void saa7134_buffer_finish(struct saa7134_dev *dev, struct saa7134_dmaqueue *q,
unsigned int state);
void saa7134_buffer_next(struct saa7134_dev *dev, struct saa7134_dmaqueue *q);
void saa7134_buffer_timeout(unsigned long data);
-void saa7134_dma_free(struct saa7134_dev *dev,struct saa7134_buf *buf);
+void saa7134_dma_free(struct videobuf_queue *q,struct saa7134_buf *buf);
int saa7134_set_dmabits(struct saa7134_dev *dev);
diff --git a/linux/drivers/media/video/tda9840.c b/linux/drivers/media/video/tda9840.c
new file mode 100644
index 000000000..9cc13ec8e
--- /dev/null
+++ b/linux/drivers/media/video/tda9840.c
@@ -0,0 +1,263 @@
+ /*
+ tda9840 - i2c-driver for the tda9840 by SGS Thomson
+
+ Copyright (C) 1998-2003 Michael Hunold <michael@mihu.de>
+
+ The tda9840 is a stereo/dual sound processor with digital
+ identification. It can be found at address 0x84 on the i2c-bus.
+
+ For detailed informations download the specifications directly
+ from SGS Thomson at http://www.st.com
+
+ 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 "compat.h"
+
+#include <linux/module.h>
+#include <linux/ioctl.h>
+#include <linux/i2c.h>
+
+#include "tda9840.h"
+
+static int debug = 0; /* insmod parameter */
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
+#define dprintk(args...) \
+ do { if (debug) { printk("%s: %s()[%d]: ",__stringify(KBUILD_MODNAME), __FUNCTION__, __LINE__); printk(args); } } while (0)
+
+#define SWITCH 0x00
+#define LEVEL_ADJUST 0x02
+#define STEREO_ADJUST 0x03
+#define TEST 0x04
+
+/* addresses to scan, found only at 0x42 (7-Bit) */
+static unsigned short normal_i2c[] = { I2C_TDA9840, I2C_CLIENT_END };
+
+/* magic definition of all other variables and things */
+I2C_CLIENT_INSMOD;
+
+static struct i2c_driver driver;
+static struct i2c_client client_template;
+
+static int command(struct i2c_client *client, unsigned int cmd, void *arg)
+{
+ int result;
+ int byte = *(int *)arg;
+
+ switch (cmd) {
+ case TDA9840_SWITCH:
+
+ dprintk("TDA9840_SWITCH: 0x%02x\n", byte);
+
+ if (byte != TDA9840_SET_MONO
+ && byte != TDA9840_SET_MUTE
+ && byte != TDA9840_SET_STEREO
+ && byte != TDA9840_SET_LANG1
+ && byte != TDA9840_SET_LANG2
+ && byte != TDA9840_SET_BOTH
+ && byte != TDA9840_SET_BOTH_R
+ && byte != TDA9840_SET_EXTERNAL) {
+ return -EINVAL;
+ }
+
+ result = i2c_smbus_write_byte_data(client, SWITCH, byte);
+ if (result)
+ dprintk("i2c_smbus_write_byte() failed, ret:%d\n", result);
+ break;
+
+ case TDA9840_LEVEL_ADJUST:
+
+ dprintk("TDA9840_LEVEL_ADJUST: %d\n", byte);
+
+ /* check for correct range */
+ if (byte > 25 || byte < -20)
+ return -EINVAL;
+
+ /* calculate actual value to set, see specs, page 18 */
+ byte /= 5;
+ if (0 < byte)
+ byte += 0x8;
+ else
+ byte = -byte;
+
+ result = i2c_smbus_write_byte_data(client, LEVEL_ADJUST, byte);
+ if (result)
+ dprintk("i2c_smbus_write_byte() failed, ret:%d\n", result);
+ break;
+
+ case TDA9840_STEREO_ADJUST:
+
+ dprintk("TDA9840_STEREO_ADJUST: %d\n", byte);
+
+ /* check for correct range */
+ if (byte > 25 || byte < -24)
+ return -EINVAL;
+
+ /* calculate actual value to set */
+ byte /= 5;
+ if (0 < byte)
+ byte += 0x20;
+ else
+ byte = -byte;
+
+ result = i2c_smbus_write_byte_data(client, STEREO_ADJUST, byte);
+ if (result)
+ dprintk("i2c_smbus_write_byte() failed, ret:%d\n", result);
+ break;
+
+ case TDA9840_DETECT: {
+ int *ret = (int *)arg;
+
+ byte = i2c_smbus_read_byte_data(client, STEREO_ADJUST);
+ if (byte == -1) {
+ dprintk("i2c_smbus_read_byte_data() failed\n");
+ return -EIO;
+ }
+
+ if (0 != (byte & 0x80)) {
+ dprintk("TDA9840_DETECT: register contents invalid\n");
+ return -EINVAL;
+ }
+
+ dprintk("TDA9840_DETECT: byte: 0x%02x\n", byte);
+ *ret = ((byte & 0x60) >> 5);
+ result = 0;
+ break;
+ }
+ case TDA9840_TEST:
+ dprintk("TDA9840_TEST: 0x%02x\n", byte);
+
+ /* mask out irrelevant bits */
+ byte &= 0x3;
+
+ result = i2c_smbus_write_byte_data(client, TEST, byte);
+ if (result)
+ dprintk("i2c_smbus_write_byte() failed, ret:%d\n", result);
+ break;
+ default:
+ return -ENOIOCTLCMD;
+ }
+
+ if (result)
+ return -EIO;
+
+ return 0;
+}
+
+static int detect(struct i2c_adapter *adapter, int address, int kind)
+{
+ struct i2c_client *client;
+ int result = 0;
+
+ int byte = 0x0;
+
+ /* let's see whether this adapter can support what we need */
+ if (0 == i2c_check_functionality(adapter,
+ I2C_FUNC_SMBUS_READ_BYTE_DATA |
+ I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) {
+ return 0;
+ }
+
+ /* allocate memory for client structure */
+ client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
+ if (0 == client) {
+ printk("not enough kernel memory\n");
+ return -ENOMEM;
+ }
+
+ /* fill client structure */
+ memcpy(client, &client_template, sizeof(struct i2c_client));
+ client->addr = address;
+ client->adapter = adapter;
+
+ /* tell the i2c layer a new client has arrived */
+ if (0 != (result = i2c_attach_client(client))) {
+ kfree(client);
+ return result;
+ }
+
+ /* set initial values for level & stereo - adjustment, mode */
+ byte = 0;
+ result = command(client, TDA9840_LEVEL_ADJUST, &byte);
+ result += command(client, TDA9840_STEREO_ADJUST, &byte);
+ byte = TDA9840_SET_MONO;
+ result = command(client, TDA9840_SWITCH, &byte);
+ if (result) {
+ dprintk("could not initialize tda9840\n");
+ return -ENODEV;
+ }
+
+ printk("tda9840: detected @ 0x%02x on adapter %s\n", address, &client->adapter->name[0]);
+ return 0;
+}
+
+static int attach(struct i2c_adapter *adapter)
+{
+ /* let's see whether this is a know adapter we can attach to */
+ if (adapter->id != I2C_HW_SAA7146) {
+ dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id);
+ return -ENODEV;
+ }
+
+ return i2c_probe(adapter, &addr_data, &detect);
+}
+
+static int detach(struct i2c_client *client)
+{
+ int ret = i2c_detach_client(client);
+ kfree(client);
+ return ret;
+}
+
+static struct i2c_driver driver = {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) &&(LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15))
+ .owner = THIS_MODULE,
+#endif
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15)
+ .name = "tda9840",
+ .flags = I2C_DF_NOTIFY,
+#else
+ .driver = {
+ .name = "tda9840",
+ },
+#endif
+ .id = I2C_DRIVERID_TDA9840,
+ .attach_adapter = attach,
+ .detach_client = detach,
+ .command = command,
+};
+
+static struct i2c_client client_template = {
+ .name = "tda9840",
+ .driver = &driver,
+};
+
+static int __init this_module_init(void)
+{
+ return i2c_add_driver(&driver);
+}
+
+static void __exit this_module_exit(void)
+{
+ i2c_del_driver(&driver);
+}
+
+module_init(this_module_init);
+module_exit(this_module_exit);
+
+MODULE_AUTHOR("Michael Hunold <michael@mihu.de>");
+MODULE_DESCRIPTION("tda9840 driver");
+MODULE_LICENSE("GPL");
diff --git a/linux/drivers/media/video/tda9840.h b/linux/drivers/media/video/tda9840.h
new file mode 100644
index 000000000..28021053b
--- /dev/null
+++ b/linux/drivers/media/video/tda9840.h
@@ -0,0 +1,35 @@
+#ifndef __INCLUDED_TDA9840__
+#define __INCLUDED_TDA9840__
+
+#define I2C_TDA9840 0x42
+
+#define TDA9840_DETECT _IOR('v',1,int)
+/* return values for TDA9840_DETCT */
+#define TDA9840_MONO_DETECT 0x0
+#define TDA9840_DUAL_DETECT 0x1
+#define TDA9840_STEREO_DETECT 0x2
+#define TDA9840_INCORRECT_DETECT 0x3
+
+#define TDA9840_SWITCH _IOW('v',2,int)
+/* modes than can be set with TDA9840_SWITCH */
+#define TDA9840_SET_MUTE 0x00
+#define TDA9840_SET_MONO 0x10
+#define TDA9840_SET_STEREO 0x2a
+#define TDA9840_SET_LANG1 0x12
+#define TDA9840_SET_LANG2 0x1e
+#define TDA9840_SET_BOTH 0x1a
+#define TDA9840_SET_BOTH_R 0x16
+#define TDA9840_SET_EXTERNAL 0x7a
+
+/* values may range between +2.5 and -2.0;
+ the value has to be multiplied with 10 */
+#define TDA9840_LEVEL_ADJUST _IOW('v',3,int)
+
+/* values may range between +2.5 and -2.4;
+ the value has to be multiplied with 10 */
+#define TDA9840_STEREO_ADJUST _IOW('v',4,int)
+
+/* currently not implemented */
+#define TDA9840_TEST _IOW('v',5,int)
+
+#endif
diff --git a/linux/drivers/media/video/tea6415c.c b/linux/drivers/media/video/tea6415c.c
new file mode 100644
index 000000000..12e83ad21
--- /dev/null
+++ b/linux/drivers/media/video/tea6415c.c
@@ -0,0 +1,232 @@
+ /*
+ tea6415c - i2c-driver for the tea6415c by SGS Thomson
+
+ Copyright (C) 1998-2003 Michael Hunold <michael@mihu.de>
+
+ The tea6415c is a bus controlled video-matrix-switch
+ with 8 inputs and 6 outputs.
+ It is cascadable, i.e. it can be found at the addresses
+ 0x86 and 0x06 on the i2c-bus.
+
+ For detailed informations download the specifications directly
+ from SGS Thomson at http://www.st.com
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License vs 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 Mvss Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "compat.h"
+
+#include <linux/module.h>
+#include <linux/ioctl.h>
+#include <linux/i2c.h>
+
+#include "tea6415c.h"
+
+static int debug = 0; /* insmod parameter */
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
+#define dprintk(args...) \
+ do { if (debug) { printk("%s: %s()[%d]: ",__stringify(KBUILD_MODNAME), __FUNCTION__, __LINE__); printk(args); } } while (0)
+
+#define TEA6415C_NUM_INPUTS 8
+#define TEA6415C_NUM_OUTPUTS 6
+
+/* addresses to scan, found only at 0x03 and/or 0x43 (7-bit) */
+static unsigned short normal_i2c[] = { I2C_TEA6415C_1, I2C_TEA6415C_2, I2C_CLIENT_END };
+
+/* magic definition of all other variables and things */
+I2C_CLIENT_INSMOD;
+
+static struct i2c_driver driver;
+static struct i2c_client client_template;
+
+/* this function is called by i2c_probe */
+static int detect(struct i2c_adapter *adapter, int address, int kind)
+{
+ struct i2c_client *client = NULL;
+ int err = 0;
+
+ /* let's see whether this adapter can support what we need */
+ if (0 == i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE)) {
+ return 0;
+ }
+
+ /* allocate memory for client structure */
+ client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
+ if (0 == client) {
+ return -ENOMEM;
+ }
+
+ /* fill client structure */
+ memcpy(client, &client_template, sizeof(struct i2c_client));
+ client->addr = address;
+ client->adapter = adapter;
+
+ /* tell the i2c layer a new client has arrived */
+ if (0 != (err = i2c_attach_client(client))) {
+ kfree(client);
+ return err;
+ }
+
+ printk("tea6415c: detected @ 0x%02x on adapter %s\n", address, &client->adapter->name[0]);
+
+ return 0;
+}
+
+static int attach(struct i2c_adapter *adapter)
+{
+ /* let's see whether this is a know adapter we can attach to */
+ if (adapter->id != I2C_HW_SAA7146) {
+ dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id);
+ return -ENODEV;
+ }
+
+ return i2c_probe(adapter, &addr_data, &detect);
+}
+
+static int detach(struct i2c_client *client)
+{
+ int ret = i2c_detach_client(client);
+ kfree(client);
+ return ret;
+}
+
+/* makes a connection between the input-pin 'i' and the output-pin 'o'
+ for the tea6415c-client 'client' */
+static int switch_matrix(struct i2c_client *client, int i, int o)
+{
+ u8 byte = 0;
+ int ret;
+
+ dprintk("adr:0x%02x, i:%d, o:%d\n", client->addr, i, o);
+
+ /* check if the pins are valid */
+ if (0 == ((1 == i || 3 == i || 5 == i || 6 == i || 8 == i || 10 == i || 20 == i || 11 == i)
+ && (18 == o || 17 == o || 16 == o || 15 == o || 14 == o || 13 == o)))
+ return -1;
+
+ /* to understand this, have a look at the tea6415c-specs (p.5) */
+ switch (o) {
+ case 18:
+ byte = 0x00;
+ break;
+ case 14:
+ byte = 0x20;
+ break;
+ case 16:
+ byte = 0x10;
+ break;
+ case 17:
+ byte = 0x08;
+ break;
+ case 15:
+ byte = 0x18;
+ break;
+ case 13:
+ byte = 0x28;
+ break;
+ };
+
+ switch (i) {
+ case 5:
+ byte |= 0x00;
+ break;
+ case 8:
+ byte |= 0x04;
+ break;
+ case 3:
+ byte |= 0x02;
+ break;
+ case 20:
+ byte |= 0x06;
+ break;
+ case 6:
+ byte |= 0x01;
+ break;
+ case 10:
+ byte |= 0x05;
+ break;
+ case 1:
+ byte |= 0x03;
+ break;
+ case 11:
+ byte |= 0x07;
+ break;
+ };
+
+ ret = i2c_smbus_write_byte(client, byte);
+ if (ret) {
+ dprintk("i2c_smbus_write_byte() failed, ret:%d\n", ret);
+ return -EIO;
+ }
+
+ return ret;
+}
+
+static int command(struct i2c_client *client, unsigned int cmd, void *arg)
+{
+ struct tea6415c_multiplex *v = (struct tea6415c_multiplex *)arg;
+ int result = 0;
+
+ switch (cmd) {
+ case TEA6415C_SWITCH:
+ result = switch_matrix(client, v->in, v->out);
+ break;
+ default:
+ return -ENOIOCTLCMD;
+ }
+
+ return result;
+}
+
+static struct i2c_driver driver = {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) &&(LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15))
+ .owner = THIS_MODULE,
+#endif
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15)
+ .name = "tea6415c",
+ .flags = I2C_DF_NOTIFY,
+#else
+ .driver = {
+ .name = "tea6415c",
+ },
+#endif
+ .id = I2C_DRIVERID_TEA6415C,
+ .attach_adapter = attach,
+ .detach_client = detach,
+ .command = command,
+};
+
+static struct i2c_client client_template = {
+ .name = "tea6415c",
+ .driver = &driver,
+};
+
+static int __init this_module_init(void)
+{
+ return i2c_add_driver(&driver);
+}
+
+static void __exit this_module_exit(void)
+{
+ i2c_del_driver(&driver);
+}
+
+module_init(this_module_init);
+module_exit(this_module_exit);
+
+MODULE_AUTHOR("Michael Hunold <michael@mihu.de>");
+MODULE_DESCRIPTION("tea6415c driver");
+MODULE_LICENSE("GPL");
diff --git a/linux/drivers/media/video/tea6415c.h b/linux/drivers/media/video/tea6415c.h
new file mode 100644
index 000000000..f84ed8005
--- /dev/null
+++ b/linux/drivers/media/video/tea6415c.h
@@ -0,0 +1,39 @@
+#ifndef __INCLUDED_TEA6415C__
+#define __INCLUDED_TEA6415C__
+
+/* possible i2c-addresses */
+#define I2C_TEA6415C_1 0x03
+#define I2C_TEA6415C_2 0x43
+
+/* the tea6415c's design is quite brain-dead. although there are
+ 8 inputs and 6 outputs, these aren't enumerated in any way. because
+ I don't want to say "connect input pin 20 to output pin 17", I define
+ a "virtual" pin-order. */
+
+/* input pins */
+#define TEA6415C_OUTPUT1 18
+#define TEA6415C_OUTPUT2 14
+#define TEA6415C_OUTPUT3 16
+#define TEA6415C_OUTPUT4 17
+#define TEA6415C_OUTPUT5 13
+#define TEA6415C_OUTPUT6 15
+
+/* output pins */
+#define TEA6415C_INPUT1 5
+#define TEA6415C_INPUT2 8
+#define TEA6415C_INPUT3 3
+#define TEA6415C_INPUT4 20
+#define TEA6415C_INPUT5 6
+#define TEA6415C_INPUT6 10
+#define TEA6415C_INPUT7 1
+#define TEA6415C_INPUT8 11
+
+struct tea6415c_multiplex
+{
+ int in; /* input-pin */
+ int out; /* output-pin */
+};
+
+#define TEA6415C_SWITCH _IOW('v',1,struct tea6415c_multiplex)
+
+#endif
diff --git a/linux/drivers/media/video/tea6420.c b/linux/drivers/media/video/tea6420.c
new file mode 100644
index 000000000..d22eac01b
--- /dev/null
+++ b/linux/drivers/media/video/tea6420.c
@@ -0,0 +1,209 @@
+ /*
+ tea6420 - i2c-driver for the tea6420 by SGS Thomson
+
+ Copyright (C) 1998-2003 Michael Hunold <michael@mihu.de>
+
+ The tea6420 is a bus controlled audio-matrix with 5 stereo inputs,
+ 4 stereo outputs and gain control for each output.
+ It is cascadable, i.e. it can be found at the adresses 0x98
+ and 0x9a on the i2c-bus.
+
+ For detailed informations download the specifications directly
+ from SGS Thomson at http://www.st.com
+
+ 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 "compat.h"
+
+#include <linux/module.h>
+#include <linux/ioctl.h>
+#include <linux/i2c.h>
+
+#include "tea6420.h"
+
+static int debug = 0; /* insmod parameter */
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
+#define dprintk(args...) \
+ do { if (debug) { printk("%s: %s()[%d]: ",__stringify(KBUILD_MODNAME), __FUNCTION__, __LINE__); printk(args); } } while (0)
+
+/* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */
+static unsigned short normal_i2c[] = { I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END };
+
+/* magic definition of all other variables and things */
+I2C_CLIENT_INSMOD;
+
+static struct i2c_driver driver;
+static struct i2c_client client_template;
+
+/* make a connection between the input 'i' and the output 'o'
+ with gain 'g' for the tea6420-client 'client' (note: i = 6 means 'mute') */
+static int tea6420_switch(struct i2c_client *client, int i, int o, int g)
+{
+ u8 byte = 0;
+ int ret;
+
+ dprintk("adr:0x%02x, i:%d, o:%d, g:%d\n", client->addr, i, o, g);
+
+ /* check if the paramters are valid */
+ if (i < 1 || i > 6 || o < 1 || o > 4 || g < 0 || g > 6 || g % 2 != 0)
+ return -1;
+
+ byte = ((o - 1) << 5);
+ byte |= (i - 1);
+
+ /* to understand this, have a look at the tea6420-specs (p.5) */
+ switch (g) {
+ case 0:
+ byte |= (3 << 3);
+ break;
+ case 2:
+ byte |= (2 << 3);
+ break;
+ case 4:
+ byte |= (1 << 3);
+ break;
+ case 6:
+ break;
+ }
+
+ ret = i2c_smbus_write_byte(client, byte);
+ if (ret) {
+ dprintk("i2c_smbus_write_byte() failed, ret:%d\n", ret);
+ return -EIO;
+ }
+
+ return 0;
+}
+
+/* this function is called by i2c_probe */
+static int tea6420_detect(struct i2c_adapter *adapter, int address, int kind)
+{
+ struct i2c_client *client;
+ int err = 0, i = 0;
+
+ /* let's see whether this adapter can support what we need */
+ if (0 == i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE)) {
+ return 0;
+ }
+
+ /* allocate memory for client structure */
+ client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
+ if (0 == client) {
+ return -ENOMEM;
+ }
+ memset(client, 0x0, sizeof(struct i2c_client));
+
+ /* fill client structure */
+ memcpy(client, &client_template, sizeof(struct i2c_client));
+ client->addr = address;
+ client->adapter = adapter;
+
+ /* tell the i2c layer a new client has arrived */
+ if (0 != (err = i2c_attach_client(client))) {
+ kfree(client);
+ return err;
+ }
+
+ /* set initial values: set "mute"-input to all outputs at gain 0 */
+ err = 0;
+ for (i = 1; i < 5; i++) {
+ err += tea6420_switch(client, 6, i, 0);
+ }
+ if (err) {
+ dprintk("could not initialize tea6420\n");
+ kfree(client);
+ return -ENODEV;
+ }
+
+ printk("tea6420: detected @ 0x%02x on adapter %s\n", address, &client->adapter->name[0]);
+
+ return 0;
+}
+
+static int attach(struct i2c_adapter *adapter)
+{
+ /* let's see whether this is a know adapter we can attach to */
+ if (adapter->id != I2C_HW_SAA7146) {
+ dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id);
+ return -ENODEV;
+ }
+
+ return i2c_probe(adapter, &addr_data, &tea6420_detect);
+}
+
+static int detach(struct i2c_client *client)
+{
+ int ret = i2c_detach_client(client);
+ kfree(client);
+ return ret;
+}
+
+static int command(struct i2c_client *client, unsigned int cmd, void *arg)
+{
+ struct tea6420_multiplex *a = (struct tea6420_multiplex *)arg;
+ int result = 0;
+
+ switch (cmd) {
+ case TEA6420_SWITCH:
+ result = tea6420_switch(client, a->in, a->out, a->gain);
+ break;
+ default:
+ return -ENOIOCTLCMD;
+ }
+
+ return result;
+}
+
+static struct i2c_driver driver = {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) &&(LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15))
+ .owner = THIS_MODULE,
+#endif
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15)
+ .name = "tea6420",
+ .flags = I2C_DF_NOTIFY,
+#else
+ .driver = {
+ .name = "tea6420",
+ },
+#endif
+ .id = I2C_DRIVERID_TEA6420,
+ .attach_adapter = attach,
+ .detach_client = detach,
+ .command = command,
+};
+
+static struct i2c_client client_template = {
+ .name = "tea6420",
+ .driver = &driver,
+};
+
+static int __init this_module_init(void)
+{
+ return i2c_add_driver(&driver);
+}
+
+static void __exit this_module_exit(void)
+{
+ i2c_del_driver(&driver);
+}
+
+module_init(this_module_init);
+module_exit(this_module_exit);
+
+MODULE_AUTHOR("Michael Hunold <michael@mihu.de>");
+MODULE_DESCRIPTION("tea6420 driver");
+MODULE_LICENSE("GPL");
diff --git a/linux/drivers/media/video/tea6420.h b/linux/drivers/media/video/tea6420.h
new file mode 100644
index 000000000..ea664df15
--- /dev/null
+++ b/linux/drivers/media/video/tea6420.h
@@ -0,0 +1,17 @@
+#ifndef __INCLUDED_TEA6420__
+#define __INCLUDED_TEA6420__
+
+/* possible addresses */
+#define I2C_TEA6420_1 0x4c
+#define I2C_TEA6420_2 0x4d
+
+struct tea6420_multiplex
+{
+ int in; /* input of audio switch */
+ int out; /* output of audio switch */
+ int gain; /* gain of connection */
+};
+
+#define TEA6420_SWITCH _IOW('v',1,struct tea6420_multiplex)
+
+#endif
diff --git a/linux/drivers/media/video/tuner-simple.c b/linux/drivers/media/video/tuner-simple.c
index e6e808259..57db5b1aa 100644
--- a/linux/drivers/media/video/tuner-simple.c
+++ b/linux/drivers/media/video/tuner-simple.c
@@ -390,6 +390,9 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
case TUNER_PHILIPS_FMD1216ME_MK3:
buffer[3] = 0x19;
break;
+ case TUNER_TNF_5335MF:
+ buffer[3] = 0x11;
+ break;
case TUNER_PHILIPS_FM1256_IH3:
div = (20 * freq) / 16000 + (int)(33.3 * 20); /* IF 33.3 MHz */
buffer[3] = 0x19;
diff --git a/linux/drivers/media/video/tuner-types.c b/linux/drivers/media/video/tuner-types.c
index c66a55e81..560879ce9 100644
--- a/linux/drivers/media/video/tuner-types.c
+++ b/linux/drivers/media/video/tuner-types.c
@@ -941,17 +941,27 @@ static struct tuner_params tuner_ymec_tvf66t5_b_dff_params[] = {
/* ------------ TUNER_LG_NTSC_TALN_MINI - LGINNOTEK NTSC ------------ */
-static struct tuner_range tuner_lg_taln_mini_ntsc_ranges[] = {
+static struct tuner_range tuner_lg_taln_ntsc_ranges[] = {
{ 16 * 137.25 /*MHz*/, 0x8e, 0x01, },
{ 16 * 373.25 /*MHz*/, 0x8e, 0x02, },
{ 16 * 999.99 , 0x8e, 0x08, },
};
-static struct tuner_params tuner_lg_taln_mini_params[] = {
+static struct tuner_range tuner_lg_taln_pal_secam_ranges[] = {
+ { 16 * 150.00 /*MHz*/, 0x8e, 0x01, },
+ { 16 * 425.00 /*MHz*/, 0x8e, 0x02, },
+ { 16 * 999.99 , 0x8e, 0x08, },
+};
+
+static struct tuner_params tuner_lg_taln_params[] = {
{
.type = TUNER_PARAM_TYPE_NTSC,
- .ranges = tuner_lg_taln_mini_ntsc_ranges,
- .count = ARRAY_SIZE(tuner_lg_taln_mini_ntsc_ranges),
+ .ranges = tuner_lg_taln_ntsc_ranges,
+ .count = ARRAY_SIZE(tuner_lg_taln_ntsc_ranges),
+ },{
+ .type = TUNER_PARAM_TYPE_PAL,
+ .ranges = tuner_lg_taln_pal_secam_ranges,
+ .count = ARRAY_SIZE(tuner_lg_taln_pal_secam_ranges),
},
};
@@ -999,12 +1009,22 @@ static struct tuner_params tuner_tuv1236d_params[] = {
#endif
};
-/* ------------ TUNER_TNF_5335MF - Philips NTSC ------------ */
+/* ------------ TUNER_TNF_xxx5 - Texas Instruments--------- */
+/* This is known to work with Tenna TVF58t5-MFF and TVF5835 MFF
+ * but it is expected to work also with other Tenna/Ymec
+ * models based on TI SN 761677 chip on both PAL and NTSC
+ */
+
+static struct tuner_range tuner_tnf_5335_d_if_pal_ranges[] = {
+ { 16 * 168.25 /*MHz*/, 0x8e, 0x01, },
+ { 16 * 471.25 /*MHz*/, 0x8e, 0x02, },
+ { 16 * 999.99 , 0x8e, 0x08, },
+};
static struct tuner_range tuner_tnf_5335mf_ntsc_ranges[] = {
- { 16 * 157.25 /*MHz*/, 0x8e, 0x01, },
- { 16 * 454.00 /*MHz*/, 0x8e, 0x02, },
- { 16 * 999.99 , 0x8e, 0x04, },
+ { 16 * 169.25 /*MHz*/, 0x8e, 0x01, },
+ { 16 * 469.25 /*MHz*/, 0x8e, 0x02, },
+ { 16 * 999.99 , 0x8e, 0x08, },
};
static struct tuner_params tuner_tnf_5335mf_params[] = {
@@ -1013,6 +1033,11 @@ static struct tuner_params tuner_tnf_5335mf_params[] = {
.ranges = tuner_tnf_5335mf_ntsc_ranges,
.count = ARRAY_SIZE(tuner_tnf_5335mf_ntsc_ranges),
},
+ {
+ .type = TUNER_PARAM_TYPE_PAL,
+ .ranges = tuner_tnf_5335_d_if_pal_ranges,
+ .count = ARRAY_SIZE(tuner_tnf_5335_d_if_pal_ranges),
+ },
};
/* 70-79 */
@@ -1032,6 +1057,22 @@ static struct tuner_params tuner_samsung_tcpn_2121p30a_params[] = {
},
};
+/* ------------ TUNER_THOMSON_FE6600 - DViCO Hybrid PAL ------------ */
+
+static struct tuner_range tuner_thomson_fe6600_ranges[] = {
+ { 16 * 160.00 /*MHz*/, 0xfe, 0x11, },
+ { 16 * 442.00 /*MHz*/, 0xf6, 0x12, },
+ { 16 * 999.99 , 0xf6, 0x18, },
+};
+
+static struct tuner_params tuner_thomson_fe6600_params[] = {
+ {
+ .type = TUNER_PARAM_TYPE_PAL,
+ .ranges = tuner_thomson_fe6600_ranges,
+ .count = ARRAY_SIZE(tuner_thomson_fe6600_ranges),
+ },
+};
+
/* --------------------------------------------------------------------- */
struct tunertype tuners[] = {
@@ -1372,10 +1413,10 @@ struct tunertype tuners[] = {
.params = tuner_ymec_tvf66t5_b_dff_params,
.count = ARRAY_SIZE(tuner_ymec_tvf66t5_b_dff_params),
},
- [TUNER_LG_NTSC_TALN_MINI] = { /* LGINNOTEK NTSC */
- .name = "LG NTSC (TALN mini series)",
- .params = tuner_lg_taln_mini_params,
- .count = ARRAY_SIZE(tuner_lg_taln_mini_params),
+ [TUNER_LG_TALN] = { /* LGINNOTEK NTSC / PAL / SECAM */
+ .name = "LG TALN series",
+ .params = tuner_lg_taln_params,
+ .count = ARRAY_SIZE(tuner_lg_taln_params),
},
[TUNER_PHILIPS_TD1316] = { /* Philips PAL */
.name = "Philips TD1316 Hybrid Tuner",
@@ -1387,8 +1428,8 @@ struct tunertype tuners[] = {
.params = tuner_tuv1236d_params,
.count = ARRAY_SIZE(tuner_tuv1236d_params),
},
- [TUNER_TNF_5335MF] = { /* Philips NTSC */
- .name = "Tena TNF 5335 MF",
+ [TUNER_TNF_5335MF] = { /* Tenna PAL/NTSC */
+ .name = "Tena TNF 5335 and similar models",
.params = tuner_tnf_5335mf_params,
.count = ARRAY_SIZE(tuner_tnf_5335mf_params),
},
@@ -1403,6 +1444,11 @@ struct tunertype tuners[] = {
.name = "Xceive xc3028",
/* see xc3028.c for details */
},
+ [TUNER_THOMSON_FE6600] = { /* Thomson PAL / DVB-T */
+ .name = "Thomson FE6600",
+ .params = tuner_thomson_fe6600_params,
+ .count = ARRAY_SIZE(tuner_thomson_fe6600_params),
+ },
};
unsigned const int tuner_count = ARRAY_SIZE(tuners);
diff --git a/linux/drivers/media/video/v4l2-common.c b/linux/drivers/media/video/v4l2-common.c
index 27158d0b9..b9c56e5e5 100644
--- a/linux/drivers/media/video/v4l2-common.c
+++ b/linux/drivers/media/video/v4l2-common.c
@@ -501,7 +501,7 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
prt_names(p->memory,v4l2_memory_names),
p->m.userptr);
printk ("%s: timecode= %02d:%02d:%02d type=%d, "
- "flags=0x%08d, frames=%d, userbits=0x%08x",
+ "flags=0x%08d, frames=%d, userbits=0x%08x\n",
s,tc->hours,tc->minutes,tc->seconds,
tc->type, tc->flags, tc->frames, (__u32) tc->userbits);
break;
@@ -509,8 +509,8 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
case VIDIOC_QUERYCAP:
{
struct v4l2_capability *p=arg;
- printk ("%s: driver=%s, card=%s, bus=%s, version=%d, "
- "capabilities=%d\n", s,
+ printk ("%s: driver=%s, card=%s, bus=%s, version=0x%08x, "
+ "capabilities=0x%08x\n", s,
p->driver,p->card,p->bus_info,
p->version,
p->capabilities);
diff --git a/linux/drivers/media/video/video-buf.c b/linux/drivers/media/video/video-buf.c
index c4e2c58a2..e2d5e03c9 100644
--- a/linux/drivers/media/video/video-buf.c
+++ b/linux/drivers/media/video/video-buf.c
@@ -2,15 +2,20 @@
* $Id: video-buf.c,v 1.25 2006/01/11 19:28:02 mchehab Exp $
*
* generic helper functions for video4linux capture buffers, to handle
- * memory management and PCI DMA. Right now bttv + saa7134 use it.
+ * memory management and PCI DMA.
+ * Right now, bttv, saa7134, saa7146 and cx88 use it.
*
* The functions expect the hardware being able to scatter gatter
* (i.e. the buffers are not linear in physical memory, but fragmented
* into PAGE_SIZE chunks). They also assume the driver does not need
- * to touch the video data (thus it is probably not useful for USB 1.1
- * as data often must be uncompressed by the drivers).
+ * to touch the video data.
+ *
+ * device specific map/unmap/sync stuff now are mapped as operations
+ * to allow its usage by USB and virtual devices.
*
* (c) 2001-2004 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs]
+ * (c) 2006 Mauro Carvalho Chehab <mchehab@infradead.org>
+ * (c) 2006 Ted Walther and John Sokol
*
* 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
@@ -61,8 +66,7 @@ videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages)
pg = vmalloc_to_page(virt);
if (NULL == pg)
goto err;
- if (PageHighMem(pg))
- BUG();
+ BUG_ON(PageHighMem(pg));
sglist[i].page = pg;
sglist[i].length = PAGE_SIZE;
}
@@ -170,6 +174,9 @@ int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction,
dprintk(1,"vmalloc_32(%d pages) failed\n",nr_pages);
return -ENOMEM;
}
+ dprintk(1,"vmalloc is at addr 0x%08lx, size=%d\n",
+ (unsigned long)dma->vmalloc,
+ nr_pages << PAGE_SHIFT);
memset(dma->vmalloc,0,nr_pages << PAGE_SHIFT);
dma->nr_pages = nr_pages;
return 0;
@@ -189,8 +196,10 @@ int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction,
return 0;
}
-int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma)
+int videobuf_dma_map(struct videobuf_queue* q,struct videobuf_dmabuf *dma)
{
+ void *dev=q->dev;
+
MAGIC_CHECK(dma->magic,MAGIC_DMABUF);
BUG_ON(0 == dma->nr_pages);
@@ -200,7 +209,7 @@ int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma)
}
if (dma->vmalloc) {
dma->sglist = videobuf_vmalloc_to_sg
- (dma->vmalloc,dma->nr_pages);
+ (dma->vmalloc,dma->nr_pages);
}
if (dma->bus_addr) {
dma->sglist = kmalloc(sizeof(struct scatterlist), GFP_KERNEL);
@@ -215,13 +224,14 @@ int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma)
dprintk(1,"scatterlist is NULL\n");
return -ENOMEM;
}
-
if (!dma->bus_addr) {
- dma->sglen = pci_map_sg(dev,dma->sglist,dma->nr_pages,
- dma->direction);
+ if (q->ops->vb_map_sg) {
+ dma->sglen = q->ops->vb_map_sg(dev,dma->sglist,
+ dma->nr_pages, dma->direction);
+ }
if (0 == dma->sglen) {
printk(KERN_WARNING
- "%s: pci_map_sg failed\n",__FUNCTION__);
+ "%s: videobuf_map_sg failed\n",__FUNCTION__);
kfree(dma->sglist);
dma->sglist = NULL;
dma->sglen = 0;
@@ -231,29 +241,31 @@ int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma)
return 0;
}
-int videobuf_dma_pci_sync(struct pci_dev *dev, struct videobuf_dmabuf *dma)
+int videobuf_dma_sync(struct videobuf_queue* q,struct videobuf_dmabuf *dma)
{
+ void *dev=q->dev;
+
MAGIC_CHECK(dma->magic,MAGIC_DMABUF);
BUG_ON(!dma->sglen);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,5)
- if (!dma->bus_addr)
- pci_dma_sync_sg(dev,dma->sglist,dma->nr_pages,dma->direction);
-#else
- if (!dma->bus_addr)
- pci_dma_sync_sg_for_cpu(dev,dma->sglist,dma->nr_pages,dma->direction);
-#endif
+ if (!dma->bus_addr && q->ops->vb_dma_sync_sg)
+ q->ops->vb_dma_sync_sg(dev,dma->sglist,dma->nr_pages,
+ dma->direction);
+
return 0;
}
-int videobuf_dma_pci_unmap(struct pci_dev *dev, struct videobuf_dmabuf *dma)
+int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma)
{
+ void *dev=q->dev;
+
MAGIC_CHECK(dma->magic,MAGIC_DMABUF);
if (!dma->sglen)
return 0;
- if (!dma->bus_addr)
- pci_unmap_sg(dev,dma->sglist,dma->nr_pages,dma->direction);
+ if (!dma->bus_addr && q->ops->vb_unmap_sg)
+ q->ops->vb_unmap_sg(dev,dma->sglist,dma->nr_pages,
+ dma->direction);
kfree(dma->sglist);
dma->sglist = NULL;
dma->sglen = 0;
@@ -326,7 +338,7 @@ int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr)
}
int
-videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb,
+videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb,
struct v4l2_framebuffer *fbuf)
{
int err,pages;
@@ -365,7 +377,7 @@ videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb,
default:
BUG();
}
- err = videobuf_dma_pci_map(pci,&vb->dma);
+ err = videobuf_dma_map(q,&vb->dma);
if (0 != err)
return err;
@@ -374,9 +386,46 @@ videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb,
/* --------------------------------------------------------------------- */
+void videobuf_queue_pci(struct videobuf_queue* q)
+{
+ /* If not specified, defaults to PCI map sg */
+ if (!q->ops->vb_map_sg)
+ q->ops->vb_map_sg=(vb_map_sg_t *)pci_map_sg;
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,5)
+ if (!q->ops->vb_dma_sync_sg)
+ q->ops->vb_dma_sync_sg=(vb_map_sg_t *)pci_dma_sync_sg;
+#else
+ if (!q->ops->vb_dma_sync_sg)
+ q->ops->vb_dma_sync_sg=(vb_map_sg_t *)pci_dma_sync_sg_for_cpu;
+#endif
+ if (!q->ops->vb_unmap_sg)
+ q->ops->vb_unmap_sg=(vb_map_sg_t *)pci_unmap_sg;
+}
+
+int videobuf_pci_dma_map(struct pci_dev *pci,struct videobuf_dmabuf *dma)
+{
+ struct videobuf_queue q;
+
+ q.dev=pci;
+ q.ops->vb_map_sg=(vb_map_sg_t *)pci_unmap_sg;
+
+ return (videobuf_dma_unmap(&q,dma));
+}
+
+int videobuf_pci_dma_unmap(struct pci_dev *pci,struct videobuf_dmabuf *dma)
+{
+ struct videobuf_queue q;
+
+ q.dev=pci;
+ q.ops->vb_map_sg=(vb_map_sg_t *)pci_unmap_sg;
+
+ return (videobuf_dma_unmap(&q,dma));
+}
+
void videobuf_queue_init(struct videobuf_queue* q,
struct videobuf_queue_ops *ops,
- struct pci_dev *pci,
+ void *dev,
spinlock_t *irqlock,
enum v4l2_buf_type type,
enum v4l2_field field,
@@ -385,13 +434,15 @@ void videobuf_queue_init(struct videobuf_queue* q,
{
memset(q,0,sizeof(*q));
q->irqlock = irqlock;
- q->pci = pci;
+ q->dev = dev;
q->type = type;
q->field = field;
q->msize = msize;
q->ops = ops;
q->priv_data = priv;
+ videobuf_queue_pci(q);
+
mutex_init(&q->lock);
INIT_LIST_HEAD(&q->stream);
}
@@ -435,11 +486,12 @@ videobuf_queue_is_busy(struct videobuf_queue *q)
void
videobuf_queue_cancel(struct videobuf_queue *q)
{
- unsigned long flags;
+ unsigned long flags=0;
int i;
/* remove queued buffers from list */
- spin_lock_irqsave(q->irqlock,flags);
+ if (q->irqlock)
+ spin_lock_irqsave(q->irqlock,flags);
for (i = 0; i < VIDEO_MAX_FRAME; i++) {
if (NULL == q->bufs[i])
continue;
@@ -448,7 +500,8 @@ videobuf_queue_cancel(struct videobuf_queue *q)
q->bufs[i]->state = STATE_ERROR;
}
}
- spin_unlock_irqrestore(q->irqlock,flags);
+ if (q->irqlock)
+ spin_unlock_irqrestore(q->irqlock,flags);
/* free all buffers + clear queue */
for (i = 0; i < VIDEO_MAX_FRAME; i++) {
@@ -542,19 +595,29 @@ videobuf_reqbufs(struct videobuf_queue *q,
unsigned int size,count;
int retval;
- if (req->type != q->type)
+ if (req->type != q->type) {
+ dprintk(1,"reqbufs: queue type invalid\n");
return -EINVAL;
- if (req->count < 1)
+ }
+ if (req->count < 1) {
+ dprintk(1,"reqbufs: count invalid (%d)\n",req->count);
return -EINVAL;
+ }
if (req->memory != V4L2_MEMORY_MMAP &&
req->memory != V4L2_MEMORY_USERPTR &&
- req->memory != V4L2_MEMORY_OVERLAY)
+ req->memory != V4L2_MEMORY_OVERLAY) {
+ dprintk(1,"reqbufs: memory type invalid\n");
return -EINVAL;
+ }
- if (q->streaming)
+ if (q->streaming) {
+ dprintk(1,"reqbufs: streaming already exists\n");
return -EBUSY;
- if (!list_empty(&q->stream))
+ }
+ if (!list_empty(&q->stream)) {
+ dprintk(1,"reqbufs: stream running\n");
return -EBUSY;
+ }
mutex_lock(&q->lock);
count = req->count;
@@ -567,8 +630,10 @@ videobuf_reqbufs(struct videobuf_queue *q,
count, size, (count*size)>>PAGE_SHIFT);
retval = videobuf_mmap_setup(q,count,size,req->memory);
- if (retval < 0)
+ if (retval < 0) {
+ dprintk(1,"reqbufs: mmap setup returned %d\n",retval);
goto done;
+ }
req->count = count;
@@ -580,12 +645,18 @@ videobuf_reqbufs(struct videobuf_queue *q,
int
videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b)
{
- if (unlikely(b->type != q->type))
+ if (unlikely(b->type != q->type)) {
+ dprintk(1,"querybuf: Wrong type.\n");
return -EINVAL;
- if (unlikely(b->index < 0 || b->index >= VIDEO_MAX_FRAME))
+ }
+ if (unlikely(b->index < 0 || b->index >= VIDEO_MAX_FRAME)) {
+ dprintk(1,"querybuf: index out of range.\n");
return -EINVAL;
- if (unlikely(NULL == q->bufs[b->index]))
+ }
+ if (unlikely(NULL == q->bufs[b->index])) {
+ dprintk(1,"querybuf: buffer is null.\n");
return -EINVAL;
+ }
videobuf_status(b,q->bufs[b->index],q->type);
return 0;
}
@@ -596,31 +667,45 @@ videobuf_qbuf(struct videobuf_queue *q,
{
struct videobuf_buffer *buf;
enum v4l2_field field;
- unsigned long flags;
+ unsigned long flags=0;
int retval;
mutex_lock(&q->lock);
retval = -EBUSY;
- if (q->reading)
+ if (q->reading) {
+ dprintk(1,"qbuf: Reading running...\n");
goto done;
+ }
retval = -EINVAL;
- if (b->type != q->type)
+ if (b->type != q->type) {
+ dprintk(1,"qbuf: Wrong type.\n");
goto done;
- if (b->index < 0 || b->index >= VIDEO_MAX_FRAME)
+ }
+ if (b->index < 0 || b->index >= VIDEO_MAX_FRAME) {
+ dprintk(1,"qbuf: index out of range.\n");
goto done;
+ }
buf = q->bufs[b->index];
- if (NULL == buf)
+ if (NULL == buf) {
+ dprintk(1,"qbuf: buffer is null.\n");
goto done;
+ }
MAGIC_CHECK(buf->magic,MAGIC_BUFFER);
- if (buf->memory != b->memory)
+ if (buf->memory != b->memory) {
+ dprintk(1,"qbuf: memory type is wrong.\n");
goto done;
+ }
if (buf->state == STATE_QUEUED ||
- buf->state == STATE_ACTIVE)
+ buf->state == STATE_ACTIVE) {
+ dprintk(1,"qbuf: buffer is already queued or active.\n");
goto done;
+ }
if (b->flags & V4L2_BUF_FLAG_INPUT) {
- if (b->input >= q->inputs)
+ if (b->input >= q->inputs) {
+ dprintk(1,"qbuf: wrong input.\n");
goto done;
+ }
buf->input = b->input;
} else {
buf->input = UNSET;
@@ -628,12 +713,16 @@ videobuf_qbuf(struct videobuf_queue *q,
switch (b->memory) {
case V4L2_MEMORY_MMAP:
- if (0 == buf->baddr)
+ if (0 == buf->baddr) {
+ dprintk(1,"qbuf: mmap requested but buffer addr is zero!\n");
goto done;
+ }
break;
case V4L2_MEMORY_USERPTR:
- if (b->length < buf->bsize)
+ if (b->length < buf->bsize) {
+ dprintk(1,"qbuf: buffer length is not enough\n");
goto done;
+ }
if (STATE_NEEDS_INIT != buf->state && buf->baddr != b->m.userptr)
q->ops->buf_release(q,buf);
buf->baddr = b->m.userptr;
@@ -642,20 +731,27 @@ videobuf_qbuf(struct videobuf_queue *q,
buf->boff = b->m.offset;
break;
default:
+ dprintk(1,"qbuf: wrong memory type\n");
goto done;
}
+ dprintk(1,"qbuf: requesting next field\n");
field = videobuf_next_field(q);
retval = q->ops->buf_prepare(q,buf,field);
- if (0 != retval)
+ if (0 != retval) {
+ dprintk(1,"qbuf: buffer_prepare returned %d\n",retval);
goto done;
+ }
list_add_tail(&buf->stream,&q->stream);
if (q->streaming) {
- spin_lock_irqsave(q->irqlock,flags);
+ if (q->irqlock)
+ spin_lock_irqsave(q->irqlock,flags);
q->ops->buf_queue(q,buf);
- spin_unlock_irqrestore(q->irqlock,flags);
+ if (q->irqlock)
+ spin_unlock_irqrestore(q->irqlock,flags);
}
+ dprintk(1,"qbuf: succeded\n");
retval = 0;
done:
@@ -672,26 +768,39 @@ videobuf_dqbuf(struct videobuf_queue *q,
mutex_lock(&q->lock);
retval = -EBUSY;
- if (q->reading)
+ if (q->reading) {
+ dprintk(1,"dqbuf: Reading running...\n");
goto done;
+ }
retval = -EINVAL;
- if (b->type != q->type)
+ if (b->type != q->type) {
+ dprintk(1,"dqbuf: Wrong type.\n");
goto done;
- if (list_empty(&q->stream))
+ }
+ if (list_empty(&q->stream)) {
+ dprintk(1,"dqbuf: stream running\n");
goto done;
+ }
buf = list_entry(q->stream.next, struct videobuf_buffer, stream);
retval = videobuf_waiton(buf, nonblocking, 1);
- if (retval < 0)
+ if (retval < 0) {
+ dprintk(1,"dqbuf: waiton returned %d\n",retval);
goto done;
+ }
switch (buf->state) {
case STATE_ERROR:
+ dprintk(1,"dqbuf: state is error\n");
retval = -EIO;
- /* fall through */
+ videobuf_dma_sync(q,&buf->dma);
+ buf->state = STATE_IDLE;
+ break;
case STATE_DONE:
- videobuf_dma_pci_sync(q->pci,&buf->dma);
+ dprintk(1,"dqbuf: state is done\n");
+ videobuf_dma_sync(q,&buf->dma);
buf->state = STATE_IDLE;
break;
default:
+ dprintk(1,"dqbuf: state invalid\n");
retval = -EINVAL;
goto done;
}
@@ -708,7 +817,7 @@ int videobuf_streamon(struct videobuf_queue *q)
{
struct videobuf_buffer *buf;
struct list_head *list;
- unsigned long flags;
+ unsigned long flags=0;
int retval;
mutex_lock(&q->lock);
@@ -719,13 +828,15 @@ int videobuf_streamon(struct videobuf_queue *q)
if (q->streaming)
goto done;
q->streaming = 1;
- spin_lock_irqsave(q->irqlock,flags);
+ if (q->irqlock)
+ spin_lock_irqsave(q->irqlock,flags);
list_for_each(list,&q->stream) {
buf = list_entry(list, struct videobuf_buffer, stream);
if (buf->state == STATE_PREPARED)
q->ops->buf_queue(q,buf);
}
- spin_unlock_irqrestore(q->irqlock,flags);
+ if (q->irqlock)
+ spin_unlock_irqrestore(q->irqlock,flags);
done:
mutex_unlock(&q->lock);
@@ -753,7 +864,7 @@ videobuf_read_zerocopy(struct videobuf_queue *q, char __user *data,
size_t count, loff_t *ppos)
{
enum v4l2_field field;
- unsigned long flags;
+ unsigned long flags=0;
int retval;
/* setup stuff */
@@ -770,12 +881,14 @@ videobuf_read_zerocopy(struct videobuf_queue *q, char __user *data,
goto done;
/* start capture & wait */
- spin_lock_irqsave(q->irqlock,flags);
+ if (q->irqlock)
+ spin_lock_irqsave(q->irqlock,flags);
q->ops->buf_queue(q,q->read_buf);
- spin_unlock_irqrestore(q->irqlock,flags);
+ if (q->irqlock)
+ spin_unlock_irqrestore(q->irqlock,flags);
retval = videobuf_waiton(q->read_buf,0,0);
if (0 == retval) {
- videobuf_dma_pci_sync(q->pci,&q->read_buf->dma);
+ videobuf_dma_sync(q,&q->read_buf->dma);
if (STATE_ERROR == q->read_buf->state)
retval = -EIO;
else
@@ -795,7 +908,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
int nonblocking)
{
enum v4l2_field field;
- unsigned long flags;
+ unsigned long flags=0;
unsigned size, nbufs, bytes;
int retval;
@@ -817,6 +930,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
/* need to capture a new frame */
retval = -ENOMEM;
q->read_buf = videobuf_alloc(q->msize);
+ dprintk(1,"video alloc=0x%08x\n",(unsigned int) q->read_buf);
if (NULL == q->read_buf)
goto done;
q->read_buf->memory = V4L2_MEMORY_USERPTR;
@@ -828,9 +942,11 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
q->read_buf = NULL;
goto done;
}
- spin_lock_irqsave(q->irqlock,flags);
+ if (q->irqlock)
+ spin_lock_irqsave(q->irqlock,flags);
q->ops->buf_queue(q,q->read_buf);
- spin_unlock_irqrestore(q->irqlock,flags);
+ if (q->irqlock)
+ spin_unlock_irqrestore(q->irqlock,flags);
q->read_off = 0;
}
@@ -838,7 +954,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
retval = videobuf_waiton(q->read_buf, nonblocking, 1);
if (0 != retval)
goto done;
- videobuf_dma_pci_sync(q->pci,&q->read_buf->dma);
+ videobuf_dma_sync(q,&q->read_buf->dma);
if (STATE_ERROR == q->read_buf->state) {
/* catch I/O errors */
@@ -874,7 +990,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
int videobuf_read_start(struct videobuf_queue *q)
{
enum v4l2_field field;
- unsigned long flags;
+ unsigned long flags=0;
int count = 0, size = 0;
int err, i;
@@ -895,10 +1011,12 @@ int videobuf_read_start(struct videobuf_queue *q)
return err;
list_add_tail(&q->bufs[i]->stream, &q->stream);
}
- spin_lock_irqsave(q->irqlock,flags);
+ if (q->irqlock)
+ spin_lock_irqsave(q->irqlock,flags);
for (i = 0; i < count; i++)
q->ops->buf_queue(q,q->bufs[i]);
- spin_unlock_irqrestore(q->irqlock,flags);
+ if (q->irqlock)
+ spin_unlock_irqrestore(q->irqlock,flags);
q->reading = 1;
return 0;
}
@@ -926,7 +1044,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q,
{
unsigned int *fc, bytes;
int err, retval;
- unsigned long flags;
+ unsigned long flags=0;
dprintk(2,"%s\n",__FUNCTION__);
mutex_lock(&q->lock);
@@ -993,9 +1111,11 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q,
if (q->read_off == q->read_buf->size) {
list_add_tail(&q->read_buf->stream,
&q->stream);
- spin_lock_irqsave(q->irqlock,flags);
+ if (q->irqlock)
+ spin_lock_irqsave(q->irqlock,flags);
q->ops->buf_queue(q,q->read_buf);
- spin_unlock_irqrestore(q->irqlock,flags);
+ if (q->irqlock)
+ spin_unlock_irqrestore(q->irqlock,flags);
q->read_buf = NULL;
}
if (retval < 0)
@@ -1268,11 +1388,14 @@ EXPORT_SYMBOL_GPL(videobuf_dma_init);
EXPORT_SYMBOL_GPL(videobuf_dma_init_user);
EXPORT_SYMBOL_GPL(videobuf_dma_init_kernel);
EXPORT_SYMBOL_GPL(videobuf_dma_init_overlay);
-EXPORT_SYMBOL_GPL(videobuf_dma_pci_map);
-EXPORT_SYMBOL_GPL(videobuf_dma_pci_sync);
-EXPORT_SYMBOL_GPL(videobuf_dma_pci_unmap);
+EXPORT_SYMBOL_GPL(videobuf_dma_map);
+EXPORT_SYMBOL_GPL(videobuf_dma_sync);
+EXPORT_SYMBOL_GPL(videobuf_dma_unmap);
EXPORT_SYMBOL_GPL(videobuf_dma_free);
+EXPORT_SYMBOL_GPL(videobuf_pci_dma_map);
+EXPORT_SYMBOL_GPL(videobuf_pci_dma_unmap);
+
EXPORT_SYMBOL_GPL(videobuf_alloc);
EXPORT_SYMBOL_GPL(videobuf_waiton);
EXPORT_SYMBOL_GPL(videobuf_iolock);
diff --git a/linux/drivers/media/video/vivi.c b/linux/drivers/media/video/vivi.c
new file mode 100644
index 000000000..2dfbf65f2
--- /dev/null
+++ b/linux/drivers/media/video/vivi.c
@@ -0,0 +1,1543 @@
+/*
+ * Virtual Video driver - This code emulates a real video device with v4l2 api
+ *
+ * Copyright (c) 2006 by:
+ * Mauro Carvalho Chehab <mchehab--a.t--infradead.org>
+ * Ted Walther <ted--a.t--enumera.com>
+ * John Sokol <sokol--a.t--videotechnology.com>
+ * http://v4l.videotechnology.com/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the BSD Licence, GNU General Public License
+ * as published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version
+ */
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/fs.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/mm.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/pci.h>
+#include <linux/random.h>
+#include <linux/version.h>
+#include <linux/videodev2.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
+#include <linux/videodev.h>
+#include <linux/interrupt.h>
+#endif
+#include <media/video-buf.h>
+#include <media/v4l2-common.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#include <linux/kthread.h>
+#endif
+#include <linux/highmem.h>
+
+/* Wake up at about 30 fps */
+#define WAKE_NUMERATOR 30
+#define WAKE_DENOMINATOR 1001
+#define BUFFER_TIMEOUT msecs_to_jiffies(500) /* 0.5 seconds */
+
+/* These timers are for 1 fps - used only for testing */
+//#define WAKE_DENOMINATOR 30 /* hack for testing purposes */
+//#define BUFFER_TIMEOUT msecs_to_jiffies(5000) /* 5 seconds */
+
+#include "font.h"
+
+#ifndef kzalloc
+#define kzalloc(size, flags) \
+({ \
+ void *__ret = kmalloc(size, flags); \
+ if (__ret) \
+ memset(__ret, 0, size); \
+ __ret; \
+})
+#endif
+
+MODULE_DESCRIPTION("Video Technology Magazine Virtual Video Capture Board");
+MODULE_AUTHOR("Mauro Carvalho Chehab, Ted Walther and John Sokol");
+MODULE_LICENSE("Dual BSD/GPL");
+
+#define VIVI_MAJOR_VERSION 0
+#define VIVI_MINOR_VERSION 4
+#define VIVI_RELEASE 0
+#define VIVI_VERSION KERNEL_VERSION(VIVI_MAJOR_VERSION, VIVI_MINOR_VERSION, VIVI_RELEASE)
+
+static int video_nr = -1; /* /dev/videoN, -1 for autodetect */
+module_param(video_nr, int, 0);
+
+static int debug = 0;
+module_param(debug, int, 0);
+
+static unsigned int vid_limit = 16;
+module_param(vid_limit,int,0644);
+MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes");
+
+/* supported controls */
+static struct v4l2_queryctrl vivi_qctrl[] = {
+ {
+ .id = V4L2_CID_AUDIO_VOLUME,
+ .name = "Volume",
+ .minimum = 0,
+ .maximum = 65535,
+ .step = 65535/100,
+ .default_value = 65535,
+ .flags = 0,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ },{
+ .id = V4L2_CID_BRIGHTNESS,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Brightness",
+ .minimum = 0,
+ .maximum = 255,
+ .step = 1,
+ .default_value = 127,
+ .flags = 0,
+ }, {
+ .id = V4L2_CID_CONTRAST,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Contrast",
+ .minimum = 0,
+ .maximum = 255,
+ .step = 0x1,
+ .default_value = 0x10,
+ .flags = 0,
+ }, {
+ .id = V4L2_CID_SATURATION,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Saturation",
+ .minimum = 0,
+ .maximum = 255,
+ .step = 0x1,
+ .default_value = 127,
+ .flags = 0,
+ }, {
+ .id = V4L2_CID_HUE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Hue",
+ .minimum = -128,
+ .maximum = 127,
+ .step = 0x1,
+ .default_value = 0,
+ .flags = 0,
+ }
+};
+
+static int qctl_regs[ARRAY_SIZE(vivi_qctrl)];
+
+#define dprintk(level,fmt, arg...) \
+ do { \
+ if (debug >= (level)) \
+ printk(KERN_DEBUG "vivi: " fmt , ## arg); \
+ } while (0)
+
+/* ------------------------------------------------------------------
+ Basic structures
+ ------------------------------------------------------------------*/
+
+struct vivi_fmt {
+ char *name;
+ u32 fourcc; /* v4l2 format id */
+ int depth;
+};
+
+static struct vivi_fmt format = {
+ .name = "4:2:2, packed, YUYV",
+ .fourcc = V4L2_PIX_FMT_YUYV,
+ .depth = 16,
+};
+
+struct sg_to_addr {
+ int pos;
+ struct scatterlist *sg;
+};
+
+/* buffer for one video frame */
+struct vivi_buffer {
+ /* common v4l buffer stuff -- must be first */
+ struct videobuf_buffer vb;
+
+ struct vivi_fmt *fmt;
+
+ struct sg_to_addr *to_addr;
+};
+
+struct vivi_dmaqueue {
+ struct list_head active;
+ struct list_head queued;
+ struct timer_list timeout;
+
+ /* thread for generating video stream*/
+ struct task_struct *kthread;
+ wait_queue_head_t wq;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ struct semaphore *notify;
+ int rmmod:1;
+#endif
+ /* Counters to control fps rate */
+ int frame;
+ int ini_jiffies;
+};
+
+static LIST_HEAD(vivi_devlist);
+
+struct vivi_dev {
+ struct list_head vivi_devlist;
+
+ struct semaphore lock;
+
+ int users;
+
+ /* various device info */
+ unsigned int resources;
+ struct video_device video_dev;
+
+ struct vivi_dmaqueue vidq;
+
+ /* Several counters */
+ int h,m,s,us,jiffies;
+ char timestr[13];
+};
+
+struct vivi_fh {
+ struct vivi_dev *dev;
+
+ /* video capture */
+ struct vivi_fmt *fmt;
+ unsigned int width,height;
+ struct videobuf_queue vb_vidq;
+
+ enum v4l2_buf_type type;
+};
+
+/* ------------------------------------------------------------------
+ DMA and thread functions
+ ------------------------------------------------------------------*/
+
+/* Bars and Colors should match positions */
+
+enum colors {
+ WHITE,
+ AMBAR,
+ CYAN,
+ GREEN,
+ MAGENTA,
+ RED,
+ BLUE
+};
+
+static u8 bars[8][3] = {
+ /* R G B */
+ {204,204,204}, /* white */
+ {208,208, 0}, /* ambar */
+ { 0,206,206}, /* cyan */
+ { 0,239, 0}, /* green */
+ {239, 0,239}, /* magenta */
+ {205, 0, 0}, /* red */
+ { 0, 0,255}, /* blue */
+ { 0, 0, 0}
+};
+
+#define TO_Y(r,g,b) (((16829*r +33039*g +6416*b + 32768)>>16)+16)
+/* RGB to V(Cr) Color transform */
+#define TO_V(r,g,b) (((28784*r -24103*g -4681*b + 32768)>>16)+128)
+/* RGB to U(Cb) Color transform */
+#define TO_U(r,g,b) (((-9714*r -19070*g +28784*b + 32768)>>16)+128)
+
+#define TSTAMP_MIN_Y 24
+#define TSTAMP_MAX_Y TSTAMP_MIN_Y+15
+#define TSTAMP_MIN_X 64
+
+void prep_to_addr(struct sg_to_addr to_addr[],struct videobuf_buffer *vb)
+{
+ int i, pos=0;
+
+ for (i=0;i<vb->dma.nr_pages;i++) {
+ to_addr[i].sg=&vb->dma.sglist[i];
+ to_addr[i].pos=pos;
+ pos += vb->dma.sglist[i].length;
+ }
+}
+
+inline int get_addr_pos(int pos, int pages, struct sg_to_addr to_addr[])
+{
+ int p1=0,p2=pages-1,p3=pages/2;
+
+ /* Sanity test */
+ BUG_ON (pos>=to_addr[p2].pos+to_addr[p2].sg->length);
+
+ while (p1+1<p2) {
+ if (pos < to_addr[p3].pos) {
+ p2=p3;
+ } else {
+ p1=p3;
+ }
+ p3=(p1+p2)/2;
+ }
+ if (pos >= to_addr[p2].pos)
+ p1=p2;
+
+ return (p1);
+}
+
+void gen_line(struct sg_to_addr to_addr[],int inipos,int pages,int wmax,
+ int hmax, int line, char *timestr)
+{
+ int w,i,j,pos=inipos,pgpos,oldpg,y;
+ char *p,*s,*basep;
+ struct page *pg;
+ u8 chr,r,g,b,color;
+
+ /* Get first addr pointed to pixel position */
+ oldpg=get_addr_pos(pos,pages,to_addr);
+ pg=pfn_to_page(to_addr[oldpg].sg->dma_address >> PAGE_SHIFT);
+ basep = kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[oldpg].sg->offset;
+
+ /* We will just duplicate the second pixel at the packet */
+ wmax/=2;
+
+ /* Generate a standard color bar pattern */
+ for (w=0;w<wmax;w++) {
+ r=bars[w*7/wmax][0];
+ g=bars[w*7/wmax][1];
+ b=bars[w*7/wmax][2];
+
+ for (color=0;color<4;color++) {
+ pgpos=get_addr_pos(pos,pages,to_addr);
+ if (pgpos!=oldpg) {
+ pg=pfn_to_page(to_addr[pgpos].sg->dma_address >> PAGE_SHIFT);
+ kunmap_atomic(basep, KM_BOUNCE_READ);
+ basep= kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[pgpos].sg->offset;
+ oldpg=pgpos;
+ }
+ p=basep+pos-to_addr[pgpos].pos;
+
+ switch (color) {
+ case 0:
+ case 2:
+ *p=TO_Y(r,g,b); /* Luminance */
+ break;
+ case 1:
+ *p=TO_U(r,g,b); /* Cb */
+ break;
+ case 3:
+ *p=TO_V(r,g,b); /* Cr */
+ break;
+ }
+ pos++;
+ }
+ }
+
+ /* Checks if it is possible to show timestamp */
+ if (TSTAMP_MAX_Y>=hmax)
+ goto end;
+ if (TSTAMP_MIN_X+strlen(timestr)>=wmax)
+ goto end;
+
+ /* Print stream time */
+ if (line>=TSTAMP_MIN_Y && line<=TSTAMP_MAX_Y) {
+ j=TSTAMP_MIN_X;
+ for (s=timestr;*s;s++) {
+ chr=rom8x16_bits[(*s-0x30)*16+line-TSTAMP_MIN_Y];
+ for (i=0;i<7;i++) {
+ if (chr&1<<(7-i)) { /* Font color*/
+ r=bars[BLUE][0];
+ g=bars[BLUE][1];
+ b=bars[BLUE][2];
+ r=g=b=0;
+ g=198;
+ } else { /* Background color */
+ r=bars[WHITE][0];
+ g=bars[WHITE][1];
+ b=bars[WHITE][2];
+ r=g=b=0;
+ }
+
+ pos=inipos+j*2;
+ for (color=0;color<4;color++) {
+ pgpos=get_addr_pos(pos,pages,to_addr);
+ if (pgpos!=oldpg) {
+ pg=pfn_to_page(to_addr[pgpos].
+ sg->dma_address
+ >> PAGE_SHIFT);
+ kunmap_atomic(basep,
+ KM_BOUNCE_READ);
+ basep= kmap_atomic(pg,
+ KM_BOUNCE_READ)+
+ to_addr[pgpos].sg->offset;
+ oldpg=pgpos;
+ }
+ p=basep+pos-to_addr[pgpos].pos;
+
+ y=TO_Y(r,g,b);
+
+ switch (color) {
+ case 0:
+ case 2:
+ *p=TO_Y(r,g,b); /* Luminance */
+ break;
+ case 1:
+ *p=TO_U(r,g,b); /* Cb */
+ break;
+ case 3:
+ *p=TO_V(r,g,b); /* Cr */
+ break;
+ }
+ pos++;
+ }
+ j++;
+ }
+ }
+ }
+
+#if 0 /* This will require a different logic */
+ /* Generate random noise */
+ if (line>6*hmax/7) {
+ if (line>6*hmax/7) {
+ p=get_addr_pos(inipos+j/2,pages,to_addr);
+
+// get_random_bytes(buf+wmax-(wmax/7), wmax/7);
+ kunmap_atomic(p, KM_BOUNCE_READ);
+ }
+ }
+
+#endif
+
+end:
+ kunmap_atomic(basep, KM_BOUNCE_READ);
+}
+static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
+{
+ int h,pos=0;
+ int hmax = buf->vb.height;
+ int wmax = buf->vb.width;
+ struct videobuf_buffer *vb=&buf->vb;
+ struct sg_to_addr *to_addr=buf->to_addr;
+ struct timeval ts;
+
+ /* Test if DMA mapping is ready */
+ if (!vb->dma.sglist[0].dma_address)
+ return;
+
+ prep_to_addr(to_addr,vb);
+
+ /* Check if there is enough memory */
+ BUG_ON(buf->vb.dma.nr_pages << PAGE_SHIFT < (buf->vb.width*buf->vb.height)*2);
+
+ for (h=0;h<hmax;h++) {
+ gen_line(to_addr,pos,vb->dma.nr_pages,wmax,hmax,h,dev->timestr);
+ pos += wmax*2;
+ }
+
+ /* Updates stream time */
+
+ dev->us+=jiffies_to_usecs(jiffies-dev->jiffies);
+ dev->jiffies=jiffies;
+ if (dev->us>=1000000) {
+ dev->us-=1000000;
+ dev->s++;
+ if (dev->s>=60) {
+ dev->s-=60;
+ dev->m++;
+ if (dev->m>60) {
+ dev->m-=60;
+ dev->h++;
+ if (dev->h>24)
+ dev->h-=24;
+ }
+ }
+ }
+ sprintf(dev->timestr,"%02d:%02d:%02d:%03d",
+ dev->h,dev->m,dev->s,(dev->us+500)/1000);
+
+ dprintk(2,"vivifill at %s: Buffer 0x%08lx size= %d\n",dev->timestr,
+ (unsigned long)buf->vb.dma.vmalloc,pos);
+
+ /* Advice that buffer was filled */
+ buf->vb.state = STATE_DONE;
+ buf->vb.field_count++;
+ do_gettimeofday(&ts);
+ buf->vb.ts = ts;
+
+ list_del(&buf->vb.queue);
+ wake_up(&buf->vb.done);
+}
+
+static int restart_video_queue(struct vivi_dmaqueue *dma_q);
+
+static void vivi_thread_tick(struct vivi_dmaqueue *dma_q)
+{
+ struct vivi_buffer *buf;
+ struct vivi_dev *dev= container_of(dma_q,struct vivi_dev,vidq);
+
+ int bc;
+
+ /* Announces videobuf that all went ok */
+ for (bc = 0;; bc++) {
+ if (list_empty(&dma_q->active)) {
+ dprintk(1,"No active queue to serve\n");
+ break;
+ }
+
+ buf = list_entry(dma_q->active.next,
+ struct vivi_buffer, vb.queue);
+
+ /* Nobody is waiting something to be done, just return */
+ if (!waitqueue_active(&buf->vb.done)) {
+ mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
+ return;
+ }
+
+ do_gettimeofday(&buf->vb.ts);
+ dprintk(2,"[%p/%d] wakeup\n",buf,buf->vb.i);
+
+ /* Fill buffer */
+ vivi_fillbuff(dev,buf);
+ }
+ if (list_empty(&dma_q->active)) {
+ del_timer(&dma_q->timeout);
+ } else {
+ mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
+ }
+ if (bc != 1)
+ dprintk(1,"%s: %d buffers handled (should be 1)\n",__FUNCTION__,bc);
+}
+
+void vivi_sleep(struct vivi_dmaqueue *dma_q)
+{
+ int timeout;
+ DECLARE_WAITQUEUE(wait, current);
+
+ dprintk(1,"%s dma_q=0x%08lx\n",__FUNCTION__,(unsigned long)dma_q);
+
+ add_wait_queue(&dma_q->wq, &wait);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ if (!(q->rmmod || signal_pending(current))) {
+#else
+ if (!kthread_should_stop()) {
+#endif
+ dma_q->frame++;
+
+ /* Calculate time to wake up */
+ timeout=dma_q->ini_jiffies+msecs_to_jiffies((dma_q->frame*WAKE_NUMERATOR*1000)/WAKE_DENOMINATOR)-jiffies;
+
+ if (timeout <= 0) {
+ int old=dma_q->frame;
+ dma_q->frame=(jiffies_to_msecs(jiffies-dma_q->ini_jiffies)*WAKE_DENOMINATOR)/(WAKE_NUMERATOR*1000)+1;
+
+ timeout=dma_q->ini_jiffies+msecs_to_jiffies((dma_q->frame*WAKE_NUMERATOR*1000)/WAKE_DENOMINATOR)-jiffies;
+
+ dprintk(1,"underrun, losed %d frames. "
+ "Now, frame is %d. Waking on %d jiffies\n",
+ dma_q->frame-old,dma_q->frame,timeout);
+ } else
+ dprintk(1,"will sleep for %i jiffies\n",timeout);
+
+ vivi_thread_tick(dma_q);
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13)
+ schedule_timeout_interruptible (timeout);
+#else
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(timeout);
+#endif
+ }
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,12)) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
+ if (current->flags & PF_FREEZE) {
+ refrigerator (PF_FREEZE);
+ }
+#endif
+
+ remove_wait_queue(&dma_q->wq, &wait);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12)
+ try_to_freeze();
+#endif
+}
+
+int vivi_thread(void *data)
+{
+ struct vivi_dmaqueue *dma_q=data;
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ daemonize();
+ exit_files(current);
+ reparent_to_init();
+
+ spin_lock_irq(SIGMASK_LOCK(current));
+ sigfillset(&current->blocked);
+ spin_unlock_irq(SIGMASK_LOCK(current));
+ strcpy(current->comm, "vivi");
+
+ dma_q->kthread = current;
+ if (dma_q->notify != NULL)
+ up(dma_q->notify);
+#endif
+ dprintk(1,"thread started\n");
+
+ for (;;) {
+ vivi_sleep(dma_q);
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ if (dma_q->rmmod || signal_pending(current))
+#else
+ if (kthread_should_stop())
+#endif
+ break;
+ }
+ dprintk(1, "thread: exit\n");
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ dma_q->kthread = NULL;
+
+ if (dma_q->notify != NULL)
+ up(dma_q->notify);
+#endif
+ return 0;
+}
+
+int vivi_start_thread(struct vivi_dmaqueue *dma_q)
+{
+ dma_q->frame=0;
+ dma_q->ini_jiffies=jiffies;
+
+ dprintk(1,"%s\n",__FUNCTION__);
+ init_waitqueue_head(&dma_q->wq);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ dma_q->kthread = kthread_run(vivi_thread, dma_q, "vivi");
+
+ if (dma_q->kthread == NULL) {
+ printk(KERN_ERR "vivi: kernel_thread() failed\n");
+ return -EINVAL;
+ }
+#else
+ DECLARE_MUTEX_LOCKED(sem);
+
+ dma_q->kthread = NULL;
+ dma_q->notify = &sem;
+ kernel_thread(vivi_thread, dma_q, 0);
+ down(&sem);
+ dma_q->notify = NULL;
+#endif
+ dprintk(1,"returning from %s\n",__FUNCTION__);
+ return 0;
+}
+
+void vivi_stop_thread(struct vivi_dmaqueue *dma_q)
+{
+ dprintk(1,"%s\n",__FUNCTION__);
+ /* shutdown control thread */
+ if (dma_q->kthread) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ DECLARE_MUTEX_LOCKED(sem);
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ /* shutdown control thread */
+ dma_q->notify = &sem;
+ dma_q->rmmod = 1;
+ wake_up_interruptible(&dma_q->wq);
+ down(&sem);
+ dma_q->notify = NULL;
+#else
+ kthread_stop(dma_q->kthread);
+#endif
+ dma_q->kthread=NULL;
+ }
+}
+
+static int restart_video_queue(struct vivi_dmaqueue *dma_q)
+{
+ struct vivi_buffer *buf, *prev;
+ struct list_head *item;
+
+ dprintk(1,"%s dma_q=0x%08lx\n",__FUNCTION__,(unsigned long)dma_q);
+
+ if (!list_empty(&dma_q->active)) {
+ buf = list_entry(dma_q->active.next, struct vivi_buffer, vb.queue);
+ dprintk(2,"restart_queue [%p/%d]: restart dma\n",
+ buf, buf->vb.i);
+
+ dprintk(1,"Restarting video dma\n");
+ vivi_stop_thread(dma_q);
+// vivi_start_thread(dma_q);
+
+ /* cancel all outstanding capture / vbi requests */
+ list_for_each(item,&dma_q->active) {
+ buf = list_entry(item, struct vivi_buffer, vb.queue);
+
+ list_del(&buf->vb.queue);
+ buf->vb.state = STATE_ERROR;
+ wake_up(&buf->vb.done);
+ }
+ mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
+
+ return 0;
+ }
+
+ prev = NULL;
+ for (;;) {
+ if (list_empty(&dma_q->queued))
+ return 0;
+ buf = list_entry(dma_q->queued.next, struct vivi_buffer, vb.queue);
+ if (NULL == prev) {
+ list_del(&buf->vb.queue);
+ list_add_tail(&buf->vb.queue,&dma_q->active);
+
+ dprintk(1,"Restarting video dma\n");
+ vivi_stop_thread(dma_q);
+ vivi_start_thread(dma_q);
+
+ buf->vb.state = STATE_ACTIVE;
+ mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
+ dprintk(2,"[%p/%d] restart_queue - first active\n",
+ buf,buf->vb.i);
+
+ } else if (prev->vb.width == buf->vb.width &&
+ prev->vb.height == buf->vb.height &&
+ prev->fmt == buf->fmt) {
+ list_del(&buf->vb.queue);
+ list_add_tail(&buf->vb.queue,&dma_q->active);
+ buf->vb.state = STATE_ACTIVE;
+ dprintk(2,"[%p/%d] restart_queue - move to active\n",
+ buf,buf->vb.i);
+ } else {
+ return 0;
+ }
+ prev = buf;
+ }
+}
+
+static void vivi_vid_timeout(unsigned long data)
+{
+ struct vivi_dev *dev = (struct vivi_dev*)data;
+ struct vivi_dmaqueue *vidq = &dev->vidq;
+ struct vivi_buffer *buf;
+
+ while (!list_empty(&vidq->active)) {
+ buf = list_entry(vidq->active.next, struct vivi_buffer, vb.queue);
+ list_del(&buf->vb.queue);
+ buf->vb.state = STATE_ERROR;
+ wake_up(&buf->vb.done);
+ printk("vivi/0: [%p/%d] timeout\n", buf, buf->vb.i);
+ }
+
+ restart_video_queue(vidq);
+}
+
+/* ------------------------------------------------------------------
+ Videobuf operations
+ ------------------------------------------------------------------*/
+static int
+buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
+{
+ struct vivi_fh *fh = vq->priv_data;
+
+ *size = fh->width*fh->height*2;
+
+ if (0 == *count)
+ *count = 32;
+ while (*size * *count > vid_limit * 1024 * 1024)
+ (*count)--;
+ return 0;
+}
+
+void
+free_buffer(struct videobuf_queue *vq, struct vivi_buffer *buf)
+{
+ dprintk(1,"%s\n",__FUNCTION__);
+
+ if (in_interrupt())
+ BUG();
+
+ /*FIXME: Maybe a spinlock is required here */
+ kfree(buf->to_addr);
+ buf->to_addr=NULL;
+
+ videobuf_waiton(&buf->vb,0,0);
+ videobuf_dma_unmap(vq, &buf->vb.dma);
+ videobuf_dma_free(&buf->vb.dma);
+ buf->vb.state = STATE_NEEDS_INIT;
+}
+
+#define norm_maxw() 1024
+#define norm_maxh() 768
+static int
+buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
+ enum v4l2_field field)
+{
+ struct vivi_fh *fh = vq->priv_data;
+ struct vivi_buffer *buf = container_of(vb,struct vivi_buffer,vb);
+ int rc, init_buffer = 0;
+
+// dprintk(1,"%s, field=%d\n",__FUNCTION__,field);
+
+ BUG_ON(NULL == fh->fmt);
+ if (fh->width < 48 || fh->width > norm_maxw() ||
+ fh->height < 32 || fh->height > norm_maxh())
+ return -EINVAL;
+ buf->vb.size = fh->width*fh->height*2;
+ if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size)
+ return -EINVAL;
+
+ if (buf->fmt != fh->fmt ||
+ buf->vb.width != fh->width ||
+ buf->vb.height != fh->height ||
+ buf->vb.field != field) {
+ buf->fmt = fh->fmt;
+ buf->vb.width = fh->width;
+ buf->vb.height = fh->height;
+ buf->vb.field = field;
+ init_buffer = 1;
+ }
+
+ if (STATE_NEEDS_INIT == buf->vb.state) {
+ if (0 != (rc = videobuf_iolock(vq,&buf->vb,NULL)))
+ goto fail;
+ }
+
+ buf->vb.state = STATE_PREPARED;
+
+ if (NULL == (buf->to_addr = kmalloc(sizeof(*buf->to_addr) * vb->dma.nr_pages,GFP_KERNEL))) {
+ rc=-ENOMEM;
+ goto fail;
+ }
+
+ return 0;
+
+fail:
+ free_buffer(vq,buf);
+ return rc;
+}
+
+static void
+buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
+{
+ struct vivi_buffer *buf = container_of(vb,struct vivi_buffer,vb);
+ struct vivi_fh *fh = vq->priv_data;
+ struct vivi_dev *dev = fh->dev;
+ struct vivi_dmaqueue *vidq = &dev->vidq;
+ struct vivi_buffer *prev;
+
+ if (!list_empty(&vidq->queued)) {
+ dprintk(1,"adding vb queue=0x%08lx\n",(unsigned long)&buf->vb.queue);
+ list_add_tail(&buf->vb.queue,&vidq->queued);
+ buf->vb.state = STATE_QUEUED;
+ dprintk(2,"[%p/%d] buffer_queue - append to queued\n",
+ buf, buf->vb.i);
+ } else if (list_empty(&vidq->active)) {
+ list_add_tail(&buf->vb.queue,&vidq->active);
+
+ buf->vb.state = STATE_ACTIVE;
+ mod_timer(&vidq->timeout, jiffies+BUFFER_TIMEOUT);
+ dprintk(2,"[%p/%d] buffer_queue - first active\n",
+ buf, buf->vb.i);
+
+ vivi_start_thread(vidq);
+ } else {
+ prev = list_entry(vidq->active.prev, struct vivi_buffer, vb.queue);
+ if (prev->vb.width == buf->vb.width &&
+ prev->vb.height == buf->vb.height &&
+ prev->fmt == buf->fmt) {
+ list_add_tail(&buf->vb.queue,&vidq->active);
+ buf->vb.state = STATE_ACTIVE;
+ dprintk(2,"[%p/%d] buffer_queue - append to active\n",
+ buf, buf->vb.i);
+
+ } else {
+ list_add_tail(&buf->vb.queue,&vidq->queued);
+ buf->vb.state = STATE_QUEUED;
+ dprintk(2,"[%p/%d] buffer_queue - first queued\n",
+ buf, buf->vb.i);
+ }
+ }
+}
+
+static void buffer_release(struct videobuf_queue *vq, struct videobuf_buffer *vb)
+{
+ struct vivi_buffer *buf = container_of(vb,struct vivi_buffer,vb);
+ struct vivi_fh *fh = vq->priv_data;
+ struct vivi_dev *dev = (struct vivi_dev*)fh->dev;
+ struct vivi_dmaqueue *vidq = &dev->vidq;
+
+ dprintk(1,"%s\n",__FUNCTION__);
+
+ vivi_stop_thread(vidq);
+
+ free_buffer(vq,buf);
+}
+
+int vivi_map_sg (void *dev, struct scatterlist *sg, int nents,
+ int direction)
+{
+ int i;
+
+ dprintk(1,"%s, number of pages=%d\n",__FUNCTION__,nents);
+ BUG_ON(direction == DMA_NONE);
+
+ for (i = 0; i < nents; i++ ) {
+ BUG_ON(!sg[i].page);
+
+ sg[i].dma_address = page_to_phys(sg[i].page) + sg[i].offset;
+ }
+
+ return nents;
+}
+
+int vivi_unmap_sg(void *dev,struct scatterlist *sglist,int nr_pages,
+ int direction)
+{
+ dprintk(1,"%s\n",__FUNCTION__);
+ return 0;
+}
+
+int vivi_dma_sync_sg(void *dev,struct scatterlist *sglist,int nr_pages,
+ int direction)
+{
+// dprintk(1,"%s\n",__FUNCTION__);
+
+// flush_write_buffers();
+ return 0;
+}
+
+static struct videobuf_queue_ops vivi_video_qops = {
+ .buf_setup = buffer_setup,
+ .buf_prepare = buffer_prepare,
+ .buf_queue = buffer_queue,
+ .buf_release = buffer_release,
+
+ /* Non-pci handling routines */
+ .vb_map_sg = vivi_map_sg,
+ .vb_dma_sync_sg = vivi_dma_sync_sg,
+ .vb_unmap_sg = vivi_unmap_sg,
+};
+
+/* ------------------------------------------------------------------
+ IOCTL handling
+ ------------------------------------------------------------------*/
+
+static int vivi_try_fmt(struct vivi_dev *dev, struct vivi_fh *fh,
+ struct v4l2_format *f)
+{
+ struct vivi_fmt *fmt;
+ enum v4l2_field field;
+ unsigned int maxw, maxh;
+
+ if (format.fourcc != f->fmt.pix.pixelformat) {
+ dprintk(1,"Fourcc format invalid.\n");
+ return -EINVAL;
+ }
+ fmt=&format;
+
+ field = f->fmt.pix.field;
+
+ if (field == V4L2_FIELD_ANY) {
+// field=V4L2_FIELD_INTERLACED;
+ field=V4L2_FIELD_SEQ_TB;
+ } else if (V4L2_FIELD_INTERLACED != field) {
+ dprintk(1,"Field type invalid.\n");
+ return -EINVAL;
+ }
+
+ maxw = norm_maxw();
+ maxh = norm_maxh();
+
+ f->fmt.pix.field = field;
+ if (f->fmt.pix.height < 32)
+ f->fmt.pix.height = 32;
+ if (f->fmt.pix.height > maxh)
+ f->fmt.pix.height = maxh;
+ if (f->fmt.pix.width < 48)
+ f->fmt.pix.width = 48;
+ if (f->fmt.pix.width > maxw)
+ f->fmt.pix.width = maxw;
+ f->fmt.pix.width &= ~0x03;
+ f->fmt.pix.bytesperline =
+ (f->fmt.pix.width * fmt->depth) >> 3;
+ f->fmt.pix.sizeimage =
+ f->fmt.pix.height * f->fmt.pix.bytesperline;
+
+ return 0;
+}
+
+static int res_get(struct vivi_dev *dev, struct vivi_fh *fh)
+{
+ /* is it free? */
+ down(&dev->lock);
+ if (dev->resources) {
+ /* no, someone else uses it */
+ up(&dev->lock);
+ return 0;
+ }
+ /* it's free, grab it */
+ dev->resources =1;
+ dprintk(1,"res: get\n");
+ up(&dev->lock);
+ return 1;
+}
+
+static inline int res_locked(struct vivi_dev *dev)
+{
+ return (dev->resources);
+}
+
+static void res_free(struct vivi_dev *dev, struct vivi_fh *fh)
+{
+ down(&dev->lock);
+ dev->resources = 0;
+ dprintk(1,"res: put\n");
+ up(&dev->lock);
+}
+
+static int vivi_do_ioctl(struct inode *inode, struct file *file, unsigned int cmd, void *arg)
+{
+ struct vivi_fh *fh = file->private_data;
+ struct vivi_dev *dev = fh->dev;
+ int ret=0;
+
+ if (debug) {
+ if (_IOC_DIR(cmd) & _IOC_WRITE)
+ v4l_printk_ioctl_arg("vivi(w)",cmd, arg);
+ else if (!_IOC_DIR(cmd) & _IOC_READ) {
+ v4l_print_ioctl("vivi", cmd);
+ }
+ }
+
+ switch(cmd) {
+ /* --- capabilities ------------------------------------------ */
+ case VIDIOC_QUERYCAP:
+ {
+ struct v4l2_capability *cap = (struct v4l2_capability*)arg;
+
+ memset(cap, 0, sizeof(*cap));
+
+ strcpy(cap->driver, "vivi");
+ strcpy(cap->card, "vivi");
+ cap->version = VIVI_VERSION;
+ cap->capabilities =
+ V4L2_CAP_VIDEO_CAPTURE |
+ V4L2_CAP_STREAMING |
+ V4L2_CAP_READWRITE;
+ break;
+ }
+ /* --- capture ioctls ---------------------------------------- */
+ case VIDIOC_ENUM_FMT:
+ {
+ struct v4l2_fmtdesc *f = arg;
+ enum v4l2_buf_type type;
+ unsigned int index;
+
+ index = f->index;
+ type = f->type;
+
+ if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ ret=-EINVAL;
+ break;
+ }
+
+ switch (type) {
+ case V4L2_BUF_TYPE_VIDEO_CAPTURE:
+ if (index > 0){
+ ret=-EINVAL;
+ break;
+ }
+ memset(f,0,sizeof(*f));
+
+ f->index = index;
+ f->type = type;
+ strlcpy(f->description,format.name,sizeof(f->description));
+ f->pixelformat = format.fourcc;
+ break;
+ default:
+ ret=-EINVAL;
+ }
+ break;
+ }
+ case VIDIOC_G_FMT:
+ {
+ struct v4l2_format *f = (struct v4l2_format *)arg;
+
+ if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ ret=-EINVAL;
+ break;
+ }
+
+ memset(&f->fmt.pix,0,sizeof(f->fmt.pix));
+ f->fmt.pix.width = fh->width;
+ f->fmt.pix.height = fh->height;
+ f->fmt.pix.field = fh->vb_vidq.field;
+ f->fmt.pix.pixelformat = fh->fmt->fourcc;
+ f->fmt.pix.bytesperline =
+ (f->fmt.pix.width * fh->fmt->depth) >> 3;
+ f->fmt.pix.sizeimage =
+ f->fmt.pix.height * f->fmt.pix.bytesperline;
+ break;
+ }
+ case VIDIOC_S_FMT:
+ {
+ struct v4l2_format *f = arg;
+
+ if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ dprintk(1,"Only capture supported.\n");
+ ret=-EINVAL;
+ break;
+ }
+
+ ret = vivi_try_fmt(dev,fh,f);
+ if (ret < 0)
+ break;
+
+ fh->fmt = &format;
+ fh->width = f->fmt.pix.width;
+ fh->height = f->fmt.pix.height;
+ fh->vb_vidq.field = f->fmt.pix.field;
+ fh->type = f->type;
+
+ break;
+ }
+ case VIDIOC_TRY_FMT:
+ {
+ struct v4l2_format *f = arg;
+ if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ ret=-EINVAL;
+ break;
+ }
+
+ ret=vivi_try_fmt(dev,fh,f);
+ break;
+ }
+ case VIDIOC_REQBUFS:
+ if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ ret=-EINVAL;
+ break;
+ }
+ ret=videobuf_reqbufs(&fh->vb_vidq, arg);
+ break;
+ case VIDIOC_QUERYBUF:
+ if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ ret=-EINVAL;
+ break;
+ }
+ ret=videobuf_querybuf(&fh->vb_vidq, arg);
+ break;
+ case VIDIOC_QBUF:
+ if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ ret=-EINVAL;
+ break;
+ }
+ ret=videobuf_qbuf(&fh->vb_vidq, arg);
+ break;
+ case VIDIOC_DQBUF:
+ if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ ret=-EINVAL;
+ break;
+ }
+ ret=videobuf_dqbuf(&fh->vb_vidq, arg,
+ file->f_flags & O_NONBLOCK);
+ break;
+#ifdef HAVE_V4L1
+ /* --- streaming capture ------------------------------------- */
+ case VIDIOCGMBUF:
+ {
+ struct video_mbuf *mbuf = arg;
+ struct videobuf_queue *q=&fh->vb_vidq;
+ struct v4l2_requestbuffers req;
+ unsigned int i;
+
+ memset(&req,0,sizeof(req));
+ req.type = q->type;
+ req.count = 8;
+ req.memory = V4L2_MEMORY_MMAP;
+ ret = videobuf_reqbufs(q,&req);
+ if (ret < 0)
+ break;
+ memset(mbuf,0,sizeof(*mbuf));
+ mbuf->frames = req.count;
+ mbuf->size = 0;
+ for (i = 0; i < mbuf->frames; i++) {
+ mbuf->offsets[i] = q->bufs[i]->boff;
+ mbuf->size += q->bufs[i]->bsize;
+ }
+ break;
+ }
+#endif
+ case VIDIOC_STREAMON:
+ {
+ if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+ return -EINVAL;
+ if (!res_get(dev,fh))
+ return -EBUSY;
+ ret=videobuf_streamon(&fh->vb_vidq);
+ break;
+ }
+ case VIDIOC_STREAMOFF:
+ {
+ if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ ret=-EINVAL;
+ break;
+ }
+ ret = videobuf_streamoff(&fh->vb_vidq);
+ if (ret < 0)
+ break;
+ res_free(dev,fh);
+ break;
+ }
+ /* ---------- tv norms ---------- */
+ case VIDIOC_ENUMSTD:
+ {
+ struct v4l2_standard *e = arg;
+
+ if (e->index>0) {
+ ret=-EINVAL;
+ break;
+ }
+ ret = v4l2_video_std_construct(e, V4L2_STD_NTSC_M, "NTSC-M");
+
+ /* Allows vivi to use different fps from video std */
+ e->frameperiod.numerator = WAKE_NUMERATOR;
+ e->frameperiod.denominator = WAKE_DENOMINATOR;
+
+ break;
+ }
+ case VIDIOC_G_STD:
+ {
+ v4l2_std_id *id = arg;
+
+ *id = V4L2_STD_NTSC_M;
+ break;
+ }
+ case VIDIOC_S_STD:
+ {
+ break;
+ }
+ /* ------ input switching ---------- */
+ case VIDIOC_ENUMINPUT:
+ { /* only one input in this sample driver */
+ struct v4l2_input *inp = arg;
+
+ if (inp->index != 0) {
+ ret=-EINVAL;
+ break;
+ }
+ memset(inp, 0, sizeof(*inp));
+
+ inp->index = 0;
+ inp->type = V4L2_INPUT_TYPE_CAMERA;
+ inp->std = V4L2_STD_NTSC_M;
+ strcpy(inp->name,"Camera");
+ break;
+ }
+ case VIDIOC_G_INPUT:
+ {
+ unsigned int *i = arg;
+
+ *i = 0;
+ break;
+ }
+ case VIDIOC_S_INPUT:
+ {
+ unsigned int *i = arg;
+
+ if (*i > 0)
+ ret=-EINVAL;
+ break;
+ }
+
+ /* --- controls ---------------------------------------------- */
+ case VIDIOC_QUERYCTRL:
+ {
+ struct v4l2_queryctrl *qc = arg;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
+ if (qc->id && qc->id == vivi_qctrl[i].id) {
+ memcpy(qc, &(vivi_qctrl[i]),
+ sizeof(*qc));
+ break;
+ }
+
+ ret=-EINVAL;
+ break;
+ }
+ case VIDIOC_G_CTRL:
+ {
+ struct v4l2_control *ctrl = arg;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
+ if (ctrl->id == vivi_qctrl[i].id) {
+ ctrl->value=qctl_regs[i];
+ break;
+ }
+
+ ret=-EINVAL;
+ break;
+ }
+ case VIDIOC_S_CTRL:
+ {
+ struct v4l2_control *ctrl = arg;
+ int i;
+ for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
+ if (ctrl->id == vivi_qctrl[i].id) {
+ if (ctrl->value <
+ vivi_qctrl[i].minimum
+ || ctrl->value >
+ vivi_qctrl[i].maximum) {
+ ret=-ERANGE;
+ break;
+ }
+ qctl_regs[i]=ctrl->value;
+ break;
+ }
+ ret=-EINVAL;
+ break;
+ }
+ default:
+ ret=v4l_compat_translate_ioctl(inode,file,cmd,arg,vivi_do_ioctl);
+ }
+
+ if (debug) {
+ if (ret<0) {
+ v4l_print_ioctl("vivi(err)", cmd);
+ dprintk(1,"errcode=%d\n",ret);
+ } else if (_IOC_DIR(cmd) & _IOC_READ)
+ v4l_printk_ioctl_arg("vivi(r)",cmd, arg);
+ }
+
+ return ret;
+}
+
+static int vivi_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+{
+ return video_usercopy(inode, file, cmd, arg, vivi_do_ioctl);
+}
+
+/* ------------------------------------------------------------------
+ File operations for the device
+ ------------------------------------------------------------------*/
+
+#define line_buf_size(norm) (norm_maxw(norm)*(format.depth+7)/8)
+
+static int vivi_open(struct inode *inode, struct file *file)
+{
+ int minor = iminor(inode);
+ struct vivi_dev *h,*dev = NULL;
+ struct vivi_fh *fh;
+ struct list_head *list;
+ enum v4l2_buf_type type = 0;
+ int i;
+
+ printk(KERN_DEBUG "vivi: open called (minor=%d)\n",minor);
+
+ list_for_each(list,&vivi_devlist) {
+ h = list_entry(list, struct vivi_dev, vivi_devlist);
+ if (h->video_dev.minor == minor) {
+ dev = h;
+ type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ }
+ }
+ if (NULL == dev)
+ return -ENODEV;
+
+#if 0 /* Avoids an oops at read() - seems to be semaphore related */
+ if (dev->users) {
+ printk(KERN_INFO "this driver can be opened only once (users=%d)\n",dev->users);
+ return -EBUSY;
+ }
+#endif
+
+ /* If more than one user, mutex should be added */
+ dev->users++;
+
+ dprintk(1,"open minor=%d type=%s users=%d\n",
+ minor,v4l2_type_names[type],dev->users);
+
+ /* allocate + initialize per filehandle data */
+ fh = kzalloc(sizeof(*fh),GFP_KERNEL);
+ if (NULL == fh) {
+ dev->users--;
+ return -ENOMEM;
+ }
+
+ file->private_data = fh;
+ fh->dev = dev;
+ fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ fh->fmt = &format;
+ fh->width = 640;
+ fh->height = 480;
+
+ /* Put all controls at a sane state */
+ for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
+ qctl_regs[i] =vivi_qctrl[i].default_value;
+
+ dprintk(1,"Open: fh=0x%08lx, dev=0x%08lx, dev->vidq=0x%08lx\n",
+ (unsigned long)fh,(unsigned long)dev,(unsigned long)&dev->vidq);
+ dprintk(1,"Open: list_empty queued=%d\n",list_empty(&dev->vidq.queued));
+ dprintk(1,"Open: list_empty active=%d\n",list_empty(&dev->vidq.active));
+
+ /* Resets frame counters */
+ dev->h=0;
+ dev->m=0;
+ dev->s=0;
+ dev->us=0;
+ dev->jiffies=jiffies;
+ sprintf(dev->timestr,"%02d:%02d:%02d:%03d",
+ dev->h,dev->m,dev->s,(dev->us+500)/1000);
+
+ videobuf_queue_init(&fh->vb_vidq, &vivi_video_qops,
+ NULL, NULL,
+ fh->type,
+ V4L2_FIELD_INTERLACED,
+ sizeof(struct vivi_buffer),fh);
+
+ return 0;
+}
+
+static ssize_t
+vivi_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
+{
+ struct vivi_fh *fh = file->private_data;
+
+ if (fh->type==V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ if (res_locked(fh->dev))
+ return -EBUSY;
+ return videobuf_read_one(&fh->vb_vidq, data, count, ppos,
+ file->f_flags & O_NONBLOCK);
+ }
+ return 0;
+}
+
+static unsigned int
+vivi_poll(struct file *file, struct poll_table_struct *wait)
+{
+ struct vivi_fh *fh = file->private_data;
+ struct vivi_buffer *buf;
+
+ dprintk(1,"%s\n",__FUNCTION__);
+
+ if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type)
+ return POLLERR;
+
+ if (res_get(fh->dev,fh)) {
+ dprintk(1,"poll: mmap interface\n");
+ /* streaming capture */
+ if (list_empty(&fh->vb_vidq.stream))
+ return POLLERR;
+ buf = list_entry(fh->vb_vidq.stream.next,struct vivi_buffer,vb.stream);
+ } else {
+ dprintk(1,"poll: read() interface\n");
+ /* read() capture */
+ buf = (struct vivi_buffer*)fh->vb_vidq.read_buf;
+ if (NULL == buf)
+ return POLLERR;
+ }
+ poll_wait(file, &buf->vb.done, wait);
+ if (buf->vb.state == STATE_DONE ||
+ buf->vb.state == STATE_ERROR)
+ return POLLIN|POLLRDNORM;
+ return 0;
+}
+
+static int vivi_release(struct inode *inode, struct file *file)
+{
+ struct vivi_fh *fh = file->private_data;
+ struct vivi_dev *dev = fh->dev;
+ struct vivi_dmaqueue *vidq = &dev->vidq;
+
+ int minor = iminor(inode);
+
+ vivi_stop_thread(vidq);
+ videobuf_mmap_free(&fh->vb_vidq);
+
+ kfree (fh);
+
+ dev->users--;
+
+ printk(KERN_DEBUG "vivi: close called (minor=%d, users=%d)\n",minor,dev->users);
+
+ return 0;
+}
+
+static int
+vivi_mmap(struct file *file, struct vm_area_struct * vma)
+{
+ struct vivi_fh *fh = file->private_data;
+ int ret;
+
+ dprintk (1,"mmap called, vma=0x%08lx\n",(unsigned long)vma);
+
+ ret=videobuf_mmap_mapper(&fh->vb_vidq, vma);
+
+ dprintk (1,"vma start=0x%08lx, size=%ld, ret=%d\n",
+ (unsigned long)vma->vm_start,
+ (unsigned long)vma->vm_end-(unsigned long)vma->vm_start,
+ ret);
+
+ return ret;
+}
+
+static struct file_operations vivi_fops = {
+ .owner = THIS_MODULE,
+ .open = vivi_open,
+ .release = vivi_release,
+ .read = vivi_read,
+ .poll = vivi_poll,
+ .ioctl = vivi_ioctl,
+ .mmap = vivi_mmap,
+ .llseek = no_llseek,
+};
+
+static struct video_device vivi = {
+ .name = "VTM Virtual Video Capture Board",
+ .type = VID_TYPE_CAPTURE,
+ .hardware = 0,
+ .fops = &vivi_fops,
+ .minor = -1,
+// .release = video_device_release,
+};
+/* ------------------------------------------------------------------
+ Initialization and module stuff
+ ------------------------------------------------------------------*/
+
+static int __init vivi_init(void)
+{
+ int ret;
+ struct vivi_dev *dev;
+
+ dev = kzalloc(sizeof(*dev),GFP_KERNEL);
+ if (NULL == dev)
+ return -ENOMEM;
+ list_add_tail(&dev->vivi_devlist,&vivi_devlist);
+
+ /* init video dma queues */
+ INIT_LIST_HEAD(&dev->vidq.active);
+ INIT_LIST_HEAD(&dev->vidq.queued);
+
+ /* initialize locks */
+ init_MUTEX(&dev->lock);
+
+ dev->vidq.timeout.function = vivi_vid_timeout;
+ dev->vidq.timeout.data = (unsigned long)dev;
+ init_timer(&dev->vidq.timeout);
+
+ ret = video_register_device(&vivi, VFL_TYPE_GRABBER, video_nr);
+ printk(KERN_INFO "Video Technology Magazine Virtual Video Capture Board (Load status: %d)\n", ret);
+ return ret;
+}
+
+static void __exit vivi_exit(void)
+{
+ struct vivi_dev *h;
+ struct list_head *list;
+
+ list_for_each(list,&vivi_devlist) {
+ h = list_entry(list, struct vivi_dev, vivi_devlist);
+ kfree (h);
+ }
+ video_unregister_device(&vivi);
+}
+
+module_init(vivi_init);
+module_exit(vivi_exit);
diff --git a/linux/include/linux/dvb/video.h b/linux/include/linux/dvb/video.h
index 1f7fa0351..faebfda39 100644
--- a/linux/include/linux/dvb/video.h
+++ b/linux/include/linux/dvb/video.h
@@ -135,7 +135,7 @@ typedef struct video_spu {
typedef struct video_spu_palette { /* SPU Palette information */
int length;
- uint8_t *palette;
+ uint8_t __user *palette;
} video_spu_palette_t;
diff --git a/linux/include/linux/videodev2.h b/linux/include/linux/videodev2.h
index 1b76d3e9a..2995bf836 100644
--- a/linux/include/linux/videodev2.h
+++ b/linux/include/linux/videodev2.h
@@ -592,7 +592,7 @@ struct v4l2_framebuffer
struct v4l2_clip
{
struct v4l2_rect c;
- struct v4l2_clip *next;
+ struct v4l2_clip __user *next;
};
struct v4l2_window
diff --git a/linux/include/media/saa7146_vv.h b/linux/include/media/saa7146_vv.h
index e5e749e98..4507cb61a 100644
--- a/linux/include/media/saa7146_vv.h
+++ b/linux/include/media/saa7146_vv.h
@@ -197,7 +197,8 @@ void saa7146_buffer_finish(struct saa7146_dev *dev, struct saa7146_dmaqueue *q,
void saa7146_buffer_next(struct saa7146_dev *dev, struct saa7146_dmaqueue *q,int vbi);
int saa7146_buffer_queue(struct saa7146_dev *dev, struct saa7146_dmaqueue *q, struct saa7146_buf *buf);
void saa7146_buffer_timeout(unsigned long data);
-void saa7146_dma_free(struct saa7146_dev *dev,struct saa7146_buf *buf);
+void saa7146_dma_free(struct saa7146_dev* dev,struct videobuf_queue *q,
+ struct saa7146_buf *buf);
int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv);
int saa7146_vv_release(struct saa7146_dev* dev);
diff --git a/linux/include/media/tuner.h b/linux/include/media/tuner.h
index 2e5e8c25c..a5471fa67 100644
--- a/linux/include/media/tuner.h
+++ b/linux/include/media/tuner.h
@@ -111,15 +111,16 @@
#define TUNER_LG_TDVS_H062F 64 /* DViCO FusionHDTV 5 */
#define TUNER_YMEC_TVF66T5_B_DFF 65 /* Acorp Y878F */
-#define TUNER_LG_NTSC_TALN_MINI 66
+#define TUNER_LG_TALN 66
#define TUNER_PHILIPS_TD1316 67
#define TUNER_PHILIPS_TUV1236D 68 /* ATI HDTV Wonder */
#define TUNER_TNF_5335MF 69 /* Sabrent Bt848 */
#define TUNER_SAMSUNG_TCPN_2121P30A 70 /* Hauppauge PVR-500MCE NTSC */
-
#define TUNER_XCEIVE_XC3028 71
+#define TUNER_THOMSON_FE6600 72 /* DViCO FusionHDTV DVB-T Hybrid */
+
/* tv card specific */
#define TDA9887_PRESENT (1<<0)
#define TDA9887_PORT1_INACTIVE (1<<1)
diff --git a/linux/include/media/v4l2-common.h b/linux/include/media/v4l2-common.h
index a69118bbc..9ddebdd2a 100644
--- a/linux/include/media/v4l2-common.h
+++ b/linux/include/media/v4l2-common.h
@@ -109,6 +109,7 @@ enum v4l2_chip_ident {
V4L2_IDENT_UNKNOWN = 0,
/* module saa7115: reserved range 100-149 */
+ V4L2_IDENT_SAA7113 = 103,
V4L2_IDENT_SAA7114 = 104,
V4L2_IDENT_SAA7115 = 105,
diff --git a/linux/include/media/video-buf.h b/linux/include/media/video-buf.h
index dd2bb1800..c6be316ce 100644
--- a/linux/include/media/video-buf.h
+++ b/linux/include/media/video-buf.h
@@ -2,15 +2,20 @@
* $Id: video-buf.h,v 1.11 2005/10/17 21:18:42 mchehab Exp $
*
* generic helper functions for video4linux capture buffers, to handle
- * memory management and PCI DMA. Right now bttv + saa7134 use it.
+ * memory management and PCI DMA.
+ * Right now, bttv, saa7134, saa7146 and cx88 use it.
*
* The functions expect the hardware being able to scatter gatter
* (i.e. the buffers are not linear in physical memory, but fragmented
* into PAGE_SIZE chunks). They also assume the driver does not need
- * to touch the video data (thus it is probably not useful for USB as
- * data often must be uncompressed by the drivers).
+ * to touch the video data.
+ *
+ * device specific map/unmap/sync stuff now are mapped as file operations
+ * to allow its usage by USB and virtual devices.
*
* (c) 2001,02 Gerd Knorr <kraxel@bytesex.org>
+ * (c) 2006 Mauro Carvalho Chehab, <mchehab@infradead.org>
+ * (c) 2006 Ted Walther and John Sokol
*
* 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
@@ -39,6 +44,9 @@ struct scatterlist* videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages);
struct scatterlist* videobuf_pages_to_sg(struct page **pages, int nr_pages,
int offset);
+struct videobuf_buffer;
+struct videobuf_queue;
+
/* --------------------------------------------------------------------- */
/*
@@ -50,7 +58,7 @@ struct scatterlist* videobuf_pages_to_sg(struct page **pages, int nr_pages,
* pointer + length. The kernel version just wants the size and
* does memory allocation too using vmalloc_32().
*
- * videobuf_dma_pci_*()
+ * videobuf_dma_*()
* see Documentation/DMA-mapping.txt, these functions to
* basically the same. The map function does also build a
* scatterlist for the buffer (and unmap frees it ...)
@@ -87,12 +95,18 @@ int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction,
int nr_pages);
int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction,
dma_addr_t addr, int nr_pages);
-int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma);
-int videobuf_dma_pci_sync(struct pci_dev *dev,
- struct videobuf_dmabuf *dma);
-int videobuf_dma_pci_unmap(struct pci_dev *dev, struct videobuf_dmabuf *dma);
int videobuf_dma_free(struct videobuf_dmabuf *dma);
+int videobuf_dma_map(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
+int videobuf_dma_sync(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
+int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
+
+ /*FIXME: these variants are used only on *-alsa code, where videobuf is
+ * used without queue
+ */
+int videobuf_pci_dma_map(struct pci_dev *pci,struct videobuf_dmabuf *dma);
+int videobuf_pci_dma_unmap(struct pci_dev *pci,struct videobuf_dmabuf *dma);
+
/* --------------------------------------------------------------------- */
/*
@@ -116,9 +130,6 @@ int videobuf_dma_free(struct videobuf_dmabuf *dma);
*
*/
-struct videobuf_buffer;
-struct videobuf_queue;
-
struct videobuf_mapping {
unsigned int count;
unsigned long start;
@@ -165,6 +176,10 @@ struct videobuf_buffer {
struct timeval ts;
};
+typedef int (vb_map_sg_t)(void *dev,struct scatterlist *sglist,int nr_pages,
+ int direction);
+
+
struct videobuf_queue_ops {
int (*buf_setup)(struct videobuf_queue *q,
unsigned int *count, unsigned int *size);
@@ -175,6 +190,14 @@ struct videobuf_queue_ops {
struct videobuf_buffer *vb);
void (*buf_release)(struct videobuf_queue *q,
struct videobuf_buffer *vb);
+
+ /* Helper operations - device dependent.
+ * If null, videobuf_init defaults all to PCI handling
+ */
+
+ vb_map_sg_t *vb_map_sg;
+ vb_map_sg_t *vb_dma_sync_sg;
+ vb_map_sg_t *vb_unmap_sg;
};
struct videobuf_queue {
@@ -184,7 +207,7 @@ struct videobuf_queue {
struct semaphore lock;
#endif
spinlock_t *irqlock;
- struct pci_dev *pci;
+ void *dev; /* on pci, points to struct pci_dev */
enum v4l2_buf_type type;
unsigned int inputs; /* for V4L2_BUF_FLAG_INPUT */
@@ -209,12 +232,15 @@ struct videobuf_queue {
void* videobuf_alloc(unsigned int size);
int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr);
-int videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb,
- struct v4l2_framebuffer *fbuf);
+int videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb,
+ struct v4l2_framebuffer *fbuf);
+
+/* Maps fops to PCI stuff */
+void videobuf_queue_pci(struct videobuf_queue* q);
void videobuf_queue_init(struct videobuf_queue *q,
struct videobuf_queue_ops *ops,
- struct pci_dev *pci,
+ void *dev,
spinlock_t *irqlock,
enum v4l2_buf_type type,
enum v4l2_field field,
diff --git a/mailimport b/mailimport
new file mode 100755
index 000000000..e6e4df411
--- /dev/null
+++ b/mailimport
@@ -0,0 +1,167 @@
+#!/bin/bash
+# Copyright (c) 2006 Mauro Carvalho Chehab (mchehab@infradead.org)
+# This code is placed under the terms of the GNU General Public License
+#
+#This script is capable to mass import patches on a mbox file, test for it, allow
+#comment editing and applying it.
+#
+#This script requires:
+#1) git, since it uses gitimport to break a mbox into patches;
+#2) hg mailqueue. It is easier to manage patches using mq, allowing to work with
+# the patches before applying to the tree.
+
+#uncomment to use mq
+#usemq=1
+
+#uncomment to stop at the first error while testing a patch with --dry-run
+#exitonerror=1
+
+head=v4l/scripts/hghead.pl
+
+if [ "$1" == "" ]; then
+ echo "Usage: $0 <mbox>"
+ exit
+fi
+MBOX=$1
+
+if [ "$TMPDIR" == "" ]; then
+ TMPDIR=/tmp
+fi
+
+if [ "$EDITOR" == "" ]; then
+ EDITOR=nano
+fi
+
+DIR=$TMPDIR/mailimport$$
+mkdir $DIR
+if [ "$?" != "0" ]; then
+ echo "*** Error at mkdir $DIR"
+ exit;
+fi
+trap "rm -rf $DIR" EXIT
+TMP2=$DIR/patchheader
+
+apply_patch () {
+ next=$1
+
+ unset cont
+ until [ "$cont" == "0" ]; do
+ cont=1
+ pdir=linux
+ echo patch -s -t -p1 --dry-run -l -N -d $pdir -i $next
+ patch -s -t -p1 --dry-run -l -N -d $pdir -i $next
+ if [ "$?" != "0" ]; then
+ pdir=.
+ echo patch -s -t -p1 --dry-run -l -N -d $pdir -i $next
+ patch -s -t -p1 --dry-run -l -N -d $pdir -i $next
+ fi
+
+ if [ "$?" != "0" ]; then
+ echo "*** ERROR: Patch didn't applied well"
+ if [ "$exitonerror" != "" ]; then
+ $head $next
+ exit
+ fi
+ echo "** Edit file $next"
+ sleep 1
+ $EDITOR $next
+ else
+ echo "Patch applied OK against $pdir"
+ cont=0
+ fi
+ done
+
+ $EDITOR $next
+
+ unset cont
+ until [ "$cont" == "0" ]; do
+ cont=0
+ $head $next >$TMP2
+
+ if [ "`grep '^Bad:' $TMP2`" != "" ]; then
+ echo "*** ERROR: Patch bad formed. Please fix."
+ sleep 1
+ $EDITOR $next
+ cont=1
+ fi
+ done
+
+ make whitespace
+
+ committer=`grep "Committer:" $TMP2|sed s/"#Committer: "//`
+
+ if [ "$usemq" != "" ]; then
+ name=`cat $next | perl -ne '
+ if (s/Subject:\s+(.*)/$1/) {
+ m/\s*(.*)\s*\n/;
+ $_="$1";
+
+ tr/[A-Z]/[a-z]/;
+ s/[^a-z0-9]/_/g;
+ s/_+$//;
+ s/_+/_/g;
+ s/^v4l_dvb_\d+[a-z]*_//g;
+
+ printf "%s.patch",$_;
+ exit;
+ }'`
+
+ cat $next| grep -v "^#" >$TMPDIR/$name
+
+ echo hg -m "`cat $TMP2|grep -v "^#"`" qnew $name
+ hg qnew -m "`cat $TMP2|grep -v "^#"`" $name
+ hg qrefresh
+ else
+ patch -s -t -p1 -l -N -d $pdir -i $next
+ if [ "$?" != "0" ]; then
+ echo "*** ERROR at: patch -s -t -p1 -l -N -d $pdir -i $next"
+ exit
+ fi
+ cur=`pwd`
+ cd $pdir
+ hg addremove `diffstat -p1 -l $next`
+ if [ "$?" != "0" ]; then
+ echo "*** ERROR at hg addremove"
+ exit
+ fi
+ # Commit the changed files
+ hg commit -u "$committer" -m "`cat $TMP2|grep -v "^#"`" `diffstat -p1 -l $next`
+ if [ "$?" != "0" ]; then
+ echo "*** ERROR at hg commit"
+ cd $cur
+ exit
+ fi
+ cd $cur
+ fi
+}
+
+echo git-mailsplit $MBOX $DIR
+echo -n "Number of patches at file: "
+git-mailsplit $MBOX $DIR
+echo
+
+for i in $DIR/*; do
+ cat $i| git-mailinfo $DIR/msg $DIR/patch>$DIR/author
+ cat $DIR/msg|grep -vi ^CC: >$DIR/msg2
+
+ cat $DIR/author|perl -ne "if (m/Author[:]\\s*(.*)\\n/) { \$auth=\$1; } else \
+ { if (m/Email[:]\\s*(.*)\\n/) { print \"From: \$auth \<\$1\>\n\"; } else \
+ { if (m/Subject[:]\\s*(.*)\\n/) { \
+ \$sub=\$1; \
+ \$sub=~ s;^(media|dvb|v4l|video|drivers|[-_/: \\t])*(.*);\$2;; \
+ print \"Subject: \$sub\\n\"; \
+ } else \
+ { print; } } \
+ }" >$DIR/author2
+
+ out=$DIR/patch.diff
+
+ cat $DIR/author2
+
+ echo "Signed-off-by: $CHANGE_LOG_NAME <$CHANGE_LOG_EMAIL_ADDRESS>" >>$DIR/msg2
+
+ echo "cat $DIR/author2 $DIR/msg2 $DIR/patch >$out"
+ cat $DIR/author2 $DIR/msg2 $DIR/patch >$out
+
+ apply_patch $out
+done
diff --git a/v4l/Make.config b/v4l/Make.config
index 0dd4365ce..7d8ae8e8d 100644
--- a/v4l/Make.config
+++ b/v4l/Make.config
@@ -9,7 +9,6 @@ CONFIG_VIDEO_TVAUDIO := m
CONFIG_VIDEO_CX88 := m
CONFIG_TVP5150 := m
-CONFIG_SAA711X := m
#enable experimental support for xc3028 tuner
CONFIG_XC3028 := m
@@ -20,13 +19,18 @@ CONFIG_VIDEO_ALSA := y
CONFIG_VIDEO_ADV_DEBUG := y
-CONFIG_VIDEO_PVRUSB2 := n
+CONFIG_VIDEO_PVRUSB2 := m
CONFIG_VIDEO_IVTV := n
CONFIG_DVB_FIRESAT := n
-CONFIG_VIDEO_CPIA2 := m
+CONFIG_VIRTUAL_DEVICE := m
+CONFIG_VIDEO_CPIA2 := m
+
+CONFIG_VIDEO_CX88_IVTV := n
+
+CONFIG_VIDEO_MXB := m
# doesn't build on older kernels
@@ -112,4 +116,4 @@ ifeq ($(CONFIG_DVB_CORE),m)
endif
CONFIG_VIDEO_IVTV := $(if $(wildcard $(src)/ivtv-svnversion.h),m)
-CONFIG_VIDEO_PVRUSB2 := $(if $(wildcard $(src)/.pvrusb2-merge),m)
+CONFIG_VIDEO_CX88_IVTV := $(if $(wildcard $(src)/cx88-ivtv.c),m)
diff --git a/v4l/Makefile b/v4l/Makefile
index dcc8cc020..fd757e928 100644
--- a/v4l/Makefile
+++ b/v4l/Makefile
@@ -88,11 +88,15 @@ ifeq ($(CONFIG_VIDEO_DEV),m)
obj-m += videodev.o
endif
+obj-$(CONFIG_VIDEO_MXB) += mxb.o tea6420.o tea6415c.o tda9840.o
+obj-$(CONFIG_VIDEO_DPC) += dpc7146.o
+obj-$(CONFIG_VIDEO_HEXIUM_ORION)+= hexium_orion.o
+obj-$(CONFIG_VIDEO_HEXIUM_GEMINI)+= hexium_gemini.o
obj-$(CONFIG_VIDEO_BTTV) += btcx-risc.o ir-common.o bttv.o tveeprom.o
obj-$(CONFIG_VIDEO_CX88) += btcx-risc.o cx88xx.o cx8800.o cx8802.o \
cx88-blackbird.o tveeprom.o
+obj-$(CONFIG_VIDEO_CX88_IVTV) += cx88-ivtv.o
obj-$(CONFIG_TVP5150) += tvp5150.o
-obj-$(CONFIG_SAA711X) += saa711x.o
obj-$(CONFIG_EM28XX) += em28xx.o tveeprom.o
obj-$(CONFIG_VIDEO_DECODER) += saa7115.o cx25840.o saa7127.o bt832.o
@@ -104,6 +108,7 @@ ifeq ($(CONFIG_VIDEO_ALSA),y)
# obj-$(CONFIG_VIDEO_BTTV) += bt87x.o
endif
+obj-$(CONFIG_VIRTUAL_DEVICE) += vivi.o
obj-$(CONFIG_VIDEO_SAA7134) += saa7134.o saa7134-empress.o saa6752hs.o
obj-$(CONFIG_VIDEO_SAA7134) += saa7134-oss.o
obj-$(CONFIG_VIDEO_IR) += ir-common.o
@@ -122,7 +127,7 @@ obj-$(CONFIG_DVB_FRONTENDS) += dvb-pll.o cx22702.o or51132.o lgdt330x.o \
dib3000-common.o dib3000mb.o dib3000mc.o \
ves1820.o cx22700.o tda8083.o ves1x93.o \
stv0297.o sp8870.o l64781.o s5h1420.o \
- tda10021.o at76c651.o tda80xx.o
+ tda10021.o at76c651.o tda80xx.o zl10353.o
obj-$(CONFIG_DVB_CORE) += dvb-core.o
obj-$(CONFIG_DVB_B2C2_FLEXCOP) += b2c2-flexcop.o
obj-$(CONFIG_DVB_B2C2_FLEXCOP) += stv0297_cs2.o
@@ -187,6 +192,7 @@ ifeq ($(CONFIG_VIDEO_CX88_DVB),m)
EXTRA_CFLAGS += -DHAVE_OR51132=1
EXTRA_CFLAGS += -DHAVE_LGDT330X=1
EXTRA_CFLAGS += -DHAVE_MT352=1
+ EXTRA_CFLAGS += -DHAVE_ZL10353=1
EXTRA_CFLAGS += -DHAVE_NXT200X=1
EXTRA_CFLAGS += -DHAVE_CX24123=1
EXTRA_CFLAGS += -DHAVE_VP3054_I2C=1
@@ -216,6 +222,11 @@ $(obj)/av7110_firm.h: $(obj)/fdump
EXTRA_CFLAGS += -DCONFIG_DVB_AV7110_FIRMWARE_FILE
endif
+ifeq ($(ARCH),)
+ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
+ -e s/arm.*/arm/ -e s/sa110/arm/ \
+ -e s/s390x/s390/ -e s/parisc64/parisc/ )
+endif
#################################################
# compile modules
@@ -301,10 +312,11 @@ inst_video += tvmixer.ko v4l1-compat.ko v4l2-common.ko wm8775.ko cs53l32a.ko
inst_video += video-buf.ko video-buf-dvb.ko
inst_video += videodev.ko
inst_video += ir-kbd-i2c.ko msp3400.ko
-inst_video += tvp5150.ko saa711x.ko saa7134-alsa.ko saa7134-oss.ko
+inst_video += tvp5150.ko saa7134-alsa.ko saa7134-oss.ko
inst_video += saa7115.ko cx25840.ko saa7127.ko compat_ioctl32.ko
-inst_cx88 := cx8800.ko cx8802.ko cx88-alsa.ko
-inst_cx88 += cx88-blackbird.ko cx88xx.ko cx88-dvb.ko cx88-vp3054-i2c.ko
+inst_cx88 := cx88xx.ko cx8800.ko cx8802.ko cx88-alsa.ko cx88-dvb.ko
+inst_video += vivi.ko
+inst_cx88 += cx88-blackbird.ko cx88-vp3054-i2c.ko cx88-ivtv.ko
inst_saa7134 := saa6752hs.ko saa7134.ko saa7134-empress.ko saa7134-dvb.ko
inst_em28xx := em28xx.ko
inst_bt8xx := bt878.ko dvb-bt8xx.ko dst.ko dst_ca.ko
@@ -314,7 +326,7 @@ inst_frontends += nxt200x.ko cx24123.ko mt312.ko stv0299.ko
inst_frontends += bcm3510.ko dib3000mb.ko dib3000mc.ko ves1820.ko
inst_frontends += cx22700.ko tda8083.ko ves1x93.ko stv0297.ko sp8870.ko
inst_frontends += l64781.ko s5h1420.ko tda10021.ko at76c651.ko tda80xx.ko
-inst_frontends += stv0297_cs2.ko
+inst_frontends += stv0297_cs2.ko zl10353.ko
inst_dvb-core := dvb-core.ko
inst_saa7146 := saa7146.ko saa7146_vv.ko
inst_b2c2 := b2c2-flexcop.ko b2c2-flexcop-pci.ko b2c2-flexcop-usb.ko
@@ -343,10 +355,9 @@ all:: default
default:: links .version
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) $(MYCFLAGS) modules
-pvrusb2::
- @echo creating pvrusb2 symbolic links...
- @find ../v4l_experimental/pvrusb2 -name '*.[ch]' -type f -exec ln -sf '{}' . \;
- @echo 'm' > .pvrusb2-merge
+qconfig:: links .version
+ ./scripts/make_kconfig.pl /usr/src/linux-2.6.14 $(ARCH)
+ $(KDIR)/scripts/kconfig/qconf Kconfig
ivtv-checkout::
@if [ ! -d ivtv ]; then \
@@ -367,6 +378,10 @@ ivtv:: ivtv-links
@echo '#define IVTV_DRIVER_VERSION_COMMENT "(v4l-dvb + ivtv virtual merge)"' > ivtv-svnversion.h
@echo ivtv trunk merged. Run make to build the entire tree.
+cx88-ivtv::
+ @echo creating cx88-ivtv symbolic links...
+ @ln -sf ../v4l_experimental/cx88-ivtv.c .
+
links::
@echo creating symbolic links...
@find ../linux/drivers/media -name '*.[ch]' -type f -exec ln -sf '{}' . \;
@@ -521,7 +536,9 @@ rmmodules::
clean::
@find . -name '*.c' -type l -exec rm '{}' \;
@find . -name '*.h' -type l -exec rm '{}' \;
- -rm -f *~ *.o *.ko .*.o.cmd .*.ko.cmd *.mod.c av7110_firm.h fdump ivtv-svnversion.h .pvrusb2-merge
+ -rm -f *~ *.o *.ko .*.o.cmd .*.ko.cmd *.mod.c av7110_firm.h fdump \
+ ivtv-svnversion.h \
+ Kconfig Kconfig.kern .config .config.cmd
distclean:: clean
-rm -f .version .*.o.flags .*.o.d
diff --git a/v4l/scripts/hghead.pl b/v4l/scripts/hghead.pl
new file mode 100755
index 000000000..ddaef0767
--- /dev/null
+++ b/v4l/scripts/hghead.pl
@@ -0,0 +1,152 @@
+#!/usr/bin/perl
+use strict;
+use Date::Parse;
+
+#################################################################
+# analyse diffs
+
+my $in = shift;
+my $line;
+my $subject;
+my $from=0;
+my $sub_ok=0;
+my $init=0;
+my $num=0;
+my $maint_ok=0;
+my $noblank=1;
+my $maintainer_name=$ENV{CHANGE_LOG_NAME};
+my $maintainer_email=$ENV{CHANGE_LOG_EMAIL_ADDRESS};
+my $from="";
+my $body="";
+my $signed="";
+my $fromname="";
+
+open IN, "<$in";
+
+while ($line = <IN>) {
+ if ($line =~ m/Index.*/) {
+ last;
+ }
+ if ($line =~ m/^diff .*/) {
+ last;
+ }
+ if ($line =~ m/^\-\-\- .*/) {
+ last;
+ }
+ if ($line =~ m/^\-\-\-.*/) {
+ last;
+ }
+ if ($line =~ m/^\+\+\+ .*/) {
+ last;
+ }
+
+ if ($line =~ m/^Date:\s*(.*)/) {
+ my $time = str2time($1);
+# my $timestr = gmtime($time);
+
+ if ($time) {
+ print "# Date: $time\n";
+ }
+ next;
+ }
+ if ($line =~ m/^From:/) {
+ if ($line =~ m/^From:[\s\"]*([^\"]*)[\s\"]*<(.*)>/) {
+ if ($1 eq "") {
+ next;
+ }
+ my $name=$1;
+ my $email=$2;
+ $name =~ s/\s+$//;
+ $email =~ s/\s+$//;
+ $fromname="$name <$email>";
+ $from= "From: $fromname\n";
+ next;
+ }
+ print "Bad: author line have a wrong syntax\n";
+ die;
+ }
+
+ if ($line =~ m/^Subject:\s*(.*\n)/) {
+ $subject=$1;
+ next;
+ }
+
+ if ($line =~ m;^ .*\/.*\| *[0-9]*;) {
+ next;
+ }
+ if ($line =~m/\d+\s*file.* changed, /) {
+ next;
+ }
+
+ if ($line =~ m/^Signed-off-by:.*/) {
+ $noblank=1;
+ if ($line =~ m/$maintainer_name/) {
+ $maint_ok=1;
+ }
+
+ $signed="$signed$line";
+ next;
+ }
+ if ($line =~ m/^Acked-by:.*/) {
+ $signed="$signed$line";
+ next;
+ }
+
+ if ($line =~ m/^[a-zA-Z\-]*:/) {
+ if ($line =~ m/Changeset:\s*(.*)\n/) {
+ $num=$1;
+ }
+ print "# $line";
+ next;
+ }
+
+ if ($line =~ m|^(V4L\/DVB\s*\(.+\)\s*:.*\n)|) {
+ $subject=$1;
+ $line="\n";
+ }
+
+ if ($sub_ok == 0) {
+ $sub_ok=1;
+ substr( $subject, 0, 1 ) = uc (substr ($subject, 0, 1));
+ if ($subject =~ m|V4L\/DVB\s*(.+)|) {
+ $subject=$1;
+ }
+ if ($line =~ m/^\n/) {
+ next;
+ }
+ }
+
+ if ($noblank) {
+ if ($line =~ m/^\n/) {
+ next;
+ }
+ }
+ if (!$init) {
+ $init=1;
+ $noblank=0;
+ }
+ $body="$body$line";
+}
+close IN;
+
+if ($from eq "") {
+ print "Bad: author doesn't exist!\n";
+ die;
+}
+
+if (!$maint_ok) {
+ $signed=$signed."Signed-off-by: $maintainer_name <$maintainer_email>\n";
+}
+
+if (!$signed =~ m/$from/) {
+ print "Bad: Author didn't signed his patch!\n";
+ die;
+}
+
+$body=~s/\n+$//;
+$body=~s/^\n+$//;
+
+# First from is used by hg to recognize commiter name
+print "#Committer: $maintainer_name <$maintainer_email>\n";
+print "$subject\n$from\n$body\n\n$signed";
+
diff --git a/v4l/scripts/insmod.sh b/v4l/scripts/insmod.sh
index bf22a69ce..e4ebb1494 100755
--- a/v4l/scripts/insmod.sh
+++ b/v4l/scripts/insmod.sh
@@ -122,6 +122,8 @@ case "$1" in
insmod ./saa6752hs.ko
insmod ./em28xx.ko
+ insmod ./vivi.ko
+
echo
;;
debug)
@@ -232,6 +234,7 @@ case "$1" in
insmod ./saa6752hs.ko
insmod ./em28xx.ko
+ insmod ./vivi.ko
echo
;;
unload)
@@ -246,7 +249,7 @@ case "$1" in
# video4linux cards
rmmod cx88-alsa cx88-blackbird cx88-dvb cx88-vp3054-i2c cx8802 cx8800 \
cx88xx saa7134-oss saa7134-alsa saa7134-empress saa7134-dvb \
- saa7134 dvb-bt8xx dst_ca dst bt878 bttv em28xx
+ saa7134 dvb-bt8xx dst_ca dst bt878 bttv em28xx vivi
# frontends
rmmod dib3000mb dib3000mc dib3000_common nxt200x ves1x93 \
diff --git a/v4l/scripts/make_kconfig.pl b/v4l/scripts/make_kconfig.pl
new file mode 100755
index 000000000..f612e83db
--- /dev/null
+++ b/v4l/scripts/make_kconfig.pl
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+use FileHandle;
+
+my $KDIR=shift;
+my $ARCH=shift;
+
+sub open_kconfig($$) {
+ my ($dir,$file)=@_;
+ my $in = new FileHandle;
+
+print "opening $file\n";
+ open $in,"$file";
+ while (<$in>) {
+ if (m;^\s*source[\s\"]+drivers/media/(video|dvb)/Kconfig;) {
+ next;
+ }
+ if (m|^\s*source[\s\"]+([^\n\s\"]+)[\n\s\"]|) {
+ open_kconfig($dir,"$dir/$1");
+ next;
+ }
+ s/^main(menu\s\"[^\"]+)/\1 - DON'T CHANGE IT!/;
+ print OUT $_;
+ }
+ close $in;
+}
+
+open OUT,">Kconfig.kern";
+open_kconfig($KDIR,"$KDIR/arch/$ARCH/Kconfig");
+print OUT "endmenu\n";
+close OUT;
+
+open OUT,">Kconfig";
+print OUT "mainmenu \"V4L/DVB menu\"\n";
+open_kconfig ("../linux","../linux/drivers/media/video/Kconfig");
+open_kconfig ("../linux","../linux/drivers/media/dvb/Kconfig");
+print OUT "source Kconfig.kern\n";
+close OUT;
diff --git a/v4l/scripts/usbaudio_setup.sh b/v4l/scripts/usbaudio_setup.sh
new file mode 100755
index 000000000..66fdd23df
--- /dev/null
+++ b/v4l/scripts/usbaudio_setup.sh
@@ -0,0 +1,106 @@
+#!/bin/bash
+#
+# Copyright (C) 2006 Markus Rechberger <mrechberger@gmail.com>
+#
+# 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.
+#
+
+which /usr/bin/dialog >/dev/null
+if [ "0" != "$?" ]; then
+echo "this tool requires \"dialog\" (http://hightek.org/dialog/)"
+exit 1
+fi
+uid=`id -u`
+if [ "0" != "$uid" ]; then
+echo "this tool must be run as root, you can disable this message by editing the script but only do that unless you know what you're doing!"
+exit 1
+fi
+which gcc > /dev/null
+if [ "0" != "$?" ]; then
+echo "this tool won't work unless you install gcc"
+exit 1
+fi
+test -f ossid
+if [ "0" != "$?" ]; then
+cat > ossid.c <<_EOF
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <linux/soundcard.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+int main(int argc, char **argv){
+ int fd;
+ struct mixer_info *info;
+ fd=open(argv[1],O_RDONLY);
+ if(fd>=0){
+ info=malloc(sizeof(struct mixer_info));
+ ioctl(fd,SOUND_MIXER_INFO,info);
+ printf("%c \"%s %s\"\n",(argv[1][strlen(argv[1])-1]=='p')?'0':(argv[1][strlen(argv[1])-1]+1),info->name,info->id);
+ free(info);
+ close(fd);
+ } else {
+ return 1;
+ }
+ return 0;
+}
+_EOF
+gcc ossid.c -o ossid
+rm ossid.c
+fi
+
+test -f /proc/asound/cards
+if [ "0" != "$?" ]; then
+dialog --title "Welcome" --backtitle "Empia Sound Configuration" \
+--msgbox "Your system doesn't support ALSA, please have a look at \
+www.alsa-project.org and set it up properly \
+
+
+Press any key to continue... " 11 50
+exit 1;
+fi
+
+dialog --title "Welcome" --backtitle "Empia Sound Configuration" \
+--msgbox "This tool was written to ease up sound configuration for
+* Terratec Hybrid XS
+* Terratec Cinergy 250 USB 2.0
+* Hauppauge HVR 900
+* and possible others :)
+
+first select an usb audio source, as target choose your soundcard
+Press any key to continue... " 13 60
+
+ls /dev/dsp* | while read a; do ./ossid $a; done | xargs dialog --menu "Choose your TV Audio source:" 12 60 5 2>/tmp/em2880_source.$$
+ls /dev/dsp* | while read a; do ./ossid $a; done | xargs dialog --menu "Choose your output soundcard device:" 12 60 5 2>/tmp/em2880_dst.$$
+
+source=`egrep '^[0-9p]' /tmp/em2880_source.$$`
+dst=`egrep '^[0-9p]' /tmp/em2880_dst.$$`
+
+echo "playing $source to $dst";
+if [ "$source" = "0" ]; then
+ device="/dev/dsp"
+else
+ device="/dev/dsp`expr $source - 1`"
+fi
+
+if [ "$dst" = "0" ]; then
+ device2="/dev/dsp"
+else
+ device2="/dev/dsp`expr $source - 1`"
+fi
+clear
+echo "Using command: sox -r 48000 -w -c 2 -t ossdsp $device -t ossdsp $device2"
+sox -r 48000 -w -c 2 -t ossdsp $device -t ossdsp $device2
diff --git a/v4l_experimental/cx88-ivtv.c b/v4l_experimental/cx88-ivtv.c
index c28c1d413..a747e2372 100644
--- a/v4l_experimental/cx88-ivtv.c
+++ b/v4l_experimental/cx88-ivtv.c
@@ -25,8 +25,8 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
-
#include "compat.h"
+#include <media/v4l2-common.h>
#include "cx88.h"
MODULE_DESCRIPTION("ivtv ioctl emulation module for blackbird TV cards");
@@ -111,10 +111,10 @@ static int ivtv_do_ioctl(struct inode *inode, struct file *file,
/* int err; */
if (debug > 1)
- cx88_print_ioctl(dev->core->name,cmd);
+ v4l_print_ioctl(dev->core->name,cmd);
#if 1
printk( KERN_INFO "IVTV IOCTL: 0x%x\n", cmd );
- cx88_print_ioctl(dev->core->name,cmd);
+ v4l_print_ioctl(dev->core->name,cmd);
#endif
dprintk( 1, "IVTV IOCTL: 0x%x\n", cmd );
diff --git a/v4l_experimental/pvrusb2/.cvsignore b/v4l_experimental/pvrusb2/.cvsignore
deleted file mode 100644
index 88be5bcbc..000000000
--- a/v4l_experimental/pvrusb2/.cvsignore
+++ /dev/null
@@ -1,7 +0,0 @@
-*.ko
-*.o.flags
-*.mod.c
-.*.cmd
-.version
-.snapshot
-.tmp_versions
diff --git a/v4l_experimental/pvrusb2/Makefile b/v4l_experimental/pvrusb2/Makefile
deleted file mode 100644
index 0c43d6977..000000000
--- a/v4l_experimental/pvrusb2/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-BUILD_DIR := $(shell pwd)/../..
-
-all:
- $(MAKE) -C $(BUILD_DIR) pvrusb2
-
-install:
- $(MAKE) -C $(BUILD_DIR) install
-
-%::
- $(MAKE) -C $(BUILD_DIR) $(MAKECMDGOALS)