This is a "plugin" for the Video Disk Recorder (VDR).

Written by:		Dominic Morris <dom@suborbital.org.uk> (Original Author),
                        Andreas Schaefers <Andreas_Schaefers@gmx.de>,
                        Martin Dauskardt <directorskinner@arcor.de> ("Dr. Seltsam")


Latest version available at:  http://drseltsam.device.name/vdr/pvr/src/pvr350/

The pvr350-plugin was originally written by Dominic Morris, but he stopped development.
Based on the last version 0.0.5 from December 2005 (which was only sent to a few people),
I adapted the plugin during the years to ivtv changes. Although I have only very limited knowledge
about C++, I also managed to improve some things. Special thanks to
- Jon Burgess (for helping me to convert the ivtv fwcall 0x56 to IVTVFB_IOCTL_SET_WINDOW)
- Ian Armstrong (for adapting the code to the ivtv-fb changes)
- Hans Verkuil (for a lot of tips how to convert the code to the new V4L2 API. I also used
  a lot of code found in his ivtvtv-tool)
- and of course to Andreas Schaefers, who rewrote a lot of parts of the plugin and introduced
  ac3 conversion. Without his help the plugin wouldn`t be like it is.

Dr. Seltsam


See the file COPYING for license information.

Description:
------------

This plugin implements an output device for the PVR350 TV out.


Requirements:
-------------
- ivtv driver version >= 0.10
  It is higly recommended to use ivtv 1.x. You need both ivtv (included in kernel since 2.6.22)
  and ivtvfb (included in kernel since 2.6.24). If you have a kernel > 2.6.24 have a look at
  http://ivtvdriver.org/index.php/Download to see what you need to compile.

- twolame from http://www.twolame.org/ (tested with 0.3.10). For Debian/Ubuntu the package name is
  libtwolame-dev.

- a52dec from http://liba52.sourceforge.net/ (tested with a 0.7.5-cvs snapshot, but 0.7.4 should also work)

- plugin pvrinput (you don`t need it, if you only want to use the pvr350 decoder part, e.g. with DVB cards) 
  You cand find the latest sources at http://drseltsam.device.name/vdr/pvr/src/pvrinput/

- Be sure you have a recent version of videodev2.h in your /usr/include/linux.
  You also need recent versions of /usr/include/linux/dvb/video.h and /usr/include/linux/dvb/video.h
  All three files can be found at http://linuxtv.org/hg/v4l-dvb. Click on "manifest" and browse
  to linux/include/linux/.

Installation:
-------------
- Unpack the package into "PLUGINS/SRC" directory.
- Make a symbolic link to this pvr350-plugin (ln -s pvr350-x.x.x pvr350).
- Call "make plugins" in the VDR root directory.
- Make sure ivtv and ivtv-fb modules are loaded. (In newer driver versions ivtv-fb has been renamend to ivtvfb !)
- If you want to use the remote, load lirc-i2c
- Start vdr with plugin pvr350 (for example "vdr -Ppvr350")
 

Problems/Troubleshooting:
-------------------------

- The PVR350 decoder needs a multiplexed mpg containing both video and audio. Playing audio-only
  is not possible. A workaround for analogue radio (you need a recent
  pvrinput version) is to set the VPID to 301.
  For DVB radio you could try the radio plugin, which creates a still picture as background.
  Unfortunately this works only for live. If you play back such a recordings it may crash, 
  especially when you use trickmode (fast forward/rewind).

- The PVR350 can`t play PCM audio like it is delivered from the mp3-plugin with output mode=DVB.
  Solution: Compile the mp3-plugin with OSS support (see its Makefile), set it to OSS output mode and
  use your soundcard.

- Changing audio volume is not possible due to a hardware limitation. A solution could be to connect
  the audio output of the pvr350 with the line input of your soundcard and to use the sndctl-plugin or avolctl-plugin.

- The plugin uses /dev/video16 at default. If you have other videocards 
  (for example an additional PVR card or a DVB device with analogue tuner and/or video input)
  your pvr350 may get /dev/video17 or higher. In most cases you won`t be able to set the right
  device number of your PVR350 in the plugin menu, because you can`t start vdr.
  Solution: If your PVR350 is /dev/video17, edit vdr`s setup.conf:
  pvr350.DeviceNumber = 17

- After loading ivtv-fb the console locks: To avoid the console being taken over
  by ivtv-fb, try the following: Add a valid vga mode to the kernel options, so that the console
  display driver gets fb0. Add also "video=vc:64-64 video=map:0".
  Example for boot/grub/menu.lst:
       kernel /boot/vmlinuz vga=0x317 video=vc:64-64 video=map:0 root=/dev/hda1 quiet
  You may also try the kernel option 'fbcon=vc:0-0' . This ensures that only
  the first framebuffer device (that of your graphics card) is used.
  If you don't use a framebuffer at all for your console, then try the option
  'fbcon=vc:64-63', this will prevent any framebuffer device from being used
  for the console. However, in kernel 2.6.23 the 'vc:64-63' trick no longer works. Instead
  enable the VT_HW_CONSOLE_BINDING configuration option when compiling
  the kernel: 'Device Drivers', 'Character devices', 'Support for binding and
  unbinding console drivers'. You can now unload ivtvfb by running
  'rmmod -f ivtvfb' and the standard console will automatically be reattached.
  WARNING: There is obviously a kernel bug: After unloading ivtvfb this way, the /proc/dev/fb0 
  does still exist, but loading ivtvfb again will create a new /proc/dev/fb0. At least vdr will crash,
  you may also get a kernel oops. So use this as last solution and avoid unloading/reloading ivtvfb
  without a reboot.

- playing an ac3-DVD with the dvd-plugin: You need to set "Use Dolby Digital" to "yes" in the vdr
  settings, otherwise you won`t hear anything. The pvr350-plugin converts ac3 internally to mp2. You
  may notice a much lower audio volume. This is because ac3 has more dynamic range (the difference
  between loud and soft). You can adjust the AC3 Gain level in the plugin setup menu, which is also
  useful for DVB channels with AC3 sound.

- When switching from fast forward to Play, it always skips a few seconds. The reason
  is, that vdr calls "Clear()" to clear the decoder buffers. For DVB cards (which have a smaller buffer)
  vdr`s dvbplayer uses cBacktrace to compensate this. Until a better solution (e.g. by using GetSTC)
  is not implemented in vdr, you need to patch vdr (dvbplayer.c):
  
	int cBackTrace::Get(bool Forward)
	{
	  int p = pos;
	  int n = num;
	//  int l = DVB_BUF_SIZE + (Forward ? 0 : 256 * 1024); //XXX (256 * 1024) == DVB_BUF_SIZE ???
	  int l = (2560 * 1024); //fix for PVR350
	  int i = -1; 

