<?xml version='1.0'?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
	"file:///usr/share/sgml/docbook/dtd/xml/4.2/docbookx.dtd">

<!-- This should be the DOCTYPE URL above but xmlto doesn't like it
	"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
-->

<article>

<title>Hauppauge WinTV Nova-T PCI Linux HowTo</title>

<articleinfo>
	<author>
	<firstname>Tony</firstname> <surname>Houghton</surname>
	<email>h@realh.co.uk</email>
	</author>
	<copyright><year>2005</year> <holder>Tony Houghton</holder></copyright>
	<revhistory>
	<revision>
		<revnumber>1.5</revnumber>
		<date>03 Nov 2009</date>
		<revremark>Typo (/dev/dvr/... instead of /dev/dvb/</revremark>
	</revision>
	<revision>
		<revnumber>1.4</revnumber>
		<date>13 Feb 2007</date>
		<revremark>Got rid of spamtrap. Hauppauge remote patch no longer
			necessary</revremark>
	</revision>
	<revision>
		<revnumber>1.3</revnumber>
		<date>16 January 2007</date>
		<revremark>Corrected info about location of HOWTO. This version of Nova-T
			no longer current?</revremark>
	</revision>
	<revision>
	<revnumber>1.2</revnumber>
	<date>23 July 2006</date>
	<revremark>bttv doesn't seem necessary after all. New info about
			location of HOWTO. New version of dvb-apps. Added note about
			/proc/bus/input/devices</revremark>
	</revision>
	<revision>
	<revnumber>1.1</revnumber>
	<date>24 February 2006</date>
	<revremark>Now using relative links for downloadable files. Updated LIRC
	section and added inputlirc. Replaced "Nova-T" with "remote" in
	comment about enabling bttv.</revremark>
	</revision>
	<revision>
	<revnumber>1.0</revnumber>
	<date>1 November 2005</date>
	</revision>
	</revhistory>
</articleinfo>

<sect1> <title>Location</title>
	<para>I can not guarantee the exact location of this document due to
		vagaries of whatever domain hosting package I'm using at any given
		time, but you should always be able to find it by going to
		<ulink url="http://www.realh.co.uk/">http://www.realh.co.uk</ulink> and
		following the link. I will also try to make it available directly at
		either <ulink url="http://dvbhowto.realh.co.uk/">
				http://dvbhowto.realh.co.uk/</ulink> or
		<ulink url="http://www.realh.co.uk/dvbhowto">
			http://www.realh.co.uk/dvbhowto</ulink>.</para>
</sect1>

<sect1> <title>The hardware</title>

<para>Hauppauge's WinTV Nova-T is a PCI card for receiving digital
	terrestrial television broadcasts (<acronym>DVB-T</acronym>), eg the UK's
	Freeview service. This is a guide to using the card in Linux. Apparently
	there is more than one type of card with the same model name. This guide
	is for what I believe is unfortunately no longer the current version of
	the card, supplied with a grey remote control and based on
	<hardware>saa7146</hardware> and <hardware>tda10045</hardware> chips. Some
	of the information here should also be useful for other cards though.
	Linux's <command>lspci</command> command should identify at least one of
	the chips for you if you're not sure. This is often referred to as a
	"Budget" card because of the lack of a built-in MPEG decoder, while models
	with MPEG decoders are often refered to as "full-featured" (sometimes
	abbreviated to <acronym>FF</acronym> in technical circles).</para>

</sect1>

<sect1> <title>Compiling the Linux DVB drivers</title>

<para>I recommend using the latest 2.6 series kernel, which has DVB drivers
	built in. You can also download the drivers either as a tarball or by CVS.
	See <ulink url="http://www.linuxtv.org">www.linuxtv.org</ulink> and either
	compile them outside the kernel or patch them into the kernel source. This
	may give you newer versions of the drivers, but last time I tried patching
	the drivers into a recent kernel they failed to compile. There is some
	very good information about the DVB drivers in the
	<filename>dvb</filename> subdirectory of the kernel's
	documentation, although some of it is out of date.</para>

<sect2> <title>Kernel options</title>

	<para>Start configuring the kernel, eg with
	<command>make menuconfig</command>, and go to
	<menuchoice><guisubmenu>Device Drivers</guisubmenu>
	<guisubmenu>Multimedia devices</guisubmenu></menuchoice>. Enable
	<menuchoice><guimenuitem>Video For Linux</guimenuitem></menuchoice>
	and
	<menuchoice><guimenuitem>Enable Video For Linux API
			1</guimenuitem></menuchoice>,
	even if it says it's deprecated, then enter the <menuchoice><guisubmenu>
	Digital Video Broadcasting Devices
	</guisubmenu></menuchoice> section. There enable
	<menuchoice><guimenuitem>DVB For Linux</guimenuitem></menuchoice> and,
	preferably as modules
	<menuchoice><guimenuitem>DVB Core Support</guimenuitem></menuchoice>
	and the drivers for your card. The Nova-T uses the
	<literal>budget-ci</literal> module
	(<menuchoice><guimenuitem>
	Budget cards with onboard CI connector
	</guimenuitem></menuchoice>).
	Enabling this should automatically enable other modules/drivers it needs,
	including the TDA1004x front-end. Note the use of
	<literal>budget-ci</literal> as opposed to <literal>budget</literal>
	even though this card does not have a "Common Interface" (CI)
	connector.</para>

	<para>To be able to use the remote control you should also enable
	<literal>evdev</literal>
	(<menuchoice><guisubmenu>Device Drivers</guisubmenu>
	<guisubmenu>Input device support</guisubmenu>
	<guimenuitem>Event interface</guimenuitem></menuchoice>).</para>

	<para id="devinputscan">When working the remote will generate events at
	<filename>/dev/input/event<replaceable>X</replaceable></filename> where
	<replaceable>X</replaceable> is a number which will vary depending on
	what devices are connected. To help work out which device is which, I've
	written a utility to scan input devices and print each one's description
	so that you can easily find which one corresponds to your remote.
	Download <ulink url="devinputscan.c">devinputscan.c</ulink>, compile it, eg:

	<literallayout><computeroutput>gcc -Wall -o devinputscan devinputscan.c</computeroutput></literallayout>
		and run it. Or you can just examine the pseudo-file
		<filename>/proc/bus/input/devices</filename>.</para>

</sect2>

<sect2>
	<title>Patch to make the remote work correctly (obsolescent)</title>

	<para>As of version 2.6.20 the budget-ci driver supplied with the Linux
		kernel now works correctly with the remote control featured in this
		article. No doubt this has also been the case with the separate driver
		package from linuxtv.org for some time before the kernel tree caught up.
		Previous versions of the <literal>budget-ci</literal> driver contained
		incorrect mappings for this card's remote. There is a patch in
		circulation to make the driver more sophisticated and able to load a
		mapping at run-time, but I used to use an alternative patch with the
		correct mapping encoded in it. There are two versions, depending on the
		driver version: <ulink url="hauppauge-ir.patch"> hauppauge-ir.patch
		</ulink> or <ulink url="hauppauge-ir-cvs.patch"> hauppauge-ir-cvs.patch
	</ulink>.  The former is for older versions of the driver, and the latter
	for more recent ones including the ones supplied with kernel 2.6.</para>

</sect2>

</sect1>

<sect1> <title>Card firmware</title>

	<para>Some DVB front-ends, including the TDA10045 used by the Nova-T,
	require firmware. Fortunately, as long as you know which chip is on your
	card, kernel 2.6 now makes this quite straightforward. In
	<filename>Documentation/dvb</filename> is a script called
	<filename>get_dvb_firmware</filename>. Near the start of the file is a
	variable called <varname>&commat;components</varname> with a list of
	supported chips. Pick the one that matches your card and use it as an
	argument to the script eg:

<literallayout><computeroutput>/usr/src/linux/Documentation/dvb/get_dvb_firmware tda10045</computeroutput></literallayout>

	This will download and extract a suitable firmware image for the card
	and tell you where to install it. The module will automatically upload
	it to the card when necessary.</para>

</sect1>

<sect1> <title>DVB utilities</title>

	<para><ulink url="http://www.linuxtv.org">www.linuxtv.org</ulink> provides
	a package called <filename>linuxtv-dvb-apps</filename> with some
	essential utilities. Download it, unpack it, enter the directory and run
	<command>make</command>. There is no <literal>install</literal> target.
	You may find it useful to copy the utilities you need to
	<filename>/usr/local/bin</filename> and the information for your local
	transmitter (or satellite or cable provider etc) to a more convenient
	location.
	</para>

	<sect2> <title>scan</title>

	<para>The first thing you need is a list of channels to tune your card
	to, which you can generate with the scan utility. It needs to find the
	frequency to which to tune initially to find the channels, which is
	provided in one of the subdirectories. For example, to tune to the
	Rowridge transmitter on the Isle of Wight, serving Southern England:

<literallayout><computeroutput>cd /usr/src/linuxtv-dvb-apps-1.1.1/util/scan
./scan dvb-t/uk-Rowridge &gt; ~/channels.conf </computeroutput></literallayout>

	For a list of options run it without any arguments. You can also copy
	the <filename>channels.conf</filename> into
	<filename>~/.mplayer</filename>; recent versions of <ulink
	url="http://mplayerhq.hu">MPlayer</ulink> can then play TV with the
	<literal>dvb://</literal> URI, eg:

<literallayout><computeroutput>mplayer 'dvb://BBC ONE'</computeroutput></literallayout>

	Similarly, <ulink url="http://xinehq.de">Xine</ulink> can interface
	directly with the card:

<literallayout><computeroutput>xine 'dvb://'</computeroutput></literallayout>

Then use its interface or the number keys to select channels.</para>

	<para>Note that many channel names contain spaces and need to be
	quoted on the command line.</para>

	</sect2>

	<sect2> <title>tzap</title>

	<para><command>tzap</command> - or one of its satellite and cable
	counterparts, <command>czap</command> and <command>szap</command> -
	can be used to tune the card to a channel and make its output
	available. All three are in the <filename>util/szap</filename>
	subdirectory of <filename>linuxtv-dvb-apps</filename>. As with
	<command>scan</command>, run it without any arguments for a syntax
	summary. The config file is a list of channels as generated with scan,
	and the <literal>-r</literal> option routes the output to a device
	node (default <filename>/dev/dvb/adapter0/dvr0</filename>) for cards
	with no inbuilt MPEG decoder. For example:

<literallayout><computeroutput>/usr/src/linuxtv-dvb-apps-1.1.1/util/szap/tzap -r -c ~/channels.conf 'BBC ONE'</computeroutput></literallayout>

	You can record the transmission simply with:

<literallayout><computeroutput>cat /dev/dvr/adapter0/dvr0 &gt; recording.ts</computeroutput></literallayout>

	The <filename>.ts</filename> extension is quite arbitrary, but refers to
	the fact that the card's output is in MPEG Transport Stream format.
	<filename>.mpg</filename> files are more usually in Program Stream
	format.</para>

	<para><ulink url="http://mplayerhq.hu">MPlayer</ulink> and
	<ulink url="http://xinehq.de">Xine</ulink> can play tzap's output:

<literallayout><computeroutput>mplayer - &lt; /dev/dvb/adapter0/dvr0</computeroutput></literallayout>

	or

<literallayout><computeroutput>xine stdin://mpeg2 &lt; /dev/dvb/adapter0/dvr0</computeroutput></literallayout>

	</para>

	</sect2>

</sect1>

<sect1> <title>DVB applications</title>

	<para>The kernel's DVB FAQ lists some other useful tools and applications.
	If you want to use your PC as a PVR (Personal Video Recorder), VDR is
	arguably the best for a DVB card, because it was specifically written
	for them. However, with a budget card, lacking an MPEG decoder, you will
	need an output plugin, eg xine. Full details of setting up VDR, or any
	other PVR application, is beyond the scope of this document, but I do
	recommend joining the users' mailing list and using developer versions
	instead of the somewhat outdated 1.2 release.</para>

</sect1>

<sect1> <title>LIRC</title>

	<para>LIRC is a common interface between a variety of Linux applications,
	including MPlayer and Xine, and a variety of IR remote control devices.
	It can use the Nova-T's remote via its <literal>dev/input</literal>
	driver. Unfortunately it generates two events for each application and
	the developers seem to prefer to criticise Linux's input device
	interface than fix their code, so you'll probably need to patch it with
	<ulink url="lirc-devinput-doubleclick.patch">
	lirc-devinput-doubleclick.patch</ulink>.</para>

	<para>I've been told that setting:
	<literallayout>
	repeat_bit 2
	</literallayout>
	in <filename>lircd.conf</filename> cures the problem for some people,
	but it didn't seem to work for me.</para>

	<para>I have also uploaded the following. Please note that on 24 Feb 2006
	I updated <filename>lircd.conf</filename> and
	<filename>lircrc</filename> to use key names consistent with
	<link linkend="inputlirc">inputlirc</link>.</para>

	<variablelist>
	<varlistentry>
	<term>
	<ulink url="lircd.conf">/etc/lirc/lircd.conf</ulink>
	</term>
	<listitem>
	<para>A mapping from devinput codes to LIRC commands.</para>
	</listitem>
	</varlistentry>
	<varlistentry>
	<term>
	<ulink url="lircrc">/etc/lirc/lircrc</ulink>
	</term>
	<listitem>
	<para>Applies the above LIRC commands to MPlayer.</para>
	</listitem>
	</varlistentry>
	<varlistentry>
	<term>
	<ulink url="hardware.conf">/etc/lirc/hardware.conf</ulink>
	</term>
	<listitem>
	<para>
	Instructs LIRC which driver to load etc. My HTPC is headless (no
	keyboard or mouse) so you'll probably need to change the
	<literal>DEVICE</literal> setting for a more conventional PC. Use
	<link linkend="devinputscan">my devinputscan utility</link> to
	determine which device to use.
	</para>
	</listitem>
	</varlistentry>
	</variablelist>

</sect1>

<sect1 id="inputlirc"> <title>inputlirc</title>

	<para>inputlirc is a simplified LIRC daemon which works just for input
		devices. It is described with svn download instructions
		<ulink url="http://www.nabble.com/inputlirc:-zeroconf-LIRC-daemon-using-Linux-input-event-devices-t1095010.html">here</ulink>
		and is also available as a Debian package. It does not suffer from
		the repeat bug in the full version of LIRC, but the repeat delay
		seems a little short. You will need the LIRC client libraries, and
		you may also find <filename>irw</filename> from the LIRC package
		useful to check for key names. For the Nova-T device you can look up 
		the keys in my <ulink url="lircd.conf">/etc/lirc/lircd.conf</ulink>.
	</para>
	
</sect1>

</article>

