rpms/kernel/F-8 linux-2.6-firewire-git-update.patch, NONE, 1.1 kernel.spec, 1.314, 1.315 linux-2.6-lirc.patch, 1.3, 1.4

Jarod Wilson (jwilson) fedora-extras-commits at redhat.com
Fri Jan 11 22:21:34 UTC 2008


Author: jwilson

Update of /cvs/pkgs/rpms/kernel/F-8
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv28118

Modified Files:
	kernel.spec linux-2.6-lirc.patch 
Added Files:
	linux-2.6-firewire-git-update.patch 
Log Message:
* Fri Jan 11 2008 Jarod Wilson <jwilson at redhat.com> 2.6.23.13-106
- FireWire update, should enable iidc reception on all controllers
- Update lirc bits to latest upstream


linux-2.6-firewire-git-update.patch:

--- NEW FILE linux-2.6-firewire-git-update.patch ---
IEEE 1394 updates for Linux 2.6.23 (v601 2008-01-11)

 drivers/firewire/fw-cdev.c               |   57 +
 drivers/firewire/fw-device.h             |    5 
 drivers/firewire/fw-ohci.c               |  528 ++++++++++++-----
 drivers/firewire/fw-ohci.h               |    2 
 drivers/firewire/fw-sbp2.c               |  700 +++++++++++++----------
 drivers/firewire/fw-topology.c           |   10 
 drivers/firewire/fw-topology.h           |    6 
 drivers/firewire/fw-transaction.c        |   16 
 drivers/ieee1394/csr1212.c               |   57 -
 drivers/ieee1394/csr1212.h               |    6 
 drivers/ieee1394/dma.c                   |   37 -
 drivers/ieee1394/eth1394.c               |   16 
 drivers/ieee1394/ieee1394_core.c         |    2 
 drivers/ieee1394/ieee1394_transactions.c |   70 --
 drivers/ieee1394/nodemgr.c               |   22 
 drivers/ieee1394/ohci1394.c              |   12 
 drivers/ieee1394/pcilynx.c               |   29 
 drivers/ieee1394/raw1394.c               |    4 
 drivers/ieee1394/sbp2.c                  |   41 -
 drivers/ieee1394/sbp2.h                  |    1 
 include/linux/firewire-cdev.h            |   15 
 21 files changed, 1000 insertions(+), 636 deletions(-)

========================================================================
Date: Sun, 06 Jan 2008 17:21:41 -0500
From: David Moore <dcm at MIT.EDU>
Subject: firewire: fw-ohci: Dynamically allocate buffers for DMA descriptors

Previously, the fw-ohci driver used fixed-length buffers for storing
descriptors for isochronous receive DMA programs.  If an application
(such as libdc1394) generated a DMA program that was too large, fw-ohci
would reach the limit of its fixed-sized buffer and return an error to
userspace.

This patch replaces the fixed-length ring-buffer with a linked-list of
page-sized buffers.  Additional buffers can be dynamically allocated and
appended to the list when necessary.  For a particular context, buffers
are kept around after use and reused as necessary, so there is no
allocation taking place after the DMA program is generated for the first
time.

In addition, the buffers it uses are coherent for DMA so there is no
syncing required before and after writes.  This syncing wasn't properly
done in the previous version of the code.

-

This is the fourth version of my patch that replaces a fixed-length
buffer for DMA descriptors with a dynamically allocated linked-list of
buffers.

As we discovered with the last attempt, new context programs are
sometimes queued from interrupt context, making it unacceptable to call
tasklet_disable() from context_get_descriptors().

This version of the patch uses ohci->lock for all locking needs instead
of tasklet_disable/enable.  There is a new requirement that
context_get_descriptors() be called while holding ohci->lock.  It was
already held for the AT context, so adding the requirement for the iso
context did not seem particularly onerous.  In addition, this has the
side benefit of allowing iso queue to be safely called from concurrent
user-space threads, which previously was not safe.

Signed-off-by: David Moore <dcm at acm.org>
Signed-off-by: Kristian Høgsberg <krh at redhat.com>
Signed-off-by: Jarod Wilson <jwilson at redhat.com>

-

Fixes the following issues:
  - Isochronous reception stopped prematurely if an application used a
    larger buffer.  (Reproduced with coriander.)
  - Isochronous reception stopped after one or a few frames on VT630x
    in OHCI 1.0 mode.  (Fixes reception in coriander, but dvgrab still
    doesn't work with these chips.)

Patch update: struct member alignment, whitespace nits

Signed-off-by: Stefan Richter <stefanr at s5r6.in-berlin.de>
---
 drivers/firewire/fw-ohci.c |  232 ++++++++++++++++++++++++-------------
 1 file changed, 154 insertions(+), 78 deletions(-)

========================================================================
Date: Sat, 22 Dec 2007 22:14:52 +0100 (CET)
From: Stefan Richter <stefanr at s5r6.in-berlin.de>
Subject: firewire: fw-ohci: CycleTooLong interrupt management

The firewire-ohci driver so far lacked the ability to resume cycle
master duty after that condition happened, as added to ohci1394 in Linux
2.6.18 by commit 57fdb58fa5a140bdd52cf4c4ffc30df73676f0a5.  This ports
this patch to fw-ohci.

The "cycle too long" condition has been seen in practice
  - with IIDC cameras if a mode with packets too large for a speed is
    chosen,
  - sporadically when capturing DV on a VIA VT6306 card with ohci1394/
    ieee1394/ raw1394/ dvgrab 2.
    https://bugzilla.redhat.com/show_bug.cgi?id=415841#c7
(This does not fix Fedora bug 415841.)

Signed-off-by: Stefan Richter <stefanr at s5r6.in-berlin.de>
---
 drivers/firewire/fw-ohci.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

========================================================================
Date: Fri, 21 Dec 2007 23:02:15 +0530
From: Rabin Vincent <rabin at rab.in>
Subject: firewire: Fix extraction of source node id

Fix extraction of the source node id from the packet header.

Signed-off-by: Rabin Vincent <rabin at rab.in>
Signed-off-by: Stefan Richter <stefanr at s5r6.in-berlin.de>
---
 drivers/firewire/fw-transaction.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

========================================================================
Date: Wed, 19 Dec 2007 15:26:38 -0500
From: David Moore <dcm at MIT.EDU>
Subject: firewire: fw-ohci: Bug fixes for packet-per-buffer support

This patch corrects a number of bugs in the current OHCI 1.0
packet-per-buffer support:

1. Correctly deal with payloads that cross a page boundary.  The
previous version would not split the descriptor at such a boundary,
potentially corrupting unrelated memory.

2. Allow user-space to specify multiple packets per struct
fw_cdev_iso_packet in the same way that dual-buffer allows.  This is
signaled by header_length being a multiple of header_size.  This
multiple determines the number of packets.  The payload size allocated
per packet is determined by dividing the total payload size by the
number of packets.

3. Make sync support work properly for packet-per-buffer.

I have tested this patch with libdc1394 by forcing my OHCI 1.1
controller to use the packet-per-buffer support instead of dual-buffer.

I would greatly appreciate testing by those who have a DV devices and
other types of iso streamers to make sure I didn't cause any
regressions.

Stefan, with this patch, I'm hoping that libdc1394 will work with all
your OHCI 1.0 controllers now.

The one bit of future work that remains for packet-per-buffer support is
the automatic compaction of short payloads that I discussed with
Kristian.

Signed-off-by: David Moore <dcm at acm.org>
Signed-off-by: Stefan Richter <stefanr at s5r6.in-berlin.de>
---
 drivers/firewire/fw-ohci.c |   99 ++++++++++++++++++-------------------
 1 file changed, 49 insertions(+), 50 deletions(-)

========================================================================
Date: Wed, 19 Dec 2007 03:09:18 -0500
From: David Moore <dcm at MIT.EDU>
Subject: firewire: fw-ohci: Fix for dualbuffer three-or-more buffers

This patch fixes the problem where different OHCI 1.1 controllers behave
differently when a received iso packet straddles three or more buffers
when using the dual-buffer receive mode.  Two changes are made in order
to handle this situation:

1. The packet sync DMA descriptor is given a non-zero header length and
non-zero payload length.  This is because zero-payload descriptors are
not discussed in the OHCI 1.1 specs and their behavior is thus
undefined.  Instead we use a header size just large enough for a single
header and a payload length of 4 bytes for this first descriptor.

2. As we process received packets in the context's tasklet, read the
packet length out of the headers.  Keep track of the running total of
the packet length as "excess_bytes", so we can ignore any descriptors
where no packet starts or ends.  These descriptors may not have had
their first_res_count or second_res_count fields updated by the
controller so we cannot rely on those values.

The main drawback of this patch is that the excess_bytes value might get
"out of sync" with the packet descriptors if something strange happens
to the DMA program.  I'm not if such a thing could ever happen, but I
appreciate any suggestions in making it more robust.

Also, the packet-per-buffer support may need a similar fix to deal with
issue 1, but I haven't done any work on that yet.

Stefan, I'm hoping that with this patch, all your OHCI 1.1 controllers
will work properly with an unmodified version of libdc1394.

Signed-off-by: David Moore <dcm at acm.org>
Signed-off-by: Stefan Richter <stefanr at s5r6.in-berlin.de>
---
[...3440 lines suppressed...]
 	case ACK_BUSY_A:
@@ -282,7 +281,6 @@ int hpsb_packet_success(struct hpsb_pack
 			 packet->ack_code, packet->node_id, packet->tcode);
 		return -EAGAIN;
 	}
-	BUG();
 }
 
 struct hpsb_packet *hpsb_make_readpacket(struct hpsb_host *host, nodeid_t node,
@@ -572,71 +570,3 @@ int hpsb_write(struct hpsb_host *host, n
 
 	return retval;
 }
-
-#if 0
-
-int hpsb_lock(struct hpsb_host *host, nodeid_t node, unsigned int generation,
-	      u64 addr, int extcode, quadlet_t * data, quadlet_t arg)
-{
-	struct hpsb_packet *packet;
-	int retval = 0;
-
-	BUG_ON(in_interrupt());	// We can't be called in an interrupt, yet
-
-	packet = hpsb_make_lockpacket(host, node, addr, extcode, data, arg);
-	if (!packet)
-		return -ENOMEM;
-
-	packet->generation = generation;
-	retval = hpsb_send_packet_and_wait(packet);
-	if (retval < 0)
-		goto hpsb_lock_fail;
-
-	retval = hpsb_packet_success(packet);
-
-	if (retval == 0) {
-		*data = packet->data[0];
-	}
-
-      hpsb_lock_fail:
-	hpsb_free_tlabel(packet);
-	hpsb_free_packet(packet);
-
-	return retval;
-}
-
-int hpsb_send_gasp(struct hpsb_host *host, int channel, unsigned int generation,
-		   quadlet_t * buffer, size_t length, u32 specifier_id,
-		   unsigned int version)
-{
-	struct hpsb_packet *packet;
-	int retval = 0;
-	u16 specifier_id_hi = (specifier_id & 0x00ffff00) >> 8;
-	u8 specifier_id_lo = specifier_id & 0xff;
-
-	HPSB_VERBOSE("Send GASP: channel = %d, length = %Zd", channel, length);
-
-	length += 8;
-
-	packet = hpsb_make_streampacket(host, NULL, length, channel, 3, 0);
-	if (!packet)
-		return -ENOMEM;
-
-	packet->data[0] = cpu_to_be32((host->node_id << 16) | specifier_id_hi);
-	packet->data[1] =
-	    cpu_to_be32((specifier_id_lo << 24) | (version & 0x00ffffff));
-
-	memcpy(&(packet->data[2]), buffer, length - 8);
-
-	packet->generation = generation;
-
-	packet->no_waiter = 1;
-
-	retval = hpsb_send_packet(packet);
-	if (retval < 0)
-		hpsb_free_packet(packet);
-
-	return retval;
-}
-
-#endif				/*  0  */
Index: linux-2.6.23/drivers/ieee1394/raw1394.c
===================================================================
--- linux-2.6.23.orig/drivers/ieee1394/raw1394.c
+++ linux-2.6.23/drivers/ieee1394/raw1394.c
@@ -858,7 +858,7 @@ static int arm_read(struct hpsb_host *ho
 	int found = 0, size = 0, rcode = -1;
 	struct arm_request_response *arm_req_resp = NULL;
 
-	DBGMSG("arm_read  called by node: %X"
+	DBGMSG("arm_read  called by node: %X "
 	       "addr: %4.4x %8.8x length: %Zu", nodeid,
 	       (u16) ((addr >> 32) & 0xFFFF), (u32) (addr & 0xFFFFFFFF),
 	       length);
@@ -1012,7 +1012,7 @@ static int arm_write(struct hpsb_host *h
 	int found = 0, size = 0, rcode = -1, length_conflict = 0;
 	struct arm_request_response *arm_req_resp = NULL;
 
-	DBGMSG("arm_write called by node: %X"
+	DBGMSG("arm_write called by node: %X "
 	       "addr: %4.4x %8.8x length: %Zu", nodeid,
 	       (u16) ((addr >> 32) & 0xFFFF), (u32) (addr & 0xFFFFFFFF),
 	       length);
Index: linux-2.6.23/drivers/ieee1394/dma.c
===================================================================
--- linux-2.6.23.orig/drivers/ieee1394/dma.c
+++ linux-2.6.23/drivers/ieee1394/dma.c
@@ -232,37 +232,24 @@ void dma_region_sync_for_device(struct d
 
 #ifdef CONFIG_MMU
 
-/* nopage() handler for mmap access */
-
-static struct page *dma_region_pagefault(struct vm_area_struct *area,
-					 unsigned long address, int *type)
+static int dma_region_pagefault(struct vm_area_struct *vma,
+				struct vm_fault *vmf)
 {
-	unsigned long offset;
-	unsigned long kernel_virt_addr;
-	struct page *ret = NOPAGE_SIGBUS;
-
-	struct dma_region *dma = (struct dma_region *)area->vm_private_data;
+	struct dma_region *dma = (struct dma_region *)vma->vm_private_data;
 
 	if (!dma->kvirt)
-		goto out;
+		return VM_FAULT_SIGBUS;
 
-	if ((address < (unsigned long)area->vm_start) ||
-	    (address >
-	     (unsigned long)area->vm_start + (dma->n_pages << PAGE_SHIFT)))
-		goto out;
-
-	if (type)
-		*type = VM_FAULT_MINOR;
-	offset = address - area->vm_start;
-	kernel_virt_addr = (unsigned long)dma->kvirt + offset;
-	ret = vmalloc_to_page((void *)kernel_virt_addr);
-	get_page(ret);
-      out:
-	return ret;
+	if (vmf->pgoff >= dma->n_pages)
+		return VM_FAULT_SIGBUS;
+
+	vmf->page = vmalloc_to_page(dma->kvirt + (vmf->pgoff << PAGE_SHIFT));
+	get_page(vmf->page);
+	return 0;
 }
 
 static struct vm_operations_struct dma_region_vm_ops = {
-	.nopage = dma_region_pagefault,
+	.fault = dma_region_pagefault,
 };
 
 /**
@@ -276,7 +263,7 @@ int dma_region_mmap(struct dma_region *d
 	if (!dma->kvirt)
 		return -EINVAL;
 
-	/* must be page-aligned */
+	/* must be page-aligned (XXX: comment is wrong, we could allow pgoff) */
 	if (vma->vm_pgoff != 0)
 		return -EINVAL;
 
Index: linux-2.6.23/drivers/ieee1394/sbp2.h
===================================================================
--- linux-2.6.23.orig/drivers/ieee1394/sbp2.h
+++ linux-2.6.23/drivers/ieee1394/sbp2.h
@@ -222,7 +222,6 @@ struct sbp2_status_block {
  */
 
 #define SBP2_MAX_SG_ELEMENT_LENGTH		0xf000
-#define SBP2_MAX_SECTORS			255
 /* There is no real limitation of the queue depth (i.e. length of the linked
  * list of command ORBs) at the target. The chosen depth is merely an
  * implementation detail of the sbp2 driver. */
Index: linux-2.6.23/drivers/ieee1394/ohci1394.c
===================================================================
--- linux-2.6.23.orig/drivers/ieee1394/ohci1394.c
+++ linux-2.6.23/drivers/ieee1394/ohci1394.c
@@ -2126,10 +2126,14 @@ static void ohci_schedule_iso_tasklets(s
 	list_for_each_entry(t, &ohci->iso_tasklet_list, link) {
 		mask = 1 << t->context;
 
-		if (t->type == OHCI_ISO_TRANSMIT && tx_event & mask)
-			tasklet_schedule(&t->tasklet);
-		else if (rx_event & mask)
-			tasklet_schedule(&t->tasklet);
+		if (t->type == OHCI_ISO_TRANSMIT) {
+			if (tx_event & mask)
+				tasklet_schedule(&t->tasklet);
+		} else {
+			/* OHCI_ISO_RECEIVE or OHCI_ISO_MULTICHANNEL_RECEIVE */
+			if (rx_event & mask)
+				tasklet_schedule(&t->tasklet);
+		}
 	}
 
 	spin_unlock_irqrestore(&ohci->iso_tasklet_list_lock, flags);


Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-8/kernel.spec,v
retrieving revision 1.314
retrieving revision 1.315
diff -u -r1.314 -r1.315
--- kernel.spec	10 Jan 2008 23:22:50 -0000	1.314
+++ kernel.spec	11 Jan 2008 22:20:56 -0000	1.315
@@ -744,7 +744,6 @@
 Patch1504: linux-2.6-xfs-optimize-away-realtime-tests.patch
 Patch1505: linux-2.6-xfs-refactor-xfs_mountfs.patch
 Patch1509: linux-2.6-xfs-setfattr-32bit-compat.patch
-Patch1512: linux-2.6-firewire-multi-lun.patch
 Patch1515: linux-2.6-lirc.patch
 Patch1520: linux-2.6-dcdbas-autoload.patch
 
@@ -756,10 +755,9 @@
 Patch1802: linux-2.6-drm-radeon-update.patch
 Patch1803: linux-2.6-git-initial-r500-drm.patch
 
-# Fix lockdep bug in firewire.
-Patch1900: linux-2.6-firewire-lockdep.patch
-# OHCI 1.0 isochronous receive support
-Patch1910: linux-2.6-firewire-ohci-1.0-iso-receive.patch
+# Updated firewire stack from linux1394 git
+# snap from http://me.in-berlin.de/~s5r6/linux1394/updates/2.6.23/
+Patch1910: linux-2.6-firewire-git-update.patch
 # Work around E100 NAPI bug
 Patch2000: linux-2.6-net-e100-disable-polling.patch
 # fix thinkpad key events for volume/brightness
@@ -1429,19 +1427,15 @@
 ApplyPatch linux-2.6-pass-g-to-assembler-under-config_debug_info.patch
 ApplyPatch linux-2.6-powerpc-lparmap-g.patch
 
-#
-# The multi-lun patch fixes #242254, but won't be in 2.6.23.
-#
-ApplyPatch linux-2.6-firewire-multi-lun.patch
-
 # http://www.lirc.org/
 ApplyPatch linux-2.6-lirc.patch
 
 # DMI autoloading for dcdbas driver
 ApplyPatch linux-2.6-dcdbas-autoload.patch
 
-ApplyPatch linux-2.6-firewire-lockdep.patch
-ApplyPatch linux-2.6-firewire-ohci-1.0-iso-receive.patch
+# FireWire updates and fixes
+ApplyPatch linux-2.6-firewire-git-update.patch
+
 ApplyPatch linux-2.6-net-e100-disable-polling.patch
 ApplyPatch linux-2.6-thinkpad-key-events.patch
 
@@ -2053,6 +2047,10 @@
 
 
 %changelog
+* Fri Jan 11 2008 Jarod Wilson <jwilson at redhat.com> 2.6.23.13-106
+- FireWire update, should enable iidc reception on all controllers
+- Update lirc bits to latest upstream
+
 * Thu Jan 10 2008 John W. Linville <linville at redhat.com> 2.6.23.13-105
 - rt2500usb thinko fix
 - b43 N phy pre-support updates

linux-2.6-lirc.patch:

View full diff with command:
/usr/bin/cvs -f diff  -kk -u -N -r 1.3 -r 1.4 linux-2.6-lirc.patch
Index: linux-2.6-lirc.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-8/linux-2.6-lirc.patch,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- linux-2.6-lirc.patch	13 Sep 2007 18:17:42 -0000	1.3
+++ linux-2.6-lirc.patch	11 Jan 2008 22:20:56 -0000	1.4
@@ -1,8 +1,43 @@
+Linux Infrared Remote Control drivers (http://lirc.org/)
+
+Signed-off-by: Jarod Wilson <jwilson at redhat.com>
+
+ drivers/input/Kconfig                 |    2 +
+ drivers/input/Makefile                |    1 +
+ drivers/input/lirc/Kconfig            |  127 +++
+ drivers/input/lirc/Makefile           |   24 +
+ drivers/input/lirc/commandir.c        | 1009 +++++++++++++++++++++++
+ drivers/input/lirc/commandir.h        |   41 +
+ drivers/input/lirc/kcompat.h          |  150 ++++
+ drivers/input/lirc/lirc.h             |  101 +++
+ drivers/input/lirc/lirc_atiusb.c      | 1326 ++++++++++++++++++++++++++++++
+ drivers/input/lirc/lirc_bt829.c       |  393 +++++++++
+ drivers/input/lirc/lirc_cmdir.c       |  605 ++++++++++++++
+ drivers/input/lirc/lirc_cmdir.h       |   27 +
+ drivers/input/lirc/lirc_dev.c         |  827 +++++++++++++++++++
+ drivers/input/lirc/lirc_dev.h         |  264 ++++++
+ drivers/input/lirc/lirc_i2c.c         |  671 +++++++++++++++
+ drivers/input/lirc/lirc_igorplugusb.c |  624 ++++++++++++++
+ drivers/input/lirc/lirc_imon.c        | 1165 +++++++++++++++++++++++++++
+ drivers/input/lirc/lirc_it87.c        | 1012 +++++++++++++++++++++++
+ drivers/input/lirc/lirc_it87.h        |  116 +++
+ drivers/input/lirc/lirc_mceusb.c      |  890 ++++++++++++++++++++
+ drivers/input/lirc/lirc_mceusb2.c     | 1042 ++++++++++++++++++++++++
+ drivers/input/lirc/lirc_parallel.c    |  745 +++++++++++++++++
+ drivers/input/lirc/lirc_parallel.h    |   26 +
+ drivers/input/lirc/lirc_pvr150.c      | 1431 +++++++++++++++++++++++++++++++++
+ drivers/input/lirc/lirc_sasem.c       |  971 ++++++++++++++++++++++
+ drivers/input/lirc/lirc_serial.c      | 1348 +++++++++++++++++++++++++++++++
+ drivers/input/lirc/lirc_sir.c         | 1323 ++++++++++++++++++++++++++++++
+ drivers/input/lirc/lirc_streamzap.c   |  810 +++++++++++++++++++
+ drivers/input/lirc/lirc_ttusbir.c     |  393 +++++++++
+ 29 files changed, 17464 insertions(+), 0 deletions(-)
+
 diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
-index 2d87357..61fd0ca 100644
+index 63512d9..de4b170 100644
 --- a/drivers/input/Kconfig
 +++ b/drivers/input/Kconfig
-@@ -183,5 +183,7 @@ source "drivers/input/gameport/Kconfig"
+@@ -161,5 +161,7 @@ source "drivers/input/gameport/Kconfig"
  
  endmenu
  
@@ -11,15 +46,14 @@
  endmenu
  
 diff --git a/drivers/input/Makefile b/drivers/input/Makefile
-index 15eb752..195d342 100644
+index 99af903..78b0420 100644
 --- a/drivers/input/Makefile
 +++ b/drivers/input/Makefile
-@@ -22,4 +22,4 @@ obj-$(CONFIG_INPUT_JOYSTICK)	+= joystick/
- obj-$(CONFIG_INPUT_TABLET)	+= tablet/
+@@ -22,3 +22,4 @@ obj-$(CONFIG_INPUT_TABLET)	+= tablet/
  obj-$(CONFIG_INPUT_TOUCHSCREEN)	+= touchscreen/
  obj-$(CONFIG_INPUT_MISC)	+= misc/
--
-+obj-$(CONFIG_INPUT_LIRC)	+= lirc/
+ 
++obj-$(CONFIG_INPUT_LIRC)       += lirc/
 diff --git a/drivers/input/lirc/Kconfig b/drivers/input/lirc/Kconfig
 new file mode 100644
 index 0000000..138e58a
@@ -185,10 +219,10 @@
 +obj-$(CONFIG_LIRC_TTUSBIR)	+= lirc_ttusbir.o
 diff --git a/drivers/input/lirc/commandir.c b/drivers/input/lirc/commandir.c
 new file mode 100644
-index 0000000..32f46aa
+index 0000000..a49d996
 --- /dev/null
 +++ b/drivers/input/lirc/commandir.c
-@@ -0,0 +1,999 @@
+@@ -0,0 +1,1009 @@
 +
 +/*
 + *
@@ -275,8 +309,7 @@
 +int debug_commandir;
 +
 +/* Structure to hold all of our device specific stuff */
-+struct usb_skel
-+{
++struct usb_skel {
 +	struct usb_device *udev; /* the usb device for this device */
 +	struct usb_interface *interface; /* the interface for this device */
 +	unsigned char *bulk_in_buffer; /* the buffer to receive data */
@@ -447,7 +480,8 @@
 +
 +	/* check whether minor already includes base */
 +	minor = interface->minor;
-+	if (minor >= USB_CMDIR_MINOR_BASE) minor = minor-USB_CMDIR_MINOR_BASE;
++	if (minor >= USB_CMDIR_MINOR_BASE)
++		minor = minor-USB_CMDIR_MINOR_BASE;
 +
 +	/* let the user know what node this device is now attached to */
 +	info("CommandIR USB device now attached to commandir%d", minor);
@@ -462,6 +496,7 @@
 +	return retval;
 +}
 +
++
 +static void cmdir_disconnect(struct usb_interface *interface)
 +{
 +	struct usb_skel *dev;
@@ -482,7 +517,8 @@
 +		kref_put(&dev->kref, cmdir_delete);
 +
 +	/* check whether minor already includes base */
-+	if (minor >= USB_CMDIR_MINOR_BASE) minor = minor-USB_CMDIR_MINOR_BASE;
++	if (minor >= USB_CMDIR_MINOR_BASE)
++		minor = minor-USB_CMDIR_MINOR_BASE;
 +
 +	info("CommandIR #%d now disconnected", minor);
 +
@@ -491,7 +527,8 @@
 +		/* decrement until find next valid device */
 +		while (rx_device > 0) {
 +			rx_device--;
-+			if (cmdir_check(rx_device) == 0) break;
++			if (cmdir_check(rx_device) == 0)
++				break;
 +		}
 +		if (minor > 0)
 +			info("Active Receiver is on CommandIR #%d", rx_device);
@@ -509,7 +546,7 @@
 +		return -ENODEV;
 +
 +	/* decrement the count on our device */
-+	kref_put(&dev->kref, cmdir_delete);
++		kref_put(&dev->kref, cmdir_delete);
 +	return retval;
 +}
 +
@@ -595,19 +632,22 @@
 +	}
 +	if (transmitters & (multiplier*0x02)) {
 +		cmdir_var[next_pos] = '2';
-+		if (next_comma > 0) cmdir_var[next_pos-2] = ',';
++		if (next_comma > 0)
++			cmdir_var[next_pos-2] = ',';
 +		next_pos += 3;
 +		next_comma++;
 +	}
 +	if (transmitters & (multiplier*0x04)) {
 +		cmdir_var[next_pos] = '3';
-+		if (next_comma > 0) cmdir_var[next_pos-2] = ',';
++		if (next_comma > 0)
++			cmdir_var[next_pos-2] = ',';
 +		next_pos += 3;
 +		next_comma++;
 +	}
 +	if (transmitters & (multiplier*0x08)) {
 +		cmdir_var[next_pos] = '4';
-+		if (next_comma > 0) cmdir_var[next_pos-2] = ',';
++		if (next_comma > 0)
++			cmdir_var[next_pos-2] = ',';
 +		next_pos += 3;
 +		next_comma++;
 +	}
@@ -905,7 +945,8 @@
 +			/* start it up: */
 +
 +			last_sent = nexttosend - 1;
-+			if (last_sent < 0) last_sent = QUEUELENGTH - 1;
++			if (last_sent < 0)
++				last_sent = QUEUELENGTH - 1;
 +			/* Final check - is it TIME to send this packet yet? */
 +			/* if (wait_to_tx(waitusecs[last_sent]) == 0) { */
 +			/* always send if there's room,
@@ -966,8 +1007,10 @@
 +	 * for non-zero last_tx's. */
 +	int wait_until_sec = 0, wait_until_usec = 0;
 +	int now_sec = 0, now_usec = 0;
-+	if (debug_commandir == 1) printk(KERN_INFO "waittotx(%d)\n", usecs);
-+	if (usecs == 0) return 0;
++	if (debug_commandir == 1)
++		printk(KERN_INFO "waittotx(%d)\n", usecs);
++	if (usecs == 0)
++		return 0;
 +
 +	if (!(last_tx_sec == 0 && last_tx_usec == 0)) {
 +		/* calculate wait time: */
@@ -1166,7 +1209,8 @@
 +	struct usb_skel *dev;
 +	dev = (struct usb_skel *)urb->context;
 +	send_status = SEND_IDLE;
-+	if (debug_commandir == 1) printk(KERN_INFO "callback()\n");
++	if (debug_commandir == 1)
++		printk(KERN_INFO "callback()\n");
[...2980 lines suppressed...]
 +	sz->plugin.set_use_dec = &streamzap_use_dec;
 +	sz->plugin.ioctl = streamzap_ioctl;
-+#ifdef LIRC_HAVE_SYSFS
 +	sz->plugin.dev = &udev->dev;
-+#endif
 +	sz->plugin.owner = THIS_MODULE;
 +
 +	sz->idle = 1;
@@ -17505,9 +17062,10 @@
 +		if (sz->urb_in)
 +			usb_free_urb(sz->urb_in);
 +
-+		if (sz->buf_in)
++		if (sz->buf_in) {
 +			usb_buffer_free(udev, sz->buf_in_len,
 +					sz->buf_in, sz->dma_in);
++		}
 +		kfree(sz);
 +	}
 +
@@ -17722,10 +17280,10 @@
 +#endif /* MODULE */
 diff --git a/drivers/input/lirc/lirc_ttusbir.c b/drivers/input/lirc/lirc_ttusbir.c
 new file mode 100644
-index 0000000..b80dbf8
+index 0000000..929583d
 --- /dev/null
 +++ b/drivers/input/lirc/lirc_ttusbir.c
-@@ -0,0 +1,361 @@
+@@ -0,0 +1,393 @@
 +/****************************************************************************
 + ** lirc_ttusbir.c ***********************************************************
 + ****************************************************************************
@@ -17749,6 +17307,16 @@
 + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 + *
 + */
++
++/* This LIRC driver provides access to the TechnoTrend USB IR Receiver.
++ * The receiver delivers the IR signal as raw sampled true/false data in
++ * isochronous USB packets each of size 128 byte.
++ * Currently the driver reduces the sampling rate by factor of 8 as this
++ * is still more than enough to decode RC-5 - others should be analyzed.
++ * But the driver does not rely on RC-5 it should be able to decode every
++ * IR signal that is not too fast.
++ */
++
 +#include <linux/version.h>
 +#include <linux/kernel.h>
 +#include <linux/init.h>
@@ -17765,9 +17333,6 @@
 +MODULE_AUTHOR("Stefan Macher (st_maker-lirc at yahoo.de)");
 +MODULE_LICENSE("GPL");
 +
-+/* @TODO Is it enough to have only two, I guess yes */
-+#define NUM_URBS 4 /* Number of URBs used in the queue */
-+
 +/* #define DEBUG */
 +#ifdef DEBUG
 +#define DPRINTK printk
@@ -17782,6 +17347,12 @@
 +static int set_use_inc(void *data);
 +static void set_use_dec(void *data);
 +
++static int num_urbs = 2;
++module_param(num_urbs, int, 0444);
++MODULE_PARM_DESC(num_urbs,
++		 "Number of URBs in queue. Try to increase to 4 in case "
++		 "of problems (default: 2; minimum: 2)");
++
 +/* table of devices that work with this driver */
 +static struct usb_device_id device_id_table[] = {
 +    { USB_DEVICE(0x0B48, 0x2003) },
@@ -17798,8 +17369,7 @@
 +};
 +
 +/* USB device definition */
-+struct ttusbir_device
-+{
++struct ttusbir_device {
 +	struct usb_driver *driver;
 +	struct usb_device *udev;
 +	struct usb_interface *interf;
@@ -17807,8 +17377,8 @@
 +	unsigned int ifnum; /* Interface number to use */
 +	unsigned int alt_setting; /* alternate setting to use */
 +	unsigned int endpoint; /* Endpoint to use */
-+	struct urb *urb[NUM_URBS];
-+	char buffer[NUM_URBS][128];
++	struct urb **urb; /* num_urb URB pointers*/
++	char **buffer; /* 128 byte buffer for each URB */
 +	struct lirc_buffer rbuf; /* Buffer towards LIRC */
 +	struct lirc_plugin plugin;
 +	int minor;
@@ -17826,10 +17396,10 @@
 +	struct ttusbir_device *ttusbir = data;
 +
 +	DPRINTK("Sending first URBs\n");
-+
++	/* @TODO Do I need to check if I am already opened */
 +	ttusbir->opened = 1;
 +
-+	for (i = 0; i < NUM_URBS; i++)
++	for (i = 0; i < num_urbs; i++)
 +		usb_submit_urb(ttusbir->urb[i], GFP_KERNEL);
 +
 +	return 0;
@@ -17848,11 +17418,12 @@
 + * USB specific functions
 + */
 +
-+/* This mapping table is used to do a very simple filtering of the input signal
-+ * For a value with at least 4 bits set it returns 0xFF otherwise 0x00.
-+ * For faster IR signals this can not be used. But for RC-5 we still have
-+ * about 14 bytes per pulse/space
-+ */
++/* This mapping table is used to do a very simple filtering of the
++ * input signal.
++ * For a value with at least 4 bits set it returns 0xFF otherwise
++ * 0x00.  For faster IR signals this can not be used. But for RC-5 we
++ * still have about 14 samples per pulse/space, i.e. we sample with 14
++ * times higher frequency than the signal frequency */
 +const unsigned char map_table[] =
 +{
 +	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -17904,6 +17475,7 @@
 +	buf = (unsigned char *)urb->transfer_buffer;
 +
 +	for (i = 0; i < 128; i++) {
++		/* Here we do the filtering and some kind of down sampling */
 +		buf[i] = ~map_table[buf[i]];
 +		if (ttusbir->last_pulse == buf[i]) {
 +			if (ttusbir->last_num < PULSE_MASK/63)
@@ -17933,6 +17505,7 @@
 +	int alt_set, endp;
 +	int found = 0;
 +	int i, j;
++	int struct_size;
 +	struct usb_host_interface *host_interf;
 +	struct usb_interface_descriptor *interf_desc;
 +	struct usb_host_endpoint *host_endpoint;
@@ -17940,12 +17513,27 @@
 +
 +	DPRINTK("Module ttusbir probe\n");
 +
-+	ttusbir = (struct ttusbir_device *)
-+		  kzalloc(sizeof(struct ttusbir_device), GFP_KERNEL);
++	/* To reduce memory fragmentation we use only one allocation */
++	struct_size =  sizeof(struct ttusbir_device) +
++		(sizeof(struct urb *) * num_urbs) +
++		(sizeof(char *) * num_urbs) +
++		(num_urbs * 128);
++	ttusbir = kmalloc(struct_size, GFP_KERNEL);
 +	if (!ttusbir)
 +		return -ENOMEM;
++	memset(ttusbir, 0, struct_size);
++
++	ttusbir->urb = (struct urb **)((char *)ttusbir +
++				      sizeof(struct ttusbir_device));
++	ttusbir->buffer = (char **)((char *)ttusbir->urb +
++				   (sizeof(struct urb *) * num_urbs));
++	for (i = 0; i < num_urbs; i++)
++		ttusbir->buffer[i] = (char *)ttusbir->buffer +
++			(sizeof(char *)*num_urbs) + (i * 128);
++
 +	ttusbir->driver = &driver;
 +	ttusbir->alt_setting = -1;
++	/* @TODO check if error can be returned */
 +	ttusbir->udev = usb_get_dev(interface_to_usbdev(intf));
 +	ttusbir->interf = intf;
 +	ttusbir->last_pulse = 0x00;
@@ -18014,7 +17602,7 @@
 +	}
 +
 +	/* Allocate and setup the URB that we will use to talk to the device */
-+	for (i = 0; i < NUM_URBS; i++) {
++	for (i = 0; i < num_urbs; i++) {
 +		ttusbir->urb[i] = usb_alloc_urb(8, GFP_KERNEL);
 +		if (!ttusbir->urb[i]) {
 +			err("Could not allocate memory for the URB\n");
@@ -18053,14 +17641,16 @@
 +
 +	DPRINTK("Module ttusbir disconnect\n");
 +
-+	lock_kernel();
 +	ttusbir = (struct ttusbir_device *) usb_get_intfdata(intf);
 +	usb_set_intfdata(intf, NULL);
 +	lirc_unregister_plugin(ttusbir->minor);
-+	unlock_kernel();
++	DPRINTK("unregistered\n");
 +
-+	for (i = 0; i < NUM_URBS; i++)
++	for (i = 0; i < num_urbs; i++) {
++		usb_kill_urb(ttusbir->urb[i]);
 +		usb_free_urb(ttusbir->urb[i]);
++	}
++	DPRINTK("URBs killed\n");
 +	lirc_buffer_free(&ttusbir->rbuf);
 +	kfree(ttusbir);
 +}




More information about the fedora-extras-commits mailing list