summaryrefslogtreecommitdiff
path: root/v4l2-apps/libv4l2util
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-02-13 13:06:29 +0100
committerHans Verkuil <hverkuil@xs4all.nl>2009-02-13 13:06:29 +0100
commit4e061e403e8a5ab5f041a54a6852c69e6b00b368 (patch)
treed288a6a3edad467d22fc7cb7a022b327060a0733 /v4l2-apps/libv4l2util
parentd9fcd7e5495fbd0fe020223823338d21ce31dcaf (diff)
downloadmediapointer-dvb-s2-4e061e403e8a5ab5f041a54a6852c69e6b00b368.tar.gz
mediapointer-dvb-s2-4e061e403e8a5ab5f041a54a6852c69e6b00b368.tar.bz2
v4l2-apps: move libraries around to make the directory tree flatter
From: Hans Verkuil <hverkuil@xs4all.nl> Instead of having libv4l2util in v4l2-apps/lib and libv4l in v4l2-apps/lib/libv4l, both are now moved to v4l2-apps/libv4l2util and v4l2-apps/libv4l. This is much cleaner and less confusing. Priority: normal Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Diffstat (limited to 'v4l2-apps/libv4l2util')
-rw-r--r--v4l2-apps/libv4l2util/COPYING.LIB510
-rw-r--r--v4l2-apps/libv4l2util/Makefile33
-rw-r--r--v4l2-apps/libv4l2util/TODO81
-rw-r--r--v4l2-apps/libv4l2util/frequencies.c1502
-rw-r--r--v4l2-apps/libv4l2util/libv4l2util.h45
-rw-r--r--v4l2-apps/libv4l2util/v4l2_driver.c804
-rw-r--r--v4l2-apps/libv4l2util/v4l2_driver.h81
7 files changed, 3056 insertions, 0 deletions
diff --git a/v4l2-apps/libv4l2util/COPYING.LIB b/v4l2-apps/libv4l2util/COPYING.LIB
new file mode 100644
index 000000000..1dd325d2b
--- /dev/null
+++ b/v4l2-apps/libv4l2util/COPYING.LIB
@@ -0,0 +1,510 @@
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations
+below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+^L
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it
+becomes a de-facto standard. To achieve this, non-free programs must
+be allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+^L
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control
+compilation and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+^L
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+^L
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at least
+ three years, to give the same user the materials specified in
+ Subsection 6a, above, for a charge no more than the cost of
+ performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+^L
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+^L
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply, and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License
+may add an explicit geographical distribution limitation excluding those
+countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+^L
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+^L
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms
+of the ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library.
+It is safest to attach them to the start of each source file to most
+effectively convey the exclusion of warranty; and each file should
+have at least the "copyright" line and a pointer to where the full
+notice is found.
+
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or
+your school, if any, to sign a "copyright disclaimer" for the library,
+if necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James
+ Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/v4l2-apps/libv4l2util/Makefile b/v4l2-apps/libv4l2util/Makefile
new file mode 100644
index 000000000..f3f413071
--- /dev/null
+++ b/v4l2-apps/libv4l2util/Makefile
@@ -0,0 +1,33 @@
+# Makefile for linuxtv.org v4l2-apps/lib
+
+CPPFLAGS += -I../include -I..
+
+includes = libv4l2util.h
+
+objects = frequencies.o v4l2_driver.o
+
+sharedlib = libv4l2util.so
+staticlib = libv4l2util.a
+
+ifeq ($(prefix),)
+prefix = /usr
+endif
+
+.PHONY: all clean install
+
+all: $(sharedlib) $(staticlib)
+
+$(sharedlib): $(objects)
+
+$(staticlib): $(objects)
+
+clean::
+ rm -f $(objects) $(sharedlib) $(staticlib)
+
+install:
+ mkdir -p $(prefix)/include
+ cp $(includes) $(prefix)/include
+ mkdir -p $(prefix)/lib
+ cp $(sharedlib) $(staticlib) $(prefix)/lib
+
+include ../Make.rules
diff --git a/v4l2-apps/libv4l2util/TODO b/v4l2-apps/libv4l2util/TODO
new file mode 100644
index 000000000..456a916ce
--- /dev/null
+++ b/v4l2-apps/libv4l2util/TODO
@@ -0,0 +1,81 @@
+The only capture method implemented currently is mmap.
+
+Missing V4L2 ioctls to be implemented at library:
+ Methods to change controls at V4L devices:
+ VIDIOC_QUERYCTRL
+ VIDIOC_QUERYMENU
+ VIDIOC_G_CTRL
+ VIDIOC_S_CTRL
+ VIDIOC_TRY_EXT_CTRLS
+ VIDIOC_G_EXT_CTRLS
+ VIDIOC_S_EXT_CTRLS
+
+ Tuner control methods:
+ VIDIOC_G_TUNER
+ VIDIOC_S_TUNER
+ VIDIOC_S_FREQUENCY
+ VIDIOC_G_FREQUENCY
+
+ Crop methods:
+ VIDIOC_CROPCAP
+ VIDIOC_S_CROP
+ VIDIOC_G_CROP
+
+ Audio input/output:
+ VIDIOC_ENUMAUDIO
+ VIDIOC_ENUMAUDOUT
+ VIDIOC_G_AUDIO
+ VIDIOC_S_AUDIO
+ VIDIOC_G_AUDOUT
+ VIDIOC_S_AUDOUT
+
+ Video output:
+ VIDIOC_ENUMOUTPUT
+ VIDIOC_G_OUTPUT
+ VIDIOC_S_OUTPUT
+
+ Priority control:
+ VIDIOC_G_PRIORITY
+ VIDIOC_S_PRIORITY
+
+ Sliced VBI control:
+ VIDIOC_G_SLICED_VBI_CAP
+
+ The received video STD:
+ VIDIOC_QUERYSTD
+
+ Streaming parameters:
+ VIDIOC_G_PARM
+ VIDIOC_S_PARM
+
+ Output modulator (generally for TV):
+ VIDIOC_G_MODULATOR
+ VIDIOC_S_MODULATOR
+
+ Those methods are brand new. Not yet used on drivers:
+ VIDIOC_ENUM_FRAMEINTERVALS
+ VIDIOC_ENUM_FRAMESIZES
+
+ Overlay is somewhat legacy stuff those days:
+ VIDIOC_OVERLAY
+ VIDIOC_G_FBUF
+ VIDIOC_S_FBUF
+
+ Those are unlikely to be implemented at API (legacy stuff, debug stuff or private):
+ VIDIOC_G_JPEGCOMP
+ VIDIOC_S_JPEGCOMP
+ VIDIOC_LOG_STATUS
+ VIDIOC_PRIVATE
+ VIDIOC_RESERVED
+ VIDIOC_OVERLAY_OLD
+ VIDIOC_S_PARM_OLD
+ VIDIOC_S_CTRL_OLD
+ VIDIOC_G_AUDIO_OLD
+ VIDIOC_G_AUDOUT_OLD
+ VIDIOC_CROPCAP_OLD
+
+Also missing V4L1 mmap method:
+ VIDIOCGMBUF
+
+ This method is interesting only to be used by driver-test to check
+API compliance to the legacy method.
diff --git a/v4l2-apps/libv4l2util/frequencies.c b/v4l2-apps/libv4l2util/frequencies.c
new file mode 100644
index 000000000..df8d47dba
--- /dev/null
+++ b/v4l2-apps/libv4l2util/frequencies.c
@@ -0,0 +1,1502 @@
+/* Copyright (C) 2006 Nathan Laredo <laredo@gnu.org>
+ Nathan contributed the frequency tables.
+
+ Copyright (C) 2006 Hans Verkuil <hverkuil@xs4all.nl>
+ Added the iso-std table.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdlib.h>
+
+#include <linux/videodev2.h>
+#include "libv4l2util.h"
+
+/* This source was originally written by Nathan Laredo <laredo@gnu.org>.
+ He kindly gave permission to release this source under the LGPL
+ license. */
+
+/* --------------------------------------------------------------------- */
+
+/* US broadcast */
+static const struct v4l2_channel_list ntsc_bcast[] = {
+ { "2", 55250 },
+ { "3", 61250 },
+ { "4", 67250 },
+ { "5", 77250 },
+ { "6", 83250 },
+ { "7", 175250 },
+ { "8", 181250 },
+ { "9", 187250 },
+ { "10", 193250 },
+ { "11", 199250 },
+ { "12", 205250 },
+ { "13", 211250 },
+ { "14", 471250 },
+ { "15", 477250 },
+ { "16", 483250 },
+ { "17", 489250 },
+ { "18", 495250 },
+ { "19", 501250 },
+ { "20", 507250 },
+ { "21", 513250 },
+ { "22", 519250 },
+ { "23", 525250 },
+ { "24", 531250 },
+ { "25", 537250 },
+ { "26", 543250 },
+ { "27", 549250 },
+ { "28", 555250 },
+ { "29", 561250 },
+ { "30", 567250 },
+ { "31", 573250 },
+ { "32", 579250 },
+ { "33", 585250 },
+ { "34", 591250 },
+ { "35", 597250 },
+ { "36", 603250 },
+ { "37", 609250 },
+ { "38", 615250 },
+ { "39", 621250 },
+ { "40", 627250 },
+ { "41", 633250 },
+ { "42", 639250 },
+ { "43", 645250 },
+ { "44", 651250 },
+ { "45", 657250 },
+ { "46", 663250 },
+ { "47", 669250 },
+ { "48", 675250 },
+ { "49", 681250 },
+ { "50", 687250 },
+ { "51", 693250 },
+ { "52", 699250 },
+ { "53", 705250 },
+ { "54", 711250 },
+ { "55", 717250 },
+ { "56", 723250 },
+ { "57", 729250 },
+ { "58", 735250 },
+ { "59", 741250 },
+ { "60", 747250 },
+ { "61", 753250 },
+ { "62", 759250 },
+ { "63", 765250 },
+ { "64", 771250 },
+ { "65", 777250 },
+ { "66", 783250 },
+ { "67", 789250 },
+ { "68", 795250 },
+ { "69", 801250 },
+
+ { "70", 807250 },
+ { "71", 813250 },
+ { "72", 819250 },
+ { "73", 825250 },
+ { "74", 831250 },
+ { "75", 837250 },
+ { "76", 843250 },
+ { "77", 849250 },
+ { "78", 855250 },
+ { "79", 861250 },
+ { "80", 867250 },
+ { "81", 873250 },
+ { "82", 879250 },
+ { "83", 885250 },
+};
+
+/* US cable */
+static const struct v4l2_channel_list ntsc_cable[] = {
+ { "1", 73250 },
+ { "2", 55250 },
+ { "3", 61250 },
+ { "4", 67250 },
+ { "5", 77250 },
+ { "6", 83250 },
+ { "7", 175250 },
+ { "8", 181250 },
+ { "9", 187250 },
+ { "10", 193250 },
+ { "11", 199250 },
+ { "12", 205250 },
+
+ { "13", 211250 },
+ { "14", 121250 },
+ { "15", 127250 },
+ { "16", 133250 },
+ { "17", 139250 },
+ { "18", 145250 },
+ { "19", 151250 },
+ { "20", 157250 },
+
+ { "21", 163250 },
+ { "22", 169250 },
+ { "23", 217250 },
+ { "24", 223250 },
+ { "25", 229250 },
+ { "26", 235250 },
+ { "27", 241250 },
+ { "28", 247250 },
+ { "29", 253250 },
+ { "30", 259250 },
+ { "31", 265250 },
+ { "32", 271250 },
+ { "33", 277250 },
+ { "34", 283250 },
+ { "35", 289250 },
+ { "36", 295250 },
+ { "37", 301250 },
+ { "38", 307250 },
+ { "39", 313250 },
+ { "40", 319250 },
+ { "41", 325250 },
+ { "42", 331250 },
+ { "43", 337250 },
+ { "44", 343250 },
+ { "45", 349250 },
+ { "46", 355250 },
+ { "47", 361250 },
+ { "48", 367250 },
+ { "49", 373250 },
+ { "50", 379250 },
+ { "51", 385250 },
+ { "52", 391250 },
+ { "53", 397250 },
+ { "54", 403250 },
+ { "55", 409250 },
+ { "56", 415250 },
+ { "57", 421250 },
+ { "58", 427250 },
+ { "59", 433250 },
+ { "60", 439250 },
+ { "61", 445250 },
+ { "62", 451250 },
+ { "63", 457250 },
+ { "64", 463250 },
+ { "65", 469250 },
+ { "66", 475250 },
+ { "67", 481250 },
+ { "68", 487250 },
+ { "69", 493250 },
+
+ { "70", 499250 },
+ { "71", 505250 },
+ { "72", 511250 },
+ { "73", 517250 },
+ { "74", 523250 },
+ { "75", 529250 },
+ { "76", 535250 },
+ { "77", 541250 },
+ { "78", 547250 },
+ { "79", 553250 },
+ { "80", 559250 },
+ { "81", 565250 },
+ { "82", 571250 },
+ { "83", 577250 },
+ { "84", 583250 },
+ { "85", 589250 },
+ { "86", 595250 },
+ { "87", 601250 },
+ { "88", 607250 },
+ { "89", 613250 },
+ { "90", 619250 },
+ { "91", 625250 },
+ { "92", 631250 },
+ { "93", 637250 },
+ { "94", 643250 },
+ { "95", 91250 },
+ { "96", 97250 },
+ { "97", 103250 },
+ { "98", 109250 },
+ { "99", 115250 },
+ { "100", 649250 },
+ { "101", 655250 },
+ { "102", 661250 },
+ { "103", 667250 },
+ { "104", 673250 },
+ { "105", 679250 },
+ { "106", 685250 },
+ { "107", 691250 },
+ { "108", 697250 },
+ { "109", 703250 },
+ { "110", 709250 },
+ { "111", 715250 },
+ { "112", 721250 },
+ { "113", 727250 },
+ { "114", 733250 },
+ { "115", 739250 },
+ { "116", 745250 },
+ { "117", 751250 },
+ { "118", 757250 },
+ { "119", 763250 },
+ { "120", 769250 },
+ { "121", 775250 },
+ { "122", 781250 },
+ { "123", 787250 },
+ { "124", 793250 },
+ { "125", 799250 },
+
+ { "T7", 8250 },
+ { "T8", 14250 },
+ { "T9", 20250 },
+ { "T10", 26250 },
+ { "T11", 32250 },
+ { "T12", 38250 },
+ { "T13", 44250 },
+ { "T14", 50250 }
+};
+
+/* US HRC */
+static const struct v4l2_channel_list ntsc_hrc[] = {
+ { "1", 72000 },
+
+ { "2", 54000 },
+ { "3", 60000 },
+ { "4", 66000 },
+
+ { "5", 78000 },
+ { "6", 84000 },
+
+ { "7", 174000 },
+ { "8", 180000 },
+ { "9", 186000 },
+ { "10", 192000 },
+ { "11", 198000 },
+ { "12", 204000 },
+ { "13", 210000 },
+ { "14", 120000 },
+ { "15", 126000 },
+ { "16", 132000 },
+ { "17", 138000 },
+ { "18", 144000 },
+ { "19", 150000 },
+ { "20", 156000 },
+ { "21", 162000 },
+ { "22", 168000 },
+ { "23", 216000 },
+ { "24", 222000 },
+ { "25", 228000 },
+ { "26", 234000 },
+ { "27", 240000 },
+ { "28", 246000 },
+ { "29", 252000 },
+ { "30", 258000 },
+ { "31", 264000 },
+ { "32", 270000 },
+ { "33", 276000 },
+ { "34", 282000 },
+ { "35", 288000 },
+ { "36", 294000 },
+ { "37", 300000 },
+ { "38", 306000 },
+ { "39", 312000 },
+ { "40", 318000 },
+ { "41", 324000 },
+ { "42", 330000 },
+ { "43", 336000 },
+ { "44", 342000 },
+ { "45", 348000 },
+ { "46", 354000 },
+ { "47", 360000 },
+ { "48", 366000 },
+ { "49", 372000 },
+ { "50", 378000 },
+ { "51", 384000 },
+ { "52", 390000 },
+ { "53", 396000 },
+ { "54", 402000 },
+ { "55", 408000 },
+ { "56", 414000 },
+ { "57", 420000 },
+ { "58", 426000 },
+ { "59", 432000 },
+ { "60", 438000 },
+ { "61", 444000 },
+ { "62", 450000 },
+ { "63", 456000 },
+ { "64", 462000 },
+ { "65", 468000 },
+ { "66", 474000 },
+ { "67", 480000 },
+ { "68", 486000 },
+ { "69", 492000 },
+ { "70", 498000 },
+ { "71", 504000 },
+ { "72", 510000 },
+ { "73", 516000 },
+ { "74", 522000 },
+ { "75", 528000 },
+ { "76", 534000 },
+ { "77", 540000 },
+ { "78", 546000 },
+ { "79", 552000 },
+ { "80", 558000 },
+ { "81", 564000 },
+ { "82", 570000 },
+ { "83", 576000 },
+ { "84", 582000 },
+ { "85", 588000 },
+ { "86", 594000 },
+ { "87", 600000 },
+ { "88", 606000 },
+ { "89", 612000 },
+ { "90", 618000 },
+ { "91", 624000 },
+ { "92", 630000 },
+ { "93", 636000 },
+ { "94", 642000 },
+
+ { "95", 90000 },
+ { "96", 96000 },
+ { "97", 102000 },
+ { "98", 108000 },
+ { "99", 114000 },
+
+ { "100", 648000 },
+ { "101", 654000 },
+ { "102", 660000 },
+ { "103", 666000 },
+ { "104", 672000 },
+ { "105", 678000 },
+ { "106", 684000 },
+ { "107", 690000 },
+ { "108", 696000 },
+ { "109", 702000 },
+ { "110", 708000 },
+ { "111", 714000 },
+ { "112", 720000 },
+ { "113", 726000 },
+ { "114", 732000 },
+ { "115", 738000 },
+ { "116", 744000 },
+ { "117", 750000 },
+ { "118", 756000 },
+ { "119", 762000 },
+ { "120", 768000 },
+ { "121", 774000 },
+ { "122", 780000 },
+ { "123", 786000 },
+ { "124", 792000 },
+ { "125", 798000 },
+
+ { "T7", 7000 },
+ { "T8", 13000 },
+ { "T9", 19000 },
+ { "T10", 25000 },
+ { "T11", 31000 },
+ { "T12", 37000 },
+ { "T13", 43000 },
+ { "T14", 49000 },
+};
+
+/* US IRC */
+static const struct v4l2_channel_list ntsc_irc[] = {
+ { "1", 73250 },
+ { "2", 55250 },
+ { "3", 61250 },
+ { "4", 67250 },
+ { "5", 79250 },
+ { "6", 85250 },
+ { "7", 175250 },
+ { "8", 181250 },
+ { "9", 187250 },
+ { "10", 193250 },
+ { "11", 199250 },
+ { "12", 205250 },
+ { "13", 211250 },
+
+ { "14", 121150 },
+ { "15", 127150 },
+ { "16", 133150 },
+ { "17", 139150 },
+ { "18", 145150 },
+ { "19", 151150 },
+ { "20", 157150 },
+ { "21", 163150 },
+ { "22", 169150 },
+
+ { "23", 217250 },
+ { "24", 223250 },
+ { "25", 229250 },
+ { "26", 235250 },
+ { "27", 241250 },
+ { "28", 247250 },
+ { "29", 253250 },
+ { "30", 259250 },
+ { "31", 265250 },
+ { "32", 271250 },
+ { "33", 277250 },
+ { "34", 283250 },
+ { "35", 289250 },
+ { "36", 295250 },
+ { "37", 301250 },
+ { "38", 307250 },
+ { "39", 313250 },
+ { "40", 319250 },
+ { "41", 325250 },
+ { "42", 331250 },
+ { "43", 337250 },
+ { "44", 343250 },
+ { "45", 349250 },
+ { "46", 355250 },
+ { "47", 361250 },
+ { "48", 367250 },
+ { "49", 373250 },
+ { "50", 379250 },
+ { "51", 385250 },
+ { "52", 391250 },
+ { "53", 397250 },
+ { "54", 403250 },
+ { "55", 409250 },
+ { "56", 415250 },
+ { "57", 421250 },
+ { "58", 427250 },
+ { "59", 433250 },
+ { "60", 439250 },
+ { "61", 445250 },
+ { "62", 451250 },
+ { "63", 457250 },
+ { "64", 463250 },
+ { "65", 469250 },
+ { "66", 475250 },
+ { "67", 481250 },
+ { "68", 487250 },
+ { "69", 493250 },
+ { "70", 499250 },
+ { "71", 505250 },
+ { "72", 511250 },
+ { "73", 517250 },
+ { "74", 523250 },
+ { "75", 529250 },
+ { "76", 535250 },
+ { "77", 541250 },
+ { "78", 547250 },
+ { "79", 553250 },
+ { "80", 559250 },
+ { "81", 565250 },
+ { "82", 571250 },
+ { "83", 577250 },
+ { "84", 583250 },
+ { "85", 589250 },
+ { "86", 595250 },
+ { "87", 601250 },
+ { "88", 607250 },
+ { "89", 613250 },
+ { "90", 619250 },
+ { "91", 625250 },
+ { "92", 631250 },
+ { "93", 637250 },
+ { "94", 643250 },
+
+ { "95", 91250 },
+ { "96", 97250 },
+ { "97", 103250 },
+ { "98", 109250 },
+ { "99", 115250 },
+ { "100", 649250 },
+ { "101", 655250 },
+ { "102", 661250 },
+ { "103", 667250 },
+ { "104", 673250 },
+ { "105", 679250 },
+ { "106", 685250 },
+ { "107", 691250 },
+ { "108", 697250 },
+ { "109", 703250 },
+ { "110", 709250 },
+ { "111", 715250 },
+ { "112", 721250 },
+ { "113", 727250 },
+ { "114", 733250 },
+ { "115", 739250 },
+ { "116", 745250 },
+ { "117", 751250 },
+ { "118", 757250 },
+ { "119", 763250 },
+ { "120", 769250 },
+ { "121", 775250 },
+ { "122", 781250 },
+ { "123", 787250 },
+ { "124", 793250 },
+ { "125", 799250 },
+
+ { "T7", 8250 },
+ { "T8", 14250 },
+ { "T9", 20250 },
+ { "T10", 26250 },
+ { "T11", 32250 },
+ { "T12", 38250 },
+ { "T13", 44250 },
+ { "T14", 50250 }
+};
+
+
+/* --------------------------------------------------------------------- */
+
+/* JP broadcast */
+static const struct v4l2_channel_list ntsc_bcast_jp[] = {
+ { "1", 91250 },
+ { "2", 97250 },
+ { "3", 103250 },
+ { "4", 171250 },
+ { "5", 177250 },
+ { "6", 183250 },
+ { "7", 189250 },
+ { "8", 193250 },
+ { "9", 199250 },
+ { "10", 205250 },
+ { "11", 211250 },
+ { "12", 217250 },
+
+ { "13", 471250 },
+ { "14", 477250 },
+ { "15", 483250 },
+ { "16", 489250 },
+ { "17", 495250 },
+ { "18", 501250 },
+ { "19", 507250 },
+ { "20", 513250 },
+ { "21", 519250 },
+ { "22", 525250 },
+ { "23", 531250 },
+ { "24", 537250 },
+ { "25", 543250 },
+ { "26", 549250 },
+ { "27", 555250 },
+ { "28", 561250 },
+ { "29", 567250 },
+ { "30", 573250 },
+ { "31", 579250 },
+ { "32", 585250 },
+ { "33", 591250 },
+ { "34", 597250 },
+ { "35", 603250 },
+ { "36", 609250 },
+ { "37", 615250 },
+ { "38", 621250 },
+ { "39", 627250 },
+ { "40", 633250 },
+ { "41", 639250 },
+ { "42", 645250 },
+ { "43", 651250 },
+ { "44", 657250 },
+
+ { "45", 663250 },
+ { "46", 669250 },
+ { "47", 675250 },
+ { "48", 681250 },
+ { "49", 687250 },
+ { "50", 693250 },
+ { "51", 699250 },
+ { "52", 705250 },
+ { "53", 711250 },
+ { "54", 717250 },
+ { "55", 723250 },
+ { "56", 729250 },
+ { "57", 735250 },
+ { "58", 741250 },
+ { "59", 747250 },
+ { "60", 753250 },
+ { "61", 759250 },
+ { "62", 765250 },
+};
+
+/* JP cable */
+static const struct v4l2_channel_list ntsc_cable_jp[] = {
+ { "13", 109250 },
+ { "14", 115250 },
+ { "15", 121250 },
+ { "16", 127250 },
+ { "17", 133250 },
+ { "18", 139250 },
+ { "19", 145250 },
+ { "20", 151250 },
+
+ { "21", 157250 },
+ { "22", 165250 },
+ { "23", 223250 },
+ { "24", 231250 },
+ { "25", 237250 },
+ { "26", 243250 },
+ { "27", 249250 },
+ { "28", 253250 },
+ { "29", 259250 },
+ { "30", 265250 },
+ { "31", 271250 },
+ { "32", 277250 },
+ { "33", 283250 },
+ { "34", 289250 },
+ { "35", 295250 },
+ { "36", 301250 },
+ { "37", 307250 },
+ { "38", 313250 },
+ { "39", 319250 },
+ { "40", 325250 },
+ { "41", 331250 },
+ { "42", 337250 },
+ { "43", 343250 },
+ { "44", 349250 },
+ { "45", 355250 },
+ { "46", 361250 },
+ { "47", 367250 },
+ { "48", 373250 },
+ { "49", 379250 },
+ { "50", 385250 },
+ { "51", 391250 },
+ { "52", 397250 },
+ { "53", 403250 },
+ { "54", 409250 },
+ { "55", 415250 },
+ { "56", 421250 },
+ { "57", 427250 },
+ { "58", 433250 },
+ { "59", 439250 },
+ { "60", 445250 },
+ { "61", 451250 },
+ { "62", 457250 },
+ { "63", 463250 },
+};
+
+/* --------------------------------------------------------------------- */
+
+/* australia */
+static const struct v4l2_channel_list pal_australia[] = {
+ { "0", 46250 },
+ { "1", 57250 },
+ { "2", 64250 },
+ { "3", 86250 },
+ { "4", 95250 },
+ { "5", 102250 },
+ { "5A", 138250 },
+ { "6", 175250 },
+ { "7", 182250 },
+ { "8", 189250 },
+ { "9", 196250 },
+ { "10", 209250 },
+ { "11", 216250 },
+ { "28", 527250 },
+ { "29", 534250 },
+ { "30", 541250 },
+ { "31", 548250 },
+ { "32", 555250 },
+ { "33", 562250 },
+ { "34", 569250 },
+ { "35", 576250 },
+ { "36", 591250 },
+ { "39", 604250 },
+ { "40", 611250 },
+ { "41", 618250 },
+ { "42", 625250 },
+ { "43", 632250 },
+ { "44", 639250 },
+ { "45", 646250 },
+ { "46", 653250 },
+ { "47", 660250 },
+ { "48", 667250 },
+ { "49", 674250 },
+ { "50", 681250 },
+ { "51", 688250 },
+ { "52", 695250 },
+ { "53", 702250 },
+ { "54", 709250 },
+ { "55", 716250 },
+ { "56", 723250 },
+ { "57", 730250 },
+ { "58", 737250 },
+ { "59", 744250 },
+ { "60", 751250 },
+ { "61", 758250 },
+ { "62", 765250 },
+ { "63", 772250 },
+ { "64", 779250 },
+ { "65", 786250 },
+ { "66", 793250 },
+ { "67", 800250 },
+ { "68", 807250 },
+ { "69", 814250 },
+};
+
+static const struct v4l2_channel_list pal_australia_optus[] = {
+ { "1", 138250 },
+ { "2", 147250 },
+ { "3", 154250 },
+ { "4", 161250 },
+ { "5", 168250 },
+ { "6", 175250 },
+ { "7", 182250 },
+ { "8", 189250 },
+ { "9", 196250 },
+ { "10", 209250 },
+ { "11", 216250 },
+ { "12", 224250 },
+ { "13", 231250 },
+ { "14", 238250 },
+ { "15", 245250 },
+ { "16", 252250 },
+ { "17", 259250 },
+ { "18", 266250 },
+ { "19", 273250 },
+ { "20", 280250 },
+ { "21", 287250 },
+ { "22", 294250 },
+ { "23", 303250 },
+ { "24", 310250 },
+ { "25", 317250 },
+ { "26", 324250 },
+ { "27", 338250 },
+ { "28", 345250 },
+ { "29", 352250 },
+ { "30", 359250 },
+ { "31", 366250 },
+ { "32", 373250 },
+ { "33", 380250 },
+ { "34", 387250 },
+ { "35", 394250 },
+ { "36", 401250 },
+ { "37", 408250 },
+ { "38", 415250 },
+ { "39", 422250 },
+ { "40", 429250 },
+ { "41", 436250 },
+ { "42", 443250 },
+ { "43", 450250 },
+ { "44", 457250 },
+ { "45", 464250 },
+ { "46", 471250 },
+ { "47", 478250 },
+ { "48", 485250 },
+ { "49", 492250 },
+ { "50", 499250 },
+ { "51", 506250 },
+ { "52", 513250 },
+ { "53", 520250 },
+ { "54", 527250 },
+ { "55", 534250 },
+};
+
+
+/* --------------------------------------------------------------------- */
+/* europe */
+
+/* CCIR frequencies */
+
+#define FREQ_CCIR_I_III \
+ { "E2", 48250 }, \
+ { "E3", 55250 }, \
+ { "E4", 62250 }, \
+ \
+ { "S01", 69250 }, \
+ { "S02", 76250 }, \
+ { "S03", 83250 }, \
+ \
+ { "E5", 175250 }, \
+ { "E6", 182250 }, \
+ { "E7", 189250 }, \
+ { "E8", 196250 }, \
+ { "E9", 203250 }, \
+ { "E10", 210250 }, \
+ { "E11", 217250 }, \
+ { "E12", 224250 }
+
+#define FREQ_CCIR_SL_SH \
+ { "SE1", 105250 }, \
+ { "SE2", 112250 }, \
+ { "SE3", 119250 }, \
+ { "SE4", 126250 }, \
+ { "SE5", 133250 }, \
+ { "SE6", 140250 }, \
+ { "SE7", 147250 }, \
+ { "SE8", 154250 }, \
+ { "SE9", 161250 }, \
+ { "SE10", 168250 }, \
+ \
+ { "SE11", 231250 }, \
+ { "SE12", 238250 }, \
+ { "SE13", 245250 }, \
+ { "SE14", 252250 }, \
+ { "SE15", 259250 }, \
+ { "SE16", 266250 }, \
+ { "SE17", 273250 }, \
+ { "SE18", 280250 }, \
+ { "SE19", 287250 }, \
+ { "SE20", 294250 }
+
+#define FREQ_CCIR_H \
+ { "S21", 303250 }, \
+ { "S22", 311250 }, \
+ { "S23", 319250 }, \
+ { "S24", 327250 }, \
+ { "S25", 335250 }, \
+ { "S26", 343250 }, \
+ { "S27", 351250 }, \
+ { "S28", 359250 }, \
+ { "S29", 367250 }, \
+ { "S30", 375250 }, \
+ { "S31", 383250 }, \
+ { "S32", 391250 }, \
+ { "S33", 399250 }, \
+ { "S34", 407250 }, \
+ { "S35", 415250 }, \
+ { "S36", 423250 }, \
+ { "S37", 431250 }, \
+ { "S38", 439250 }, \
+ { "S39", 447250 }, \
+ { "S40", 455250 }, \
+ { "S41", 463250 }
+
+/* OIRT frequencies */
+
+#define FREQ_OIRT_I_III \
+ { "R1", 49750 }, \
+ { "R2", 59250 }, \
+ \
+ { "R3", 77250 }, \
+ { "R4", 85250 }, \
+ { "R5", 93250 }, \
+ \
+ { "R6", 175250 }, \
+ { "R7", 183250 }, \
+ { "R8", 191250 }, \
+ { "R9", 199250 }, \
+ { "R10", 207250 }, \
+ { "R11", 215250 }, \
+ { "R12", 223250 }
+
+#define FREQ_OIRT_SL_SH \
+ { "SR1", 111250 }, \
+ { "SR2", 119250 }, \
+ { "SR3", 127250 }, \
+ { "SR4", 135250 }, \
+ { "SR5", 143250 }, \
+ { "SR6", 151250 }, \
+ { "SR7", 159250 }, \
+ { "SR8", 167250 }, \
+ \
+ { "SR11", 231250 }, \
+ { "SR12", 239250 }, \
+ { "SR13", 247250 }, \
+ { "SR14", 255250 }, \
+ { "SR15", 263250 }, \
+ { "SR16", 271250 }, \
+ { "SR17", 279250 }, \
+ { "SR18", 287250 }, \
+ { "SR19", 295250 }
+
+#define FREQ_UHF \
+ { "21", 471250 }, \
+ { "22", 479250 }, \
+ { "23", 487250 }, \
+ { "24", 495250 }, \
+ { "25", 503250 }, \
+ { "26", 511250 }, \
+ { "27", 519250 }, \
+ { "28", 527250 }, \
+ { "29", 535250 }, \
+ { "30", 543250 }, \
+ { "31", 551250 }, \
+ { "32", 559250 }, \
+ { "33", 567250 }, \
+ { "34", 575250 }, \
+ { "35", 583250 }, \
+ { "36", 591250 }, \
+ { "37", 599250 }, \
+ { "38", 607250 }, \
+ { "39", 615250 }, \
+ { "40", 623250 }, \
+ { "41", 631250 }, \
+ { "42", 639250 }, \
+ { "43", 647250 }, \
+ { "44", 655250 }, \
+ { "45", 663250 }, \
+ { "46", 671250 }, \
+ { "47", 679250 }, \
+ { "48", 687250 }, \
+ { "49", 695250 }, \
+ { "50", 703250 }, \
+ { "51", 711250 }, \
+ { "52", 719250 }, \
+ { "53", 727250 }, \
+ { "54", 735250 }, \
+ { "55", 743250 }, \
+ { "56", 751250 }, \
+ { "57", 759250 }, \
+ { "58", 767250 }, \
+ { "59", 775250 }, \
+ { "60", 783250 }, \
+ { "61", 791250 }, \
+ { "62", 799250 }, \
+ { "63", 807250 }, \
+ { "64", 815250 }, \
+ { "65", 823250 }, \
+ { "66", 831250 }, \
+ { "67", 839250 }, \
+ { "68", 847250 }, \
+ { "69", 855250 }
+
+static const struct v4l2_channel_list europe_west[] = {
+ FREQ_CCIR_I_III,
+ FREQ_CCIR_SL_SH,
+ FREQ_CCIR_H,
+ FREQ_UHF
+};
+
+static const struct v4l2_channel_list europe_east[] = {
+ FREQ_OIRT_I_III,
+ FREQ_OIRT_SL_SH,
+ FREQ_CCIR_I_III,
+ FREQ_CCIR_SL_SH,
+ FREQ_CCIR_H,
+ FREQ_UHF
+};
+
+static const struct v4l2_channel_list pal_italy[] = {
+ { "A", 53750 },
+ { "B", 62250 },
+ { "C", 82250 },
+ { "D", 175250 },
+ { "E", 183750 },
+ { "F", 192250 },
+ { "G", 201250 },
+ { "H", 210250 },
+ { "H1", 217250 },
+ { "H2", 224250 },
+ FREQ_UHF
+};
+
+static const struct v4l2_channel_list pal_ireland[] = {
+ { "A0", 45750 },
+ { "A1", 48000 },
+ { "A2", 53750 },
+ { "A3", 56000 },
+ { "A4", 61750 },
+ { "A5", 64000 },
+ { "A6", 175250 },
+ { "A7", 176000 },
+ { "A8", 183250 },
+ { "A9", 184000 },
+ { "A10", 191250 },
+ { "A11", 192000 },
+ { "A12", 199250 },
+ { "A13", 200000 },
+ { "A14", 207250 },
+ { "A15", 208000 },
+ { "A16", 215250 },
+ { "A17", 216000 },
+ { "A18", 224000 },
+ { "A19", 232000 },
+ { "A20", 248000 },
+ { "A21", 256000 },
+ { "A22", 264000 },
+ { "A23", 272000 },
+ { "A24", 280000 },
+ { "A25", 288000 },
+ { "A26", 296000 },
+ { "A27", 304000 },
+ { "A28", 312000 },
+ { "A29", 320000 },
+ { "A30", 344000 },
+ { "A31", 352000 },
+ { "A32", 408000 },
+ { "A33", 416000 },
+ { "A34", 448000 },
+ { "A35", 480000 },
+ { "A36", 520000 },
+ FREQ_UHF,
+};
+
+static const struct v4l2_channel_list secam_france[] = {
+ { "K01", 47750 },
+ { "K02", 55750 },
+ { "K03", 60500 },
+ { "K04", 63750 },
+ { "K05", 176000 },
+ { "K06", 184000 },
+ { "K07", 192000 },
+ { "K08", 200000 },
+ { "K09", 208000 },
+ { "K10", 216000 },
+ { "KB", 116750 },
+ { "KC", 128750 },
+ { "KD", 140750 },
+ { "KE", 159750 },
+ { "KF", 164750 },
+ { "KG", 176750 },
+ { "KH", 188750 },
+ { "KI", 200750 },
+ { "KJ", 212750 },
+ { "KK", 224750 },
+ { "KL", 236750 },
+ { "KM", 248750 },
+ { "KN", 260750 },
+ { "KO", 272750 },
+ { "KP", 284750 },
+ { "KQ", 296750 },
+ { "H01", 303250 },
+ { "H02", 311250 },
+ { "H03", 319250 },
+ { "H04", 327250 },
+ { "H05", 335250 },
+ { "H06", 343250 },
+ { "H07", 351250 },
+ { "H08", 359250 },
+ { "H09", 367250 },
+ { "H10", 375250 },
+ { "H11", 383250 },
+ { "H12", 391250 },
+ { "H13", 399250 },
+ { "H14", 407250 },
+ { "H15", 415250 },
+ { "H16", 423250 },
+ { "H17", 431250 },
+ { "H18", 439250 },
+ { "H19", 447250 },
+ FREQ_UHF,
+};
+
+/* --------------------------------------------------------------------- */
+
+static const struct v4l2_channel_list pal_newzealand[] = {
+ { "1", 45250 },
+ { "2", 55250 },
+ { "3", 62250 },
+ { "4", 175250 },
+ { "5", 182250 },
+ { "6", 189250 },
+ { "7", 196250 },
+ { "8", 203250 },
+ { "9", 210250 },
+ { "10", 217250 },
+ { "11", 224250 },
+ FREQ_UHF,
+};
+
+/* --------------------------------------------------------------------- */
+
+/* China broadcast */
+static const struct v4l2_channel_list pal_bcast_cn[] = {
+ { "1", 49750 },
+ { "2", 57750 },
+ { "3", 65750 },
+ { "4", 77250 },
+ { "5", 85250 },
+ { "6", 112250 },
+ { "7", 120250 },
+ { "8", 128250 },
+ { "9", 136250 },
+ { "10", 144250 },
+ { "11", 152250 },
+ { "12", 160250 },
+ { "13", 168250 },
+ { "14", 176250 },
+ { "15", 184250 },
+ { "16", 192250 },
+ { "17", 200250 },
+ { "18", 208250 },
+ { "19", 216250 },
+ { "20", 224250 },
+ { "21", 232250 },
+ { "22", 240250 },
+ { "23", 248250 },
+ { "24", 256250 },
+ { "25", 264250 },
+ { "26", 272250 },
+ { "27", 280250 },
+ { "28", 288250 },
+ { "29", 296250 },
+ { "30", 304250 },
+ { "31", 312250 },
+ { "32", 320250 },
+ { "33", 328250 },
+ { "34", 336250 },
+ { "35", 344250 },
+ { "36", 352250 },
+ { "37", 360250 },
+ { "38", 368250 },
+ { "39", 376250 },
+ { "40", 384250 },
+ { "41", 392250 },
+ { "42", 400250 },
+ { "43", 408250 },
+ { "44", 416250 },
+ { "45", 424250 },
+ { "46", 432250 },
+ { "47", 440250 },
+ { "48", 448250 },
+ { "49", 456250 },
+ { "50", 463250 },
+ { "51", 471250 },
+ { "52", 479250 },
+ { "53", 487250 },
+ { "54", 495250 },
+ { "55", 503250 },
+ { "56", 511250 },
+ { "57", 519250 },
+ { "58", 527250 },
+ { "59", 535250 },
+ { "60", 543250 },
+ { "61", 551250 },
+ { "62", 559250 },
+ { "63", 607250 },
+ { "64", 615250 },
+ { "65", 623250 },
+ { "66", 631250 },
+ { "67", 639250 },
+ { "68", 647250 },
+ { "69", 655250 },
+ { "70", 663250 },
+ { "71", 671250 },
+ { "72", 679250 },
+ { "73", 687250 },
+ { "74", 695250 },
+ { "75", 703250 },
+ { "76", 711250 },
+ { "77", 719250 },
+ { "78", 727250 },
+ { "79", 735250 },
+ { "80", 743250 },
+ { "81", 751250 },
+ { "82", 759250 },
+ { "83", 767250 },
+ { "84", 775250 },
+ { "85", 783250 },
+ { "86", 791250 },
+ { "87", 799250 },
+ { "88", 807250 },
+ { "89", 815250 },
+ { "90", 823250 },
+ { "91", 831250 },
+ { "92", 839250 },
+ { "93", 847250 },
+ { "94", 855250 },
+};
+
+/* --------------------------------------------------------------------- */
+/* South Africa Broadcast */
+
+static const struct v4l2_channel_list pal_bcast_za[] ={
+ { "4", 175250 },
+ { "5", 183250 },
+ { "6", 191250 },
+ { "7", 199250 },
+ { "8", 207250 },
+ { "9", 215250 },
+ { "10", 223250 },
+ { "11", 231250 },
+ { "12", 239250 },
+ { "13", 247250 },
+ FREQ_UHF
+};
+
+/* --------------------------------------------------------------------- */
+
+static const struct v4l2_channel_list argentina[] = {
+ { "001", 56250 },
+ { "002", 62250 },
+ { "003", 68250 },
+ { "004", 78250 },
+ { "005", 84250 },
+ { "006", 176250 },
+ { "007", 182250 },
+ { "008", 188250 },
+ { "009", 194250 },
+ { "010", 200250 },
+ { "011", 206250 },
+ { "012", 212250 },
+ { "013", 122250 },
+ { "014", 128250 },
+ { "015", 134250 },
+ { "016", 140250 },
+ { "017", 146250 },
+ { "018", 152250 },
+ { "019", 158250 },
+ { "020", 164250 },
+ { "021", 170250 },
+ { "022", 218250 },
+ { "023", 224250 },
+ { "024", 230250 },
+ { "025", 236250 },
+ { "026", 242250 },
+ { "027", 248250 },
+ { "028", 254250 },
+ { "029", 260250 },
+ { "030", 266250 },
+ { "031", 272250 },
+ { "032", 278250 },
+ { "033", 284250 },
+ { "034", 290250 },
+ { "035", 296250 },
+ { "036", 302250 },
+ { "037", 308250 },
+ { "038", 314250 },
+ { "039", 320250 },
+ { "040", 326250 },
+ { "041", 332250 },
+ { "042", 338250 },
+ { "043", 344250 },
+ { "044", 350250 },
+ { "045", 356250 },
+ { "046", 362250 },
+ { "047", 368250 },
+ { "048", 374250 },
+ { "049", 380250 },
+ { "050", 386250 },
+ { "051", 392250 },
+ { "052", 398250 },
+ { "053", 404250 },
+ { "054", 410250 },
+ { "055", 416250 },
+ { "056", 422250 },
+ { "057", 428250 },
+ { "058", 434250 },
+ { "059", 440250 },
+ { "060", 446250 },
+ { "061", 452250 },
+ { "062", 458250 },
+ { "063", 464250 },
+ { "064", 470250 },
+ { "065", 476250 },
+ { "066", 482250 },
+ { "067", 488250 },
+ { "068", 494250 },
+ { "069", 500250 },
+ { "070", 506250 },
+ { "071", 512250 },
+ { "072", 518250 },
+ { "073", 524250 },
+ { "074", 530250 },
+ { "075", 536250 },
+ { "076", 542250 },
+ { "077", 548250 },
+ { "078", 554250 },
+ { "079", 560250 },
+ { "080", 566250 },
+ { "081", 572250 },
+ { "082", 578250 },
+ { "083", 584250 },
+ { "084", 590250 },
+ { "085", 596250 },
+ { "086", 602250 },
+ { "087", 608250 },
+ { "088", 614250 },
+ { "089", 620250 },
+ { "090", 626250 },
+ { "091", 632250 },
+ { "092", 638250 },
+ { "093", 644250 },
+};
+
+/* --------------------------------------------------------------------- */
+
+#define CHAN_COUNT(x) (sizeof(x)/sizeof(struct v4l2_channel_list))
+
+const struct v4l2_channel_lists v4l2_channel_lists[] = {
+ { "us-bcast", ntsc_bcast, CHAN_COUNT(ntsc_bcast) },
+ { "us-cable", ntsc_cable, CHAN_COUNT(ntsc_cable) },
+ { "us-cable-hrc", ntsc_hrc, CHAN_COUNT(ntsc_hrc) },
+ { "us-cable-irc", ntsc_irc, CHAN_COUNT(ntsc_irc) },
+ { "japan-bcast", ntsc_bcast_jp, CHAN_COUNT(ntsc_bcast_jp) },
+ { "japan-cable", ntsc_cable_jp, CHAN_COUNT(ntsc_cable_jp) },
+ { "europe-west", europe_west, CHAN_COUNT(europe_west) },
+ { "europe-east", europe_east, CHAN_COUNT(europe_east) },
+ { "italy", pal_italy, CHAN_COUNT(pal_italy) },
+ { "newzealand", pal_newzealand, CHAN_COUNT(pal_newzealand) },
+ { "australia", pal_australia, CHAN_COUNT(pal_australia) },
+ { "ireland", pal_ireland, CHAN_COUNT(pal_ireland) },
+ { "france", secam_france, CHAN_COUNT(secam_france) },
+ { "china-bcast", pal_bcast_cn, CHAN_COUNT(pal_bcast_cn) },
+ { "southafrica", pal_bcast_za, CHAN_COUNT(pal_bcast_za) },
+ { "argentina", argentina, CHAN_COUNT(argentina) },
+ { "australia-optus", pal_australia_optus, CHAN_COUNT(pal_australia_optus) },
+ { NULL, NULL, 0 } /* EOF */
+};
+
+/* This list contains omissions and almost certainly incorrect information.
+ Please provide me (Hans Verkuil, <hverkuil@xs4all.nl>) with corrections. */
+const struct v4l2_country_std_map v4l2_country_std_map[] = {
+ { "AE", V4L2_STD_PAL_BG }, /* United Arab Emirates */
+ { "AF", V4L2_STD_SECAM_D }, /* Afghanistan */
+ { "AG", V4L2_STD_NTSC_M }, /* Antigua */
+ { "AL", V4L2_STD_PAL_BG }, /* Albania */
+ { "AM", V4L2_STD_SECAM_DK }, /* Armenia */
+ { "AN", V4L2_STD_NTSC_M }, /* Netherlands Antilles */
+ { "AO", V4L2_STD_PAL_I }, /* Angola */
+ { "AR", V4L2_STD_PAL_Nc }, /* Argentina */
+ { "AT", V4L2_STD_PAL_BG }, /* Austria */
+ { "AU", V4L2_STD_PAL_B }, /* Australia */
+ { "AW", V4L2_STD_NTSC_M }, /* Aruba */
+ { "AZ", V4L2_STD_SECAM_DK }, /* Azerbaijan */
+ { "BA", V4L2_STD_PAL_BG }, /* Bosnia and Herzegovina */
+ { "BB", V4L2_STD_NTSC_M }, /* Barbados */
+ { "BD", V4L2_STD_PAL_B }, /* Bangladesh */
+ { "BE", V4L2_STD_PAL_B | V4L2_STD_PAL_H }, /* Belgium */
+ { "BF", V4L2_STD_SECAM_K1 }, /* Burkina Faso */
+ { "BG", V4L2_STD_SECAM_DK }, /* Bulgaria */
+ { "BH", V4L2_STD_PAL_BG }, /* Bahrain */
+ { "BI", V4L2_STD_SECAM_K1 }, /* Burundi */
+ { "BJ", V4L2_STD_SECAM_K1 }, /* Benin */
+ { "BM", V4L2_STD_NTSC_M }, /* Bermuda */
+ { "BN", V4L2_STD_PAL_B }, /* Brunei Darussalam */
+ { "BO", V4L2_STD_NTSC_M }, /* Bolivia */
+ { "BR", V4L2_STD_PAL_M }, /* Brazil */
+ { "BS", V4L2_STD_NTSC_M }, /* Bahamas */
+ { "BW", V4L2_STD_PAL_I }, /* Botswana */
+ { "BY", V4L2_STD_SECAM_D }, /* Belarus */
+ { "BZ", V4L2_STD_NTSC_M }, /* Belize */
+ { "CA", V4L2_STD_NTSC_M }, /* Canada */
+ { "CD", V4L2_STD_SECAM_K1 }, /* The Democratic Republic of the Congo */
+ { "CF", V4L2_STD_SECAM_K1 }, /* Central African Republic */
+ { "CG", V4L2_STD_SECAM_K1 }, /* Republic of the Congo */
+ { "CH", V4L2_STD_PAL_BG }, /* Switzerland */
+ { "CL", V4L2_STD_NTSC_M }, /* Chile */
+ { "CM", V4L2_STD_PAL_BG }, /* Cameroon */
+ { "CN", V4L2_STD_PAL_D }, /* China */
+ { "CO", V4L2_STD_NTSC_M }, /* Colombia */
+ { "CR", V4L2_STD_NTSC_M }, /* Costa Rica */
+ { "CU", V4L2_STD_NTSC_M }, /* Cuba */
+ { "CY", V4L2_STD_PAL_BG }, /* Cyprus */
+ { "CZ", V4L2_STD_PAL_D }, /* Czech Republic */
+ { "DE", V4L2_STD_PAL_BG }, /* Germany */
+ { "DJ", V4L2_STD_SECAM_B }, /* Djibouti */
+ { "DK", V4L2_STD_PAL_BG }, /* Denmark */
+ { "DO", V4L2_STD_NTSC_M }, /* Dominican Republic */
+ { "DZ", V4L2_STD_PAL_BG }, /* Algeria */
+ { "EC", V4L2_STD_NTSC_M }, /* Ecuador */
+ { "EE", V4L2_STD_SECAM_DK }, /* Estonia */
+ { "EG", V4L2_STD_PAL_BG }, /* Egypt */
+ { "ES", V4L2_STD_PAL_BG }, /* Spain */
+ { "ET", V4L2_STD_PAL_BG }, /* Ethiopia */
+ { "FI", V4L2_STD_PAL_BG }, /* Finland */
+ { "FR", V4L2_STD_SECAM_L }, /* France */
+ { "GA", V4L2_STD_SECAM_K1 }, /* Gabon */
+ { "GB", V4L2_STD_PAL_I }, /* United Kingdom */
+ { "GE", V4L2_STD_SECAM_DK }, /* Georgia */
+ { "GH", V4L2_STD_PAL_B }, /* Ghana */
+ { "GI", V4L2_STD_PAL_BG }, /* Gibraltar */
+ { "GL", V4L2_STD_PAL_BG }, /* Greenland */
+ { "GM", V4L2_STD_PAL_I }, /* Gambia */
+ { "GQ", V4L2_STD_PAL_BG }, /* Equatorial Guinea */
+ { "GR", V4L2_STD_SECAM_B }, /* Greece */
+ { "GR", V4L2_STD_SECAM_G }, /* Greece */
+ { "GT", V4L2_STD_NTSC_M }, /* Guatemala */
+ { "GU", V4L2_STD_NTSC_M }, /* Guam */
+ { "GW", V4L2_STD_PAL_I }, /* Guinea-Bissau */
+ { "HK", V4L2_STD_PAL_I }, /* Hong Kong */
+ { "HN", V4L2_STD_NTSC_M }, /* Honduras */
+ { "HR", V4L2_STD_PAL_BG }, /* Croatia */
+ { "HU", V4L2_STD_SECAM_DK }, /* Hungary */
+ { "ID", V4L2_STD_PAL_B }, /* Indonesia */
+ { "IE", V4L2_STD_PAL_I }, /* Ireland */
+ { "IL", V4L2_STD_PAL_BG }, /* Israel */
+ { "IN", V4L2_STD_PAL_B }, /* India */
+ { "IQ", V4L2_STD_SECAM_B | V4L2_STD_SECAM_G }, /* Iraq */
+ { "IR", V4L2_STD_SECAM_B | V4L2_STD_SECAM_G }, /* Iran */
+ { "IS", V4L2_STD_PAL_BG }, /* Iceland */
+ { "IT", V4L2_STD_PAL_BG }, /* Italy */
+ { "JM", V4L2_STD_NTSC_M }, /* Jamaica */
+ { "JO", V4L2_STD_PAL_BG }, /* Jordan */
+ { "JP", V4L2_STD_NTSC_M_JP }, /* Japan */
+ { "KE", V4L2_STD_PAL_BG }, /* Kenya */
+ { "KH", V4L2_STD_PAL_BG }, /* Cambodia */
+ { "KM", V4L2_STD_SECAM_K1 }, /* Comoros */
+ { "KN", V4L2_STD_NTSC_M }, /* Saint Kitts and Nevis */
+ { "KP", V4L2_STD_PAL_D }, /* North Korea */
+ { "KR", V4L2_STD_NTSC_M_KR }, /* South Korea */
+ { "KW", V4L2_STD_PAL_BG }, /* Kuwait */
+ { "KZ", V4L2_STD_SECAM_D }, /* Kazakhstan */
+ { "KZ", V4L2_STD_SECAM_K }, /* Kazakhstan */
+ { "LB", V4L2_STD_SECAM_B }, /* Lebanon */
+ { "LK", V4L2_STD_PAL_BG }, /* Sri Lanka */
+ { "LR", V4L2_STD_PAL_BG }, /* Liberia */
+ { "LS", V4L2_STD_PAL_I }, /* Lesotho */
+ { "LT", V4L2_STD_SECAM_DK }, /* Lithuania */
+ { "LU", V4L2_STD_PAL_BG }, /* Luxembourg */
+ { "LY", V4L2_STD_PAL_BG }, /* Libya */
+ { "MA", V4L2_STD_SECAM_B | V4L2_STD_SECAM_G }, /* Morocco */
+ { "MC", V4L2_STD_PAL_G }, /* Monaco */
+ { "MD", V4L2_STD_SECAM_DK }, /* Moldova */
+ { "MG", V4L2_STD_SECAM_K | V4L2_STD_SECAM_K1 }, /* Madagascar */
+ { "ML", V4L2_STD_SECAM_B | V4L2_STD_SECAM_G }, /* Mali */
+ { "MM", V4L2_STD_NTSC_M }, /* Myanmar */
+ { "MN", V4L2_STD_SECAM_D }, /* Mongolia */
+ { "MR", V4L2_STD_SECAM_B }, /* Mauritania */
+ { "MS", V4L2_STD_NTSC_M }, /* Montserrat */
+ { "MT", V4L2_STD_PAL_B }, /* Malta */
+ { "MU", V4L2_STD_SECAM_B | V4L2_STD_SECAM_G }, /* Mauritius */
+ { "MV", V4L2_STD_PAL_B }, /* Maldives */
+ { "MW", V4L2_STD_PAL_I }, /* Malawi */
+ { "MX", V4L2_STD_NTSC_M }, /* Mexico */
+ { "MY", V4L2_STD_PAL_BG }, /* Malaysia */
+ { "MZ", V4L2_STD_PAL_G }, /* Mozambique */
+ { "NA", V4L2_STD_PAL_I }, /* Namibia */
+ { "NE", V4L2_STD_SECAM_K1 }, /* Niger */
+ { "NG", V4L2_STD_PAL_BG }, /* Nigeria */
+ { "NI", V4L2_STD_NTSC_M }, /* Nicaragua */
+ { "NL", V4L2_STD_PAL_BG }, /* Netherlands */
+ { "NO", V4L2_STD_PAL_BG }, /* Norway */
+ { "NP", V4L2_STD_PAL_B }, /* Nepal */
+ { "NZ", V4L2_STD_PAL_BG }, /* New Zealand */
+ { "OM", V4L2_STD_PAL_BG }, /* Oman */
+ { "PA", V4L2_STD_NTSC_M }, /* Panama */
+ { "PE", V4L2_STD_NTSC_M }, /* Peru */
+ { "PG", V4L2_STD_PAL_BG }, /* Papua New Guinea */
+ { "PH", V4L2_STD_NTSC_M }, /* Philippines */
+ { "PK", V4L2_STD_PAL_BG }, /* Pakistan */
+ { "PL", V4L2_STD_SECAM_K }, /* Poland */
+ { "PR", V4L2_STD_NTSC_M }, /* Puerto Rico */
+ { "PT", V4L2_STD_PAL_BG }, /* Portugal */
+ { "PY", V4L2_STD_PAL_N }, /* Paraguay */
+ { "QA", V4L2_STD_PAL_BG }, /* Qatar */
+ { "RO", V4L2_STD_PAL_DK }, /* Romania */
+ { "RU", V4L2_STD_SECAM_DK }, /* Russia */
+ { "RW", V4L2_STD_SECAM_K1 }, /* Rwanda */
+ { "SA", V4L2_STD_PAL_BG | V4L2_STD_SECAM_B | V4L2_STD_SECAM_G }, /* Saudi Arabia */
+ { "SC", V4L2_STD_PAL_B }, /* Seychelles */
+ { "SD", V4L2_STD_PAL_BG }, /* Sudan */
+ { "SE", V4L2_STD_PAL_BG }, /* Sweden */
+ { "SG", V4L2_STD_PAL_BG }, /* Singapore */
+ { "SI", V4L2_STD_PAL_BG }, /* Slovenia */
+ { "SK", V4L2_STD_SECAM_DK }, /* Slovak Republic */
+ { "SL", V4L2_STD_PAL_BG }, /* Sierra Leone */
+ { "SN", V4L2_STD_SECAM_K1 }, /* Senegal */
+ { "SO", V4L2_STD_PAL_BG }, /* Somalia */
+ { "SR", V4L2_STD_NTSC_M }, /* Suriname */
+ { "ST", V4L2_STD_PAL_B }, /* Sao Tome and Principe */
+ { "SV", V4L2_STD_NTSC_M }, /* El Salvador */
+ { "SY", V4L2_STD_PAL_BG }, /* Syria */
+ { "SZ", V4L2_STD_PAL_BG }, /* Swaziland */
+ { "TD", V4L2_STD_SECAM_K1 }, /* Chad */
+ { "TG", V4L2_STD_SECAM_K1 }, /* Togo */
+ { "TH", V4L2_STD_PAL_BG }, /* Thailand */
+ { "TN", V4L2_STD_PAL_BG }, /* Tunisia */
+ { "TR", V4L2_STD_PAL_BG }, /* Turkey */
+ { "TT", V4L2_STD_NTSC_M }, /* Trinidad and Tobago */
+ { "TW", V4L2_STD_NTSC_M }, /* Taiwan */
+ { "TZ", V4L2_STD_PAL_I }, /* Tanzania */
+ { "UA", V4L2_STD_SECAM_DK }, /* Ukraine */
+ { "UG", V4L2_STD_PAL_B }, /* Uganda */
+ { "US", V4L2_STD_NTSC_M }, /* United States */
+ { "UY", V4L2_STD_PAL_N }, /* Uruguay */
+ { "VC", V4L2_STD_SECAM_K1 }, /* Cape Verde */
+ { "VE", V4L2_STD_NTSC_M }, /* Venezuela */
+ { "VG", V4L2_STD_NTSC_M }, /* Virgin Islands, British */
+ { "VI", V4L2_STD_NTSC_M }, /* Virgin Islands, U.S. */
+ { "VN", V4L2_STD_SECAM_DK }, /* Vietnam */
+ { "WS", V4L2_STD_NTSC_M }, /* Samoa */
+ { "YE", V4L2_STD_PAL_BG }, /* Yemen */
+ { "ZA", V4L2_STD_PAL_I }, /* South Africa */
+ { "ZM", V4L2_STD_PAL_G }, /* Zambia */
+ { "ZW", V4L2_STD_PAL_G }, /* Zimbabwe */
+ { NULL, 0 }
+};
diff --git a/v4l2-apps/libv4l2util/libv4l2util.h b/v4l2-apps/libv4l2util/libv4l2util.h
new file mode 100644
index 000000000..fde7cdc75
--- /dev/null
+++ b/v4l2-apps/libv4l2util/libv4l2util.h
@@ -0,0 +1,45 @@
+/* Copyright (C) 2006 Hans Verkuil <hverkuil@xs4all.nl>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _V4L2UTIL_H_
+#define _V4L2UTIL_H_
+
+/* --------------------------------------------------------------------- */
+
+struct v4l2_channel_list {
+ const char * const name; /* channel name */
+ unsigned freq; /* channel frequency in kHz */
+};
+
+struct v4l2_channel_lists {
+ const char * const name; /* channel list name */
+ const struct v4l2_channel_list * const list;
+ unsigned count; /* number of channels in channel list */
+};
+
+extern const struct v4l2_channel_lists v4l2_channel_lists[];
+
+/* This list is sorted alphabetically on ISO code. The last item is
+ denoted by a NULL pointer for the iso_code. */
+struct v4l2_country_std_map {
+ const char * const iso_code; /* The 2-character upper case ISO-3166 country code */
+ v4l2_std_id std; /* The TV standard(s) in use */
+};
+
+extern const struct v4l2_country_std_map v4l2_country_std_map[];
+
+#endif
diff --git a/v4l2-apps/libv4l2util/v4l2_driver.c b/v4l2-apps/libv4l2util/v4l2_driver.c
new file mode 100644
index 000000000..94f826968
--- /dev/null
+++ b/v4l2-apps/libv4l2util/v4l2_driver.c
@@ -0,0 +1,804 @@
+/*
+ Copyright (C) 2006 Mauro Carvalho Chehab <mchehab@infradead.org>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <malloc.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <stdlib.h>
+
+#include "v4l2_driver.h"
+
+/****************************************************************************
+ Auxiliary routines
+ ****************************************************************************/
+static int xioctl (int fd, int request, void *arg)
+{
+ int r;
+
+ do r = ioctl (fd, request, arg);
+ while (-1 == r && EINTR == errno);
+
+ return r;
+}
+
+static void free_list(struct drv_list **list_ptr)
+{
+ struct drv_list *prev,*cur;
+
+ if (list_ptr==NULL)
+ return;
+
+ prev=*list_ptr;
+ if (prev==NULL)
+ return;
+
+ do {
+ cur=prev->next;
+ if (prev->curr)
+ free (prev->curr); // Free data
+ free (prev); // Free list
+ prev=cur;
+ } while (prev);
+
+ *list_ptr=NULL;
+}
+
+/****************************************************************************
+ Auxiliary Arrays to aid debug messages
+ ****************************************************************************/
+char *v4l2_field_names[] = {
+ [V4L2_FIELD_ANY] = "any",
+ [V4L2_FIELD_NONE] = "none",
+ [V4L2_FIELD_TOP] = "top",
+ [V4L2_FIELD_BOTTOM] = "bottom",
+ [V4L2_FIELD_INTERLACED] = "interlaced",
+ [V4L2_FIELD_SEQ_TB] = "seq-tb",
+ [V4L2_FIELD_SEQ_BT] = "seq-bt",
+ [V4L2_FIELD_ALTERNATE] = "alternate",
+};
+
+char *v4l2_type_names[] = {
+ [V4L2_BUF_TYPE_VIDEO_CAPTURE] = "video-cap",
+ [V4L2_BUF_TYPE_VIDEO_OVERLAY] = "video-over",
+ [V4L2_BUF_TYPE_VIDEO_OUTPUT] = "video-out",
+ [V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap",
+ [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out",
+ [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-cap",
+ [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT] = "slicec-vbi-out",
+};
+
+static char *v4l2_memory_names[] = {
+ [V4L2_MEMORY_MMAP] = "mmap",
+ [V4L2_MEMORY_USERPTR] = "userptr",
+ [V4L2_MEMORY_OVERLAY] = "overlay",
+};
+
+#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(*arr))
+#define prt_names(a,arr) (((a)<ARRAY_SIZE(arr))?arr[a]:"unknown")
+
+char *prt_caps(uint32_t caps)
+{
+ static char s[4096]="";
+
+ if (V4L2_CAP_VIDEO_CAPTURE & caps)
+ strcat (s,"CAPTURE ");
+ if (V4L2_CAP_VIDEO_OUTPUT & caps)
+ strcat (s,"OUTPUT ");
+ if (V4L2_CAP_VIDEO_OVERLAY & caps)
+ strcat (s,"OVERLAY ");
+ if (V4L2_CAP_VBI_CAPTURE & caps)
+ strcat (s,"VBI_CAPTURE ");
+ if (V4L2_CAP_VBI_OUTPUT & caps)
+ strcat (s,"VBI_OUTPUT ");
+ if (V4L2_CAP_SLICED_VBI_CAPTURE & caps)
+ strcat (s,"SLICED_VBI_CAPTURE ");
+ if (V4L2_CAP_SLICED_VBI_OUTPUT & caps)
+ strcat (s,"SLICED_VBI_OUTPUT ");
+ if (V4L2_CAP_RDS_CAPTURE & caps)
+ strcat (s,"RDS_CAPTURE ");
+ if (V4L2_CAP_TUNER & caps)
+ strcat (s,"TUNER ");
+ if (V4L2_CAP_AUDIO & caps)
+ strcat (s,"AUDIO ");
+ if (V4L2_CAP_RADIO & caps)
+ strcat (s,"RADIO ");
+ if (V4L2_CAP_READWRITE & caps)
+ strcat (s,"READWRITE ");
+ if (V4L2_CAP_ASYNCIO & caps)
+ strcat (s,"ASYNCIO ");
+ if (V4L2_CAP_STREAMING & caps)
+ strcat (s,"STREAMING ");
+
+ return s;
+}
+
+static void prt_buf_info(char *name,struct v4l2_buffer *p)
+{
+ struct v4l2_timecode *tc=&p->timecode;
+
+ printf ("%s: %02ld:%02d:%02d.%08ld index=%d, type=%s, "
+ "bytesused=%d, flags=0x%08x, "
+ "field=%s, sequence=%d, memory=%s, offset=0x%08x, length=%d\n",
+ name, (p->timestamp.tv_sec/3600),
+ (int)(p->timestamp.tv_sec/60)%60,
+ (int)(p->timestamp.tv_sec%60),
+ p->timestamp.tv_usec,
+ p->index,
+ prt_names(p->type,v4l2_type_names),
+ p->bytesused,p->flags,
+ prt_names(p->field,v4l2_field_names),
+ p->sequence,
+ prt_names(p->memory,v4l2_memory_names),
+ p->m.offset,
+ p->length);
+ tc=&p->timecode;
+ printf ("\tTIMECODE: %02d:%02d:%02d type=%d, "
+ "flags=0x%08x, frames=%d, userbits=0x%08x\n",
+ tc->hours,tc->minutes,tc->seconds,
+ tc->type, tc->flags, tc->frames, *(uint32_t *) tc->userbits);
+}
+
+/****************************************************************************
+ Open V4L2 devices
+ ****************************************************************************/
+int v4l2_open (char *device, int debug, struct v4l2_driver *drv)
+{
+ int ret;
+
+ memset(drv,0,sizeof(*drv));
+
+ drv->debug=debug;
+
+ if ((drv->fd = open(device, O_RDWR )) < 0) {
+ return(-errno);
+ }
+
+ ret=xioctl(drv->fd,VIDIOC_QUERYCAP,(void *) &drv->cap);
+ if (!ret && drv->debug) {
+ printf ("driver=%s, card=%s, bus=%s, version=%d.%d.%d, "
+ "capabilities=%s\n",
+ drv->cap.driver,drv->cap.card,drv->cap.bus_info,
+ (drv->cap.version >> 16) & 0xff,
+ (drv->cap.version >> 8) & 0xff,
+ drv->cap.version & 0xff,
+ prt_caps(drv->cap.capabilities));
+
+
+ }
+ return ret;
+}
+
+
+/****************************************************************************
+ V4L2 Eumberations
+ ****************************************************************************/
+int v4l2_enum_stds (struct v4l2_driver *drv)
+{
+ struct v4l2_standard *p=NULL;
+ struct drv_list *list;
+ int ok=0,ret,i;
+ v4l2_std_id id;
+
+ free_list(&drv->stds);
+
+ list=drv->stds=calloc(1,sizeof(*drv->stds));
+ assert (list!=NULL);
+
+ for (i=0; ok==0; i++) {
+ p=calloc(1,sizeof(*p));
+ assert (p);
+
+ p->index=i;
+ ok=xioctl(drv->fd,VIDIOC_ENUMSTD,p);
+ if (ok<0) {
+ ok=-errno;
+ free(p);
+ break;
+ }
+ if (drv->debug) {
+ printf ("STANDARD: index=%d, id=0x%08x, name=%s, fps=%.3f, "
+ "framelines=%d\n", p->index,
+ (unsigned int)p->id, p->name,
+ 1.*p->frameperiod.denominator/p->frameperiod.numerator,
+ p->framelines);
+ }
+ if (list->curr) {
+ list->next=calloc(1,sizeof(*list->next));
+ list=list->next;
+ assert (list!=NULL);
+ }
+ list->curr=p;
+ }
+ if (i>0 && ok==-EINVAL)
+ return 0;
+
+ return ok;
+}
+
+int v4l2_enum_input (struct v4l2_driver *drv)
+{
+ struct v4l2_input *p=NULL;
+ struct drv_list *list;
+ int ok=0,ret,i;
+ v4l2_std_id id;
+
+ free_list(&drv->inputs);
+
+ list=drv->inputs=calloc(1,sizeof(*drv->inputs));
+ assert (list!=NULL);
+
+ for (i=0; ok==0; i++) {
+ p=calloc(1,sizeof(*p));
+ assert (p);
+ p->index=i;
+ ok=xioctl(drv->fd,VIDIOC_ENUMINPUT,p);
+ if (ok<0) {
+ ok=errno;
+ free(p);
+ break;
+ }
+ if (drv->debug) {
+ printf ("INPUT: index=%d, name=%s, type=%d, audioset=%d, "
+ "tuner=%d, std=%08x, status=%d\n",
+ p->index,p->name,p->type,p->audioset, p->tuner,
+ (unsigned int)p->std, p->status);
+ }
+ if (list->curr) {
+ list->next=calloc(1,sizeof(*list->next));
+ list=list->next;
+ assert (list!=NULL);
+ }
+ list->curr=p;
+ }
+ if (i>0 && ok==-EINVAL)
+ return 0;
+ return ok;
+}
+
+int v4l2_enum_fmt (struct v4l2_driver *drv, enum v4l2_buf_type type)
+{
+ struct v4l2_fmtdesc *p=NULL;
+ struct v4l2_format fmt;
+ struct drv_list *list;
+ int ok=0,ret,i;
+ v4l2_std_id id;
+
+ free_list(&drv->fmt_caps);
+
+ list=drv->fmt_caps=calloc(1,sizeof(*drv->fmt_caps));
+ assert (list!=NULL);
+
+ for (i=0; ok==0; i++) {
+ p=calloc(1,sizeof(*p));
+ assert (p!=NULL);
+
+ p->index=i;
+ p->type =type;
+
+ ok=xioctl(drv->fd,VIDIOC_ENUM_FMT,p);
+ if (ok<0) {
+ ok=errno;
+ free(p);
+ break;
+ }
+ if (drv->debug) {
+ printf ("FORMAT: index=%d, type=%d, flags=%d, description='%s'\n\t"
+ "fourcc=%c%c%c%c\n",
+ p->index, p->type, p->flags,p->description,
+ p->pixelformat & 0xff,
+ (p->pixelformat >> 8) & 0xff,
+ (p->pixelformat >> 16) & 0xff,
+ (p->pixelformat >> 24) & 0xff
+ );
+ }
+ if (list->curr) {
+ list->next=calloc(1,sizeof(*list->next));
+ list=list->next;
+ assert (list!=NULL);
+ }
+ list->curr=p;
+ }
+ if (i>0 && ok==-EINVAL)
+ return 0;
+ return ok;
+}
+
+/****************************************************************************
+ Set routines - currently, it also checks results with Get
+ ****************************************************************************/
+int v4l2_setget_std (struct v4l2_driver *drv, enum v4l2_direction dir, v4l2_std_id *id)
+{
+ v4l2_std_id s_id=*id;
+ int ret=0;
+ char s[256];
+
+ if (dir & V4L2_SET) {
+ ret=xioctl(drv->fd,VIDIOC_S_STD,&s_id);
+ if (ret<0) {
+ ret=errno;
+
+ sprintf (s,"while trying to set STD to %08x",
+ (unsigned int) *id);
+ perror(s);
+ }
+ }
+
+ if (dir & V4L2_GET) {
+ ret=xioctl(drv->fd,VIDIOC_G_STD,&s_id);
+ if (ret<0) {
+ ret=errno;
+ perror ("while trying to get STD id");
+ }
+ }
+
+ if (dir == V4L2_SET_GET) {
+ if (*id & s_id) {
+ if (*id != s_id) {
+ printf ("Warning: Received a std subset (%08x"
+ " std) while trying to adjust to %08x\n",
+ (unsigned int) s_id,(unsigned int) *id);
+ }
+ } else {
+ fprintf (stderr,"Error: Received %08x std while trying"
+ " to adjust to %08x\n",
+ (unsigned int) s_id,(unsigned int) *id);
+ }
+ }
+ return ret;
+}
+
+int v4l2_setget_input (struct v4l2_driver *drv, enum v4l2_direction dir, struct v4l2_input *input)
+{
+ int ok=0,ret,i;
+ unsigned int inp=input->index;
+ char s[256];
+
+ if (dir & V4L2_SET) {
+ ret=xioctl(drv->fd,VIDIOC_S_INPUT,input);
+ if (ret<0) {
+ ret=errno;
+ sprintf (s,"while trying to set INPUT to %d\n", inp);
+ perror(s);
+ }
+ }
+
+ if (dir & V4L2_GET) {
+ ret=xioctl(drv->fd,VIDIOC_G_INPUT,input);
+ if (ret<0) {
+ perror ("while trying to get INPUT id\n");
+ }
+ }
+
+ if (dir & V4L2_SET_GET) {
+ if (input->index != inp) {
+ printf ("Input is different than expected (received %i, set %i)\n",
+ inp, input->index);
+ }
+ }
+
+ return ok;
+}
+
+int v4l2_gettryset_fmt_cap (struct v4l2_driver *drv, enum v4l2_direction dir,
+ struct v4l2_format *fmt,uint32_t width, uint32_t height,
+ uint32_t pixelformat, enum v4l2_field field)
+{
+ struct v4l2_pix_format *pix=&(fmt->fmt.pix);
+ int ret=0;
+
+ fmt->type=V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (dir == V4L2_GET) {
+ ret=xioctl(drv->fd,VIDIOC_G_FMT,fmt);
+ if (ret < 0) {
+ ret=errno;
+ perror("VIDIOC_G_FMT failed\n");
+ }
+ return ret;
+ } else if (dir & (~(V4L2_TRY|V4L2_SET)) ) {
+ perror ("Invalid direction\n");
+ return EINVAL;
+ }
+
+ if (dir & (V4L2_TRY|V4L2_SET)) {
+ pix->width = width;
+ pix->height = height;
+ pix->pixelformat = pixelformat;
+ pix->field = field;
+ /*
+ enum v4l2_colorspace colorspace;
+ */
+
+ if (dir & V4L2_TRY) {
+ ret=xioctl(drv->fd,VIDIOC_TRY_FMT,fmt);
+ if (ret < 0) {
+ perror("VIDIOC_TRY_FMT failed\n");
+ }
+ }
+
+ if (dir & V4L2_SET) {
+ ret=xioctl(drv->fd,VIDIOC_S_FMT,fmt);
+ if (ret < 0) {
+ perror("VIDIOC_S_FMT failed\n");
+ }
+ drv->sizeimage=pix->sizeimage;
+ }
+
+ if (pix->pixelformat != pixelformat) {
+ fprintf(stderr,"Error: asked for format %d, received %d",pixelformat,
+ pix->pixelformat);
+ }
+
+ if (pix->width != width) {
+ fprintf(stderr,"Error: asked for format %d, received %d\n",width,
+ pix->width);
+ }
+
+ if (pix->height != height) {
+ fprintf(stderr,"Error: asked for format %d, received %d\n",height,
+ pix->height);
+ }
+
+ if (pix->bytesperline == 0 ) {
+ fprintf(stderr,"Error: bytesperline = 0\n");
+ }
+
+ if (pix->sizeimage == 0 ) {
+ fprintf(stderr,"Error: sizeimage = 0\n");
+ }
+ }
+
+ if (drv->debug)
+ printf( "FMT SET: %dx%d, fourcc=%c%c%c%c, %d bytes/line,"
+ " %d bytes/frame, colorspace=0x%08x\n",
+ pix->width,pix->height,
+ pix->pixelformat & 0xff,
+ (pix->pixelformat >> 8) & 0xff,
+ (pix->pixelformat >> 16) & 0xff,
+ (pix->pixelformat >> 24) & 0xff,
+ pix->bytesperline,
+ pix->sizeimage,
+ pix->colorspace);
+
+ return 0;
+}
+
+/****************************************************************************
+ Get routines
+ ****************************************************************************/
+int v4l2_get_parm (struct v4l2_driver *drv)
+{
+ int ret;
+ struct v4l2_captureparm *c;
+
+ drv->parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if ((ret=xioctl(drv->fd,VIDIOC_G_PARM,&drv->parm))>=0) {
+ c=&drv->parm.parm.capture;
+ printf ("PARM: capability=%d, capturemode=%d, %.3f fps "
+ "ext=%x, readbuf=%d\n",
+ c->capability,
+ c->capturemode,
+ c->timeperframe.denominator*1./c->timeperframe.numerator,
+ c->extendedmode, c->readbuffers);
+ } else {
+ ret=errno;
+
+ perror ("VIDIOC_G_PARM");
+ }
+
+ return ret;
+}
+
+/****************************************************************************
+ Queue and stream control
+ ****************************************************************************/
+
+int v4l2_free_bufs(struct v4l2_driver *drv)
+{
+ unsigned int i;
+
+ if (!drv->n_bufs)
+ return 0;
+
+ /* Requests the driver to free all buffers */
+ drv->reqbuf.count = 0;
+ drv->reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ drv->reqbuf.memory = V4L2_MEMORY_MMAP;
+
+ /* stop capture */
+ if (xioctl(drv->fd,VIDIOC_STREAMOFF,&drv->reqbuf.type)<0)
+ return errno;
+
+ sleep (1); // FIXME: Should check if all buffers are stopped
+
+/* V4L2 API says REQBUFS with count=0 should be used to release buffer.
+ However, video-buf.c doesn't implement it.
+ */
+#if 0
+ if (xioctl(drv->fd,VIDIOC_REQBUFS,&drv->reqbuf)<0) {
+ perror("reqbufs while freeing buffers");
+ return errno;
+ }
+#endif
+
+ if (drv->reqbuf.count != 0) {
+ fprintf(stderr,"REQBUFS returned %d buffers while asking for freeing it!\n",
+ drv->reqbuf.count);
+ }
+
+ for (i = 0; i < drv->n_bufs; i++) {
+ if (drv->bufs[i].length)
+ munmap(drv->bufs[i].start, drv->bufs[i].length);
+ if (drv->v4l2_bufs[i])
+ free (drv->v4l2_bufs[i]);
+ }
+
+ free(drv->v4l2_bufs);
+ free(drv->bufs);
+
+ drv->v4l2_bufs=NULL;
+ drv->bufs=NULL;
+ drv->n_bufs=0;
+
+ return 0;
+}
+
+int v4l2_mmap_bufs(struct v4l2_driver *drv, unsigned int num_buffers)
+{
+ /* Frees previous allocations, if required */
+ v4l2_free_bufs(drv);
+
+ if (drv->sizeimage==0) {
+ fprintf(stderr,"Image size is zero! Can't proceed\n");
+ return -1;
+ }
+ /* Requests the specified number of buffers */
+ drv->reqbuf.count = num_buffers;
+ drv->reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ drv->reqbuf.memory = V4L2_MEMORY_MMAP;
+
+ if (xioctl(drv->fd,VIDIOC_REQBUFS,&drv->reqbuf)<0) {
+ perror("reqbufs");
+ return errno;
+ }
+
+ if (drv->debug)
+ printf ("REQBUFS: count=%d, type=%s, memory=%s\n",
+ drv->reqbuf.count,
+ prt_names(drv->reqbuf.type,v4l2_type_names),
+ prt_names(drv->reqbuf.memory,v4l2_memory_names));
+
+ /* Allocates the required number of buffers */
+ drv->v4l2_bufs=calloc(drv->reqbuf.count, sizeof(*drv->v4l2_bufs));
+ assert(drv->v4l2_bufs!=NULL);
+ drv->bufs=calloc(drv->reqbuf.count, sizeof(*drv->bufs));
+ assert(drv->bufs!=NULL);
+
+ for (drv->n_bufs = 0; drv->n_bufs < drv->reqbuf.count; drv->n_bufs++) {
+ struct v4l2_buffer *p;
+ struct v4l2_timecode *tc;
+
+ /* Requests kernel buffers to be mmapped */
+ p=drv->v4l2_bufs[drv->n_bufs]=calloc(1,sizeof(*p));
+ assert (p!=NULL);
+ p->index = drv->n_bufs;
+ p->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ p->memory = V4L2_MEMORY_MMAP;
+ if (xioctl(drv->fd,VIDIOC_QUERYBUF,p)<0) {
+ int ret=errno;
+ perror("querybuf");
+
+ free (drv->v4l2_bufs[drv->n_bufs]);
+
+ v4l2_free_bufs(drv);
+ return ret;
+ }
+
+ if (drv->debug)
+ prt_buf_info("QUERYBUF",p);
+
+ if (drv->sizeimage != p->length) {
+ if (drv->sizeimage < p->length) {
+ fprintf (stderr, "QUERYBUF: ERROR: VIDIOC_S_FMT said buffer should have %d size, but received %d from QUERYBUF!\n",
+ drv->sizeimage, p->length);
+ } else {
+ fprintf (stderr, "QUERYBUF: Expecting %d size, received %d buff length\n",
+ drv->sizeimage, p->length);
+ }
+ }
+
+ drv->bufs[drv->n_bufs].length = p->length;
+ drv->bufs[drv->n_bufs].start = mmap (NULL, /* start anywhere */
+ p->length,
+ PROT_READ | PROT_WRITE, /* required */
+ MAP_SHARED, /* recommended */
+ drv->fd, p->m.offset);
+
+
+ if (MAP_FAILED == drv->bufs[drv->n_bufs].start) {
+ perror("mmap");
+
+ free (drv->v4l2_bufs[drv->n_bufs]);
+ v4l2_free_bufs(drv);
+ return errno;
+ }
+ }
+
+ return 0;
+}
+
+int v4l2_rcvbuf(struct v4l2_driver *drv, v4l2_recebe_buffer *rec_buf)
+{
+ int ret;
+
+ struct v4l2_buffer buf;
+ memset (&buf, 0, sizeof(buf));
+
+ buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ buf.memory = V4L2_MEMORY_MMAP;
+
+ if (-1 == xioctl (drv->fd, VIDIOC_DQBUF, &buf)) {
+ switch (errno) {
+ case EAGAIN:
+ return 0;
+
+ case EIO:
+ /* Could ignore EIO, see spec. */
+
+ /* fall through */
+
+ default:
+ perror ("dqbuf");
+ return errno;
+ }
+ }
+ prt_buf_info("DQBUF",&buf);
+
+ assert (buf.index < drv->n_bufs);
+
+ ret = rec_buf (&buf,&drv->bufs[buf.index]);
+
+ if (ret) {
+ v4l2_free_bufs(drv);
+ return ret;
+ }
+
+ if (-1 == xioctl (drv->fd, VIDIOC_QBUF, &buf)) {
+ perror ("qbuf");
+ return errno;
+ }
+ return 0;
+}
+
+
+int v4l2_start_streaming(struct v4l2_driver *drv)
+{
+ uint32_t i;
+ struct v4l2_buffer buf;
+
+ if (drv->debug)
+ printf("Activating %d queues\n", drv->n_bufs);
+ for (i = 0; i < drv->n_bufs; i++) {
+ int res;
+
+ memset(&buf, 0, sizeof(buf));
+ buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ buf.memory = V4L2_MEMORY_MMAP;
+ buf.index = i;
+
+ res = xioctl (drv->fd, VIDIOC_QBUF, &buf);
+
+ if (!res)
+ prt_buf_info("QBUF",&buf);
+ else {
+ perror("qbuf");
+ return errno;
+ }
+ }
+
+ /* Activates stream */
+ if (drv->debug)
+ printf("Enabling streaming\n");
+
+ if (xioctl(drv->fd,VIDIOC_STREAMON,&drv->reqbuf.type)<0)
+ return errno;
+
+ return 0;
+}
+
+int v4l2_stop_streaming(struct v4l2_driver *drv)
+{
+ v4l2_free_bufs(drv);
+
+ return 0;
+}
+
+/****************************************************************************
+ Close V4L2, disallocating all structs
+ ****************************************************************************/
+int v4l2_close (struct v4l2_driver *drv)
+{
+ v4l2_free_bufs(drv);
+
+ free_list(&drv->stds);
+ free_list(&drv->inputs);
+ free_list(&drv->fmt_caps);
+
+ return (close(drv->fd));
+}
+
+/****************************************************************************
+ Get/Set frequency
+ ****************************************************************************/
+
+int v4l2_getset_freq (struct v4l2_driver *drv, enum v4l2_direction dir,
+ double *freq)
+{
+ struct v4l2_tuner tun;
+ struct v4l2_frequency frq;
+ double d = 62500;
+ unsigned int counter;
+
+ memset(&tun, 0, sizeof(tun));
+
+ if (-1 == xioctl (drv->fd, VIDIOC_G_TUNER, &tun)) {
+ perror ("g_tuner");
+ printf("Assuming 62.5 kHz step\n");
+ } else {
+ if (tun.capability & V4L2_TUNER_CAP_LOW)
+ d=62.5;
+ }
+
+ if (drv->debug) {
+ if (tun.capability & V4L2_TUNER_CAP_LOW)
+ printf("62.5 Hz step\n");
+ else
+ printf("62.5 kHz step\n");
+ }
+
+ memset(&frq, 0, sizeof(frq));
+
+ frq.type = V4L2_TUNER_ANALOG_TV;
+
+ if (dir & V4L2_GET) {
+ if (-1 == xioctl (drv->fd, VIDIOC_G_FREQUENCY, &frq)) {
+ perror ("s_frequency");
+ return errno;
+ }
+ *freq = frq.frequency * d;
+ if (drv->debug)
+ printf("board is at freq %4.3f MHz (%d)\n",
+ *freq/1000000, frq.frequency);
+ } else {
+ frq.frequency = (uint32_t)(((*freq)+d/2) / d);
+
+ if (-1 == xioctl (drv->fd, VIDIOC_S_FREQUENCY, &frq)) {
+ perror ("s_frequency");
+ return errno;
+ }
+ if (drv->debug)
+ printf("board set to freq %4.3f MHz (%d)\n",
+ *freq/1000000, frq.frequency);
+
+ }
+ return 0;
+}
diff --git a/v4l2-apps/libv4l2util/v4l2_driver.h b/v4l2-apps/libv4l2util/v4l2_driver.h
new file mode 100644
index 000000000..b5d5dd22d
--- /dev/null
+++ b/v4l2-apps/libv4l2util/v4l2_driver.h
@@ -0,0 +1,81 @@
+/*
+ Copyright (C) 2006 Mauro Carvalho Chehab <mchehab@infradead.org>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+ */
+
+#include <stddef.h>
+#include <stdint.h>
+#include <sys/time.h>
+#include <linux/videodev2.h>
+
+struct drv_list {
+ void *curr;
+ struct drv_list *next;
+};
+
+struct v4l2_t_buf {
+ void *start;
+ size_t length;
+};
+
+typedef int v4l2_recebe_buffer (struct v4l2_buffer *v4l2_buf, struct v4l2_t_buf *buf);
+
+struct v4l2_driver {
+ int fd; /* Driver descriptor */
+
+ int debug;
+
+ /* V4L2 structs */
+ struct v4l2_capability cap;
+ struct v4l2_streamparm parm;
+
+ /* Several lists to be used to store enumbered values */
+ struct drv_list *stds,*inputs,*fmt_caps;
+
+ /* Stream control */
+ struct v4l2_requestbuffers reqbuf;
+ struct v4l2_buffer **v4l2_bufs;
+ struct v4l2_t_buf *bufs;
+ uint32_t sizeimage,n_bufs;
+
+ /* Queue control */
+ uint32_t waitq, currq;
+};
+
+enum v4l2_direction {
+ V4L2_GET = 1, // Bit 1
+ V4L2_SET = 2, // Bit 2
+ V4L2_SET_GET = 3, // Bits 1 and 2 - sets then gets and compare
+ V4L2_TRY = 4, // Bit 3
+ V4L2_TRY_SET = 6, // Bits 3 and 2 - try then sets
+ V4L2_TRY_SET_GET = 7, // Bits 3, 2 and 1- try, sets and gets
+};
+
+int v4l2_open (char *device, int debug, struct v4l2_driver *drv);
+int v4l2_close (struct v4l2_driver *drv);
+int v4l2_enum_stds (struct v4l2_driver *drv);
+int v4l2_enum_input (struct v4l2_driver *drv);
+int v4l2_enum_fmt (struct v4l2_driver *drv,enum v4l2_buf_type type);
+int v4l2_get_parm (struct v4l2_driver *drv);
+int v4l2_setget_std (struct v4l2_driver *drv, enum v4l2_direction dir, v4l2_std_id *id);
+int v4l2_setget_input (struct v4l2_driver *drv, enum v4l2_direction dir, struct v4l2_input *input);
+int v4l2_gettryset_fmt_cap (struct v4l2_driver *drv, enum v4l2_direction dir,
+ struct v4l2_format *fmt,uint32_t width, uint32_t height,
+ uint32_t pixelformat, enum v4l2_field field);
+int v4l2_mmap_bufs(struct v4l2_driver *drv, unsigned int num_buffers);
+int v4l2_free_bufs(struct v4l2_driver *drv);
+int v4l2_start_streaming(struct v4l2_driver *drv);
+int v4l2_stop_streaming(struct v4l2_driver *drv);
+int v4l2_rcvbuf(struct v4l2_driver *drv, v4l2_recebe_buffer *v4l2_rec_buf);
+int v4l2_getset_freq (struct v4l2_driver *drv, enum v4l2_direction dir,
+ double *freq);
+