AVerMedia A828

From LinuxTVWiki
Revision as of 21:06, 16 April 2012 by Vquicksilver (talk | contribs) (→‎Modifications to bring)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

AVermedia DVB-T A828 was compatible with Linux until the version 2.6.37 of the kernel. Since this version, the Big Kernel Lock (BKL) is disabled by default. Thus, many of drivers using it have to be updated. The Linux driver for A828 belongs to this kind of driver. We will see above how to ensure the compatibility with it.


Script all in one to execute

Here is a script installing automatically the A828 driver, and use dkms to automate the installation with all the kernels. Download the script

Just download the script, and run ./install.sh.

NOTE : you will need Make and Dkms packages. ("apt-get install dkms make" if you are on a Debian/Ubuntu based distribution ...)

Feel free to modify this little script if needed.

Warning

This tipp have only been tested by me. I am not friendly with V4L nor with driver coding. It would be great if someone can test, give feedback, and correct if necessary. Thanks in advance.

Download And Prepare the installation

First, if you hadn't download it yet, download the driver from this page : http://www.avermedia.com/avertv/support/Download.aspx?Type=APDriver&tab=APDriver&id=31

Extract the archive where you want to. Then, run a terminal, and type those commands :

  cd /where/you/put/A828_Installer_...
  sudo sh AVERMEDIA-Linux-x64-A828-0.28-beta.sh

You will be asked if you want the normal installation or the expert one. Choose Expert.

Choose a directory for the output... Then :

 cd /where/you/put/A828-expert-install/

Now, we will apply the modifications.


Modifications to bring

1. In aver/osdep.c : 
        1.a If Kernel >= 2.6.37 then remove line :
                #include <linux/smp_lock.h>
	1.b Replace : 
		void SysLockKernel()
		{
			lock_kernel();
		}

		void SysUnlockKernel()
		{
			unlock_kernel();
		}
		
	  By : 
		static DEFINE_MUTEX(dvbdev_mutex);
		void SysLockKernel()
		{
			mutex_lock(&dvbdev_mutex);
		}

		void SysUnlockKernel()
		{
			mutex_unlock(&dvbdev_mutex);
		}
	
	1.c As per previous instructions (can't include because blocked by spam filter)	

2. In aver/osdep_th2.c :
	2.a After : 
		#include "osdep_th2.h"
	    Add : 
		#include "osdep.h"
        2.b If Kernel >= 2.6.37 then remove line :
                #include <linux/smp_lock.h>
	2.c Replace : 
		lock_kernel();
	    By : 
		SysLockKernel();
	
	2.d and Replace : 
		unlock_kernel();
	    By:
		SysUnlockKernel();
		
3. In aver/osdep_v4l2.c :
	3.a After : 
		#include "debug.h"
	    Add : 
		#define VFL_TYPE_VTX    3
        3.b If Kernel >= 2.6.37 then remove line :
                #include <linux/smp_lock.h>
4. In aver/osdep_dvb.c :
        If Kernel >= 2.6.37 then remove line :
                #include <linux/smp_lock.h>
5. Run : 
	sed -i 's/param_array_[gs]et/param_array_ops/g' *
	sed -i 's/param_array_[gs]et/param_array_ops/g' aver/*

6. Run : 
        make

7. Run : 
	sudo modprobe dmx3191d
	sudo modprobe v4l2-common
        sudo modprobe dvb-core
	sudo insmod ./averusba828.ko
	sudo insmod ./a828.ko

8. To make modules ./averusba828.ko and ./a828.ko available after reboot :
        cp ./averusba828.ko /lib/modules/`uname -r`/kernel/drivers/media/dvb/dvbusb
        cp ./a828.ko /lib/modules/`uname -r`/kernel/drivers/media/dvb/dvbusb

If you are using Linux kernel 3.3.1 you will need to apply this patch:

diff --git a/aver/osdep_dvb.c b/aver/osdep_dvb.c
index eb20708..cc95702 100644
--- a/aver/osdep_dvb.c
+++ b/aver/osdep_dvb.c
@@ -84,6 +84,7 @@ shall govern.
 #include <linux/dvb/ca.h>
 #include <linux/dvb/osd.h>
 #include <linux/dvb/net.h>
+#include <linux/dvb/frontend.h>
 
 #include "dvbdev.h"
 #include "demux.h"
@@ -166,10 +167,12 @@ static int dvb_fe_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg);
 #endif
 static int demux_sw_start_feed(struct dvb_demux_feed *feed);
 static int demux_sw_stop_feed(struct dvb_demux_feed *feed);
+#if defined(__DVB_CORE__) || !defined (__KERNEL__)
 static int dvbfe_set_parameters(struct dvb_frontend *fe,
 			struct dvb_frontend_parameters *param);
 static int dvbfe_get_parameters(struct dvb_frontend *fe,
 			struct dvb_frontend_parameters *param);
+#endif
 static int dvbfe_read_status(struct dvb_frontend* fe, fe_status_t* status);
 static int dvbfe_read_ber(struct dvb_frontend* fe, u32* ber);
 static int dvbfe_read_signal_strength(struct dvb_frontend* fe, u16* strength);
@@ -274,8 +277,10 @@ int SysDVBRegisterFrontend(dvb_t dev, struct dvb_frontend_info *info,
 
 	p->fe.ops.info = *info;
 	p->fe.ops.release = dvbfe_release;
+#if defined(__DVB_CORE__) || !defined (__KERNEL__)
 	p->fe.ops.set_frontend = dvbfe_set_parameters;
 	p->fe.ops.get_frontend = dvbfe_get_parameters;
+#endif
 	p->fe.ops.read_status = dvbfe_read_status;
 	p->fe.ops.read_ber = dvbfe_read_ber;
 	p->fe.ops.read_signal_strength =
@@ -751,6 +756,7 @@ static int demux_sw_stop_feed(struct dvb_demux_feed *feed)
 	return status;
 }
 
+#if defined(__DVB_CORE__) || !defined (__KERNEL__)
 static int dvbfe_set_parameters(struct dvb_frontend *fe,
 				struct dvb_frontend_parameters *param)
 {
@@ -766,6 +772,7 @@ static int dvbfe_get_parameters(struct dvb_frontend *fe,
 	DBG_fCDVB("calling GetParameters()\n");
 	return GetParameters(p->context, param);
 }
+#endif
 
 static int dvbfe_read_status(struct dvb_frontend* fe, fe_status_t* status)
 {
diff --git a/aver/osdep_dvb.h b/aver/osdep_dvb.h
index 884827b..01b5583 100644
--- a/aver/osdep_dvb.h
+++ b/aver/osdep_dvb.h
@@ -123,8 +123,10 @@ int GetStatus(void *context, fe_status_t *stat);
 int GetBER(void *context, unsigned int *ber);
 int GetSignalStrength(void *context, unsigned short *signal);
 int GetSNR(void *context, unsigned short *snr);
+#if defined(__DVB_CORE__) || !defined (__KERNEL__)
 int SetParameters(void *context, struct dvb_frontend_parameters *param);
 int GetParameters(void *context, struct dvb_frontend_parameters *param);
+#endif
 int FEInit(void *context);
 int FESleep(void *context);