go7007.txt 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. This is a driver for the WIS GO7007SB multi-format video encoder.
  2. Pete Eberlein <pete@sensoray.com>
  3. The driver was originally released under the GPL and is currently hosted at:
  4. http://nikosapi.org/wiki/index.php/WIS_Go7007_Linux_driver
  5. The go7007 firmware can be acquired from the package on the site above.
  6. I've modified the driver to support the following Video4Linux2 MPEG
  7. controls, with acceptable values:
  8. V4L2_CID_MPEG_STREAM_TYPE V4L2_MPEG_STREAM_TYPE_MPEG2_DVD
  9. V4L2_MPEG_STREAM_TYPE_MPEG_ELEM
  10. V4L2_CID_MPEG_VIDEO_ENCODING V4L2_MPEG_VIDEO_ENCODING_MPEG_1
  11. V4L2_MPEG_VIDEO_ENCODING_MPEG_2
  12. V4L2_MPEG_VIDEO_ENCODING_MPEG_4
  13. V4L2_CID_MPEG_VIDEO_ASPECT V4L2_MPEG_VIDEO_ASPECT_1x1
  14. V4L2_MPEG_VIDEO_ASPECT_4x3
  15. V4L2_MPEG_VIDEO_ASPECT_16x9
  16. V4L2_CID_MPEG_VIDEO_GOP_SIZE integer
  17. V4L2_CID_MPEG_VIDEO_BITRATE 64000 .. 10000000
  18. These should be used instead of the non-standard GO7007 ioctls described
  19. below.
  20. The README files from the orignal package appear below:
  21. ---------------------------------------------------------------------------
  22. WIS GO7007SB Public Linux Driver
  23. ---------------------------------------------------------------------------
  24. *** Please see the file RELEASE-NOTES for important last-minute updates ***
  25. 0. OVERVIEW AND LICENSING/DISCLAIMER
  26. This driver kit contains Linux drivers for the WIS GO7007SB multi-format
  27. video encoder. Only kernel version 2.6.x is supported. The video stream
  28. is available through the Video4Linux2 API and the audio stream is available
  29. through the ALSA API (or the OSS emulation layer of the ALSA system).
  30. The files in kernel/ and hotplug/ are licensed under the GNU General Public
  31. License Version 2 from the Free Software Foundation. A copy of the license
  32. is included in the file COPYING.
  33. The example applications in apps/ and C header files in include/ are
  34. licensed under a permissive license included in the source files which
  35. allows copying, modification and redistribution for any purpose without
  36. attribution.
  37. The firmware files included in the firmware/ directory may be freely
  38. redistributed only in conjunction with this document; but modification,
  39. tampering and reverse engineering are prohibited.
  40. MICRONAS USA, INC., MAKES NO WARRANTIES TO ANY PERSON OR ENTITY WITH
  41. RESPECT TO THE SOFTWARE OR ANY DERIVATIVES THEREOF OR ANY SERVICES OR
  42. LICENSES AND DISCLAIMS ALL IMPLIED WARRANTIES, INCLUDING WITHOUT LIMITATION
  43. WARRANTIES OF MERCHANTABILITY, SUPPORT, AND FITNESS FOR A PARTICULAR
  44. PURPOSE AND NON-INFRINGEMENT.
  45. 1. SYSTEM REQUIREMENTS
  46. This driver requires Linux kernel 2.6. Kernel 2.4 is not supported. Using
  47. kernel 2.6.10 or later is recommended, as earlier kernels are known to have
  48. unstable USB 2.0 support.
  49. A fully built kernel source tree must be available. Typically this will be
  50. linked from "/lib/modules/<KERNEL VERSION>/build" for convenience. If this
  51. link does not exist, an extra parameter will need to be passed to the
  52. `make` command.
  53. All vendor-built kernels should already be configured properly. However,
  54. for custom-built kernels, the following options need to be enabled in the
  55. kernel as built-in or modules:
  56. CONFIG_HOTPLUG - Support for hot-pluggable devices
  57. CONFIG_MODULES - Enable loadable module support
  58. CONFIG_KMOD - Automatic kernel module loading
  59. CONFIG_FW_LOADER - Hotplug firmware loading support
  60. CONFIG_I2C - I2C support
  61. CONFIG_VIDEO_DEV - Video For Linux
  62. CONFIG_SOUND - Sound card support
  63. CONFIG_SND - Advanced Linux Sound Architecture
  64. CONFIG_USB - Support for Host-side USB
  65. CONFIG_USB_DEVICEFS - USB device filesystem
  66. CONFIG_USB_EHCI_HCD - EHCI HCD (USB 2.0) support
  67. Additionally, to use the example application, the following options need to
  68. be enabled in the ALSA section:
  69. CONFIG_SND_MIXER_OSS - OSS Mixer API
  70. CONFIG_SND_PCM_OSS - OSS PCM (digital audio) API
  71. The hotplug scripts, along with the fxload utility, must also be installed.
  72. These scripts can be obtained from <http://linux-hotplug.sourceforge.net/>.
  73. Hotplugging is used for loading firmware into the Cypruss EZ-USB chip using
  74. fxload and for loading firmware into the driver using the firmware agent.
  75. 2. COMPILING AND INSTALLING THE DRIVER
  76. Most users should be able to compile the driver by simply running:
  77. $ make
  78. in the top-level directory of the driver kit. First the kernel modules
  79. will be built, followed by the example applications.
  80. If the build system is unable to locate the kernel source tree for the
  81. currently-running kernel, or if the module should be built for a kernel
  82. other than the currently-running kernel, an additional parameter will need
  83. to be passed to make to specify the appropriate kernel source directory:
  84. $ make KERNELSRC=/usr/src/linux-2.6.10-custom3
  85. Once the compile completes, the driver and firmware files should be
  86. installed by running:
  87. $ make install
  88. The kernel modules will be placed in "/lib/modules/<KERNEL VERSION>/extra"
  89. and the firmware files will be placed in the appropriate hotplug firmware
  90. directory, usually /lib/firmware. In addition, USB maps and scripts will
  91. be placed in /etc/hotplug/usb to enable fxload to initialize the EZ-USB
  92. control chip when the device is connected.
  93. 3. PAL/SECAM TUNER CONFIGURATION (TV402U-EU only)
  94. The PAL model of the Plextor ConvertX TV402U may require additional
  95. configuration to correctly select the appropriate TV frequency band and
  96. audio subchannel.
  97. Users with a device other than the Plextor ConvertX TV402U-EU should skip
  98. this section.
  99. The wide variety of PAL TV systems used in Europe requires that additional
  100. information about the local TV standards be passed to the driver in order
  101. to properly tune TV channels. The two necessary parameters are (a) the PAL
  102. TV band, and (b) the audio subchannel format in use.
  103. In many cases, the appropriate TV band selection is passed to the driver
  104. from applications. However, in some cases, the application only specifies
  105. that the driver should use PAL but not the specific information about the
  106. appropriate TV band. To work around this issue, the correct TV band may be
  107. specified in the "force_band" parameter to the wis-sony-tuner module:
  108. TV band force_band
  109. ------- ----------
  110. PAL B/G B
  111. PAL I I
  112. PAL D/K D
  113. SECAM L L
  114. If the "force_band" parameter is specified, the driver will ignore any TV
  115. band specified by applications and will always use the band provided in the
  116. module parameter.
  117. The other parameter that can be specified is the audio subchannel format.
  118. There are several stereo audio carrier systems in use, including NICAM and
  119. three varieties of A2. To receive audio broadcast on one of these stereo
  120. carriers, the "force_mpx_mode" parameter must be specified to the
  121. wis-sony-tuner module.
  122. TV band Audio subcarrier force_mpx_mode
  123. ------- ---------------- --------------
  124. PAL B/G Mono (default) 1
  125. PAL B/G A2 2
  126. PAL B/G NICAM 3
  127. PAL I Mono (default) 4
  128. PAL I NICAM 5
  129. PAL D/K Mono (default) 6
  130. PAL D/K A2 (1) 7
  131. PAL D/K A2 (2) 8
  132. PAL D/K A2 (3) 9
  133. PAL D/K NICAM 10
  134. SECAM L Mono (default) 11
  135. SECAM L NICAM 12
  136. If the "force_mpx_mode" parameter is not specified, the correct mono-only
  137. mode will be chosen based on the TV band. However, the tuner will not
  138. receive stereo audio or bilingual broadcasts correctly.
  139. To pass the "force_band" or "force_mpx_mode" parameters to the
  140. wis-sony-tuner module, the following line must be added to the modprobe
  141. configuration file, which varies from one Linux distribution to another.
  142. options wis-sony-tuner force_band=B force_mpx_mode=2
  143. The above example would force the tuner to the PAL B/G TV band and receive
  144. stereo audio broadcasts on the A2 carrier.
  145. To verify that the configuration has been placed in the correct location,
  146. execute:
  147. $ modprobe -c | grep wis-sony-tuner
  148. If the configuration line appears, then modprobe will pass the parameters
  149. correctly the next time the wis-sony-tuner module is loaded into the
  150. kernel.
  151. 4. TESTING THE DRIVER
  152. Because few Linux applications are able to correctly capture from
  153. Video4Linux2 devices with only compressed formats supported, the new driver
  154. should be tested with the "gorecord" application in the apps/ directory.
  155. First connect a video source to the device, such as a DVD player or VCR.
  156. This will be captured to a file for testing the driver. If an input source
  157. is unavailable, a test file can still be captured, but the video will be
  158. black and the audio will be silent.
  159. This application will auto-detect the V4L2 and ALSA/OSS device names of the
  160. hardware and will record video and audio to an AVI file for a specified
  161. number of seconds. For example:
  162. $ apps/gorecord -duration 60 capture.avi
  163. If this application does not successfully record an AVI file, the error
  164. messages produced by gorecord and recorded in the system log (usually in
  165. /var/log/messages) should provide information to help resolve the problem.
  166. Supplying no parameters to gorecord will cause it to probe the available
  167. devices and exit. Use the -help flag for usage information.
  168. 5. USING THE DRIVER
  169. The V4L2 device implemented by the driver provides a standard compressed
  170. format API, within the following criteria:
  171. * Applications that only support the original Video4Linux1 API will not
  172. be able to communicate with this driver at all.
  173. * No raw video modes are supported, so applications like xawtv that
  174. expect only uncompressed video will not function.
  175. * Supported compression formats are: Motion-JPEG, MPEG1, MPEG2 and MPEG4.
  176. * MPEG video formats are delivered as Video Elementary Streams only.
  177. Program Stream (PS), Transport Stream (TS) and Packetized Elementary
  178. Stream (PES) formats are not supported.
  179. * Video parameters such as format and input port may not be changed while
  180. the encoder is active.
  181. * The audio capture device only functions when the video encoder is
  182. actively capturing video. Attempts to read from the audio device when
  183. the encoder is inactive will result in an I/O error.
  184. * The native format of the audio device is 48Khz 2-channel 16-bit
  185. little-endian PCM, delivered through the ALSA system. No audio
  186. compression is implemented in the hardware. ALSA may convert to other
  187. uncompressed formats on the fly.
  188. The include/ directory contains a C header file describing non-standard
  189. features of the GO7007SB encoder, which are described below:
  190. GO7007IOC_S_COMP_PARAMS, GO7007IOC_G_COMP_PARAMS
  191. These ioctls are used to negotiate general compression parameters.
  192. To query the current parameters, call the GO7007IOC_G_COMP_PARAMS ioctl
  193. with a pointer to a struct go7007_comp_params. If the driver is not
  194. set to MPEG format, the EINVAL error code will be returned.
  195. To change the current parameters, initialize all fields of a struct
  196. go7007_comp_params and call the GO7007_IOC_S_COMP_PARAMS ioctl with a
  197. pointer to this structure. The driver will return the current
  198. parameters with any necessary changes to conform to the limitations of
  199. the hardware or current compression mode. Any or all fields can be set
  200. to zero to request a reasonable default value. If the driver is not
  201. set to MPEG format, the EINVAL error code will be returned. When I/O
  202. is in progress, the EBUSY error code will be returned.
  203. Fields in struct go7007_comp_params:
  204. __u32 The maximum number of frames in each
  205. gop_size Group Of Pictures; i.e. the maximum
  206. number of frames minus one between
  207. each key frame.
  208. __u32 The maximum number of sequential
  209. max_b_frames bidirectionally-predicted frames.
  210. (B-frames are not yet supported.)
  211. enum go7007_aspect_ratio The aspect ratio to be encoded in the
  212. aspect_ratio meta-data of the compressed format.
  213. Choices are:
  214. GO7007_ASPECT_RATIO_1_1
  215. GO7007_ASPECT_RATIO_4_3_NTSC
  216. GO7007_ASPECT_RATIO_4_3_PAL
  217. GO7007_ASPECT_RATIO_16_9_NTSC
  218. GO7007_ASPECT_RATIO_16_9_PAL
  219. __u32 Bit-wise OR of control flags (below)
  220. flags
  221. Flags in struct go7007_comp_params:
  222. GO7007_COMP_CLOSED_GOP Only produce self-contained GOPs, used
  223. to produce streams appropriate for
  224. random seeking.
  225. GO7007_COMP_OMIT_SEQ_HEADER Omit the stream sequence header.
  226. GO7007IOC_S_MPEG_PARAMS, GO7007IOC_G_MPEG_PARAMS
  227. These ioctls are used to negotiate MPEG-specific stream parameters when
  228. the pixelformat has been set to V4L2_PIX_FMT_MPEG.
  229. To query the current parameters, call the GO7007IOC_G_MPEG_PARAMS ioctl
  230. with a pointer to a struct go7007_mpeg_params. If the driver is not
  231. set to MPEG format, the EINVAL error code will be returned.
  232. To change the current parameters, initialize all fields of a struct
  233. go7007_mpeg_params and call the GO7007_IOC_S_MPEG_PARAMS ioctl with a
  234. pointer to this structure. The driver will return the current
  235. parameters with any necessary changes to conform to the limitations of
  236. the hardware or selected MPEG mode. Any or all fields can be set to
  237. zero to request a reasonable default value. If the driver is not set
  238. to MPEG format, the EINVAL error code will be returned. When I/O is in
  239. progress, the EBUSY error code will be returned.
  240. Fields in struct go7007_mpeg_params:
  241. enum go7007_mpeg_video_standard
  242. mpeg_video_standard The MPEG video standard in which to
  243. compress the video.
  244. Choices are:
  245. GO7007_MPEG_VIDEO_MPEG1
  246. GO7007_MPEG_VIDEO_MPEG2
  247. GO7007_MPEG_VIDEO_MPEG4
  248. __u32 Bit-wise OR of control flags (below)
  249. flags
  250. __u32 The profile and level indication to be
  251. pali stored in the sequence header. This
  252. is only used as an indicator to the
  253. decoder, and does not affect the MPEG
  254. features used in the video stream.
  255. Not valid for MPEG1.
  256. Choices for MPEG2 are:
  257. GO7007_MPEG2_PROFILE_MAIN_MAIN
  258. Choices for MPEG4 are:
  259. GO7007_MPEG4_PROFILE_S_L0
  260. GO7007_MPEG4_PROFILE_S_L1
  261. GO7007_MPEG4_PROFILE_S_L2
  262. GO7007_MPEG4_PROFILE_S_L3
  263. GO7007_MPEG4_PROFILE_ARTS_L1
  264. GO7007_MPEG4_PROFILE_ARTS_L2
  265. GO7007_MPEG4_PROFILE_ARTS_L3
  266. GO7007_MPEG4_PROFILE_ARTS_L4
  267. GO7007_MPEG4_PROFILE_AS_L0
  268. GO7007_MPEG4_PROFILE_AS_L1
  269. GO7007_MPEG4_PROFILE_AS_L2
  270. GO7007_MPEG4_PROFILE_AS_L3
  271. GO7007_MPEG4_PROFILE_AS_L4
  272. GO7007_MPEG4_PROFILE_AS_L5
  273. Flags in struct go7007_mpeg_params:
  274. GO7007_MPEG_FORCE_DVD_MODE Force all compression parameters and
  275. bitrate control settings to comply
  276. with DVD MPEG2 stream requirements.
  277. This overrides most compression and
  278. bitrate settings!
  279. GO7007_MPEG_OMIT_GOP_HEADER Omit the GOP header.
  280. GO7007_MPEG_REPEAT_SEQHEADER Repeat the MPEG sequence header at
  281. the start of each GOP.
  282. GO7007IOC_S_BITRATE, GO7007IOC_G_BITRATE
  283. These ioctls are used to set and query the target bitrate value for the
  284. compressed video stream. The bitrate may be selected by storing the
  285. target bits per second in an int and calling GO7007IOC_S_BITRATE with a
  286. pointer to the int. The bitrate may be queried by calling
  287. GO7007IOC_G_BITRATE with a pointer to an int where the current bitrate
  288. will be stored.
  289. Note that this is the primary means of controlling the video quality
  290. for all compression modes, including V4L2_PIX_FMT_MJPEG. The
  291. VIDIOC_S_JPEGCOMP ioctl is not supported.
  292. ----------------------------------------------------------------------------
  293. Installing the WIS PCI Voyager Driver
  294. ---------------------------------------------------------------------------
  295. The WIS PCI Voyager driver requires several patches to the Linux 2.6.11.x
  296. kernel source tree before compiling the driver. These patches update the
  297. in-kernel SAA7134 driver to the newest development version and patch bugs
  298. in the TDA8290/TDA8275 tuner driver.
  299. The following patches must be downloaded from Gerd Knorr's website and
  300. applied in the order listed:
  301. http://dl.bytesex.org/patches/2.6.11-2/i2c-tuner
  302. http://dl.bytesex.org/patches/2.6.11-2/i2c-tuner2
  303. http://dl.bytesex.org/patches/2.6.11-2/v4l2-api-mpeg
  304. http://dl.bytesex.org/patches/2.6.11-2/saa7134-update
  305. The following patches are included with this SDK and can be applied in any
  306. order:
  307. patches/2.6.11/saa7134-voyager.diff
  308. patches/2.6.11/tda8275-newaddr.diff
  309. patches/2.6.11/tda8290-ntsc.diff
  310. Check to make sure the CONFIG_VIDEO_SAA7134 option is enabled in the kernel
  311. configuration, and build and install the kernel.
  312. After rebooting into the new kernel, the GO7007 driver can be compiled and
  313. installed:
  314. $ make SAA7134_BUILD=y
  315. $ make install
  316. $ modprobe saa7134-go7007
  317. There will be two V4L video devices associated with the PCI Voyager. The
  318. first device (most likely /dev/video0) provides access to the raw video
  319. capture mode of the SAA7133 device and is used to configure the source
  320. video parameters and tune the TV tuner. This device can be used with xawtv
  321. or other V4L(2) video software as a standard uncompressed device.
  322. The second device (most likely /dev/video1) provides access to the
  323. compression functions of the GO7007. It can be tested using the gorecord
  324. application in the apps/ directory of this SDK:
  325. $ apps/gorecord -vdevice /dev/video1 -noaudio test.avi
  326. Currently the frame resolution is fixed at 720x480 (NTSC) or 720x576 (PAL),
  327. and the video standard must be specified to both the raw and the compressed
  328. video devices (xawtv and gorecord, for example).
  329. --------------------------------------------------------------------------
  330. RELEASE NOTES FOR WIS GO7007SB LINUX DRIVER
  331. ---------------------------------------------------------------------------
  332. Last updated: 5 November 2005
  333. - Release 0.9.7 includes new support for using udev to run fxload. The
  334. install script should automatically detect whether the old hotplug
  335. scripts or the new udev rules should be used. To force the use of
  336. hotplug, run "make install USE_UDEV=n". To force the use of udev, run
  337. "make install USE_UDEV=y".
  338. - Motion detection is supported but undocumented. Try the `modet` app
  339. for a demonstration of how to use the facility.
  340. - Using USB2.0 devices such as the TV402U with USB1.1 HCDs or hubs can
  341. cause buffer overruns and frame drops, even at low framerates, due to
  342. inconsistency in the bitrate control mechanism.
  343. - On devices with an SAA7115, including the Plextor ConvertX, video height
  344. values of 96, 128, 160, 192, 256, 320, and 384 do not work in NTSC mode.
  345. All valid heights up to 512 work correctly in PAL mode.
  346. - The WIS Star Trek and PCI Voyager boards have no support yet for audio
  347. or the TV tuner.