From df0eb5882580e5b5479e81ea51eb81bc2aa2ac6d Mon Sep 17 00:00:00 2001
From: Greg Frost <gregfrost1@bigpond.com>
Date: Sun, 22 Nov 2009 17:08:43 +1030
Subject: lirc: send carrier support for lirc_mod_mce

---
 abs/core-testing/lirc/PKGBUILD           |  4 +-
 abs/core-testing/lirc/lirc_mod_mce.patch | 95 ++++++++++++++++++++++++++++++--
 2 files changed, 93 insertions(+), 6 deletions(-)

diff --git a/abs/core-testing/lirc/PKGBUILD b/abs/core-testing/lirc/PKGBUILD
index d15cf1d..df8e22a 100644
--- a/abs/core-testing/lirc/PKGBUILD
+++ b/abs/core-testing/lirc/PKGBUILD
@@ -3,7 +3,7 @@
 
 pkgname=lirc
 pkgver=0.8.5CVS
-pkgrel=15
+pkgrel=16
 _kernver=2.6.28-LinHES
 pkgdesc="Linux Infrared Remote Control kernel modules for stock arch kernel"
 arch=(i686 x86_64)
@@ -79,7 +79,7 @@ md5sums=('b96dae91b566143b3af433fa2714ec9a'
          '6f151eb4e81fc7776a06c9063e6ad9a5'
          '7eccd7826ab99e5cf1b9154171c8b927'
          '21ce358809105f005e888e3b138c59e6'
-         'd299b696b007fc9b663a73cc1758a1ef'
+         '2d64683eba51960a76b80e303df07a5a'
          'f059f4030afc682c9539a03bf837c1cf'
          '4e698654cc44fc6c4163814acda5a7ee'
          '9a3a6dc03647ee6674a166dfb884ddd6'
diff --git a/abs/core-testing/lirc/lirc_mod_mce.patch b/abs/core-testing/lirc/lirc_mod_mce.patch
index 314f2d7..2147ec5 100644
--- a/abs/core-testing/lirc/lirc_mod_mce.patch
+++ b/abs/core-testing/lirc/lirc_mod_mce.patch
@@ -1,6 +1,6 @@
-diff -Naru lirc_mod_mce.orig/lirc_mod_mce.c lirc_mod_mce/lirc_mod_mce.c
---- lirc_mod_mce.orig/lirc_mod_mce.c	2008-04-18 02:12:28.000000000 +0930
-+++ lirc_mod_mce/lirc_mod_mce.c	2009-05-28 07:53:10.000000000 +0930
+diff -Naru lirc_mod_mce/lirc_mod_mce.c lirc_mod_mce_new/lirc_mod_mce.c
+--- lirc_mod_mce/lirc_mod_mce.c	2008-04-18 02:12:28.000000000 +0930
++++ lirc_mod_mce_new/lirc_mod_mce.c	2009-11-22 16:22:41.000000000 +1030
 @@ -171,17 +171,76 @@
  #define VENDOR_TATUNG           0x1460
  #define VENDOR_GATEWAY          0x107b
@@ -86,7 +86,94 @@ diff -Naru lirc_mod_mce.orig/lirc_mod_mce.c lirc_mod_mce/lirc_mod_mce.c
  };
  
  static unsigned char usb_kbd_keycode[256] = {
-@@ -1108,7 +1167,7 @@
+@@ -252,6 +311,8 @@
+     struct semaphore lock;
+     char name[NAME_BUFSIZE];
+     char phys[NAME_BUFSIZE];
++
++    unsigned int carrier_freq;
+ };
+ 
+ /* init strings */
+@@ -889,6 +950,51 @@
+     }
+ }
+ 
++/* Sets the send carrier frequency */
++static int set_send_carrier(struct irctl *ir, int carrier)
++{
++    	int clk = 10000000;
++	int prescaler = 0, divisor = 0;
++	unsigned char cmdbuf[] = { 0x9F, 0x06, 0x01, 0x80 };
++
++	/* Carrier is changed */
++	if (ir->carrier_freq != carrier) {
++
++		if (carrier <= 0) {
++			ir->carrier_freq = carrier;
++			dprintk(DRIVER_NAME "[%d]: SET_CARRIER disabling "
++				"carrier modulation\n", ir->devnum);
++			request_packet_async(ir, ir->usb_ep_out,
++					     cmdbuf, sizeof(cmdbuf),
++					     PHILUSB_OUTBOUND);
++			return carrier;
++		}
++
++		for (prescaler = 0; prescaler < 4; ++prescaler) {
++			divisor = (clk >> (2 * prescaler)) / carrier;
++			if (divisor <= 0xFF) {
++				ir->carrier_freq = carrier;
++				cmdbuf[2] = prescaler;
++				cmdbuf[3] = divisor;
++				dprintk(DRIVER_NAME "[%d]: SET_CARRIER "
++					"requesting %d Hz\n",
++					ir->devnum, carrier);
++
++				/* Transmit new carrier to mce device */
++				request_packet_async(ir, ir->usb_ep_out,
++						     cmdbuf, sizeof(cmdbuf),
++						     PHILUSB_OUTBOUND);
++				return carrier;
++			}
++		}
++
++		return -EINVAL;
++
++	}
++
++	return carrier;
++}
++
+ static int input_open(struct input_dev *id)
+ {
+     return 0;
+@@ -945,6 +1051,15 @@
+         if(lvalue!=(LIRC_MODE_PULSE&LIRC_CAN_SEND_MASK)) return -EINVAL;
+         break;
+ 
++    case LIRC_SET_SEND_CARRIER:
++
++	result = get_user(ivalue, (unsigned int *) arg);
++	if (result)
++	    return result;
++
++	set_send_carrier(ir, ivalue);
++	break;
++
+     default:
+         return -ENOIOCTLCMD;
+     }
+@@ -1047,7 +1162,8 @@
+             plugin->minor = -1;
+             plugin->features = LIRC_CAN_SEND_PULSE |
+                                 LIRC_CAN_SET_TRANSMITTER_MASK |
+-                                LIRC_CAN_REC_MODE2;
++                                LIRC_CAN_REC_MODE2 |
++                                LIRC_CAN_SET_SEND_CARRIER;
+             plugin->data = ir;
+             plugin->rbuf = rbuf;
+             plugin->set_use_inc = &set_use_inc;
+@@ -1108,7 +1224,7 @@
      input_dev->name = ir->name;
      input_dev->phys = ir->phys;
      usb_to_input_id(dev, &input_dev->id);
-- 
cgit v0.12

