git-fixes.patch 150 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363
  1. diff --git a/ChangeLog b/ChangeLog
  2. deleted file mode 100644
  3. index 02fc6fa..0000000
  4. --- a/ChangeLog
  5. +++ /dev/null
  6. @@ -1,57 +0,0 @@
  7. -2006-04-07 Adam Jackson <ajax@freedesktop.org>
  8. -
  9. - * configure.ac:
  10. - * src/v4l.c:
  11. - Bump to 0.1.1 for Xv changes.
  12. -
  13. -2006-04-07 Aaron Plattner <aplattner@nvidia.com>
  14. -
  15. - * src/v4l.c: (V4lPutVideo), (V4lPutStill):
  16. - Add a DrawablePtr argument to the XV functions to pave the way for
  17. - redirected video.
  18. -
  19. -2006-04-07 Adam Jackson <ajax@freedesktop.org>
  20. -
  21. - * configure.ac:
  22. - * src/v4l.c:
  23. - Unlibcwrap. Bump server version requirement. Bump to 0.1.0.
  24. -
  25. -2005-12-20 Kevin E. Martin <kem-at-freedesktop-dot-org>
  26. -
  27. - * configure.ac:
  28. - Update package version for X11R7 release.
  29. -
  30. -2005-12-14 Kevin E. Martin <kem-at-freedesktop-dot-org>
  31. -
  32. - * configure.ac:
  33. - Update package version number for final X11R7 release candidate.
  34. -
  35. -2005-12-06 Kevin E. Martin <kem-at-freedesktop-dot-org>
  36. -
  37. - * man/Makefile.am:
  38. - Change *man_SOURCES ==> *man_PRE to fix autotools warnings.
  39. -
  40. -2005-12-03 Kevin E. Martin <kem-at-freedesktop-dot-org>
  41. -
  42. - * configure.ac:
  43. - Update package version number for X11R7 RC3 release.
  44. -
  45. -2005-12-01 Kevin E. Martin <kem-at-freedesktop-dot-org>
  46. -
  47. - * configure.ac:
  48. - Remove extraneous AC_MSG_RESULT.
  49. -
  50. -2005-11-29 Adam Jackson <ajax@freedesktop.org>
  51. -
  52. - * configure.ac:
  53. - Only build dlloader modules by default.
  54. -
  55. -2005-11-09 Kevin E. Martin <kem-at-freedesktop-dot-org>
  56. -
  57. - * configure.ac:
  58. - Update package version number for X11R7 RC2 release.
  59. -
  60. -2005-11-01 Kevin E. Martin <kem-at-freedesktop-dot-org>
  61. -
  62. - * configure.ac:
  63. - Update pkgcheck dependencies to work with separate build roots.
  64. diff --git a/Makefile.am b/Makefile.am
  65. index 3ae2692..4c278ba 100644
  66. --- a/Makefile.am
  67. +++ b/Makefile.am
  68. @@ -18,6 +18,15 @@
  69. # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  70. # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  71. -AUTOMAKE_OPTIONS = foreign
  72. SUBDIRS = src man
  73. -EXTRA_DIST = README
  74. +MAINTAINERCLEANFILES = ChangeLog INSTALL
  75. +
  76. +.PHONY: ChangeLog INSTALL
  77. +
  78. +INSTALL:
  79. + $(INSTALL_CMD)
  80. +
  81. +ChangeLog:
  82. + $(CHANGELOG_CMD)
  83. +
  84. +dist-hook: ChangeLog INSTALL
  85. diff --git a/configure.ac b/configure.ac
  86. index d9ac542..c490919 100644
  87. --- a/configure.ac
  88. +++ b/configure.ac
  89. @@ -20,57 +20,56 @@
  90. #
  91. # Process this file with autoconf to produce a configure script
  92. -AC_PREREQ(2.57)
  93. +# Initialize Autoconf
  94. +AC_PREREQ([2.60])
  95. AC_INIT([xf86-video-v4l],
  96. - 0.2.0,
  97. + [0.2.0],
  98. [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
  99. - xf86-video-v4l)
  100. -
  101. + [xf86-video-v4l])
  102. AC_CONFIG_SRCDIR([Makefile.am])
  103. -AM_CONFIG_HEADER([config.h])
  104. +AC_CONFIG_HEADERS([config.h])
  105. AC_CONFIG_AUX_DIR(.)
  106. -AM_INIT_AUTOMAKE([dist-bzip2])
  107. -
  108. +# Initialize Automake
  109. +AM_INIT_AUTOMAKE([foreign dist-bzip2])
  110. AM_MAINTAINER_MODE
  111. -# Checks for programs.
  112. +# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
  113. +m4_ifndef([XORG_MACROS_VERSION],
  114. + [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
  115. +XORG_MACROS_VERSION(1.8)
  116. +XORG_DEFAULT_OPTIONS
  117. +
  118. +# Initialize libtool
  119. AC_DISABLE_STATIC
  120. AC_PROG_LIBTOOL
  121. -AC_PROG_CC
  122. AH_TOP([#include "xorg-server.h"])
  123. +# Define a configure option for an alternate module directory
  124. AC_ARG_WITH(xorg-module-dir,
  125. - AC_HELP_STRING([--with-xorg-module-dir=DIR],
  126. + AS_HELP_STRING([--with-xorg-module-dir=DIR],
  127. [Default xorg module directory [[default=$libdir/xorg/modules]]]),
  128. [moduledir="$withval"],
  129. [moduledir="$libdir/xorg/modules"])
  130. -# Checks for extensions
  131. +# Store the list of server defined optional extensions in REQUIRED_MODULES
  132. XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
  133. XORG_DRIVER_CHECK_EXT(XV, videoproto)
  134. -# Checks for pkg-config packages
  135. +# Obtain compiler/linker options for the driver dependencies
  136. PKG_CHECK_MODULES(XORG, [xorg-server >= 1.0.99.901 xproto $REQUIRED_MODULES])
  137. -sdkdir=$(pkg-config --variable=sdkdir xorg-server)
  138. # Checks for libraries.
  139. -# Checks for header files.
  140. -AC_HEADER_STDC
  141. -
  142. -AC_SUBST([XORG_CFLAGS])
  143. AC_SUBST([moduledir])
  144. DRIVER_NAME=v4l
  145. AC_SUBST([DRIVER_NAME])
  146. -XORG_MANPAGE_SECTIONS
  147. -XORG_RELEASE_VERSION
  148. -
  149. -AC_OUTPUT([
  150. - Makefile
  151. - src/Makefile
  152. - man/Makefile
  153. +AC_CONFIG_FILES([
  154. + Makefile
  155. + src/Makefile
  156. + man/Makefile
  157. ])
  158. +AC_OUTPUT
  159. diff --git a/man/Makefile.am b/man/Makefile.am
  160. index f0eb29b..b3688ce 100644
  161. --- a/man/Makefile.am
  162. +++ b/man/Makefile.am
  163. @@ -1,27 +1,24 @@
  164. #
  165. # Copyright 2005 Sun Microsystems, Inc. All rights reserved.
  166. -#
  167. -# Permission to use, copy, modify, distribute, and sell this software and its
  168. -# documentation for any purpose is hereby granted without fee, provided that
  169. -# the above copyright notice appear in all copies and that both that
  170. -# copyright notice and this permission notice appear in supporting
  171. -# documentation.
  172. -#
  173. -# The above copyright notice and this permission notice shall be included
  174. -# in all copies or substantial portions of the Software.
  175. -#
  176. -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  177. -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  178. -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  179. -# IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
  180. -# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  181. -# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  182. -# OTHER DEALINGS IN THE SOFTWARE.
  183. -#
  184. -# Except as contained in this notice, the name of the copyright holders shall
  185. -# not be used in advertising or otherwise to promote the sale, use or
  186. -# other dealings in this Software without prior written authorization
  187. -# from the copyright holders.
  188. +#
  189. +# Permission is hereby granted, free of charge, to any person obtaining a
  190. +# copy of this software and associated documentation files (the "Software"),
  191. +# to deal in the Software without restriction, including without limitation
  192. +# the rights to use, copy, modify, merge, publish, distribute, sublicense,
  193. +# and/or sell copies of the Software, and to permit persons to whom the
  194. +# Software is furnished to do so, subject to the following conditions:
  195. +#
  196. +# The above copyright notice and this permission notice (including the next
  197. +# paragraph) shall be included in all copies or substantial portions of the
  198. +# Software.
  199. +#
  200. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  201. +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  202. +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  203. +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  204. +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  205. +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  206. +# DEALINGS IN THE SOFTWARE.
  207. #
  208. drivermandir = $(DRIVER_MAN_DIR)
  209. @@ -34,25 +31,11 @@ EXTRA_DIST = @DRIVER_NAME@.man
  210. CLEANFILES = $(driverman_DATA)
  211. -SED = sed
  212. -# Strings to replace in man pages
  213. -XORGRELSTRING = @PACKAGE_STRING@
  214. - XORGMANNAME = X Version 11
  215. +# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
  216. -MAN_SUBSTS = \
  217. - -e 's|__vendorversion__|"$(XORGRELSTRING)" "$(XORGMANNAME)"|' \
  218. - -e 's|__xorgversion__|"$(XORGRELSTRING)" "$(XORGMANNAME)"|' \
  219. - -e 's|__xservername__|Xorg|g' \
  220. - -e 's|__xconfigfile__|xorg.conf|g' \
  221. - -e 's|__projectroot__|$(prefix)|g' \
  222. - -e 's|__appmansuffix__|$(APP_MAN_SUFFIX)|g' \
  223. - -e 's|__drivermansuffix__|$(DRIVER_MAN_SUFFIX)|g' \
  224. - -e 's|__adminmansuffix__|$(ADMIN_MAN_SUFFIX)|g' \
  225. - -e 's|__miscmansuffix__|$(MISC_MAN_SUFFIX)|g' \
  226. - -e 's|__filemansuffix__|$(FILE_MAN_SUFFIX)|g'
  227. SUFFIXES = .$(DRIVER_MAN_SUFFIX) .man
  228. .man.$(DRIVER_MAN_SUFFIX):
  229. - sed $(MAN_SUBSTS) < $< > $@
  230. + $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
  231. diff --git a/man/v4l.man b/man/v4l.man
  232. index 7d35b86..dc1e201 100644
  233. --- a/man/v4l.man
  234. +++ b/man/v4l.man
  235. @@ -34,6 +34,6 @@ Please refer to __xconfigfile__(__filemansuffix__) for general configuration
  236. details. This section only covers configuration details specific to this
  237. driver.
  238. .SH "SEE ALSO"
  239. -__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), xorgconfig(__appmansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)
  240. +__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)
  241. .SH AUTHORS
  242. Authors include: Gerd Knorr <kraxel@bytesex.org>
  243. diff --git a/src/Makefile.am b/src/Makefile.am
  244. index ed30a80..08afe60 100644
  245. --- a/src/Makefile.am
  246. +++ b/src/Makefile.am
  247. @@ -28,7 +28,6 @@ v4l_drv_la_LTLIBRARIES = v4l_drv.la
  248. v4l_drv_la_LDFLAGS = -module -avoid-version
  249. v4l_drv_ladir = @moduledir@/drivers
  250. -v4l_drv_la_SOURCES = \
  251. - v4l.c
  252. -
  253. -EXTRA_DIST = videodev.h
  254. +v4l_drv_la_SOURCES = \
  255. + v4l.c \
  256. + videodev.h
  257. diff --git a/src/v4l.c b/src/v4l.c
  258. index b827f80..10e782b 100644
  259. --- a/src/v4l.c
  260. +++ b/src/v4l.c
  261. @@ -1,6 +1,9 @@
  262. /*
  263. - * video4linux Xv Driver
  264. + * video4linux Xv Driver
  265. * based on Michael Schimek's permedia 2 driver.
  266. + *
  267. + * Copyright (c) 2011 Mauro Carvalho Chehab <mchehab@redhat.com> for:
  268. + * - Major rewrite, as driver got ported to V4L2 API
  269. */
  270. #ifdef HAVE_CONFIG_H
  271. @@ -9,12 +12,16 @@
  272. #include <sys/types.h>
  273. #include <sys/stat.h>
  274. +#include <ctype.h>
  275. +
  276. #include <fcntl.h>
  277. #include <errno.h>
  278. #include <string.h>
  279. #include <stdio.h>
  280. +#include <unistd.h>
  281. +#include <sys/ioctl.h>
  282. -#include "videodev.h"
  283. +#include "videodev2.h"
  284. #include "xf86.h"
  285. #include "xf86_OSproc.h"
  286. #include "xf86Pci.h"
  287. @@ -25,8 +32,9 @@
  288. #include "regionstr.h"
  289. #include "dgaproc.h"
  290. #include "xf86str.h"
  291. +#include "fourcc.h"
  292. -#include <asm/ioctl.h> /* _IORW(xxx) #defines are here */
  293. +#include <asm/ioctl.h> /* _IORW(xxx) #defines are here */
  294. #if 0
  295. # define DEBUG(x) (x)
  296. @@ -34,20 +42,22 @@
  297. # define DEBUG(x)
  298. #endif
  299. +/***************************************************************************/
  300. +
  301. static void V4LIdentify(int flags);
  302. static Bool V4LProbe(DriverPtr drv, int flags);
  303. static const OptionInfoRec * V4LAvailableOptions(int chipid, int busid);
  304. _X_EXPORT DriverRec V4L = {
  305. - 40000,
  306. - "v4l",
  307. - V4LIdentify, /* Identify*/
  308. - V4LProbe, /* Probe */
  309. - V4LAvailableOptions,
  310. - NULL,
  311. - 0
  312. -};
  313. -
  314. + .driverVersion = 50000,
  315. + .driverName = "v4l",
  316. + .Identify = V4LIdentify,
  317. + .Probe = V4LProbe,
  318. + .AvailableOptions = V4LAvailableOptions,
  319. + .module = NULL,
  320. + .refCount = 0,
  321. + .driverFunc = NULL, /* FIXME: Need to implement for new probing mode */
  322. +};
  323. #ifdef XFree86LOADER
  324. @@ -55,16 +65,16 @@ static MODULESETUPPROTO(v4lSetup);
  325. static XF86ModuleVersionInfo v4lVersRec =
  326. {
  327. - "v4l",
  328. - MODULEVENDORSTRING,
  329. - MODINFOSTRING1,
  330. - MODINFOSTRING2,
  331. - XORG_VERSION_CURRENT,
  332. - 0, 1, 1,
  333. - ABI_CLASS_VIDEODRV,
  334. - ABI_VIDEODRV_VERSION,
  335. - MOD_CLASS_NONE,
  336. - {0,0,0,0}
  337. + "v4l",
  338. + MODULEVENDORSTRING,
  339. + MODINFOSTRING1,
  340. + MODINFOSTRING2,
  341. + XORG_VERSION_CURRENT,
  342. + 0, 1, 1,
  343. + ABI_CLASS_VIDEODRV,
  344. + ABI_VIDEODRV_VERSION,
  345. + MOD_CLASS_NONE,
  346. + {0,0,0,0}
  347. };
  348. _X_EXPORT XF86ModuleData v4lModuleData = { &v4lVersRec, v4lSetup, NULL };
  349. @@ -72,32 +82,32 @@ _X_EXPORT XF86ModuleData v4lModuleData = { &v4lVersRec, v4lSetup, NULL };
  350. static pointer
  351. v4lSetup(pointer module, pointer opts, int *errmaj, int *errmin)
  352. {
  353. - const char *osname;
  354. - static Bool setupDone = FALSE;
  355. -
  356. - if (setupDone) {
  357. - if (errmaj)
  358. - *errmaj = LDR_ONCEONLY;
  359. - return NULL;
  360. - }
  361. -
  362. - setupDone = TRUE;
  363. -
  364. - /* Check that we're being loaded on a Linux system */
  365. - LoaderGetOS(&osname, NULL, NULL, NULL);
  366. - if (!osname || strcmp(osname, "linux") != 0) {
  367. - if (errmaj)
  368. - *errmaj = LDR_BADOS;
  369. - if (errmin)
  370. - *errmin = 0;
  371. - return NULL;
  372. - } else {
  373. - /* OK */
  374. -
  375. - xf86AddDriver (&V4L, module, 0);
  376. -
  377. - return (pointer)1;
  378. - }
  379. + const char *osname;
  380. + static Bool setupDone = FALSE;
  381. +
  382. + if (setupDone) {
  383. + if (errmaj)
  384. + *errmaj = LDR_ONCEONLY;
  385. + return NULL;
  386. + }
  387. +
  388. + setupDone = TRUE;
  389. +
  390. + /* Check that we're being loaded on a Linux system */
  391. + LoaderGetOS(&osname, NULL, NULL, NULL);
  392. + if (!osname || strcmp(osname, "linux") != 0) {
  393. + if (errmaj)
  394. + *errmaj = LDR_BADOS;
  395. + if (errmin)
  396. + *errmin = 0;
  397. + return NULL;
  398. + } else {
  399. + /* OK */
  400. +
  401. + xf86AddDriver (&V4L, module, 0);
  402. +
  403. + return (pointer)1;
  404. + }
  405. }
  406. #else
  407. @@ -112,25 +122,28 @@ v4lSetup(pointer module, pointer opts, int *errmaj, int *errmin)
  408. #define VIDEO_YUV 2 /* yuv overlay (to offscreen memory + hw scaling) */
  409. #define VIDEO_RECLIP 3 /* temporarly off, window clipping changes */
  410. +typedef struct _XvV4LCtrlRec {
  411. + struct v4l2_queryctrl qctrl;
  412. + Atom xv;
  413. +} XvV4LCtrlRec, *XvV4LCtrlPtr;
  414. +
  415. typedef struct _PortPrivRec {
  416. ScrnInfoPtr pScrn;
  417. - FBAreaPtr pFBArea[2];
  418. - int VideoOn;
  419. - Bool StreamOn;
  420. + FBAreaPtr pFBArea[2];
  421. + int VideoOn;
  422. + Bool StreamOn;
  423. /* file handle */
  424. - int nr;
  425. - struct video_capability cap;
  426. + int nr;
  427. + struct v4l2_capability cap;
  428. /* RGB overlay */
  429. - struct video_buffer rgb_fbuf;
  430. - struct video_window rgb_win;
  431. - int rgbpalette;
  432. + struct v4l2_framebuffer rgb_fbuf;
  433. + struct v4l2_window rgb_win;
  434. int rgbdepth;
  435. /* attributes */
  436. - struct video_picture pict;
  437. - struct video_audio audio;
  438. + CARD32 pixelformat;
  439. XF86VideoEncodingPtr enc;
  440. int *input;
  441. @@ -145,24 +158,21 @@ typedef struct _PortPrivRec {
  442. int yuv_width,yuv_height;
  443. XF86SurfacePtr surface;
  444. - struct video_buffer yuv_fbuf;
  445. - struct video_window yuv_win;
  446. -} PortPrivRec, *PortPrivPtr;
  447. + struct v4l2_framebuffer yuv_fbuf;
  448. + struct v4l2_window yuv_win;
  449. +
  450. + struct v4l2_standard *standard; /* FIXME: can be removed */
  451. -#define XV_ENCODING "XV_ENCODING"
  452. -#define XV_BRIGHTNESS "XV_BRIGHTNESS"
  453. -#define XV_CONTRAST "XV_CONTRAST"
  454. -#define XV_SATURATION "XV_SATURATION"
  455. -#define XV_HUE "XV_HUE"
  456. + XvV4LCtrlPtr XvV4LCtrl;
  457. + int n_qctrl;
  458. +} PortPrivRec, *PortPrivPtr;
  459. -#define XV_FREQ "XV_FREQ"
  460. -#define XV_MUTE "XV_MUTE"
  461. -#define XV_VOLUME "XV_VOLUME"
  462. +#define XV_ENCODING "XV_ENCODING"
  463. +#define XV_FREQ "XV_FREQ"
  464. -#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
  465. +#define MAKE_ATOM(a) MakeAtom(a, strlen(a), TRUE)
  466. -static Atom xvEncoding, xvBrightness, xvContrast, xvSaturation, xvHue;
  467. -static Atom xvFreq, xvMute, xvVolume;
  468. +static Atom xvEncoding, xvFreq;
  469. static XF86VideoFormatRec
  470. InputVideoFormats[] = {
  471. @@ -176,16 +186,8 @@ InputVideoFormats[] = {
  472. static const XF86AttributeRec Attributes[] = {
  473. {XvSettable | XvGettable, -1000, 1000, XV_ENCODING},
  474. - {XvSettable | XvGettable, -1000, 1000, XV_BRIGHTNESS},
  475. - {XvSettable | XvGettable, -1000, 1000, XV_CONTRAST},
  476. - {XvSettable | XvGettable, -1000, 1000, XV_SATURATION},
  477. - {XvSettable | XvGettable, -1000, 1000, XV_HUE},
  478. };
  479. -static const XF86AttributeRec VolumeAttr =
  480. - {XvSettable | XvGettable, -1000, 1000, XV_VOLUME};
  481. -static const XF86AttributeRec MuteAttr =
  482. - {XvSettable | XvGettable, 0, 1, XV_MUTE};
  483. -static const XF86AttributeRec FreqAttr =
  484. +static const XF86AttributeRec FreqAttr =
  485. {XvSettable | XvGettable, 0, 16*1000, XV_FREQ};
  486. @@ -206,59 +208,247 @@ static struct V4L_DEVICE {
  487. };
  488. /* ---------------------------------------------------------------------- */
  489. -/* forward decl */
  490. -static void V4lQueryBestSize(ScrnInfoPtr pScrn, Bool motion,
  491. - short vid_w, short vid_h, short drw_w, short drw_h,
  492. - unsigned int *p_w, unsigned int *p_h, pointer data);
  493. +static int SetV4LFmt(int fd, CARD32 pixelformat)
  494. +{
  495. + struct v4l2_framebuffer fbuf;
  496. + char *p = (char *)&pixelformat;
  497. +
  498. + memset(&fbuf, 0, sizeof(fbuf));
  499. + if (ioctl(fd, VIDIOC_G_FBUF, &fbuf) == -1) {
  500. + xf86Msg(X_ERROR, "v4l: Error %d: Can't get FBUF\n", errno);
  501. + return errno;
  502. + }
  503. + if (fbuf.fmt.pixelformat != pixelformat) {
  504. + fbuf.fmt.pixelformat = pixelformat;
  505. + if (ioctl(fd, VIDIOC_S_FBUF, &fbuf) == -1) {
  506. + xf86Msg(X_ERROR, "v4l: Error %d: Can't set FBUF to %c%c%c%c\n",
  507. + errno, p[0], p[1], p[2], p[3]);
  508. + return errno;
  509. + }
  510. + }
  511. + DEBUG(xf86Msg(X_INFO, "v4l: Set overlay format to %c%c%c%c\n",
  512. + p[0], p[1], p[2], p[3]));
  513. + return 0;
  514. +}
  515. +static int GetV4LFmt(int fd, CARD32 *pixelformat)
  516. +{
  517. + struct v4l2_framebuffer fbuf;
  518. +
  519. + memset(&fbuf, 0, sizeof(fbuf));
  520. + if (ioctl(fd, VIDIOC_G_FBUF, &fbuf) == -1) {
  521. + xf86Msg(X_ERROR, "v4l: Error %d: Can't get FBUF\n", errno);
  522. + return errno;
  523. + }
  524. +
  525. + *pixelformat = fbuf.fmt.pixelformat;
  526. +
  527. + return 0;
  528. +}
  529. +
  530. +#define ATTR_NAME_PREFIX "XV_"
  531. +static int AddControl(PortPrivPtr p, XF86AttributeRec **list, int *count,
  532. + struct v4l2_queryctrl *qctrl, int *n)
  533. +{
  534. + char *ptr;
  535. +
  536. +/* v4l_add_attr */
  537. + if (qctrl->flags & V4L2_CTRL_FLAG_DISABLED)
  538. + return 0;
  539. + switch (qctrl->type) {
  540. + case V4L2_CTRL_TYPE_INTEGER:
  541. + case V4L2_CTRL_TYPE_BOOLEAN:
  542. + case V4L2_CTRL_TYPE_MENU:
  543. + case V4L2_CTRL_TYPE_BUTTON:
  544. + break;
  545. + default:
  546. + return 0;
  547. + }
  548. +
  549. + p->XvV4LCtrl = realloc(p->XvV4LCtrl, sizeof(XvV4LCtrlRec) * (*n + 1));
  550. + if (!p->XvV4LCtrl) {
  551. + if (*list) {
  552. + free (*list);
  553. + *count = 0;
  554. + *n = 0;
  555. + }
  556. + return -1;
  557. + }
  558. +
  559. + *list = realloc(*list, sizeof(XF86AttributeRec) * (*count + 1));
  560. + if (NULL == *list) {
  561. + if (p->XvV4LCtrl)
  562. + free (p->XvV4LCtrl);
  563. + *count = 0;
  564. + return -1;
  565. + }
  566. +
  567. + memset(*list + *count, 0, sizeof(XF86AttributeRec));
  568. + (*list)[*count].flags = XvSettable | XvGettable;
  569. +
  570. + if (qctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)
  571. + (*list)[*count].flags &= ~XvSettable;
  572. + if (qctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY)
  573. + (*list)[*count].flags &= ~XvGettable;
  574. + (*list)[*count].min_value = qctrl->minimum;
  575. + (*list)[*count].max_value = qctrl->maximum;
  576. + (*list)[*count].name = malloc(strlen((char *)qctrl->name) + 1 + sizeof (ATTR_NAME_PREFIX));
  577. + strcpy((*list)[*count].name, ATTR_NAME_PREFIX);
  578. + strcat((*list)[*count].name, (char *)qctrl->name);
  579. + for (ptr = (*list)[*count].name; *ptr; ptr++) {
  580. + *ptr = toupper(*ptr);
  581. + if (*ptr == ' ')
  582. + *ptr = '_';
  583. + }
  584. +
  585. + p->XvV4LCtrl[*n].xv = MAKE_ATOM((*list)[*count].name);
  586. + memcpy(&p->XvV4LCtrl[*n].qctrl, qctrl, sizeof(*qctrl));
  587. +
  588. + xf86Msg(X_INFO, "v4l: add attr %s (Xv/GPA %d) (%d to %d)\n",
  589. + (*list)[*count].name, (int)p->XvV4LCtrl[*n].xv,
  590. + p->XvV4LCtrl[*n].qctrl.minimum,
  591. + p->XvV4LCtrl[*n].qctrl.maximum);
  592. +
  593. + (*count)++;
  594. + (*n)++;
  595. +
  596. + return 0;
  597. +}
  598. +
  599. +static void AddAllV4LControls(PortPrivPtr p, XF86AttributeRec **list,
  600. + int *count, int fd)
  601. +{
  602. + int entries = 0;
  603. + CARD32 id;
  604. + struct v4l2_queryctrl qctrl;
  605. +
  606. + memset(&qctrl, 0, sizeof(qctrl));
  607. + qctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL;
  608. + while (!ioctl(fd, VIDIOC_QUERYCTRL, &qctrl)) {
  609. + if (AddControl(p, list, count, &qctrl, &entries))
  610. + return;
  611. + qctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
  612. + }
  613. + if (qctrl.id != V4L2_CTRL_FLAG_NEXT_CTRL)
  614. + return;
  615. + for (id = V4L2_CID_USER_BASE; id < V4L2_CID_LASTP1; id++) {
  616. + qctrl.id = id;
  617. + if (!ioctl(fd, VIDIOC_QUERYCTRL, &qctrl)) {
  618. + if (AddControl(p, list, count, &qctrl, &entries))
  619. + return;
  620. + }
  621. + }
  622. + qctrl.id = V4L2_CID_PRIVATE_BASE;
  623. + while (!ioctl(fd, VIDIOC_QUERYCTRL, &qctrl)) {
  624. + if (AddControl(p, list, count, &qctrl, &entries))
  625. + return;
  626. + qctrl.id++;
  627. + }
  628. + p->n_qctrl = entries;
  629. +}
  630. /* ---------------------------------------------------------------------- */
  631. +/* setup yuv overlay + hw scaling: look if we find some common video
  632. + format which both v4l driver and the X-Server can handle */
  633. +static int v4l_check_yuv(ScrnInfoPtr pScrn, PortPrivPtr pPPriv,
  634. + char *dev, int fd)
  635. +{
  636. + static const struct {
  637. + CARD32 v4l_palette;
  638. + unsigned int xv_id;
  639. + unsigned int xv_format;
  640. + } yuvlist[] = {
  641. + { V4L2_PIX_FMT_YUYV, FOURCC_YUY2, XvPacked },
  642. + { V4L2_PIX_FMT_UYVY, FOURCC_UYVY, XvPacked },
  643. + { 0 /* end of list */ },
  644. + };
  645. + /* FIXME: Why pScrn->scrnIndex? */
  646. + ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
  647. + int fmt,i;
  648. +
  649. + pPPriv->format = xf86XVQueryOffscreenImages(pScreen, &pPPriv->nformat);
  650. + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
  651. + "v4l: Number of Xv formats: %d\n", pPPriv->nformat);
  652. + if (!pPPriv->nformat)
  653. + return FALSE;
  654. +
  655. + for (fmt = 0; yuvlist[fmt].v4l_palette != 0; fmt++) {
  656. + pPPriv->pixelformat = yuvlist[fmt].v4l_palette;
  657. + if (-1 == SetV4LFmt(fd, pPPriv->pixelformat))
  658. + continue;
  659. + GetV4LFmt(fd, &pPPriv->pixelformat);
  660. + if (pPPriv->pixelformat != yuvlist[fmt].v4l_palette)
  661. + continue;
  662. + /* ... works, check available offscreen image formats now ... */
  663. + for (i = 0; i < pPPriv->nformat; i++) {
  664. + if (pPPriv->format[i].image->id == yuvlist[fmt].xv_id &&
  665. + pPPriv->format[i].image->format == yuvlist[fmt].xv_format) {
  666. + /* ... match found, good. */
  667. + pPPriv->yuv_format = yuvlist[fmt].v4l_palette;
  668. + pPPriv->myfmt = pPPriv->format+i;
  669. + xf86DrvMsg(pScrn->scrnIndex, X_INFO,
  670. + "v4l[%s]: using hw video scaling [%4.4s].\n",
  671. + dev,(char*)&(pPPriv->format[i].image->id));
  672. + return TRUE;
  673. + }
  674. + }
  675. + }
  676. + return TRUE;
  677. +}
  678. +
  679. static int V4lOpenDevice(PortPrivPtr pPPriv, ScrnInfoPtr pScrn)
  680. {
  681. static int first = 1;
  682. +#if 0
  683. + /*
  684. + * It may be a good idea to probe here, but this would break
  685. + * some things, as initialization uses yuv_format
  686. + */
  687. + if (!pPPriv->yuv_format && first)
  688. + v4l_check_yuv(pScrn, pPPriv, V4L_NAME, V4L_FD);
  689. +#endif
  690. if (-1 == V4L_FD) {
  691. - V4L_FD = open(V4L_NAME, O_RDWR, 0);
  692. -
  693. - pPPriv->rgb_fbuf.width = pScrn->virtualX;
  694. - pPPriv->rgb_fbuf.height = pScrn->virtualY;
  695. - pPPriv->rgb_fbuf.depth = pScrn->bitsPerPixel;
  696. - pPPriv->rgb_fbuf.bytesperline = pScrn->displayWidth * ((pScrn->bitsPerPixel + 7)/8);
  697. - pPPriv->rgb_fbuf.base = (pointer)(pScrn->memPhysBase + pScrn->fbOffset);
  698. - if (first) {
  699. - first = 0;
  700. - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
  701. - "v4l: memPhysBase=0x%lx\n", pScrn->memPhysBase);
  702. - }
  703. -
  704. - switch (pScrn->bitsPerPixel) {
  705. - case 16:
  706. - if (pScrn->weight.green == 5) {
  707. - pPPriv->rgbpalette = VIDEO_PALETTE_RGB555;
  708. - pPPriv->rgbdepth = 16;
  709. - } else {
  710. - pPPriv->rgbpalette = VIDEO_PALETTE_RGB565;
  711. - pPPriv->rgbdepth = 16;
  712. - }
  713. - break;
  714. - case 24:
  715. - pPPriv->rgbpalette = VIDEO_PALETTE_RGB24;
  716. - pPPriv->rgbdepth = 24;
  717. - break;
  718. - case 32:
  719. - pPPriv->rgbpalette = VIDEO_PALETTE_RGB32;
  720. - pPPriv->rgbdepth = 32;
  721. - break;
  722. - }
  723. + V4L_FD = open(V4L_NAME, O_RDWR, 0);
  724. +
  725. + if (-1 == V4L_FD)
  726. + return errno;
  727. +
  728. + if (-1 == ioctl(V4L_FD, VIDIOC_G_FBUF, &pPPriv->rgb_fbuf)) {
  729. + xf86Msg(X_ERROR, "v4l: Error %d: Can't get FBUF\n", errno);
  730. + return errno;
  731. + }
  732. + pPPriv->rgb_fbuf.fmt.width = pScrn->virtualX;
  733. + pPPriv->rgb_fbuf.fmt.height = pScrn->virtualY;
  734. + pPPriv->rgb_fbuf.fmt.bytesperline = pScrn->displayWidth * ((pScrn->bitsPerPixel + 7)/8);
  735. + pPPriv->rgb_fbuf.base = (pointer)(pScrn->memPhysBase + pScrn->fbOffset);
  736. + if (first) {
  737. + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
  738. + "v4l: memPhysBase=0x%lx\n", pScrn->memPhysBase);
  739. + first = 0;
  740. + }
  741. +
  742. + switch (pScrn->bitsPerPixel) {
  743. + case 16:
  744. + if (pScrn->weight.green == 5) {
  745. + pPPriv->rgb_fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB555;
  746. + } else {
  747. + pPPriv->rgb_fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB565;
  748. + }
  749. + break;
  750. + case 24:
  751. + pPPriv->rgb_fbuf.fmt.pixelformat = V4L2_PIX_FMT_BGR24;
  752. + break;
  753. + case 32:
  754. + pPPriv->rgb_fbuf.fmt.pixelformat = V4L2_PIX_FMT_BGR32;
  755. + break;
  756. + }
  757. }
  758. - if (-1 == V4L_FD)
  759. - return errno;
  760. -
  761. V4L_REF++;
  762. DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
  763. - "Xv/open: refcount=%d\n",V4L_REF));
  764. + "Xv/open: refcount=%d\n",V4L_REF));
  765. return 0;
  766. }
  767. @@ -267,10 +457,10 @@ static void V4lCloseDevice(PortPrivPtr pPPriv, ScrnInfoPtr pScrn)
  768. {
  769. V4L_REF--;
  770. DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
  771. - "Xv/close: refcount=%d\n",V4L_REF));
  772. + "Xv/close: refcount=%d\n",V4L_REF));
  773. if (0 == V4L_REF && -1 != V4L_FD) {
  774. - close(V4L_FD);
  775. - V4L_FD = -1;
  776. + close(V4L_FD);
  777. + V4L_FD = -1;
  778. }
  779. }
  780. @@ -280,8 +470,10 @@ V4lPutVideo(ScrnInfoPtr pScrn,
  781. short vid_w, short vid_h, short drw_w, short drw_h,
  782. RegionPtr clipBoxes, pointer data, DrawablePtr pDraw)
  783. {
  784. + struct v4l2_format fmt;
  785. +
  786. PortPrivPtr pPPriv = (PortPrivPtr) data;
  787. - struct video_clip *clip;
  788. + struct v4l2_clip *clip;
  789. BoxPtr pBox;
  790. RegionRec newReg;
  791. BoxRec newBox;
  792. @@ -291,179 +483,214 @@ V4lPutVideo(ScrnInfoPtr pScrn,
  793. /* Open a file handle to the device */
  794. if (VIDEO_OFF == pPPriv->VideoOn) {
  795. - if (V4lOpenDevice(pPPriv, pScrn))
  796. - return Success;
  797. + if (V4lOpenDevice(pPPriv, pScrn))
  798. + return Success;
  799. }
  800. if (0 != pPPriv->yuv_format) {
  801. - DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/PV yuv\n"));
  802. - width = pPPriv->enc[pPPriv->cenc].width;
  803. + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/PV yuv\n"));
  804. + width = pPPriv->enc[pPPriv->cenc].width;
  805. height = pPPriv->enc[pPPriv->cenc].height/2; /* no interlace */
  806. - if (drw_w < width)
  807. - width = drw_w;
  808. - if (drw_h < height)
  809. - height = drw_h;
  810. - if ((height != pPPriv->yuv_height) || (width != pPPriv->yuv_width)) {
  811. - /* new size -- free old surface */
  812. - DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, " surface resize\n"));
  813. - if (pPPriv->surface) {
  814. - pPPriv->VideoOn = VIDEO_OFF;
  815. - pPPriv->myfmt->stop(pPPriv->surface);
  816. - pPPriv->myfmt->free_surface(pPPriv->surface);
  817. - xfree(pPPriv->surface);
  818. - pPPriv->surface = NULL;
  819. - }
  820. - pPPriv->yuv_width = width;
  821. - pPPriv->yuv_height = height;
  822. - }
  823. - if (!pPPriv->surface) {
  824. - /* allocate + setup offscreen surface */
  825. - if (NULL == (pPPriv->surface = xalloc(sizeof(XF86SurfaceRec))))
  826. - return FALSE;
  827. - if (Success != pPPriv->myfmt->alloc_surface
  828. - (pScrn,pPPriv->myfmt->image->id,
  829. - pPPriv->yuv_width,pPPriv->yuv_height,pPPriv->surface)) {
  830. - xfree(pPPriv->surface);
  831. - pPPriv->surface = NULL;
  832. - goto fallback_to_rgb;
  833. - }
  834. - pPPriv->yuv_fbuf.width = pPPriv->surface->width;
  835. - pPPriv->yuv_fbuf.height = pPPriv->surface->height;
  836. - pPPriv->yuv_fbuf.depth = 16;
  837. - pPPriv->yuv_fbuf.bytesperline = pPPriv->surface->pitches[0];
  838. - pPPriv->yuv_fbuf.base =
  839. - (pointer)(pScrn->memPhysBase + pPPriv->surface->offsets[0]);
  840. - DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, " surface: %p+%d = %p, %dx%d, pitch %d\n",
  841. - pScrn->memPhysBase,pPPriv->surface->offsets[0],
  842. - pScrn->memPhysBase+pPPriv->surface->offsets[0],
  843. - pPPriv->surface->width,pPPriv->surface->height,
  844. - pPPriv->surface->pitches[0]));
  845. - pPPriv->yuv_win.width = pPPriv->surface->width;
  846. - pPPriv->yuv_win.height = pPPriv->surface->height;
  847. - }
  848. -
  849. - /* program driver */
  850. - if (-1 == ioctl(V4L_FD,VIDIOCSFBUF,&(pPPriv->yuv_fbuf)))
  851. - perror("ioctl VIDIOCSFBUF");
  852. - if (-1 == ioctl(V4L_FD,VIDIOCGPICT,&pPPriv->pict))
  853. - perror("ioctl VIDIOCGPICT");
  854. - pPPriv->pict.palette = pPPriv->yuv_format;
  855. - pPPriv->pict.depth = 16;
  856. - if (-1 == ioctl(V4L_FD,VIDIOCSPICT,&pPPriv->pict))
  857. - perror("ioctl VIDIOCSPICT");
  858. - if (-1 == ioctl(V4L_FD,VIDIOCSWIN,&(pPPriv->yuv_win)))
  859. - perror("ioctl VIDIOCSWIN");
  860. - if (-1 == ioctl(V4L_FD, VIDIOCCAPTURE, &one))
  861. - perror("ioctl VIDIOCCAPTURE(1)");
  862. -
  863. - if (0 == (pPPriv->myfmt->flags & VIDEO_INVERT_CLIPLIST)) {
  864. - /* invert cliplist */
  865. - newBox.x1 = drw_x;
  866. - newBox.y1 = drw_y;
  867. - newBox.x2 = drw_x + drw_w;
  868. - newBox.y2 = drw_y + drw_h;
  869. -
  870. - if (pPPriv->myfmt->flags & VIDEO_CLIP_TO_VIEWPORT) {
  871. - /* trim to the viewport */
  872. - if(newBox.x1 < pScrn->frameX0)
  873. - newBox.x1 = pScrn->frameX0;
  874. - if(newBox.x2 > pScrn->frameX1)
  875. - newBox.x2 = pScrn->frameX1;
  876. -
  877. - if(newBox.y1 < pScrn->frameY0)
  878. - newBox.y1 = pScrn->frameY0;
  879. - if(newBox.y2 > pScrn->frameY1)
  880. - newBox.y2 = pScrn->frameY1;
  881. - }
  882. + if (drw_w < width)
  883. + width = drw_w;
  884. + if (drw_h < height)
  885. + height = drw_h;
  886. + if ((height != pPPriv->yuv_height) || (width != pPPriv->yuv_width)) {
  887. + /* new size -- free old surface */
  888. + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, " surface resize\n"));
  889. + if (pPPriv->surface) {
  890. + pPPriv->VideoOn = VIDEO_OFF;
  891. + pPPriv->myfmt->stop(pPPriv->surface);
  892. + pPPriv->myfmt->free_surface(pPPriv->surface);
  893. + free(pPPriv->surface);
  894. + pPPriv->surface = NULL;
  895. + }
  896. + pPPriv->yuv_width = width;
  897. + pPPriv->yuv_height = height;
  898. + }
  899. + if (!pPPriv->surface) {
  900. + /* allocate + setup offscreen surface */
  901. + if (NULL == (pPPriv->surface = malloc(sizeof(XF86SurfaceRec))))
  902. + return FALSE;
  903. + if (Success != pPPriv->myfmt->alloc_surface
  904. + (pScrn,pPPriv->myfmt->image->id,
  905. + pPPriv->yuv_width,pPPriv->yuv_height,pPPriv->surface)) {
  906. + free(pPPriv->surface);
  907. + pPPriv->surface = NULL;
  908. + goto fallback_to_rgb;
  909. + }
  910. +
  911. + if (-1 == ioctl(V4L_FD, VIDIOC_G_FBUF, &pPPriv->yuv_fbuf)) {
  912. + xf86Msg(X_ERROR, "v4l: Error %d: Can't get FBUF\n", errno);
  913. + return errno;
  914. + }
  915. + pPPriv->yuv_fbuf.fmt.width = pPPriv->surface->width;
  916. + pPPriv->yuv_fbuf.fmt.height = pPPriv->surface->height;
  917. + pPPriv->yuv_fbuf.fmt.bytesperline = pPPriv->surface->pitches[0];
  918. + pPPriv->yuv_fbuf.fmt.pixelformat = pPPriv->yuv_format;
  919. + pPPriv->yuv_fbuf.base =
  920. + (pointer)(pScrn->memPhysBase + pPPriv->surface->offsets[0]);
  921. + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
  922. + " surface: %p+%d = %p, %dx%d, pitch %d\n",
  923. + (void *)pScrn->memPhysBase, pPPriv->surface->offsets[0],
  924. + (void *)pScrn->memPhysBase+pPPriv->surface->offsets[0],
  925. + pPPriv->surface->width, pPPriv->surface->height,
  926. + pPPriv->surface->pitches[0]));
  927. + memset(&pPPriv->yuv_win, 0, sizeof(pPPriv->yuv_win));
  928. + pPPriv->yuv_win.w.left = 0;
  929. + pPPriv->yuv_win.w.top = 0;
  930. + pPPriv->yuv_win.w.width = pPPriv->surface->width;
  931. + pPPriv->yuv_win.w.height = pPPriv->surface->height;
  932. + }
  933. - REGION_INIT(pScrn->pScreen, &newReg, &newBox, 1);
  934. - REGION_SUBTRACT(pScrn->pScreen, &newReg, &newReg, clipBoxes);
  935. - clipBoxes = &newReg;
  936. - }
  937. -
  938. - /* start overlay */
  939. - DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
  940. - "over: - %d,%d -> %d,%d (%dx%d) (yuv=%dx%d)\n",
  941. - drw_x, drw_y,
  942. - drw_x+drw_w, drw_y+drw_h,
  943. - drw_w, drw_h,
  944. - pPPriv->surface->width,pPPriv->surface->height));
  945. - pPPriv->myfmt->display(pPPriv->surface,
  946. - 0, 0, drw_x, drw_y,
  947. - pPPriv->surface->width,
  948. - pPPriv->surface->height,
  949. - drw_w, drw_h,
  950. - clipBoxes);
  951. - if (0 == (pPPriv->myfmt->flags & VIDEO_INVERT_CLIPLIST)) {
  952. - REGION_UNINIT(pScrn->pScreen, &newReg);
  953. - }
  954. - pPPriv->VideoOn = VIDEO_YUV;
  955. - return Success;
  956. + /* program driver */
  957. + if (-1 == ioctl(V4L_FD, VIDIOC_S_FBUF, &pPPriv->yuv_fbuf)) {
  958. + xf86Msg(X_ERROR, "Error %d at VIDIOC_S_FBUF\n", errno);
  959. + return BadValue;
  960. + }
  961. + pPPriv->pixelformat = pPPriv->yuv_format;
  962. + if (-1 == SetV4LFmt(V4L_FD, pPPriv->pixelformat))
  963. + return BadValue;
  964. +
  965. + memset(&fmt, 0, sizeof(fmt));
  966. + fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
  967. + memcpy(&fmt.fmt.win, &pPPriv->yuv_win, sizeof(pPPriv->yuv_win));
  968. + if (-1 == ioctl(V4L_FD, VIDIOC_S_FMT, &fmt)) {
  969. + xf86Msg(X_ERROR, "Error %d at VIDIOC_S_FMT\n", errno);
  970. + return BadValue;
  971. + }
  972. + if (-1 == ioctl(V4L_FD, VIDIOC_OVERLAY, &one)) {
  973. + xf86Msg(X_ERROR, "v4l: Error %d while enabling Overlay\n", errno);
  974. + return BadValue;
  975. + }
  976. +
  977. + if (0 == (pPPriv->myfmt->flags & VIDEO_INVERT_CLIPLIST)) {
  978. + /* invert cliplist */
  979. + newBox.x1 = drw_x;
  980. + newBox.y1 = drw_y;
  981. + newBox.x2 = drw_x + drw_w;
  982. + newBox.y2 = drw_y + drw_h;
  983. +
  984. + if (pPPriv->myfmt->flags & VIDEO_CLIP_TO_VIEWPORT) {
  985. + /* trim to the viewport */
  986. + if(newBox.x1 < pScrn->frameX0)
  987. + newBox.x1 = pScrn->frameX0;
  988. + if(newBox.x2 > pScrn->frameX1)
  989. + newBox.x2 = pScrn->frameX1;
  990. +
  991. + if(newBox.y1 < pScrn->frameY0)
  992. + newBox.y1 = pScrn->frameY0;
  993. + if(newBox.y2 > pScrn->frameY1)
  994. + newBox.y2 = pScrn->frameY1;
  995. + }
  996. +
  997. + REGION_INIT(pScrn->pScreen, &newReg, &newBox, 1);
  998. + REGION_SUBTRACT(pScrn->pScreen, &newReg, &newReg, clipBoxes);
  999. + clipBoxes = &newReg;
  1000. + }
  1001. +
  1002. + /* start overlay */
  1003. + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
  1004. + "over: - %d,%d -> %d,%d (%dx%d) (yuv=%dx%d)\n",
  1005. + drw_x, drw_y,
  1006. + drw_x+drw_w, drw_y+drw_h,
  1007. + drw_w, drw_h,
  1008. + pPPriv->surface->width,pPPriv->surface->height));
  1009. + pPPriv->myfmt->display(pPPriv->surface,
  1010. + 0, 0, drw_x, drw_y,
  1011. + pPPriv->surface->width,
  1012. + pPPriv->surface->height,
  1013. + drw_w, drw_h,
  1014. + clipBoxes);
  1015. + if (0 == (pPPriv->myfmt->flags & VIDEO_INVERT_CLIPLIST)) {
  1016. + REGION_UNINIT(pScrn->pScreen, &newReg);
  1017. + }
  1018. + pPPriv->VideoOn = VIDEO_YUV;
  1019. + return Success;
  1020. }
  1021. - fallback_to_rgb:
  1022. +fallback_to_rgb:
  1023. DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/PV rgb\n"));
  1024. /* FIXME: vid-* is ignored for now, not supported by v4l */
  1025. dw = (drw_w < pPPriv->enc[pPPriv->cenc].width) ?
  1026. - drw_w : pPPriv->enc[pPPriv->cenc].width;
  1027. + drw_w : pPPriv->enc[pPPriv->cenc].width;
  1028. dh = (drw_h < pPPriv->enc[pPPriv->cenc].height) ?
  1029. - drw_h : pPPriv->enc[pPPriv->cenc].height;
  1030. + drw_h : pPPriv->enc[pPPriv->cenc].height;
  1031. /* if the window is too big, center the video */
  1032. dx = drw_x + (drw_w - dw)/2;
  1033. dy = drw_y + (drw_h - dh)/2;
  1034. /* bttv prefeares aligned addresses */
  1035. dx &= ~3;
  1036. - if (dx < drw_x) dx += 4;
  1037. - if (dx+dw > drw_x+drw_w) dw -= 4;
  1038. + if (dx < drw_x)
  1039. + dx += 4;
  1040. + if (dx+dw > drw_x+drw_w)
  1041. + dw -= 4;
  1042. /* window */
  1043. DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, " win: %dx%d+%d+%d\n",
  1044. - drw_w,drw_h,drw_x,drw_y));
  1045. + drw_w,drw_h,drw_x,drw_y));
  1046. DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, " use: %dx%d+%d+%d\n",
  1047. - dw,dh,dx,dy));
  1048. - pPPriv->rgb_win.x = dx;
  1049. - pPPriv->rgb_win.y = dy;
  1050. - pPPriv->rgb_win.width = dw;
  1051. - pPPriv->rgb_win.height = dh;
  1052. - pPPriv->rgb_win.flags = 0;
  1053. -
  1054. + dw,dh,dx,dy));
  1055. + memset(&pPPriv->rgb_win, 0, sizeof(pPPriv->rgb_win));
  1056. + pPPriv->rgb_win.w.left = dx;
  1057. + pPPriv->rgb_win.w.top = dy;
  1058. + pPPriv->rgb_win.w.width = dw;
  1059. + pPPriv->rgb_win.w.height = dh;
  1060. +
  1061. /* clipping */
  1062. if (pPPriv->rgb_win.clips) {
  1063. - xfree(pPPriv->rgb_win.clips);
  1064. - pPPriv->rgb_win.clips = NULL;
  1065. + free(pPPriv->rgb_win.clips);
  1066. + pPPriv->rgb_win.clips = NULL;
  1067. }
  1068. pPPriv->rgb_win.clipcount = REGION_NUM_RECTS(clipBoxes);
  1069. DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2," clip: have #%d\n",
  1070. - pPPriv->rgb_win.clipcount));
  1071. + pPPriv->rgb_win.clipcount));
  1072. if (0 != pPPriv->rgb_win.clipcount) {
  1073. - pPPriv->rgb_win.clips = xalloc(pPPriv->rgb_win.clipcount*sizeof(struct video_clip));
  1074. - if (NULL != pPPriv->rgb_win.clips) {
  1075. - memset(pPPriv->rgb_win.clips,0,pPPriv->rgb_win.clipcount*sizeof(struct video_clip));
  1076. - pBox = REGION_RECTS(clipBoxes);
  1077. - clip = pPPriv->rgb_win.clips;
  1078. - for (i = 0; i < REGION_NUM_RECTS(clipBoxes); i++, pBox++, clip++) {
  1079. - clip->x = pBox->x1 - dx;
  1080. - clip->y = pBox->y1 - dy;
  1081. - clip->width = pBox->x2 - pBox->x1;
  1082. - clip->height = pBox->y2 - pBox->y1;
  1083. - }
  1084. - }
  1085. + pPPriv->rgb_win.clips = malloc(pPPriv->rgb_win.clipcount*sizeof(struct v4l2_clip));
  1086. + if (NULL != pPPriv->rgb_win.clips) {
  1087. + memset(pPPriv->rgb_win.clips,0,pPPriv->rgb_win.clipcount*sizeof(struct v4l2_clip));
  1088. + pBox = REGION_RECTS(clipBoxes);
  1089. + clip = pPPriv->rgb_win.clips;
  1090. +
  1091. + /*
  1092. + * FIXME: This code currently does nothing, as we don't emulate
  1093. + * The V4L1 clipping stuff
  1094. + */
  1095. + for (i = 0; i < REGION_NUM_RECTS(clipBoxes); i++, pBox++, clip++) {
  1096. + clip->c.left = pBox->x1 - dx;
  1097. + clip->c.top = pBox->y1 - dy;
  1098. + clip->c.width = pBox->x2 - pBox->x1;
  1099. + clip->c.height = pBox->y2 - pBox->y1;
  1100. + }
  1101. + }
  1102. }
  1103. /* start */
  1104. - if (-1 == ioctl(V4L_FD,VIDIOCSFBUF,&(pPPriv->rgb_fbuf)))
  1105. - perror("ioctl VIDIOCSFBUF");
  1106. - if (-1 == ioctl(V4L_FD,VIDIOCGPICT,&pPPriv->pict))
  1107. - perror("ioctl VIDIOCGPICT");
  1108. - pPPriv->pict.palette = pPPriv->rgbpalette;
  1109. - pPPriv->pict.depth = pPPriv->rgbdepth;
  1110. - if (-1 == ioctl(V4L_FD,VIDIOCSPICT,&pPPriv->pict))
  1111. - perror("ioctl VIDIOCSPICT");
  1112. - if (-1 == ioctl(V4L_FD,VIDIOCSWIN,&(pPPriv->rgb_win)))
  1113. - perror("ioctl VIDIOCSWIN");
  1114. - if (-1 == ioctl(V4L_FD, VIDIOCCAPTURE, &one))
  1115. - perror("ioctl VIDIOCCAPTURE(1)");
  1116. + if (-1 == ioctl(V4L_FD, VIDIOC_S_FBUF, &pPPriv->rgb_fbuf)) {
  1117. + xf86Msg(X_ERROR, "Error %d at VIDIOC_S_FBUF\n", errno);
  1118. + return BadValue;
  1119. + }
  1120. + if (-1 == GetV4LFmt(V4L_FD, &pPPriv->pixelformat)) {
  1121. + xf86Msg(X_ERROR, "Error %d getting pixelformat\n", errno);
  1122. + return BadValue;
  1123. + }
  1124. + pPPriv->pixelformat = pPPriv->rgb_fbuf.fmt.pixelformat;
  1125. + if (-1 == SetV4LFmt(V4L_FD, pPPriv->pixelformat)) {
  1126. + xf86Msg(X_ERROR, "Error %d getting pixelformat\n", errno);
  1127. + return BadValue;
  1128. + }
  1129. + memset(&fmt, 0, sizeof(fmt));
  1130. + fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
  1131. + memcpy(&fmt.fmt.win, &pPPriv->rgb_win, sizeof(pPPriv->rgb_win));
  1132. + if (-1 == ioctl(V4L_FD, VIDIOC_S_FMT, &fmt)) {
  1133. + xf86Msg(X_ERROR, "Error %d at VIDIOC_S_FMT\n", errno);
  1134. + return BadValue;
  1135. + }
  1136. + if (-1 == ioctl(V4L_FD, VIDIOC_OVERLAY, &one)) {
  1137. + xf86Msg(X_ERROR, "v4l: Error %d while enabling Overlay\n", errno);
  1138. + return BadValue;
  1139. + }
  1140. pPPriv->VideoOn = VIDEO_RGB;
  1141. return Success;
  1142. @@ -476,7 +703,7 @@ V4lPutStill(ScrnInfoPtr pScrn,
  1143. RegionPtr clipBoxes, pointer data, DrawablePtr pDraw)
  1144. {
  1145. #if 0
  1146. - PortPrivPtr pPPriv = (PortPrivPtr) data;
  1147. + PortPrivPtr pPPriv = (PortPrivPtr) data;
  1148. #endif
  1149. DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/PS\n"));
  1150. @@ -488,177 +715,152 @@ V4lPutStill(ScrnInfoPtr pScrn,
  1151. static void
  1152. V4lStopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown)
  1153. {
  1154. - PortPrivPtr pPPriv = (PortPrivPtr) data;
  1155. + PortPrivPtr pPPriv = (PortPrivPtr) data;
  1156. int zero=0;
  1157. if (VIDEO_OFF == pPPriv->VideoOn) {
  1158. - DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
  1159. - "Xv/StopVideo called with video already off\n"));
  1160. - return;
  1161. + DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
  1162. + "Xv/StopVideo called with video already off\n"));
  1163. + return;
  1164. }
  1165. DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/StopVideo shutdown=%d\n",shutdown));
  1166. if (!shutdown) {
  1167. - /* just reclipping, we have to stop DMA transfers to the visible screen */
  1168. - if (VIDEO_RGB == pPPriv->VideoOn) {
  1169. - if (-1 == ioctl(V4L_FD, VIDIOCCAPTURE, &zero))
  1170. - perror("ioctl VIDIOCCAPTURE(0)");
  1171. - pPPriv->VideoOn = VIDEO_RECLIP;
  1172. - }
  1173. + /* just reclipping, we have to stop DMA transfers to the visible screen */
  1174. + if (VIDEO_RGB == pPPriv->VideoOn) {
  1175. + if (-1 == ioctl(V4L_FD, VIDIOC_OVERLAY, &zero))
  1176. + xf86Msg(X_ERROR, "v4l: Error %d while disabling Overlay\n", errno);
  1177. + pPPriv->VideoOn = VIDEO_RECLIP;
  1178. + }
  1179. } else {
  1180. - /* video stop - turn off and free everything */
  1181. - if (VIDEO_YUV == pPPriv->VideoOn) {
  1182. - pPPriv->myfmt->stop(pPPriv->surface);
  1183. - pPPriv->myfmt->free_surface(pPPriv->surface);
  1184. - xfree(pPPriv->surface);
  1185. - pPPriv->surface = NULL;
  1186. - }
  1187. - if (-1 == ioctl(V4L_FD, VIDIOCCAPTURE, &zero))
  1188. - perror("ioctl VIDIOCCAPTURE(0)");
  1189. -
  1190. - V4lCloseDevice(pPPriv,pScrn);
  1191. - pPPriv->VideoOn = VIDEO_OFF;
  1192. - }
  1193. -}
  1194. + /* video stop - turn off and free everything */
  1195. + if (VIDEO_YUV == pPPriv->VideoOn) {
  1196. + pPPriv->myfmt->stop(pPPriv->surface);
  1197. + pPPriv->myfmt->free_surface(pPPriv->surface);
  1198. + free(pPPriv->surface);
  1199. + pPPriv->surface = NULL;
  1200. + }
  1201. + if (-1 == ioctl(V4L_FD, VIDIOC_OVERLAY, &zero))
  1202. + xf86Msg(X_ERROR, "v4l: Error %d while disabling Overlay\n", errno);
  1203. -/* v4l uses range 0 - 65535; Xv uses -1000 - 1000 */
  1204. -static int
  1205. -v4l_to_xv(int val) {
  1206. - val = val * 2000 / 65536 - 1000;
  1207. - if (val < -1000) val = -1000;
  1208. - if (val > 1000) val = 1000;
  1209. - return val;
  1210. -}
  1211. -static int
  1212. -xv_to_v4l(int val) {
  1213. - val = val * 65536 / 2000 + 32768;
  1214. - if (val < -0) val = 0;
  1215. - if (val > 65535) val = 65535;
  1216. - return val;
  1217. + V4lCloseDevice(pPPriv,pScrn);
  1218. + pPPriv->VideoOn = VIDEO_OFF;
  1219. + }
  1220. }
  1221. static int
  1222. V4lSetPortAttribute(ScrnInfoPtr pScrn,
  1223. Atom attribute, INT32 value, pointer data)
  1224. {
  1225. - PortPrivPtr pPPriv = (PortPrivPtr) data;
  1226. - struct video_channel chan;
  1227. - int ret = Success;
  1228. + struct v4l2_control ctrl;
  1229. + PortPrivPtr pPPriv = (PortPrivPtr) data;
  1230. + int i, ret = BadValue;
  1231. if (V4lOpenDevice(pPPriv, pScrn))
  1232. - return Success;
  1233. + return Success;
  1234. DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/SPA %d, %d\n",
  1235. - attribute, value));
  1236. + (int)attribute, (int)value));
  1237. if (-1 == V4L_FD) {
  1238. - ret = Success;
  1239. + ret = Success;
  1240. } else if (attribute == xvEncoding) {
  1241. - if (value >= 0 && value < pPPriv->nenc) {
  1242. - pPPriv->cenc = value;
  1243. - chan.channel = pPPriv->input[value];
  1244. - chan.norm = pPPriv->norm[value];
  1245. - if (-1 == ioctl(V4L_FD,VIDIOCSCHAN,&chan))
  1246. - perror("ioctl VIDIOCSCHAN");
  1247. - } else {
  1248. - ret = BadValue;
  1249. - }
  1250. - } else if (attribute == xvBrightness ||
  1251. - attribute == xvContrast ||
  1252. - attribute == xvSaturation ||
  1253. - attribute == xvHue) {
  1254. - ioctl(V4L_FD,VIDIOCGPICT,&pPPriv->pict);
  1255. - if (attribute == xvBrightness) pPPriv->pict.brightness = xv_to_v4l(value);
  1256. - if (attribute == xvContrast) pPPriv->pict.contrast = xv_to_v4l(value);
  1257. - if (attribute == xvSaturation) pPPriv->pict.colour = xv_to_v4l(value);
  1258. - if (attribute == xvHue) pPPriv->pict.hue = xv_to_v4l(value);
  1259. - if (-1 == ioctl(V4L_FD,VIDIOCSPICT,&pPPriv->pict))
  1260. - perror("ioctl VIDIOCSPICT");
  1261. - } else if (attribute == xvMute ||
  1262. - attribute == xvVolume) {
  1263. - ioctl(V4L_FD,VIDIOCGAUDIO,&pPPriv->audio);
  1264. - if (attribute == xvMute) {
  1265. - if (value)
  1266. - pPPriv->audio.flags |= VIDEO_AUDIO_MUTE;
  1267. - else
  1268. - pPPriv->audio.flags &= ~VIDEO_AUDIO_MUTE;
  1269. - } else if (attribute == xvVolume) {
  1270. - if (pPPriv->audio.flags & VIDEO_AUDIO_VOLUME)
  1271. - pPPriv->audio.volume = xv_to_v4l(value);
  1272. - } else {
  1273. - ret = BadValue;
  1274. - }
  1275. - if (ret != BadValue)
  1276. - if (-1 == ioctl(V4L_FD,VIDIOCSAUDIO,&pPPriv->audio))
  1277. - perror("ioctl VIDIOCSAUDIO");
  1278. + if (value < 0 || value >= pPPriv->nenc)
  1279. + goto err;
  1280. + if (ioctl(V4L_FD, VIDIOC_S_INPUT, &pPPriv->input[value]) == -1) {
  1281. + xf86Msg(X_ERROR, "v4l: Error %d while setting input\n", errno);
  1282. + goto err;
  1283. + }
  1284. + if (ioctl(V4L_FD, VIDIOC_S_STD, &pPPriv->norm[value]) == -1) {
  1285. + xf86Msg(X_ERROR, "v4l: Error %d while setting standard\n", errno);
  1286. + goto err;
  1287. + }
  1288. + pPPriv->cenc = value;
  1289. + ret = Success;
  1290. } else if (attribute == xvFreq) {
  1291. - unsigned long freq = value;
  1292. - if (-1 == ioctl(V4L_FD,VIDIOCSFREQ,&freq))
  1293. - perror("ioctl VIDIOCSFREQ");
  1294. - } else if (0 != pPPriv->yuv_format &&
  1295. - pPPriv->myfmt->setAttribute) {
  1296. - /* not mine -> pass to yuv scaler driver */
  1297. - ret = pPPriv->myfmt->setAttribute(pScrn, attribute, value);
  1298. + struct v4l2_frequency freq;
  1299. + memset(&freq, 0, sizeof(freq));
  1300. + ioctl(V4L_FD, VIDIOC_G_FREQUENCY, &freq);
  1301. + freq.frequency = value;
  1302. + if (ioctl(V4L_FD, VIDIOC_S_FREQUENCY, &freq) == -1)
  1303. + xf86Msg(X_ERROR, "v4l: Error %d while setting frequency\n", errno);
  1304. + else
  1305. + ret = Success;
  1306. } else {
  1307. - ret = BadValue;
  1308. + for (i = 0; i < pPPriv->n_qctrl; i++)
  1309. + if (pPPriv->XvV4LCtrl[i].xv == attribute)
  1310. + break;
  1311. + if (i == pPPriv->n_qctrl) {
  1312. + /* not mine -> pass to yuv scaler driver */
  1313. + if (0 != pPPriv->yuv_format && pPPriv->myfmt->setAttribute)
  1314. + ret = pPPriv->myfmt->setAttribute(pScrn, attribute, value);
  1315. + else
  1316. + ret = BadMatch;
  1317. + goto err;
  1318. + }
  1319. + if (pPPriv->XvV4LCtrl[i].qctrl.flags & V4L2_CTRL_FLAG_DISABLED)
  1320. + goto err;
  1321. + ctrl.id = pPPriv->XvV4LCtrl[i].qctrl.id;
  1322. + ctrl.value = value;
  1323. + if (ioctl(V4L_FD, VIDIOC_S_CTRL, &ctrl) != 1)
  1324. + ret = Success;
  1325. }
  1326. +err:
  1327. V4lCloseDevice(pPPriv,pScrn);
  1328. return ret;
  1329. }
  1330. static int
  1331. -V4lGetPortAttribute(ScrnInfoPtr pScrn,
  1332. +V4lGetPortAttribute(ScrnInfoPtr pScrn,
  1333. Atom attribute, INT32 *value, pointer data)
  1334. {
  1335. + struct v4l2_control ctrl;
  1336. PortPrivPtr pPPriv = (PortPrivPtr) data;
  1337. - int ret = Success;
  1338. + int i, ret = BadValue;
  1339. if (V4lOpenDevice(pPPriv, pScrn))
  1340. - return Success;
  1341. + return Success;
  1342. DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/GPA %d\n",
  1343. - attribute));
  1344. + (int)attribute));
  1345. if (-1 == V4L_FD) {
  1346. - ret = Success;
  1347. + ret = Success;
  1348. } else if (attribute == xvEncoding) {
  1349. - *value = pPPriv->cenc;
  1350. - } else if (attribute == xvBrightness ||
  1351. - attribute == xvContrast ||
  1352. - attribute == xvSaturation ||
  1353. - attribute == xvHue) {
  1354. - ioctl(V4L_FD,VIDIOCGPICT,&pPPriv->pict);
  1355. - if (attribute == xvBrightness) *value = v4l_to_xv(pPPriv->pict.brightness);
  1356. - if (attribute == xvContrast) *value = v4l_to_xv(pPPriv->pict.contrast);
  1357. - if (attribute == xvSaturation) *value = v4l_to_xv(pPPriv->pict.colour);
  1358. - if (attribute == xvHue) *value = v4l_to_xv(pPPriv->pict.hue);
  1359. - } else if (attribute == xvMute ||
  1360. - attribute == xvVolume) {
  1361. - ioctl(V4L_FD,VIDIOCGAUDIO,&pPPriv->audio);
  1362. - if (attribute == xvMute) {
  1363. - *value = (pPPriv->audio.flags & VIDEO_AUDIO_MUTE) ? 1 : 0;
  1364. - } else if (attribute == xvVolume) {
  1365. - if (pPPriv->audio.flags & VIDEO_AUDIO_VOLUME)
  1366. - *value = v4l_to_xv(pPPriv->audio.volume);
  1367. - } else {
  1368. - ret = BadValue;
  1369. - }
  1370. + *value = pPPriv->cenc;
  1371. + ret = Success;
  1372. } else if (attribute == xvFreq) {
  1373. - unsigned long freq;
  1374. - ioctl(V4L_FD,VIDIOCGFREQ,&freq);
  1375. - *value = freq;
  1376. - } else if (0 != pPPriv->yuv_format &&
  1377. - pPPriv->myfmt->getAttribute) {
  1378. - /* not mine -> pass to yuv scaler driver */
  1379. - ret = pPPriv->myfmt->getAttribute(pScrn, attribute, value);
  1380. + struct v4l2_frequency freq;
  1381. + memset(&freq, 0, sizeof(freq));
  1382. + if (ioctl(V4L_FD, VIDIOC_G_FREQUENCY, &freq) != -1) {
  1383. + *value = freq.frequency;
  1384. + ret = Success;
  1385. + }
  1386. } else {
  1387. - ret = BadValue;
  1388. + for (i = 0; i < pPPriv->n_qctrl; i++)
  1389. + if (pPPriv->XvV4LCtrl[i].xv == attribute)
  1390. + break;
  1391. + if (i == pPPriv->n_qctrl) {
  1392. + /* not mine -> pass to yuv scaler driver */
  1393. + if (0 != pPPriv->yuv_format && pPPriv->myfmt->getAttribute)
  1394. + ret = pPPriv->myfmt->getAttribute(pScrn, attribute, value);
  1395. + else
  1396. + ret = BadMatch;
  1397. + goto err;
  1398. + }
  1399. + if (pPPriv->XvV4LCtrl[i].qctrl.flags & V4L2_CTRL_FLAG_DISABLED)
  1400. + goto err;
  1401. + ctrl.id = pPPriv->XvV4LCtrl[i].qctrl.id;
  1402. + if (ioctl(V4L_FD, VIDIOC_G_CTRL, &ctrl) != -1) {
  1403. + *value = ctrl.value;
  1404. + ret = Success;
  1405. + }
  1406. }
  1407. -
  1408. DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/GPA %d, %d\n",
  1409. - attribute, *value));
  1410. + (int)attribute, (int)*value));
  1411. +err:
  1412. V4lCloseDevice(pPPriv,pScrn);
  1413. return ret;
  1414. }
  1415. @@ -673,15 +875,15 @@ V4lQueryBestSize(ScrnInfoPtr pScrn, Bool motion,
  1416. int maxy = pPPriv->enc[pPPriv->cenc].height;
  1417. if (0 != pPPriv->yuv_format) {
  1418. - *p_w = pPPriv->myfmt->max_width;
  1419. - *p_h = pPPriv->myfmt->max_height;
  1420. + *p_w = pPPriv->myfmt->max_width;
  1421. + *p_h = pPPriv->myfmt->max_height;
  1422. } else {
  1423. - *p_w = (drw_w < maxx) ? drw_w : maxx;
  1424. - *p_h = (drw_h < maxy) ? drw_h : maxy;
  1425. + *p_w = (drw_w < maxx) ? drw_w : maxx;
  1426. + *p_h = (drw_h < maxy) ? drw_h : maxy;
  1427. }
  1428. DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/BS %d %dx%d %dx%d\n",
  1429. - pPPriv->cenc,drw_w,drw_h,*p_w,*p_h));
  1430. + pPPriv->cenc,drw_w,drw_h,*p_w,*p_h));
  1431. }
  1432. static const OptionInfoRec *
  1433. @@ -693,132 +895,198 @@ V4LAvailableOptions(int chipid, int busid)
  1434. static void
  1435. V4LIdentify(int flags)
  1436. {
  1437. - xf86Msg(X_INFO, "v4l driver for Video4Linux\n");
  1438. -}
  1439. + xf86Msg(X_INFO, "v4l driver for Video4Linux overlay mode (V4L2)\n");
  1440. +}
  1441. static char*
  1442. fixname(char *str)
  1443. {
  1444. int s,d;
  1445. for (s=0, d=0;; s++) {
  1446. - if (str[s] == '-')
  1447. - continue;
  1448. - str[d++] = tolower(str[s]);
  1449. - if (0 == str[s])
  1450. - break;
  1451. + if (str[s] == '-')
  1452. + continue;
  1453. + str[d++] = tolower(str[s]);
  1454. + if (0 == str[s])
  1455. + break;
  1456. }
  1457. return str;
  1458. }
  1459. static int
  1460. -v4l_add_enc(XF86VideoEncodingPtr enc, int i,
  1461. - char *norm, char *input, int width, int height, int n, int d)
  1462. +AddV4LEnc(XF86VideoEncodingPtr enc, int entry,
  1463. + char *norm, char *input, int width, int height, int n, int d)
  1464. {
  1465. - enc[i].id = i;
  1466. - enc[i].name = xalloc(strlen(norm)+strlen(input)+2);
  1467. - if (NULL == enc[i].name)
  1468. - return -1;
  1469. - enc[i].width = width;
  1470. - enc[i].height = height;
  1471. - enc[i].rate.numerator = n;
  1472. - enc[i].rate.denominator = d;
  1473. - sprintf(enc[i].name,"%s-%s",norm,fixname(input));
  1474. + enc->id = entry;
  1475. + enc->name = malloc(strlen(norm) + strlen(input) + 2);
  1476. + if (!enc->name)
  1477. + return -1;
  1478. +
  1479. + enc->width = width;
  1480. + enc->height = height;
  1481. + enc->rate.numerator = n;
  1482. + enc->rate.denominator = d * 2; /* Refresh rate is twice, due to interlace */
  1483. + sprintf(enc->name,"%s-%s",norm,fixname(input));
  1484. +
  1485. + xf86Msg(X_INFO, "v4l: adding input %s, %dx%d %d fps\n",
  1486. + enc->name, enc->width, enc->height, (d + n - 1)/n);
  1487. +
  1488. return 0;
  1489. }
  1490. +static int
  1491. +V4LGetStd(PortPrivPtr p, int fd)
  1492. +{
  1493. + struct v4l2_standard standard;
  1494. + int entries = 0;
  1495. +
  1496. + /*
  1497. + * 128 is just an arbitrary large number. There aren't that many video stds
  1498. + * The max value is there just to avoid an endless loop, if the driver is
  1499. + * broken.
  1500. + */
  1501. + for (entries = 0; entries < 128; entries++) {
  1502. + memset(&standard, 0, sizeof(standard));
  1503. + standard.index = entries;
  1504. + if (-1 == ioctl(fd,VIDIOC_ENUMSTD, &standard))
  1505. + break;
  1506. + p->standard = realloc(p->standard, sizeof(standard) * (entries + 1));
  1507. + memcpy(&p->standard[entries], &standard, sizeof(standard));
  1508. + }
  1509. +
  1510. + /*
  1511. + * Some webcam drivers don't implement VIDIOC_ENUMSTD. Fake it
  1512. + * This is currently unused, as no webcam driver allows OVERLAY mode,
  1513. + * but the code is here, in the case some webcam driver starts allowing
  1514. + * overlay.
  1515. + * FIXME: Webcam drivers may use VIDIOC_ENUM_FRAMESIZES and
  1516. + * VIDIOC_ENUM_FRAMEINTERVALS ioctl's that may help to fine-tune
  1517. + * their needs. Those ioctl's could be used here in order to better
  1518. + * support webcams.
  1519. + */
  1520. + if (!entries) {
  1521. + xf86Msg(X_INFO, "v4l: VIDIOC_ENUMSTD error %d.\n",errno);
  1522. + p->standard = realloc(p->standard, sizeof(standard) * (entries + 1));
  1523. + p->standard[0].id = V4L2_STD_ALL;
  1524. + strcpy((char *)p->standard[0].name, "CAMERA");
  1525. + p->standard[0].frameperiod.numerator = 1001;
  1526. + p->standard[0].frameperiod.denominator = 300001;
  1527. + p->standard[0].framelines = 480;
  1528. + entries++;
  1529. + }
  1530. + return entries;
  1531. +}
  1532. +
  1533. static void
  1534. -V4LBuildEncodings(PortPrivPtr p, int fd, int channels)
  1535. +V4LBuildEncodings(PortPrivPtr p, int fd)
  1536. {
  1537. - static struct video_channel channel;
  1538. - int i,entries,have_bttv,bttv_ver;
  1539. -
  1540. -#define BTTV_VERSION _IOR('v' , BASE_VIDIOCPRIVATE+6, int)
  1541. - have_bttv = 0;
  1542. - if (-1 != ioctl(fd,BTTV_VERSION,&bttv_ver))
  1543. - have_bttv = 1;
  1544. -
  1545. - entries = (have_bttv ? 7 : 3) * channels;
  1546. - p->enc = xalloc(sizeof(XF86VideoEncodingRec) * entries);
  1547. - if (NULL == p->enc)
  1548. - goto fail;
  1549. - memset(p->enc,0,sizeof(XF86VideoEncodingRec) * entries);
  1550. - p->norm = xalloc(sizeof(int) * entries);
  1551. - if (NULL == p->norm)
  1552. - goto fail;
  1553. - memset(p->norm,0,sizeof(int) * entries);
  1554. - p->input = xalloc(sizeof(int) * entries);
  1555. - if (NULL == p->input)
  1556. - goto fail;
  1557. - memset(p->input,0,sizeof(int) * entries);
  1558. + unsigned int inp, std, num_std;
  1559. +
  1560. + num_std = V4LGetStd(p, fd);
  1561. p->nenc = 0;
  1562. - for (i = 0; i < channels; i++) {
  1563. - channel.channel = i;
  1564. - if (-1 == ioctl(fd,VIDIOCGCHAN,&channel)) {
  1565. - perror("ioctl VIDIOCGCHAN");
  1566. - continue;
  1567. - }
  1568. -
  1569. - v4l_add_enc(p->enc, p->nenc,"PAL", channel.name, 768,576, 1,50);
  1570. - p->norm[p->nenc] = VIDEO_MODE_PAL;
  1571. - p->input[p->nenc] = i;
  1572. - p->nenc++;
  1573. -
  1574. - v4l_add_enc(p->enc,p->nenc,"NTSC", channel.name, 640,480, 1001,60000);
  1575. - p->norm[p->nenc] = VIDEO_MODE_NTSC;
  1576. - p->input[p->nenc] = i;
  1577. - p->nenc++;
  1578. -
  1579. - v4l_add_enc(p->enc,p->nenc,"SECAM",channel.name, 768,576, 1,50);
  1580. - p->norm[p->nenc] = VIDEO_MODE_SECAM;
  1581. - p->input[p->nenc] = i;
  1582. - p->nenc++;
  1583. -
  1584. - if (have_bttv) {
  1585. - /* workaround for a v4l design flaw: The v4l API knows just pal,
  1586. - ntsc and secam. But there are a few more norms (pal versions
  1587. - with a different timings used in south america for example).
  1588. - The bttv driver can handle these too. */
  1589. - if (0 != v4l_add_enc(p->enc,p->nenc,"PAL-Nc",channel.name,
  1590. - 640, 576, 1,50))
  1591. - goto fail;
  1592. - p->norm[p->nenc] = 3;
  1593. - p->input[p->nenc] = i;
  1594. - p->nenc++;
  1595. -
  1596. - if (0 != v4l_add_enc(p->enc,p->nenc,"PAL-M",channel.name,
  1597. - 640, 576, 1,50))
  1598. - goto fail;
  1599. - p->norm[p->nenc] = 4;
  1600. - p->input[p->nenc] = i;
  1601. - p->nenc++;
  1602. -
  1603. - if (0 != v4l_add_enc(p->enc, p->nenc,"PAL-N", channel.name,
  1604. - 768,576, 1,50))
  1605. - goto fail;
  1606. - p->norm[p->nenc] = 5;
  1607. - p->input[p->nenc] = i;
  1608. - p->nenc++;
  1609. -
  1610. - if (0 != v4l_add_enc(p->enc,p->nenc,"NTSC-JP", channel.name,
  1611. - 640,480, 1001,60000))
  1612. - goto fail;
  1613. - p->norm[p->nenc] = 6;
  1614. - p->input[p->nenc] = i;
  1615. - p->nenc++;
  1616. - }
  1617. +
  1618. + /*
  1619. + * 256 is just an arbitrary large number. There aren't that many video
  1620. + * inputs on any driver. The max value is there just to avoid an endless
  1621. + * loop, if the driver is broken.
  1622. + */
  1623. + for (inp = 0; inp < 256; inp++) {
  1624. + struct v4l2_input input;
  1625. +
  1626. + memset(&input, 0, sizeof(input));
  1627. + input.index = inp;
  1628. + if (ioctl(fd, VIDIOC_ENUMINPUT, &input) == -1)
  1629. + break;
  1630. +
  1631. + for (std = 0; std < num_std; std++) {
  1632. + int width, height;
  1633. +
  1634. + /*
  1635. + * Currently, this code is not reliable, due to driver
  1636. + * non-compliance on both saa7134 and bttv. So, instead,
  1637. + * just use the video standard information
  1638. + */
  1639. +#if 0
  1640. + struct v4l2_framebuffer fbuf;
  1641. +
  1642. + /* Some webcam drivers will fail here, but that's OK */
  1643. + ioctl(fd, VIDIOC_S_STD, &p->standard[std].id);
  1644. +
  1645. + memset(&fbuf, 0, sizeof(fbuf));
  1646. + if (ioctl(fd, VIDIOC_G_FBUF, &fbuf) == -1) {
  1647. + xf86Msg(X_INFO, "v4l: Error %d: Can't get FBUF\n", errno);
  1648. + return;
  1649. + }
  1650. + height = fbuf.fmt.height;
  1651. + width = fbuf.fmt.width;
  1652. +
  1653. + /*
  1654. + * If the overlay method fails, get the resolution
  1655. + * via checking V4L2_BUF_TYPE_VIDEO_CAPTURE
  1656. + */
  1657. + if (!height || !width) {
  1658. + struct v4l2_format format;
  1659. +
  1660. + format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
  1661. + if (ioctl(fd, VIDIOC_G_FMT, &format) == -1) {
  1662. + /* Hmm... device doesn't support capture. */
  1663. + height = p->standard[std].framelines;
  1664. + if (height == 480)
  1665. + width = 640;
  1666. + else if (height == 576)
  1667. + width = 768;
  1668. + else
  1669. + continue;
  1670. + } else {
  1671. + height = format.fmt.pix.height;
  1672. + width = format.fmt.pix.width;
  1673. + }
  1674. + }
  1675. +#else
  1676. + if (p->standard[std].id & V4L2_STD_525_60) {
  1677. + height = 480;
  1678. + width = 640;
  1679. + } else {
  1680. + height = 576;
  1681. + width = 768;
  1682. + }
  1683. +
  1684. +#endif
  1685. + /* Fixup for some driver bug */
  1686. + if ((p->standard[std].id & V4L2_STD_525_60) && (height == 576))
  1687. + height = 480;
  1688. +
  1689. + p->enc = realloc(p->enc, sizeof(XF86VideoEncodingRec) * (p->nenc + 1));
  1690. + p->norm = realloc(p->norm, sizeof(int) * (p->nenc + 1));
  1691. + p->input = realloc(p->input, sizeof(int) * (p->nenc + 1));
  1692. + if (!p->enc || !p->norm || !p->input)
  1693. + goto fail;
  1694. + if (AddV4LEnc(&p->enc[p->nenc], p->nenc,
  1695. + (char *)p->standard[std].name,
  1696. + (char *)input.name, width, height,
  1697. + p->standard[std].frameperiod.numerator,
  1698. + p->standard[std].frameperiod.denominator))
  1699. + goto fail;
  1700. + p->norm[p->nenc] = p->standard[std].id;
  1701. + p->input[p->nenc] = inp;
  1702. + p->nenc++;
  1703. + }
  1704. }
  1705. +
  1706. + if (!p->nenc)
  1707. + xf86Msg(X_ERROR, "v4l: couldn't detect any valid input/standard\n");
  1708. return;
  1709. -
  1710. - fail:
  1711. +
  1712. +fail:
  1713. + xf86Msg(X_ERROR, "v4l: Fail to get standards: %d\n", errno);
  1714. if (p->input)
  1715. - xfree(p->input);
  1716. + free(p->input);
  1717. p->input = NULL;
  1718. if (p->norm)
  1719. - xfree(p->norm);
  1720. + free(p->norm);
  1721. p->norm = NULL;
  1722. if (p->enc)
  1723. - xfree(p->enc);
  1724. + free(p->enc);
  1725. p->enc = NULL;
  1726. p->nenc = 0;
  1727. }
  1728. @@ -826,73 +1094,33 @@ V4LBuildEncodings(PortPrivPtr p, int fd, int channels)
  1729. /* add a attribute a list */
  1730. static void
  1731. v4l_add_attr(XF86AttributeRec **list, int *count,
  1732. - const XF86AttributeRec *attr)
  1733. + const XF86AttributeRec *attr)
  1734. {
  1735. XF86AttributeRec *oldlist = *list;
  1736. int i;
  1737. + Atom gpa;
  1738. for (i = 0; i < *count; i++) {
  1739. - if (0 == strcmp((*list)[i].name,attr->name)) {
  1740. - DEBUG(xf86Msg(X_INFO, "v4l: skip dup attr %s\n",attr->name));
  1741. - return;
  1742. - }
  1743. + if (0 == strcmp((*list)[i].name,attr->name)) {
  1744. + DEBUG(xf86Msg(X_INFO, "v4l: skip dup attr %s\n",attr->name));
  1745. + return;
  1746. + }
  1747. }
  1748. -
  1749. - DEBUG(xf86Msg(X_INFO, "v4l: add attr %s\n",attr->name));
  1750. - *list = xalloc((*count + 1) * sizeof(XF86AttributeRec));
  1751. +
  1752. + *list = malloc((*count + 1) * sizeof(XF86AttributeRec));
  1753. if (NULL == *list) {
  1754. - *count = 0;
  1755. - return;
  1756. + *count = 0;
  1757. + return;
  1758. }
  1759. if (*count)
  1760. - memcpy(*list, oldlist, *count * sizeof(XF86AttributeRec));
  1761. + memcpy(*list, oldlist, *count * sizeof(XF86AttributeRec));
  1762. memcpy(*list + *count, attr, sizeof(XF86AttributeRec));
  1763. - (*count)++;
  1764. -}
  1765. -/* setup yuv overlay + hw scaling: look if we find some common video
  1766. - format which both v4l driver and the X-Server can handle */
  1767. -static void v4l_check_yuv(ScrnInfoPtr pScrn, PortPrivPtr pPPriv,
  1768. - char *dev, int fd)
  1769. -{
  1770. - static const struct {
  1771. - unsigned int v4l_palette;
  1772. - unsigned int v4l_depth;
  1773. - unsigned int xv_id;
  1774. - unsigned int xv_format;
  1775. - } yuvlist[] = {
  1776. - { VIDEO_PALETTE_YUV422, 16, 0x32595559, XvPacked },
  1777. - { VIDEO_PALETTE_UYVY, 16, 0x59565955, XvPacked },
  1778. - { 0 /* end of list */ },
  1779. - };
  1780. - ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
  1781. - int fmt,i;
  1782. + gpa = MAKE_ATOM((*list)[*count].name);
  1783. + xf86Msg(X_INFO, "v4l: add attr %s (Xv/GPA %d) (%d to %d)\n",
  1784. + attr->name, (int)gpa, attr->min_value, attr->max_value);
  1785. - pPPriv->format = xf86XVQueryOffscreenImages(pScreen,&pPPriv->nformat);
  1786. - for (fmt = 0; yuvlist[fmt].v4l_palette != 0; fmt++) {
  1787. - /* check v4l ... */
  1788. - ioctl(fd,VIDIOCGPICT,&pPPriv->pict);
  1789. - pPPriv->pict.palette = yuvlist[fmt].v4l_palette;
  1790. - pPPriv->pict.depth = yuvlist[fmt].v4l_depth;
  1791. - if (-1 == ioctl(fd,VIDIOCSPICT,&pPPriv->pict))
  1792. - continue;
  1793. - ioctl(fd,VIDIOCGPICT,&pPPriv->pict);
  1794. - if (pPPriv->pict.palette != yuvlist[fmt].v4l_palette)
  1795. - continue;
  1796. - /* ... works, check available offscreen image formats now ... */
  1797. - for (i = 0; i < pPPriv->nformat; i++) {
  1798. - if (pPPriv->format[i].image->id == yuvlist[fmt].xv_id &&
  1799. - pPPriv->format[i].image->format == yuvlist[fmt].xv_format) {
  1800. - /* ... match found, good. */
  1801. - pPPriv->yuv_format = yuvlist[fmt].v4l_palette;
  1802. - pPPriv->myfmt = pPPriv->format+i;
  1803. - xf86DrvMsg(pScrn->scrnIndex, X_INFO,
  1804. - "v4l[%s]: using hw video scaling [%4.4s].\n",
  1805. - dev,(char*)&(pPPriv->format[i].image->id));
  1806. - return;
  1807. - }
  1808. - }
  1809. - }
  1810. + (*count)++;
  1811. }
  1812. static int
  1813. @@ -904,118 +1132,114 @@ V4LInit(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr **adaptors)
  1814. char dev[18];
  1815. int fd,i,j,d;
  1816. - DEBUG(xf86Msg(X_INFO, "v4l: init start\n"));
  1817. -
  1818. for (i = 0, d = 0; d < MAX_V4L_DEVICES; d++) {
  1819. - sprintf(dev, "/dev/video%d", d);
  1820. - fd = open(dev, O_RDWR, 0);
  1821. - if (fd == -1) {
  1822. - sprintf(dev, "/dev/v4l/video%d", d);
  1823. - fd = open(dev, O_RDWR, 0);
  1824. - if (fd == -1)
  1825. - break;
  1826. - }
  1827. - DEBUG(xf86Msg(X_INFO, "v4l: %s open ok\n",dev));
  1828. -
  1829. - /* our private data */
  1830. - pPPriv = xalloc(sizeof(PortPrivRec));
  1831. - if (!pPPriv)
  1832. - return FALSE;
  1833. - memset(pPPriv,0,sizeof(PortPrivRec));
  1834. - pPPriv->nr = d;
  1835. -
  1836. - /* check device */
  1837. - if (-1 == ioctl(fd,VIDIOCGCAP,&pPPriv->cap) ||
  1838. - 0 == (pPPriv->cap.type & VID_TYPE_OVERLAY)) {
  1839. - DEBUG(xf86Msg(X_INFO, "v4l: %s: no overlay support\n",dev));
  1840. - xfree(pPPriv);
  1841. - close(fd);
  1842. - continue;
  1843. - }
  1844. - strncpy(V4L_NAME, dev, 16);
  1845. - V4LBuildEncodings(pPPriv,fd,pPPriv->cap.channels);
  1846. - if (NULL == pPPriv->enc)
  1847. - return FALSE;
  1848. - v4l_check_yuv(pScrn,pPPriv,dev,fd);
  1849. -
  1850. - /* alloc VideoAdaptorRec */
  1851. - VAR = xrealloc(VAR,sizeof(XF86VideoAdaptorPtr)*(i+1));
  1852. - VAR[i] = xalloc(sizeof(XF86VideoAdaptorRec));
  1853. - if (!VAR[i])
  1854. - return FALSE;
  1855. - memset(VAR[i],0,sizeof(XF86VideoAdaptorRec));
  1856. -
  1857. -
  1858. - /* build attribute list */
  1859. - for (j = 0; j < V4L_ATTR; j++) {
  1860. - /* video attributes */
  1861. - v4l_add_attr(&VAR[i]->pAttributes, &VAR[i]->nAttributes,
  1862. - &Attributes[j]);
  1863. - }
  1864. - if (0 == ioctl(fd,VIDIOCGAUDIO,&pPPriv->audio)) {
  1865. - /* audio attributes */
  1866. - if (pPPriv->audio.flags & VIDEO_AUDIO_VOLUME)
  1867. - v4l_add_attr(&VAR[i]->pAttributes, &VAR[i]->nAttributes,
  1868. - &VolumeAttr);
  1869. - if (pPPriv->audio.flags & VIDEO_AUDIO_MUTABLE)
  1870. - v4l_add_attr(&VAR[i]->pAttributes, &VAR[i]->nAttributes,
  1871. - &MuteAttr);
  1872. - }
  1873. - if (pPPriv->cap.type & VID_TYPE_TUNER) {
  1874. - /* tuner attributes */
  1875. - v4l_add_attr(&VAR[i]->pAttributes, &VAR[i]->nAttributes,
  1876. - &FreqAttr);
  1877. - }
  1878. - if (0 != pPPriv->yuv_format) {
  1879. - /* pass throuth scaler attributes */
  1880. - for (j = 0; j < pPPriv->myfmt->num_attributes; j++) {
  1881. - v4l_add_attr(&VAR[i]->pAttributes, &VAR[i]->nAttributes,
  1882. - pPPriv->myfmt->attributes+j);
  1883. - }
  1884. - }
  1885. -
  1886. -
  1887. - /* hook in private data */
  1888. - Private = xalloc(sizeof(DevUnion));
  1889. - if (!Private)
  1890. - return FALSE;
  1891. - memset(Private,0,sizeof(DevUnion));
  1892. - Private->ptr = (pointer)pPPriv;
  1893. - VAR[i]->pPortPrivates = Private;
  1894. - VAR[i]->nPorts = 1;
  1895. -
  1896. - /* init VideoAdaptorRec */
  1897. - VAR[i]->type = XvInputMask | XvWindowMask | XvVideoMask;
  1898. - VAR[i]->name = "video4linux";
  1899. - VAR[i]->flags = VIDEO_INVERT_CLIPLIST;
  1900. -
  1901. - VAR[i]->PutVideo = V4lPutVideo;
  1902. - VAR[i]->PutStill = V4lPutStill;
  1903. - VAR[i]->StopVideo = V4lStopVideo;
  1904. - VAR[i]->SetPortAttribute = V4lSetPortAttribute;
  1905. - VAR[i]->GetPortAttribute = V4lGetPortAttribute;
  1906. - VAR[i]->QueryBestSize = V4lQueryBestSize;
  1907. -
  1908. - VAR[i]->nEncodings = pPPriv->nenc;
  1909. - VAR[i]->pEncodings = pPPriv->enc;
  1910. - VAR[i]->nFormats =
  1911. - sizeof(InputVideoFormats) / sizeof(InputVideoFormats[0]);
  1912. - VAR[i]->pFormats = InputVideoFormats;
  1913. -
  1914. - if (fd != -1)
  1915. - close(fd);
  1916. - i++;
  1917. + sprintf(dev, "/dev/video%d", d);
  1918. + fd = open(dev, O_RDWR, 0);
  1919. + if (fd == -1) {
  1920. + sprintf(dev, "/dev/v4l/video%d", d);
  1921. + fd = open(dev, O_RDWR, 0);
  1922. + if (fd == -1)
  1923. + break;
  1924. + }
  1925. + DEBUG(xf86Msg(X_INFO, "v4l: %s open ok\n",dev));
  1926. +
  1927. + /* our private data */
  1928. + pPPriv = malloc(sizeof(PortPrivRec));
  1929. + if (!pPPriv)
  1930. + return FALSE;
  1931. + memset(pPPriv,0,sizeof(PortPrivRec));
  1932. + pPPriv->nr = d;
  1933. +
  1934. + /* check device capabilities */
  1935. + memset(&pPPriv->cap, 0, sizeof(&pPPriv->cap));
  1936. + if (-1 == ioctl(fd, VIDIOC_QUERYCAP, &pPPriv->cap) ||
  1937. + 0 == (pPPriv->cap.capabilities & V4L2_CAP_VIDEO_OVERLAY)) {
  1938. + xf86Msg(X_ERROR, "v4l: %s: no overlay support\n",dev);
  1939. + free(pPPriv);
  1940. + close(fd);
  1941. + continue;
  1942. + }
  1943. +
  1944. + if (v4l_check_yuv(pScrn, pPPriv, dev, fd) == FALSE) {
  1945. + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
  1946. + "Xv Overlay not supported. Can't use v4l driver\n");
  1947. + free(pPPriv);
  1948. + close(fd);
  1949. + continue;
  1950. + }
  1951. +
  1952. + xf86Msg(X_INFO, "v4l: enabling overlay mode for %s.\n", dev);
  1953. + strncpy(V4L_NAME, dev, 16);
  1954. + V4LBuildEncodings(pPPriv, fd);
  1955. + if (NULL == pPPriv->enc)
  1956. + return FALSE;
  1957. +
  1958. + /* alloc VideoAdaptorRec */
  1959. + VAR = realloc(VAR,sizeof(XF86VideoAdaptorPtr)*(i+1));
  1960. + VAR[i] = malloc(sizeof(XF86VideoAdaptorRec));
  1961. + if (!VAR[i])
  1962. + return FALSE;
  1963. + memset(VAR[i],0,sizeof(XF86VideoAdaptorRec));
  1964. +
  1965. + /* build attribute list */
  1966. + AddAllV4LControls(pPPriv, &VAR[i]->pAttributes, &VAR[i]->nAttributes, fd);
  1967. +
  1968. + for (j = 0; j < V4L_ATTR; j++) {
  1969. + /* Other video attributes */
  1970. + v4l_add_attr(&VAR[i]->pAttributes, &VAR[i]->nAttributes,
  1971. + &Attributes[j]);
  1972. + }
  1973. + if (pPPriv->cap.capabilities & V4L2_CAP_TUNER) {
  1974. + /* tuner attributes */
  1975. + v4l_add_attr(&VAR[i]->pAttributes, &VAR[i]->nAttributes,
  1976. + &FreqAttr);
  1977. + }
  1978. +
  1979. + /* Initialize yuv_format */
  1980. + if (0 != pPPriv->yuv_format) {
  1981. + /* pass throuth scaler attributes */
  1982. + for (j = 0; j < pPPriv->myfmt->num_attributes; j++) {
  1983. + v4l_add_attr(&VAR[i]->pAttributes, &VAR[i]->nAttributes,
  1984. + pPPriv->myfmt->attributes+j);
  1985. + }
  1986. + }
  1987. +
  1988. + DEBUG(xf86Msg(X_INFO, "v4l: saving config into driver data\n"));
  1989. + /* hook in private data */
  1990. + Private = malloc(sizeof(DevUnion));
  1991. + if (!Private)
  1992. + return FALSE;
  1993. + memset(Private,0,sizeof(DevUnion));
  1994. + Private->ptr = (pointer)pPPriv;
  1995. + VAR[i]->pPortPrivates = Private;
  1996. + VAR[i]->nPorts = 1;
  1997. +
  1998. + /* init VideoAdaptorRec */
  1999. + VAR[i]->type = XvInputMask | XvWindowMask | XvVideoMask;
  2000. + VAR[i]->name = "video4linux";
  2001. + VAR[i]->flags = VIDEO_INVERT_CLIPLIST;
  2002. +
  2003. + VAR[i]->PutVideo = V4lPutVideo;
  2004. + VAR[i]->PutStill = V4lPutStill;
  2005. + VAR[i]->StopVideo = V4lStopVideo;
  2006. + VAR[i]->SetPortAttribute = V4lSetPortAttribute;
  2007. + VAR[i]->GetPortAttribute = V4lGetPortAttribute;
  2008. + VAR[i]->QueryBestSize = V4lQueryBestSize;
  2009. +
  2010. + VAR[i]->nEncodings = pPPriv->nenc;
  2011. + VAR[i]->pEncodings = pPPriv->enc;
  2012. + VAR[i]->nFormats = sizeof(InputVideoFormats) / sizeof(InputVideoFormats[0]);
  2013. + VAR[i]->pFormats = InputVideoFormats;
  2014. +
  2015. + if (fd != -1) {
  2016. + DEBUG(xf86Msg(X_INFO, "v4l: %s init finished.\n",dev));
  2017. + close(fd);
  2018. + }
  2019. + i++;
  2020. }
  2021. xvEncoding = MAKE_ATOM(XV_ENCODING);
  2022. - xvHue = MAKE_ATOM(XV_HUE);
  2023. - xvSaturation = MAKE_ATOM(XV_SATURATION);
  2024. - xvBrightness = MAKE_ATOM(XV_BRIGHTNESS);
  2025. - xvContrast = MAKE_ATOM(XV_CONTRAST);
  2026. -
  2027. xvFreq = MAKE_ATOM(XV_FREQ);
  2028. - xvMute = MAKE_ATOM(XV_MUTE);
  2029. - xvVolume = MAKE_ATOM(XV_VOLUME);
  2030. DEBUG(xf86Msg(X_INFO, "v4l: init done, %d device(s) found\n",i));
  2031. @@ -1024,10 +1248,43 @@ V4LInit(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr **adaptors)
  2032. }
  2033. static Bool
  2034. +V4LDetect(void)
  2035. +{
  2036. + struct v4l2_capability cap;
  2037. + int fd, d, n = 0;
  2038. + char dev[18];
  2039. +
  2040. + for (d = 0; d < MAX_V4L_DEVICES; d++) {
  2041. + sprintf(dev, "/dev/video%d", d);
  2042. + fd = open(dev, O_RDWR, 0);
  2043. + if (fd == -1) {
  2044. + sprintf(dev, "/dev/v4l/video%d", d);
  2045. + fd = open(dev, O_RDWR, 0);
  2046. + if (fd == -1)
  2047. + break;
  2048. + }
  2049. + close (fd);
  2050. + memset(&cap, 0, sizeof(cap));
  2051. + if (!ioctl(fd, VIDIOC_QUERYCAP, &cap) &&
  2052. + (cap.capabilities & V4L2_CAP_VIDEO_OVERLAY))
  2053. + n++;
  2054. + }
  2055. + xf86Msg(X_INFO, "v4l: %d video adapters with overlay support detected\n", n);
  2056. +
  2057. + return (n > 0) ? TRUE : FALSE;
  2058. +}
  2059. +
  2060. +static Bool
  2061. V4LProbe(DriverPtr drv, int flags)
  2062. {
  2063. - if (flags & PROBE_DETECT)
  2064. - return TRUE;
  2065. + /*
  2066. + * Don't try to register adapter at the detection phase, as Xv
  2067. + * extensions won't be there
  2068. + */
  2069. + if (flags == PROBE_DETECT)
  2070. + return V4LDetect();
  2071. +
  2072. + DEBUG(xf86Msg(X_INFO, "v4l: Initiating device probe\n"));
  2073. xf86XVRegisterGenericAdaptorDriver(V4LInit);
  2074. drv->refCount++;
  2075. diff --git a/src/videodev.h b/src/videodev.h
  2076. deleted file mode 100644
  2077. index 3c9a7d8..0000000
  2078. --- a/src/videodev.h
  2079. +++ /dev/null
  2080. @@ -1,254 +0,0 @@
  2081. -#ifndef __LINUX_VIDEODEV_H
  2082. -#define __LINUX_VIDEODEV_H
  2083. -
  2084. -/* Linux V4L API, Version 1
  2085. - * videodev.h from v4l driver in Linux 2.2.3
  2086. - *
  2087. - * Used here with the explicit permission of the original author, Alan Cox.
  2088. - * <alan@lxorguk.ukuu.org.uk>
  2089. - */
  2090. -
  2091. -#include <X11/Xmd.h>
  2092. -
  2093. -#define VID_TYPE_CAPTURE 1 /* Can capture */
  2094. -#define VID_TYPE_TUNER 2 /* Can tune */
  2095. -#define VID_TYPE_TELETEXT 4 /* Does teletext */
  2096. -#define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */
  2097. -#define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */
  2098. -#define VID_TYPE_CLIPPING 32 /* Can clip */
  2099. -#define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */
  2100. -#define VID_TYPE_SCALES 128 /* Scalable */
  2101. -#define VID_TYPE_MONOCHROME 256 /* Monochrome only */
  2102. -#define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */
  2103. -
  2104. -struct video_capability
  2105. -{
  2106. - char name[32];
  2107. - int type;
  2108. - int channels; /* Num channels */
  2109. - int audios; /* Num audio devices */
  2110. - int maxwidth; /* Supported width */
  2111. - int maxheight; /* And height */
  2112. - int minwidth; /* Supported width */
  2113. - int minheight; /* And height */
  2114. -};
  2115. -
  2116. -
  2117. -struct video_channel
  2118. -{
  2119. - int channel;
  2120. - char name[32];
  2121. - int tuners;
  2122. - CARD32 flags;
  2123. -#define VIDEO_VC_TUNER 1 /* Channel has a tuner */
  2124. -#define VIDEO_VC_AUDIO 2 /* Channel has audio */
  2125. - CARD16 type;
  2126. -#define VIDEO_TYPE_TV 1
  2127. -#define VIDEO_TYPE_CAMERA 2
  2128. - CARD16 norm; /* Norm set by channel */
  2129. -};
  2130. -
  2131. -struct video_tuner
  2132. -{
  2133. - int tuner;
  2134. - char name[32];
  2135. - unsigned long rangelow, rangehigh; /* Tuner range */
  2136. - CARD32 flags;
  2137. -#define VIDEO_TUNER_PAL 1
  2138. -#define VIDEO_TUNER_NTSC 2
  2139. -#define VIDEO_TUNER_SECAM 4
  2140. -#define VIDEO_TUNER_LOW 8 /* Uses KHz not MHz */
  2141. -#define VIDEO_TUNER_NORM 16 /* Tuner can set norm */
  2142. -#define VIDEO_TUNER_STEREO_ON 128 /* Tuner is seeing stereo */
  2143. - CARD16 mode; /* PAL/NTSC/SECAM/OTHER */
  2144. -#define VIDEO_MODE_PAL 0
  2145. -#define VIDEO_MODE_NTSC 1
  2146. -#define VIDEO_MODE_SECAM 2
  2147. -#define VIDEO_MODE_AUTO 3
  2148. - CARD16 signal; /* Signal strength 16bit scale */
  2149. -};
  2150. -
  2151. -struct video_picture
  2152. -{
  2153. - CARD16 brightness;
  2154. - CARD16 hue;
  2155. - CARD16 colour;
  2156. - CARD16 contrast;
  2157. - CARD16 whiteness; /* Black and white only */
  2158. - CARD16 depth; /* Capture depth */
  2159. - CARD16 palette; /* Palette in use */
  2160. -#define VIDEO_PALETTE_GREY 1 /* Linear greyscale */
  2161. -#define VIDEO_PALETTE_HI240 2 /* High 240 cube (BT848) */
  2162. -#define VIDEO_PALETTE_RGB565 3 /* 565 16 bit RGB */
  2163. -#define VIDEO_PALETTE_RGB24 4 /* 24bit RGB */
  2164. -#define VIDEO_PALETTE_RGB32 5 /* 32bit RGB */
  2165. -#define VIDEO_PALETTE_RGB555 6 /* 555 15bit RGB */
  2166. -#define VIDEO_PALETTE_YUV422 7 /* YUV422 capture */
  2167. -#define VIDEO_PALETTE_YUYV 8
  2168. -#define VIDEO_PALETTE_UYVY 9 /* The great thing about standards is ... */
  2169. -#define VIDEO_PALETTE_YUV420 10
  2170. -#define VIDEO_PALETTE_YUV411 11 /* YUV411 capture */
  2171. -#define VIDEO_PALETTE_RAW 12 /* RAW capture (BT848) */
  2172. -#define VIDEO_PALETTE_YUV422P 13 /* YUV 4:2:2 Planar */
  2173. -#define VIDEO_PALETTE_YUV411P 14 /* YUV 4:1:1 Planar */
  2174. -#define VIDEO_PALETTE_YUV420P 15 /* YUV 4:2:0 Planar */
  2175. -#define VIDEO_PALETTE_YUV410P 16 /* YUV 4:1:0 Planar */
  2176. -#define VIDEO_PALETTE_PLANAR 13 /* start of planar entries */
  2177. -#define VIDEO_PALETTE_COMPONENT 7 /* start of component entries */
  2178. -};
  2179. -
  2180. -struct video_audio
  2181. -{
  2182. - int audio; /* Audio channel */
  2183. - CARD16 volume; /* If settable */
  2184. - CARD16 bass, treble;
  2185. - CARD32 flags;
  2186. -#define VIDEO_AUDIO_MUTE 1
  2187. -#define VIDEO_AUDIO_MUTABLE 2
  2188. -#define VIDEO_AUDIO_VOLUME 4
  2189. -#define VIDEO_AUDIO_BASS 8
  2190. -#define VIDEO_AUDIO_TREBLE 16
  2191. - char name[16];
  2192. -#define VIDEO_SOUND_MONO 1
  2193. -#define VIDEO_SOUND_STEREO 2
  2194. -#define VIDEO_SOUND_LANG1 4
  2195. -#define VIDEO_SOUND_LANG2 8
  2196. - CARD16 mode;
  2197. - CARD16 balance; /* Stereo balance */
  2198. - CARD16 step; /* Step actual volume uses */
  2199. -};
  2200. -
  2201. -struct video_clip
  2202. -{
  2203. - INT32 x,y;
  2204. - INT32 width, height;
  2205. - struct video_clip *next; /* For user use/driver use only */
  2206. -};
  2207. -
  2208. -struct video_window
  2209. -{
  2210. - CARD32 x,y; /* Position of window */
  2211. - CARD32 width,height; /* Its size */
  2212. - CARD32 chromakey;
  2213. - CARD32 flags;
  2214. - struct video_clip *clips; /* Set only */
  2215. - int clipcount;
  2216. -#define VIDEO_WINDOW_INTERLACE 1
  2217. -#define VIDEO_CLIP_BITMAP -1
  2218. -/* bitmap is 1024x625, a '1' bit represents a clipped pixel */
  2219. -#define VIDEO_CLIPMAP_SIZE (128 * 625)
  2220. -};
  2221. -
  2222. -struct video_capture
  2223. -{
  2224. - CARD32 x,y; /* Offsets into image */
  2225. - CARD32 width, height; /* Area to capture */
  2226. - CARD16 decimation; /* Decimation divder */
  2227. - CARD16 flags; /* Flags for capture */
  2228. -#define VIDEO_CAPTURE_ODD 0 /* Temporal */
  2229. -#define VIDEO_CAPTURE_EVEN 1
  2230. -};
  2231. -
  2232. -struct video_buffer
  2233. -{
  2234. - void *base;
  2235. - int height,width;
  2236. - int depth;
  2237. - int bytesperline;
  2238. -};
  2239. -
  2240. -struct video_mmap
  2241. -{
  2242. - unsigned int frame; /* Frame (0 - n) for double buffer */
  2243. - int height,width;
  2244. - unsigned int format; /* should be VIDEO_PALETTE_* */
  2245. -};
  2246. -
  2247. -struct video_key
  2248. -{
  2249. - CARD8 key[8];
  2250. - CARD32 flags;
  2251. -};
  2252. -
  2253. -
  2254. -#define VIDEO_MAX_FRAME 32
  2255. -
  2256. -struct video_mbuf
  2257. -{
  2258. - int size; /* Total memory to map */
  2259. - int frames; /* Frames */
  2260. - int offsets[VIDEO_MAX_FRAME];
  2261. -};
  2262. -
  2263. -
  2264. -#define VIDEO_NO_UNIT (-1)
  2265. -
  2266. -
  2267. -struct video_unit
  2268. -{
  2269. - int video; /* Video minor */
  2270. - int vbi; /* VBI minor */
  2271. - int radio; /* Radio minor */
  2272. - int audio; /* Audio minor */
  2273. - int teletext; /* Teletext minor */
  2274. -};
  2275. -
  2276. -#define VIDIOCGCAP _IOR('v',1,struct video_capability) /* Get capabilities */
  2277. -#define VIDIOCGCHAN _IOWR('v',2,struct video_channel) /* Get channel info (sources) */
  2278. -#define VIDIOCSCHAN _IOW('v',3,struct video_channel) /* Set channel */
  2279. -#define VIDIOCGTUNER _IOWR('v',4,struct video_tuner) /* Get tuner abilities */
  2280. -#define VIDIOCSTUNER _IOW('v',5,struct video_tuner) /* Tune the tuner for the current channel */
  2281. -#define VIDIOCGPICT _IOR('v',6,struct video_picture) /* Get picture properties */
  2282. -#define VIDIOCSPICT _IOW('v',7,struct video_picture) /* Set picture properties */
  2283. -#define VIDIOCCAPTURE _IOW('v',8,int) /* Start, end capture */
  2284. -#define VIDIOCGWIN _IOR('v',9, struct video_window) /* Set the video overlay window */
  2285. -#define VIDIOCSWIN _IOW('v',10, struct video_window) /* Set the video overlay window - passes clip list for hardware smarts , chromakey etc */
  2286. -#define VIDIOCGFBUF _IOR('v',11, struct video_buffer) /* Get frame buffer */
  2287. -#define VIDIOCSFBUF _IOW('v',12, struct video_buffer) /* Set frame buffer - root only */
  2288. -#define VIDIOCKEY _IOR('v',13, struct video_key) /* Video key event - to dev 255 is to all - cuts capture on all DMA windows with this key (0xFFFFFFFF == all) */
  2289. -#define VIDIOCGFREQ _IOR('v',14, unsigned long) /* Set tuner */
  2290. -#define VIDIOCSFREQ _IOW('v',15, unsigned long) /* Set tuner */
  2291. -#define VIDIOCGAUDIO _IOR('v',16, struct video_audio) /* Get audio info */
  2292. -#define VIDIOCSAUDIO _IOW('v',17, struct video_audio) /* Audio source, mute etc */
  2293. -#define VIDIOCSYNC _IOW('v',18, int) /* Sync with mmap grabbing */
  2294. -#define VIDIOCMCAPTURE _IOW('v',19, struct video_mmap) /* Grab frames */
  2295. -#define VIDIOCGMBUF _IOR('v', 20, struct video_mbuf) /* Memory map buffer info */
  2296. -#define VIDIOCGUNIT _IOR('v', 21, struct video_unit) /* Get attached units */
  2297. -#define VIDIOCGCAPTURE _IOR('v',22, struct video_capture) /* Get frame buffer */
  2298. -#define VIDIOCSCAPTURE _IOW('v',23, struct video_capture) /* Set frame buffer - root only */
  2299. -
  2300. -#define BASE_VIDIOCPRIVATE 192 /* 192-255 are private */
  2301. -
  2302. -
  2303. -#define VID_HARDWARE_BT848 1
  2304. -#define VID_HARDWARE_QCAM_BW 2
  2305. -#define VID_HARDWARE_PMS 3
  2306. -#define VID_HARDWARE_QCAM_C 4
  2307. -#define VID_HARDWARE_PSEUDO 5
  2308. -#define VID_HARDWARE_SAA5249 6
  2309. -#define VID_HARDWARE_AZTECH 7
  2310. -#define VID_HARDWARE_SF16MI 8
  2311. -#define VID_HARDWARE_RTRACK 9
  2312. -#define VID_HARDWARE_ZOLTRIX 10
  2313. -#define VID_HARDWARE_SAA7146 11
  2314. -#define VID_HARDWARE_VIDEUM 12 /* Reserved for Winnov videum */
  2315. -#define VID_HARDWARE_RTRACK2 13
  2316. -#define VID_HARDWARE_PERMEDIA2 14 /* Reserved for Permedia2 */
  2317. -#define VID_HARDWARE_RIVA128 15 /* Reserved for RIVA 128 */
  2318. -#define VID_HARDWARE_PLANB 16 /* PowerMac motherboard video-in */
  2319. -#define VID_HARDWARE_BROADWAY 17 /* Broadway project */
  2320. -#define VID_HARDWARE_GEMTEK 18
  2321. -#define VID_HARDWARE_TYPHOON 19
  2322. -#define VID_HARDWARE_VINO 20 /* Reserved for SGI Indy Vino */
  2323. -
  2324. -/*
  2325. - * Initialiser list
  2326. - */
  2327. -
  2328. -struct video_init
  2329. -{
  2330. - char *name;
  2331. - int (*init)(struct video_init *);
  2332. -};
  2333. -
  2334. -#endif
  2335. diff --git a/src/videodev2.h b/src/videodev2.h
  2336. new file mode 100644
  2337. index 0000000..bf6dde2
  2338. --- /dev/null
  2339. +++ b/src/videodev2.h
  2340. @@ -0,0 +1,1929 @@
  2341. +/*
  2342. + * Video for Linux Two header file
  2343. + *
  2344. + * Copyright (C) 1999-2007 the contributors
  2345. + *
  2346. + * This program is free software; you can redistribute it and/or modify
  2347. + * it under the terms of the GNU General Public License as published by
  2348. + * the Free Software Foundation; either version 2 of the License, or
  2349. + * (at your option) any later version.
  2350. + *
  2351. + * This program is distributed in the hope that it will be useful,
  2352. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2353. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2354. + * GNU General Public License for more details.
  2355. + *
  2356. + * Alternatively you can redistribute this file under the terms of the
  2357. + * BSD license as stated below:
  2358. + *
  2359. + * Redistribution and use in source and binary forms, with or without
  2360. + * modification, are permitted provided that the following conditions
  2361. + * are met:
  2362. + * 1. Redistributions of source code must retain the above copyright
  2363. + * notice, this list of conditions and the following disclaimer.
  2364. + * 2. Redistributions in binary form must reproduce the above copyright
  2365. + * notice, this list of conditions and the following disclaimer in
  2366. + * the documentation and/or other materials provided with the
  2367. + * distribution.
  2368. + * 3. The names of its contributors may not be used to endorse or promote
  2369. + * products derived from this software without specific prior written
  2370. + * permission.
  2371. + *
  2372. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  2373. + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  2374. + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  2375. + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  2376. + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  2377. + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  2378. + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  2379. + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  2380. + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  2381. + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  2382. + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2383. + *
  2384. + * Header file for v4l or V4L2 drivers and applications
  2385. + * with public API.
  2386. + * All kernel-specific stuff were moved to media/v4l2-dev.h, so
  2387. + * no #if __KERNEL tests are allowed here
  2388. + *
  2389. + * See http://linuxtv.org for more info
  2390. + *
  2391. + * Author: Bill Dirks <bill@thedirks.org>
  2392. + * Justin Schoeman
  2393. + * Hans Verkuil <hverkuil@xs4all.nl>
  2394. + * et al.
  2395. + */
  2396. +#ifndef __LINUX_VIDEODEV2_H
  2397. +#define __LINUX_VIDEODEV2_H
  2398. +
  2399. +#include <linux/ioctl.h>
  2400. +#include <linux/types.h>
  2401. +#include <sys/time.h>
  2402. +
  2403. +/*
  2404. + * Common stuff for both V4L1 and V4L2
  2405. + * Moved from videodev.h
  2406. + */
  2407. +#define VIDEO_MAX_FRAME 32
  2408. +#define VIDEO_MAX_PLANES 8
  2409. +
  2410. +/* These defines are V4L1 specific and should not be used with the V4L2 API!
  2411. + They will be removed from this header in the future. */
  2412. +
  2413. +#define VID_TYPE_CAPTURE 1 /* Can capture */
  2414. +#define VID_TYPE_TUNER 2 /* Can tune */
  2415. +#define VID_TYPE_TELETEXT 4 /* Does teletext */
  2416. +#define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */
  2417. +#define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */
  2418. +#define VID_TYPE_CLIPPING 32 /* Can clip */
  2419. +#define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */
  2420. +#define VID_TYPE_SCALES 128 /* Scalable */
  2421. +#define VID_TYPE_MONOCHROME 256 /* Monochrome only */
  2422. +#define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */
  2423. +#define VID_TYPE_MPEG_DECODER 1024 /* Can decode MPEG streams */
  2424. +#define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */
  2425. +#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */
  2426. +#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */
  2427. +
  2428. +/*
  2429. + * M I S C E L L A N E O U S
  2430. + */
  2431. +
  2432. +/* Four-character-code (FOURCC) */
  2433. +#define v4l2_fourcc(a, b, c, d)\
  2434. + ((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) | ((__u32)(d) << 24))
  2435. +
  2436. +/*
  2437. + * E N U M S
  2438. + */
  2439. +enum v4l2_field {
  2440. + V4L2_FIELD_ANY = 0, /* driver can choose from none,
  2441. + top, bottom, interlaced
  2442. + depending on whatever it thinks
  2443. + is approximate ... */
  2444. + V4L2_FIELD_NONE = 1, /* this device has no fields ... */
  2445. + V4L2_FIELD_TOP = 2, /* top field only */
  2446. + V4L2_FIELD_BOTTOM = 3, /* bottom field only */
  2447. + V4L2_FIELD_INTERLACED = 4, /* both fields interlaced */
  2448. + V4L2_FIELD_SEQ_TB = 5, /* both fields sequential into one
  2449. + buffer, top-bottom order */
  2450. + V4L2_FIELD_SEQ_BT = 6, /* same as above + bottom-top order */
  2451. + V4L2_FIELD_ALTERNATE = 7, /* both fields alternating into
  2452. + separate buffers */
  2453. + V4L2_FIELD_INTERLACED_TB = 8, /* both fields interlaced, top field
  2454. + first and the top field is
  2455. + transmitted first */
  2456. + V4L2_FIELD_INTERLACED_BT = 9, /* both fields interlaced, top field
  2457. + first and the bottom field is
  2458. + transmitted first */
  2459. +};
  2460. +#define V4L2_FIELD_HAS_TOP(field) \
  2461. + ((field) == V4L2_FIELD_TOP ||\
  2462. + (field) == V4L2_FIELD_INTERLACED ||\
  2463. + (field) == V4L2_FIELD_INTERLACED_TB ||\
  2464. + (field) == V4L2_FIELD_INTERLACED_BT ||\
  2465. + (field) == V4L2_FIELD_SEQ_TB ||\
  2466. + (field) == V4L2_FIELD_SEQ_BT)
  2467. +#define V4L2_FIELD_HAS_BOTTOM(field) \
  2468. + ((field) == V4L2_FIELD_BOTTOM ||\
  2469. + (field) == V4L2_FIELD_INTERLACED ||\
  2470. + (field) == V4L2_FIELD_INTERLACED_TB ||\
  2471. + (field) == V4L2_FIELD_INTERLACED_BT ||\
  2472. + (field) == V4L2_FIELD_SEQ_TB ||\
  2473. + (field) == V4L2_FIELD_SEQ_BT)
  2474. +#define V4L2_FIELD_HAS_BOTH(field) \
  2475. + ((field) == V4L2_FIELD_INTERLACED ||\
  2476. + (field) == V4L2_FIELD_INTERLACED_TB ||\
  2477. + (field) == V4L2_FIELD_INTERLACED_BT ||\
  2478. + (field) == V4L2_FIELD_SEQ_TB ||\
  2479. + (field) == V4L2_FIELD_SEQ_BT)
  2480. +
  2481. +enum v4l2_buf_type {
  2482. + V4L2_BUF_TYPE_VIDEO_CAPTURE = 1,
  2483. + V4L2_BUF_TYPE_VIDEO_OUTPUT = 2,
  2484. + V4L2_BUF_TYPE_VIDEO_OVERLAY = 3,
  2485. + V4L2_BUF_TYPE_VBI_CAPTURE = 4,
  2486. + V4L2_BUF_TYPE_VBI_OUTPUT = 5,
  2487. + V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = 6,
  2488. + V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = 7,
  2489. +#if 1
  2490. + /* Experimental */
  2491. + V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY = 8,
  2492. +#endif
  2493. + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9,
  2494. + V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = 10,
  2495. + V4L2_BUF_TYPE_PRIVATE = 0x80,
  2496. +};
  2497. +
  2498. +#define V4L2_TYPE_IS_MULTIPLANAR(type) \
  2499. + ((type) == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE \
  2500. + || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
  2501. +
  2502. +#define V4L2_TYPE_IS_OUTPUT(type) \
  2503. + ((type) == V4L2_BUF_TYPE_VIDEO_OUTPUT \
  2504. + || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE \
  2505. + || (type) == V4L2_BUF_TYPE_VIDEO_OVERLAY \
  2506. + || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY \
  2507. + || (type) == V4L2_BUF_TYPE_VBI_OUTPUT \
  2508. + || (type) == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT)
  2509. +
  2510. +enum v4l2_tuner_type {
  2511. + V4L2_TUNER_RADIO = 1,
  2512. + V4L2_TUNER_ANALOG_TV = 2,
  2513. + V4L2_TUNER_DIGITAL_TV = 3,
  2514. +};
  2515. +
  2516. +enum v4l2_memory {
  2517. + V4L2_MEMORY_MMAP = 1,
  2518. + V4L2_MEMORY_USERPTR = 2,
  2519. + V4L2_MEMORY_OVERLAY = 3,
  2520. +};
  2521. +
  2522. +/* see also http://vektor.theorem.ca/graphics/ycbcr/ */
  2523. +enum v4l2_colorspace {
  2524. + /* ITU-R 601 -- broadcast NTSC/PAL */
  2525. + V4L2_COLORSPACE_SMPTE170M = 1,
  2526. +
  2527. + /* 1125-Line (US) HDTV */
  2528. + V4L2_COLORSPACE_SMPTE240M = 2,
  2529. +
  2530. + /* HD and modern captures. */
  2531. + V4L2_COLORSPACE_REC709 = 3,
  2532. +
  2533. + /* broken BT878 extents (601, luma range 16-253 instead of 16-235) */
  2534. + V4L2_COLORSPACE_BT878 = 4,
  2535. +
  2536. + /* These should be useful. Assume 601 extents. */
  2537. + V4L2_COLORSPACE_470_SYSTEM_M = 5,
  2538. + V4L2_COLORSPACE_470_SYSTEM_BG = 6,
  2539. +
  2540. + /* I know there will be cameras that send this. So, this is
  2541. + * unspecified chromaticities and full 0-255 on each of the
  2542. + * Y'CbCr components
  2543. + */
  2544. + V4L2_COLORSPACE_JPEG = 7,
  2545. +
  2546. + /* For RGB colourspaces, this is probably a good start. */
  2547. + V4L2_COLORSPACE_SRGB = 8,
  2548. +};
  2549. +
  2550. +enum v4l2_priority {
  2551. + V4L2_PRIORITY_UNSET = 0, /* not initialized */
  2552. + V4L2_PRIORITY_BACKGROUND = 1,
  2553. + V4L2_PRIORITY_INTERACTIVE = 2,
  2554. + V4L2_PRIORITY_RECORD = 3,
  2555. + V4L2_PRIORITY_DEFAULT = V4L2_PRIORITY_INTERACTIVE,
  2556. +};
  2557. +
  2558. +struct v4l2_rect {
  2559. + __s32 left;
  2560. + __s32 top;
  2561. + __s32 width;
  2562. + __s32 height;
  2563. +};
  2564. +
  2565. +struct v4l2_fract {
  2566. + __u32 numerator;
  2567. + __u32 denominator;
  2568. +};
  2569. +
  2570. +/*
  2571. + * D R I V E R C A P A B I L I T I E S
  2572. + */
  2573. +struct v4l2_capability {
  2574. + __u8 driver[16]; /* i.e. "bttv" */
  2575. + __u8 card[32]; /* i.e. "Hauppauge WinTV" */
  2576. + __u8 bus_info[32]; /* "PCI:" + pci_name(pci_dev) */
  2577. + __u32 version; /* should use KERNEL_VERSION() */
  2578. + __u32 capabilities; /* Device capabilities */
  2579. + __u32 reserved[4];
  2580. +};
  2581. +
  2582. +/* Values for 'capabilities' field */
  2583. +#define V4L2_CAP_VIDEO_CAPTURE 0x00000001 /* Is a video capture device */
  2584. +#define V4L2_CAP_VIDEO_OUTPUT 0x00000002 /* Is a video output device */
  2585. +#define V4L2_CAP_VIDEO_OVERLAY 0x00000004 /* Can do video overlay */
  2586. +#define V4L2_CAP_VBI_CAPTURE 0x00000010 /* Is a raw VBI capture device */
  2587. +#define V4L2_CAP_VBI_OUTPUT 0x00000020 /* Is a raw VBI output device */
  2588. +#define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040 /* Is a sliced VBI capture device */
  2589. +#define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080 /* Is a sliced VBI output device */
  2590. +#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */
  2591. +#define V4L2_CAP_VIDEO_OUTPUT_OVERLAY 0x00000200 /* Can do video output overlay */
  2592. +#define V4L2_CAP_HW_FREQ_SEEK 0x00000400 /* Can do hardware frequency seek */
  2593. +#define V4L2_CAP_RDS_OUTPUT 0x00000800 /* Is an RDS encoder */
  2594. +
  2595. +/* Is a video capture device that supports multiplanar formats */
  2596. +#define V4L2_CAP_VIDEO_CAPTURE_MPLANE 0x00001000
  2597. +/* Is a video output device that supports multiplanar formats */
  2598. +#define V4L2_CAP_VIDEO_OUTPUT_MPLANE 0x00002000
  2599. +
  2600. +#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */
  2601. +#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */
  2602. +#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */
  2603. +#define V4L2_CAP_MODULATOR 0x00080000 /* has a modulator */
  2604. +
  2605. +#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */
  2606. +#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */
  2607. +#define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */
  2608. +
  2609. +/*
  2610. + * V I D E O I M A G E F O R M A T
  2611. + */
  2612. +struct v4l2_pix_format {
  2613. + __u32 width;
  2614. + __u32 height;
  2615. + __u32 pixelformat;
  2616. + enum v4l2_field field;
  2617. + __u32 bytesperline; /* for padding, zero if unused */
  2618. + __u32 sizeimage;
  2619. + enum v4l2_colorspace colorspace;
  2620. + __u32 priv; /* private data, depends on pixelformat */
  2621. +};
  2622. +
  2623. +/* Pixel format FOURCC depth Description */
  2624. +
  2625. +/* RGB formats */
  2626. +#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R', 'G', 'B', '1') /* 8 RGB-3-3-2 */
  2627. +#define V4L2_PIX_FMT_RGB444 v4l2_fourcc('R', '4', '4', '4') /* 16 xxxxrrrr ggggbbbb */
  2628. +#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R', 'G', 'B', 'O') /* 16 RGB-5-5-5 */
  2629. +#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R', 'G', 'B', 'P') /* 16 RGB-5-6-5 */
  2630. +#define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R', 'G', 'B', 'Q') /* 16 RGB-5-5-5 BE */
  2631. +#define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R') /* 16 RGB-5-6-5 BE */
  2632. +#define V4L2_PIX_FMT_BGR666 v4l2_fourcc('B', 'G', 'R', 'H') /* 18 BGR-6-6-6 */
  2633. +#define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B', 'G', 'R', '3') /* 24 BGR-8-8-8 */
  2634. +#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R', 'G', 'B', '3') /* 24 RGB-8-8-8 */
  2635. +#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B', 'G', 'R', '4') /* 32 BGR-8-8-8-8 */
  2636. +#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4') /* 32 RGB-8-8-8-8 */
  2637. +
  2638. +/* Grey formats */
  2639. +#define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */
  2640. +#define V4L2_PIX_FMT_Y4 v4l2_fourcc('Y', '0', '4', ' ') /* 4 Greyscale */
  2641. +#define V4L2_PIX_FMT_Y6 v4l2_fourcc('Y', '0', '6', ' ') /* 6 Greyscale */
  2642. +#define V4L2_PIX_FMT_Y10 v4l2_fourcc('Y', '1', '0', ' ') /* 10 Greyscale */
  2643. +#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ') /* 16 Greyscale */
  2644. +
  2645. +/* Palette formats */
  2646. +#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8') /* 8 8-bit palette */
  2647. +
  2648. +/* Luminance+Chrominance formats */
  2649. +#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y', 'V', 'U', '9') /* 9 YVU 4:1:0 */
  2650. +#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2') /* 12 YVU 4:2:0 */
  2651. +#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V') /* 16 YUV 4:2:2 */
  2652. +#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y', 'Y', 'U', 'V') /* 16 YUV 4:2:2 */
  2653. +#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U') /* 16 YVU 4:2:2 */
  2654. +#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y') /* 16 YUV 4:2:2 */
  2655. +#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y') /* 16 YUV 4:2:2 */
  2656. +#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P') /* 16 YVU422 planar */
  2657. +#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4', '1', '1', 'P') /* 16 YVU411 planar */
  2658. +#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */
  2659. +#define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y', '4', '4', '4') /* 16 xxxxyyyy uuuuvvvv */
  2660. +#define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O') /* 16 YUV-5-5-5 */
  2661. +#define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P') /* 16 YUV-5-6-5 */
  2662. +#define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4') /* 32 YUV-8-8-8-8 */
  2663. +#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */
  2664. +#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2') /* 12 YUV 4:2:0 */
  2665. +#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit color */
  2666. +#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */
  2667. +
  2668. +/* two planes -- one Y, one Cr + Cb interleaved */
  2669. +#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */
  2670. +#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N', 'V', '2', '1') /* 12 Y/CrCb 4:2:0 */
  2671. +#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6') /* 16 Y/CbCr 4:2:2 */
  2672. +#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */
  2673. +
  2674. +/* two non contiguous planes - one Y, one Cr + Cb interleaved */
  2675. +#define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 */
  2676. +#define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 macroblocks */
  2677. +
  2678. +/* three non contiguous planes - Y, Cb, Cr */
  2679. +#define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'M', '1', '2') /* 12 YUV420 planar */
  2680. +
  2681. +/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */
  2682. +#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */
  2683. +#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */
  2684. +#define V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G') /* 8 GRGR.. BGBG.. */
  2685. +#define V4L2_PIX_FMT_SRGGB8 v4l2_fourcc('R', 'G', 'G', 'B') /* 8 RGRG.. GBGB.. */
  2686. +#define V4L2_PIX_FMT_SBGGR10 v4l2_fourcc('B', 'G', '1', '0') /* 10 BGBG.. GRGR.. */
  2687. +#define V4L2_PIX_FMT_SGBRG10 v4l2_fourcc('G', 'B', '1', '0') /* 10 GBGB.. RGRG.. */
  2688. +#define V4L2_PIX_FMT_SGRBG10 v4l2_fourcc('B', 'A', '1', '0') /* 10 GRGR.. BGBG.. */
  2689. +#define V4L2_PIX_FMT_SRGGB10 v4l2_fourcc('R', 'G', '1', '0') /* 10 RGRG.. GBGB.. */
  2690. + /* 10bit raw bayer DPCM compressed to 8 bits */
  2691. +#define V4L2_PIX_FMT_SGRBG10DPCM8 v4l2_fourcc('B', 'D', '1', '0')
  2692. + /*
  2693. + * 10bit raw bayer, expanded to 16 bits
  2694. + * xxxxrrrrrrrrrrxxxxgggggggggg xxxxggggggggggxxxxbbbbbbbbbb...
  2695. + */
  2696. +#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16 BGBG.. GRGR.. */
  2697. +
  2698. +/* compressed formats */
  2699. +#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M', 'J', 'P', 'G') /* Motion-JPEG */
  2700. +#define V4L2_PIX_FMT_JPEG v4l2_fourcc('J', 'P', 'E', 'G') /* JFIF JPEG */
  2701. +#define V4L2_PIX_FMT_DV v4l2_fourcc('d', 'v', 's', 'd') /* 1394 */
  2702. +#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M', 'P', 'E', 'G') /* MPEG-1/2/4 */
  2703. +
  2704. +/* Vendor-specific formats */
  2705. +#define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */
  2706. +#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W', 'N', 'V', 'A') /* Winnov hw compress */
  2707. +#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S', '9', '1', '0') /* SN9C10x compression */
  2708. +#define V4L2_PIX_FMT_SN9C20X_I420 v4l2_fourcc('S', '9', '2', '0') /* SN9C20x YUV 4:2:0 */
  2709. +#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P', 'W', 'C', '1') /* pwc older webcam */
  2710. +#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P', 'W', 'C', '2') /* pwc newer webcam */
  2711. +#define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E', '6', '2', '5') /* ET61X251 compression */
  2712. +#define V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S', '5', '0', '1') /* YUYV per line */
  2713. +#define V4L2_PIX_FMT_SPCA505 v4l2_fourcc('S', '5', '0', '5') /* YYUV per line */
  2714. +#define V4L2_PIX_FMT_SPCA508 v4l2_fourcc('S', '5', '0', '8') /* YUVY per line */
  2715. +#define V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S', '5', '6', '1') /* compressed GBRG bayer */
  2716. +#define V4L2_PIX_FMT_PAC207 v4l2_fourcc('P', '2', '0', '7') /* compressed BGGR bayer */
  2717. +#define V4L2_PIX_FMT_MR97310A v4l2_fourcc('M', '3', '1', '0') /* compressed BGGR bayer */
  2718. +#define V4L2_PIX_FMT_SN9C2028 v4l2_fourcc('S', 'O', 'N', 'X') /* compressed GBRG bayer */
  2719. +#define V4L2_PIX_FMT_SQ905C v4l2_fourcc('9', '0', '5', 'C') /* compressed RGGB bayer */
  2720. +#define V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G') /* Pixart 73xx JPEG */
  2721. +#define V4L2_PIX_FMT_OV511 v4l2_fourcc('O', '5', '1', '1') /* ov511 JPEG */
  2722. +#define V4L2_PIX_FMT_OV518 v4l2_fourcc('O', '5', '1', '8') /* ov518 JPEG */
  2723. +#define V4L2_PIX_FMT_STV0680 v4l2_fourcc('S', '6', '8', '0') /* stv0680 bayer */
  2724. +#define V4L2_PIX_FMT_TM6000 v4l2_fourcc('T', 'M', '6', '0') /* tm5600/tm60x0 */
  2725. +#define V4L2_PIX_FMT_CIT_YYVYUY v4l2_fourcc('C', 'I', 'T', 'V') /* one line of Y then 1 line of VYUY */
  2726. +#define V4L2_PIX_FMT_KONICA420 v4l2_fourcc('K', 'O', 'N', 'I') /* YUV420 planar in blocks of 256 pixels */
  2727. +
  2728. +/*
  2729. + * F O R M A T E N U M E R A T I O N
  2730. + */
  2731. +struct v4l2_fmtdesc {
  2732. + __u32 index; /* Format number */
  2733. + enum v4l2_buf_type type; /* buffer type */
  2734. + __u32 flags;
  2735. + __u8 description[32]; /* Description string */
  2736. + __u32 pixelformat; /* Format fourcc */
  2737. + __u32 reserved[4];
  2738. +};
  2739. +
  2740. +#define V4L2_FMT_FLAG_COMPRESSED 0x0001
  2741. +#define V4L2_FMT_FLAG_EMULATED 0x0002
  2742. +
  2743. +#if 1
  2744. + /* Experimental Frame Size and frame rate enumeration */
  2745. +/*
  2746. + * F R A M E S I Z E E N U M E R A T I O N
  2747. + */
  2748. +enum v4l2_frmsizetypes {
  2749. + V4L2_FRMSIZE_TYPE_DISCRETE = 1,
  2750. + V4L2_FRMSIZE_TYPE_CONTINUOUS = 2,
  2751. + V4L2_FRMSIZE_TYPE_STEPWISE = 3,
  2752. +};
  2753. +
  2754. +struct v4l2_frmsize_discrete {
  2755. + __u32 width; /* Frame width [pixel] */
  2756. + __u32 height; /* Frame height [pixel] */
  2757. +};
  2758. +
  2759. +struct v4l2_frmsize_stepwise {
  2760. + __u32 min_width; /* Minimum frame width [pixel] */
  2761. + __u32 max_width; /* Maximum frame width [pixel] */
  2762. + __u32 step_width; /* Frame width step size [pixel] */
  2763. + __u32 min_height; /* Minimum frame height [pixel] */
  2764. + __u32 max_height; /* Maximum frame height [pixel] */
  2765. + __u32 step_height; /* Frame height step size [pixel] */
  2766. +};
  2767. +
  2768. +struct v4l2_frmsizeenum {
  2769. + __u32 index; /* Frame size number */
  2770. + __u32 pixel_format; /* Pixel format */
  2771. + __u32 type; /* Frame size type the device supports. */
  2772. +
  2773. + union { /* Frame size */
  2774. + struct v4l2_frmsize_discrete discrete;
  2775. + struct v4l2_frmsize_stepwise stepwise;
  2776. + };
  2777. +
  2778. + __u32 reserved[2]; /* Reserved space for future use */
  2779. +};
  2780. +
  2781. +/*
  2782. + * F R A M E R A T E E N U M E R A T I O N
  2783. + */
  2784. +enum v4l2_frmivaltypes {
  2785. + V4L2_FRMIVAL_TYPE_DISCRETE = 1,
  2786. + V4L2_FRMIVAL_TYPE_CONTINUOUS = 2,
  2787. + V4L2_FRMIVAL_TYPE_STEPWISE = 3,
  2788. +};
  2789. +
  2790. +struct v4l2_frmival_stepwise {
  2791. + struct v4l2_fract min; /* Minimum frame interval [s] */
  2792. + struct v4l2_fract max; /* Maximum frame interval [s] */
  2793. + struct v4l2_fract step; /* Frame interval step size [s] */
  2794. +};
  2795. +
  2796. +struct v4l2_frmivalenum {
  2797. + __u32 index; /* Frame format index */
  2798. + __u32 pixel_format; /* Pixel format */
  2799. + __u32 width; /* Frame width */
  2800. + __u32 height; /* Frame height */
  2801. + __u32 type; /* Frame interval type the device supports. */
  2802. +
  2803. + union { /* Frame interval */
  2804. + struct v4l2_fract discrete;
  2805. + struct v4l2_frmival_stepwise stepwise;
  2806. + };
  2807. +
  2808. + __u32 reserved[2]; /* Reserved space for future use */
  2809. +};
  2810. +#endif
  2811. +
  2812. +/*
  2813. + * T I M E C O D E
  2814. + */
  2815. +struct v4l2_timecode {
  2816. + __u32 type;
  2817. + __u32 flags;
  2818. + __u8 frames;
  2819. + __u8 seconds;
  2820. + __u8 minutes;
  2821. + __u8 hours;
  2822. + __u8 userbits[4];
  2823. +};
  2824. +
  2825. +/* Type */
  2826. +#define V4L2_TC_TYPE_24FPS 1
  2827. +#define V4L2_TC_TYPE_25FPS 2
  2828. +#define V4L2_TC_TYPE_30FPS 3
  2829. +#define V4L2_TC_TYPE_50FPS 4
  2830. +#define V4L2_TC_TYPE_60FPS 5
  2831. +
  2832. +/* Flags */
  2833. +#define V4L2_TC_FLAG_DROPFRAME 0x0001 /* "drop-frame" mode */
  2834. +#define V4L2_TC_FLAG_COLORFRAME 0x0002
  2835. +#define V4L2_TC_USERBITS_field 0x000C
  2836. +#define V4L2_TC_USERBITS_USERDEFINED 0x0000
  2837. +#define V4L2_TC_USERBITS_8BITCHARS 0x0008
  2838. +/* The above is based on SMPTE timecodes */
  2839. +
  2840. +struct v4l2_jpegcompression {
  2841. + int quality;
  2842. +
  2843. + int APPn; /* Number of APP segment to be written,
  2844. + * must be 0..15 */
  2845. + int APP_len; /* Length of data in JPEG APPn segment */
  2846. + char APP_data[60]; /* Data in the JPEG APPn segment. */
  2847. +
  2848. + int COM_len; /* Length of data in JPEG COM segment */
  2849. + char COM_data[60]; /* Data in JPEG COM segment */
  2850. +
  2851. + __u32 jpeg_markers; /* Which markers should go into the JPEG
  2852. + * output. Unless you exactly know what
  2853. + * you do, leave them untouched.
  2854. + * Inluding less markers will make the
  2855. + * resulting code smaller, but there will
  2856. + * be fewer applications which can read it.
  2857. + * The presence of the APP and COM marker
  2858. + * is influenced by APP_len and COM_len
  2859. + * ONLY, not by this property! */
  2860. +
  2861. +#define V4L2_JPEG_MARKER_DHT (1<<3) /* Define Huffman Tables */
  2862. +#define V4L2_JPEG_MARKER_DQT (1<<4) /* Define Quantization Tables */
  2863. +#define V4L2_JPEG_MARKER_DRI (1<<5) /* Define Restart Interval */
  2864. +#define V4L2_JPEG_MARKER_COM (1<<6) /* Comment segment */
  2865. +#define V4L2_JPEG_MARKER_APP (1<<7) /* App segment, driver will
  2866. + * allways use APP0 */
  2867. +};
  2868. +
  2869. +/*
  2870. + * M E M O R Y - M A P P I N G B U F F E R S
  2871. + */
  2872. +struct v4l2_requestbuffers {
  2873. + __u32 count;
  2874. + enum v4l2_buf_type type;
  2875. + enum v4l2_memory memory;
  2876. + __u32 reserved[2];
  2877. +};
  2878. +
  2879. +/**
  2880. + * struct v4l2_plane - plane info for multi-planar buffers
  2881. + * @bytesused: number of bytes occupied by data in the plane (payload)
  2882. + * @length: size of this plane (NOT the payload) in bytes
  2883. + * @mem_offset: when memory in the associated struct v4l2_buffer is
  2884. + * V4L2_MEMORY_MMAP, equals the offset from the start of
  2885. + * the device memory for this plane (or is a "cookie" that
  2886. + * should be passed to mmap() called on the video node)
  2887. + * @userptr: when memory is V4L2_MEMORY_USERPTR, a userspace pointer
  2888. + * pointing to this plane
  2889. + * @data_offset: offset in the plane to the start of data; usually 0,
  2890. + * unless there is a header in front of the data
  2891. + *
  2892. + * Multi-planar buffers consist of one or more planes, e.g. an YCbCr buffer
  2893. + * with two planes can have one plane for Y, and another for interleaved CbCr
  2894. + * components. Each plane can reside in a separate memory buffer, or even in
  2895. + * a completely separate memory node (e.g. in embedded devices).
  2896. + */
  2897. +struct v4l2_plane {
  2898. + __u32 bytesused;
  2899. + __u32 length;
  2900. + union {
  2901. + __u32 mem_offset;
  2902. + unsigned long userptr;
  2903. + } m;
  2904. + __u32 data_offset;
  2905. + __u32 reserved[11];
  2906. +};
  2907. +
  2908. +/**
  2909. + * struct v4l2_buffer - video buffer info
  2910. + * @index: id number of the buffer
  2911. + * @type: buffer type (type == *_MPLANE for multiplanar buffers)
  2912. + * @bytesused: number of bytes occupied by data in the buffer (payload);
  2913. + * unused (set to 0) for multiplanar buffers
  2914. + * @flags: buffer informational flags
  2915. + * @field: field order of the image in the buffer
  2916. + * @timestamp: frame timestamp
  2917. + * @timecode: frame timecode
  2918. + * @sequence: sequence count of this frame
  2919. + * @memory: the method, in which the actual video data is passed
  2920. + * @offset: for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
  2921. + * offset from the start of the device memory for this plane,
  2922. + * (or a "cookie" that should be passed to mmap() as offset)
  2923. + * @userptr: for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
  2924. + * a userspace pointer pointing to this buffer
  2925. + * @planes: for multiplanar buffers; userspace pointer to the array of plane
  2926. + * info structs for this buffer
  2927. + * @length: size in bytes of the buffer (NOT its payload) for single-plane
  2928. + * buffers (when type != *_MPLANE); number of elements in the
  2929. + * planes array for multi-plane buffers
  2930. + * @input: input number from which the video data has has been captured
  2931. + *
  2932. + * Contains data exchanged by application and driver using one of the Streaming
  2933. + * I/O methods.
  2934. + */
  2935. +struct v4l2_buffer {
  2936. + __u32 index;
  2937. + enum v4l2_buf_type type;
  2938. + __u32 bytesused;
  2939. + __u32 flags;
  2940. + enum v4l2_field field;
  2941. + struct timeval timestamp;
  2942. + struct v4l2_timecode timecode;
  2943. + __u32 sequence;
  2944. +
  2945. + /* memory location */
  2946. + enum v4l2_memory memory;
  2947. + union {
  2948. + __u32 offset;
  2949. + unsigned long userptr;
  2950. + struct v4l2_plane *planes;
  2951. + } m;
  2952. + __u32 length;
  2953. + __u32 input;
  2954. + __u32 reserved;
  2955. +};
  2956. +
  2957. +/* Flags for 'flags' field */
  2958. +#define V4L2_BUF_FLAG_MAPPED 0x0001 /* Buffer is mapped (flag) */
  2959. +#define V4L2_BUF_FLAG_QUEUED 0x0002 /* Buffer is queued for processing */
  2960. +#define V4L2_BUF_FLAG_DONE 0x0004 /* Buffer is ready */
  2961. +#define V4L2_BUF_FLAG_KEYFRAME 0x0008 /* Image is a keyframe (I-frame) */
  2962. +#define V4L2_BUF_FLAG_PFRAME 0x0010 /* Image is a P-frame */
  2963. +#define V4L2_BUF_FLAG_BFRAME 0x0020 /* Image is a B-frame */
  2964. +/* Buffer is ready, but the data contained within is corrupted. */
  2965. +#define V4L2_BUF_FLAG_ERROR 0x0040
  2966. +#define V4L2_BUF_FLAG_TIMECODE 0x0100 /* timecode field is valid */
  2967. +#define V4L2_BUF_FLAG_INPUT 0x0200 /* input field is valid */
  2968. +
  2969. +/*
  2970. + * O V E R L A Y P R E V I E W
  2971. + */
  2972. +struct v4l2_framebuffer {
  2973. + __u32 capability;
  2974. + __u32 flags;
  2975. +/* FIXME: in theory we should pass something like PCI device + memory
  2976. + * region + offset instead of some physical address */
  2977. + void *base;
  2978. + struct v4l2_pix_format fmt;
  2979. +};
  2980. +/* Flags for the 'capability' field. Read only */
  2981. +#define V4L2_FBUF_CAP_EXTERNOVERLAY 0x0001
  2982. +#define V4L2_FBUF_CAP_CHROMAKEY 0x0002
  2983. +#define V4L2_FBUF_CAP_LIST_CLIPPING 0x0004
  2984. +#define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008
  2985. +#define V4L2_FBUF_CAP_LOCAL_ALPHA 0x0010
  2986. +#define V4L2_FBUF_CAP_GLOBAL_ALPHA 0x0020
  2987. +#define V4L2_FBUF_CAP_LOCAL_INV_ALPHA 0x0040
  2988. +#define V4L2_FBUF_CAP_SRC_CHROMAKEY 0x0080
  2989. +/* Flags for the 'flags' field. */
  2990. +#define V4L2_FBUF_FLAG_PRIMARY 0x0001
  2991. +#define V4L2_FBUF_FLAG_OVERLAY 0x0002
  2992. +#define V4L2_FBUF_FLAG_CHROMAKEY 0x0004
  2993. +#define V4L2_FBUF_FLAG_LOCAL_ALPHA 0x0008
  2994. +#define V4L2_FBUF_FLAG_GLOBAL_ALPHA 0x0010
  2995. +#define V4L2_FBUF_FLAG_LOCAL_INV_ALPHA 0x0020
  2996. +#define V4L2_FBUF_FLAG_SRC_CHROMAKEY 0x0040
  2997. +
  2998. +struct v4l2_clip {
  2999. + struct v4l2_rect c;
  3000. + struct v4l2_clip *next;
  3001. +};
  3002. +
  3003. +struct v4l2_window {
  3004. + struct v4l2_rect w;
  3005. + enum v4l2_field field;
  3006. + __u32 chromakey;
  3007. + struct v4l2_clip *clips;
  3008. + __u32 clipcount;
  3009. + void *bitmap;
  3010. + __u8 global_alpha;
  3011. +};
  3012. +
  3013. +/*
  3014. + * C A P T U R E P A R A M E T E R S
  3015. + */
  3016. +struct v4l2_captureparm {
  3017. + __u32 capability; /* Supported modes */
  3018. + __u32 capturemode; /* Current mode */
  3019. + struct v4l2_fract timeperframe; /* Time per frame in .1us units */
  3020. + __u32 extendedmode; /* Driver-specific extensions */
  3021. + __u32 readbuffers; /* # of buffers for read */
  3022. + __u32 reserved[4];
  3023. +};
  3024. +
  3025. +/* Flags for 'capability' and 'capturemode' fields */
  3026. +#define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */
  3027. +#define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */
  3028. +
  3029. +struct v4l2_outputparm {
  3030. + __u32 capability; /* Supported modes */
  3031. + __u32 outputmode; /* Current mode */
  3032. + struct v4l2_fract timeperframe; /* Time per frame in seconds */
  3033. + __u32 extendedmode; /* Driver-specific extensions */
  3034. + __u32 writebuffers; /* # of buffers for write */
  3035. + __u32 reserved[4];
  3036. +};
  3037. +
  3038. +/*
  3039. + * I N P U T I M A G E C R O P P I N G
  3040. + */
  3041. +struct v4l2_cropcap {
  3042. + enum v4l2_buf_type type;
  3043. + struct v4l2_rect bounds;
  3044. + struct v4l2_rect defrect;
  3045. + struct v4l2_fract pixelaspect;
  3046. +};
  3047. +
  3048. +struct v4l2_crop {
  3049. + enum v4l2_buf_type type;
  3050. + struct v4l2_rect c;
  3051. +};
  3052. +
  3053. +/*
  3054. + * A N A L O G V I D E O S T A N D A R D
  3055. + */
  3056. +
  3057. +typedef __u64 v4l2_std_id;
  3058. +
  3059. +/* one bit for each */
  3060. +#define V4L2_STD_PAL_B ((v4l2_std_id)0x00000001)
  3061. +#define V4L2_STD_PAL_B1 ((v4l2_std_id)0x00000002)
  3062. +#define V4L2_STD_PAL_G ((v4l2_std_id)0x00000004)
  3063. +#define V4L2_STD_PAL_H ((v4l2_std_id)0x00000008)
  3064. +#define V4L2_STD_PAL_I ((v4l2_std_id)0x00000010)
  3065. +#define V4L2_STD_PAL_D ((v4l2_std_id)0x00000020)
  3066. +#define V4L2_STD_PAL_D1 ((v4l2_std_id)0x00000040)
  3067. +#define V4L2_STD_PAL_K ((v4l2_std_id)0x00000080)
  3068. +
  3069. +#define V4L2_STD_PAL_M ((v4l2_std_id)0x00000100)
  3070. +#define V4L2_STD_PAL_N ((v4l2_std_id)0x00000200)
  3071. +#define V4L2_STD_PAL_Nc ((v4l2_std_id)0x00000400)
  3072. +#define V4L2_STD_PAL_60 ((v4l2_std_id)0x00000800)
  3073. +
  3074. +#define V4L2_STD_NTSC_M ((v4l2_std_id)0x00001000)
  3075. +#define V4L2_STD_NTSC_M_JP ((v4l2_std_id)0x00002000)
  3076. +#define V4L2_STD_NTSC_443 ((v4l2_std_id)0x00004000)
  3077. +#define V4L2_STD_NTSC_M_KR ((v4l2_std_id)0x00008000)
  3078. +
  3079. +#define V4L2_STD_SECAM_B ((v4l2_std_id)0x00010000)
  3080. +#define V4L2_STD_SECAM_D ((v4l2_std_id)0x00020000)
  3081. +#define V4L2_STD_SECAM_G ((v4l2_std_id)0x00040000)
  3082. +#define V4L2_STD_SECAM_H ((v4l2_std_id)0x00080000)
  3083. +#define V4L2_STD_SECAM_K ((v4l2_std_id)0x00100000)
  3084. +#define V4L2_STD_SECAM_K1 ((v4l2_std_id)0x00200000)
  3085. +#define V4L2_STD_SECAM_L ((v4l2_std_id)0x00400000)
  3086. +#define V4L2_STD_SECAM_LC ((v4l2_std_id)0x00800000)
  3087. +
  3088. +/* ATSC/HDTV */
  3089. +#define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000)
  3090. +#define V4L2_STD_ATSC_16_VSB ((v4l2_std_id)0x02000000)
  3091. +
  3092. +/* FIXME:
  3093. + Although std_id is 64 bits, there is an issue on PPC32 architecture that
  3094. + makes switch(__u64) to break. So, there's a hack on v4l2-common.c rounding
  3095. + this value to 32 bits.
  3096. + As, currently, the max value is for V4L2_STD_ATSC_16_VSB (30 bits wide),
  3097. + it should work fine. However, if needed to add more than two standards,
  3098. + v4l2-common.c should be fixed.
  3099. + */
  3100. +
  3101. +/* some merged standards */
  3102. +#define V4L2_STD_MN (V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC)
  3103. +#define V4L2_STD_B (V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_SECAM_B)
  3104. +#define V4L2_STD_GH (V4L2_STD_PAL_G|V4L2_STD_PAL_H|V4L2_STD_SECAM_G|V4L2_STD_SECAM_H)
  3105. +#define V4L2_STD_DK (V4L2_STD_PAL_DK|V4L2_STD_SECAM_DK)
  3106. +
  3107. +/* some common needed stuff */
  3108. +#define V4L2_STD_PAL_BG (V4L2_STD_PAL_B |\
  3109. + V4L2_STD_PAL_B1 |\
  3110. + V4L2_STD_PAL_G)
  3111. +#define V4L2_STD_PAL_DK (V4L2_STD_PAL_D |\
  3112. + V4L2_STD_PAL_D1 |\
  3113. + V4L2_STD_PAL_K)
  3114. +#define V4L2_STD_PAL (V4L2_STD_PAL_BG |\
  3115. + V4L2_STD_PAL_DK |\
  3116. + V4L2_STD_PAL_H |\
  3117. + V4L2_STD_PAL_I)
  3118. +#define V4L2_STD_NTSC (V4L2_STD_NTSC_M |\
  3119. + V4L2_STD_NTSC_M_JP |\
  3120. + V4L2_STD_NTSC_M_KR)
  3121. +#define V4L2_STD_SECAM_DK (V4L2_STD_SECAM_D |\
  3122. + V4L2_STD_SECAM_K |\
  3123. + V4L2_STD_SECAM_K1)
  3124. +#define V4L2_STD_SECAM (V4L2_STD_SECAM_B |\
  3125. + V4L2_STD_SECAM_G |\
  3126. + V4L2_STD_SECAM_H |\
  3127. + V4L2_STD_SECAM_DK |\
  3128. + V4L2_STD_SECAM_L |\
  3129. + V4L2_STD_SECAM_LC)
  3130. +
  3131. +#define V4L2_STD_525_60 (V4L2_STD_PAL_M |\
  3132. + V4L2_STD_PAL_60 |\
  3133. + V4L2_STD_NTSC |\
  3134. + V4L2_STD_NTSC_443)
  3135. +#define V4L2_STD_625_50 (V4L2_STD_PAL |\
  3136. + V4L2_STD_PAL_N |\
  3137. + V4L2_STD_PAL_Nc |\
  3138. + V4L2_STD_SECAM)
  3139. +#define V4L2_STD_ATSC (V4L2_STD_ATSC_8_VSB |\
  3140. + V4L2_STD_ATSC_16_VSB)
  3141. +
  3142. +#define V4L2_STD_UNKNOWN 0
  3143. +#define V4L2_STD_ALL (V4L2_STD_525_60 |\
  3144. + V4L2_STD_625_50)
  3145. +
  3146. +struct v4l2_standard {
  3147. + __u32 index;
  3148. + v4l2_std_id id;
  3149. + __u8 name[24];
  3150. + struct v4l2_fract frameperiod; /* Frames, not fields */
  3151. + __u32 framelines;
  3152. + __u32 reserved[4];
  3153. +};
  3154. +
  3155. +/*
  3156. + * V I D E O T I M I N G S D V P R E S E T
  3157. + */
  3158. +struct v4l2_dv_preset {
  3159. + __u32 preset;
  3160. + __u32 reserved[4];
  3161. +};
  3162. +
  3163. +/*
  3164. + * D V P R E S E T S E N U M E R A T I O N
  3165. + */
  3166. +struct v4l2_dv_enum_preset {
  3167. + __u32 index;
  3168. + __u32 preset;
  3169. + __u8 name[32]; /* Name of the preset timing */
  3170. + __u32 width;
  3171. + __u32 height;
  3172. + __u32 reserved[4];
  3173. +};
  3174. +
  3175. +/*
  3176. + * D V P R E S E T V A L U E S
  3177. + */
  3178. +#define V4L2_DV_INVALID 0
  3179. +#define V4L2_DV_480P59_94 1 /* BT.1362 */
  3180. +#define V4L2_DV_576P50 2 /* BT.1362 */
  3181. +#define V4L2_DV_720P24 3 /* SMPTE 296M */
  3182. +#define V4L2_DV_720P25 4 /* SMPTE 296M */
  3183. +#define V4L2_DV_720P30 5 /* SMPTE 296M */
  3184. +#define V4L2_DV_720P50 6 /* SMPTE 296M */
  3185. +#define V4L2_DV_720P59_94 7 /* SMPTE 274M */
  3186. +#define V4L2_DV_720P60 8 /* SMPTE 274M/296M */
  3187. +#define V4L2_DV_1080I29_97 9 /* BT.1120/ SMPTE 274M */
  3188. +#define V4L2_DV_1080I30 10 /* BT.1120/ SMPTE 274M */
  3189. +#define V4L2_DV_1080I25 11 /* BT.1120 */
  3190. +#define V4L2_DV_1080I50 12 /* SMPTE 296M */
  3191. +#define V4L2_DV_1080I60 13 /* SMPTE 296M */
  3192. +#define V4L2_DV_1080P24 14 /* SMPTE 296M */
  3193. +#define V4L2_DV_1080P25 15 /* SMPTE 296M */
  3194. +#define V4L2_DV_1080P30 16 /* SMPTE 296M */
  3195. +#define V4L2_DV_1080P50 17 /* BT.1120 */
  3196. +#define V4L2_DV_1080P60 18 /* BT.1120 */
  3197. +
  3198. +/*
  3199. + * D V B T T I M I N G S
  3200. + */
  3201. +
  3202. +/* BT.656/BT.1120 timing data */
  3203. +struct v4l2_bt_timings {
  3204. + __u32 width; /* width in pixels */
  3205. + __u32 height; /* height in lines */
  3206. + __u32 interlaced; /* Interlaced or progressive */
  3207. + __u32 polarities; /* Positive or negative polarity */
  3208. + __u64 pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
  3209. + __u32 hfrontporch; /* Horizpontal front porch in pixels */
  3210. + __u32 hsync; /* Horizontal Sync length in pixels */
  3211. + __u32 hbackporch; /* Horizontal back porch in pixels */
  3212. + __u32 vfrontporch; /* Vertical front porch in pixels */
  3213. + __u32 vsync; /* Vertical Sync length in lines */
  3214. + __u32 vbackporch; /* Vertical back porch in lines */
  3215. + __u32 il_vfrontporch; /* Vertical front porch for bottom field of
  3216. + * interlaced field formats
  3217. + */
  3218. + __u32 il_vsync; /* Vertical sync length for bottom field of
  3219. + * interlaced field formats
  3220. + */
  3221. + __u32 il_vbackporch; /* Vertical back porch for bottom field of
  3222. + * interlaced field formats
  3223. + */
  3224. + __u32 reserved[16];
  3225. +} __attribute__ ((packed));
  3226. +
  3227. +/* Interlaced or progressive format */
  3228. +#define V4L2_DV_PROGRESSIVE 0
  3229. +#define V4L2_DV_INTERLACED 1
  3230. +
  3231. +/* Polarities. If bit is not set, it is assumed to be negative polarity */
  3232. +#define V4L2_DV_VSYNC_POS_POL 0x00000001
  3233. +#define V4L2_DV_HSYNC_POS_POL 0x00000002
  3234. +
  3235. +
  3236. +/* DV timings */
  3237. +struct v4l2_dv_timings {
  3238. + __u32 type;
  3239. + union {
  3240. + struct v4l2_bt_timings bt;
  3241. + __u32 reserved[32];
  3242. + };
  3243. +} __attribute__ ((packed));
  3244. +
  3245. +/* Values for the type field */
  3246. +#define V4L2_DV_BT_656_1120 0 /* BT.656/1120 timing type */
  3247. +
  3248. +/*
  3249. + * V I D E O I N P U T S
  3250. + */
  3251. +struct v4l2_input {
  3252. + __u32 index; /* Which input */
  3253. + __u8 name[32]; /* Label */
  3254. + __u32 type; /* Type of input */
  3255. + __u32 audioset; /* Associated audios (bitfield) */
  3256. + __u32 tuner; /* Associated tuner */
  3257. + v4l2_std_id std;
  3258. + __u32 status;
  3259. + __u32 capabilities;
  3260. + __u32 reserved[3];
  3261. +};
  3262. +
  3263. +/* Values for the 'type' field */
  3264. +#define V4L2_INPUT_TYPE_TUNER 1
  3265. +#define V4L2_INPUT_TYPE_CAMERA 2
  3266. +
  3267. +/* field 'status' - general */
  3268. +#define V4L2_IN_ST_NO_POWER 0x00000001 /* Attached device is off */
  3269. +#define V4L2_IN_ST_NO_SIGNAL 0x00000002
  3270. +#define V4L2_IN_ST_NO_COLOR 0x00000004
  3271. +
  3272. +/* field 'status' - sensor orientation */
  3273. +/* If sensor is mounted upside down set both bits */
  3274. +#define V4L2_IN_ST_HFLIP 0x00000010 /* Frames are flipped horizontally */
  3275. +#define V4L2_IN_ST_VFLIP 0x00000020 /* Frames are flipped vertically */
  3276. +
  3277. +/* field 'status' - analog */
  3278. +#define V4L2_IN_ST_NO_H_LOCK 0x00000100 /* No horizontal sync lock */
  3279. +#define V4L2_IN_ST_COLOR_KILL 0x00000200 /* Color killer is active */
  3280. +
  3281. +/* field 'status' - digital */
  3282. +#define V4L2_IN_ST_NO_SYNC 0x00010000 /* No synchronization lock */
  3283. +#define V4L2_IN_ST_NO_EQU 0x00020000 /* No equalizer lock */
  3284. +#define V4L2_IN_ST_NO_CARRIER 0x00040000 /* Carrier recovery failed */
  3285. +
  3286. +/* field 'status' - VCR and set-top box */
  3287. +#define V4L2_IN_ST_MACROVISION 0x01000000 /* Macrovision detected */
  3288. +#define V4L2_IN_ST_NO_ACCESS 0x02000000 /* Conditional access denied */
  3289. +#define V4L2_IN_ST_VTR 0x04000000 /* VTR time constant */
  3290. +
  3291. +/* capabilities flags */
  3292. +#define V4L2_IN_CAP_PRESETS 0x00000001 /* Supports S_DV_PRESET */
  3293. +#define V4L2_IN_CAP_CUSTOM_TIMINGS 0x00000002 /* Supports S_DV_TIMINGS */
  3294. +#define V4L2_IN_CAP_STD 0x00000004 /* Supports S_STD */
  3295. +
  3296. +/*
  3297. + * V I D E O O U T P U T S
  3298. + */
  3299. +struct v4l2_output {
  3300. + __u32 index; /* Which output */
  3301. + __u8 name[32]; /* Label */
  3302. + __u32 type; /* Type of output */
  3303. + __u32 audioset; /* Associated audios (bitfield) */
  3304. + __u32 modulator; /* Associated modulator */
  3305. + v4l2_std_id std;
  3306. + __u32 capabilities;
  3307. + __u32 reserved[3];
  3308. +};
  3309. +/* Values for the 'type' field */
  3310. +#define V4L2_OUTPUT_TYPE_MODULATOR 1
  3311. +#define V4L2_OUTPUT_TYPE_ANALOG 2
  3312. +#define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3
  3313. +
  3314. +/* capabilities flags */
  3315. +#define V4L2_OUT_CAP_PRESETS 0x00000001 /* Supports S_DV_PRESET */
  3316. +#define V4L2_OUT_CAP_CUSTOM_TIMINGS 0x00000002 /* Supports S_DV_TIMINGS */
  3317. +#define V4L2_OUT_CAP_STD 0x00000004 /* Supports S_STD */
  3318. +
  3319. +/*
  3320. + * C O N T R O L S
  3321. + */
  3322. +struct v4l2_control {
  3323. + __u32 id;
  3324. + __s32 value;
  3325. +};
  3326. +
  3327. +struct v4l2_ext_control {
  3328. + __u32 id;
  3329. + __u32 size;
  3330. + __u32 reserved2[1];
  3331. + union {
  3332. + __s32 value;
  3333. + __s64 value64;
  3334. + char *string;
  3335. + };
  3336. +} __attribute__ ((packed));
  3337. +
  3338. +struct v4l2_ext_controls {
  3339. + __u32 ctrl_class;
  3340. + __u32 count;
  3341. + __u32 error_idx;
  3342. + __u32 reserved[2];
  3343. + struct v4l2_ext_control *controls;
  3344. +};
  3345. +
  3346. +/* Values for ctrl_class field */
  3347. +#define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */
  3348. +#define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */
  3349. +#define V4L2_CTRL_CLASS_CAMERA 0x009a0000 /* Camera class controls */
  3350. +#define V4L2_CTRL_CLASS_FM_TX 0x009b0000 /* FM Modulator control class */
  3351. +
  3352. +#define V4L2_CTRL_ID_MASK (0x0fffffff)
  3353. +#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL)
  3354. +#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000)
  3355. +
  3356. +enum v4l2_ctrl_type {
  3357. + V4L2_CTRL_TYPE_INTEGER = 1,
  3358. + V4L2_CTRL_TYPE_BOOLEAN = 2,
  3359. + V4L2_CTRL_TYPE_MENU = 3,
  3360. + V4L2_CTRL_TYPE_BUTTON = 4,
  3361. + V4L2_CTRL_TYPE_INTEGER64 = 5,
  3362. + V4L2_CTRL_TYPE_CTRL_CLASS = 6,
  3363. + V4L2_CTRL_TYPE_STRING = 7,
  3364. +};
  3365. +
  3366. +/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
  3367. +struct v4l2_queryctrl {
  3368. + __u32 id;
  3369. + enum v4l2_ctrl_type type;
  3370. + __u8 name[32]; /* Whatever */
  3371. + __s32 minimum; /* Note signedness */
  3372. + __s32 maximum;
  3373. + __s32 step;
  3374. + __s32 default_value;
  3375. + __u32 flags;
  3376. + __u32 reserved[2];
  3377. +};
  3378. +
  3379. +/* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */
  3380. +struct v4l2_querymenu {
  3381. + __u32 id;
  3382. + __u32 index;
  3383. + __u8 name[32]; /* Whatever */
  3384. + __u32 reserved;
  3385. +};
  3386. +
  3387. +/* Control flags */
  3388. +#define V4L2_CTRL_FLAG_DISABLED 0x0001
  3389. +#define V4L2_CTRL_FLAG_GRABBED 0x0002
  3390. +#define V4L2_CTRL_FLAG_READ_ONLY 0x0004
  3391. +#define V4L2_CTRL_FLAG_UPDATE 0x0008
  3392. +#define V4L2_CTRL_FLAG_INACTIVE 0x0010
  3393. +#define V4L2_CTRL_FLAG_SLIDER 0x0020
  3394. +#define V4L2_CTRL_FLAG_WRITE_ONLY 0x0040
  3395. +
  3396. +/* Query flag, to be ORed with the control ID */
  3397. +#define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000
  3398. +
  3399. +/* User-class control IDs defined by V4L2 */
  3400. +#define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900)
  3401. +#define V4L2_CID_USER_BASE V4L2_CID_BASE
  3402. +/* IDs reserved for driver specific controls */
  3403. +#define V4L2_CID_PRIVATE_BASE 0x08000000
  3404. +
  3405. +#define V4L2_CID_USER_CLASS (V4L2_CTRL_CLASS_USER | 1)
  3406. +#define V4L2_CID_BRIGHTNESS (V4L2_CID_BASE+0)
  3407. +#define V4L2_CID_CONTRAST (V4L2_CID_BASE+1)
  3408. +#define V4L2_CID_SATURATION (V4L2_CID_BASE+2)
  3409. +#define V4L2_CID_HUE (V4L2_CID_BASE+3)
  3410. +#define V4L2_CID_AUDIO_VOLUME (V4L2_CID_BASE+5)
  3411. +#define V4L2_CID_AUDIO_BALANCE (V4L2_CID_BASE+6)
  3412. +#define V4L2_CID_AUDIO_BASS (V4L2_CID_BASE+7)
  3413. +#define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8)
  3414. +#define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9)
  3415. +#define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10)
  3416. +#define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11) /* Deprecated */
  3417. +#define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12)
  3418. +#define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13)
  3419. +#define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14)
  3420. +#define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15)
  3421. +#define V4L2_CID_GAMMA (V4L2_CID_BASE+16)
  3422. +#define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* Deprecated */
  3423. +#define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17)
  3424. +#define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18)
  3425. +#define V4L2_CID_GAIN (V4L2_CID_BASE+19)
  3426. +#define V4L2_CID_HFLIP (V4L2_CID_BASE+20)
  3427. +#define V4L2_CID_VFLIP (V4L2_CID_BASE+21)
  3428. +
  3429. +/* Deprecated; use V4L2_CID_PAN_RESET and V4L2_CID_TILT_RESET */
  3430. +#define V4L2_CID_HCENTER (V4L2_CID_BASE+22)
  3431. +#define V4L2_CID_VCENTER (V4L2_CID_BASE+23)
  3432. +
  3433. +#define V4L2_CID_POWER_LINE_FREQUENCY (V4L2_CID_BASE+24)
  3434. +enum v4l2_power_line_frequency {
  3435. + V4L2_CID_POWER_LINE_FREQUENCY_DISABLED = 0,
  3436. + V4L2_CID_POWER_LINE_FREQUENCY_50HZ = 1,
  3437. + V4L2_CID_POWER_LINE_FREQUENCY_60HZ = 2,
  3438. +};
  3439. +#define V4L2_CID_HUE_AUTO (V4L2_CID_BASE+25)
  3440. +#define V4L2_CID_WHITE_BALANCE_TEMPERATURE (V4L2_CID_BASE+26)
  3441. +#define V4L2_CID_SHARPNESS (V4L2_CID_BASE+27)
  3442. +#define V4L2_CID_BACKLIGHT_COMPENSATION (V4L2_CID_BASE+28)
  3443. +#define V4L2_CID_CHROMA_AGC (V4L2_CID_BASE+29)
  3444. +#define V4L2_CID_COLOR_KILLER (V4L2_CID_BASE+30)
  3445. +#define V4L2_CID_COLORFX (V4L2_CID_BASE+31)
  3446. +enum v4l2_colorfx {
  3447. + V4L2_COLORFX_NONE = 0,
  3448. + V4L2_COLORFX_BW = 1,
  3449. + V4L2_COLORFX_SEPIA = 2,
  3450. + V4L2_COLORFX_NEGATIVE = 3,
  3451. + V4L2_COLORFX_EMBOSS = 4,
  3452. + V4L2_COLORFX_SKETCH = 5,
  3453. + V4L2_COLORFX_SKY_BLUE = 6,
  3454. + V4L2_COLORFX_GRASS_GREEN = 7,
  3455. + V4L2_COLORFX_SKIN_WHITEN = 8,
  3456. + V4L2_COLORFX_VIVID = 9,
  3457. +};
  3458. +#define V4L2_CID_AUTOBRIGHTNESS (V4L2_CID_BASE+32)
  3459. +#define V4L2_CID_BAND_STOP_FILTER (V4L2_CID_BASE+33)
  3460. +
  3461. +#define V4L2_CID_ROTATE (V4L2_CID_BASE+34)
  3462. +#define V4L2_CID_BG_COLOR (V4L2_CID_BASE+35)
  3463. +
  3464. +#define V4L2_CID_CHROMA_GAIN (V4L2_CID_BASE+36)
  3465. +
  3466. +#define V4L2_CID_ILLUMINATORS_1 (V4L2_CID_BASE+37)
  3467. +#define V4L2_CID_ILLUMINATORS_2 (V4L2_CID_BASE+38)
  3468. +
  3469. +/* last CID + 1 */
  3470. +#define V4L2_CID_LASTP1 (V4L2_CID_BASE+39)
  3471. +
  3472. +/* MPEG-class control IDs defined by V4L2 */
  3473. +#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900)
  3474. +#define V4L2_CID_MPEG_CLASS (V4L2_CTRL_CLASS_MPEG | 1)
  3475. +
  3476. +/* MPEG streams */
  3477. +#define V4L2_CID_MPEG_STREAM_TYPE (V4L2_CID_MPEG_BASE+0)
  3478. +enum v4l2_mpeg_stream_type {
  3479. + V4L2_MPEG_STREAM_TYPE_MPEG2_PS = 0, /* MPEG-2 program stream */
  3480. + V4L2_MPEG_STREAM_TYPE_MPEG2_TS = 1, /* MPEG-2 transport stream */
  3481. + V4L2_MPEG_STREAM_TYPE_MPEG1_SS = 2, /* MPEG-1 system stream */
  3482. + V4L2_MPEG_STREAM_TYPE_MPEG2_DVD = 3, /* MPEG-2 DVD-compatible stream */
  3483. + V4L2_MPEG_STREAM_TYPE_MPEG1_VCD = 4, /* MPEG-1 VCD-compatible stream */
  3484. + V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD = 5, /* MPEG-2 SVCD-compatible stream */
  3485. +};
  3486. +#define V4L2_CID_MPEG_STREAM_PID_PMT (V4L2_CID_MPEG_BASE+1)
  3487. +#define V4L2_CID_MPEG_STREAM_PID_AUDIO (V4L2_CID_MPEG_BASE+2)
  3488. +#define V4L2_CID_MPEG_STREAM_PID_VIDEO (V4L2_CID_MPEG_BASE+3)
  3489. +#define V4L2_CID_MPEG_STREAM_PID_PCR (V4L2_CID_MPEG_BASE+4)
  3490. +#define V4L2_CID_MPEG_STREAM_PES_ID_AUDIO (V4L2_CID_MPEG_BASE+5)
  3491. +#define V4L2_CID_MPEG_STREAM_PES_ID_VIDEO (V4L2_CID_MPEG_BASE+6)
  3492. +#define V4L2_CID_MPEG_STREAM_VBI_FMT (V4L2_CID_MPEG_BASE+7)
  3493. +enum v4l2_mpeg_stream_vbi_fmt {
  3494. + V4L2_MPEG_STREAM_VBI_FMT_NONE = 0, /* No VBI in the MPEG stream */
  3495. + V4L2_MPEG_STREAM_VBI_FMT_IVTV = 1, /* VBI in private packets, IVTV format */
  3496. +};
  3497. +
  3498. +/* MPEG audio */
  3499. +#define V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ (V4L2_CID_MPEG_BASE+100)
  3500. +enum v4l2_mpeg_audio_sampling_freq {
  3501. + V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100 = 0,
  3502. + V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000 = 1,
  3503. + V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000 = 2,
  3504. +};
  3505. +#define V4L2_CID_MPEG_AUDIO_ENCODING (V4L2_CID_MPEG_BASE+101)
  3506. +enum v4l2_mpeg_audio_encoding {
  3507. + V4L2_MPEG_AUDIO_ENCODING_LAYER_1 = 0,
  3508. + V4L2_MPEG_AUDIO_ENCODING_LAYER_2 = 1,
  3509. + V4L2_MPEG_AUDIO_ENCODING_LAYER_3 = 2,
  3510. + V4L2_MPEG_AUDIO_ENCODING_AAC = 3,
  3511. + V4L2_MPEG_AUDIO_ENCODING_AC3 = 4,
  3512. +};
  3513. +#define V4L2_CID_MPEG_AUDIO_L1_BITRATE (V4L2_CID_MPEG_BASE+102)
  3514. +enum v4l2_mpeg_audio_l1_bitrate {
  3515. + V4L2_MPEG_AUDIO_L1_BITRATE_32K = 0,
  3516. + V4L2_MPEG_AUDIO_L1_BITRATE_64K = 1,
  3517. + V4L2_MPEG_AUDIO_L1_BITRATE_96K = 2,
  3518. + V4L2_MPEG_AUDIO_L1_BITRATE_128K = 3,
  3519. + V4L2_MPEG_AUDIO_L1_BITRATE_160K = 4,
  3520. + V4L2_MPEG_AUDIO_L1_BITRATE_192K = 5,
  3521. + V4L2_MPEG_AUDIO_L1_BITRATE_224K = 6,
  3522. + V4L2_MPEG_AUDIO_L1_BITRATE_256K = 7,
  3523. + V4L2_MPEG_AUDIO_L1_BITRATE_288K = 8,
  3524. + V4L2_MPEG_AUDIO_L1_BITRATE_320K = 9,
  3525. + V4L2_MPEG_AUDIO_L1_BITRATE_352K = 10,
  3526. + V4L2_MPEG_AUDIO_L1_BITRATE_384K = 11,
  3527. + V4L2_MPEG_AUDIO_L1_BITRATE_416K = 12,
  3528. + V4L2_MPEG_AUDIO_L1_BITRATE_448K = 13,
  3529. +};
  3530. +#define V4L2_CID_MPEG_AUDIO_L2_BITRATE (V4L2_CID_MPEG_BASE+103)
  3531. +enum v4l2_mpeg_audio_l2_bitrate {
  3532. + V4L2_MPEG_AUDIO_L2_BITRATE_32K = 0,
  3533. + V4L2_MPEG_AUDIO_L2_BITRATE_48K = 1,
  3534. + V4L2_MPEG_AUDIO_L2_BITRATE_56K = 2,
  3535. + V4L2_MPEG_AUDIO_L2_BITRATE_64K = 3,
  3536. + V4L2_MPEG_AUDIO_L2_BITRATE_80K = 4,
  3537. + V4L2_MPEG_AUDIO_L2_BITRATE_96K = 5,
  3538. + V4L2_MPEG_AUDIO_L2_BITRATE_112K = 6,
  3539. + V4L2_MPEG_AUDIO_L2_BITRATE_128K = 7,
  3540. + V4L2_MPEG_AUDIO_L2_BITRATE_160K = 8,
  3541. + V4L2_MPEG_AUDIO_L2_BITRATE_192K = 9,
  3542. + V4L2_MPEG_AUDIO_L2_BITRATE_224K = 10,
  3543. + V4L2_MPEG_AUDIO_L2_BITRATE_256K = 11,
  3544. + V4L2_MPEG_AUDIO_L2_BITRATE_320K = 12,
  3545. + V4L2_MPEG_AUDIO_L2_BITRATE_384K = 13,
  3546. +};
  3547. +#define V4L2_CID_MPEG_AUDIO_L3_BITRATE (V4L2_CID_MPEG_BASE+104)
  3548. +enum v4l2_mpeg_audio_l3_bitrate {
  3549. + V4L2_MPEG_AUDIO_L3_BITRATE_32K = 0,
  3550. + V4L2_MPEG_AUDIO_L3_BITRATE_40K = 1,
  3551. + V4L2_MPEG_AUDIO_L3_BITRATE_48K = 2,
  3552. + V4L2_MPEG_AUDIO_L3_BITRATE_56K = 3,
  3553. + V4L2_MPEG_AUDIO_L3_BITRATE_64K = 4,
  3554. + V4L2_MPEG_AUDIO_L3_BITRATE_80K = 5,
  3555. + V4L2_MPEG_AUDIO_L3_BITRATE_96K = 6,
  3556. + V4L2_MPEG_AUDIO_L3_BITRATE_112K = 7,
  3557. + V4L2_MPEG_AUDIO_L3_BITRATE_128K = 8,
  3558. + V4L2_MPEG_AUDIO_L3_BITRATE_160K = 9,
  3559. + V4L2_MPEG_AUDIO_L3_BITRATE_192K = 10,
  3560. + V4L2_MPEG_AUDIO_L3_BITRATE_224K = 11,
  3561. + V4L2_MPEG_AUDIO_L3_BITRATE_256K = 12,
  3562. + V4L2_MPEG_AUDIO_L3_BITRATE_320K = 13,
  3563. +};
  3564. +#define V4L2_CID_MPEG_AUDIO_MODE (V4L2_CID_MPEG_BASE+105)
  3565. +enum v4l2_mpeg_audio_mode {
  3566. + V4L2_MPEG_AUDIO_MODE_STEREO = 0,
  3567. + V4L2_MPEG_AUDIO_MODE_JOINT_STEREO = 1,
  3568. + V4L2_MPEG_AUDIO_MODE_DUAL = 2,
  3569. + V4L2_MPEG_AUDIO_MODE_MONO = 3,
  3570. +};
  3571. +#define V4L2_CID_MPEG_AUDIO_MODE_EXTENSION (V4L2_CID_MPEG_BASE+106)
  3572. +enum v4l2_mpeg_audio_mode_extension {
  3573. + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4 = 0,
  3574. + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_8 = 1,
  3575. + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_12 = 2,
  3576. + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_16 = 3,
  3577. +};
  3578. +#define V4L2_CID_MPEG_AUDIO_EMPHASIS (V4L2_CID_MPEG_BASE+107)
  3579. +enum v4l2_mpeg_audio_emphasis {
  3580. + V4L2_MPEG_AUDIO_EMPHASIS_NONE = 0,
  3581. + V4L2_MPEG_AUDIO_EMPHASIS_50_DIV_15_uS = 1,
  3582. + V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17 = 2,
  3583. +};
  3584. +#define V4L2_CID_MPEG_AUDIO_CRC (V4L2_CID_MPEG_BASE+108)
  3585. +enum v4l2_mpeg_audio_crc {
  3586. + V4L2_MPEG_AUDIO_CRC_NONE = 0,
  3587. + V4L2_MPEG_AUDIO_CRC_CRC16 = 1,
  3588. +};
  3589. +#define V4L2_CID_MPEG_AUDIO_MUTE (V4L2_CID_MPEG_BASE+109)
  3590. +#define V4L2_CID_MPEG_AUDIO_AAC_BITRATE (V4L2_CID_MPEG_BASE+110)
  3591. +#define V4L2_CID_MPEG_AUDIO_AC3_BITRATE (V4L2_CID_MPEG_BASE+111)
  3592. +enum v4l2_mpeg_audio_ac3_bitrate {
  3593. + V4L2_MPEG_AUDIO_AC3_BITRATE_32K = 0,
  3594. + V4L2_MPEG_AUDIO_AC3_BITRATE_40K = 1,
  3595. + V4L2_MPEG_AUDIO_AC3_BITRATE_48K = 2,
  3596. + V4L2_MPEG_AUDIO_AC3_BITRATE_56K = 3,
  3597. + V4L2_MPEG_AUDIO_AC3_BITRATE_64K = 4,
  3598. + V4L2_MPEG_AUDIO_AC3_BITRATE_80K = 5,
  3599. + V4L2_MPEG_AUDIO_AC3_BITRATE_96K = 6,
  3600. + V4L2_MPEG_AUDIO_AC3_BITRATE_112K = 7,
  3601. + V4L2_MPEG_AUDIO_AC3_BITRATE_128K = 8,
  3602. + V4L2_MPEG_AUDIO_AC3_BITRATE_160K = 9,
  3603. + V4L2_MPEG_AUDIO_AC3_BITRATE_192K = 10,
  3604. + V4L2_MPEG_AUDIO_AC3_BITRATE_224K = 11,
  3605. + V4L2_MPEG_AUDIO_AC3_BITRATE_256K = 12,
  3606. + V4L2_MPEG_AUDIO_AC3_BITRATE_320K = 13,
  3607. + V4L2_MPEG_AUDIO_AC3_BITRATE_384K = 14,
  3608. + V4L2_MPEG_AUDIO_AC3_BITRATE_448K = 15,
  3609. + V4L2_MPEG_AUDIO_AC3_BITRATE_512K = 16,
  3610. + V4L2_MPEG_AUDIO_AC3_BITRATE_576K = 17,
  3611. + V4L2_MPEG_AUDIO_AC3_BITRATE_640K = 18,
  3612. +};
  3613. +
  3614. +/* MPEG video */
  3615. +#define V4L2_CID_MPEG_VIDEO_ENCODING (V4L2_CID_MPEG_BASE+200)
  3616. +enum v4l2_mpeg_video_encoding {
  3617. + V4L2_MPEG_VIDEO_ENCODING_MPEG_1 = 0,
  3618. + V4L2_MPEG_VIDEO_ENCODING_MPEG_2 = 1,
  3619. + V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVC = 2,
  3620. +};
  3621. +#define V4L2_CID_MPEG_VIDEO_ASPECT (V4L2_CID_MPEG_BASE+201)
  3622. +enum v4l2_mpeg_video_aspect {
  3623. + V4L2_MPEG_VIDEO_ASPECT_1x1 = 0,
  3624. + V4L2_MPEG_VIDEO_ASPECT_4x3 = 1,
  3625. + V4L2_MPEG_VIDEO_ASPECT_16x9 = 2,
  3626. + V4L2_MPEG_VIDEO_ASPECT_221x100 = 3,
  3627. +};
  3628. +#define V4L2_CID_MPEG_VIDEO_B_FRAMES (V4L2_CID_MPEG_BASE+202)
  3629. +#define V4L2_CID_MPEG_VIDEO_GOP_SIZE (V4L2_CID_MPEG_BASE+203)
  3630. +#define V4L2_CID_MPEG_VIDEO_GOP_CLOSURE (V4L2_CID_MPEG_BASE+204)
  3631. +#define V4L2_CID_MPEG_VIDEO_PULLDOWN (V4L2_CID_MPEG_BASE+205)
  3632. +#define V4L2_CID_MPEG_VIDEO_BITRATE_MODE (V4L2_CID_MPEG_BASE+206)
  3633. +enum v4l2_mpeg_video_bitrate_mode {
  3634. + V4L2_MPEG_VIDEO_BITRATE_MODE_VBR = 0,
  3635. + V4L2_MPEG_VIDEO_BITRATE_MODE_CBR = 1,
  3636. +};
  3637. +#define V4L2_CID_MPEG_VIDEO_BITRATE (V4L2_CID_MPEG_BASE+207)
  3638. +#define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK (V4L2_CID_MPEG_BASE+208)
  3639. +#define V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION (V4L2_CID_MPEG_BASE+209)
  3640. +#define V4L2_CID_MPEG_VIDEO_MUTE (V4L2_CID_MPEG_BASE+210)
  3641. +#define V4L2_CID_MPEG_VIDEO_MUTE_YUV (V4L2_CID_MPEG_BASE+211)
  3642. +
  3643. +/* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */
  3644. +#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000)
  3645. +#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0)
  3646. +enum v4l2_mpeg_cx2341x_video_spatial_filter_mode {
  3647. + V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL = 0,
  3648. + V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO = 1,
  3649. +};
  3650. +#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+1)
  3651. +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+2)
  3652. +enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type {
  3653. + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF = 0,
  3654. + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR = 1,
  3655. + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_VERT = 2,
  3656. + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_HV_SEPARABLE = 3,
  3657. + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_SYM_NON_SEPARABLE = 4,
  3658. +};
  3659. +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+3)
  3660. +enum v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type {
  3661. + V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF = 0,
  3662. + V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR = 1,
  3663. +};
  3664. +#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+4)
  3665. +enum v4l2_mpeg_cx2341x_video_temporal_filter_mode {
  3666. + V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL = 0,
  3667. + V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO = 1,
  3668. +};
  3669. +#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+5)
  3670. +#define V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+6)
  3671. +enum v4l2_mpeg_cx2341x_video_median_filter_type {
  3672. + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF = 0,
  3673. + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR = 1,
  3674. + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_VERT = 2,
  3675. + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR_VERT = 3,
  3676. + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG = 4,
  3677. +};
  3678. +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+7)
  3679. +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+8)
  3680. +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+9)
  3681. +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10)
  3682. +#define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (V4L2_CID_MPEG_CX2341X_BASE+11)
  3683. +
  3684. +/* Camera class control IDs */
  3685. +#define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x900)
  3686. +#define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1)
  3687. +
  3688. +#define V4L2_CID_EXPOSURE_AUTO (V4L2_CID_CAMERA_CLASS_BASE+1)
  3689. +enum v4l2_exposure_auto_type {
  3690. + V4L2_EXPOSURE_AUTO = 0,
  3691. + V4L2_EXPOSURE_MANUAL = 1,
  3692. + V4L2_EXPOSURE_SHUTTER_PRIORITY = 2,
  3693. + V4L2_EXPOSURE_APERTURE_PRIORITY = 3
  3694. +};
  3695. +#define V4L2_CID_EXPOSURE_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+2)
  3696. +#define V4L2_CID_EXPOSURE_AUTO_PRIORITY (V4L2_CID_CAMERA_CLASS_BASE+3)
  3697. +
  3698. +#define V4L2_CID_PAN_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+4)
  3699. +#define V4L2_CID_TILT_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+5)
  3700. +#define V4L2_CID_PAN_RESET (V4L2_CID_CAMERA_CLASS_BASE+6)
  3701. +#define V4L2_CID_TILT_RESET (V4L2_CID_CAMERA_CLASS_BASE+7)
  3702. +
  3703. +#define V4L2_CID_PAN_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+8)
  3704. +#define V4L2_CID_TILT_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+9)
  3705. +
  3706. +#define V4L2_CID_FOCUS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+10)
  3707. +#define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+11)
  3708. +#define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE+12)
  3709. +
  3710. +#define V4L2_CID_ZOOM_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+13)
  3711. +#define V4L2_CID_ZOOM_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+14)
  3712. +#define V4L2_CID_ZOOM_CONTINUOUS (V4L2_CID_CAMERA_CLASS_BASE+15)
  3713. +
  3714. +#define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16)
  3715. +
  3716. +#define V4L2_CID_IRIS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+17)
  3717. +#define V4L2_CID_IRIS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+18)
  3718. +
  3719. +/* FM Modulator class control IDs */
  3720. +#define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900)
  3721. +#define V4L2_CID_FM_TX_CLASS (V4L2_CTRL_CLASS_FM_TX | 1)
  3722. +
  3723. +#define V4L2_CID_RDS_TX_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 1)
  3724. +#define V4L2_CID_RDS_TX_PI (V4L2_CID_FM_TX_CLASS_BASE + 2)
  3725. +#define V4L2_CID_RDS_TX_PTY (V4L2_CID_FM_TX_CLASS_BASE + 3)
  3726. +#define V4L2_CID_RDS_TX_PS_NAME (V4L2_CID_FM_TX_CLASS_BASE + 5)
  3727. +#define V4L2_CID_RDS_TX_RADIO_TEXT (V4L2_CID_FM_TX_CLASS_BASE + 6)
  3728. +
  3729. +#define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 64)
  3730. +#define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME (V4L2_CID_FM_TX_CLASS_BASE + 65)
  3731. +#define V4L2_CID_AUDIO_LIMITER_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 66)
  3732. +
  3733. +#define V4L2_CID_AUDIO_COMPRESSION_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 80)
  3734. +#define V4L2_CID_AUDIO_COMPRESSION_GAIN (V4L2_CID_FM_TX_CLASS_BASE + 81)
  3735. +#define V4L2_CID_AUDIO_COMPRESSION_THRESHOLD (V4L2_CID_FM_TX_CLASS_BASE + 82)
  3736. +#define V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME (V4L2_CID_FM_TX_CLASS_BASE + 83)
  3737. +#define V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME (V4L2_CID_FM_TX_CLASS_BASE + 84)
  3738. +
  3739. +#define V4L2_CID_PILOT_TONE_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 96)
  3740. +#define V4L2_CID_PILOT_TONE_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 97)
  3741. +#define V4L2_CID_PILOT_TONE_FREQUENCY (V4L2_CID_FM_TX_CLASS_BASE + 98)
  3742. +
  3743. +#define V4L2_CID_TUNE_PREEMPHASIS (V4L2_CID_FM_TX_CLASS_BASE + 112)
  3744. +enum v4l2_preemphasis {
  3745. + V4L2_PREEMPHASIS_DISABLED = 0,
  3746. + V4L2_PREEMPHASIS_50_uS = 1,
  3747. + V4L2_PREEMPHASIS_75_uS = 2,
  3748. +};
  3749. +#define V4L2_CID_TUNE_POWER_LEVEL (V4L2_CID_FM_TX_CLASS_BASE + 113)
  3750. +#define V4L2_CID_TUNE_ANTENNA_CAPACITOR (V4L2_CID_FM_TX_CLASS_BASE + 114)
  3751. +
  3752. +/*
  3753. + * T U N I N G
  3754. + */
  3755. +struct v4l2_tuner {
  3756. + __u32 index;
  3757. + __u8 name[32];
  3758. + enum v4l2_tuner_type type;
  3759. + __u32 capability;
  3760. + __u32 rangelow;
  3761. + __u32 rangehigh;
  3762. + __u32 rxsubchans;
  3763. + __u32 audmode;
  3764. + __s32 signal;
  3765. + __s32 afc;
  3766. + __u32 reserved[4];
  3767. +};
  3768. +
  3769. +struct v4l2_modulator {
  3770. + __u32 index;
  3771. + __u8 name[32];
  3772. + __u32 capability;
  3773. + __u32 rangelow;
  3774. + __u32 rangehigh;
  3775. + __u32 txsubchans;
  3776. + __u32 reserved[4];
  3777. +};
  3778. +
  3779. +/* Flags for the 'capability' field */
  3780. +#define V4L2_TUNER_CAP_LOW 0x0001
  3781. +#define V4L2_TUNER_CAP_NORM 0x0002
  3782. +#define V4L2_TUNER_CAP_STEREO 0x0010
  3783. +#define V4L2_TUNER_CAP_LANG2 0x0020
  3784. +#define V4L2_TUNER_CAP_SAP 0x0020
  3785. +#define V4L2_TUNER_CAP_LANG1 0x0040
  3786. +#define V4L2_TUNER_CAP_RDS 0x0080
  3787. +#define V4L2_TUNER_CAP_RDS_BLOCK_IO 0x0100
  3788. +#define V4L2_TUNER_CAP_RDS_CONTROLS 0x0200
  3789. +
  3790. +/* Flags for the 'rxsubchans' field */
  3791. +#define V4L2_TUNER_SUB_MONO 0x0001
  3792. +#define V4L2_TUNER_SUB_STEREO 0x0002
  3793. +#define V4L2_TUNER_SUB_LANG2 0x0004
  3794. +#define V4L2_TUNER_SUB_SAP 0x0004
  3795. +#define V4L2_TUNER_SUB_LANG1 0x0008
  3796. +#define V4L2_TUNER_SUB_RDS 0x0010
  3797. +
  3798. +/* Values for the 'audmode' field */
  3799. +#define V4L2_TUNER_MODE_MONO 0x0000
  3800. +#define V4L2_TUNER_MODE_STEREO 0x0001
  3801. +#define V4L2_TUNER_MODE_LANG2 0x0002
  3802. +#define V4L2_TUNER_MODE_SAP 0x0002
  3803. +#define V4L2_TUNER_MODE_LANG1 0x0003
  3804. +#define V4L2_TUNER_MODE_LANG1_LANG2 0x0004
  3805. +
  3806. +struct v4l2_frequency {
  3807. + __u32 tuner;
  3808. + enum v4l2_tuner_type type;
  3809. + __u32 frequency;
  3810. + __u32 reserved[8];
  3811. +};
  3812. +
  3813. +struct v4l2_hw_freq_seek {
  3814. + __u32 tuner;
  3815. + enum v4l2_tuner_type type;
  3816. + __u32 seek_upward;
  3817. + __u32 wrap_around;
  3818. + __u32 spacing;
  3819. + __u32 reserved[7];
  3820. +};
  3821. +
  3822. +/*
  3823. + * R D S
  3824. + */
  3825. +
  3826. +struct v4l2_rds_data {
  3827. + __u8 lsb;
  3828. + __u8 msb;
  3829. + __u8 block;
  3830. +} __attribute__ ((packed));
  3831. +
  3832. +#define V4L2_RDS_BLOCK_MSK 0x7
  3833. +#define V4L2_RDS_BLOCK_A 0
  3834. +#define V4L2_RDS_BLOCK_B 1
  3835. +#define V4L2_RDS_BLOCK_C 2
  3836. +#define V4L2_RDS_BLOCK_D 3
  3837. +#define V4L2_RDS_BLOCK_C_ALT 4
  3838. +#define V4L2_RDS_BLOCK_INVALID 7
  3839. +
  3840. +#define V4L2_RDS_BLOCK_CORRECTED 0x40
  3841. +#define V4L2_RDS_BLOCK_ERROR 0x80
  3842. +
  3843. +/*
  3844. + * A U D I O
  3845. + */
  3846. +struct v4l2_audio {
  3847. + __u32 index;
  3848. + __u8 name[32];
  3849. + __u32 capability;
  3850. + __u32 mode;
  3851. + __u32 reserved[2];
  3852. +};
  3853. +
  3854. +/* Flags for the 'capability' field */
  3855. +#define V4L2_AUDCAP_STEREO 0x00001
  3856. +#define V4L2_AUDCAP_AVL 0x00002
  3857. +
  3858. +/* Flags for the 'mode' field */
  3859. +#define V4L2_AUDMODE_AVL 0x00001
  3860. +
  3861. +struct v4l2_audioout {
  3862. + __u32 index;
  3863. + __u8 name[32];
  3864. + __u32 capability;
  3865. + __u32 mode;
  3866. + __u32 reserved[2];
  3867. +};
  3868. +
  3869. +/*
  3870. + * M P E G S E R V I C E S
  3871. + *
  3872. + * NOTE: EXPERIMENTAL API
  3873. + */
  3874. +#if 1
  3875. +#define V4L2_ENC_IDX_FRAME_I (0)
  3876. +#define V4L2_ENC_IDX_FRAME_P (1)
  3877. +#define V4L2_ENC_IDX_FRAME_B (2)
  3878. +#define V4L2_ENC_IDX_FRAME_MASK (0xf)
  3879. +
  3880. +struct v4l2_enc_idx_entry {
  3881. + __u64 offset;
  3882. + __u64 pts;
  3883. + __u32 length;
  3884. + __u32 flags;
  3885. + __u32 reserved[2];
  3886. +};
  3887. +
  3888. +#define V4L2_ENC_IDX_ENTRIES (64)
  3889. +struct v4l2_enc_idx {
  3890. + __u32 entries;
  3891. + __u32 entries_cap;
  3892. + __u32 reserved[4];
  3893. + struct v4l2_enc_idx_entry entry[V4L2_ENC_IDX_ENTRIES];
  3894. +};
  3895. +
  3896. +
  3897. +#define V4L2_ENC_CMD_START (0)
  3898. +#define V4L2_ENC_CMD_STOP (1)
  3899. +#define V4L2_ENC_CMD_PAUSE (2)
  3900. +#define V4L2_ENC_CMD_RESUME (3)
  3901. +
  3902. +/* Flags for V4L2_ENC_CMD_STOP */
  3903. +#define V4L2_ENC_CMD_STOP_AT_GOP_END (1 << 0)
  3904. +
  3905. +struct v4l2_encoder_cmd {
  3906. + __u32 cmd;
  3907. + __u32 flags;
  3908. + union {
  3909. + struct {
  3910. + __u32 data[8];
  3911. + } raw;
  3912. + };
  3913. +};
  3914. +
  3915. +#endif
  3916. +
  3917. +
  3918. +/*
  3919. + * D A T A S E R V I C E S ( V B I )
  3920. + *
  3921. + * Data services API by Michael Schimek
  3922. + */
  3923. +
  3924. +/* Raw VBI */
  3925. +struct v4l2_vbi_format {
  3926. + __u32 sampling_rate; /* in 1 Hz */
  3927. + __u32 offset;
  3928. + __u32 samples_per_line;
  3929. + __u32 sample_format; /* V4L2_PIX_FMT_* */
  3930. + __s32 start[2];
  3931. + __u32 count[2];
  3932. + __u32 flags; /* V4L2_VBI_* */
  3933. + __u32 reserved[2]; /* must be zero */
  3934. +};
  3935. +
  3936. +/* VBI flags */
  3937. +#define V4L2_VBI_UNSYNC (1 << 0)
  3938. +#define V4L2_VBI_INTERLACED (1 << 1)
  3939. +
  3940. +/* Sliced VBI
  3941. + *
  3942. + * This implements is a proposal V4L2 API to allow SLICED VBI
  3943. + * required for some hardware encoders. It should change without
  3944. + * notice in the definitive implementation.
  3945. + */
  3946. +
  3947. +struct v4l2_sliced_vbi_format {
  3948. + __u16 service_set;
  3949. + /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field
  3950. + service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field
  3951. + (equals frame lines 313-336 for 625 line video
  3952. + standards, 263-286 for 525 line standards) */
  3953. + __u16 service_lines[2][24];
  3954. + __u32 io_size;
  3955. + __u32 reserved[2]; /* must be zero */
  3956. +};
  3957. +
  3958. +/* Teletext World System Teletext
  3959. + (WST), defined on ITU-R BT.653-2 */
  3960. +#define V4L2_SLICED_TELETEXT_B (0x0001)
  3961. +/* Video Program System, defined on ETS 300 231*/
  3962. +#define V4L2_SLICED_VPS (0x0400)
  3963. +/* Closed Caption, defined on EIA-608 */
  3964. +#define V4L2_SLICED_CAPTION_525 (0x1000)
  3965. +/* Wide Screen System, defined on ITU-R BT1119.1 */
  3966. +#define V4L2_SLICED_WSS_625 (0x4000)
  3967. +
  3968. +#define V4L2_SLICED_VBI_525 (V4L2_SLICED_CAPTION_525)
  3969. +#define V4L2_SLICED_VBI_625 (V4L2_SLICED_TELETEXT_B | V4L2_SLICED_VPS | V4L2_SLICED_WSS_625)
  3970. +
  3971. +struct v4l2_sliced_vbi_cap {
  3972. + __u16 service_set;
  3973. + /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field
  3974. + service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field
  3975. + (equals frame lines 313-336 for 625 line video
  3976. + standards, 263-286 for 525 line standards) */
  3977. + __u16 service_lines[2][24];
  3978. + enum v4l2_buf_type type;
  3979. + __u32 reserved[3]; /* must be 0 */
  3980. +};
  3981. +
  3982. +struct v4l2_sliced_vbi_data {
  3983. + __u32 id;
  3984. + __u32 field; /* 0: first field, 1: second field */
  3985. + __u32 line; /* 1-23 */
  3986. + __u32 reserved; /* must be 0 */
  3987. + __u8 data[48];
  3988. +};
  3989. +
  3990. +/*
  3991. + * Sliced VBI data inserted into MPEG Streams
  3992. + */
  3993. +
  3994. +/*
  3995. + * V4L2_MPEG_STREAM_VBI_FMT_IVTV:
  3996. + *
  3997. + * Structure of payload contained in an MPEG 2 Private Stream 1 PES Packet in an
  3998. + * MPEG-2 Program Pack that contains V4L2_MPEG_STREAM_VBI_FMT_IVTV Sliced VBI
  3999. + * data
  4000. + *
  4001. + * Note, the MPEG-2 Program Pack and Private Stream 1 PES packet header
  4002. + * definitions are not included here. See the MPEG-2 specifications for details
  4003. + * on these headers.
  4004. + */
  4005. +
  4006. +/* Line type IDs */
  4007. +#define V4L2_MPEG_VBI_IVTV_TELETEXT_B (1)
  4008. +#define V4L2_MPEG_VBI_IVTV_CAPTION_525 (4)
  4009. +#define V4L2_MPEG_VBI_IVTV_WSS_625 (5)
  4010. +#define V4L2_MPEG_VBI_IVTV_VPS (7)
  4011. +
  4012. +struct v4l2_mpeg_vbi_itv0_line {
  4013. + __u8 id; /* One of V4L2_MPEG_VBI_IVTV_* above */
  4014. + __u8 data[42]; /* Sliced VBI data for the line */
  4015. +} __attribute__ ((packed));
  4016. +
  4017. +struct v4l2_mpeg_vbi_itv0 {
  4018. + __le32 linemask[2]; /* Bitmasks of VBI service lines present */
  4019. + struct v4l2_mpeg_vbi_itv0_line line[35];
  4020. +} __attribute__ ((packed));
  4021. +
  4022. +struct v4l2_mpeg_vbi_ITV0 {
  4023. + struct v4l2_mpeg_vbi_itv0_line line[36];
  4024. +} __attribute__ ((packed));
  4025. +
  4026. +#define V4L2_MPEG_VBI_IVTV_MAGIC0 "itv0"
  4027. +#define V4L2_MPEG_VBI_IVTV_MAGIC1 "ITV0"
  4028. +
  4029. +struct v4l2_mpeg_vbi_fmt_ivtv {
  4030. + __u8 magic[4];
  4031. + union {
  4032. + struct v4l2_mpeg_vbi_itv0 itv0;
  4033. + struct v4l2_mpeg_vbi_ITV0 ITV0;
  4034. + };
  4035. +} __attribute__ ((packed));
  4036. +
  4037. +/*
  4038. + * A G G R E G A T E S T R U C T U R E S
  4039. + */
  4040. +
  4041. +/**
  4042. + * struct v4l2_plane_pix_format - additional, per-plane format definition
  4043. + * @sizeimage: maximum size in bytes required for data, for which
  4044. + * this plane will be used
  4045. + * @bytesperline: distance in bytes between the leftmost pixels in two
  4046. + * adjacent lines
  4047. + */
  4048. +struct v4l2_plane_pix_format {
  4049. + __u32 sizeimage;
  4050. + __u16 bytesperline;
  4051. + __u16 reserved[7];
  4052. +} __attribute__ ((packed));
  4053. +
  4054. +/**
  4055. + * struct v4l2_pix_format_mplane - multiplanar format definition
  4056. + * @width: image width in pixels
  4057. + * @height: image height in pixels
  4058. + * @pixelformat: little endian four character code (fourcc)
  4059. + * @field: field order (for interlaced video)
  4060. + * @colorspace: supplemental to pixelformat
  4061. + * @plane_fmt: per-plane information
  4062. + * @num_planes: number of planes for this format
  4063. + */
  4064. +struct v4l2_pix_format_mplane {
  4065. + __u32 width;
  4066. + __u32 height;
  4067. + __u32 pixelformat;
  4068. + enum v4l2_field field;
  4069. + enum v4l2_colorspace colorspace;
  4070. +
  4071. + struct v4l2_plane_pix_format plane_fmt[VIDEO_MAX_PLANES];
  4072. + __u8 num_planes;
  4073. + __u8 reserved[11];
  4074. +} __attribute__ ((packed));
  4075. +
  4076. +/**
  4077. + * struct v4l2_format - stream data format
  4078. + * @type: type of the data stream
  4079. + * @pix: definition of an image format
  4080. + * @pix_mp: definition of a multiplanar image format
  4081. + * @win: definition of an overlaid image
  4082. + * @vbi: raw VBI capture or output parameters
  4083. + * @sliced: sliced VBI capture or output parameters
  4084. + * @raw_data: placeholder for future extensions and custom formats
  4085. + */
  4086. +struct v4l2_format {
  4087. + enum v4l2_buf_type type;
  4088. + union {
  4089. + struct v4l2_pix_format pix; /* V4L2_BUF_TYPE_VIDEO_CAPTURE */
  4090. + struct v4l2_pix_format_mplane pix_mp; /* V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE */
  4091. + struct v4l2_window win; /* V4L2_BUF_TYPE_VIDEO_OVERLAY */
  4092. + struct v4l2_vbi_format vbi; /* V4L2_BUF_TYPE_VBI_CAPTURE */
  4093. + struct v4l2_sliced_vbi_format sliced; /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */
  4094. + __u8 raw_data[200]; /* user-defined */
  4095. + } fmt;
  4096. +};
  4097. +
  4098. +/* Stream type-dependent parameters
  4099. + */
  4100. +struct v4l2_streamparm {
  4101. + enum v4l2_buf_type type;
  4102. + union {
  4103. + struct v4l2_captureparm capture;
  4104. + struct v4l2_outputparm output;
  4105. + __u8 raw_data[200]; /* user-defined */
  4106. + } parm;
  4107. +};
  4108. +
  4109. +/*
  4110. + * E V E N T S
  4111. + */
  4112. +
  4113. +#define V4L2_EVENT_ALL 0
  4114. +#define V4L2_EVENT_VSYNC 1
  4115. +#define V4L2_EVENT_EOS 2
  4116. +#define V4L2_EVENT_PRIVATE_START 0x08000000
  4117. +
  4118. +/* Payload for V4L2_EVENT_VSYNC */
  4119. +struct v4l2_event_vsync {
  4120. + /* Can be V4L2_FIELD_ANY, _NONE, _TOP or _BOTTOM */
  4121. + __u8 field;
  4122. +} __attribute__ ((packed));
  4123. +
  4124. +struct v4l2_event {
  4125. + __u32 type;
  4126. + union {
  4127. + struct v4l2_event_vsync vsync;
  4128. + __u8 data[64];
  4129. + } u;
  4130. + __u32 pending;
  4131. + __u32 sequence;
  4132. + struct timespec timestamp;
  4133. + __u32 reserved[9];
  4134. +};
  4135. +
  4136. +struct v4l2_event_subscription {
  4137. + __u32 type;
  4138. + __u32 reserved[7];
  4139. +};
  4140. +
  4141. +/*
  4142. + * A D V A N C E D D E B U G G I N G
  4143. + *
  4144. + * NOTE: EXPERIMENTAL API, NEVER RELY ON THIS IN APPLICATIONS!
  4145. + * FOR DEBUGGING, TESTING AND INTERNAL USE ONLY!
  4146. + */
  4147. +
  4148. +/* VIDIOC_DBG_G_REGISTER and VIDIOC_DBG_S_REGISTER */
  4149. +
  4150. +#define V4L2_CHIP_MATCH_HOST 0 /* Match against chip ID on host (0 for the host) */
  4151. +#define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver name */
  4152. +#define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */
  4153. +#define V4L2_CHIP_MATCH_AC97 3 /* Match against anciliary AC97 chip */
  4154. +
  4155. +struct v4l2_dbg_match {
  4156. + __u32 type; /* Match type */
  4157. + union { /* Match this chip, meaning determined by type */
  4158. + __u32 addr;
  4159. + char name[32];
  4160. + };
  4161. +} __attribute__ ((packed));
  4162. +
  4163. +struct v4l2_dbg_register {
  4164. + struct v4l2_dbg_match match;
  4165. + __u32 size; /* register size in bytes */
  4166. + __u64 reg;
  4167. + __u64 val;
  4168. +} __attribute__ ((packed));
  4169. +
  4170. +/* VIDIOC_DBG_G_CHIP_IDENT */
  4171. +struct v4l2_dbg_chip_ident {
  4172. + struct v4l2_dbg_match match;
  4173. + __u32 ident; /* chip identifier as specified in <media/v4l2-chip-ident.h> */
  4174. + __u32 revision; /* chip revision, chip specific */
  4175. +} __attribute__ ((packed));
  4176. +
  4177. +/*
  4178. + * I O C T L C O D E S F O R V I D E O D E V I C E S
  4179. + *
  4180. + */
  4181. +#define VIDIOC_QUERYCAP _IOR('V', 0, struct v4l2_capability)
  4182. +#define VIDIOC_RESERVED _IO('V', 1)
  4183. +#define VIDIOC_ENUM_FMT _IOWR('V', 2, struct v4l2_fmtdesc)
  4184. +#define VIDIOC_G_FMT _IOWR('V', 4, struct v4l2_format)
  4185. +#define VIDIOC_S_FMT _IOWR('V', 5, struct v4l2_format)
  4186. +#define VIDIOC_REQBUFS _IOWR('V', 8, struct v4l2_requestbuffers)
  4187. +#define VIDIOC_QUERYBUF _IOWR('V', 9, struct v4l2_buffer)
  4188. +#define VIDIOC_G_FBUF _IOR('V', 10, struct v4l2_framebuffer)
  4189. +#define VIDIOC_S_FBUF _IOW('V', 11, struct v4l2_framebuffer)
  4190. +#define VIDIOC_OVERLAY _IOW('V', 14, int)
  4191. +#define VIDIOC_QBUF _IOWR('V', 15, struct v4l2_buffer)
  4192. +#define VIDIOC_DQBUF _IOWR('V', 17, struct v4l2_buffer)
  4193. +#define VIDIOC_STREAMON _IOW('V', 18, int)
  4194. +#define VIDIOC_STREAMOFF _IOW('V', 19, int)
  4195. +#define VIDIOC_G_PARM _IOWR('V', 21, struct v4l2_streamparm)
  4196. +#define VIDIOC_S_PARM _IOWR('V', 22, struct v4l2_streamparm)
  4197. +#define VIDIOC_G_STD _IOR('V', 23, v4l2_std_id)
  4198. +#define VIDIOC_S_STD _IOW('V', 24, v4l2_std_id)
  4199. +#define VIDIOC_ENUMSTD _IOWR('V', 25, struct v4l2_standard)
  4200. +#define VIDIOC_ENUMINPUT _IOWR('V', 26, struct v4l2_input)
  4201. +#define VIDIOC_G_CTRL _IOWR('V', 27, struct v4l2_control)
  4202. +#define VIDIOC_S_CTRL _IOWR('V', 28, struct v4l2_control)
  4203. +#define VIDIOC_G_TUNER _IOWR('V', 29, struct v4l2_tuner)
  4204. +#define VIDIOC_S_TUNER _IOW('V', 30, struct v4l2_tuner)
  4205. +#define VIDIOC_G_AUDIO _IOR('V', 33, struct v4l2_audio)
  4206. +#define VIDIOC_S_AUDIO _IOW('V', 34, struct v4l2_audio)
  4207. +#define VIDIOC_QUERYCTRL _IOWR('V', 36, struct v4l2_queryctrl)
  4208. +#define VIDIOC_QUERYMENU _IOWR('V', 37, struct v4l2_querymenu)
  4209. +#define VIDIOC_G_INPUT _IOR('V', 38, int)
  4210. +#define VIDIOC_S_INPUT _IOWR('V', 39, int)
  4211. +#define VIDIOC_G_OUTPUT _IOR('V', 46, int)
  4212. +#define VIDIOC_S_OUTPUT _IOWR('V', 47, int)
  4213. +#define VIDIOC_ENUMOUTPUT _IOWR('V', 48, struct v4l2_output)
  4214. +#define VIDIOC_G_AUDOUT _IOR('V', 49, struct v4l2_audioout)
  4215. +#define VIDIOC_S_AUDOUT _IOW('V', 50, struct v4l2_audioout)
  4216. +#define VIDIOC_G_MODULATOR _IOWR('V', 54, struct v4l2_modulator)
  4217. +#define VIDIOC_S_MODULATOR _IOW('V', 55, struct v4l2_modulator)
  4218. +#define VIDIOC_G_FREQUENCY _IOWR('V', 56, struct v4l2_frequency)
  4219. +#define VIDIOC_S_FREQUENCY _IOW('V', 57, struct v4l2_frequency)
  4220. +#define VIDIOC_CROPCAP _IOWR('V', 58, struct v4l2_cropcap)
  4221. +#define VIDIOC_G_CROP _IOWR('V', 59, struct v4l2_crop)
  4222. +#define VIDIOC_S_CROP _IOW('V', 60, struct v4l2_crop)
  4223. +#define VIDIOC_G_JPEGCOMP _IOR('V', 61, struct v4l2_jpegcompression)
  4224. +#define VIDIOC_S_JPEGCOMP _IOW('V', 62, struct v4l2_jpegcompression)
  4225. +#define VIDIOC_QUERYSTD _IOR('V', 63, v4l2_std_id)
  4226. +#define VIDIOC_TRY_FMT _IOWR('V', 64, struct v4l2_format)
  4227. +#define VIDIOC_ENUMAUDIO _IOWR('V', 65, struct v4l2_audio)
  4228. +#define VIDIOC_ENUMAUDOUT _IOWR('V', 66, struct v4l2_audioout)
  4229. +#define VIDIOC_G_PRIORITY _IOR('V', 67, enum v4l2_priority)
  4230. +#define VIDIOC_S_PRIORITY _IOW('V', 68, enum v4l2_priority)
  4231. +#define VIDIOC_G_SLICED_VBI_CAP _IOWR('V', 69, struct v4l2_sliced_vbi_cap)
  4232. +#define VIDIOC_LOG_STATUS _IO('V', 70)
  4233. +#define VIDIOC_G_EXT_CTRLS _IOWR('V', 71, struct v4l2_ext_controls)
  4234. +#define VIDIOC_S_EXT_CTRLS _IOWR('V', 72, struct v4l2_ext_controls)
  4235. +#define VIDIOC_TRY_EXT_CTRLS _IOWR('V', 73, struct v4l2_ext_controls)
  4236. +#if 1
  4237. +#define VIDIOC_ENUM_FRAMESIZES _IOWR('V', 74, struct v4l2_frmsizeenum)
  4238. +#define VIDIOC_ENUM_FRAMEINTERVALS _IOWR('V', 75, struct v4l2_frmivalenum)
  4239. +#define VIDIOC_G_ENC_INDEX _IOR('V', 76, struct v4l2_enc_idx)
  4240. +#define VIDIOC_ENCODER_CMD _IOWR('V', 77, struct v4l2_encoder_cmd)
  4241. +#define VIDIOC_TRY_ENCODER_CMD _IOWR('V', 78, struct v4l2_encoder_cmd)
  4242. +#endif
  4243. +
  4244. +#if 1
  4245. +/* Experimental, meant for debugging, testing and internal use.
  4246. + Only implemented if CONFIG_VIDEO_ADV_DEBUG is defined.
  4247. + You must be root to use these ioctls. Never use these in applications! */
  4248. +#define VIDIOC_DBG_S_REGISTER _IOW('V', 79, struct v4l2_dbg_register)
  4249. +#define VIDIOC_DBG_G_REGISTER _IOWR('V', 80, struct v4l2_dbg_register)
  4250. +
  4251. +/* Experimental, meant for debugging, testing and internal use.
  4252. + Never use this ioctl in applications! */
  4253. +#define VIDIOC_DBG_G_CHIP_IDENT _IOWR('V', 81, struct v4l2_dbg_chip_ident)
  4254. +#endif
  4255. +
  4256. +#define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek)
  4257. +#define VIDIOC_ENUM_DV_PRESETS _IOWR('V', 83, struct v4l2_dv_enum_preset)
  4258. +#define VIDIOC_S_DV_PRESET _IOWR('V', 84, struct v4l2_dv_preset)
  4259. +#define VIDIOC_G_DV_PRESET _IOWR('V', 85, struct v4l2_dv_preset)
  4260. +#define VIDIOC_QUERY_DV_PRESET _IOR('V', 86, struct v4l2_dv_preset)
  4261. +#define VIDIOC_S_DV_TIMINGS _IOWR('V', 87, struct v4l2_dv_timings)
  4262. +#define VIDIOC_G_DV_TIMINGS _IOWR('V', 88, struct v4l2_dv_timings)
  4263. +#define VIDIOC_DQEVENT _IOR('V', 89, struct v4l2_event)
  4264. +#define VIDIOC_SUBSCRIBE_EVENT _IOW('V', 90, struct v4l2_event_subscription)
  4265. +#define VIDIOC_UNSUBSCRIBE_EVENT _IOW('V', 91, struct v4l2_event_subscription)
  4266. +
  4267. +#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */
  4268. +
  4269. +#endif /* __LINUX_VIDEODEV2_H */