From b964f37d22ecbcaedfab7bfdf08b423688907b63 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Thu, 12 Nov 2015 00:23:23 +0000
Subject: linux: update to 3.18.24. add xc5000 patch

---
 abs/core/linux/PKGBUILD                            |  11 ++-
 abs/core/linux/linux.install.pkg                   |   2 +-
 .../linux/xc5000-add_IF_output_level_control.patch | 103 +++++++++++++++++++++
 3 files changed, 112 insertions(+), 4 deletions(-)
 create mode 100644 abs/core/linux/xc5000-add_IF_output_level_control.patch

diff --git a/abs/core/linux/PKGBUILD b/abs/core/linux/PKGBUILD
index 2a4c690..c9fa42a 100644
--- a/abs/core/linux/PKGBUILD
+++ b/abs/core/linux/PKGBUILD
@@ -5,7 +5,7 @@
 pkgbase=linux               # Build stock -ARCH kernel
 #pkgbase=linux-custom       # Build kernel with a different name
 _srcname=linux-3.18
-pkgver=3.18.22
+pkgver=3.18.24
 pkgrel=1
 arch=('i686' 'x86_64')
 url="http://www.kernel.org/"
@@ -21,6 +21,7 @@ source=("https://www.kernel.org/pub/linux/kernel/v3.x/${_srcname}.tar.xz"
         # standard config files for mkinitcpio ramdisk
         'linux.preset'
         'change-default-console-loglevel.patch'
+        'xc5000-add_IF_output_level_control.patch'
         )
 validpgpkeys=(
               'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
@@ -43,6 +44,9 @@ prepare() {
   # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
   patch -p1 -i "${srcdir}/change-default-console-loglevel.patch"
 
+  # xc5000 patches
+  patch -p1 -i "${srcdir}/xc5000-add_IF_output_level_control.patch"
+
   if [ "${CARCH}" = "x86_64" ]; then
     cat "${srcdir}/config.x86_64" > ./.config
   else
@@ -295,8 +299,9 @@ done
 
 # vim:set ts=8 sts=2 sw=2 et:
 md5sums=('9e854df51ca3fef8bfe566dbd7b89241'
-         '04e193d2b3f4d8e3524422534ffe27f2'
+         '3edcf56dba63548978fb66805a1e6167'
          'ed1d392d9feb77674e7a71c3eda060e6'
          'ce7ffe528b5920dc1e8b3d7229a66639'
          'eb14dcfd80c00852ef81ded6e826826a'
-         'df7fceae6ee5d7e7be7b60ecd7f6bb35')
+         'df7fceae6ee5d7e7be7b60ecd7f6bb35'
+         'f8ffc0bf9c01329d21093adce05b9ebb')
diff --git a/abs/core/linux/linux.install.pkg b/abs/core/linux/linux.install.pkg
index fa5ccff..1fc923b 100644
--- a/abs/core/linux/linux.install.pkg
+++ b/abs/core/linux/linux.install.pkg
@@ -2,7 +2,7 @@
 # arg 2:  the old package version
 
 KERNEL_NAME=
-KERNEL_VERSION=3.18.22-1-ARCH
+KERNEL_VERSION=3.18.24-1-ARCH
 
 post_install () {
   # updating module dependencies
diff --git a/abs/core/linux/xc5000-add_IF_output_level_control.patch b/abs/core/linux/xc5000-add_IF_output_level_control.patch
new file mode 100644
index 0000000..b880fd6
--- /dev/null
+++ b/abs/core/linux/xc5000-add_IF_output_level_control.patch
@@ -0,0 +1,103 @@
+From 52e269b133d167a345758cb9d76d6348b3c66ebb Mon Sep 17 00:00:00 2001
+From: Richard Vollkommer <linux@hauppauge.com>
+Date: Sat, 25 Oct 2014 17:17:22 -0300
+Subject: [media] xc5000: add IF output level control
+
+Adds control of the IF output level to the xc5000 tuner
+configuration structure.  Increases the IF level to the
+demodulator to fix failure to lock and picture breakup
+issues (with the au8522 demodulator, in the case of the
+Hauppauge HVR950Q).
+
+This patch works with all XC5000 firmware versions.
+
+Signed-off-by: Richard Vollkommer <linux@hauppauge.com>
+Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
+Reviewed-by: Devin Heitmueller <dheitmueller@kernellabs.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
+---
+ drivers/media/tuners/xc5000.c         | 14 +++++++++++++-
+ drivers/media/tuners/xc5000.h         |  1 +
+ drivers/media/usb/au0828/au0828-dvb.c |  2 ++
+ 3 files changed, 16 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c
+index 803a0e6..705c258 100644
+--- a/drivers/media/tuners/xc5000.c
++++ b/drivers/media/tuners/xc5000.c
+@@ -62,6 +62,7 @@ struct xc5000_priv {
+ 	unsigned int mode;
+ 	u8  rf_mode;
+ 	u8  radio_input;
++	u16  output_amp;
+ 
+ 	int chip_id;
+ 	u16 pll_register_no;
+@@ -744,7 +745,9 @@ static int xc5000_tune_digital(struct dvb_frontend *fe)
+ 		return -EIO;
+ 	}
+ 
+-	xc_write_reg(priv, XREG_OUTPUT_AMP, 0x8a);
++	dprintk(1, "%s() setting OUTPUT_AMP to 0x%x\n",
++		__func__, priv->output_amp);
++	xc_write_reg(priv, XREG_OUTPUT_AMP, priv->output_amp);
+ 
+ 	xc_tune_channel(priv, priv->freq_hz, XC_TUNE_DIGITAL);
+ 
+@@ -1358,6 +1361,9 @@ static int xc5000_set_config(struct dvb_frontend *fe, void *priv_cfg)
+ 	if (p->radio_input)
+ 		priv->radio_input = p->radio_input;
+ 
++	if (p->output_amp)
++		priv->output_amp = p->output_amp;
++
+ 	return 0;
+ }
+ 
+@@ -1438,6 +1444,12 @@ struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
+ 		   it can be overridden if this is a hybrid driver */
+ 		priv->chip_id = (cfg->chip_id) ? cfg->chip_id : 0;
+ 
++	/* don't override output_amp if it's already been set
++	   unless explicitly specified */
++	if ((priv->output_amp == 0) || (cfg->output_amp))
++		/* use default output_amp value if none specified */
++		priv->output_amp = (cfg->output_amp) ? cfg->output_amp : 0x8a;
++
+ 	/* Check if firmware has been loaded. It is possible that another
+ 	   instance of the driver has loaded the firmware.
+ 	 */
+diff --git a/drivers/media/tuners/xc5000.h b/drivers/media/tuners/xc5000.h
+index 7245cae..6aa534f 100644
+--- a/drivers/media/tuners/xc5000.h
++++ b/drivers/media/tuners/xc5000.h
+@@ -36,6 +36,7 @@ struct xc5000_config {
+ 	u32  if_khz;
+ 	u8   radio_input;
+ 	u16  xtal_khz;
++	u16  output_amp;
+ 
+ 	int chip_id;
+ };
+diff --git a/drivers/media/usb/au0828/au0828-dvb.c b/drivers/media/usb/au0828/au0828-dvb.c
+index 00ab1563..c267d76 100644
+--- a/drivers/media/usb/au0828/au0828-dvb.c
++++ b/drivers/media/usb/au0828/au0828-dvb.c
+@@ -88,12 +88,14 @@ static struct xc5000_config hauppauge_xc5000a_config = {
+ 	.i2c_address      = 0x61,
+ 	.if_khz           = 6000,
+ 	.chip_id          = XC5000A,
++	.output_amp       = 0x8f,
+ };
+ 
+ static struct xc5000_config hauppauge_xc5000c_config = {
+ 	.i2c_address      = 0x61,
+ 	.if_khz           = 6000,
+ 	.chip_id          = XC5000C,
++	.output_amp       = 0x8f,
+ };
+ 
+ static struct mxl5007t_config mxl5007t_hvr950q_config = {
+-- 
+cgit v0.11.2-5-g481e
+
-- 
cgit v0.12

