]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Merge master.kernel.org:/home/rmk/linux-2.6-arm
authorLinus Torvalds <torvalds@g5.osdl.org>
Mon, 14 Nov 2005 02:17:54 +0000 (18:17 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 14 Nov 2005 02:17:54 +0000 (18:17 -0800)
289 files changed:
CREDITS
Documentation/DocBook/Makefile
Documentation/DocBook/kernel-api.tmpl
Documentation/DocBook/stylesheet.xsl
Documentation/atomic_ops.txt
Documentation/oops-tracing.txt
Documentation/video4linux/CARDLIST.bttv
Documentation/video4linux/CARDLIST.saa7134
Documentation/video4linux/CARDLIST.tuner
MAINTAINERS
Makefile
README
arch/arm/kernel/apm.c
arch/frv/kernel/pm.c
arch/i386/Kconfig
arch/i386/kernel/apm.c
arch/i386/kernel/cpu/intel.c
arch/i386/kernel/entry.S
arch/i386/kernel/timers/timer_pit.c
arch/i386/mm/init.c
arch/m68k/fpsp040/skeleton.S
arch/m68k/ifpsp060/iskeleton.S
arch/m68k/kernel/asm-offsets.c
arch/m68k/kernel/entry.S
arch/m68k/kernel/ptrace.c
arch/mips/au1000/common/power.c
arch/mips/au1000/common/usbdev.c
arch/powerpc/kernel/head_fsl_booke.S
arch/powerpc/kernel/ioctl32.c
arch/powerpc/mm/fsl_booke_mmu.c
arch/powerpc/oprofile/op_model_fsl_booke.c
arch/powerpc/xmon/xmon.c
arch/ppc/kernel/head_fsl_booke.S
arch/ppc/mm/fsl_booke_mmu.c
arch/ppc/platforms/83xx/mpc834x_sys.c
arch/ppc/platforms/83xx/mpc834x_sys.h
arch/ppc/platforms/85xx/mpc8540_ads.c
arch/ppc/platforms/85xx/mpc8540_ads.h
arch/ppc/platforms/85xx/mpc8555_cds.h
arch/ppc/platforms/85xx/mpc8560_ads.c
arch/ppc/platforms/85xx/mpc8560_ads.h
arch/ppc/platforms/85xx/mpc85xx_ads_common.c
arch/ppc/platforms/85xx/mpc85xx_ads_common.h
arch/ppc/platforms/85xx/mpc85xx_cds_common.c
arch/ppc/platforms/85xx/mpc85xx_cds_common.h
arch/ppc/platforms/85xx/sbc8560.c
arch/ppc/platforms/pmac_feature.c
arch/ppc/platforms/pq2ads.c
arch/ppc/syslib/ipic.h
arch/ppc/syslib/mpc83xx_devices.c
arch/ppc/syslib/mpc83xx_sys.c
arch/ppc/syslib/mpc85xx_devices.c
arch/ppc/syslib/mpc85xx_sys.c
arch/ppc/syslib/mpc8xx_devices.c
arch/ppc/syslib/mpc8xx_sys.c
arch/ppc/syslib/ppc83xx_setup.c
arch/ppc/syslib/ppc83xx_setup.h
arch/ppc/syslib/ppc85xx_common.c
arch/ppc/syslib/ppc85xx_common.h
arch/ppc/syslib/ppc85xx_setup.c
arch/ppc/syslib/ppc85xx_setup.h
arch/ppc/syslib/ppc_sys.c
arch/ppc/syslib/pq2_devices.c
arch/ppc/syslib/pq2_sys.c
arch/ppc64/kernel/prom.c
arch/sparc/lib/atomic32.c
arch/sparc/lib/bitext.c
arch/sparc64/kernel/ioctl32.c
arch/um/Kconfig
arch/um/Kconfig.i386
arch/um/Makefile-i386
arch/um/drivers/chan_kern.c
arch/um/drivers/chan_user.c
arch/um/drivers/daemon_user.c
arch/um/drivers/fd.c
arch/um/drivers/mcast_user.c
arch/um/drivers/port_user.c
arch/um/drivers/pty.c
arch/um/drivers/tty.c
arch/um/drivers/xterm.c
arch/um/include/chan_user.h
arch/um/include/um_uaccess.h
arch/um/kernel/skas/include/uaccess-skas.h
arch/um/kernel/skas/uaccess.c
arch/um/kernel/trap_kern.c
arch/um/kernel/tt/include/uaccess-tt.h
arch/um/kernel/tt/uaccess.c
arch/x86_64/kernel/i8259.c
block/cfq-iosched.c
block/elevator.c
block/genhd.c
block/noop-iosched.c
drivers/acpi/bus.c
drivers/base/firmware_class.c
drivers/block/pktcdvd.c
drivers/char/agp/uninorth-agp.c
drivers/char/i8k.c
drivers/char/pcmcia/Kconfig
drivers/char/pcmcia/Makefile
drivers/char/pcmcia/cm4000_cs.c [new file with mode: 0644]
drivers/char/pcmcia/cm4040_cs.c [new file with mode: 0644]
drivers/char/pcmcia/cm4040_cs.h [new file with mode: 0644]
drivers/char/synclink.c
drivers/char/tpm/tpm.c
drivers/char/tpm/tpm.h
drivers/char/tpm/tpm_atmel.c
drivers/char/tpm/tpm_atmel.h [new file with mode: 0644]
drivers/char/watchdog/booke_wdt.c
drivers/ide/ppc/pmac.c
drivers/media/common/ir-common.c
drivers/media/dvb/b2c2/Kconfig
drivers/media/video/Kconfig
drivers/media/video/Makefile
drivers/media/video/bttv-cards.c
drivers/media/video/bttv-driver.c
drivers/media/video/bttv-gpio.c
drivers/media/video/bttv.h
drivers/media/video/bttvp.h
drivers/media/video/cx25840/Makefile [new file with mode: 0644]
drivers/media/video/cx25840/cx25840-audio.c [new file with mode: 0644]
drivers/media/video/cx25840/cx25840-core.c [new file with mode: 0644]
drivers/media/video/cx25840/cx25840-firmware.c [new file with mode: 0644]
drivers/media/video/cx25840/cx25840-vbi.c [new file with mode: 0644]
drivers/media/video/cx25840/cx25840.h [new file with mode: 0644]
drivers/media/video/cx88/cx88-dvb.c
drivers/media/video/em28xx/em28xx-input.c
drivers/media/video/ir-kbd-gpio.c
drivers/media/video/ir-kbd-i2c.c
drivers/media/video/saa7115.c [new file with mode: 0644]
drivers/media/video/saa711x.c
drivers/media/video/saa7127.c [new file with mode: 0644]
drivers/media/video/saa7134/Kconfig
drivers/media/video/saa7134/Makefile
drivers/media/video/saa7134/saa7134-alsa.c
drivers/media/video/saa7134/saa7134-cards.c
drivers/media/video/saa7134/saa7134-core.c
drivers/media/video/saa7134/saa7134-input.c
drivers/media/video/saa7134/saa7134-oss.c
drivers/media/video/saa7134/saa7134.h
drivers/media/video/tda8290.c
drivers/media/video/tuner-core.c
drivers/media/video/tuner-simple.c
drivers/media/video/wm8775.c
drivers/mmc/mmci.c
drivers/mtd/maps/Kconfig
drivers/net/3c509.c
drivers/net/gianfar.c
drivers/net/gianfar.h
drivers/net/gianfar_ethtool.c
drivers/net/gianfar_mii.c
drivers/net/gianfar_mii.h
drivers/net/irda/ali-ircc.c
drivers/net/irda/nsc-ircc.c
drivers/net/sungem.c
drivers/pci/hotplug/pciehp_hpc.c
drivers/pci/hotplug/rpaphp_pci.c
drivers/pci/hotplug/shpchp_hpc.c
drivers/sbus/char/rtc.c
drivers/scsi/ahci.c
drivers/scsi/libata-core.c
drivers/scsi/libata-scsi.c
drivers/scsi/sata_qstor.c
drivers/scsi/sata_sil24.c
drivers/serial/68328serial.c
drivers/serial/8250.c
drivers/serial/8250_pnp.c
drivers/serial/cpm_uart/cpm_uart_core.c
drivers/serial/cpm_uart/cpm_uart_cpm1.c
drivers/serial/cpm_uart/cpm_uart_cpm2.c
drivers/serial/dz.c
drivers/serial/mpc52xx_uart.c
drivers/serial/sa1100.c
drivers/serial/serial_core.c
drivers/video/bw2.c
drivers/video/cg14.c
drivers/video/cg3.c
drivers/video/cg6.c
drivers/video/console/Kconfig
drivers/video/console/Makefile
drivers/video/console/fbcon.c
drivers/video/console/fbcon.h
drivers/video/console/fbcon_ccw.c
drivers/video/console/fbcon_cw.c
drivers/video/console/fbcon_ud.c
drivers/video/console/font_rl.c [deleted file]
drivers/video/console/fonts.c
drivers/video/ffb.c
drivers/video/leo.c
drivers/video/nvidia/nv_proto.h
drivers/video/nvidia/nvidia.c
drivers/video/p9100.c
drivers/video/sbuslib.c
drivers/video/sbuslib.h
drivers/video/tcx.c
drivers/video/vesafb.c
drivers/video/w100fb.c
fs/aio.c
fs/ext2/super.c
fs/ext3/inode.c
fs/jffs2/scan.c
fs/locks.c
fs/proc/task_mmu.c
include/asm-alpha/atomic.h
include/asm-arm/atomic.h
include/asm-arm26/atomic.h
include/asm-cris/atomic.h
include/asm-frv/atomic.h
include/asm-h8300/atomic.h
include/asm-i386/atomic.h
include/asm-i386/system.h
include/asm-ia64/atomic.h
include/asm-m68k/atomic.h
include/asm-m68k/processor.h
include/asm-m68k/thread_info.h
include/asm-m68knommu/atomic.h
include/asm-mips/atomic.h
include/asm-parisc/atomic.h
include/asm-powerpc/atomic.h
include/asm-ppc/immap_85xx.h
include/asm-ppc/ipic.h
include/asm-ppc/mpc83xx.h
include/asm-ppc/mpc85xx.h
include/asm-ppc/ppc_sys.h
include/asm-s390/atomic.h
include/asm-sh/atomic.h
include/asm-sh64/atomic.h
include/asm-sparc/atomic.h
include/asm-sparc64/atomic.h
include/asm-v850/atomic.h
include/asm-x86_64/atomic.h
include/asm-x86_64/desc.h
include/asm-xtensa/atomic.h
include/linux/acct.h
include/linux/aio.h
include/linux/blkdev.h
include/linux/cm4000_cs.h [new file with mode: 0644]
include/linux/compat_ioctl.h
include/linux/file.h
include/linux/font.h
include/linux/fsl_devices.h
include/linux/genhd.h
include/linux/gfp.h
include/linux/hardirq.h
include/linux/hugetlb.h
include/linux/init_task.h
include/linux/interrupt.h
include/linux/mmzone.h
include/linux/pagemap.h
include/linux/pci_ids.h
include/linux/percpu.h
include/linux/pm.h
include/linux/pm_legacy.h [new file with mode: 0644]
include/linux/preempt.h
include/linux/sched.h
include/linux/smp_lock.h
include/linux/thread_info.h
include/linux/time.h
include/linux/usb.h
include/linux/videodev2.h
include/media/ir-common.h
include/media/ir-kbd-i2c.h
include/media/tuner.h
include/media/v4l2-common.h [new file with mode: 0644]
kernel/cpuset.c
kernel/exit.c
kernel/fork.c
kernel/posix-timers.c
kernel/power/Kconfig
kernel/power/Makefile
kernel/power/pm.c
kernel/printk.c
kernel/ptrace.c
kernel/rcutorture.c
kernel/sched.c
kernel/signal.c
kernel/stop_machine.c
mm/memory.c
mm/page_alloc.c
mm/slab.c
mm/vmscan.c
net/ipv4/netfilter/ip_conntrack_proto_tcp.c
net/ipv6/route.c
net/netfilter/nf_conntrack_proto_tcp.c
scripts/kernel-doc
sound/oss/ad1848.c
sound/oss/cs4281/cs4281m.c
sound/oss/maestro.c
sound/oss/nm256_audio.c
sound/oss/opl3sa2.c

diff --git a/CREDITS b/CREDITS
index 7fb4c73e02288494856ae67eb9a37e461035f2b5..192f749eba25b38007b7a32e362e06896f7a368c 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -1097,7 +1097,7 @@ S: 80050-430 - Curitiba - Paran
 S: Brazil
 
 N: Kumar Gala
-E: kumar.gala@freescale.com
+E: galak@kernel.crashing.org
 D: Embedded PowerPC 6xx/7xx/74xx/82xx/83xx/85xx support
 S: Austin, Texas 78729
 S: USA
index 7018f5c6a447b392a8ccd316d49380ce5307e936..1c955883cf58864015c7dd93243e819dd0b18429 100644 (file)
@@ -20,6 +20,12 @@ DOCBOOKS := wanbook.xml z8530book.xml mcabook.xml videobook.xml \
 #                        +--> DIR=file  (htmldocs)
 #                        +--> man/      (mandocs)
 
+
+# for PDF and PS output you can choose between xmlto and docbook-utils tools
+PDF_METHOD     = $(prefer-db2x)
+PS_METHOD      = $(prefer-db2x)
+
+
 ###
 # The targets that may be used.
 .PHONY:        xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs
@@ -93,27 +99,39 @@ C-procfs-example = procfs_example.xml
 C-procfs-example2 = $(addprefix $(obj)/,$(C-procfs-example))
 $(obj)/procfs-guide.xml: $(C-procfs-example2)
 
-###
-# Rules to generate postscript, PDF and HTML
-# db2html creates a directory. Generate a html file used for timestamp
+notfoundtemplate = echo "*** You have to install docbook-utils or xmlto ***"; \
+                  exit 1
+db2xtemplate = db2TYPE -o $(dir $@) $<
+xmltotemplate = xmlto TYPE $(XMLTOFLAGS) -o $(dir $@) $<
+
+# determine which methods are available
+ifeq ($(shell which db2ps >/dev/null 2>&1 && echo found),found)
+       use-db2x = db2x
+       prefer-db2x = db2x
+else
+       use-db2x = notfound
+       prefer-db2x = $(use-xmlto)
+endif
+ifeq ($(shell which xmlto >/dev/null 2>&1 && echo found),found)
+       use-xmlto = xmlto
+       prefer-xmlto = xmlto
+else
+       use-xmlto = notfound
+       prefer-xmlto = $(use-db2x)
+endif
 
-quiet_cmd_db2ps = XMLTO    $@
-      cmd_db2ps = xmlto ps $(XMLTOFLAGS) -o $(dir $@) $<
+# the commands, generated from the chosen template
+quiet_cmd_db2ps = PS      $@
+      cmd_db2ps = $(subst TYPE,ps, $($(PS_METHOD)template))
 %.ps : %.xml
-       @(which xmlto > /dev/null 2>&1) || \
-        (echo "*** You need to install xmlto ***"; \
-         exit 1)
        $(call cmd,db2ps)
 
-quiet_cmd_db2pdf = XMLTO   $@
-      cmd_db2pdf = xmlto pdf $(XMLTOFLAGS) -o $(dir $@) $<
+quiet_cmd_db2pdf = PDF      $@
+      cmd_db2pdf = $(subst TYPE,pdf, $($(PDF_METHOD)template))
 %.pdf : %.xml
-       @(which xmlto > /dev/null 2>&1) || \
-        (echo "*** You need to install xmlto ***"; \
-         exit 1)
        $(call cmd,db2pdf)
 
-quiet_cmd_db2html = XMLTO  $@
+quiet_cmd_db2html = HTML   $@
       cmd_db2html = xmlto xhtml $(XMLTOFLAGS) -o $(patsubst %.html,%,$@) $< && \
                echo '<a HREF="$(patsubst %.html,%,$(notdir $@))/index.html"> \
          Goto $(patsubst %.html,%,$(notdir $@))</a><p>' > $@
@@ -127,7 +145,7 @@ quiet_cmd_db2html = XMLTO  $@
        @if [ ! -z "$(PNG-$(basename $(notdir $@)))" ]; then \
             cp $(PNG-$(basename $(notdir $@))) $(patsubst %.html,%,$@); fi
 
-quiet_cmd_db2man = XMLTO   $@
+quiet_cmd_db2man = MAN     $@
       cmd_db2man = if grep -q refentry $<; then xmlto man $(XMLTOFLAGS) -o $(obj)/man $< ; gzip -f $(obj)/man/*.9; fi
 %.9 : %.xml
        @(which xmlto > /dev/null 2>&1) || \
index a8316b1a3e3d45e3368a1a4b3dddb732bab65b32..0519c9dc00659f0691de16fddbd861a71a752766 100644 (file)
@@ -68,9 +68,7 @@ X!Iinclude/linux/kobject.h
 
      <sect1><title>Kernel utility functions</title>
 !Iinclude/linux/kernel.h
-<!-- This needs to clean up to make kernel-doc happy
-X!Ekernel/printk.c
- -->
+!Ekernel/printk.c
 !Ekernel/panic.c
 !Ekernel/sys.c
 !Ekernel/rcupdate.c
index 64be9f7ee3bba74a415d10c0f9508c7c4105e176..3ccce886c349d4ab3d5e357213d651b82d204eb4 100644 (file)
@@ -3,4 +3,5 @@
 <param name="chunk.quietly">1</param>
 <param name="funcsynopsis.style">ansi</param>
 <param name="funcsynopsis.tabular.threshold">80</param>
+<!-- <param name="paper.type">A4</param> -->
 </stylesheet>
index 8eedaa24f5e284f09dcfce6b2164bc53cfaed579..23a1c2402bccf3ec6d8bbf97bba3becfcf149272 100644 (file)
@@ -115,6 +115,33 @@ boolean is return which indicates whether the resulting counter value
 is negative.  It requires explicit memory barrier semantics around the
 operation.
 
+Then:
+
+       int atomic_cmpxchg(atomic_t *v, int old, int new);
+
+This performs an atomic compare exchange operation on the atomic value v,
+with the given old and new values. Like all atomic_xxx operations,
+atomic_cmpxchg will only satisfy its atomicity semantics as long as all
+other accesses of *v are performed through atomic_xxx operations.
+
+atomic_cmpxchg requires explicit memory barriers around the operation.
+
+The semantics for atomic_cmpxchg are the same as those defined for 'cas'
+below.
+
+Finally:
+
+       int atomic_add_unless(atomic_t *v, int a, int u);
+
+If the atomic value v is not equal to u, this function adds a to v, and
+returns non zero. If v is equal to u then it returns zero. This is done as
+an atomic operation.
+
+atomic_add_unless requires explicit memory barriers around the operation.
+
+atomic_inc_not_zero, equivalent to atomic_add_unless(v, 1, 0)
+
+
 If a caller requires memory barrier semantics around an atomic_t
 operation which does not return a value, a set of interfaces are
 defined which accomplish this:
index c563842ed8057e1ee960ff0faa75d87c6b797a56..9f30ac6ca47b4caa382a281523b27a8abc95f541 100644 (file)
@@ -30,7 +30,9 @@ the disk is not available then you have three options :-
 
 (1) Hand copy the text from the screen and type it in after the machine
     has restarted.  Messy but it is the only option if you have not
-    planned for a crash.
+    planned for a crash. Alternatively, you can take a picture of
+    the screen with a digital camera - not nice, but better than
+    nothing.
 
 (2) Boot with a serial console (see Documentation/serial-console.txt),
     run a null modem to a second machine and capture the output there
index 2404099996ac40d83a6e5512eb98498749c5bc83..330246ac80f80f282e987d83d78acac8856ddc14 100644 (file)
 139 -> Prolink PixelView PlayTV MPEG2 PV-M4900
 140 -> Osprey 440                                          [0070:ff07]
 141 -> Asound Skyeye PCTV
+142 -> Sabrent TV-FM (bttv version)
index 57c9d631db56210359ee75cce70825b41e78e631..efb708ec116ace349ccabdb31ccc0a1123fe5238 100644 (file)
@@ -80,3 +80,5 @@
  79 -> Sedna/MuchTV PC TV Cardbus TV/Radio (ITO25 Rev:2B)
  80 -> ASUS Digimatrix TV                       [1043:0210]
  81 -> Philips Tiger reference design           [1131:2018]
+ 82 -> MSI TV@Anywhere plus                     [1462:6231]
+
index ec840ca6f45501e215c52fe6b4a6540f7702512a..9d6544ea9f41881f0df7fea74f4f31b90211b9e5 100644 (file)
@@ -67,3 +67,4 @@ tuner=65 - Ymec TVF66T5-B/DFF
 tuner=66 - LG NTSC (TALN mini series)
 tuner=67 - Philips TD1316 Hybrid Tuner
 tuner=68 - Philips TUV1236D ATSC/NTSC dual in
+tuner=69 - Tena TNF 5335 MF
index 2313de23b0dad531fa6821a0c8a44d01f145ce24..509927e40bbbf92c9802aac8064a7ae82e18e5aa 100644 (file)
@@ -1565,7 +1565,7 @@ S:        Maintained
 
 LINUX FOR POWERPC EMBEDDED PPC83XX AND PPC85XX
 P:     Kumar Gala
-M:     kumar.gala@freescale.com
+M:     galak@kernel.crashing.org
 W:     http://www.penguinppc.org/
 L:     linuxppc-embedded@ozlabs.org
 S:     Maintained
@@ -1873,6 +1873,16 @@ L:       linux-tr@linuxtr.net
 W:     http://www.linuxtr.net
 S:     Maintained
 
+OMNIKEY CARDMAN 4000 DRIVER
+P:     Harald Welte
+M:     laforge@gnumonks.org
+S:     Maintained
+
+OMNIKEY CARDMAN 4040 DRIVER
+P:     Harald Welte
+M:     laforge@gnumonks.org
+S:     Maintained
+
 ONSTREAM SCSI TAPE DRIVER
 P:     Willem Riede
 M:     osst@riede.org
index 8560b79268ba1aa2b1648e85311a11aeef83d302..c31914400953b05438b6cda4e793d166094b2ee4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1193,6 +1193,17 @@ else
 __srctree = $(srctree)/
 endif
 
+ifeq ($(ALLSOURCE_ARCHS),)
+ifeq ($(ARCH),um)
+ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH)
+else
+ALLINCLUDE_ARCHS := $(ARCH)
+endif
+else
+#Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behaviour.
+ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS)
+endif
+
 ALLSOURCE_ARCHS := $(ARCH)
 
 define all-sources
@@ -1208,7 +1219,7 @@ define all-sources
          find $(__srctree)include $(RCS_FIND_IGNORE) \
               \( -name config -o -name 'asm-*' \) -prune \
               -o -name '*.[chS]' -print; \
-         for ARCH in $(ALLSOURCE_ARCHS) ; do \
+         for ARCH in $(ALLINCLUDE_ARCHS) ; do \
               find $(__srctree)include/asm-$${ARCH} $(RCS_FIND_IGNORE) \
                    -name '*.[chS]' -print; \
          done ; \
diff --git a/README b/README
index 4ee7dda88ba3956f0bea64072ee456ddf27fe8f9..61c4f7429233d509f26c267cf95fa01742b81e3e 100644 (file)
--- a/README
+++ b/README
@@ -81,6 +81,11 @@ INSTALLING the kernel:
    failed patches (xxx# or xxx.rej). If there are, either you or me has
    made a mistake.
 
+   Unlike patches for the 2.6.x kernels, patches for the 2.6.x.y kernels
+   (also known as the -stable kernels) are not incremental but instead apply
+   directly to the base 2.6.x kernel.  Please read
+   Documentation/applying-patches.txt for more information.
+
    Alternatively, the script patch-kernel can be used to automate this
    process.  It determines the current kernel version and applies any
    patches found.
index b0bbd1e62ebb70e107268ce7b176de0ffcd13c8e..a2843be0555733feaa8fc5cc29574817ce5c6c4d 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/apm_bios.h>
 #include <linux/sched.h>
 #include <linux/pm.h>
+#include <linux/pm_legacy.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
index 1a1e8a119c3d722aa7d9b64ddabe820ace45bc4b..712c3c24c954008d520f7925a492eee0a85f97e5 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/config.h>
 #include <linux/init.h>
 #include <linux/pm.h>
+#include <linux/pm_legacy.h>
 #include <linux/sched.h>
 #include <linux/interrupt.h>
 #include <linux/sysctl.h>
index dbf90ad6eac363a082deae5141c7fcac7a385279..6004bb0795e0992687ffdc2548798c7661736e2a 100644 (file)
@@ -699,7 +699,7 @@ depends on PM && !X86_VISWS
 
 config APM
        tristate "APM (Advanced Power Management) BIOS support"
-       depends on PM
+       depends on PM && PM_LEGACY
        ---help---
          APM is a BIOS specification for saving power using several different
          techniques. This is mostly useful for battery powered laptops with
index 003548b8735f961b24794da2306bff45944ee63e..1e60acbed3c1468189d6323437a03420383deb25 100644 (file)
 #include <linux/time.h>
 #include <linux/sched.h>
 #include <linux/pm.h>
+#include <linux/pm_legacy.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/smp.h>
index 43601de0f6331415aaa8b19594112a3de080ae4f..c28d26fb5f241891c02b3fd5fd7f508083315334 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/bitops.h>
 #include <linux/smp.h>
 #include <linux/thread_info.h>
+#include <linux/module.h>
 
 #include <asm/processor.h>
 #include <asm/msr.h>
@@ -264,5 +265,52 @@ __init int intel_cpu_init(void)
        return 0;
 }
 
+#ifndef CONFIG_X86_CMPXCHG
+unsigned long cmpxchg_386_u8(volatile void *ptr, u8 old, u8 new)
+{
+       u8 prev;
+       unsigned long flags;
+
+       /* Poor man's cmpxchg for 386. Unsuitable for SMP */
+       local_irq_save(flags);
+       prev = *(u8 *)ptr;
+       if (prev == old)
+               *(u8 *)ptr = new;
+       local_irq_restore(flags);
+       return prev;
+}
+EXPORT_SYMBOL(cmpxchg_386_u8);
+
+unsigned long cmpxchg_386_u16(volatile void *ptr, u16 old, u16 new)
+{
+       u16 prev;
+       unsigned long flags;
+
+       /* Poor man's cmpxchg for 386. Unsuitable for SMP */
+       local_irq_save(flags);
+       prev = *(u16 *)ptr;
+       if (prev == old)
+               *(u16 *)ptr = new;
+       local_irq_restore(flags);
+       return prev;
+}
+EXPORT_SYMBOL(cmpxchg_386_u16);
+
+unsigned long cmpxchg_386_u32(volatile void *ptr, u32 old, u32 new)
+{
+       u32 prev;
+       unsigned long flags;
+
+       /* Poor man's cmpxchg for 386. Unsuitable for SMP */
+       local_irq_save(flags);
+       prev = *(u32 *)ptr;
+       if (prev == old)
+               *(u32 *)ptr = new;
+       local_irq_restore(flags);
+       return prev;
+}
+EXPORT_SYMBOL(cmpxchg_386_u32);
+#endif
+
 // arch_initcall(intel_cpu_init);
 
index 9e24f7b207ee1636eabcafc48f6f630b56ed8d3e..e50b93155249b79732378ccbc6d4bc41c2d74207 100644 (file)
@@ -560,11 +560,10 @@ nmi_stack_fixup:
 nmi_debug_stack_check:
        cmpw $__KERNEL_CS,16(%esp)
        jne nmi_stack_correct
-       cmpl $debug - 1,(%esp)
-       jle nmi_stack_correct
+       cmpl $debug,(%esp)
+       jb nmi_stack_correct
        cmpl $debug_esp_fix_insn,(%esp)
-       jle nmi_debug_stack_fixup
-nmi_debug_stack_fixup:
+       ja nmi_stack_correct
        FIX_STACK(24,nmi_stack_correct, 1)
        jmp nmi_stack_correct
 
index e42e46d351591d583782921f6b30e5b302b2285a..b9b6bd56b9bafc27b2be1d3dd2621c4a47a8a782 100644 (file)
@@ -25,8 +25,9 @@ static int __init init_pit(char* override)
 {
        /* check clock override */
        if (override[0] && strncmp(override,"pit",3))
-               printk(KERN_ERR "Warning: clock= override failed. Defaulting to PIT\n");
+               printk(KERN_ERR "Warning: clock= override failed. Defaulting "
+                               "to PIT\n");
+       init_cpu_khz();
        count_p = LATCH;
        return 0;
 }
index 542d9298da5e91571bf75f45152e8901d473a684..06e26f0062382301e02c13a6c2fa24617a48b663 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/proc_fs.h>
 #include <linux/efi.h>
 #include <linux/memory_hotplug.h>
+#include <linux/initrd.h>
 
 #include <asm/processor.h>
 #include <asm/system.h>
@@ -267,7 +268,7 @@ static void __init permanent_kmaps_init(pgd_t *pgd_base)
        pkmap_page_table = pte; 
 }
 
-void __devinit free_new_highpage(struct page *page)
+static void __devinit free_new_highpage(struct page *page)
 {
        set_page_count(page, 1);
        __free_page(page);
index 9571a21d6ad42b0d0f9de6a63038fd1d4f5cee9c..a1629194e3fd917260604e372371416a1def8b64 100644 (file)
@@ -381,10 +381,8 @@ fpsp_done:
 .Lnotkern:
        SAVE_ALL_INT
        GET_CURRENT(%d0)
-       tstb    %curptr@(TASK_NEEDRESCHED)
-       jne     ret_from_exception      | deliver signals,
-                                       | reschedule etc..
-       RESTORE_ALL
+       | deliver signals, reschedule etc..
+       jra     ret_from_exception
 
 |
 |      mem_write --- write to user or supervisor address space
index 4ba2c74da93da6070d80e26cd754ca59b671d046..b2dbdf5ee3090ba7359eda1fcdca7971aa76ecae 100644 (file)
@@ -75,10 +75,8 @@ _060_isp_done:
 .Lnotkern:
        SAVE_ALL_INT
        GET_CURRENT(%d0)
-       tstb    %curptr@(TASK_NEEDRESCHED)
-       jne     ret_from_exception      | deliver signals,
-                                       | reschedule etc..
-       RESTORE_ALL
+       | deliver signals, reschedule etc..
+       jra     ret_from_exception
 
 |
 | _060_real_chk():
index cee3317b866505da52f3d3e5afe16abec5846f77..c787c5ba951310fe13f53e2e99d949c79f868e37 100644 (file)
@@ -25,12 +25,8 @@ int main(void)
        DEFINE(TASK_STATE, offsetof(struct task_struct, state));
        DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags));
        DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
-       DEFINE(TASK_WORK, offsetof(struct task_struct, thread.work));
-       DEFINE(TASK_NEEDRESCHED, offsetof(struct task_struct, thread.work.need_resched));
-       DEFINE(TASK_SYSCALL_TRACE, offsetof(struct task_struct, thread.work.syscall_trace));
-       DEFINE(TASK_SIGPENDING, offsetof(struct task_struct, thread.work.sigpending));
-       DEFINE(TASK_NOTIFY_RESUME, offsetof(struct task_struct, thread.work.notify_resume));
        DEFINE(TASK_THREAD, offsetof(struct task_struct, thread));
+       DEFINE(TASK_INFO, offsetof(struct task_struct, thread.info));
        DEFINE(TASK_MM, offsetof(struct task_struct, mm));
        DEFINE(TASK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
 
@@ -45,6 +41,10 @@ int main(void)
        DEFINE(THREAD_FPCNTL, offsetof(struct thread_struct, fpcntl));
        DEFINE(THREAD_FPSTATE, offsetof(struct thread_struct, fpstate));
 
+       /* offsets into the thread_info struct */
+       DEFINE(TINFO_PREEMPT, offsetof(struct thread_info, preempt_count));
+       DEFINE(TINFO_FLAGS, offsetof(struct thread_info, flags));
+
        /* offsets into the pt_regs */
        DEFINE(PT_D0, offsetof(struct pt_regs, d0));
        DEFINE(PT_ORIG_D0, offsetof(struct pt_regs, orig_d0));
index 23ca60a4555249af81024a3d53b27ba2e8a28d03..320fde05dc631a646d7b51dee0c8fbf2ea6d65a5 100644 (file)
@@ -44,9 +44,7 @@
 
 #include <asm/asm-offsets.h>
 
-.globl system_call, buserr, trap
-.globl resume, ret_from_exception
-.globl ret_from_signal
+.globl system_call, buserr, trap, resume
 .globl inthandler, sys_call_table
 .globl sys_fork, sys_clone, sys_vfork
 .globl ret_from_interrupt, bad_interrupt
@@ -58,7 +56,7 @@ ENTRY(buserr)
        movel   %sp,%sp@-               | stack frame pointer argument
        bsrl    buserr_c
        addql   #4,%sp
-       jra     ret_from_exception
+       jra     .Lret_from_exception
 
 ENTRY(trap)
        SAVE_ALL_INT
@@ -66,7 +64,7 @@ ENTRY(trap)
        movel   %sp,%sp@-               | stack frame pointer argument
        bsrl    trap_c
        addql   #4,%sp
-       jra     ret_from_exception
+       jra     .Lret_from_exception
 
        | After a fork we jump here directly from resume,
        | so that %d1 contains the previous task
@@ -75,30 +73,31 @@ ENTRY(ret_from_fork)
        movel   %d1,%sp@-
        jsr     schedule_tail
        addql   #4,%sp
-       jra     ret_from_exception
+       jra     .Lret_from_exception
 
-badsys:
-       movel   #-ENOSYS,%sp@(PT_D0)
-       jra     ret_from_exception
-
-do_trace:
+do_trace_entry:
        movel   #-ENOSYS,%sp@(PT_D0)    | needed for strace
        subql   #4,%sp
        SAVE_SWITCH_STACK
        jbsr    syscall_trace
        RESTORE_SWITCH_STACK
        addql   #4,%sp
-       movel   %sp@(PT_ORIG_D0),%d1
-       movel   #-ENOSYS,%d0
-       cmpl    #NR_syscalls,%d1
-       jcc     1f
-       jbsr    @(sys_call_table,%d1:l:4)@(0)
-1:     movel   %d0,%sp@(PT_D0)         | save the return value
-       subql   #4,%sp                  | dummy return address
+       movel   %sp@(PT_ORIG_D0),%d0
+       cmpl    #NR_syscalls,%d0
+       jcs     syscall
+badsys:
+       movel   #-ENOSYS,%sp@(PT_D0)
+       jra     ret_from_syscall
+
+do_trace_exit:
+       subql   #4,%sp
        SAVE_SWITCH_STACK
        jbsr    syscall_trace
+       RESTORE_SWITCH_STACK
+       addql   #4,%sp
+       jra     .Lret_from_exception
 
-ret_from_signal:
+ENTRY(ret_from_signal)
        RESTORE_SWITCH_STACK
        addql   #4,%sp
 /* on 68040 complete pending writebacks if any */
@@ -111,7 +110,7 @@ ret_from_signal:
        addql   #4,%sp
 1:
 #endif
-       jra     ret_from_exception
+       jra     .Lret_from_exception
 
 ENTRY(system_call)
        SAVE_ALL_SYS
@@ -120,30 +119,34 @@ ENTRY(system_call)
        | save top of frame
        movel   %sp,%curptr@(TASK_THREAD+THREAD_ESP0)
 
-       tstb    %curptr@(TASK_SYSCALL_TRACE)
-       jne     do_trace
+       | syscall trace?
+       tstb    %curptr@(TASK_INFO+TINFO_FLAGS+2)
+       jmi     do_trace_entry
        cmpl    #NR_syscalls,%d0
        jcc     badsys
+syscall:
        jbsr    @(sys_call_table,%d0:l:4)@(0)
        movel   %d0,%sp@(PT_D0)         | save the return value
-
+ret_from_syscall:
        |oriw   #0x0700,%sr
-       movel   %curptr@(TASK_WORK),%d0
+       movew   %curptr@(TASK_INFO+TINFO_FLAGS+2),%d0
        jne     syscall_exit_work
 1:     RESTORE_ALL
 
 syscall_exit_work:
        btst    #5,%sp@(PT_SR)          | check if returning to kernel
        bnes    1b                      | if so, skip resched, signals
-       tstw    %d0
-       jeq     do_signal_return
-       tstb    %d0
-       jne     do_delayed_trace
-
+       lslw    #1,%d0
+       jcs     do_trace_exit
+       jmi     do_delayed_trace
+       lslw    #8,%d0
+       jmi     do_signal_return
        pea     resume_userspace
-       jmp     schedule
+       jra     schedule
+
 
-ret_from_exception:
+ENTRY(ret_from_exception)
+.Lret_from_exception:
        btst    #5,%sp@(PT_SR)          | check if returning to kernel
        bnes    1f                      | if so, skip resched, signals
        | only allow interrupts when we are really the last one on the
@@ -152,19 +155,18 @@ ret_from_exception:
        andw    #ALLOWINT,%sr
 
 resume_userspace:
-       movel   %curptr@(TASK_WORK),%d0
-       lsrl    #8,%d0
+       moveb   %curptr@(TASK_INFO+TINFO_FLAGS+3),%d0
        jne     exit_work
 1:     RESTORE_ALL
 
 exit_work:
        | save top of frame
        movel   %sp,%curptr@(TASK_THREAD+THREAD_ESP0)
-       tstb    %d0
-       jeq     do_signal_return
-
+       lslb    #1,%d0
+       jmi     do_signal_return
        pea     resume_userspace
-       jmp     schedule
+       jra     schedule
+
 
 do_signal_return:
        |andw   #ALLOWINT,%sr
@@ -254,7 +256,7 @@ ret_from_interrupt:
 
        /* check if we need to do software interrupts */
        tstl    irq_stat+CPUSTAT_SOFTIRQ_PENDING
-       jeq     ret_from_exception
+       jeq     .Lret_from_exception
        pea     ret_from_exception
        jra     do_softirq
 
index 7e54422685cfc1ed8737d29bac74124b3a4f8cdd..540638ca81f9832fe390b1f0b381d54ea7b2b20e 100644 (file)
@@ -109,7 +109,7 @@ static inline void singlestep_disable(struct task_struct *child)
 {
        unsigned long tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16);
        put_reg(child, PT_SR, tmp);
-       child->thread.work.delayed_trace = 0;
+       clear_tsk_thread_flag(child, TIF_DELAYED_TRACE);
 }
 
 /*
@@ -118,7 +118,7 @@ static inline void singlestep_disable(struct task_struct *child)
 void ptrace_disable(struct task_struct *child)
 {
        singlestep_disable(child);
-       child->thread.work.syscall_trace = 0;
+       clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
 }
 
 long arch_ptrace(struct task_struct *child, long request, long addr, long data)
@@ -198,9 +198,9 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                        goto out_eio;
 
                if (request == PTRACE_SYSCALL)
-                       child->thread.work.syscall_trace = ~0;
+                       set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
                else
-                       child->thread.work.syscall_trace = 0;
+                       clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
                child->exit_code = data;
                singlestep_disable(child);
                wake_up_process(child);
@@ -223,10 +223,10 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                if (!valid_signal(data))
                        goto out_eio;
 
-               child->thread.work.syscall_trace = 0;
+               clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
                tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16);
                put_reg(child, PT_SR, tmp);
-               child->thread.work.delayed_trace = 1;
+               set_tsk_thread_flag(child, TIF_DELAYED_TRACE);
 
                child->exit_code = data;
                /* give it a chance to run. */
@@ -288,9 +288,6 @@ out_eio:
 
 asmlinkage void syscall_trace(void)
 {
-       if (!current->thread.work.delayed_trace &&
-           !current->thread.work.syscall_trace)
-               return;
        ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
                                 ? 0x80 : 0));
        /*
index f85093b8d54dca800e6f0e8a0cdfd5e5d3cfa23f..f4926315fb683feaae38234b06d150c6603946ad 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/config.h>
 #include <linux/init.h>
 #include <linux/pm.h>
+#include <linux/pm_legacy.h>
 #include <linux/slab.h>
 #include <linux/sysctl.h>
 #include <linux/jiffies.h>
index 0b21bed7ee553f5413253bc7808bc64b03f26ebb..2cab7629702c3f6b6066250c8c9bc8db2dd36241 100644 (file)
@@ -348,7 +348,7 @@ endpoint_stall(endpoint_t * ep)
 {
        u32 cs;
 
-       warn(__FUNCTION__);
+       warn("%s", __FUNCTION__);
 
        cs = au_readl(ep->reg->ctrl_stat) | USBDEV_CS_STALL;
        au_writel(cs, ep->reg->ctrl_stat);
@@ -360,7 +360,7 @@ endpoint_unstall(endpoint_t * ep)
 {
        u32 cs;
 
-       warn(__FUNCTION__);
+       warn("%s", __FUNCTION__);
 
        cs = au_readl(ep->reg->ctrl_stat) & ~USBDEV_CS_STALL;
        au_writel(cs, ep->reg->ctrl_stat);
index 5063c603fad441e56a92ee9ff3de3a165c11ab4f..8d60fa99fc4b992a402ec73dfa516b139f049d08 100644 (file)
@@ -24,7 +24,7 @@
  *    Copyright 2002-2004 MontaVista Software, Inc.
  *      PowerPC 44x support, Matt Porter <mporter@kernel.crashing.org>
  *    Copyright 2004 Freescale Semiconductor, Inc
- *      PowerPC e500 modifications, Kumar Gala <kumar.gala@freescale.com>
+ *      PowerPC e500 modifications, Kumar Gala <galak@kernel.crashing.org>
  *
  * This program is free software; you can redistribute  it and/or modify it
  * under  the terms of  the GNU General  Public License as published by the
index 3fa6a93adbd00664ebf554f649437554b01155d7..0fa3d27fef013f5ce5c3311e01d29f7e78b5ad17 100644 (file)
@@ -40,10 +40,6 @@ IOCTL_TABLE_START
 #define DECLARES
 #include "compat_ioctl.c"
 
-/* Little p (/dev/rtc, /dev/envctrl, etc.) */
-COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */
-COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
-
 IOCTL_TABLE_END
 
 int ioctl_table_size = ARRAY_SIZE(ioctl_start);
index af9ca0eb6d55b6aba7fd0903371cbeef313c2199..5d581bb3aa1249fa8826fe16a648f818c3f33cae 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Modifications by Kumar Gala (kumar.gala@freescale.com) to support
+ * Modifications by Kumar Gala (galak@kernel.crashing.org) to support
  * E500 Book E processors.
  *
  * Copyright 2004 Freescale Semiconductor, Inc
index 86124a94c9afbb8aea10ef6fce4e5e61639d7d25..26539cda602360ed1438b212ff6893e3a33d2818 100644 (file)
@@ -7,7 +7,7 @@
  * Copyright (c) 2004 Freescale Semiconductor, Inc
  *
  * Author: Andy Fleming
- * Maintainer: Kumar Gala <Kumar.Gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
index ef4356b29a979ff08459c9c500dd5d9a93fdded6..c45a6ad5f3b75d55dfe0d44a78b5dd255bb7ffde 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/cpumask.h>
 #include <linux/module.h>
 #include <linux/sysrq.h>
+#include <linux/interrupt.h>
 
 #include <asm/ptrace.h>
 #include <asm/string.h>
index 5063c603fad441e56a92ee9ff3de3a165c11ab4f..8d60fa99fc4b992a402ec73dfa516b139f049d08 100644 (file)
@@ -24,7 +24,7 @@
  *    Copyright 2002-2004 MontaVista Software, Inc.
  *      PowerPC 44x support, Matt Porter <mporter@kernel.crashing.org>
  *    Copyright 2004 Freescale Semiconductor, Inc
- *      PowerPC e500 modifications, Kumar Gala <kumar.gala@freescale.com>
+ *      PowerPC e500 modifications, Kumar Gala <galak@kernel.crashing.org>
  *
  * This program is free software; you can redistribute  it and/or modify it
  * under  the terms of  the GNU General  Public License as published by the
index af9ca0eb6d55b6aba7fd0903371cbeef313c2199..5d581bb3aa1249fa8826fe16a648f818c3f33cae 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Modifications by Kumar Gala (kumar.gala@freescale.com) to support
+ * Modifications by Kumar Gala (galak@kernel.crashing.org) to support
  * E500 Book E processors.
  *
  * Copyright 2004 Freescale Semiconductor, Inc
index 98edc75f4105b22149a967b3dfd624ffee64e766..04bdc39bf47b473f762ffbfc8d4a3d58c70671d9 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC834x SYS board specific routines
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2005 Freescale Semiconductor Inc.
  *
@@ -73,12 +73,19 @@ mpc83xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
             *       A      B      C      D
             */
        {
-               {PIRQA, PIRQB,  PIRQC,  PIRQD}, /* idsel 0x11 */
-               {PIRQC, PIRQD,  PIRQA,  PIRQB}, /* idsel 0x12 */
-               {PIRQD, PIRQA,  PIRQB,  PIRQC}  /* idsel 0x13 */
+               {PIRQA, PIRQB, PIRQC, PIRQD},   /* idsel 0x11 */
+               {PIRQC, PIRQD, PIRQA, PIRQB},   /* idsel 0x12 */
+               {PIRQD, PIRQA, PIRQB, PIRQC},   /* idsel 0x13 */
+               {0, 0, 0, 0},
+               {PIRQA, PIRQB, PIRQC, PIRQD},   /* idsel 0x15 */
+               {PIRQD, PIRQA, PIRQB, PIRQC},   /* idsel 0x16 */
+               {PIRQC, PIRQD, PIRQA, PIRQB},   /* idsel 0x17 */
+               {PIRQB, PIRQC, PIRQD, PIRQA},   /* idsel 0x18 */
+               {0, 0, 0, 0},                   /* idsel 0x19 */
+               {0, 0, 0, 0},                   /* idsel 0x20 */
        };
 
-       const long min_idsel = 0x11, max_idsel = 0x13, irqs_per_slot = 4;
+       const long min_idsel = 0x11, max_idsel = 0x20, irqs_per_slot = 4;
        return PCI_IRQ_TABLE_LOOKUP;
 }
 
index 58e44c042535bb6a11d2ab3bb6b1bb559ead4e7b..2e514d316fb85c3f651bd001d95923483390bd8d 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC834X SYS common board definitions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2005 Freescale Semiconductor, Inc.
  *
index 7e952c1228cba50c4cd3823e4612f4b0ef7705ca..c5cde97c6ef00b2832a9949c884b977d83578ba7 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC8540ADS board specific routines
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2004 Freescale Semiconductor Inc.
  *
index 3d05d7c4a938f2a36d54a3f3cd18de77c69ccf17..e48ca3a97397c37fdf80c71af2e3730b28767f76 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC8540ADS board definitions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2004 Freescale Semiconductor Inc.
  *
index e0e75568bc579213089e01eb71245588f1fad487..1a8e6c67355d67771651b61e7ec978df38501c15 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC8555CDS board definitions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2004 Freescale Semiconductor Inc.
  *
index 208433f1e93ae32a1bcf207073374146da8ef6a0..8e39a551709292fd8935d88a9c8591110cb42068 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC8560ADS board specific routines
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2004 Freescale Semiconductor Inc.
  *
index 7df885d73e9dc558f5dd4eb4a7843d20ea2794cd..143ae7eefa7c501341c5a3ce1c64ddb9be8ceb25 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC8540ADS board definitions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2004 Freescale Semiconductor Inc.
  *
index 16ad092d8a06396a4ffed0f44037c5dce99a44ec..17ce48fe3503e8ad4d5c54bd57dba949cdaaf36b 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC85xx ADS board common routines
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2004 Freescale Semiconductor Inc.
  *
index 84acf6e8d45ef895e02b02ed753a0514bf91fe8a..7b26bcc5d10d146cebc3befa7eefe600bf0fdde8 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC85XX ADS common board definitions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2004 Freescale Semiconductor Inc.
  *
index a21156967a5e130ea0ca70f76c9503965156edff..d8991b88dc9c531692584548fc601eafe898a7c0 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC85xx CDS board specific routines
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2004 Freescale Semiconductor, Inc
  *
index 12b292c6ae3225bb41eeea720de35a8770bdca0a..5b588cfd0e41bc16c3b102b685d4f11eb852546d 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC85xx CDS board definitions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2004 Freescale Semiconductor, Inc
  *
index b4ee1707a836ce81693f4eae22d8bc5efae75a2d..45a5b81b4ed1ae4da5e81fa88fe280ea930b3401 100644 (file)
@@ -3,7 +3,7 @@
  * 
  * Wind River SBC8560 board specific routines
  * 
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala
  *
  * Copyright 2004 Freescale Semiconductor Inc.
  * 
index 58884a63ebdbed4983e509ff3d24dec6fe045468..1e69b05931620a2f1420adea43a27cac67644f6b 100644 (file)
@@ -2317,6 +2317,14 @@ static struct pmac_mb_def pmac_mb_defs[] = {
                PMAC_TYPE_UNKNOWN_INTREPID,     intrepid_features,
                PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
        },
+       {       "PowerBook5,8",                 "PowerBook G4 15\"",
+               PMAC_TYPE_UNKNOWN_INTREPID,     intrepid_features,
+               PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
+       },
+       {       "PowerBook5,9",                 "PowerBook G4 17\"",
+               PMAC_TYPE_UNKNOWN_INTREPID,     intrepid_features,
+               PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
+       },
        {       "PowerBook6,1",                 "PowerBook G4 12\"",
                PMAC_TYPE_UNKNOWN_INTREPID,     intrepid_features,
                PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
index 6a1475c1e128ea30e39628c684fbea415963535d..71c9fca1fe9b9d4ce293e2793dcfe0a943cf04be 100644 (file)
@@ -3,7 +3,7 @@
  *
  * PQ2ADS platform support
  *
- * Author: Kumar Gala <kumar.gala@freescale.com>
+ * Author: Kumar Gala <galak@kernel.crashing.org>
  * Derived from: est8260_setup.c by Allen Curtis
  *
  * Copyright 2004 Freescale Semiconductor, Inc.
index 2b56a4fcf373e1e5e7a0aaa2ae03ae0c88f25058..a7ce7da8785c4c2ef256dd8144f9e2aa4cff7126 100644 (file)
@@ -3,7 +3,7 @@
  *
  * IPIC private definitions and structure.
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2005 Freescale Semiconductor, Inc
  *
index f43fbf9a9389c05cbc4e6303c35f7d64a5909ce7..847df4409982af4298af2852920127ab28c2bfee 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC83xx Device descriptions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2005 Freescale Semiconductor Inc.
  *
index da743446789b01882ae9375adc55145538e2b48c..a1523989aff4dfed46b9021aeb99e5cc235325d0 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC83xx System descriptions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2005 Freescale Semiconductor Inc.
  *
index 2ede677a0a53c37d24ad208a8a9447f7acb195b7..69949d255658c93b76fb24d3d6e52df6f7479a34 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC85xx Device descriptions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2005 Freescale Semiconductor Inc.
  *
index cb68d8c58348528d98a4414f7d607fe5c4ced4cf..397cfbcce5ea10b88e4834385415809de26b4c0e 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC85xx System descriptions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2005 Freescale Semiconductor Inc.
  *
index 2b5f0e70168717ed1ceafd8fee0912d9282d746f..92dc98b36bdeffb3145d4a2057bb0eb975db5235 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC8xx Device descriptions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2005 MontaVista Software, Inc. by Vitaly Bordug<vbordug@ru.mvista.com>
  *
index 3cc27d29e3af64e59fdf3a78d0549dfd6ac78070..d3c61752160398411682e2f0986c9461305ce1b4 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC8xx System descriptions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2005 MontaVista Software, Inc. by Vitaly Bordug <vbordug@ru.mvista.com>
  *
index 4da168a6ad0310777403b52b35ac3a9068963d97..1b5fe9e398d405b353d68018dbf1641b2ae37e6c 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC83XX common board code
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2005 Freescale Semiconductor Inc.
  *
index c766c1a5f786d62fee8413145563cf5634e0627d..a122a7322e5eeda3d5c1457985e3aea0a213b16c 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC83XX common board definitions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2005 Freescale Semiconductor Inc.
  *
index da841dacdc135175b92c6ff0d23be212bdf18655..19ad537225e4340c4c49485e082490144ecbd0ac 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC85xx support routines
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2004 Freescale Semiconductor Inc.
  *
index 2c8f304441bfcb943cd6ab4be5f32172d8c7e3b9..94edf32151dda0a80de4193d3a1550d41783562d 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC85xx support routines
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2004 Freescale Semiconductor Inc.
  *
index de2f90576577198d6019374173dc5e98192e6b89..1a47ff4b831d3d75e33eca61669c3fe869ea79cd 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC85XX common board code
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2004 Freescale Semiconductor Inc.
  *
index 6e6cfe162faf9b28bb6bd8fb043bef07ae92abc7..e340b0545fb5e2bbc7842ecba8066c75ccac53bf 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC85XX common board definitions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2004 Freescale Semiconductor Inc.
  *
index 603f0119081602e866d83324acf09f7c7a93808d..c0b93c4191eeac2b73e1803b1646bb61f61e4e3c 100644 (file)
@@ -3,7 +3,7 @@
  *
  * PPC System library functions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2005 Freescale Semiconductor Inc.
  * Copyright 2005 MontaVista, Inc. by Vitaly Bordug <vbordug@ru.mvista.com>
index e960fe9353256b82e611da8226988d679b2ba433..6ff3aab82fc3374c362951b82ab70d36315e3c16 100644 (file)
@@ -3,7 +3,7 @@
  *
  * PQ2 Device descriptions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * This file is licensed under the terms of the GNU General Public License
  * version 2. This program is licensed "as is" without any warranty of any
index 7b6c9ebdb9e3eaac47bda5c78fb46171586210ea..36d6e217994019200f0ccb390a8ac47e88721c6f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * PQ2 System descriptions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * This file is licensed under the terms of the GNU General Public License
  * version 2. This program is licensed "as is" without any warranty of any
index fbad2c360784edaa0d181812fdf0f8af39730c7e..47cc26e78957168500a5b22a7b598a25f156dc9c 100644 (file)
@@ -1261,6 +1261,7 @@ prom_n_addr_cells(struct device_node* np)
        /* No #address-cells property for the root node, default to 1 */
        return 1;
 }
+EXPORT_SYMBOL_GPL(prom_n_addr_cells);
 
 int
 prom_n_size_cells(struct device_node* np)
@@ -1276,6 +1277,7 @@ prom_n_size_cells(struct device_node* np)
        /* No #size-cells property for the root node, default to 1 */
        return 1;
 }
+EXPORT_SYMBOL_GPL(prom_n_size_cells);
 
 /**
  * Work out the sense (active-low level / active-high edge)
index 2e64e8c3e8e54c1aafbe66e34d3d64cf0f96f895..cb3cf0f228221154a2dd5e658b8550733a966866 100644 (file)
@@ -37,17 +37,43 @@ int __atomic_add_return(int i, atomic_t *v)
        spin_unlock_irqrestore(ATOMIC_HASH(v), flags);
        return ret;
 }
+EXPORT_SYMBOL(__atomic_add_return);
 
-void atomic_set(atomic_t *v, int i)
+int atomic_cmpxchg(atomic_t *v, int old, int new)
 {
+       int ret;
        unsigned long flags;
+
        spin_lock_irqsave(ATOMIC_HASH(v), flags);
+       ret = v->counter;
+       if (likely(ret == old))
+               v->counter = new;
 
-       v->counter = i;
+       spin_unlock_irqrestore(ATOMIC_HASH(v), flags);
+       return ret;
+}
+
+int atomic_add_unless(atomic_t *v, int a, int u)
+{
+       int ret;
+       unsigned long flags;
 
+       spin_lock_irqsave(ATOMIC_HASH(v), flags);
+       ret = v->counter;
+       if (ret != u)
+               v->counter += a;
        spin_unlock_irqrestore(ATOMIC_HASH(v), flags);
+       return ret != u;
 }
 
-EXPORT_SYMBOL(__atomic_add_return);
-EXPORT_SYMBOL(atomic_set);
+static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
+/* Atomic operations are already serializing */
+void atomic_set(atomic_t *v, int i)
+{
+       unsigned long flags;
 
+       spin_lock_irqsave(ATOMIC_HASH(v), flags);
+       v->counter = i;
+       spin_unlock_irqrestore(ATOMIC_HASH(v), flags);
+}
+EXPORT_SYMBOL(atomic_set);
index 94b05e8c906c78ca4701ccb766573f01b2798c75..2e168d16547f93234602de95762346a727b730d8 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/smp_lock.h>
+#include <linux/string.h>
 #include <linux/bitops.h>
 
 #include <asm/bitext.h>
index e62214354bb52b0313a1ff0cacba58b8f9e2a5f9..196b208665a223cf5624bae71c81e4484494029f 100644 (file)
 #define INCLUDES
 #include "compat_ioctl.c"
 #include <linux/syscalls.h>
-#include <asm/fbio.h>
-
-/* Use this to get at 32-bit user passed pointers. 
- * See sys_sparc32.c for description about it.
- */
-#define A(__x) compat_ptr(__x)
 
 #define CODE
 #include "compat_ioctl.c"
 
-struct  fbcmap32 {
-       int             index;          /* first element (0 origin) */
-       int             count;
-       u32             red;
-       u32             green;
-       u32             blue;
-};
-
-#define FBIOPUTCMAP32  _IOW('F', 3, struct fbcmap32)
-#define FBIOGETCMAP32  _IOW('F', 4, struct fbcmap32)
-
-static int fbiogetputcmap(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
-       struct fbcmap32 __user *argp = (void __user *)arg;
-       struct fbcmap __user *p = compat_alloc_user_space(sizeof(*p));
-       u32 addr;
-       int ret;
-       
-       ret = copy_in_user(p, argp, 2 * sizeof(int));
-       ret |= get_user(addr, &argp->red);
-       ret |= put_user(compat_ptr(addr), &p->red);
-       ret |= get_user(addr, &argp->green);
-       ret |= put_user(compat_ptr(addr), &p->green);
-       ret |= get_user(addr, &argp->blue);
-       ret |= put_user(compat_ptr(addr), &p->blue);
-       if (ret)
-               return -EFAULT;
-       return sys_ioctl(fd, (cmd == FBIOPUTCMAP32) ? FBIOPUTCMAP_SPARC : FBIOGETCMAP_SPARC, (unsigned long)p);
-}
-
-struct fbcursor32 {
-       short set;              /* what to set, choose from the list above */
-       short enable;           /* cursor on/off */
-       struct fbcurpos pos;    /* cursor position */
-       struct fbcurpos hot;    /* cursor hot spot */
-       struct fbcmap32 cmap;   /* color map info */
-       struct fbcurpos size;   /* cursor bit map size */
-       u32     image;          /* cursor image bits */
-       u32     mask;           /* cursor mask bits */
-};
-       
-#define FBIOSCURSOR32  _IOW('F', 24, struct fbcursor32)
-#define FBIOGCURSOR32  _IOW('F', 25, struct fbcursor32)
-
-static int fbiogscursor(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
-       struct fbcursor __user *p = compat_alloc_user_space(sizeof(*p));
-       struct fbcursor32 __user *argp =  (void __user *)arg;
-       compat_uptr_t addr;
-       int ret;
-       
-       ret = copy_in_user(p, argp,
-                             2 * sizeof (short) + 2 * sizeof(struct fbcurpos));
-       ret |= copy_in_user(&p->size, &argp->size, sizeof(struct fbcurpos));
-       ret |= copy_in_user(&p->cmap, &argp->cmap, 2 * sizeof(int));
-       ret |= get_user(addr, &argp->cmap.red);
-       ret |= put_user(compat_ptr(addr), &p->cmap.red);
-       ret |= get_user(addr, &argp->cmap.green);
-       ret |= put_user(compat_ptr(addr), &p->cmap.green);
-       ret |= get_user(addr, &argp->cmap.blue);
-       ret |= put_user(compat_ptr(addr), &p->cmap.blue);
-       ret |= get_user(addr, &argp->mask);
-       ret |= put_user(compat_ptr(addr), &p->mask);
-       ret |= get_user(addr, &argp->image);
-       ret |= put_user(compat_ptr(addr), &p->image);
-       if (ret)
-               return -EFAULT;
-       return sys_ioctl (fd, FBIOSCURSOR, (unsigned long)p);
-}
-
 #define COMPATIBLE_IOCTL(cmd)          HANDLE_IOCTL((cmd),sys_ioctl)
 #define HANDLE_IOCTL(cmd,handler)      { (cmd), (ioctl_trans_handler_t)(handler), NULL },
 #define IOCTL_TABLE_START \
@@ -103,22 +27,6 @@ IOCTL_TABLE_START
 #include <linux/compat_ioctl.h>
 #define DECLARES
 #include "compat_ioctl.c"
-COMPATIBLE_IOCTL(FBIOGTYPE)
-COMPATIBLE_IOCTL(FBIOSATTR)
-COMPATIBLE_IOCTL(FBIOGATTR)
-COMPATIBLE_IOCTL(FBIOSVIDEO)
-COMPATIBLE_IOCTL(FBIOGVIDEO)
-COMPATIBLE_IOCTL(FBIOGCURSOR32)  /* This is not implemented yet. Later it should be converted... */
-COMPATIBLE_IOCTL(FBIOSCURPOS)
-COMPATIBLE_IOCTL(FBIOGCURPOS)
-COMPATIBLE_IOCTL(FBIOGCURMAX)
-/* Little k */
-/* Little v, the video4linux ioctls */
-/* And these ioctls need translation */
-/* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */
-HANDLE_IOCTL(FBIOPUTCMAP32, fbiogetputcmap)
-HANDLE_IOCTL(FBIOGETCMAP32, fbiogetputcmap)
-HANDLE_IOCTL(FBIOSCURSOR32, fbiogscursor)
 #if 0
 HANDLE_IOCTL(RTC32_IRQP_READ, do_rtc_ioctl)
 HANDLE_IOCTL(RTC32_IRQP_SET, do_rtc_ioctl)
index 3b5f47c469073df1ca4b0bac35bc06dff2aaaeaf..563301fe5df8bbfb4bfd5680e5489d23b91e0ba4 100644 (file)
@@ -7,7 +7,6 @@ config UML
        bool
        default y
 
-# XXX: does UM have a mmu/swap?
 config MMU
        bool
        default y
@@ -36,12 +35,6 @@ config IRQ_RELEASE_METHOD
        bool
        default y
 
-menu "Host processor type and features"
-
-source "arch/i386/Kconfig.cpu"
-
-endmenu
-
 menu "UML-specific options"
 
 config MODE_TT
@@ -209,7 +202,8 @@ config MAGIC_SYSRQ
 config SMP
        bool "Symmetric multi-processing support (EXPERIMENTAL)"
        default n
-       depends on (MODE_TT && EXPERIMENTAL && !SMP_BROKEN) || (BROKEN && SMP_BROKEN)
+       #SMP_BROKEN is for x86_64.
+       depends on MODE_TT && EXPERIMENTAL && (!SMP_BROKEN || (BROKEN && SMP_BROKEN))
        help
        This option enables UML SMP support.
        It is NOT related to having a real SMP box. Not directly, at least.
index 5d92cacd56c6a71cddf0c88026d7788fedbd3e39..c71b39a677aa49b41bab93ffaf7374800948abb0 100644 (file)
@@ -1,3 +1,9 @@
+menu "Host processor type and features"
+
+source "arch/i386/Kconfig.cpu"
+
+endmenu
+
 config UML_X86
        bool
        default y
@@ -42,7 +48,3 @@ config ARCH_HAS_SC_SIGNALS
 config ARCH_REUSE_HOST_VSYSCALL_AREA
        bool
        default y
-
-config X86_CMPXCHG
-       bool
-       default y
index 1f7dcb064aee65602eac0d5fbb18cc77aad6754e..7a0e04e34bf96f2cb4a89a6be34cfbe8f1e6cf90 100644 (file)
@@ -35,4 +35,3 @@ cflags-y += $(call cc-option,-mpreferred-stack-boundary=2)
 
 CFLAGS += $(cflags-y)
 USER_CFLAGS += $(cflags-y)
-
index 16e7dc89f61d78e2508b71a3c6cb2bb046c09785..5b58fad45290fc8ad26c50034979224389e16cda 100644 (file)
@@ -89,8 +89,7 @@ static int not_configged_write(int fd, const char *buf, int len, void *data)
        return(-EIO);
 }
 
-static int not_configged_console_write(int fd, const char *buf, int len,
-                                      void *data)
+static int not_configged_console_write(int fd, const char *buf, int len)
 {
        my_puts("Using a channel type which is configured out of "
               "UML\n");
@@ -299,7 +298,7 @@ int console_write_chan(struct list_head *chans, const char *buf, int len)
                chan = list_entry(ele, struct chan, list);
                if(!chan->output || (chan->ops->console_write == NULL))
                        continue;
-               n = chan->ops->console_write(chan->fd, buf, len, chan->data);
+               n = chan->ops->console_write(chan->fd, buf, len);
                if(chan->primary) ret = n;
        }
        return(ret);
index 1c55d580248993c9ef1dd7249ccf8bb8e548c745..5d50d4a44abf4879220e045b9eaecf0d48d8f9d7 100644 (file)
@@ -20,7 +20,7 @@
 #include "choose-mode.h"
 #include "mode.h"
 
-int generic_console_write(int fd, const char *buf, int n, void *unused)
+int generic_console_write(int fd, const char *buf, int n)
 {
        struct termios save, new;
        int err;
index c1b03f7c1daa962195a6e8ee26d09580abfab615..1bb085b2824d19e25e88ce4e931bcfba25f07a76 100644 (file)
@@ -98,7 +98,7 @@ static int connect_to_switch(struct daemon_data *pri)
                printk("daemon_open : control setup request failed, err = %d\n",
                       -n);
                err = -ENOTCONN;
-               goto out;               
+               goto out_free;
        }
 
        n = os_read_file(pri->control, sun, sizeof(*sun));
@@ -106,12 +106,14 @@ static int connect_to_switch(struct daemon_data *pri)
                printk("daemon_open : read of data socket failed, err = %d\n",
                       -n);
                err = -ENOTCONN;
-               goto out_close;         
+               goto out_free;
        }
 
        pri->data_addr = sun;
        return(fd);
 
+ out_free:
+       kfree(sun);
  out_close:
        os_close_file(fd);
  out:
index f0b888f66e0561ad3f73af964428f0d42c96e674..3296e86a03a5cd3a197007c1593e127fee3c1d7c 100644 (file)
@@ -76,13 +76,6 @@ static void fd_close(int fd, void *d)
        }
 }
 
-static int fd_console_write(int fd, const char *buf, int n, void *d)
-{
-       struct fd_chan *data = d;
-
-       return(generic_console_write(fd, buf, n, &data->tt));
-}
-
 struct chan_ops fd_ops = {
        .type           = "fd",
        .init           = fd_init,
@@ -90,7 +83,7 @@ struct chan_ops fd_ops = {
        .close          = fd_close,
        .read           = generic_read,
        .write          = generic_write,
-       .console_write  = fd_console_write,
+       .console_write  = generic_console_write,
        .window_size    = generic_window_size,
        .free           = generic_free,
        .winch          = 1,
index 5db136e2651cc20a7883ad6ce3048423bbfaa8dd..afe85bfa66e0872eabc55cd1e0b25dace52900bc 100644 (file)
@@ -54,7 +54,7 @@ static int mcast_open(void *data)
        struct mcast_data *pri = data;
        struct sockaddr_in *sin = pri->mcast_addr;
        struct ip_mreq mreq;
-       int fd, yes = 1, err = 0;
+       int fd, yes = 1, err = -EINVAL;
 
 
        if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0))
@@ -63,40 +63,40 @@ static int mcast_open(void *data)
        fd = socket(AF_INET, SOCK_DGRAM, 0);
 
        if (fd < 0){
+               err = -errno;
                printk("mcast_open : data socket failed, errno = %d\n", 
                       errno);
-               err = -errno;
                goto out;
        }
 
        if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) {
+               err = -errno;
                printk("mcast_open: SO_REUSEADDR failed, errno = %d\n",
                        errno);
-               err = -errno;
                goto out_close;
        }
 
        /* set ttl according to config */
        if (setsockopt(fd, SOL_IP, IP_MULTICAST_TTL, &pri->ttl,
                       sizeof(pri->ttl)) < 0) {
+               err = -errno;
                printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n",
                        errno);
-               err = -errno;
                goto out_close;
        }
 
        /* set LOOP, so data does get fed back to local sockets */
        if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) {
+               err = -errno;
                printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n",
                        errno);
-               err = -errno;
                goto out_close;
        }
 
        /* bind socket to mcast address */
        if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) {
-               printk("mcast_open : data bind failed, errno = %d\n", errno);
                err = -errno;
+               printk("mcast_open : data bind failed, errno = %d\n", errno);
                goto out_close;
        }               
        
@@ -105,22 +105,22 @@ static int mcast_open(void *data)
        mreq.imr_interface.s_addr = 0;
        if (setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP, 
                       &mreq, sizeof(mreq)) < 0) {
+               err = -errno;
                printk("mcast_open: IP_ADD_MEMBERSHIP failed, error = %d\n",
                        errno);
                printk("There appears not to be a multicast-capable network "
                       "interface on the host.\n");
                printk("eth0 should be configured in order to use the "
                       "multicast transport.\n");
-               err = -errno;
-                goto out_close;
+               goto out_close;
        }
 
        return fd;
 
  out_close:
-        os_close_file(fd);
+       os_close_file(fd);
  out:
-        return err;
+       return err;
 }
 
 static void mcast_close(int fd, void *data)
index ed4a1a6c5d83fa03fb515f69a2fc30340f596301..c43e8bb3250264940af52ea528fe6a378fe41f67 100644 (file)
@@ -100,13 +100,6 @@ static void port_close(int fd, void *d)
        os_close_file(fd);
 }
 
-static int port_console_write(int fd, const char *buf, int n, void *d)
-{
-       struct port_chan *data = d;
-
-       return(generic_console_write(fd, buf, n, &data->tt));
-}
-
 struct chan_ops port_ops = {
        .type           = "port",
        .init           = port_init,
@@ -114,7 +107,7 @@ struct chan_ops port_ops = {
        .close          = port_close,
        .read           = generic_read,
        .write          = generic_write,
-       .console_write  = port_console_write,
+       .console_write  = generic_console_write,
        .window_size    = generic_window_size,
        .free           = port_free,
        .winch          = 1,
index 0306a1b215b7d8016f04bd3eca2dba996ee53dfa..1c555c38de4d0184adb129755058b71a1449553f 100644 (file)
@@ -118,13 +118,6 @@ static int pty_open(int input, int output, int primary, void *d,
        return(fd);
 }
 
-static int pty_console_write(int fd, const char *buf, int n, void *d)
-{
-       struct pty_chan *data = d;
-
-       return(generic_console_write(fd, buf, n, &data->tt));
-}
-
 struct chan_ops pty_ops = {
        .type           = "pty",
        .init           = pty_chan_init,
@@ -132,7 +125,7 @@ struct chan_ops pty_ops = {
        .close          = generic_close,
        .read           = generic_read,
        .write          = generic_write,
-       .console_write  = pty_console_write,
+       .console_write  = generic_console_write,
        .window_size    = generic_window_size,
        .free           = generic_free,
        .winch          = 0,
@@ -145,7 +138,7 @@ struct chan_ops pts_ops = {
        .close          = generic_close,
        .read           = generic_read,
        .write          = generic_write,
-       .console_write  = pty_console_write,
+       .console_write  = generic_console_write,
        .window_size    = generic_window_size,
        .free           = generic_free,
        .winch          = 0,
index 6fbb670ee2741a73d30dfa9eb20e1cad2d78f00a..94c9265a4f2ca54e034f4f79c11bf48ee061bdf2 100644 (file)
@@ -60,13 +60,6 @@ static int tty_open(int input, int output, int primary, void *d,
        return(fd);
 }
 
-static int tty_console_write(int fd, const char *buf, int n, void *d)
-{
-       struct tty_chan *data = d;
-
-       return(generic_console_write(fd, buf, n, &data->tt));
-}
-
 struct chan_ops tty_ops = {
        .type           = "tty",
        .init           = tty_chan_init,
@@ -74,7 +67,7 @@ struct chan_ops tty_ops = {
        .close          = generic_close,
        .read           = generic_read,
        .write          = generic_write,
-       .console_write  = tty_console_write,
+       .console_write  = generic_console_write,
        .window_size    = generic_window_size,
        .free           = generic_free,
        .winch          = 0,
index b530f1a6540d506a556e38c90dc3afec63f2f7f6..aaa63666104333f487d01521bb6792250cb40a14 100644 (file)
@@ -194,13 +194,6 @@ static void xterm_free(void *d)
        free(d);
 }
 
-static int xterm_console_write(int fd, const char *buf, int n, void *d)
-{
-       struct xterm_chan *data = d;
-
-       return(generic_console_write(fd, buf, n, &data->tt));
-}
-
 struct chan_ops xterm_ops = {
        .type           = "xterm",
        .init           = xterm_init,
@@ -208,7 +201,7 @@ struct chan_ops xterm_ops = {
        .close          = xterm_close,
        .read           = generic_read,
        .write          = generic_write,
-       .console_write  = xterm_console_write,
+       .console_write  = generic_console_write,
        .window_size    = generic_window_size,
        .free           = xterm_free,
        .winch          = 1,
index f77d9aa4c164f103995dd83cd0407a226d31a7cd..659bb3cac32f51f3e7f8017bd137270e068cabf6 100644 (file)
@@ -25,7 +25,7 @@ struct chan_ops {
        void (*close)(int, void *);
        int (*read)(int, char *, void *);
        int (*write)(int, const char *, int, void *);
-       int (*console_write)(int, const char *, int, void *);
+       int (*console_write)(int, const char *, int);
        int (*window_size)(int, void *, unsigned short *, unsigned short *);
        void (*free)(void *);
        int winch;
@@ -37,7 +37,7 @@ extern struct chan_ops fd_ops, null_ops, port_ops, pts_ops, pty_ops, tty_ops,
 extern void generic_close(int fd, void *unused);
 extern int generic_read(int fd, char *c_out, void *unused);
 extern int generic_write(int fd, const char *buf, int n, void *unused);
-extern int generic_console_write(int fd, const char *buf, int n, void *state);
+extern int generic_console_write(int fd, const char *buf, int n);
 extern int generic_window_size(int fd, void *unused, unsigned short *rows_out,
                               unsigned short *cols_out);
 extern void generic_free(void *data);
index 84c0868cd5613610c4f874aa280283d2d5f0a35b..f8760a3f43b0f0f6e0402f21089d87e56ba62c29 100644 (file)
 #include "uaccess-skas.h"
 #endif
 
+#define __under_task_size(addr, size) \
+       (((unsigned long) (addr) < TASK_SIZE) && \
+         (((unsigned long) (addr) + (size)) < TASK_SIZE))
+
+#define __access_ok_vsyscall(type, addr, size) \
+        ((type == VERIFY_READ) && \
+         ((unsigned long) (addr) >= FIXADDR_USER_START) && \
+         ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \
+         ((unsigned long) (addr) + (size) >= (unsigned long)(addr)))
+
+#define __addr_range_nowrap(addr, size) \
+       ((unsigned long) (addr) <= ((unsigned long) (addr) + (size)))
+
 #define access_ok(type, addr, size) \
-       CHOOSE_MODE_PROC(access_ok_tt, access_ok_skas, type, addr, size)
+       (__addr_range_nowrap(addr, size) && \
+        (__under_task_size(addr, size) || \
+         __access_ok_vsyscall(type, addr, size) || \
+         segment_eq(get_fs(), KERNEL_DS) || \
+         CHOOSE_MODE_PROC(access_ok_tt, access_ok_skas, type, addr, size)))
 
 static inline int copy_from_user(void *to, const void __user *from, int n)
 {
index 7da0c2def0ef1c6ca8c2034619ad3ba2777a1b55..f611f83ad4ff815397f1746a10ba2e5656c3d9bc 100644 (file)
@@ -9,14 +9,8 @@
 #include "asm/errno.h"
 #include "asm/fixmap.h"
 
-#define access_ok_skas(type, addr, size) \
-       ((segment_eq(get_fs(), KERNEL_DS)) || \
-        (((unsigned long) (addr) < TASK_SIZE) && \
-         ((unsigned long) (addr) + (size) <= TASK_SIZE)) || \
-        ((type == VERIFY_READ ) && \
-         ((unsigned long) (addr) >= FIXADDR_USER_START) && \
-         ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \
-         ((unsigned long) (addr) + (size) >= (unsigned long)(addr))))
+/* No SKAS-specific checking. */
+#define access_ok_skas(type, addr, size) 0
 
 extern int copy_from_user_skas(void *to, const void __user *from, int n);
 extern int copy_to_user_skas(void __user *to, const void *from, int n);
index 75195281081e10252e840ea2bf533e3cd193a27d..a5a47528dec7a68cbab0c9e290461a66eea6af2c 100644 (file)
@@ -143,7 +143,7 @@ int copy_from_user_skas(void *to, const void __user *from, int n)
                return(0);
        }
 
-       return(access_ok_skas(VERIFY_READ, from, n) ?
+       return(access_ok(VERIFY_READ, from, n) ?
               buffer_op((unsigned long) from, n, 0, copy_chunk_from_user, &to):
               n);
 }
@@ -164,7 +164,7 @@ int copy_to_user_skas(void __user *to, const void *from, int n)
                return(0);
        }
 
-       return(access_ok_skas(VERIFY_WRITE, to, n) ?
+       return(access_ok(VERIFY_WRITE, to, n) ?
               buffer_op((unsigned long) to, n, 1, copy_chunk_to_user, &from) :
               n);
 }
@@ -193,7 +193,7 @@ int strncpy_from_user_skas(char *dst, const char __user *src, int count)
                return(strnlen(dst, count));
        }
 
-       if(!access_ok_skas(VERIFY_READ, src, 1))
+       if(!access_ok(VERIFY_READ, src, 1))
                return(-EFAULT);
 
        n = buffer_op((unsigned long) src, count, 0, strncpy_chunk_from_user,
@@ -221,7 +221,7 @@ int clear_user_skas(void __user *mem, int len)
                return(0);
        }
 
-       return(access_ok_skas(VERIFY_WRITE, mem, len) ?
+       return(access_ok(VERIFY_WRITE, mem, len) ?
               buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL) : len);
 }
 
index 95c8f8733bafb516e67d044d6d78a87779a46c98..0d4c10a736077702556fea90e281b82b109ada06 100644 (file)
@@ -95,7 +95,16 @@ survive:
                pte = pte_offset_kernel(pmd, address);
        } while(!pte_present(*pte));
        err = 0;
+       /* The below warning was added in place of
+        *      pte_mkyoung(); if (is_write) pte_mkdirty();
+        * If it's triggered, we'd see normally a hang here (a clean pte is
+        * marked read-only to emulate the dirty bit).
+        * However, the generic code can mark a PTE writable but clean on a
+        * concurrent read fault, triggering this harmlessly. So comment it out.
+        */
+#if 0
        WARN_ON(!pte_young(*pte) || (is_write && !pte_dirty(*pte)));
+#endif
        flush_tlb_page(vma, address);
 out:
        up_read(&mm->mmap_sem);
index dc2ebfa8c54fb621c6d790659417f4f68c010d26..b9bfe9c481c4eadd31601623bbe2e9de89dec1ea 100644 (file)
 extern unsigned long end_vm;
 extern unsigned long uml_physmem;
 
-#define under_task_size(addr, size) \
-       (((unsigned long) (addr) < TASK_SIZE) && \
-         (((unsigned long) (addr) + (size)) < TASK_SIZE))
-
 #define is_stack(addr, size) \
        (((unsigned long) (addr) < STACK_TOP) && \
         ((unsigned long) (addr) >= STACK_TOP - ABOVE_KMEM) && \
         (((unsigned long) (addr) + (size)) <= STACK_TOP))
 
 #define access_ok_tt(type, addr, size) \
-       ((type == VERIFY_READ) || (segment_eq(get_fs(), KERNEL_DS)) || \
-         (((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) && \
-          (under_task_size(addr, size) || is_stack(addr, size))))
+       (is_stack(addr, size))
 
 extern unsigned long get_fault_addr(void);
 
index a72aa632972f4ebc72c66ac09593600f7caefd33..1cb60726567ed43da205922b9b004fcd42be8a7b 100644 (file)
@@ -8,7 +8,7 @@
 
 int copy_from_user_tt(void *to, const void __user *from, int n)
 {
-       if(!access_ok_tt(VERIFY_READ, from, n))
+       if(!access_ok(VERIFY_READ, from, n))
                return(n);
 
        return(__do_copy_from_user(to, from, n, &current->thread.fault_addr,
@@ -17,7 +17,7 @@ int copy_from_user_tt(void *to, const void __user *from, int n)
 
 int copy_to_user_tt(void __user *to, const void *from, int n)
 {
-       if(!access_ok_tt(VERIFY_WRITE, to, n))
+       if(!access_ok(VERIFY_WRITE, to, n))
                return(n);
 
        return(__do_copy_to_user(to, from, n, &current->thread.fault_addr,
@@ -28,7 +28,7 @@ int strncpy_from_user_tt(char *dst, const char __user *src, int count)
 {
        int n;
 
-       if(!access_ok_tt(VERIFY_READ, src, 1))
+       if(!access_ok(VERIFY_READ, src, 1))
                return(-EFAULT);
 
        n = __do_strncpy_from_user(dst, src, count,
@@ -47,7 +47,7 @@ int __clear_user_tt(void __user *mem, int len)
 
 int clear_user_tt(void __user *mem, int len)
 {
-       if(!access_ok_tt(VERIFY_WRITE, mem, len))
+       if(!access_ok(VERIFY_WRITE, mem, len))
                return(len);
 
        return(__do_clear_user(mem, len, &current->thread.fault_addr,
index c6c9791d77c18aa2ed7025f7b9c7a0b07e18f132..a9368d4c4aba1ceba5df433b9fdfb90713f1f543 100644 (file)
@@ -515,7 +515,7 @@ void i8254_timer_resume(void)
 }
 
 static struct sysdev_class timer_sysclass = {
-       set_kset_name("timer"),
+       set_kset_name("timer_pit"),
        .resume         = timer_resume,
 };
 
index ecacca9c877eb286bdc77eb2aea5906cc3235e18..2b64f5852bfd7bb64afe6317d8df72d300c6a6e9 100644 (file)
@@ -861,8 +861,8 @@ __cfq_slice_expired(struct cfq_data *cfqd, struct cfq_queue *cfqq,
         * store what was left of this slice, if the queue idled out
         * or was preempted
         */
-       if (time_after(now, cfqq->slice_end))
-               cfqq->slice_left = now - cfqq->slice_end;
+       if (time_after(cfqq->slice_end, now))
+               cfqq->slice_left = cfqq->slice_end - now;
        else
                cfqq->slice_left = 0;
 
@@ -999,7 +999,7 @@ cfq_prio_to_maxrq(struct cfq_data *cfqd, struct cfq_queue *cfqq)
 /*
  * get next queue for service
  */
-static struct cfq_queue *cfq_select_queue(struct cfq_data *cfqd, int force)
+static struct cfq_queue *cfq_select_queue(struct cfq_data *cfqd)
 {
        unsigned long now = jiffies;
        struct cfq_queue *cfqq;
@@ -1023,7 +1023,7 @@ static struct cfq_queue *cfq_select_queue(struct cfq_data *cfqd, int force)
         */
        if (!RB_EMPTY(&cfqq->sort_list))
                goto keep_queue;
-       else if (!force && cfq_cfqq_class_sync(cfqq) &&
+       else if (cfq_cfqq_class_sync(cfqq) &&
                 time_before(now, cfqq->slice_end)) {
                if (cfq_arm_slice_timer(cfqd, cfqq))
                        return NULL;
@@ -1091,6 +1091,42 @@ __cfq_dispatch_requests(struct cfq_data *cfqd, struct cfq_queue *cfqq,
        return dispatched;
 }
 
+static int
+cfq_forced_dispatch_cfqqs(struct list_head *list)
+{
+       int dispatched = 0;
+       struct cfq_queue *cfqq, *next;
+       struct cfq_rq *crq;
+
+       list_for_each_entry_safe(cfqq, next, list, cfq_list) {
+               while ((crq = cfqq->next_crq)) {
+                       cfq_dispatch_insert(cfqq->cfqd->queue, crq);
+                       dispatched++;
+               }
+               BUG_ON(!list_empty(&cfqq->fifo));
+       }
+       return dispatched;
+}
+
+static int
+cfq_forced_dispatch(struct cfq_data *cfqd)
+{
+       int i, dispatched = 0;
+
+       for (i = 0; i < CFQ_PRIO_LISTS; i++)
+               dispatched += cfq_forced_dispatch_cfqqs(&cfqd->rr_list[i]);
+
+       dispatched += cfq_forced_dispatch_cfqqs(&cfqd->busy_rr);
+       dispatched += cfq_forced_dispatch_cfqqs(&cfqd->cur_rr);
+       dispatched += cfq_forced_dispatch_cfqqs(&cfqd->idle_rr);
+
+       cfq_slice_expired(cfqd, 0);
+
+       BUG_ON(cfqd->busy_queues);
+
+       return dispatched;
+}
+
 static int
 cfq_dispatch_requests(request_queue_t *q, int force)
 {
@@ -1100,7 +1136,10 @@ cfq_dispatch_requests(request_queue_t *q, int force)
        if (!cfqd->busy_queues)
                return 0;
 
-       cfqq = cfq_select_queue(cfqd, force);
+       if (unlikely(force))
+               return cfq_forced_dispatch(cfqd);
+
+       cfqq = cfq_select_queue(cfqd);
        if (cfqq) {
                int max_dispatch;
 
@@ -1115,12 +1154,9 @@ cfq_dispatch_requests(request_queue_t *q, int force)
                cfq_clear_cfqq_wait_request(cfqq);
                del_timer(&cfqd->idle_slice_timer);
 
-               if (!force) {
-                       max_dispatch = cfqd->cfq_quantum;
-                       if (cfq_class_idle(cfqq))
-                               max_dispatch = 1;
-               } else
-                       max_dispatch = INT_MAX;
+               max_dispatch = cfqd->cfq_quantum;
+               if (cfq_class_idle(cfqq))
+                       max_dispatch = 1;
 
                return __cfq_dispatch_requests(cfqd, cfqq, max_dispatch);
        }
index d4a49a3df829674bbb4bb476f271fc721c6fa9f3..e4c58827bb4660bc21bef638a3c9a926b2fc49c1 100644 (file)
@@ -155,9 +155,10 @@ static void elevator_setup_default(void)
        /*
         * If the given scheduler is not available, fall back to no-op.
         */
-       if (!(e = elevator_find(chosen_elevator)))
+       if ((e = elevator_find(chosen_elevator)))
+               elevator_put(e);
+       else
                strcpy(chosen_elevator, "noop");
-       elevator_put(e);
 }
 
 static int __init elevator_setup(char *str)
@@ -190,14 +191,14 @@ int elevator_init(request_queue_t *q, char *name)
 
        eq = kmalloc(sizeof(struct elevator_queue), GFP_KERNEL);
        if (!eq) {
-               elevator_put(e->elevator_type);
+               elevator_put(e);
                return -ENOMEM;
        }
 
        ret = elevator_attach(q, e, eq);
        if (ret) {
                kfree(eq);
-               elevator_put(e->elevator_type);
+               elevator_put(e);
        }
 
        return ret;
@@ -225,6 +226,7 @@ void elv_dispatch_sort(request_queue_t *q, struct request *rq)
 
        if (q->last_merge == rq)
                q->last_merge = NULL;
+       q->nr_sorted--;
 
        boundary = q->end_sector;
 
@@ -283,6 +285,7 @@ void elv_merge_requests(request_queue_t *q, struct request *rq,
 
        if (e->ops->elevator_merge_req_fn)
                e->ops->elevator_merge_req_fn(q, rq, next);
+       q->nr_sorted--;
 
        q->last_merge = rq;
 }
@@ -314,6 +317,20 @@ void elv_requeue_request(request_queue_t *q, struct request *rq)
        __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0);
 }
 
+static void elv_drain_elevator(request_queue_t *q)
+{
+       static int printed;
+       while (q->elevator->ops->elevator_dispatch_fn(q, 1))
+               ;
+       if (q->nr_sorted == 0)
+               return;
+       if (printed++ < 10) {
+               printk(KERN_ERR "%s: forced dispatching is broken "
+                      "(nr_sorted=%u), please report this\n",
+                      q->elevator->elevator_type->elevator_name, q->nr_sorted);
+       }
+}
+
 void __elv_add_request(request_queue_t *q, struct request *rq, int where,
                       int plug)
 {
@@ -348,9 +365,7 @@ void __elv_add_request(request_queue_t *q, struct request *rq, int where,
 
        case ELEVATOR_INSERT_BACK:
                rq->flags |= REQ_SOFTBARRIER;
-
-               while (q->elevator->ops->elevator_dispatch_fn(q, 1))
-                       ;
+               elv_drain_elevator(q);
                list_add_tail(&rq->queuelist, &q->queue_head);
                /*
                 * We kick the queue here for the following reasons.
@@ -369,6 +384,7 @@ void __elv_add_request(request_queue_t *q, struct request *rq, int where,
        case ELEVATOR_INSERT_SORT:
                BUG_ON(!blk_fs_request(rq));
                rq->flags |= REQ_SORTED;
+               q->nr_sorted++;
                if (q->last_merge == NULL && rq_mergeable(rq))
                        q->last_merge = rq;
                /*
@@ -525,33 +541,19 @@ int elv_queue_empty(request_queue_t *q)
 
 struct request *elv_latter_request(request_queue_t *q, struct request *rq)
 {
-       struct list_head *next;
-
        elevator_t *e = q->elevator;
 
        if (e->ops->elevator_latter_req_fn)
                return e->ops->elevator_latter_req_fn(q, rq);
-
-       next = rq->queuelist.next;
-       if (next != &q->queue_head && next != &rq->queuelist)
-               return list_entry_rq(next);
-
        return NULL;
 }
 
 struct request *elv_former_request(request_queue_t *q, struct request *rq)
 {
-       struct list_head *prev;
-
        elevator_t *e = q->elevator;
 
        if (e->ops->elevator_former_req_fn)
                return e->ops->elevator_former_req_fn(q, rq);
-
-       prev = rq->queuelist.prev;
-       if (prev != &q->queue_head && prev != &rq->queuelist)
-               return list_entry_rq(prev);
-
        return NULL;
 }
 
@@ -691,13 +693,15 @@ static void elevator_switch(request_queue_t *q, struct elevator_type *new_e)
 
        set_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags);
 
-       while (q->elevator->ops->elevator_dispatch_fn(q, 1))
-               ;
+       elv_drain_elevator(q);
 
        while (q->rq.elvpriv) {
+               blk_remove_plug(q);
+               q->request_fn(q);
                spin_unlock_irq(q->queue_lock);
                msleep(10);
                spin_lock_irq(q->queue_lock);
+               elv_drain_elevator(q);
        }
 
        spin_unlock_irq(q->queue_lock);
@@ -744,13 +748,15 @@ error:
 ssize_t elv_iosched_store(request_queue_t *q, const char *name, size_t count)
 {
        char elevator_name[ELV_NAME_MAX];
+       size_t len;
        struct elevator_type *e;
 
-       memset(elevator_name, 0, sizeof(elevator_name));
-       strncpy(elevator_name, name, sizeof(elevator_name));
+       elevator_name[sizeof(elevator_name) - 1] = '\0';
+       strncpy(elevator_name, name, sizeof(elevator_name) - 1);
+       len = strlen(elevator_name);
 
-       if (elevator_name[strlen(elevator_name) - 1] == '\n')
-               elevator_name[strlen(elevator_name) - 1] = '\0';
+       if (len && elevator_name[len - 1] == '\n')
+               elevator_name[len - 1] = '\0';
 
        e = elevator_get(elevator_name);
        if (!e) {
index 54aec4a1ae13abd6bf55a1f42d42a946e6c2a4b8..f04609d553b8530e97c2d4106d0f21381763d74e 100644 (file)
@@ -391,12 +391,14 @@ static ssize_t disk_stats_read(struct gendisk * disk, char *page)
                "%8u %8u %8llu %8u "
                "%8u %8u %8u"
                "\n",
-               disk_stat_read(disk, ios[0]), disk_stat_read(disk, merges[0]),
-               (unsigned long long)disk_stat_read(disk, sectors[0]),
-               jiffies_to_msecs(disk_stat_read(disk, ticks[0])),
-               disk_stat_read(disk, ios[1]), disk_stat_read(disk, merges[1]),
-               (unsigned long long)disk_stat_read(disk, sectors[1]),
-               jiffies_to_msecs(disk_stat_read(disk, ticks[1])),
+               disk_stat_read(disk, ios[READ]),
+               disk_stat_read(disk, merges[READ]),
+               (unsigned long long)disk_stat_read(disk, sectors[READ]),
+               jiffies_to_msecs(disk_stat_read(disk, ticks[READ])),
+               disk_stat_read(disk, ios[WRITE]),
+               disk_stat_read(disk, merges[WRITE]),
+               (unsigned long long)disk_stat_read(disk, sectors[WRITE]),
+               jiffies_to_msecs(disk_stat_read(disk, ticks[WRITE])),
                disk->in_flight,
                jiffies_to_msecs(disk_stat_read(disk, io_ticks)),
                jiffies_to_msecs(disk_stat_read(disk, time_in_queue)));
index e54f006e7e603475999cc2465278035ab547c0cf..f370e4a7fe6d7a26e66f988774c002af6b772725 100644 (file)
@@ -7,21 +7,94 @@
 #include <linux/module.h>
 #include <linux/init.h>
 
-static void elevator_noop_add_request(request_queue_t *q, struct request *rq)
+struct noop_data {
+       struct list_head queue;
+};
+
+static void noop_merged_requests(request_queue_t *q, struct request *rq,
+                                struct request *next)
+{
+       list_del_init(&next->queuelist);
+}
+
+static int noop_dispatch(request_queue_t *q, int force)
+{
+       struct noop_data *nd = q->elevator->elevator_data;
+
+       if (!list_empty(&nd->queue)) {
+               struct request *rq;
+               rq = list_entry(nd->queue.next, struct request, queuelist);
+               list_del_init(&rq->queuelist);
+               elv_dispatch_sort(q, rq);
+               return 1;
+       }
+       return 0;
+}
+
+static void noop_add_request(request_queue_t *q, struct request *rq)
+{
+       struct noop_data *nd = q->elevator->elevator_data;
+
+       list_add_tail(&rq->queuelist, &nd->queue);
+}
+
+static int noop_queue_empty(request_queue_t *q)
 {
-       rq->flags |= REQ_NOMERGE;
-       elv_dispatch_add_tail(q, rq);
+       struct noop_data *nd = q->elevator->elevator_data;
+
+       return list_empty(&nd->queue);
+}
+
+static struct request *
+noop_former_request(request_queue_t *q, struct request *rq)
+{
+       struct noop_data *nd = q->elevator->elevator_data;
+
+       if (rq->queuelist.prev == &nd->queue)
+               return NULL;
+       return list_entry(rq->queuelist.prev, struct request, queuelist);
+}
+
+static struct request *
+noop_latter_request(request_queue_t *q, struct request *rq)
+{
+       struct noop_data *nd = q->elevator->elevator_data;
+
+       if (rq->queuelist.next == &nd->queue)
+               return NULL;
+       return list_entry(rq->queuelist.next, struct request, queuelist);
 }
 
-static int elevator_noop_dispatch(request_queue_t *q, int force)
+static int noop_init_queue(request_queue_t *q, elevator_t *e)
 {
+       struct noop_data *nd;
+
+       nd = kmalloc(sizeof(*nd), GFP_KERNEL);
+       if (!nd)
+               return -ENOMEM;
+       INIT_LIST_HEAD(&nd->queue);
+       e->elevator_data = nd;
        return 0;
 }
 
+static void noop_exit_queue(elevator_t *e)
+{
+       struct noop_data *nd = e->elevator_data;
+
+       BUG_ON(!list_empty(&nd->queue));
+       kfree(nd);
+}
+
 static struct elevator_type elevator_noop = {
        .ops = {
-               .elevator_dispatch_fn           = elevator_noop_dispatch,
-               .elevator_add_req_fn            = elevator_noop_add_request,
+               .elevator_merge_req_fn          = noop_merged_requests,
+               .elevator_dispatch_fn           = noop_dispatch,
+               .elevator_add_req_fn            = noop_add_request,
+               .elevator_queue_empty_fn        = noop_queue_empty,
+               .elevator_former_req_fn         = noop_former_request,
+               .elevator_latter_req_fn         = noop_latter_request,
+               .elevator_init_fn               = noop_init_queue,
+               .elevator_exit_fn               = noop_exit_queue,
        },
        .elevator_name = "noop",
        .elevator_owner = THIS_MODULE,
index 6a4da417c16b1f996435fd49b8418302ad430406..606f8733a776cf4ab3473db6a8288431f7d9bc84 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/list.h>
 #include <linux/sched.h>
 #include <linux/pm.h>
+#include <linux/pm_legacy.h>
 #include <linux/device.h>
 #include <linux/proc_fs.h>
 #ifdef CONFIG_X86
@@ -754,7 +755,7 @@ static int __init acpi_init(void)
        result = acpi_bus_init();
 
        if (!result) {
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_LEGACY
                if (!PM_IS_ACTIVE())
                        pm_active = 1;
                else {
index 98f6c02d6790a9d78220ccffa33b616cae91a30d..59dacb6552c0c5b5088c65377f607310d43ee0c8 100644 (file)
@@ -526,18 +526,23 @@ request_firmware_work_func(void *arg)
 {
        struct firmware_work *fw_work = arg;
        const struct firmware *fw;
+       int ret;
        if (!arg) {
                WARN_ON(1);
                return 0;
        }
        daemonize("%s/%s", "firmware", fw_work->name);
-       _request_firmware(&fw, fw_work->name, fw_work->device,
+       ret = _request_firmware(&fw, fw_work->name, fw_work->device,
                fw_work->hotplug);
-       fw_work->cont(fw, fw_work->context);
-       release_firmware(fw);
+       if (ret < 0)
+               fw_work->cont(NULL, fw_work->context);
+       else {
+               fw_work->cont(fw, fw_work->context);
+               release_firmware(fw);
+       }
        module_put(fw_work->module);
        kfree(fw_work);
-       return 0;
+       return ret;
 }
 
 /**
@@ -586,6 +591,8 @@ request_firmware_nowait(
 
        if (ret < 0) {
                fw_work->cont(NULL, fw_work->context);
+               module_put(fw_work->module);
+               kfree(fw_work);
                return ret;
        }
        return 0;
index 59e5982a5db35bb0b2c18a2ebe6ca7870bd71b67..c0233efabebae2216eabeabda378bba0aafce661 100644 (file)
@@ -1188,7 +1188,7 @@ static void pkt_count_states(struct pktcdvd_device *pd, int *states)
        struct packet_data *pkt;
        int i;
 
-       for (i = 0; i <= PACKET_NUM_STATES; i++)
+       for (i = 0; i < PACKET_NUM_STATES; i++)
                states[i] = 0;
 
        spin_lock(&pd->cdrw.active_list_lock);
index c8255312b8c1f3728fb608928ebf554913cff4d2..50947e38501a1903bf98b6376f4f3efc05ba2895 100644 (file)
@@ -557,6 +557,10 @@ static struct agp_device_ids uninorth_agp_device_ids[] __devinitdata = {
                .device_id      = PCI_DEVICE_ID_APPLE_U3H_AGP,
                .chipset_name   = "U3H",
        },
+       {
+               .device_id      = PCI_DEVICE_ID_APPLE_IPID2_AGP,
+               .chipset_name   = "UniNorth/Intrepid2",
+       },
 };
 
 static int __devinit agp_uninorth_probe(struct pci_dev *pdev,
index 6c4b3f986d0ccf26828fe08d61a21810786a6287..f3c3aaf4560e86d07161fb2b8255882c9bf74599 100644 (file)
@@ -99,7 +99,9 @@ struct smm_regs {
 
 static inline char *i8k_get_dmi_data(int field)
 {
-       return dmi_get_system_info(field) ? : "N/A";
+       char *dmi_data = dmi_get_system_info(field);
+
+       return dmi_data && *dmi_data ? dmi_data : "?";
 }
 
 /*
@@ -396,7 +398,7 @@ static int i8k_proc_show(struct seq_file *seq, void *offset)
        return seq_printf(seq, "%s %s %s %d %d %d %d %d %d %d\n",
                          I8K_PROC_FMT,
                          bios_version,
-                         dmi_get_system_info(DMI_PRODUCT_SERIAL) ? : "N/A",
+                         i8k_get_dmi_data(DMI_PRODUCT_SERIAL),
                          cpu_temp,
                          left_fan, right_fan, left_speed, right_speed,
                          ac_power, fn_key);
index d22bfdc13563f722ab869043127fcf8778fcdeab..27c1179ee52749a7062c597e71f506321eeb7287 100644 (file)
@@ -18,5 +18,29 @@ config SYNCLINK_CS
          The module will be called synclinkmp.  If you want to do that, say M
          here.
 
+config CARDMAN_4000
+       tristate "Omnikey Cardman 4000 support"
+       depends on PCMCIA
+       help
+         Enable support for the Omnikey Cardman 4000 PCMCIA Smartcard
+         reader.
+
+         This kernel driver requires additional userspace support, either
+         by the vendor-provided PC/SC ifd_handler (http://www.omnikey.com/),
+         or via the cm4000 backend of OpenCT (http://www.opensc.com/).
+
+config CARDMAN_4040
+       tristate "Omnikey CardMan 4040 support"
+       depends on PCMCIA
+       help
+         Enable support for the Omnikey CardMan 4040 PCMCIA Smartcard
+         reader.
+
+         This card is basically a USB CCID device connected to a FIFO
+         in I/O space.  To use the kernel driver, you will need either the
+         PC/SC ifdhandler provided from the Omnikey homepage
+         (http://www.omnikey.com/), or a current development version of OpenCT
+         (http://www.opensc.org/).
+
 endmenu
 
index 1fcd4c591958043cbb653efd4f35bfb8dd45ebcc..0aae20985d5732059700e7fb50dec7d6573682a2 100644 (file)
@@ -5,3 +5,5 @@
 #
 
 obj-$(CONFIG_SYNCLINK_CS) += synclink_cs.o
+obj-$(CONFIG_CARDMAN_4000) += cm4000_cs.o
+obj-$(CONFIG_CARDMAN_4040) += cm4040_cs.o
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
new file mode 100644 (file)
index 0000000..ef011ef
--- /dev/null
@@ -0,0 +1,2078 @@
+ /*
+  * A driver for the PCMCIA Smartcard Reader "Omnikey CardMan Mobile 4000"
+  *
+  * cm4000_cs.c support.linux@omnikey.com
+  *
+  * Tue Oct 23 11:32:43 GMT 2001 herp - cleaned up header files
+  * Sun Jan 20 10:11:15 MET 2002 herp - added modversion header files
+  * Thu Nov 14 16:34:11 GMT 2002 mh   - added PPS functionality
+  * Tue Nov 19 16:36:27 GMT 2002 mh   - added SUSPEND/RESUME functionailty
+  * Wed Jul 28 12:55:01 CEST 2004 mh  - kernel 2.6 adjustments
+  *
+  * current version: 2.4.0gm4
+  *
+  * (C) 2000,2001,2002,2003,2004 Omnikey AG
+  *
+  * (C) 2005 Harald Welte <laforge@gnumonks.org>
+  *    - Adhere to Kernel CodingStyle
+  *    - Port to 2.6.13 "new" style PCMCIA
+  *    - Check for copy_{from,to}_user return values
+  *    - Use nonseekable_open()
+  *
+  * All rights reserved. Licensed under dual BSD/GPL license.
+  */
+
+/* #define PCMCIA_DEBUG 6 */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/fs.h>
+#include <linux/delay.h>
+#include <asm/uaccess.h>
+#include <asm/io.h>
+
+#include <pcmcia/cs_types.h>
+#include <pcmcia/cs.h>
+#include <pcmcia/cistpl.h>
+#include <pcmcia/cisreg.h>
+#include <pcmcia/ciscode.h>
+#include <pcmcia/ds.h>
+
+#include <linux/cm4000_cs.h>
+
+/* #define ATR_CSUM */
+
+#ifdef PCMCIA_DEBUG
+#define reader_to_dev(x)       (&handle_to_dev(x->link.handle))
+static int pc_debug = PCMCIA_DEBUG;
+module_param(pc_debug, int, 0600);
+#define DEBUGP(n, rdr, x, args...) do {                                \
+       if (pc_debug >= (n))                                            \
+               dev_printk(KERN_DEBUG, reader_to_dev(rdr), "%s:" x,     \
+                          __FUNCTION__ , ## args);                     \
+       } while (0)
+#else
+#define DEBUGP(n, rdr, x, args...)
+#endif
+static char *version = "cm4000_cs.c v2.4.0gm5 - All bugs added by Harald Welte";
+
+#define        T_1SEC          (HZ)
+#define        T_10MSEC        msecs_to_jiffies(10)
+#define        T_20MSEC        msecs_to_jiffies(20)
+#define        T_40MSEC        msecs_to_jiffies(40)
+#define        T_50MSEC        msecs_to_jiffies(50)
+#define        T_100MSEC       msecs_to_jiffies(100)
+#define        T_500MSEC       msecs_to_jiffies(500)
+
+static void cm4000_detach(dev_link_t *link);
+static void cm4000_release(dev_link_t *link);
+
+static int major;              /* major number we get from the kernel */
+
+/* note: the first state has to have number 0 always */
+
+#define        M_FETCH_ATR     0
+#define        M_TIMEOUT_WAIT  1
+#define        M_READ_ATR_LEN  2
+#define        M_READ_ATR      3
+#define        M_ATR_PRESENT   4
+#define        M_BAD_CARD      5
+#define M_CARDOFF      6
+
+#define        LOCK_IO                 0
+#define        LOCK_MONITOR            1
+
+#define IS_AUTOPPS_ACT          6
+#define        IS_PROCBYTE_PRESENT      7
+#define        IS_INVREV                8
+#define IS_ANY_T0               9
+#define        IS_ANY_T1               10
+#define        IS_ATR_PRESENT          11
+#define        IS_ATR_VALID            12
+#define        IS_CMM_ABSENT           13
+#define        IS_BAD_LENGTH           14
+#define        IS_BAD_CSUM             15
+#define        IS_BAD_CARD             16
+
+#define REG_FLAGS0(x)          (x + 0)
+#define REG_FLAGS1(x)          (x + 1)
+#define REG_NUM_BYTES(x)       (x + 2)
+#define REG_BUF_ADDR(x)                (x + 3)
+#define REG_BUF_DATA(x)                (x + 4)
+#define REG_NUM_SEND(x)                (x + 5)
+#define REG_BAUDRATE(x)                (x + 6)
+#define REG_STOPBITS(x)                (x + 7)
+
+struct cm4000_dev {
+       dev_link_t link;                /* pcmcia link */
+       dev_node_t node;                /* OS node (major,minor) */
+
+       unsigned char atr[MAX_ATR];
+       unsigned char rbuf[512];
+       unsigned char sbuf[512];
+
+       wait_queue_head_t devq;         /* when removing cardman must not be
+                                          zeroed! */
+
+       wait_queue_head_t ioq;          /* if IO is locked, wait on this Q */
+       wait_queue_head_t atrq;         /* wait for ATR valid */
+       wait_queue_head_t readq;        /* used by write to wake blk.read */
+
+       /* warning: do not move this fields.
+        * initialising to zero depends on it - see ZERO_DEV below.  */
+       unsigned char atr_csum;
+       unsigned char atr_len_retry;
+       unsigned short atr_len;
+       unsigned short rlen;    /* bytes avail. after write */
+       unsigned short rpos;    /* latest read pos. write zeroes */
+       unsigned char procbyte; /* T=0 procedure byte */
+       unsigned char mstate;   /* state of card monitor */
+       unsigned char cwarn;    /* slow down warning */
+       unsigned char flags0;   /* cardman IO-flags 0 */
+       unsigned char flags1;   /* cardman IO-flags 1 */
+       unsigned int mdelay;    /* variable monitor speeds, in jiffies */
+
+       unsigned int baudv;     /* baud value for speed */
+       unsigned char ta1;
+       unsigned char proto;    /* T=0, T=1, ... */
+       unsigned long flags;    /* lock+flags (MONITOR,IO,ATR) * for concurrent
+                                  access */
+
+       unsigned char pts[4];
+
+       struct timer_list timer;        /* used to keep monitor running */
+       int monitor_running;
+};
+
+#define        ZERO_DEV(dev)                                           \
+       memset(&dev->atr_csum,0,                                \
+               sizeof(struct cm4000_dev) -                     \
+               /*link*/ sizeof(dev_link_t) -                   \
+               /*node*/ sizeof(dev_node_t) -                   \
+               /*atr*/ MAX_ATR*sizeof(char) -                  \
+               /*rbuf*/ 512*sizeof(char) -                     \
+               /*sbuf*/ 512*sizeof(char) -                     \
+               /*queue*/ 4*sizeof(wait_queue_head_t))
+
+static dev_info_t dev_info = MODULE_NAME;
+static dev_link_t *dev_table[CM4000_MAX_DEV];
+
+/* This table doesn't use spaces after the comma between fields and thus
+ * violates CodingStyle.  However, I don't really think wrapping it around will
+ * make it any clearer to read -HW */
+static unsigned char fi_di_table[10][14] = {
+/*FI     00   01   02   03   04   05   06   07   08   09   10   11   12   13 */
+/*DI */
+/* 0 */ {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
+/* 1 */ {0x01,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x91,0x11,0x11,0x11,0x11},
+/* 2 */ {0x02,0x12,0x22,0x32,0x11,0x11,0x11,0x11,0x11,0x92,0xA2,0xB2,0x11,0x11},
+/* 3 */ {0x03,0x13,0x23,0x33,0x43,0x53,0x63,0x11,0x11,0x93,0xA3,0xB3,0xC3,0xD3},
+/* 4 */ {0x04,0x14,0x24,0x34,0x44,0x54,0x64,0x11,0x11,0x94,0xA4,0xB4,0xC4,0xD4},
+/* 5 */ {0x00,0x15,0x25,0x35,0x45,0x55,0x65,0x11,0x11,0x95,0xA5,0xB5,0xC5,0xD5},
+/* 6 */ {0x06,0x16,0x26,0x36,0x46,0x56,0x66,0x11,0x11,0x96,0xA6,0xB6,0xC6,0xD6},
+/* 7 */ {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
+/* 8 */ {0x08,0x11,0x28,0x38,0x48,0x58,0x68,0x11,0x11,0x98,0xA8,0xB8,0xC8,0xD8},
+/* 9 */ {0x09,0x19,0x29,0x39,0x49,0x59,0x69,0x11,0x11,0x99,0xA9,0xB9,0xC9,0xD9}
+};
+
+#ifndef PCMCIA_DEBUG
+#define        xoutb   outb
+#define        xinb    inb
+#else
+static inline void xoutb(unsigned char val, unsigned short port)
+{
+       if (pc_debug >= 7)
+               printk(KERN_DEBUG "outb(val=%.2x,port=%.4x)\n", val, port);
+       outb(val, port);
+}
+static inline unsigned char xinb(unsigned short port)
+{
+       unsigned char val;
+
+       val = inb(port);
+       if (pc_debug >= 7)
+               printk(KERN_DEBUG "%.2x=inb(%.4x)\n", val, port);
+
+       return val;
+}
+#endif
+
+#define        b_0000  15
+#define        b_0001  14
+#define        b_0010  13
+#define        b_0011  12
+#define        b_0100  11
+#define        b_0101  10
+#define        b_0110  9
+#define        b_0111  8
+#define        b_1000  7
+#define        b_1001  6
+#define        b_1010  5
+#define        b_1011  4
+#define        b_1100  3
+#define        b_1101  2
+#define        b_1110  1
+#define        b_1111  0
+
+static unsigned char irtab[16] = {
+       b_0000, b_1000, b_0100, b_1100,
+       b_0010, b_1010, b_0110, b_1110,
+       b_0001, b_1001, b_0101, b_1101,
+       b_0011, b_1011, b_0111, b_1111
+};
+
+static void str_invert_revert(unsigned char *b, int len)
+{
+       int i;
+
+       for (i = 0; i < len; i++)
+               b[i] = (irtab[b[i] & 0x0f] << 4) | irtab[b[i] >> 4];
+}
+
+static unsigned char invert_revert(unsigned char ch)
+{
+       return (irtab[ch & 0x0f] << 4) | irtab[ch >> 4];
+}
+
+#define        ATRLENCK(dev,pos) \
+       if (pos>=dev->atr_len || pos>=MAX_ATR) \
+               goto return_0;
+
+static unsigned int calc_baudv(unsigned char fidi)
+{
+       unsigned int wcrcf, wbrcf, fi_rfu, di_rfu;
+
+       fi_rfu = 372;
+       di_rfu = 1;
+
+       /* FI */
+       switch ((fidi >> 4) & 0x0F) {
+       case 0x00:
+               wcrcf = 372;
+               break;
+       case 0x01:
+               wcrcf = 372;
+               break;
+       case 0x02:
+               wcrcf = 558;
+               break;
+       case 0x03:
+               wcrcf = 744;
+               break;
+       case 0x04:
+               wcrcf = 1116;
+               break;
+       case 0x05:
+               wcrcf = 1488;
+               break;
+       case 0x06:
+               wcrcf = 1860;
+               break;
+       case 0x07:
+               wcrcf = fi_rfu;
+               break;
+       case 0x08:
+               wcrcf = fi_rfu;
+               break;
+       case 0x09:
+               wcrcf = 512;
+               break;
+       case 0x0A:
+               wcrcf = 768;
+               break;
+       case 0x0B:
+               wcrcf = 1024;
+               break;
+       case 0x0C:
+               wcrcf = 1536;
+               break;
+       case 0x0D:
+               wcrcf = 2048;
+               break;
+       default:
+               wcrcf = fi_rfu;
+               break;
+       }
+
+       /* DI */
+       switch (fidi & 0x0F) {
+       case 0x00:
+               wbrcf = di_rfu;
+               break;
+       case 0x01:
+               wbrcf = 1;
+               break;
+       case 0x02:
+               wbrcf = 2;
+               break;
+       case 0x03:
+               wbrcf = 4;
+               break;
+       case 0x04:
+               wbrcf = 8;
+               break;
+       case 0x05:
+               wbrcf = 16;
+               break;
+       case 0x06:
+               wbrcf = 32;
+               break;
+       case 0x07:
+               wbrcf = di_rfu;
+               break;
+       case 0x08:
+               wbrcf = 12;
+               break;
+       case 0x09:
+               wbrcf = 20;
+               break;
+       default:
+               wbrcf = di_rfu;
+               break;
+       }
+
+       return (wcrcf / wbrcf);
+}
+
+static unsigned short io_read_num_rec_bytes(ioaddr_t iobase, unsigned short *s)
+{
+       unsigned short tmp;
+
+       tmp = *s = 0;
+       do {
+               *s = tmp;
+               tmp = inb(REG_NUM_BYTES(iobase)) |
+                               (inb(REG_FLAGS0(iobase)) & 4 ? 0x100 : 0);
+       } while (tmp != *s);
+
+       return *s;
+}
+
+static int parse_atr(struct cm4000_dev *dev)
+{
+       unsigned char any_t1, any_t0;
+       unsigned char ch, ifno;
+       int ix, done;
+
+       DEBUGP(3, dev, "-> parse_atr: dev->atr_len = %i\n", dev->atr_len);
+
+       if (dev->atr_len < 3) {
+               DEBUGP(5, dev, "parse_atr: atr_len < 3\n");
+               return 0;
+       }
+
+       if (dev->atr[0] == 0x3f)
+               set_bit(IS_INVREV, &dev->flags);
+       else
+               clear_bit(IS_INVREV, &dev->flags);
+       ix = 1;
+       ifno = 1;
+       ch = dev->atr[1];
+       dev->proto = 0;         /* XXX PROTO */
+       any_t1 = any_t0 = done = 0;
+       dev->ta1 = 0x11;        /* defaults to 9600 baud */
+       do {
+               if (ifno == 1 && (ch & 0x10)) {
+                       /* read first interface byte and TA1 is present */
+                       dev->ta1 = dev->atr[2];
+                       DEBUGP(5, dev, "Card says FiDi is 0x%.2x\n", dev->ta1);
+                       ifno++;
+               } else if ((ifno == 2) && (ch & 0x10)) { /* TA(2) */
+                       dev->ta1 = 0x11;
+                       ifno++;
+               }
+
+               DEBUGP(5, dev, "Yi=%.2x\n", ch & 0xf0);
+               ix += ((ch & 0x10) >> 4)        /* no of int.face chars */
+                   +((ch & 0x20) >> 5)
+                   + ((ch & 0x40) >> 6)
+                   + ((ch & 0x80) >> 7);
+               /* ATRLENCK(dev,ix); */
+               if (ch & 0x80) {        /* TDi */
+                       ch = dev->atr[ix];
+                       if ((ch & 0x0f)) {
+                               any_t1 = 1;
+                               DEBUGP(5, dev, "card is capable of T=1\n");
+                       } else {
+                               any_t0 = 1;
+                               DEBUGP(5, dev, "card is capable of T=0\n");
+                       }
+               } else
+                       done = 1;
+       } while (!done);
+
+       DEBUGP(5, dev, "ix=%d noHist=%d any_t1=%d\n",
+             ix, dev->atr[1] & 15, any_t1);
+       if (ix + 1 + (dev->atr[1] & 0x0f) + any_t1 != dev->atr_len) {
+               DEBUGP(5, dev, "length error\n");
+               return 0;
+       }
+       if (any_t0)
+               set_bit(IS_ANY_T0, &dev->flags);
+
+       if (any_t1) {           /* compute csum */
+               dev->atr_csum = 0;
+#ifdef ATR_CSUM
+               for (i = 1; i < dev->atr_len; i++)
+                       dev->atr_csum ^= dev->atr[i];
+               if (dev->atr_csum) {
+                       set_bit(IS_BAD_CSUM, &dev->flags);
+                       DEBUGP(5, dev, "bad checksum\n");
+                       goto return_0;
+               }
+#endif
+               if (any_t0 == 0)
+                       dev->proto = 1; /* XXX PROTO */
+               set_bit(IS_ANY_T1, &dev->flags);
+       }
+
+       return 1;
+}
+
+struct card_fixup {
+       char atr[12];
+       u_int8_t atr_len;
+       u_int8_t stopbits;
+};
+
+static struct card_fixup card_fixups[] = {
+       {       /* ACOS */
+               .atr = { 0x3b, 0xb3, 0x11, 0x00, 0x00, 0x41, 0x01 },
+               .atr_len = 7,
+               .stopbits = 0x03,
+       },
+       {       /* Motorola */
+               .atr = {0x3b, 0x76, 0x13, 0x00, 0x00, 0x80, 0x62, 0x07,
+                       0x41, 0x81, 0x81 },
+               .atr_len = 11,
+               .stopbits = 0x04,
+       },
+};
+
+static void set_cardparameter(struct cm4000_dev *dev)
+{
+       int i;
+       ioaddr_t iobase = dev->link.io.BasePort1;
+       u_int8_t stopbits = 0x02; /* ISO default */
+
+       DEBUGP(3, dev, "-> set_cardparameter\n");
+
+       dev->flags1 = dev->flags1 | (((dev->baudv - 1) & 0x0100) >> 8);
+       xoutb(dev->flags1, REG_FLAGS1(iobase));
+       DEBUGP(5, dev, "flags1 = 0x%02x\n", dev->flags1);
+
+       /* set baudrate */
+       xoutb((unsigned char)((dev->baudv - 1) & 0xFF), REG_BAUDRATE(iobase));
+
+       DEBUGP(5, dev, "baudv = %i -> write 0x%02x\n", dev->baudv,
+             ((dev->baudv - 1) & 0xFF));
+
+       /* set stopbits */
+       for (i = 0; i < ARRAY_SIZE(card_fixups); i++) {
+               if (!memcmp(dev->atr, card_fixups[i].atr,
+                           card_fixups[i].atr_len))
+                       stopbits = card_fixups[i].stopbits;
+       }
+       xoutb(stopbits, REG_STOPBITS(iobase));
+
+       DEBUGP(3, dev, "<- set_cardparameter\n");
+}
+
+static int set_protocol(struct cm4000_dev *dev, struct ptsreq *ptsreq)
+{
+
+       unsigned long tmp, i;
+       unsigned short num_bytes_read;
+       unsigned char pts_reply[4];
+       ssize_t rc;
+       ioaddr_t iobase = dev->link.io.BasePort1;
+
+       rc = 0;
+
+       DEBUGP(3, dev, "-> set_protocol\n");
+       DEBUGP(5, dev, "ptsreq->Protocol = 0x%.8x, ptsreq->Flags=0x%.8x, "
+                "ptsreq->pts1=0x%.2x, ptsreq->pts2=0x%.2x, "
+                "ptsreq->pts3=0x%.2x\n", (unsigned int)ptsreq->protocol,
+                (unsigned int)ptsreq->flags, ptsreq->pts1, ptsreq->pts2,
+                ptsreq->pts3);
+
+       /* Fill PTS structure */
+       dev->pts[0] = 0xff;
+       dev->pts[1] = 0x00;
+       tmp = ptsreq->protocol;
+       while ((tmp = (tmp >> 1)) > 0)
+               dev->pts[1]++;
+       dev->proto = dev->pts[1];       /* Set new protocol */
+       dev->pts[1] = (0x01 << 4) | (dev->pts[1]);
+
+       /* Correct Fi/Di according to CM4000 Fi/Di table */
+       DEBUGP(5, dev, "Ta(1) from ATR is 0x%.2x\n", dev->ta1);
+       /* set Fi/Di according to ATR TA(1) */
+       dev->pts[2] = fi_di_table[dev->ta1 & 0x0F][(dev->ta1 >> 4) & 0x0F];
+
+       /* Calculate PCK character */
+       dev->pts[3] = dev->pts[0] ^ dev->pts[1] ^ dev->pts[2];
+
+       DEBUGP(5, dev, "pts0=%.2x, pts1=%.2x, pts2=%.2x, pts3=%.2x\n",
+              dev->pts[0], dev->pts[1], dev->pts[2], dev->pts[3]);
+
+       /* check card convention */
+       if (test_bit(IS_INVREV, &dev->flags))
+               str_invert_revert(dev->pts, 4);
+
+       /* reset SM */
+       xoutb(0x80, REG_FLAGS0(iobase));
+
+       /* Enable access to the message buffer */
+       DEBUGP(5, dev, "Enable access to the messages buffer\n");
+       dev->flags1 = 0x20      /* T_Active */
+           | (test_bit(IS_INVREV, &dev->flags) ? 0x02 : 0x00) /* inv parity */
+           | ((dev->baudv >> 8) & 0x01);       /* MSB-baud */
+       xoutb(dev->flags1, REG_FLAGS1(iobase));
+
+       DEBUGP(5, dev, "Enable message buffer -> flags1 = 0x%.2x\n",
+              dev->flags1);
+
+       /* write challenge to the buffer */
+       DEBUGP(5, dev, "Write challenge to buffer: ");
+       for (i = 0; i < 4; i++) {
+               xoutb(i, REG_BUF_ADDR(iobase));
+               xoutb(dev->pts[i], REG_BUF_DATA(iobase));       /* buf data */
+#ifdef PCMCIA_DEBUG
+               if (pc_debug >= 5)
+                       printk("0x%.2x ", dev->pts[i]);
+       }
+       if (pc_debug >= 5)
+               printk("\n");
+#else
+       }
+#endif
+
+       /* set number of bytes to write */
+       DEBUGP(5, dev, "Set number of bytes to write\n");
+       xoutb(0x04, REG_NUM_SEND(iobase));
+
+       /* Trigger CARDMAN CONTROLLER */
+       xoutb(0x50, REG_FLAGS0(iobase));
+
+       /* Monitor progress */
+       /* wait for xmit done */
+       DEBUGP(5, dev, "Waiting for NumRecBytes getting valid\n");
+
+       for (i = 0; i < 100; i++) {
+               if (inb(REG_FLAGS0(iobase)) & 0x08) {
+                       DEBUGP(5, dev, "NumRecBytes is valid\n");
+                       break;
+               }
+               mdelay(10);
+       }
+       if (i == 100) {
+               DEBUGP(5, dev, "Timeout waiting for NumRecBytes getting "
+                      "valid\n");
+               rc = -EIO;
+               goto exit_setprotocol;
+       }
+
+       DEBUGP(5, dev, "Reading NumRecBytes\n");
+       for (i = 0; i < 100; i++) {
+               io_read_num_rec_bytes(iobase, &num_bytes_read);
+               if (num_bytes_read >= 4) {
+                       DEBUGP(2, dev, "NumRecBytes = %i\n", num_bytes_read);
+                       break;
+               }
+               mdelay(10);
+       }
+
+       /* check whether it is a short PTS reply? */
+       if (num_bytes_read == 3)
+               i = 0;
+
+       if (i == 100) {
+               DEBUGP(5, dev, "Timeout reading num_bytes_read\n");
+               rc = -EIO;
+               goto exit_setprotocol;
+       }
+
+       DEBUGP(5, dev, "Reset the CARDMAN CONTROLLER\n");
+       xoutb(0x80, REG_FLAGS0(iobase));
+
+       /* Read PPS reply */
+       DEBUGP(5, dev, "Read PPS reply\n");
+       for (i = 0; i < num_bytes_read; i++) {
+               xoutb(i, REG_BUF_ADDR(iobase));
+               pts_reply[i] = inb(REG_BUF_DATA(iobase));
+       }
+
+#ifdef PCMCIA_DEBUG
+       DEBUGP(2, dev, "PTSreply: ");
+       for (i = 0; i < num_bytes_read; i++) {
+               if (pc_debug >= 5)
+                       printk("0x%.2x ", pts_reply[i]);
+       }
+       printk("\n");
+#endif /* PCMCIA_DEBUG */
+
+       DEBUGP(5, dev, "Clear Tactive in Flags1\n");
+       xoutb(0x20, REG_FLAGS1(iobase));
+
+       /* Compare ptsreq and ptsreply */
+       if ((dev->pts[0] == pts_reply[0]) &&
+           (dev->pts[1] == pts_reply[1]) &&
+           (dev->pts[2] == pts_reply[2]) && (dev->pts[3] == pts_reply[3])) {
+               /* setcardparameter according to PPS */
+               dev->baudv = calc_baudv(dev->pts[2]);
+               set_cardparameter(dev);
+       } else if ((dev->pts[0] == pts_reply[0]) &&
+                  ((dev->pts[1] & 0xef) == pts_reply[1]) &&
+                  ((pts_reply[0] ^ pts_reply[1]) == pts_reply[2])) {
+               /* short PTS reply, set card parameter to default values */
+               dev->baudv = calc_baudv(0x11);
+               set_cardparameter(dev);
+       } else
+               rc = -EIO;
+
+exit_setprotocol:
+       DEBUGP(3, dev, "<- set_protocol\n");
+       return rc;
+}
+
+static int io_detect_cm4000(ioaddr_t iobase, struct cm4000_dev *dev)
+{
+
+       /* note: statemachine is assumed to be reset */
+       if (inb(REG_FLAGS0(iobase)) & 8) {
+               clear_bit(IS_ATR_VALID, &dev->flags);
+               set_bit(IS_CMM_ABSENT, &dev->flags);
+               return 0;       /* detect CMM = 1 -> failure */
+       }
+       /* xoutb(0x40, REG_FLAGS1(iobase)); detectCMM */
+       xoutb(dev->flags1 | 0x40, REG_FLAGS1(iobase));
+       if ((inb(REG_FLAGS0(iobase)) & 8) == 0) {
+               clear_bit(IS_ATR_VALID, &dev->flags);
+               set_bit(IS_CMM_ABSENT, &dev->flags);
+               return 0;       /* detect CMM=0 -> failure */
+       }
+       /* clear detectCMM again by restoring original flags1 */
+       xoutb(dev->flags1, REG_FLAGS1(iobase));
+       return 1;
+}
+
+static void terminate_monitor(struct cm4000_dev *dev)
+{
+
+       /* tell the monitor to stop and wait until
+        * it terminates.
+        */
+       DEBUGP(3, dev, "-> terminate_monitor\n");
+       wait_event_interruptible(dev->devq,
+                                test_and_set_bit(LOCK_MONITOR,
+                                                 (void *)&dev->flags));
+
+       /* now, LOCK_MONITOR has been set.
+        * allow a last cycle in the monitor.
+        * the monitor will indicate that it has
+        * finished by clearing this bit.
+        */
+       DEBUGP(5, dev, "Now allow last cycle of monitor!\n");
+       while (test_bit(LOCK_MONITOR, (void *)&dev->flags))
+               msleep(25);
+
+       DEBUGP(5, dev, "Delete timer\n");
+       del_timer_sync(&dev->timer);
+#ifdef PCMCIA_DEBUG
+       dev->monitor_running = 0;
+#endif
+
+       DEBUGP(3, dev, "<- terminate_monitor\n");
+}
+
+/*
+ * monitor the card every 50msec. as a side-effect, retrieve the
+ * atr once a card is inserted. another side-effect of retrieving the
+ * atr is that the card will be powered on, so there is no need to
+ * power on the card explictely from the application: the driver
+ * is already doing that for you.
+ */
+
+static void monitor_card(unsigned long p)
+{
+       struct cm4000_dev *dev = (struct cm4000_dev *) p;
+       ioaddr_t iobase = dev->link.io.BasePort1;
+       unsigned short s;
+       struct ptsreq ptsreq;
+       int i, atrc;
+
+       DEBUGP(7, dev, "->  monitor_card\n");
+
+       /* if someone has set the lock for us: we're done! */
+       if (test_and_set_bit(LOCK_MONITOR, &dev->flags)) {
+               DEBUGP(4, dev, "About to stop monitor\n");
+               /* no */
+               dev->rlen =
+                   dev->rpos =
+                   dev->atr_csum = dev->atr_len_retry = dev->cwarn = 0;
+               dev->mstate = M_FETCH_ATR;
+               clear_bit(LOCK_MONITOR, &dev->flags);
+               /* close et al. are sleeping on devq, so wake it */
+               wake_up_interruptible(&dev->devq);
+               DEBUGP(2, dev, "<- monitor_card (we are done now)\n");
+               return;
+       }
+
+       /* try to lock io: if it is already locked, just add another timer */
+       if (test_and_set_bit(LOCK_IO, (void *)&dev->flags)) {
+               DEBUGP(4, dev, "Couldn't get IO lock\n");
+               goto return_with_timer;
+       }
+
+       /* is a card/a reader inserted at all ? */
+       dev->flags0 = xinb(REG_FLAGS0(iobase));
+       DEBUGP(7, dev, "dev->flags0 = 0x%2x\n", dev->flags0);
+       DEBUGP(7, dev, "smartcard present: %s\n",
+              dev->flags0 & 1 ? "yes" : "no");
+       DEBUGP(7, dev, "cardman present: %s\n",
+              dev->flags0 == 0xff ? "no" : "yes");
+
+       if ((dev->flags0 & 1) == 0      /* no smartcard inserted */
+           || dev->flags0 == 0xff) {   /* no cardman inserted */
+               /* no */
+               dev->rlen =
+                   dev->rpos =
+                   dev->atr_csum = dev->atr_len_retry = dev->cwarn = 0;
+               dev->mstate = M_FETCH_ATR;
+
+               dev->flags &= 0x000000ff; /* only keep IO and MONITOR locks */
+
+               if (dev->flags0 == 0xff) {
+                       DEBUGP(4, dev, "set IS_CMM_ABSENT bit\n");
+                       set_bit(IS_CMM_ABSENT, &dev->flags);
+               } else if (test_bit(IS_CMM_ABSENT, &dev->flags)) {
+                       DEBUGP(4, dev, "clear IS_CMM_ABSENT bit "
+                              "(card is removed)\n");
+                       clear_bit(IS_CMM_ABSENT, &dev->flags);
+               }
+
+               goto release_io;
+       } else if ((dev->flags0 & 1) && test_bit(IS_CMM_ABSENT, &dev->flags)) {
+               /* cardman and card present but cardman was absent before
+                * (after suspend with inserted card) */
+               DEBUGP(4, dev, "clear IS_CMM_ABSENT bit (card is inserted)\n");
+               clear_bit(IS_CMM_ABSENT, &dev->flags);
+       }
+
+       if (test_bit(IS_ATR_VALID, &dev->flags) == 1) {
+               DEBUGP(7, dev, "believe ATR is already valid (do nothing)\n");
+               goto release_io;
+       }
+
+       switch (dev->mstate) {
+               unsigned char flags0;
+       case M_CARDOFF:
+               DEBUGP(4, dev, "M_CARDOFF\n");
+               flags0 = inb(REG_FLAGS0(iobase));
+               if (flags0 & 0x02) {
+                       /* wait until Flags0 indicate power is off */
+                       dev->mdelay = T_10MSEC;
+               } else {
+                       /* Flags0 indicate power off and no card inserted now;
+                        * Reset CARDMAN CONTROLLER */
+                       xoutb(0x80, REG_FLAGS0(iobase));
+
+                       /* prepare for fetching ATR again: after card off ATR
+                        * is read again automatically */
+                       dev->rlen =
+                           dev->rpos =
+                           dev->atr_csum =
+                           dev->atr_len_retry = dev->cwarn = 0;
+                       dev->mstate = M_FETCH_ATR;
+
+                       /* minimal gap between CARDOFF and read ATR is 50msec */
+                       dev->mdelay = T_50MSEC;
+               }
+               break;
+       case M_FETCH_ATR:
+               DEBUGP(4, dev, "M_FETCH_ATR\n");
+               xoutb(0x80, REG_FLAGS0(iobase));
+               DEBUGP(4, dev, "Reset BAUDV to 9600\n");
+               dev->baudv = 0x173;     /* 9600 */
+               xoutb(0x02, REG_STOPBITS(iobase));      /* stopbits=2 */
+               xoutb(0x73, REG_BAUDRATE(iobase));      /* baud value */
+               xoutb(0x21, REG_FLAGS1(iobase));        /* T_Active=1, baud
+                                                          value */
+               /* warm start vs. power on: */
+               xoutb(dev->flags0 & 2 ? 0x46 : 0x44, REG_FLAGS0(iobase));
+               dev->mdelay = T_40MSEC;
+               dev->mstate = M_TIMEOUT_WAIT;
+               break;
+       case M_TIMEOUT_WAIT:
+               DEBUGP(4, dev, "M_TIMEOUT_WAIT\n");
+               /* numRecBytes */
+               io_read_num_rec_bytes(iobase, &dev->atr_len);
+               dev->mdelay = T_10MSEC;
+               dev->mstate = M_READ_ATR_LEN;
+               break;
+       case M_READ_ATR_LEN:
+               DEBUGP(4, dev, "M_READ_ATR_LEN\n");
+               /* infinite loop possible, since there is no timeout */
+
+#define        MAX_ATR_LEN_RETRY       100
+
+               if (dev->atr_len == io_read_num_rec_bytes(iobase, &s)) {
+                       if (dev->atr_len_retry++ >= MAX_ATR_LEN_RETRY) {                                        /* + XX msec */
+                               dev->mdelay = T_10MSEC;
+                               dev->mstate = M_READ_ATR;
+                       }
+               } else {
+                       dev->atr_len = s;
+                       dev->atr_len_retry = 0; /* set new timeout */
+               }
+
+               DEBUGP(4, dev, "Current ATR_LEN = %i\n", dev->atr_len);
+               break;
+       case M_READ_ATR:
+               DEBUGP(4, dev, "M_READ_ATR\n");
+               xoutb(0x80, REG_FLAGS0(iobase));        /* reset SM */
+               for (i = 0; i < dev->atr_len; i++) {
+                       xoutb(i, REG_BUF_ADDR(iobase));
+                       dev->atr[i] = inb(REG_BUF_DATA(iobase));
+               }
+               /* Deactivate T_Active flags */
+               DEBUGP(4, dev, "Deactivate T_Active flags\n");
+               dev->flags1 = 0x01;
+               xoutb(dev->flags1, REG_FLAGS1(iobase));
+
+               /* atr is present (which doesnt mean it's valid) */
+               set_bit(IS_ATR_PRESENT, &dev->flags);
+               if (dev->atr[0] == 0x03)
+                       str_invert_revert(dev->atr, dev->atr_len);
+               atrc = parse_atr(dev);
+               if (atrc == 0) {        /* atr invalid */
+                       dev->mdelay = 0;
+                       dev->mstate = M_BAD_CARD;
+               } else {
+                       dev->mdelay = T_50MSEC;
+                       dev->mstate = M_ATR_PRESENT;
+                       set_bit(IS_ATR_VALID, &dev->flags);
+               }
+
+               if (test_bit(IS_ATR_VALID, &dev->flags) == 1) {
+                       DEBUGP(4, dev, "monitor_card: ATR valid\n");
+                       /* if ta1 == 0x11, no PPS necessary (default values) */
+                       /* do not do PPS with multi protocol cards */
+                       if ((test_bit(IS_AUTOPPS_ACT, &dev->flags) == 0) &&
+                           (dev->ta1 != 0x11) &&
+                           !(test_bit(IS_ANY_T0, &dev->flags) &&
+                           test_bit(IS_ANY_T1, &dev->flags))) {
+                               DEBUGP(4, dev, "Perform AUTOPPS\n");
+                               set_bit(IS_AUTOPPS_ACT, &dev->flags);
+                               ptsreq.protocol = ptsreq.protocol =
+                                   (0x01 << dev->proto);
+                               ptsreq.flags = 0x01;
+                               ptsreq.pts1 = 0x00;
+                               ptsreq.pts2 = 0x00;
+                               ptsreq.pts3 = 0x00;
+                               if (set_protocol(dev, &ptsreq) == 0) {
+                                       DEBUGP(4, dev, "AUTOPPS ret SUCC\n");
+                                       clear_bit(IS_AUTOPPS_ACT, &dev->flags);
+                                       wake_up_interruptible(&dev->atrq);
+                               } else {
+                                       DEBUGP(4, dev, "AUTOPPS failed: "
+                                              "repower using defaults\n");
+                                       /* prepare for repowering  */
+                                       clear_bit(IS_ATR_PRESENT, &dev->flags);
+                                       clear_bit(IS_ATR_VALID, &dev->flags);
+                                       dev->rlen =
+                                           dev->rpos =
+                                           dev->atr_csum =
+                                           dev->atr_len_retry = dev->cwarn = 0;
+                                       dev->mstate = M_FETCH_ATR;
+
+                                       dev->mdelay = T_50MSEC;
+                               }
+                       } else {
+                               /* for cards which use slightly different
+                                * params (extra guard time) */
+                               set_cardparameter(dev);
+                               if (test_bit(IS_AUTOPPS_ACT, &dev->flags) == 1)
+                                       DEBUGP(4, dev, "AUTOPPS already active "
+                                              "2nd try:use default values\n");
+                               if (dev->ta1 == 0x11)
+                                       DEBUGP(4, dev, "No AUTOPPS necessary "
+                                              "TA(1)==0x11\n");
+                               if (test_bit(IS_ANY_T0, &dev->flags)
+                                   && test_bit(IS_ANY_T1, &dev->flags))
+                                       DEBUGP(4, dev, "Do NOT perform AUTOPPS "
+                                              "with multiprotocol cards\n");
+                               clear_bit(IS_AUTOPPS_ACT, &dev->flags);
+                               wake_up_interruptible(&dev->atrq);
+                       }
+               } else {
+                       DEBUGP(4, dev, "ATR invalid\n");
+                       wake_up_interruptible(&dev->atrq);
+               }
+               break;
+       case M_BAD_CARD:
+               DEBUGP(4, dev, "M_BAD_CARD\n");
+               /* slow down warning, but prompt immediately after insertion */
+               if (dev->cwarn == 0 || dev->cwarn == 10) {
+                       set_bit(IS_BAD_CARD, &dev->flags);
+                       printk(KERN_WARNING MODULE_NAME ": device %s: ",
+                              dev->node.dev_name);
+                       if (test_bit(IS_BAD_CSUM, &dev->flags)) {
+                               DEBUGP(4, dev, "ATR checksum (0x%.2x, should "
+                                      "be zero) failed\n", dev->atr_csum);
+                       }
+#ifdef PCMCIA_DEBUG
+                       else if (test_bit(IS_BAD_LENGTH, &dev->flags)) {
+                               DEBUGP(4, dev, "ATR length error\n");
+                       } else {
+                               DEBUGP(4, dev, "card damaged or wrong way "
+                                       "inserted\n");
+                       }
+#endif
+                       dev->cwarn = 0;
+                       wake_up_interruptible(&dev->atrq);      /* wake open */
+               }
+               dev->cwarn++;
+               dev->mdelay = T_100MSEC;
+               dev->mstate = M_FETCH_ATR;
+               break;
+       default:
+               DEBUGP(7, dev, "Unknown action\n");
+               break;          /* nothing */
+       }
+
+release_io:
+       DEBUGP(7, dev, "release_io\n");
+       clear_bit(LOCK_IO, &dev->flags);
+       wake_up_interruptible(&dev->ioq);       /* whoever needs IO */
+
+return_with_timer:
+       DEBUGP(7, dev, "<- monitor_card (returns with timer)\n");
+       dev->timer.expires = jiffies + dev->mdelay;
+       add_timer(&dev->timer);
+       clear_bit(LOCK_MONITOR, &dev->flags);
+}
+
+/* Interface to userland (file_operations) */
+
+static ssize_t cmm_read(struct file *filp, __user char *buf, size_t count,
+                       loff_t *ppos)
+{
+       struct cm4000_dev *dev = filp->private_data;
+       ioaddr_t iobase = dev->link.io.BasePort1;
+       ssize_t rc;
+       int i, j, k;
+
+       DEBUGP(2, dev, "-> cmm_read(%s,%d)\n", current->comm, current->pid);
+
+       if (count == 0)         /* according to manpage */
+               return 0;
+
+       if ((dev->link.state & DEV_PRESENT) == 0 ||     /* socket removed */
+           test_bit(IS_CMM_ABSENT, &dev->flags))
+               return -ENODEV;
+
+       if (test_bit(IS_BAD_CSUM, &dev->flags))
+               return -EIO;
+
+       /* also see the note about this in cmm_write */
+       if (wait_event_interruptible
+           (dev->atrq,
+            ((filp->f_flags & O_NONBLOCK)
+             || (test_bit(IS_ATR_PRESENT, (void *)&dev->flags) != 0)))) {
+               if (filp->f_flags & O_NONBLOCK)
+                       return -EAGAIN;
+               return -ERESTARTSYS;
+       }
+
+       if (test_bit(IS_ATR_VALID, &dev->flags) == 0)
+               return -EIO;
+
+       /* this one implements blocking IO */
+       if (wait_event_interruptible
+           (dev->readq,
+            ((filp->f_flags & O_NONBLOCK) || (dev->rpos < dev->rlen)))) {
+               if (filp->f_flags & O_NONBLOCK)
+                       return -EAGAIN;
+               return -ERESTARTSYS;
+       }
+
+       /* lock io */
+       if (wait_event_interruptible
+           (dev->ioq,
+            ((filp->f_flags & O_NONBLOCK)
+             || (test_and_set_bit(LOCK_IO, (void *)&dev->flags) == 0)))) {
+               if (filp->f_flags & O_NONBLOCK)
+                       return -EAGAIN;
+               return -ERESTARTSYS;
+       }
+
+       rc = 0;
+       dev->flags0 = inb(REG_FLAGS0(iobase));
+       if ((dev->flags0 & 1) == 0      /* no smartcard inserted */
+           || dev->flags0 == 0xff) {   /* no cardman inserted */
+               clear_bit(IS_ATR_VALID, &dev->flags);
+               if (dev->flags0 & 1) {
+                       set_bit(IS_CMM_ABSENT, &dev->flags);
+                       rc = -ENODEV;
+               }
+               rc = -EIO;
+               goto release_io;
+       }
+
+       DEBUGP(4, dev, "begin read answer\n");
+       j = min(count, (size_t)(dev->rlen - dev->rpos));
+       k = dev->rpos;
+       if (k + j > 255)
+               j = 256 - k;
+       DEBUGP(4, dev, "read1 j=%d\n", j);
+       for (i = 0; i < j; i++) {
+               xoutb(k++, REG_BUF_ADDR(iobase));
+               dev->rbuf[i] = xinb(REG_BUF_DATA(iobase));
+       }
+       j = min(count, (size_t)(dev->rlen - dev->rpos));
+       if (k + j > 255) {
+               DEBUGP(4, dev, "read2 j=%d\n", j);
+               dev->flags1 |= 0x10;    /* MSB buf addr set */
+               xoutb(dev->flags1, REG_FLAGS1(iobase));
+               for (; i < j; i++) {
+                       xoutb(k++, REG_BUF_ADDR(iobase));
+                       dev->rbuf[i] = xinb(REG_BUF_DATA(iobase));
+               }
+       }
+
+       if (dev->proto == 0 && count > dev->rlen - dev->rpos) {
+               DEBUGP(4, dev, "T=0 and count > buffer\n");
+               dev->rbuf[i] = dev->rbuf[i - 1];
+               dev->rbuf[i - 1] = dev->procbyte;
+               j++;
+       }
+       count = j;
+
+       dev->rpos = dev->rlen + 1;
+
+       /* Clear T1Active */
+       DEBUGP(4, dev, "Clear T1Active\n");
+       dev->flags1 &= 0xdf;
+       xoutb(dev->flags1, REG_FLAGS1(iobase));
+
+       xoutb(0, REG_FLAGS1(iobase));   /* clear detectCMM */
+       /* last check before exit */
+       if (!io_detect_cm4000(iobase, dev))
+               count = -ENODEV;
+
+       if (test_bit(IS_INVREV, &dev->flags) && count > 0)
+               str_invert_revert(dev->rbuf, count);
+
+       if (copy_to_user(buf, dev->rbuf, count))
+               return -EFAULT;
+
+release_io:
+       clear_bit(LOCK_IO, &dev->flags);
+       wake_up_interruptible(&dev->ioq);
+
+       DEBUGP(2, dev, "<- cmm_read returns: rc = %Zi\n",
+              (rc < 0 ? rc : count));
+       return rc < 0 ? rc : count;
+}
+
+static ssize_t cmm_write(struct file *filp, const char __user *buf,
+                        size_t count, loff_t *ppos)
+{
+       struct cm4000_dev *dev = (struct cm4000_dev *) filp->private_data;
+       ioaddr_t iobase = dev->link.io.BasePort1;
+       unsigned short s;
+       unsigned char tmp;
+       unsigned char infolen;
+       unsigned char sendT0;
+       unsigned short nsend;
+       unsigned short nr;
+       ssize_t rc;
+       int i;
+
+       DEBUGP(2, dev, "-> cmm_write(%s,%d)\n", current->comm, current->pid);
+
+       if (count == 0)         /* according to manpage */
+               return 0;
+
+       if (dev->proto == 0 && count < 4) {
+               /* T0 must have at least 4 bytes */
+               DEBUGP(4, dev, "T0 short write\n");
+               return -EIO;
+       }
+
+       nr = count & 0x1ff;     /* max bytes to write */
+
+       sendT0 = dev->proto ? 0 : nr > 5 ? 0x08 : 0;
+
+       if ((dev->link.state & DEV_PRESENT) == 0 ||     /* socket removed */
+           test_bit(IS_CMM_ABSENT, &dev->flags))
+               return -ENODEV;
+
+       if (test_bit(IS_BAD_CSUM, &dev->flags)) {
+               DEBUGP(4, dev, "bad csum\n");
+               return -EIO;
+       }
+
+       /*
+        * wait for atr to become valid.
+        * note: it is important to lock this code. if we dont, the monitor
+        * could be run between test_bit and the the call the sleep on the
+        * atr-queue.  if *then* the monitor detects atr valid, it will wake up
+        * any process on the atr-queue, *but* since we have been interrupted,
+        * we do not yet sleep on this queue. this would result in a missed
+        * wake_up and the calling process would sleep forever (until
+        * interrupted).  also, do *not* restore_flags before sleep_on, because
+        * this could result in the same situation!
+        */
+       if (wait_event_interruptible
+           (dev->atrq,
+            ((filp->f_flags & O_NONBLOCK)
+             || (test_bit(IS_ATR_PRESENT, (void *)&dev->flags) != 0)))) {
+               if (filp->f_flags & O_NONBLOCK)
+                       return -EAGAIN;
+               return -ERESTARTSYS;
+       }
+
+       if (test_bit(IS_ATR_VALID, &dev->flags) == 0) { /* invalid atr */
+               DEBUGP(4, dev, "invalid ATR\n");
+               return -EIO;
+       }
+
+       /* lock io */
+       if (wait_event_interruptible
+           (dev->ioq,
+            ((filp->f_flags & O_NONBLOCK)
+             || (test_and_set_bit(LOCK_IO, (void *)&dev->flags) == 0)))) {
+               if (filp->f_flags & O_NONBLOCK)
+                       return -EAGAIN;
+               return -ERESTARTSYS;
+       }
+
+       if (copy_from_user(dev->sbuf, buf, ((count > 512) ? 512 : count)))
+               return -EFAULT;
+
+       rc = 0;
+       dev->flags0 = inb(REG_FLAGS0(iobase));
+       if ((dev->flags0 & 1) == 0      /* no smartcard inserted */
+           || dev->flags0 == 0xff) {   /* no cardman inserted */
+               clear_bit(IS_ATR_VALID, &dev->flags);
+               if (dev->flags0 & 1) {
+                       set_bit(IS_CMM_ABSENT, &dev->flags);
+                       rc = -ENODEV;
+               } else {
+                       DEBUGP(4, dev, "IO error\n");
+                       rc = -EIO;
+               }
+               goto release_io;
+       }
+
+       xoutb(0x80, REG_FLAGS0(iobase));        /* reset SM  */
+
+       if (!io_detect_cm4000(iobase, dev)) {
+               rc = -ENODEV;
+               goto release_io;
+       }
+
+       /* reflect T=0 send/read mode in flags1 */
+       dev->flags1 |= (sendT0);
+
+       set_cardparameter(dev);
+
+       /* dummy read, reset flag procedure received */
+       tmp = inb(REG_FLAGS1(iobase));
+
+       dev->flags1 = 0x20      /* T_Active */
+           | (sendT0)
+           | (test_bit(IS_INVREV, &dev->flags) ? 2 : 0)/* inverse parity  */
+           | (((dev->baudv - 1) & 0x0100) >> 8);       /* MSB-Baud */
+       DEBUGP(1, dev, "set dev->flags1 = 0x%.2x\n", dev->flags1);
+       xoutb(dev->flags1, REG_FLAGS1(iobase));
+
+       /* xmit data */
+       DEBUGP(4, dev, "Xmit data\n");
+       for (i = 0; i < nr; i++) {
+               if (i >= 256) {
+                       dev->flags1 = 0x20      /* T_Active */
+                           | (sendT0)  /* SendT0 */
+                               /* inverse parity: */
+                           | (test_bit(IS_INVREV, &dev->flags) ? 2 : 0)
+                           | (((dev->baudv - 1) & 0x0100) >> 8) /* MSB-Baud */
+                           | 0x10;     /* set address high */
+                       DEBUGP(4, dev, "dev->flags = 0x%.2x - set address "
+                              "high\n", dev->flags1);
+                       xoutb(dev->flags1, REG_FLAGS1(iobase));
+               }
+               if (test_bit(IS_INVREV, &dev->flags)) {
+                       DEBUGP(4, dev, "Apply inverse convention for 0x%.2x "
+                               "-> 0x%.2x\n", (unsigned char)dev->sbuf[i],
+                             invert_revert(dev->sbuf[i]));
+                       xoutb(i, REG_BUF_ADDR(iobase));
+                       xoutb(invert_revert(dev->sbuf[i]),
+                             REG_BUF_DATA(iobase));
+               } else {
+                       xoutb(i, REG_BUF_ADDR(iobase));
+                       xoutb(dev->sbuf[i], REG_BUF_DATA(iobase));
+               }
+       }
+       DEBUGP(4, dev, "Xmit done\n");
+
+       if (dev->proto == 0) {
+               /* T=0 proto: 0 byte reply  */
+               if (nr == 4) {
+                       DEBUGP(4, dev, "T=0 assumes 0 byte reply\n");
+                       xoutb(i, REG_BUF_ADDR(iobase));
+                       if (test_bit(IS_INVREV, &dev->flags))
+                               xoutb(0xff, REG_BUF_DATA(iobase));
+                       else
+                               xoutb(0x00, REG_BUF_DATA(iobase));
+               }
+
+               /* numSendBytes */
+               if (sendT0)
+                       nsend = nr;
+               else {
+                       if (nr == 4)
+                               nsend = 5;
+                       else {
+                               nsend = 5 + (unsigned char)dev->sbuf[4];
+                               if (dev->sbuf[4] == 0)
+                                       nsend += 0x100;
+                       }
+               }
+       } else
+               nsend = nr;
+
+       /* T0: output procedure byte */
+       if (test_bit(IS_INVREV, &dev->flags)) {
+               DEBUGP(4, dev, "T=0 set Procedure byte (inverse-reverse) "
+                      "0x%.2x\n", invert_revert(dev->sbuf[1]));
+               xoutb(invert_revert(dev->sbuf[1]), REG_NUM_BYTES(iobase));
+       } else {
+               DEBUGP(4, dev, "T=0 set Procedure byte 0x%.2x\n", dev->sbuf[1]);
+               xoutb(dev->sbuf[1], REG_NUM_BYTES(iobase));
+       }
+
+       DEBUGP(1, dev, "set NumSendBytes = 0x%.2x\n",
+              (unsigned char)(nsend & 0xff));
+       xoutb((unsigned char)(nsend & 0xff), REG_NUM_SEND(iobase));
+
+       DEBUGP(1, dev, "Trigger CARDMAN CONTROLLER (0x%.2x)\n",
+              0x40     /* SM_Active */
+             | (dev->flags0 & 2 ? 0 : 4)       /* power on if needed */
+             |(dev->proto ? 0x10 : 0x08)       /* T=1/T=0 */
+             |(nsend & 0x100) >> 8 /* MSB numSendBytes */ );
+       xoutb(0x40              /* SM_Active */
+             | (dev->flags0 & 2 ? 0 : 4)       /* power on if needed */
+             |(dev->proto ? 0x10 : 0x08)       /* T=1/T=0 */
+             |(nsend & 0x100) >> 8,    /* MSB numSendBytes */
+             REG_FLAGS0(iobase));
+
+       /* wait for xmit done */
+       if (dev->proto == 1) {
+               DEBUGP(4, dev, "Wait for xmit done\n");
+               for (i = 0; i < 1000; i++) {
+                       if (inb(REG_FLAGS0(iobase)) & 0x08)
+                               break;
+                       msleep_interruptible(10);
+               }
+               if (i == 1000) {
+                       DEBUGP(4, dev, "timeout waiting for xmit done\n");
+                       rc = -EIO;
+                       goto release_io;
+               }
+       }
+
+       /* T=1: wait for infoLen */
+
+       infolen = 0;
+       if (dev->proto) {
+               /* wait until infoLen is valid */
+               for (i = 0; i < 6000; i++) {    /* max waiting time of 1 min */
+                       io_read_num_rec_bytes(iobase, &s);
+                       if (s >= 3) {
+                               infolen = inb(REG_FLAGS1(iobase));
+                               DEBUGP(4, dev, "infolen=%d\n", infolen);
+                               break;
+                       }
+                       msleep_interruptible(10);
+               }
+               if (i == 6000) {
+                       DEBUGP(4, dev, "timeout waiting for infoLen\n");
+                       rc = -EIO;
+                       goto release_io;
+               }
+       } else
+               clear_bit(IS_PROCBYTE_PRESENT, &dev->flags);
+
+       /* numRecBytes | bit9 of numRecytes */
+       io_read_num_rec_bytes(iobase, &dev->rlen);
+       for (i = 0; i < 600; i++) {     /* max waiting time of 2 sec */
+               if (dev->proto) {
+                       if (dev->rlen >= infolen + 4)
+                               break;
+               }
+               msleep_interruptible(10);
+               /* numRecBytes | bit9 of numRecytes */
+               io_read_num_rec_bytes(iobase, &s);
+               if (s > dev->rlen) {
+                       DEBUGP(1, dev, "NumRecBytes inc (reset timeout)\n");
+                       i = 0;  /* reset timeout */
+                       dev->rlen = s;
+               }
+               /* T=0: we are done when numRecBytes doesn't
+                *      increment any more and NoProcedureByte
+                *      is set and numRecBytes == bytes sent + 6
+                *      (header bytes + data + 1 for sw2)
+                *      except when the card replies an error
+                *      which means, no data will be sent back.
+                */
+               else if (dev->proto == 0) {
+                       if ((inb(REG_BUF_ADDR(iobase)) & 0x80)) {
+                               /* no procedure byte received since last read */
+                               DEBUGP(1, dev, "NoProcedure byte set\n");
+                               /* i=0; */
+                       } else {
+                               /* procedure byte received since last read */
+                               DEBUGP(1, dev, "NoProcedure byte unset "
+                                       "(reset timeout)\n");
+                               dev->procbyte = inb(REG_FLAGS1(iobase));
+                               DEBUGP(1, dev, "Read procedure byte 0x%.2x\n",
+                                     dev->procbyte);
+                               i = 0;  /* resettimeout */
+                       }
+                       if (inb(REG_FLAGS0(iobase)) & 0x08) {
+                               DEBUGP(1, dev, "T0Done flag (read reply)\n");
+                               break;
+                       }
+               }
+               if (dev->proto)
+                       infolen = inb(REG_FLAGS1(iobase));
+       }
+       if (i == 600) {
+               DEBUGP(1, dev, "timeout waiting for numRecBytes\n");
+               rc = -EIO;
+               goto release_io;
+       } else {
+               if (dev->proto == 0) {
+                       DEBUGP(1, dev, "Wait for T0Done bit to be  set\n");
+                       for (i = 0; i < 1000; i++) {
+                               if (inb(REG_FLAGS0(iobase)) & 0x08)
+                                       break;
+                               msleep_interruptible(10);
+                       }
+                       if (i == 1000) {
+                               DEBUGP(1, dev, "timeout waiting for T0Done\n");
+                               rc = -EIO;
+                               goto release_io;
+                       }
+
+                       dev->procbyte = inb(REG_FLAGS1(iobase));
+                       DEBUGP(4, dev, "Read procedure byte 0x%.2x\n",
+                             dev->procbyte);
+
+                       io_read_num_rec_bytes(iobase, &dev->rlen);
+                       DEBUGP(4, dev, "Read NumRecBytes = %i\n", dev->rlen);
+
+               }
+       }
+       /* T=1: read offset=zero, T=0: read offset=after challenge */
+       dev->rpos = dev->proto ? 0 : nr == 4 ? 5 : nr > dev->rlen ? 5 : nr;
+       DEBUGP(4, dev, "dev->rlen = %i,  dev->rpos = %i, nr = %i\n",
+             dev->rlen, dev->rpos, nr);
+
+release_io:
+       DEBUGP(4, dev, "Reset SM\n");
+       xoutb(0x80, REG_FLAGS0(iobase));        /* reset SM */
+
+       if (rc < 0) {
+               DEBUGP(4, dev, "Write failed but clear T_Active\n");
+               dev->flags1 &= 0xdf;
+               xoutb(dev->flags1, REG_FLAGS1(iobase));
+       }
+
+       clear_bit(LOCK_IO, &dev->flags);
+       wake_up_interruptible(&dev->ioq);
+       wake_up_interruptible(&dev->readq);     /* tell read we have data */
+
+       /* ITSEC E2: clear write buffer */
+       memset((char *)dev->sbuf, 0, 512);
+
+       /* return error or actually written bytes */
+       DEBUGP(2, dev, "<- cmm_write\n");
+       return rc < 0 ? rc : nr;
+}
+
+static void start_monitor(struct cm4000_dev *dev)
+{
+       DEBUGP(3, dev, "-> start_monitor\n");
+       if (!dev->monitor_running) {
+               DEBUGP(5, dev, "create, init and add timer\n");
+               init_timer(&dev->timer);
+               dev->monitor_running = 1;
+               dev->timer.expires = jiffies;
+               dev->timer.data = (unsigned long) dev;
+               dev->timer.function = monitor_card;
+               add_timer(&dev->timer);
+       } else
+               DEBUGP(5, dev, "monitor already running\n");
+       DEBUGP(3, dev, "<- start_monitor\n");
+}
+
+static void stop_monitor(struct cm4000_dev *dev)
+{
+       DEBUGP(3, dev, "-> stop_monitor\n");
+       if (dev->monitor_running) {
+               DEBUGP(5, dev, "stopping monitor\n");
+               terminate_monitor(dev);
+               /* reset monitor SM */
+               clear_bit(IS_ATR_VALID, &dev->flags);
+               clear_bit(IS_ATR_PRESENT, &dev->flags);
+       } else
+               DEBUGP(5, dev, "monitor already stopped\n");
+       DEBUGP(3, dev, "<- stop_monitor\n");
+}
+
+static int cmm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
+                    unsigned long arg)
+{
+       struct cm4000_dev *dev = filp->private_data;
+       ioaddr_t iobase = dev->link.io.BasePort1;
+       dev_link_t *link;
+       int size;
+       int rc;
+#ifdef PCMCIA_DEBUG
+       char *ioctl_names[CM_IOC_MAXNR + 1] = {
+               [_IOC_NR(CM_IOCGSTATUS)] "CM_IOCGSTATUS",
+               [_IOC_NR(CM_IOCGATR)] "CM_IOCGATR",
+               [_IOC_NR(CM_IOCARDOFF)] "CM_IOCARDOFF",
+               [_IOC_NR(CM_IOCSPTS)] "CM_IOCSPTS",
+               [_IOC_NR(CM_IOSDBGLVL)] "CM4000_DBGLVL",
+       };
+#endif
+       DEBUGP(3, dev, "cmm_ioctl(device=%d.%d) %s\n", imajor(inode),
+              iminor(inode), ioctl_names[_IOC_NR(cmd)]);
+
+       link = dev_table[iminor(inode)];
+       if (!(DEV_OK(link))) {
+               DEBUGP(4, dev, "DEV_OK false\n");
+               return -ENODEV;
+       }
+
+       if (test_bit(IS_CMM_ABSENT, &dev->flags)) {
+               DEBUGP(4, dev, "CMM_ABSENT flag set\n");
+               return -ENODEV;
+       }
+
+       if (_IOC_TYPE(cmd) != CM_IOC_MAGIC) {
+               DEBUGP(4, dev, "ioctype mismatch\n");
+               return -EINVAL;
+       }
+       if (_IOC_NR(cmd) > CM_IOC_MAXNR) {
+               DEBUGP(4, dev, "iocnr mismatch\n");
+               return -EINVAL;
+       }
+       size = _IOC_SIZE(cmd);
+       rc = 0;
+       DEBUGP(4, dev, "iocdir=%.4x iocr=%.4x iocw=%.4x iocsize=%d cmd=%.4x\n",
+             _IOC_DIR(cmd), _IOC_READ, _IOC_WRITE, size, cmd);
+
+       if (_IOC_DIR(cmd) & _IOC_READ) {
+               if (!access_ok(VERIFY_WRITE, (void *)arg, size))
+                       return -EFAULT;
+       }
+       if (_IOC_DIR(cmd) & _IOC_WRITE) {
+               if (!access_ok(VERIFY_READ, (void *)arg, size))
+                       return -EFAULT;
+       }
+
+       switch (cmd) {
+       case CM_IOCGSTATUS:
+               DEBUGP(4, dev, " ... in CM_IOCGSTATUS\n");
+               {
+                       int status;
+
+                       /* clear other bits, but leave inserted & powered as
+                        * they are */
+                       status = dev->flags0 & 3;
+                       if (test_bit(IS_ATR_PRESENT, &dev->flags))
+                               status |= CM_ATR_PRESENT;
+                       if (test_bit(IS_ATR_VALID, &dev->flags))
+                               status |= CM_ATR_VALID;
+                       if (test_bit(IS_CMM_ABSENT, &dev->flags))
+                               status |= CM_NO_READER;
+                       if (test_bit(IS_BAD_CARD, &dev->flags))
+                               status |= CM_BAD_CARD;
+                       if (copy_to_user((int *)arg, &status, sizeof(int)))
+                               return -EFAULT;
+               }
+               return 0;
+       case CM_IOCGATR:
+               DEBUGP(4, dev, "... in CM_IOCGATR\n");
+               {
+                       struct atreq *atreq = (struct atreq *) arg;
+                       int tmp;
+                       /* allow nonblocking io and being interrupted */
+                       if (wait_event_interruptible
+                           (dev->atrq,
+                            ((filp->f_flags & O_NONBLOCK)
+                             || (test_bit(IS_ATR_PRESENT, (void *)&dev->flags)
+                                 != 0)))) {
+                               if (filp->f_flags & O_NONBLOCK)
+                                       return -EAGAIN;
+                               return -ERESTARTSYS;
+                       }
+
+                       if (test_bit(IS_ATR_VALID, &dev->flags) == 0) {
+                               tmp = -1;
+                               if (copy_to_user(&(atreq->atr_len), &tmp,
+                                                sizeof(int)))
+                                       return -EFAULT;
+                       } else {
+                               if (copy_to_user(atreq->atr, dev->atr,
+                                                dev->atr_len))
+                                       return -EFAULT;
+
+                               tmp = dev->atr_len;
+                               if (copy_to_user(&(atreq->atr_len), &tmp, sizeof(int)))
+                                       return -EFAULT;
+                       }
+                       return 0;
+               }
+       case CM_IOCARDOFF:
+
+#ifdef PCMCIA_DEBUG
+               DEBUGP(4, dev, "... in CM_IOCARDOFF\n");
+               if (dev->flags0 & 0x01) {
+                       DEBUGP(4, dev, "    Card inserted\n");
+               } else {
+                       DEBUGP(2, dev, "    No card inserted\n");
+               }
+               if (dev->flags0 & 0x02) {
+                       DEBUGP(4, dev, "    Card powered\n");
+               } else {
+                       DEBUGP(2, dev, "    Card not powered\n");
+               }
+#endif
+
+               /* is a card inserted and powered? */
+               if ((dev->flags0 & 0x01) && (dev->flags0 & 0x02)) {
+
+                       /* get IO lock */
+                       if (wait_event_interruptible
+                           (dev->ioq,
+                            ((filp->f_flags & O_NONBLOCK)
+                             || (test_and_set_bit(LOCK_IO, (void *)&dev->flags)
+                                 == 0)))) {
+                               if (filp->f_flags & O_NONBLOCK)
+                                       return -EAGAIN;
+                               return -ERESTARTSYS;
+                       }
+                       /* Set Flags0 = 0x42 */
+                       DEBUGP(4, dev, "Set Flags0=0x42 \n");
+                       xoutb(0x42, REG_FLAGS0(iobase));
+                       clear_bit(IS_ATR_PRESENT, &dev->flags);
+                       clear_bit(IS_ATR_VALID, &dev->flags);
+                       dev->mstate = M_CARDOFF;
+                       clear_bit(LOCK_IO, &dev->flags);
+                       if (wait_event_interruptible
+                           (dev->atrq,
+                            ((filp->f_flags & O_NONBLOCK)
+                             || (test_bit(IS_ATR_VALID, (void *)&dev->flags) !=
+                                 0)))) {
+                               if (filp->f_flags & O_NONBLOCK)
+                                       return -EAGAIN;
+                               return -ERESTARTSYS;
+                       }
+               }
+               /* release lock */
+               clear_bit(LOCK_IO, &dev->flags);
+               wake_up_interruptible(&dev->ioq);
+
+               return 0;
+       case CM_IOCSPTS:
+               {
+                       struct ptsreq krnptsreq;
+
+                       if (copy_from_user(&krnptsreq, (struct ptsreq *) arg,
+                                          sizeof(struct ptsreq)))
+                               return -EFAULT;
+
+                       rc = 0;
+                       DEBUGP(4, dev, "... in CM_IOCSPTS\n");
+                       /* wait for ATR to get valid */
+                       if (wait_event_interruptible
+                           (dev->atrq,
+                            ((filp->f_flags & O_NONBLOCK)
+                             || (test_bit(IS_ATR_PRESENT, (void *)&dev->flags)
+                                 != 0)))) {
+                               if (filp->f_flags & O_NONBLOCK)
+                                       return -EAGAIN;
+                               return -ERESTARTSYS;
+                       }
+                       /* get IO lock */
+                       if (wait_event_interruptible
+                           (dev->ioq,
+                            ((filp->f_flags & O_NONBLOCK)
+                             || (test_and_set_bit(LOCK_IO, (void *)&dev->flags)
+                                 == 0)))) {
+                               if (filp->f_flags & O_NONBLOCK)
+                                       return -EAGAIN;
+                               return -ERESTARTSYS;
+                       }
+
+                       if ((rc = set_protocol(dev, &krnptsreq)) != 0) {
+                               /* auto power_on again */
+                               dev->mstate = M_FETCH_ATR;
+                               clear_bit(IS_ATR_VALID, &dev->flags);
+                       }
+                       /* release lock */
+                       clear_bit(LOCK_IO, &dev->flags);
+                       wake_up_interruptible(&dev->ioq);
+
+               }
+               return rc;
+#ifdef PCMCIA_DEBUG
+       case CM_IOSDBGLVL:      /* set debug log level */
+               {
+                       int old_pc_debug = 0;
+
+                       old_pc_debug = pc_debug;
+                       if (copy_from_user(&pc_debug, (int *)arg, sizeof(int)))
+                               return -EFAULT;
+
+                       if (old_pc_debug != pc_debug)
+                               DEBUGP(0, dev, "Changed debug log level "
+                                      "to %i\n", pc_debug);
+               }
+               return rc;
+#endif
+       default:
+               DEBUGP(4, dev, "... in default (unknown IOCTL code)\n");
+               return -EINVAL;
+       }
+}
+
+static int cmm_open(struct inode *inode, struct file *filp)
+{
+       struct cm4000_dev *dev;
+       dev_link_t *link;
+       int rc, minor = iminor(inode);
+
+       if (minor >= CM4000_MAX_DEV)
+               return -ENODEV;
+
+       link = dev_table[minor];
+       if (link == NULL || !(DEV_OK(link)))
+               return -ENODEV;
+
+       if (link->open)
+               return -EBUSY;
+
+       dev = link->priv;
+       filp->private_data = dev;
+
+       DEBUGP(2, dev, "-> cmm_open(device=%d.%d process=%s,%d)\n",
+             imajor(inode), minor, current->comm, current->pid);
+
+       /* init device variables, they may be "polluted" after close
+        * or, the device may never have been closed (i.e. open failed)
+        */
+
+       ZERO_DEV(dev);
+
+       /* opening will always block since the
+        * monitor will be started by open, which
+        * means we have to wait for ATR becoming
+        * vaild = block until valid (or card
+        * inserted)
+        */
+       if (filp->f_flags & O_NONBLOCK)
+               return -EAGAIN;
+
+       dev->mdelay = T_50MSEC;
+
+       /* start monitoring the cardstatus */
+       start_monitor(dev);
+
+       link->open = 1;         /* only one open per device */
+       rc = 0;
+
+       DEBUGP(2, dev, "<- cmm_open\n");
+       return nonseekable_open(inode, filp);
+}
+
+static int cmm_close(struct inode *inode, struct file *filp)
+{
+       struct cm4000_dev *dev;
+       dev_link_t *link;
+       int minor = iminor(inode);
+
+       if (minor >= CM4000_MAX_DEV)
+               return -ENODEV;
+
+       link = dev_table[minor];
+       if (link == NULL)
+               return -ENODEV;
+
+       dev = link->priv;
+
+       DEBUGP(2, dev, "-> cmm_close(maj/min=%d.%d)\n",
+              imajor(inode), minor);
+
+       stop_monitor(dev);
+
+       ZERO_DEV(dev);
+
+       link->open = 0;         /* only one open per device */
+       wake_up(&dev->devq);    /* socket removed? */
+
+       DEBUGP(2, dev, "cmm_close\n");
+       return 0;
+}
+
+static void cmm_cm4000_release(dev_link_t * link)
+{
+       struct cm4000_dev *dev = link->priv;
+
+       /* dont terminate the monitor, rather rely on
+        * close doing that for us.
+        */
+       DEBUGP(3, dev, "-> cmm_cm4000_release\n");
+       while (link->open) {
+               printk(KERN_INFO MODULE_NAME ": delaying release until "
+                      "process has terminated\n");
+               /* note: don't interrupt us:
+                * close the applications which own
+                * the devices _first_ !
+                */
+               wait_event(dev->devq, (link->open == 0));
+       }
+       /* dev->devq=NULL;      this cannot be zeroed earlier */
+       DEBUGP(3, dev, "<- cmm_cm4000_release\n");
+       return;
+}
+
+/*==== Interface to PCMCIA Layer =======================================*/
+
+static void cm4000_config(dev_link_t * link, int devno)
+{
+       client_handle_t handle = link->handle;
+       struct cm4000_dev *dev;
+       tuple_t tuple;
+       cisparse_t parse;
+       config_info_t conf;
+       u_char buf[64];
+       int fail_fn, fail_rc;
+       int rc;
+
+       /* read the config-tuples */
+       tuple.DesiredTuple = CISTPL_CONFIG;
+       tuple.Attributes = 0;
+       tuple.TupleData = buf;
+       tuple.TupleDataMax = sizeof(buf);
+       tuple.TupleOffset = 0;
+
+       if ((fail_rc = pcmcia_get_first_tuple(handle, &tuple)) != CS_SUCCESS) {
+               fail_fn = GetFirstTuple;
+               goto cs_failed;
+       }
+       if ((fail_rc = pcmcia_get_tuple_data(handle, &tuple)) != CS_SUCCESS) {
+               fail_fn = GetTupleData;
+               goto cs_failed;
+       }
+       if ((fail_rc =
+            pcmcia_parse_tuple(handle, &tuple, &parse)) != CS_SUCCESS) {
+               fail_fn = ParseTuple;
+               goto cs_failed;
+       }
+       if ((fail_rc =
+            pcmcia_get_configuration_info(handle, &conf)) != CS_SUCCESS) {
+               fail_fn = GetConfigurationInfo;
+               goto cs_failed;
+       }
+
+       link->state |= DEV_CONFIG;
+       link->conf.ConfigBase = parse.config.base;
+       link->conf.Present = parse.config.rmask[0];
+       link->conf.Vcc = conf.Vcc;
+
+       link->io.BasePort2 = 0;
+       link->io.NumPorts2 = 0;
+       link->io.Attributes2 = 0;
+       tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
+       for (rc = pcmcia_get_first_tuple(handle, &tuple);
+            rc == CS_SUCCESS; rc = pcmcia_get_next_tuple(handle, &tuple)) {
+
+               rc = pcmcia_get_tuple_data(handle, &tuple);
+               if (rc != CS_SUCCESS)
+                       continue;
+               rc = pcmcia_parse_tuple(handle, &tuple, &parse);
+               if (rc != CS_SUCCESS)
+                       continue;
+
+               link->conf.ConfigIndex = parse.cftable_entry.index;
+
+               if (!parse.cftable_entry.io.nwin)
+                       continue;
+
+               /* Get the IOaddr */
+               link->io.BasePort1 = parse.cftable_entry.io.win[0].base;
+               link->io.NumPorts1 = parse.cftable_entry.io.win[0].len;
+               link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
+               if (!(parse.cftable_entry.io.flags & CISTPL_IO_8BIT))
+                       link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
+               if (!(parse.cftable_entry.io.flags & CISTPL_IO_16BIT))
+                       link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
+               link->io.IOAddrLines = parse.cftable_entry.io.flags
+                   & CISTPL_IO_LINES_MASK;
+
+               rc = pcmcia_request_io(handle, &link->io);
+               if (rc == CS_SUCCESS)
+                       break;  /* we are done */
+       }
+       if (rc != CS_SUCCESS)
+               goto cs_release;
+
+       link->conf.IntType = 00000002;
+
+       if ((fail_rc =
+            pcmcia_request_configuration(handle, &link->conf)) != CS_SUCCESS) {
+               fail_fn = RequestConfiguration;
+               goto cs_release;
+       }
+
+       dev = link->priv;
+       sprintf(dev->node.dev_name, DEVICE_NAME "%d", devno);
+       dev->node.major = major;
+       dev->node.minor = devno;
+       dev->node.next = NULL;
+       link->dev = &dev->node;
+       link->state &= ~DEV_CONFIG_PENDING;
+
+       return;
+
+cs_failed:
+       cs_error(handle, fail_fn, fail_rc);
+cs_release:
+       cm4000_release(link);
+
+       link->state &= ~DEV_CONFIG_PENDING;
+}
+
+static int cm4000_event(event_t event, int priority,
+                       event_callback_args_t *args)
+{
+       dev_link_t *link;
+       struct cm4000_dev *dev;
+       int devno;
+
+       link = args->client_data;
+       dev = link->priv;
+
+       DEBUGP(3, dev, "-> cm4000_event\n");
+       for (devno = 0; devno < CM4000_MAX_DEV; devno++)
+               if (dev_table[devno] == link)
+                       break;
+
+       if (devno == CM4000_MAX_DEV)
+               return CS_BAD_ADAPTER;
+
+       switch (event) {
+       case CS_EVENT_CARD_INSERTION:
+               DEBUGP(5, dev, "CS_EVENT_CARD_INSERTION\n");
+               link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
+               cm4000_config(link, devno);
+               break;
+       case CS_EVENT_CARD_REMOVAL:
+               DEBUGP(5, dev, "CS_EVENT_CARD_REMOVAL\n");
+               link->state &= ~DEV_PRESENT;
+               stop_monitor(dev);
+               break;
+       case CS_EVENT_PM_SUSPEND:
+               DEBUGP(5, dev, "CS_EVENT_PM_SUSPEND "
+                     "(fall-through to CS_EVENT_RESET_PHYSICAL)\n");
+               link->state |= DEV_SUSPEND;
+               /* fall-through */
+       case CS_EVENT_RESET_PHYSICAL:
+               DEBUGP(5, dev, "CS_EVENT_RESET_PHYSICAL\n");
+               if (link->state & DEV_CONFIG) {
+                       DEBUGP(5, dev, "ReleaseConfiguration\n");
+                       pcmcia_release_configuration(link->handle);
+               }
+               stop_monitor(dev);
+               break;
+       case CS_EVENT_PM_RESUME:
+               DEBUGP(5, dev, "CS_EVENT_PM_RESUME "
+                     "(fall-through to CS_EVENT_CARD_RESET)\n");
+               link->state &= ~DEV_SUSPEND;
+               /* fall-through */
+       case CS_EVENT_CARD_RESET:
+               DEBUGP(5, dev, "CS_EVENT_CARD_RESET\n");
+               if ((link->state & DEV_CONFIG)) {
+                       DEBUGP(5, dev, "RequestConfiguration\n");
+                       pcmcia_request_configuration(link->handle, &link->conf);
+               }
+               if (link->open)
+                       start_monitor(dev);
+               break;
+       default:
+               DEBUGP(5, dev, "unknown event %.2x\n", event);
+               break;
+       }
+       DEBUGP(3, dev, "<- cm4000_event\n");
+       return CS_SUCCESS;
+}
+
+static void cm4000_release(dev_link_t *link)
+{
+       cmm_cm4000_release(link->priv); /* delay release until device closed */
+       pcmcia_release_configuration(link->handle);
+       pcmcia_release_io(link->handle, &link->io);
+}
+
+static dev_link_t *cm4000_attach(void)
+{
+       struct cm4000_dev *dev;
+       dev_link_t *link;
+       client_reg_t client_reg;
+       int i;
+
+       for (i = 0; i < CM4000_MAX_DEV; i++)
+               if (dev_table[i] == NULL)
+                       break;
+
+       if (i == CM4000_MAX_DEV) {
+               printk(KERN_NOTICE MODULE_NAME ": all devices in use\n");
+               return NULL;
+       }
+
+       /* create a new cm4000_cs device */
+       dev = kzalloc(sizeof(struct cm4000_dev), GFP_KERNEL);
+       if (dev == NULL)
+               return NULL;
+
+       link = &dev->link;
+       link->priv = dev;
+       link->conf.IntType = INT_MEMORY_AND_IO;
+       dev_table[i] = link;
+
+       /* register with card services */
+       client_reg.dev_info = &dev_info;
+       client_reg.EventMask =
+           CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
+           CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
+           CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
+       client_reg.Version = 0x0210;
+       client_reg.event_callback_args.client_data = link;
+
+       i = pcmcia_register_client(&link->handle, &client_reg);
+       if (i) {
+               cs_error(link->handle, RegisterClient, i);
+               cm4000_detach(link);
+               return NULL;
+       }
+
+       init_waitqueue_head(&dev->devq);
+       init_waitqueue_head(&dev->ioq);
+       init_waitqueue_head(&dev->atrq);
+       init_waitqueue_head(&dev->readq);
+
+       return link;
+}
+
+static void cm4000_detach_by_devno(int devno, dev_link_t * link)
+{
+       struct cm4000_dev *dev = link->priv;
+
+       DEBUGP(3, dev, "-> detach_by_devno(devno=%d)\n", devno);
+
+       if (link->state & DEV_CONFIG) {
+               DEBUGP(5, dev, "device still configured (try to release it)\n");
+               cm4000_release(link);
+       }
+
+       if (link->handle) {
+               pcmcia_deregister_client(link->handle);
+       }
+
+       dev_table[devno] = NULL;
+       kfree(dev);
+       return;
+}
+
+static void cm4000_detach(dev_link_t * link)
+{
+       int i;
+
+       /* find device */
+       for (i = 0; i < CM4000_MAX_DEV; i++)
+               if (dev_table[i] == link)
+                       break;
+
+       if (i == CM4000_MAX_DEV)
+               return;
+
+       cm4000_detach_by_devno(i, link);
+       return;
+}
+
+static struct file_operations cm4000_fops = {
+       .owner  = THIS_MODULE,
+       .read   = cmm_read,
+       .write  = cmm_write,
+       .ioctl  = cmm_ioctl,
+       .open   = cmm_open,
+       .release= cmm_close,
+};
+
+static struct pcmcia_device_id cm4000_ids[] = {
+       PCMCIA_DEVICE_MANF_CARD(0x0223, 0x0002),
+       PCMCIA_DEVICE_PROD_ID12("CardMan", "4000", 0x2FB368CA, 0xA2BD8C39),
+       PCMCIA_DEVICE_NULL,
+};
+MODULE_DEVICE_TABLE(pcmcia, cm4000_ids);
+
+static struct pcmcia_driver cm4000_driver = {
+       .owner    = THIS_MODULE,
+       .drv      = {
+               .name = "cm4000_cs",
+               },
+       .attach   = cm4000_attach,
+       .detach   = cm4000_detach,
+       .event    = cm4000_event,
+       .id_table = cm4000_ids,
+};
+
+static int __init cmm_init(void)
+{
+       printk(KERN_INFO "%s\n", version);
+       pcmcia_register_driver(&cm4000_driver);
+       major = register_chrdev(0, DEVICE_NAME, &cm4000_fops);
+       if (major < 0) {
+               printk(KERN_WARNING MODULE_NAME
+                       ": could not get major number\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+static void __exit cmm_exit(void)
+{
+       int i;
+
+       printk(KERN_INFO MODULE_NAME ": unloading\n");
+       pcmcia_unregister_driver(&cm4000_driver);
+       for (i = 0; i < CM4000_MAX_DEV; i++)
+               if (dev_table[i])
+                       cm4000_detach_by_devno(i, dev_table[i]);
+       unregister_chrdev(major, DEVICE_NAME);
+};
+
+module_init(cmm_init);
+module_exit(cmm_exit);
+MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
new file mode 100644 (file)
index 0000000..4c698d9
--- /dev/null
@@ -0,0 +1,841 @@
+/*
+ * A driver for the Omnikey PCMCIA smartcard reader CardMan 4040
+ *
+ * (c) 2000-2004 Omnikey AG (http://www.omnikey.com/)
+ *
+ * (C) 2005 Harald Welte <laforge@gnumonks.org>
+ *     - add support for poll()
+ *     - driver cleanup
+ *     - add waitqueues
+ *     - adhere to linux kernel coding style and policies
+ *     - support 2.6.13 "new style" pcmcia interface
+ *
+ * The device basically is a USB CCID compliant device that has been
+ * attached to an I/O-Mapped FIFO.
+ *
+ * All rights reserved, Dual BSD/GPL Licensed.
+ */
+
+/* #define PCMCIA_DEBUG 6 */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/fs.h>
+#include <linux/delay.h>
+#include <linux/poll.h>
+#include <linux/wait.h>
+#include <asm/uaccess.h>
+#include <asm/io.h>
+
+#include <pcmcia/cs_types.h>
+#include <pcmcia/cs.h>
+#include <pcmcia/cistpl.h>
+#include <pcmcia/cisreg.h>
+#include <pcmcia/ciscode.h>
+#include <pcmcia/ds.h>
+
+#include "cm4040_cs.h"
+
+
+#ifdef PCMCIA_DEBUG
+#define reader_to_dev(x)       (&handle_to_dev(x->link.handle))
+static int pc_debug = PCMCIA_DEBUG;
+module_param(pc_debug, int, 0600);
+#define DEBUGP(n, rdr, x, args...) do {                                \
+       if (pc_debug >= (n))                                            \
+               dev_printk(KERN_DEBUG, reader_to_dev(rdr), "%s:" x,     \
+                          __FUNCTION__ , ##args);                      \
+       } while (0)
+#else
+#define DEBUGP(n, rdr, x, args...)
+#endif
+
+static char *version =
+"OMNIKEY CardMan 4040 v1.1.0gm4 - All bugs added by Harald Welte";
+
+#define        CCID_DRIVER_BULK_DEFAULT_TIMEOUT        (150*HZ)
+#define        CCID_DRIVER_ASYNC_POWERUP_TIMEOUT       (35*HZ)
+#define        CCID_DRIVER_MINIMUM_TIMEOUT             (3*HZ)
+#define READ_WRITE_BUFFER_SIZE 512
+#define POLL_LOOP_COUNT                                1000
+
+/* how often to poll for fifo status change */
+#define POLL_PERIOD                            msecs_to_jiffies(10)
+
+static void reader_release(dev_link_t *link);
+static void reader_detach(dev_link_t *link);
+
+static int major;
+
+#define                BS_READABLE     0x01
+#define                BS_WRITABLE     0x02
+
+struct reader_dev {
+       dev_link_t              link;
+       dev_node_t              node;
+       wait_queue_head_t       devq;
+       wait_queue_head_t       poll_wait;
+       wait_queue_head_t       read_wait;
+       wait_queue_head_t       write_wait;
+       unsigned long           buffer_status;
+       unsigned long           timeout;
+       unsigned char           s_buf[READ_WRITE_BUFFER_SIZE];
+       unsigned char           r_buf[READ_WRITE_BUFFER_SIZE];
+       struct timer_list       poll_timer;
+};
+
+static dev_info_t dev_info = MODULE_NAME;
+static dev_link_t *dev_table[CM_MAX_DEV];
+
+#ifndef PCMCIA_DEBUG
+#define        xoutb   outb
+#define        xinb    inb
+#else
+static inline void xoutb(unsigned char val, unsigned short port)
+{
+       if (pc_debug >= 7)
+               printk(KERN_DEBUG "outb(val=%.2x,port=%.4x)\n", val, port);
+       outb(val, port);
+}
+
+static inline unsigned char xinb(unsigned short port)
+{
+       unsigned char val;
+
+       val = inb(port);
+       if (pc_debug >= 7)
+               printk(KERN_DEBUG "%.2x=inb(%.4x)\n", val, port);
+       return val;
+}
+#endif
+
+/* poll the device fifo status register.  not to be confused with
+ * the poll syscall. */
+static void cm4040_do_poll(unsigned long dummy)
+{
+       struct reader_dev *dev = (struct reader_dev *) dummy;
+       unsigned int obs = xinb(dev->link.io.BasePort1
+                               + REG_OFFSET_BUFFER_STATUS);
+
+       if ((obs & BSR_BULK_IN_FULL)) {
+               set_bit(BS_READABLE, &dev->buffer_status);
+               DEBUGP(4, dev, "waking up read_wait\n");
+               wake_up_interruptible(&dev->read_wait);
+       } else
+               clear_bit(BS_READABLE, &dev->buffer_status);
+
+       if (!(obs & BSR_BULK_OUT_FULL)) {
+               set_bit(BS_WRITABLE, &dev->buffer_status);
+               DEBUGP(4, dev, "waking up write_wait\n");
+               wake_up_interruptible(&dev->write_wait);
+       } else
+               clear_bit(BS_WRITABLE, &dev->buffer_status);
+
+       if (dev->buffer_status)
+               wake_up_interruptible(&dev->poll_wait);
+
+       mod_timer(&dev->poll_timer, jiffies + POLL_PERIOD);
+}
+
+static void cm4040_stop_poll(struct reader_dev *dev)
+{
+       del_timer_sync(&dev->poll_timer);
+}
+
+static int wait_for_bulk_out_ready(struct reader_dev *dev)
+{
+       int i, rc;
+       int iobase = dev->link.io.BasePort1;
+
+       for (i = 0; i < POLL_LOOP_COUNT; i++) {
+               if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS)
+                   & BSR_BULK_OUT_FULL) == 0) {
+                       DEBUGP(4, dev, "BulkOut empty (i=%d)\n", i);
+                       return 1;
+               }
+       }
+
+       DEBUGP(4, dev, "wait_event_interruptible_timeout(timeout=%ld\n",
+               dev->timeout);
+       rc = wait_event_interruptible_timeout(dev->write_wait,
+                                             test_and_clear_bit(BS_WRITABLE,
+                                                      &dev->buffer_status),
+                                             dev->timeout);
+
+       if (rc > 0)
+               DEBUGP(4, dev, "woke up: BulkOut empty\n");
+       else if (rc == 0)
+               DEBUGP(4, dev, "woke up: BulkOut full, returning 0 :(\n");
+       else if (rc < 0)
+               DEBUGP(4, dev, "woke up: signal arrived\n");
+
+       return rc;
+}
+
+/* Write to Sync Control Register */
+static int write_sync_reg(unsigned char val, struct reader_dev *dev)
+{
+       int iobase = dev->link.io.BasePort1;
+       int rc;
+
+       rc = wait_for_bulk_out_ready(dev);
+       if (rc <= 0)
+               return rc;
+
+       xoutb(val, iobase + REG_OFFSET_SYNC_CONTROL);
+       rc = wait_for_bulk_out_ready(dev);
+       if (rc <= 0)
+               return rc;
+
+       return 1;
+}
+
+static int wait_for_bulk_in_ready(struct reader_dev *dev)
+{
+       int i, rc;
+       int iobase = dev->link.io.BasePort1;
+
+       for (i = 0; i < POLL_LOOP_COUNT; i++) {
+               if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS)
+                   & BSR_BULK_IN_FULL) == BSR_BULK_IN_FULL) {
+                       DEBUGP(3, dev, "BulkIn full (i=%d)\n", i);
+                       return 1;
+               }
+       }
+
+       DEBUGP(4, dev, "wait_event_interruptible_timeout(timeout=%ld\n",
+               dev->timeout);
+       rc = wait_event_interruptible_timeout(dev->read_wait,
+                                             test_and_clear_bit(BS_READABLE,
+                                                       &dev->buffer_status),
+                                             dev->timeout);
+       if (rc > 0)
+               DEBUGP(4, dev, "woke up: BulkIn full\n");
+       else if (rc == 0)
+               DEBUGP(4, dev, "woke up: BulkIn not full, returning 0 :(\n");
+       else if (rc < 0)
+               DEBUGP(4, dev, "woke up: signal arrived\n");
+
+       return rc;
+}
+
+static ssize_t cm4040_read(struct file *filp, char __user *buf,
+                       size_t count, loff_t *ppos)
+{
+       struct reader_dev *dev = filp->private_data;
+       int iobase = dev->link.io.BasePort1;
+       size_t bytes_to_read;
+       unsigned long i;
+       size_t min_bytes_to_read;
+       int rc;
+       unsigned char uc;
+
+       DEBUGP(2, dev, "-> cm4040_read(%s,%d)\n", current->comm, current->pid);
+
+       if (count == 0)
+               return 0;
+
+       if (count < 10)
+               return -EFAULT;
+
+       if (filp->f_flags & O_NONBLOCK) {
+               DEBUGP(4, dev, "filep->f_flags O_NONBLOCK set\n");
+               DEBUGP(2, dev, "<- cm4040_read (failure)\n");
+               return -EAGAIN;
+       }
+
+       if ((dev->link.state & DEV_PRESENT)==0)
+               return -ENODEV;
+
+       for (i = 0; i < 5; i++) {
+               rc = wait_for_bulk_in_ready(dev);
+               if (rc <= 0) {
+                       DEBUGP(5, dev, "wait_for_bulk_in_ready rc=%.2x\n", rc);
+                       DEBUGP(2, dev, "<- cm4040_read (failed)\n");
+                       if (rc == -ERESTARTSYS)
+                               return rc;
+                       return -EIO;
+               }
+               dev->r_buf[i] = xinb(iobase + REG_OFFSET_BULK_IN);
+#ifdef PCMCIA_DEBUG
+               if (pc_debug >= 6)
+                       printk(KERN_DEBUG "%lu:%2x ", i, dev->r_buf[i]);
+       }
+       printk("\n");
+#else
+       }
+#endif
+
+       bytes_to_read = 5 + le32_to_cpu(*(__le32 *)&dev->r_buf[1]);
+
+       DEBUGP(6, dev, "BytesToRead=%lu\n", bytes_to_read);
+
+       min_bytes_to_read = min(count, bytes_to_read + 5);
+
+       DEBUGP(6, dev, "Min=%lu\n", min_bytes_to_read);
+
+       for (i = 0; i < (min_bytes_to_read-5); i++) {
+               rc = wait_for_bulk_in_ready(dev);
+               if (rc <= 0) {
+                       DEBUGP(5, dev, "wait_for_bulk_in_ready rc=%.2x\n", rc);
+                       DEBUGP(2, dev, "<- cm4040_read (failed)\n");
+                       if (rc == -ERESTARTSYS)
+                               return rc;
+                       return -EIO;
+               }
+               dev->r_buf[i+5] = xinb(iobase + REG_OFFSET_BULK_IN);
+#ifdef PCMCIA_DEBUG
+               if (pc_debug >= 6)
+                       printk(KERN_DEBUG "%lu:%2x ", i, dev->r_buf[i]);
+       }
+       printk("\n");
+#else
+       }
+#endif
+
+       *ppos = min_bytes_to_read;
+       if (copy_to_user(buf, dev->r_buf, min_bytes_to_read))
+               return -EFAULT;
+
+       rc = wait_for_bulk_in_ready(dev);
+       if (rc <= 0) {
+               DEBUGP(5, dev, "wait_for_bulk_in_ready rc=%.2x\n", rc);
+               DEBUGP(2, dev, "<- cm4040_read (failed)\n");
+               if (rc == -ERESTARTSYS)
+                       return rc;
+               return -EIO;
+       }
+
+       rc = write_sync_reg(SCR_READER_TO_HOST_DONE, dev);
+       if (rc <= 0) {
+               DEBUGP(5, dev, "write_sync_reg c=%.2x\n", rc);
+               DEBUGP(2, dev, "<- cm4040_read (failed)\n");
+               if (rc == -ERESTARTSYS)
+                       return rc;
+               else
+                       return -EIO;
+       }
+
+       uc = xinb(iobase + REG_OFFSET_BULK_IN);
+
+       DEBUGP(2, dev, "<- cm4040_read (successfully)\n");
+       return min_bytes_to_read;
+}
+
+static ssize_t cm4040_write(struct file *filp, const char __user *buf,
+                        size_t count, loff_t *ppos)
+{
+       struct reader_dev *dev = filp->private_data;
+       int iobase = dev->link.io.BasePort1;
+       ssize_t rc;
+       int i;
+       unsigned int bytes_to_write;
+
+       DEBUGP(2, dev, "-> cm4040_write(%s,%d)\n", current->comm, current->pid);
+
+       if (count == 0) {
+               DEBUGP(2, dev, "<- cm4040_write empty read (successfully)\n");
+               return 0;
+       }
+
+       if (count < 5) {
+               DEBUGP(2, dev, "<- cm4040_write buffersize=%Zd < 5\n", count);
+               return -EIO;
+       }
+
+       if (filp->f_flags & O_NONBLOCK) {
+               DEBUGP(4, dev, "filep->f_flags O_NONBLOCK set\n");
+               DEBUGP(4, dev, "<- cm4040_write (failure)\n");
+               return -EAGAIN;
+       }
+
+       if ((dev->link.state & DEV_PRESENT) == 0)
+               return -ENODEV;
+
+       bytes_to_write = count;
+       if (copy_from_user(dev->s_buf, buf, bytes_to_write))
+               return -EFAULT;
+
+       switch (dev->s_buf[0]) {
+               case CMD_PC_TO_RDR_XFRBLOCK:
+               case CMD_PC_TO_RDR_SECURE:
+               case CMD_PC_TO_RDR_TEST_SECURE:
+               case CMD_PC_TO_RDR_OK_SECURE:
+                       dev->timeout = CCID_DRIVER_BULK_DEFAULT_TIMEOUT;
+                       break;
+
+               case CMD_PC_TO_RDR_ICCPOWERON:
+                       dev->timeout = CCID_DRIVER_ASYNC_POWERUP_TIMEOUT;
+                       break;
+
+               case CMD_PC_TO_RDR_GETSLOTSTATUS:
+               case CMD_PC_TO_RDR_ICCPOWEROFF:
+               case CMD_PC_TO_RDR_GETPARAMETERS:
+               case CMD_PC_TO_RDR_RESETPARAMETERS:
+               case CMD_PC_TO_RDR_SETPARAMETERS:
+               case CMD_PC_TO_RDR_ESCAPE:
+               case CMD_PC_TO_RDR_ICCCLOCK:
+               default:
+                       dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT;
+                       break;
+       }
+
+       rc = write_sync_reg(SCR_HOST_TO_READER_START, dev);
+       if (rc <= 0) {
+               DEBUGP(5, dev, "write_sync_reg c=%.2Zx\n", rc);
+               DEBUGP(2, dev, "<- cm4040_write (failed)\n");
+               if (rc == -ERESTARTSYS)
+                       return rc;
+               else
+                       return -EIO;
+       }
+
+       DEBUGP(4, dev, "start \n");
+
+       for (i = 0; i < bytes_to_write; i++) {
+               rc = wait_for_bulk_out_ready(dev);
+               if (rc <= 0) {
+                       DEBUGP(5, dev, "wait_for_bulk_out_ready rc=%.2Zx\n",
+                              rc);
+                       DEBUGP(2, dev, "<- cm4040_write (failed)\n");
+                       if (rc == -ERESTARTSYS)
+                               return rc;
+                       else
+                               return -EIO;
+               }
+
+               xoutb(dev->s_buf[i],iobase + REG_OFFSET_BULK_OUT);
+       }
+       DEBUGP(4, dev, "end\n");
+
+       rc = write_sync_reg(SCR_HOST_TO_READER_DONE, dev);
+
+       if (rc <= 0) {
+               DEBUGP(5, dev, "write_sync_reg c=%.2Zx\n", rc);
+               DEBUGP(2, dev, "<- cm4040_write (failed)\n");
+               if (rc == -ERESTARTSYS)
+                       return rc;
+               else
+                       return -EIO;
+       }
+
+       DEBUGP(2, dev, "<- cm4040_write (successfully)\n");
+       return count;
+}
+
+static unsigned int cm4040_poll(struct file *filp, poll_table *wait)
+{
+       struct reader_dev *dev = filp->private_data;
+       unsigned int mask = 0;
+
+       poll_wait(filp, &dev->poll_wait, wait);
+
+       if (test_and_clear_bit(BS_READABLE, &dev->buffer_status))
+               mask |= POLLIN | POLLRDNORM;
+       if (test_and_clear_bit(BS_WRITABLE, &dev->buffer_status))
+               mask |= POLLOUT | POLLWRNORM;
+
+       DEBUGP(2, dev, "<- cm4040_poll(%u)\n", mask);
+
+       return mask;
+}
+
+static int cm4040_open(struct inode *inode, struct file *filp)
+{
+       struct reader_dev *dev;
+       dev_link_t *link;
+       int minor = iminor(inode);
+
+       if (minor >= CM_MAX_DEV)
+               return -ENODEV;
+
+       link = dev_table[minor];
+       if (link == NULL || !(DEV_OK(link)))
+               return -ENODEV;
+
+       if (link->open)
+               return -EBUSY;
+
+       dev = link->priv;
+       filp->private_data = dev;
+
+       if (filp->f_flags & O_NONBLOCK) {
+               DEBUGP(4, dev, "filep->f_flags O_NONBLOCK set\n");
+               return -EAGAIN;
+       }
+
+       link->open = 1;
+
+       dev->poll_timer.data = (unsigned long) dev;
+       mod_timer(&dev->poll_timer, jiffies + POLL_PERIOD);
+
+       DEBUGP(2, dev, "<- cm4040_open (successfully)\n");
+       return nonseekable_open(inode, filp);
+}
+
+static int cm4040_close(struct inode *inode, struct file *filp)
+{
+       struct reader_dev *dev = filp->private_data;
+       dev_link_t *link;
+       int minor = iminor(inode);
+
+       DEBUGP(2, dev, "-> cm4040_close(maj/min=%d.%d)\n", imajor(inode),
+             iminor(inode));
+
+       if (minor >= CM_MAX_DEV)
+               return -ENODEV;
+
+       link = dev_table[minor];
+       if (link == NULL)
+               return -ENODEV;
+
+       cm4040_stop_poll(dev);
+
+       link->open = 0;
+       wake_up(&dev->devq);
+
+       DEBUGP(2, dev, "<- cm4040_close\n");
+       return 0;
+}
+
+static void cm4040_reader_release(dev_link_t *link)
+{
+       struct reader_dev *dev = link->priv;
+
+       DEBUGP(3, dev, "-> cm4040_reader_release\n");
+       while (link->open) {
+               DEBUGP(3, dev, KERN_INFO MODULE_NAME ": delaying release "
+                      "until process has terminated\n");
+               wait_event(dev->devq, (link->open == 0));
+       }
+       DEBUGP(3, dev, "<- cm4040_reader_release\n");
+       return;
+}
+
+static void reader_config(dev_link_t *link, int devno)
+{
+       client_handle_t handle;
+       struct reader_dev *dev;
+       tuple_t tuple;
+       cisparse_t parse;
+       config_info_t conf;
+       u_char buf[64];
+       int fail_fn, fail_rc;
+       int rc;
+
+       handle = link->handle;
+
+       tuple.DesiredTuple = CISTPL_CONFIG;
+       tuple.Attributes = 0;
+       tuple.TupleData = buf;
+       tuple.TupleDataMax = sizeof(buf);
+       tuple.TupleOffset = 0;
+
+       if ((fail_rc = pcmcia_get_first_tuple(handle, &tuple)) != CS_SUCCESS) {
+               fail_fn = GetFirstTuple;
+               goto cs_failed;
+       }
+       if ((fail_rc = pcmcia_get_tuple_data(handle, &tuple)) != CS_SUCCESS) {
+               fail_fn = GetTupleData;
+               goto cs_failed;
+       }
+       if ((fail_rc = pcmcia_parse_tuple(handle, &tuple, &parse))
+                                                       != CS_SUCCESS) {
+               fail_fn = ParseTuple;
+               goto cs_failed;
+       }
+       if ((fail_rc = pcmcia_get_configuration_info(handle, &conf))
+                                                       != CS_SUCCESS) {
+               fail_fn = GetConfigurationInfo;
+               goto cs_failed;
+       }
+
+       link->state |= DEV_CONFIG;
+       link->conf.ConfigBase = parse.config.base;
+       link->conf.Present = parse.config.rmask[0];
+       link->conf.Vcc = conf.Vcc;
+
+       link->io.BasePort2 = 0;
+       link->io.NumPorts2 = 0;
+       link->io.Attributes2 = 0;
+       tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
+       for (rc = pcmcia_get_first_tuple(handle, &tuple);
+            rc == CS_SUCCESS;
+            rc = pcmcia_get_next_tuple(handle, &tuple)) {
+               rc = pcmcia_get_tuple_data(handle, &tuple);
+               if (rc != CS_SUCCESS)
+                       continue;
+               rc = pcmcia_parse_tuple(handle, &tuple, &parse);
+               if (rc != CS_SUCCESS)
+                       continue;
+
+               link->conf.ConfigIndex = parse.cftable_entry.index;
+
+               if (!parse.cftable_entry.io.nwin)
+                       continue;
+
+               link->io.BasePort1 = parse.cftable_entry.io.win[0].base;
+               link->io.NumPorts1 = parse.cftable_entry.io.win[0].len;
+               link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
+               if (!(parse.cftable_entry.io.flags & CISTPL_IO_8BIT))
+                       link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
+               if (!(parse.cftable_entry.io.flags & CISTPL_IO_16BIT))
+                       link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
+               link->io.IOAddrLines = parse.cftable_entry.io.flags
+                                               & CISTPL_IO_LINES_MASK;
+               rc = pcmcia_request_io(handle, &link->io);
+
+               dev_printk(KERN_INFO, &handle_to_dev(handle), "foo");
+               if (rc == CS_SUCCESS)
+                       break;
+               else
+                       dev_printk(KERN_INFO, &handle_to_dev(handle),
+                                  "pcmcia_request_io failed 0x%x\n", rc);
+       }
+       if (rc != CS_SUCCESS)
+               goto cs_release;
+
+       link->conf.IntType = 00000002;
+
+       if ((fail_rc = pcmcia_request_configuration(handle,&link->conf))
+                                                               !=CS_SUCCESS) {
+               fail_fn = RequestConfiguration;
+               dev_printk(KERN_INFO, &handle_to_dev(handle),
+                          "pcmcia_request_configuration failed 0x%x\n",
+                          fail_rc);
+               goto cs_release;
+       }
+
+       dev = link->priv;
+       sprintf(dev->node.dev_name, DEVICE_NAME "%d", devno);
+       dev->node.major = major;
+       dev->node.minor = devno;
+       dev->node.next = NULL;
+       link->dev = &dev->node;
+       link->state &= ~DEV_CONFIG_PENDING;
+
+       DEBUGP(2, dev, "device " DEVICE_NAME "%d at 0x%.4x-0x%.4x\n", devno,
+             link->io.BasePort1, link->io.BasePort1+link->io.NumPorts1);
+       DEBUGP(2, dev, "<- reader_config (succ)\n");
+
+       return;
+
+cs_failed:
+       cs_error(handle, fail_fn, fail_rc);
+cs_release:
+       reader_release(link);
+       link->state &= ~DEV_CONFIG_PENDING;
+}
+
+static int reader_event(event_t event, int priority,
+                       event_callback_args_t *args)
+{
+       dev_link_t *link;
+       struct reader_dev *dev;
+       int devno;
+
+       link = args->client_data;
+       dev = link->priv;
+       DEBUGP(3, dev, "-> reader_event\n");
+       for (devno = 0; devno < CM_MAX_DEV; devno++) {
+               if (dev_table[devno] == link)
+                       break;
+       }
+       if (devno == CM_MAX_DEV)
+               return CS_BAD_ADAPTER;
+
+       switch (event) {
+               case CS_EVENT_CARD_INSERTION:
+                       DEBUGP(5, dev, "CS_EVENT_CARD_INSERTION\n");
+                       link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
+                       reader_config(link, devno);
+                       break;
+               case CS_EVENT_CARD_REMOVAL:
+                       DEBUGP(5, dev, "CS_EVENT_CARD_REMOVAL\n");
+                       link->state &= ~DEV_PRESENT;
+                       break;
+               case CS_EVENT_PM_SUSPEND:
+                       DEBUGP(5, dev, "CS_EVENT_PM_SUSPEND "
+                             "(fall-through to CS_EVENT_RESET_PHYSICAL)\n");
+                       link->state |= DEV_SUSPEND;
+
+               case CS_EVENT_RESET_PHYSICAL:
+                       DEBUGP(5, dev, "CS_EVENT_RESET_PHYSICAL\n");
+                       if (link->state & DEV_CONFIG) {
+                               DEBUGP(5, dev, "ReleaseConfiguration\n");
+                               pcmcia_release_configuration(link->handle);
+                       }
+                       break;
+               case CS_EVENT_PM_RESUME:
+                       DEBUGP(5, dev, "CS_EVENT_PM_RESUME "
+                             "(fall-through to CS_EVENT_CARD_RESET)\n");
+                       link->state &= ~DEV_SUSPEND;
+
+               case CS_EVENT_CARD_RESET:
+                       DEBUGP(5, dev, "CS_EVENT_CARD_RESET\n");
+                       if ((link->state & DEV_CONFIG)) {
+                               DEBUGP(5, dev, "RequestConfiguration\n");
+                               pcmcia_request_configuration(link->handle,
+                                                            &link->conf);
+                       }
+                       break;
+               default:
+                       DEBUGP(5, dev, "reader_event: unknown event %.2x\n",
+                              event);
+                       break;
+       }
+       DEBUGP(3, dev, "<- reader_event\n");
+       return CS_SUCCESS;
+}
+
+static void reader_release(dev_link_t *link)
+{
+       cm4040_reader_release(link->priv);
+       pcmcia_release_configuration(link->handle);
+       pcmcia_release_io(link->handle, &link->io);
+}
+
+static dev_link_t *reader_attach(void)
+{
+       struct reader_dev *dev;
+       dev_link_t *link;
+       client_reg_t client_reg;
+       int i;
+
+       for (i = 0; i < CM_MAX_DEV; i++) {
+               if (dev_table[i] == NULL)
+                       break;
+       }
+
+       if (i == CM_MAX_DEV)
+               return NULL;
+
+       dev = kzalloc(sizeof(struct reader_dev), GFP_KERNEL);
+       if (dev == NULL)
+               return NULL;
+
+       dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT;
+       dev->buffer_status = 0;
+
+       link = &dev->link;
+       link->priv = dev;
+
+       link->conf.IntType = INT_MEMORY_AND_IO;
+       dev_table[i] = link;
+
+       client_reg.dev_info = &dev_info;
+       client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE;
+       client_reg.EventMask=
+               CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
+               CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
+               CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
+       client_reg.Version = 0x0210;
+       client_reg.event_callback_args.client_data = link;
+       i = pcmcia_register_client(&link->handle, &client_reg);
+       if (i) {
+               cs_error(link->handle, RegisterClient, i);
+               reader_detach(link);
+               return NULL;
+       }
+       init_waitqueue_head(&dev->devq);
+       init_waitqueue_head(&dev->poll_wait);
+       init_waitqueue_head(&dev->read_wait);
+       init_waitqueue_head(&dev->write_wait);
+       init_timer(&dev->poll_timer);
+       dev->poll_timer.function = &cm4040_do_poll;
+
+       return link;
+}
+
+static void reader_detach_by_devno(int devno, dev_link_t *link)
+{
+       struct reader_dev *dev = link->priv;
+
+       if (link->state & DEV_CONFIG) {
+               DEBUGP(5, dev, "device still configured (try to release it)\n");
+               reader_release(link);
+       }
+
+       pcmcia_deregister_client(link->handle);
+       dev_table[devno] = NULL;
+       DEBUGP(5, dev, "freeing dev=%p\n", dev);
+       cm4040_stop_poll(dev);
+       kfree(dev);
+       return;
+}
+
+static void reader_detach(dev_link_t *link)
+{
+       int i;
+
+       /* find device */
+       for (i = 0; i < CM_MAX_DEV; i++) {
+               if (dev_table[i] == link)
+                       break;
+       }
+       if (i == CM_MAX_DEV)
+               return;
+
+       reader_detach_by_devno(i, link);
+       return;
+}
+
+static struct file_operations reader_fops = {
+       .owner          = THIS_MODULE,
+       .read           = cm4040_read,
+       .write          = cm4040_write,
+       .open           = cm4040_open,
+       .release        = cm4040_close,
+       .poll           = cm4040_poll,
+};
+
+static struct pcmcia_device_id cm4040_ids[] = {
+       PCMCIA_DEVICE_MANF_CARD(0x0223, 0x0200),
+       PCMCIA_DEVICE_PROD_ID12("OMNIKEY", "CardMan 4040",
+                               0xE32CDD8C, 0x8F23318B),
+       PCMCIA_DEVICE_NULL,
+};
+MODULE_DEVICE_TABLE(pcmcia, cm4040_ids);
+
+static struct pcmcia_driver reader_driver = {
+       .owner          = THIS_MODULE,
+       .drv            = {
+               .name   = "cm4040_cs",
+       },
+       .attach         = reader_attach,
+       .detach         = reader_detach,
+       .event          = reader_event,
+       .id_table       = cm4040_ids,
+};
+
+static int __init cm4040_init(void)
+{
+       printk(KERN_INFO "%s\n", version);
+       pcmcia_register_driver(&reader_driver);
+       major = register_chrdev(0, DEVICE_NAME, &reader_fops);
+       if (major < 0) {
+               printk(KERN_WARNING MODULE_NAME
+                       ": could not get major number\n");
+               return -1;
+       }
+       return 0;
+}
+
+static void __exit cm4040_exit(void)
+{
+       int i;
+
+       printk(KERN_INFO MODULE_NAME ": unloading\n");
+       pcmcia_unregister_driver(&reader_driver);
+       for (i = 0; i < CM_MAX_DEV; i++) {
+               if (dev_table[i])
+                       reader_detach_by_devno(i, dev_table[i]);
+       }
+       unregister_chrdev(major, DEVICE_NAME);
+}
+
+module_init(cm4040_init);
+module_exit(cm4040_exit);
+MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/char/pcmcia/cm4040_cs.h b/drivers/char/pcmcia/cm4040_cs.h
new file mode 100644 (file)
index 0000000..9a8b805
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef        _CM4040_H_
+#define        _CM4040_H_
+
+#define        CM_MAX_DEV              4
+
+#define        DEVICE_NAME             "cmx"
+#define        MODULE_NAME             "cm4040_cs"
+
+#define REG_OFFSET_BULK_OUT      0
+#define REG_OFFSET_BULK_IN       0
+#define REG_OFFSET_BUFFER_STATUS 1
+#define REG_OFFSET_SYNC_CONTROL  2
+
+#define BSR_BULK_IN_FULL  0x02
+#define BSR_BULK_OUT_FULL 0x01
+
+#define SCR_HOST_TO_READER_START 0x80
+#define SCR_ABORT                0x40
+#define SCR_EN_NOTIFY            0x20
+#define SCR_ACK_NOTIFY           0x10
+#define SCR_READER_TO_HOST_DONE  0x08
+#define SCR_HOST_TO_READER_DONE  0x04
+#define SCR_PULSE_INTERRUPT      0x02
+#define SCR_POWER_DOWN           0x01
+
+
+#define  CMD_PC_TO_RDR_ICCPOWERON       0x62
+#define  CMD_PC_TO_RDR_GETSLOTSTATUS    0x65
+#define  CMD_PC_TO_RDR_ICCPOWEROFF      0x63
+#define  CMD_PC_TO_RDR_SECURE           0x69
+#define  CMD_PC_TO_RDR_GETPARAMETERS    0x6C
+#define  CMD_PC_TO_RDR_RESETPARAMETERS  0x6D
+#define  CMD_PC_TO_RDR_SETPARAMETERS    0x61
+#define  CMD_PC_TO_RDR_XFRBLOCK         0x6F
+#define  CMD_PC_TO_RDR_ESCAPE           0x6B
+#define  CMD_PC_TO_RDR_ICCCLOCK         0x6E
+#define  CMD_PC_TO_RDR_TEST_SECURE      0x74
+#define  CMD_PC_TO_RDR_OK_SECURE        0x89
+
+
+#define  CMD_RDR_TO_PC_SLOTSTATUS         0x81
+#define  CMD_RDR_TO_PC_DATABLOCK          0x80
+#define  CMD_RDR_TO_PC_PARAMETERS         0x82
+#define  CMD_RDR_TO_PC_ESCAPE             0x83
+#define  CMD_RDR_TO_PC_OK_SECURE          0x89
+
+#endif /* _CM4040_H_ */
index 82c6abde68dff226982f198ad9000bdd31dc30fe..62aa0e534a6d7dbe30c07b72e338050be2a25225 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * linux/drivers/char/synclink.c
  *
- * $Id: synclink.c,v 4.37 2005/09/07 13:13:19 paulkf Exp $
+ * $Id: synclink.c,v 4.38 2005/11/07 16:30:34 paulkf Exp $
  *
  * Device driver for Microgate SyncLink ISA and PCI
  * high speed multiprotocol serial adapters.
 #include <linux/termios.h>
 #include <linux/workqueue.h>
 #include <linux/hdlc.h>
+#include <linux/dma-mapping.h>
 
 #ifdef CONFIG_HDLC_MODULE
 #define CONFIG_HDLC 1
@@ -148,6 +149,7 @@ typedef struct _DMABUFFERENTRY
        u32 link;       /* 32-bit flat link to next buffer entry */
        char *virt_addr;        /* virtual address of data buffer */
        u32 phys_entry; /* physical address of this buffer entry */
+       dma_addr_t dma_addr;
 } DMABUFFERENTRY, *DMAPBUFFERENTRY;
 
 /* The queue of BH actions to be performed */
@@ -233,7 +235,8 @@ struct mgsl_struct {
        int ri_chkcount;
 
        char *buffer_list;              /* virtual address of Rx & Tx buffer lists */
-       unsigned long buffer_list_phys;
+       u32 buffer_list_phys;
+       dma_addr_t buffer_list_dma_addr;
 
        unsigned int rx_buffer_count;   /* count of total allocated Rx buffers */
        DMABUFFERENTRY *rx_buffer_list; /* list of receive buffer entries */
@@ -896,7 +899,7 @@ module_param_array(txdmabufs, int, NULL, 0);
 module_param_array(txholdbufs, int, NULL, 0);
 
 static char *driver_name = "SyncLink serial driver";
-static char *driver_version = "$Revision: 4.37 $";
+static char *driver_version = "$Revision: 4.38 $";
 
 static int synclink_init_one (struct pci_dev *dev,
                                     const struct pci_device_id *ent);
@@ -3811,11 +3814,10 @@ static int mgsl_alloc_buffer_list_memory( struct mgsl_struct *info )
                /* inspect portions of the buffer while other portions are being */
                /* updated by the adapter using Bus Master DMA. */
 
-               info->buffer_list = kmalloc(BUFFERLISTSIZE, GFP_KERNEL | GFP_DMA);
-               if ( info->buffer_list == NULL )
+               info->buffer_list = dma_alloc_coherent(NULL, BUFFERLISTSIZE, &info->buffer_list_dma_addr, GFP_KERNEL);
+               if (info->buffer_list == NULL)
                        return -ENOMEM;
-                       
-               info->buffer_list_phys = isa_virt_to_bus(info->buffer_list);
+               info->buffer_list_phys = (u32)(info->buffer_list_dma_addr);
        }
 
        /* We got the memory for the buffer entry lists. */
@@ -3882,8 +3884,8 @@ static int mgsl_alloc_buffer_list_memory( struct mgsl_struct *info )
  */
 static void mgsl_free_buffer_list_memory( struct mgsl_struct *info )
 {
-       if ( info->buffer_list && info->bus_type != MGSL_BUS_TYPE_PCI )
-               kfree(info->buffer_list);
+       if (info->buffer_list && info->bus_type != MGSL_BUS_TYPE_PCI)
+               dma_free_coherent(NULL, BUFFERLISTSIZE, info->buffer_list, info->buffer_list_dma_addr);
                
        info->buffer_list = NULL;
        info->rx_buffer_list = NULL;
@@ -3910,7 +3912,7 @@ static void mgsl_free_buffer_list_memory( struct mgsl_struct *info )
 static int mgsl_alloc_frame_memory(struct mgsl_struct *info,DMABUFFERENTRY *BufferList,int Buffercount)
 {
        int i;
-       unsigned long phys_addr;
+       u32 phys_addr;
 
        /* Allocate page sized buffers for the receive buffer list */
 
@@ -3922,11 +3924,10 @@ static int mgsl_alloc_frame_memory(struct mgsl_struct *info,DMABUFFERENTRY *Buff
                        info->last_mem_alloc += DMABUFFERSIZE;
                } else {
                        /* ISA adapter uses system memory. */
-                       BufferList[i].virt_addr = 
-                               kmalloc(DMABUFFERSIZE, GFP_KERNEL | GFP_DMA);
-                       if ( BufferList[i].virt_addr == NULL )
+                       BufferList[i].virt_addr = dma_alloc_coherent(NULL, DMABUFFERSIZE, &BufferList[i].dma_addr, GFP_KERNEL);
+                       if (BufferList[i].virt_addr == NULL)
                                return -ENOMEM;
-                       phys_addr = isa_virt_to_bus(BufferList[i].virt_addr);
+                       phys_addr = (u32)(BufferList[i].dma_addr);
                }
                BufferList[i].phys_addr = phys_addr;
        }
@@ -3957,7 +3958,7 @@ static void mgsl_free_frame_memory(struct mgsl_struct *info, DMABUFFERENTRY *Buf
                for ( i = 0 ; i < Buffercount ; i++ ) {
                        if ( BufferList[i].virt_addr ) {
                                if ( info->bus_type != MGSL_BUS_TYPE_PCI )
-                                       kfree(BufferList[i].virt_addr);
+                                       dma_free_coherent(NULL, DMABUFFERSIZE, BufferList[i].virt_addr, BufferList[i].dma_addr);
                                BufferList[i].virt_addr = NULL;
                        }
                }
index 303f15880466293f967a94ea5267262039006e2e..0b283d246730b051afcc2c4d1ce76f5e1f0deb78 100644 (file)
@@ -43,6 +43,13 @@ static void user_reader_timeout(unsigned long ptr)
 {
        struct tpm_chip *chip = (struct tpm_chip *) ptr;
 
+       schedule_work(&chip->work);
+}
+
+static void timeout_work(void * ptr)
+{
+       struct tpm_chip *chip = ptr;
+
        down(&chip->buffer_mutex);
        atomic_set(&chip->data_pending, 0);
        memset(chip->data_buffer, 0, TPM_BUFSIZE);
@@ -428,8 +435,7 @@ ssize_t tpm_read(struct file * file, char __user *buf,
                        ret_size = size;
 
                down(&chip->buffer_mutex);
-               if (copy_to_user
-                   ((void __user *) buf, chip->data_buffer, ret_size))
+               if (copy_to_user(buf, chip->data_buffer, ret_size))
                        ret_size = -EFAULT;
                up(&chip->buffer_mutex);
        }
@@ -460,7 +466,7 @@ void tpm_remove_hardware(struct device *dev)
        sysfs_remove_group(&dev->kobj, chip->vendor->attr_group);
 
        dev_mask[chip->dev_num / TPM_NUM_MASK_ENTRIES ] &=
-               !(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES));
+               ~(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES));
 
        kfree(chip);
 
@@ -528,6 +534,8 @@ int tpm_register_hardware(struct device *dev, struct tpm_vendor_specific *entry)
        init_MUTEX(&chip->tpm_mutex);
        INIT_LIST_HEAD(&chip->list);
 
+       INIT_WORK(&chip->work, timeout_work, chip);
+
        init_timer(&chip->user_read_timer);
        chip->user_read_timer.function = user_reader_timeout;
        chip->user_read_timer.data = (unsigned long) chip;
index 9293bcc4dc624cb5a61df076bcda36dbaa1f88fa..159882ca69dd03bdd18ce991b9b01428c48ee4be 100644 (file)
@@ -50,7 +50,11 @@ struct tpm_vendor_specific {
        u8 req_complete_mask;
        u8 req_complete_val;
        u8 req_canceled;
-       u16 base;               /* TPM base address */
+       void __iomem *iobase;           /* ioremapped address */
+       unsigned long base;             /* TPM base address */
+
+       int region_size;
+       int have_region;
 
        int (*recv) (struct tpm_chip *, u8 *, size_t);
        int (*send) (struct tpm_chip *, u8 *, size_t);
@@ -73,6 +77,7 @@ struct tpm_chip {
        struct semaphore buffer_mutex;
 
        struct timer_list user_read_timer;      /* user needs to claim result */
+       struct work_struct work;
        struct semaphore tpm_mutex;     /* tpm is processing */
 
        struct tpm_vendor_specific *vendor;
index 32e01450c4253bd4b5f9e3ddb1d3ce21d3f8752c..deb4b5c80914a0311ea613b87ba20b32a36071d3 100644 (file)
  * 
  */
 
-#include <linux/platform_device.h>
 #include "tpm.h"
-
-/* Atmel definitions */
-enum tpm_atmel_addr {
-       TPM_ATMEL_BASE_ADDR_LO = 0x08,
-       TPM_ATMEL_BASE_ADDR_HI = 0x09
-};
+#include "tpm_atmel.h"
 
 /* write status bits */
 enum tpm_atmel_write_status {
@@ -53,13 +47,13 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
                return -EIO;
 
        for (i = 0; i < 6; i++) {
-               status = inb(chip->vendor->base + 1);
+               status = atmel_getb(chip, 1);
                if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
                        dev_err(chip->dev,
                                "error reading header\n");
                        return -EIO;
                }
-               *buf++ = inb(chip->vendor->base);
+               *buf++ = atmel_getb(chip, 0);
        }
 
        /* size of the data received */
@@ -70,7 +64,7 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
                dev_err(chip->dev,
                        "Recv size(%d) less than available space\n", size);
                for (; i < size; i++) { /* clear the waiting data anyway */
-                       status = inb(chip->vendor->base + 1);
+                       status = atmel_getb(chip, 1);
                        if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
                                dev_err(chip->dev,
                                        "error reading data\n");
@@ -82,17 +76,17 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
 
        /* read all the data available */
        for (; i < size; i++) {
-               status = inb(chip->vendor->base + 1);
+               status = atmel_getb(chip, 1);
                if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
                        dev_err(chip->dev,
                                "error reading data\n");
                        return -EIO;
                }
-               *buf++ = inb(chip->vendor->base);
+               *buf++ = atmel_getb(chip, 0);
        }
 
        /* make sure data available is gone */
-       status = inb(chip->vendor->base + 1);
+       status = atmel_getb(chip, 1);
        if (status & ATML_STATUS_DATA_AVAIL) {
                dev_err(chip->dev, "data available is stuck\n");
                return -EIO;
@@ -108,7 +102,7 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
        dev_dbg(chip->dev, "tpm_atml_send:\n");
        for (i = 0; i < count; i++) {
                dev_dbg(chip->dev, "%d 0x%x(%d)\n",  i, buf[i], buf[i]);
-               outb(buf[i], chip->vendor->base);
+               atmel_putb(buf[i], chip, 0);
        }
 
        return count;
@@ -116,12 +110,12 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
 
 static void tpm_atml_cancel(struct tpm_chip *chip)
 {
-       outb(ATML_STATUS_ABORT, chip->vendor->base + 1);
+       atmel_putb(ATML_STATUS_ABORT, chip, 1);
 }
 
 static u8 tpm_atml_status(struct tpm_chip *chip)
 {
-       return inb(chip->vendor->base + 1);
+       return atmel_getb(chip, 1);
 }
 
 static struct file_operations atmel_ops = {
@@ -162,12 +156,16 @@ static struct tpm_vendor_specific tpm_atmel = {
 
 static struct platform_device *pdev;
 
-static void __devexit tpm_atml_remove(struct device *dev)
+static void atml_plat_remove(void)
 {
-       struct tpm_chip *chip = dev_get_drvdata(dev);
+       struct tpm_chip *chip = dev_get_drvdata(&pdev->dev);
+
        if (chip) {
-               release_region(chip->vendor->base, 2);
+               if (chip->vendor->have_region)
+                       atmel_release_region(chip->vendor->base, chip->vendor->region_size);
+               atmel_put_base_addr(chip->vendor);
                tpm_remove_hardware(chip->dev);
+               platform_device_unregister(pdev);
        }
 }
 
@@ -182,72 +180,40 @@ static struct device_driver atml_drv = {
 static int __init init_atmel(void)
 {
        int rc = 0;
-       int lo, hi;
 
        driver_register(&atml_drv);
 
-       lo = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_LO);
-       hi = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_HI);
-
-       tpm_atmel.base = (hi<<8)|lo;
-
-       /* verify that it is an Atmel part */
-       if (tpm_read_index(TPM_ADDR, 4) != 'A' || tpm_read_index(TPM_ADDR, 5) != 'T'
-           || tpm_read_index(TPM_ADDR, 6) != 'M' || tpm_read_index(TPM_ADDR, 7) != 'L') {
-               return -ENODEV;
-       }
-
-       /* verify chip version number is 1.1 */
-       if (    (tpm_read_index(TPM_ADDR, 0x00) != 0x01) ||
-               (tpm_read_index(TPM_ADDR, 0x01) != 0x01 ))
-               return -ENODEV;
-
-       pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL);
-       if ( !pdev )
-               return -ENOMEM;
-
-       pdev->name = "tpm_atmel0";
-       pdev->id = -1;
-       pdev->num_resources = 0;
-       pdev->dev.release = tpm_atml_remove;
-       pdev->dev.driver = &atml_drv;
-
-       if ((rc = platform_device_register(pdev)) < 0) {
-               kfree(pdev);
-               pdev = NULL;
-               return rc;
+       if (atmel_get_base_addr(&tpm_atmel) != 0) {
+               rc = -ENODEV;
+               goto err_unreg_drv;
        }
 
-       if (request_region(tpm_atmel.base, 2, "tpm_atmel0") == NULL ) {
-               platform_device_unregister(pdev);
-               kfree(pdev);
-               pdev = NULL;
-               return -EBUSY;
-       }
+       tpm_atmel.have_region = (atmel_request_region( tpm_atmel.base, tpm_atmel.region_size, "tpm_atmel0") == NULL) ? 0 : 1;
 
-       if ((rc = tpm_register_hardware(&pdev->dev, &tpm_atmel)) < 0) {
-               release_region(tpm_atmel.base, 2);
-               platform_device_unregister(pdev);
-               kfree(pdev);
-               pdev = NULL;
-               return rc;
+       if (IS_ERR(pdev = platform_device_register_simple("tpm_atmel", -1, NULL, 0 ))) {
+               rc = PTR_ERR(pdev);
+               goto err_rel_reg;
        }
 
-       dev_info(&pdev->dev, "Atmel TPM 1.1, Base Address: 0x%x\n",
-                       tpm_atmel.base);
+       if ((rc = tpm_register_hardware(&pdev->dev, &tpm_atmel)) < 0)
+               goto err_unreg_dev;
        return 0;
+
+err_unreg_dev:
+       platform_device_unregister(pdev);
+err_rel_reg:
+       if (tpm_atmel.have_region)
+               atmel_release_region(tpm_atmel.base, tpm_atmel.region_size);
+       atmel_put_base_addr(&tpm_atmel);
+err_unreg_drv:
+       driver_unregister(&atml_drv);
+       return rc;
 }
 
 static void __exit cleanup_atmel(void)
 {
-       if (pdev) {
-               tpm_atml_remove(&pdev->dev);
-               platform_device_unregister(pdev);
-               kfree(pdev);
-               pdev = NULL;
-       }
-
        driver_unregister(&atml_drv);
+       atml_plat_remove();
 }
 
 module_init(init_atmel);
diff --git a/drivers/char/tpm/tpm_atmel.h b/drivers/char/tpm/tpm_atmel.h
new file mode 100644 (file)
index 0000000..3c5b9a8
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2005 IBM Corporation
+ *
+ * Authors:
+ * Kylene Hall <kjhall@us.ibm.com>
+ *
+ * Maintained by: <tpmdd_devel@lists.sourceforge.net>
+ *
+ * Device driver for TCG/TCPA TPM (trusted platform module).
+ * Specifications at www.trustedcomputinggroup.org
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, version 2 of the
+ * License.
+ *
+ * These difference are required on power because the device must be
+ * discovered through the device tree and iomap must be used to get
+ * around the need for holes in the io_page_mask.  This does not happen
+ * automatically because the tpm is not a normal pci device and lives
+ * under the root node.
+ *
+ */
+
+#ifdef CONFIG_PPC64
+#define atmel_getb(chip, offset) readb(chip->vendor->iobase + offset);
+#define atmel_putb(val, chip, offset) writeb(val, chip->vendor->iobase + offset)
+#define atmel_request_region request_mem_region
+#define atmel_release_region release_mem_region
+static inline void atmel_put_base_addr(struct tpm_vendor_specific *vendor)
+{
+       iounmap(vendor->iobase);
+}
+
+static int atmel_get_base_addr(struct tpm_vendor_specific *vendor)
+{
+       struct device_node *dn;
+       unsigned long address, size;
+       unsigned int *reg;
+       int reglen;
+       int naddrc;
+       int nsizec;
+
+       dn = of_find_node_by_name(NULL, "tpm");
+
+       if (!dn)
+               return 1;
+
+       if (!device_is_compatible(dn, "AT97SC3201")) {
+               of_node_put(dn);
+               return 1;
+       }
+
+       reg = (unsigned int *) get_property(dn, "reg", &reglen);
+       naddrc = prom_n_addr_cells(dn);
+       nsizec = prom_n_size_cells(dn);
+
+       of_node_put(dn);
+
+
+       if (naddrc == 2)
+               address = ((unsigned long) reg[0] << 32) | reg[1];
+       else
+               address = reg[0];
+
+       if (nsizec == 2)
+               size =
+                   ((unsigned long) reg[naddrc] << 32) | reg[naddrc + 1];
+       else
+               size = reg[naddrc];
+
+       vendor->base = address;
+       vendor->region_size = size;
+       vendor->iobase = ioremap(address, size);
+       return 0;
+}
+#else
+#define atmel_getb(chip, offset) inb(chip->vendor->base + offset)
+#define atmel_putb(val, chip, offset) outb(val, chip->vendor->base + offset)
+#define atmel_request_region request_region
+#define atmel_release_region release_region
+/* Atmel definitions */
+enum tpm_atmel_addr {
+       TPM_ATMEL_BASE_ADDR_LO = 0x08,
+       TPM_ATMEL_BASE_ADDR_HI = 0x09
+};
+
+/* Verify this is a 1.1 Atmel TPM */
+static int atmel_verify_tpm11(void)
+{
+
+       /* verify that it is an Atmel part */
+       if (tpm_read_index(TPM_ADDR, 4) != 'A' ||
+           tpm_read_index(TPM_ADDR, 5) != 'T' ||
+           tpm_read_index(TPM_ADDR, 6) != 'M' ||
+           tpm_read_index(TPM_ADDR, 7) != 'L')
+               return 1;
+
+       /* query chip for its version number */
+       if (tpm_read_index(TPM_ADDR, 0x00) != 1 ||
+           tpm_read_index(TPM_ADDR, 0x01) != 1)
+               return 1;
+
+       /* This is an atmel supported part */
+       return 0;
+}
+
+static inline void atmel_put_base_addr(struct tpm_vendor_specific *vendor)
+{
+}
+
+/* Determine where to talk to device */
+static unsigned long atmel_get_base_addr(struct tpm_vendor_specific
+                                        *vendor)
+{
+       int lo, hi;
+
+       if (atmel_verify_tpm11() != 0)
+               return 1;
+
+       lo = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_LO);
+       hi = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_HI);
+
+       vendor->base = (hi << 8) | lo;
+       vendor->region_size = 2;
+
+       return 0;
+}
+#endif
index abc30cca664544e8c9f74aa92063527253f8bd7f..65830ec71042f0a2fd64666775138ce491bf3066 100644 (file)
@@ -4,7 +4,7 @@
  * Watchdog timer for PowerPC Book-E systems
  *
  * Author: Matthew McClintock
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2005 Freescale Semiconductor Inc.
  *
index b3e65a65d202c268a276657c0451ca7a37d565bf..136911a86e84f67c3a0509a4b3bda6c8b5794029 100644 (file)
@@ -1667,11 +1667,16 @@ static struct macio_driver pmac_ide_macio_driver =
 };
 
 static struct pci_device_id pmac_ide_pci_match[] = {
-       { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_ATA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-       { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_IPID_ATA100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-       { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_K2_ATA100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+       { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_ATA,
+         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+       { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_IPID_ATA100,
+         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+       { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_K2_ATA100,
+         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
        { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_SH_ATA,
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+       { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_IPID2_ATA,
+         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
 };
 
 static struct pci_driver pmac_ide_pci_driver = {
index 4b71fd6f7aed15b5ecf0382fcd8e622c2176d3c7..7972c73bc14eba1e1c3560a2c072cb28d917e624 100644 (file)
@@ -126,6 +126,66 @@ IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
 };
 EXPORT_SYMBOL_GPL(ir_codes_winfast);
 
+IR_KEYTAB_TYPE ir_codes_pinnacle[IR_KEYTAB_SIZE] = {
+       [ 0x59 ] = KEY_MUTE,
+       [ 0x4a ] = KEY_POWER,
+
+       [ 0x18 ] = KEY_TEXT,
+       [ 0x26 ] = KEY_TV,
+       [ 0x3d ] = KEY_PRINT,
+
+       [ 0x48 ] = KEY_RED,
+       [ 0x04 ] = KEY_GREEN,
+       [ 0x11 ] = KEY_YELLOW,
+       [ 0x00 ] = KEY_BLUE,
+
+       [ 0x2d ] = KEY_VOLUMEUP,
+       [ 0x1e ] = KEY_VOLUMEDOWN,
+
+       [ 0x49 ] = KEY_MENU,
+
+       [ 0x16 ] = KEY_CHANNELUP,
+       [ 0x17 ] = KEY_CHANNELDOWN,
+
+       [ 0x20 ] = KEY_UP,
+       [ 0x21 ] = KEY_DOWN,
+       [ 0x22 ] = KEY_LEFT,
+       [ 0x23 ] = KEY_RIGHT,
+       [ 0x0d ] = KEY_SELECT,
+
+
+
+       [ 0x08 ] = KEY_BACK,
+       [ 0x07 ] = KEY_REFRESH,
+
+       [ 0x2f ] = KEY_ZOOM,
+       [ 0x29 ] = KEY_RECORD,
+
+       [ 0x4b ] = KEY_PAUSE,
+       [ 0x4d ] = KEY_REWIND,
+       [ 0x2e ] = KEY_PLAY,
+       [ 0x4e ] = KEY_FORWARD,
+       [ 0x53 ] = KEY_PREVIOUS,
+       [ 0x4c ] = KEY_STOP,
+       [ 0x54 ] = KEY_NEXT,
+
+       [ 0x69 ] = KEY_KP0,
+       [ 0x6a ] = KEY_KP1,
+       [ 0x6b ] = KEY_KP2,
+       [ 0x6c ] = KEY_KP3,
+       [ 0x6d ] = KEY_KP4,
+       [ 0x6e ] = KEY_KP5,
+       [ 0x6f ] = KEY_KP6,
+       [ 0x70 ] = KEY_KP7,
+       [ 0x71 ] = KEY_KP8,
+       [ 0x72 ] = KEY_KP9,
+
+       [ 0x74 ] = KEY_CHANNEL,
+       [ 0x0a ] = KEY_BACKSPACE,
+};
+
+EXPORT_SYMBOL_GPL(ir_codes_pinnacle);
+
 /* empty keytable, can be used as placeholder for not-yet created keytables */
 IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE] = {
        [ 42 ] = KEY_COFFEE,
index d7417eac2abad01c54f16bcfa3f2e3af28d89599..2583a865a58e4c7aea3d09b01f832e30689d29ad 100644 (file)
@@ -7,6 +7,7 @@ config DVB_B2C2_FLEXCOP
        select DVB_NXT2002
        select DVB_STV0297
        select DVB_BCM3510
+       select DVB_LGDT330X
        help
          Support for the digital TV receiver chip made by B2C2 Inc. included in
          Technisats PCI cards and USB boxes.
index 199b01188858325e169adb8f9a3e5caa6fc509bf..1a3b3c7e5e99699815245de164016959b549c6ed 100644 (file)
@@ -333,4 +333,18 @@ config VIDEO_M32R_AR_M64278
          Say Y here to use the Renesas M64278E-800 camera module,
          which supports VGA(640x480 pixcels) size of images.
 
+config VIDEO_AUDIO_DECODER
+       tristate "Add support for additional audio chipsets"
+       depends on VIDEO_DEV && I2C && EXPERIMENTAL
+       ---help---
+         Say Y here to compile drivers for WM8775 and CS53L32A audio
+         decoders.
+
+config VIDEO_DECODER
+       tristate "Add support for additional video chipsets"
+       depends on VIDEO_DEV && I2C && EXPERIMENTAL
+       ---help---
+         Say Y here to compile drivers for SAA7115, SAA7127 and CX25840
+         video  decoders.
+
 endmenu
index 3ac465992400b12ab438ffca5306d59c73fbca65..82060f9909d89db008fa0c5c48dc32b46d5b0cc3 100644 (file)
@@ -36,10 +36,11 @@ obj-$(CONFIG_VIDEO_CPIA) += cpia.o
 obj-$(CONFIG_VIDEO_CPIA_PP) += cpia_pp.o
 obj-$(CONFIG_VIDEO_CPIA_USB) += cpia_usb.o
 obj-$(CONFIG_VIDEO_MEYE) += meye.o
-obj-$(CONFIG_VIDEO_SAA7134) += saa7134/
+obj-$(CONFIG_VIDEO_SAA7134) += ir-kbd-i2c.o saa7134/
 obj-$(CONFIG_VIDEO_CX88) += cx88/
 obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
 obj-$(CONFIG_VIDEO_EM28XX) += saa711x.o tvp5150.o
+obj-$(CONFIG_VIDEO_AUDIO_DECODER) += wm8775.o cs53l32a.o
 obj-$(CONFIG_VIDEO_OVCAMCHIP) += ovcamchip/
 obj-$(CONFIG_VIDEO_MXB) += saa7111.o tuner.o tda9840.o tea6415c.o tea6420.o mxb.o
 obj-$(CONFIG_VIDEO_HEXIUM_ORION) += hexium_orion.o
@@ -55,4 +56,6 @@ obj-$(CONFIG_VIDEO_TVEEPROM) += tveeprom.o
 
 obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o
 
+obj-$(CONFIG_VIDEO_DECODER)     += saa7115.o cx25840/ saa7127.o
+
 EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
index 3413bace443a6a06da2d0de1a4db9aad6c82d017..e31ebb11c4684e552adfd161234ccde8817539e3 100644 (file)
@@ -2133,7 +2133,10 @@ struct tvcard bttv_tvcards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .has_dvb        = 1,
+               .has_remote     = 1,
+               .gpiomask       = 0x1b,
                .no_gpioirq     = 1,
+               .any_irq                = 1,
        },
        [BTTV_BOARD_PV143] = {
                /* Jorge Boncompte - DTI2 <jorge@dti2.net> */
@@ -2796,7 +2799,24 @@ struct tvcard bttv_tvcards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
        },
-
+               /* ---- card 0x8e ---------------------------------- */
+       [BTTV_BOARD_SABRENT_TVFM] = {
+               .name           = "Sabrent TV-FM (bttv version)",
+               .video_inputs   = 3,
+               .audio_inputs   = 1,
+               .tuner          = 0,
+               .svhs           = 2,
+               .gpiomask       = 0x108007,
+               .muxsel         = { 2, 3, 1, 1},
+               .audiomux       = { 100000, 100002, 100002, 100000},
+               .no_msp34xx     = 1,
+               .no_tda9875     = 1,
+               .no_tda7432     = 1,
+               .pll            = PLL_28,
+               .tuner_type     = TUNER_TNF_5335MF,
+               .tuner_addr     = ADDR_UNSET,
+               .has_radio      = 1,
+       },
 };
 
 static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards);
@@ -3367,6 +3387,8 @@ void __devinit bttv_init_card2(struct bttv *btv)
                btv->has_remote=1;
        if (!bttv_tvcards[btv->c.type].no_gpioirq)
                btv->gpioirq=1;
+       if (bttv_tvcards[btv->c.type].any_irq)
+               btv->any_irq = 1;
        if (bttv_tvcards[btv->c.type].audio_hook)
                btv->audio_hook=bttv_tvcards[btv->c.type].audio_hook;
 
index 0005741d55141c0b1471cf8932845ac2e44990e9..709099f03bd20e5903a80e0f113f188824363330 100644 (file)
@@ -3667,6 +3667,10 @@ static irqreturn_t bttv_irq(int irq, void *dev_id, struct pt_regs * regs)
        int handled = 0;
 
        btv=(struct bttv *)dev_id;
+
+       if (btv->any_irq)
+               handled = bttv_any_irq(&btv->c);
+
        count=0;
        while (1) {
                /* get/clear interrupt status bits */
index 575ce8b8e714d995a92c2f6f0daa53c09e6b2dac..616a5b7e510c5c68c80ea845bf746d135c165dfa 100644 (file)
@@ -113,6 +113,24 @@ void bttv_gpio_irq(struct bttv_core *core)
        }
 }
 
+int bttv_any_irq(struct bttv_core *core)
+{
+       struct bttv_sub_driver *drv;
+       struct bttv_sub_device *dev;
+       struct list_head *item;
+       int handled = 0;
+
+       list_for_each(item,&core->subs) {
+               dev = list_entry(item,struct bttv_sub_device,list);
+               drv = to_bttv_sub_drv(dev->dev.driver);
+               if (drv && drv->any_irq) {
+                       if (drv->any_irq(dev))
+                               handled = 1;
+               }
+       }
+       return handled;
+}
+
 /* ----------------------------------------------------------------------- */
 /* external: sub-driver register/unregister                                */
 
index 124ea41dada4d204d7705b584e0c159166ed31f5..93298f06e0199b4776b010c93bbc8c58008c15d8 100644 (file)
 #define BTTV_BOARD_PV_M4900                0x8b
 #define BTTV_BOARD_OSPREY440               0x8c
 #define BTTV_BOARD_ASOUND_SKYEYE          0x8d
+#define BTTV_BOARD_SABRENT_TVFM           0x8e
 
 /* i2c address list */
 #define I2C_TSA5522        0xc2
@@ -234,6 +235,7 @@ struct tvcard
        unsigned int has_dvb:1;
        unsigned int has_remote:1;
        unsigned int no_gpioirq:1;
+       unsigned int any_irq:1;
 
        /* other settings */
        unsigned int pll;
@@ -333,6 +335,7 @@ struct bttv_sub_driver {
        struct device_driver   drv;
        char                   wanted[BUS_ID_SIZE];
        void                   (*gpio_irq)(struct bttv_sub_device *sub);
+       int                    (*any_irq)(struct bttv_sub_device *sub);
 };
 #define to_bttv_sub_drv(x) container_of((x), struct bttv_sub_driver, drv)
 
index 386f546f7d116b85578db858775c868c125f0d6e..3aa9c6e4fc33b678dd0997cd58d63a8d0dcd7a49 100644 (file)
@@ -208,6 +208,7 @@ extern struct bus_type bttv_sub_bus_type;
 int bttv_sub_add_device(struct bttv_core *core, char *name);
 int bttv_sub_del_devices(struct bttv_core *core);
 void bttv_gpio_irq(struct bttv_core *core);
+int bttv_any_irq(struct bttv_core *core);
 
 
 /* ---------------------------------------------------------- */
@@ -273,6 +274,7 @@ struct bttv {
        struct bttv_pll_info pll;
        int triton1;
        int gpioirq;
+       int any_irq;
        int use_i2c_hw;
 
        /* old gpio interface */
diff --git a/drivers/media/video/cx25840/Makefile b/drivers/media/video/cx25840/Makefile
new file mode 100644 (file)
index 0000000..543ebac
--- /dev/null
@@ -0,0 +1,6 @@
+cx25840-objs    := cx25840-core.o cx25840-audio.o cx25840-firmware.o \
+                  cx25840-vbi.o
+
+obj-$(CONFIG_VIDEO_DECODER) += cx25840.o
+
+EXTRA_CFLAGS += -I$(src)/..
diff --git a/drivers/media/video/cx25840/cx25840-audio.c b/drivers/media/video/cx25840/cx25840-audio.c
new file mode 100644 (file)
index 0000000..740908f
--- /dev/null
@@ -0,0 +1,368 @@
+/* cx25840 audio functions
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+
+#include <linux/videodev2.h>
+#include <linux/i2c.h>
+#include <media/audiochip.h>
+#include <media/v4l2-common.h>
+
+#include "cx25840.h"
+
+inline static int set_audclk_freq(struct i2c_client *client,
+                                enum v4l2_audio_clock_freq freq)
+{
+       struct cx25840_state *state = i2c_get_clientdata(client);
+
+       /* assert soft reset */
+       cx25840_and_or(client, 0x810, ~0x1, 0x01);
+
+       /* common for all inputs and rates */
+       /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x10 */
+       cx25840_write(client, 0x127, 0x50);
+
+       switch (state->audio_input) {
+       case AUDIO_TUNER:
+               switch (freq) {
+               case V4L2_AUDCLK_32_KHZ:
+                       /* VID_PLL and AUX_PLL */
+                       cx25840_write4(client, 0x108, 0x0f040610);
+
+                       /* AUX_PLL_FRAC */
+                       cx25840_write4(client, 0x110, 0xee39bb01);
+
+                       /* src3/4/6_ctl = 0x0801f77f */
+                       cx25840_write4(client, 0x900, 0x7ff70108);
+                       cx25840_write4(client, 0x904, 0x7ff70108);
+                       cx25840_write4(client, 0x90c, 0x7ff70108);
+                       break;
+
+               case V4L2_AUDCLK_441_KHZ:
+                       /* VID_PLL and AUX_PLL */
+                       cx25840_write4(client, 0x108, 0x0f040910);
+
+                       /* AUX_PLL_FRAC */
+                       cx25840_write4(client, 0x110, 0xd66bec00);
+
+                       /* src3/4/6_ctl = 0x08016d59 */
+                       cx25840_write4(client, 0x900, 0x596d0108);
+                       cx25840_write4(client, 0x904, 0x596d0108);
+                       cx25840_write4(client, 0x90c, 0x596d0108);
+                       break;
+
+               case V4L2_AUDCLK_48_KHZ:
+                       /* VID_PLL and AUX_PLL */
+                       cx25840_write4(client, 0x108, 0x0f040a10);
+
+                       /* AUX_PLL_FRAC */
+                       cx25840_write4(client, 0x110, 0xe5d69800);
+
+                       /* src3/4/6_ctl = 0x08014faa */
+                       cx25840_write4(client, 0x900, 0xaa4f0108);
+                       cx25840_write4(client, 0x904, 0xaa4f0108);
+                       cx25840_write4(client, 0x90c, 0xaa4f0108);
+                       break;
+               }
+               break;
+
+       case AUDIO_EXTERN_1:
+       case AUDIO_EXTERN_2:
+       case AUDIO_INTERN:
+       case AUDIO_RADIO:
+               switch (freq) {
+               case V4L2_AUDCLK_32_KHZ:
+                       /* VID_PLL and AUX_PLL */
+                       cx25840_write4(client, 0x108, 0x0f04081e);
+
+                       /* AUX_PLL_FRAC */
+                       cx25840_write4(client, 0x110, 0x69082a01);
+
+                       /* src1_ctl = 0x08010000 */
+                       cx25840_write4(client, 0x8f8, 0x00000108);
+
+                       /* src3/4/6_ctl = 0x08020000 */
+                       cx25840_write4(client, 0x900, 0x00000208);
+                       cx25840_write4(client, 0x904, 0x00000208);
+                       cx25840_write4(client, 0x90c, 0x00000208);
+
+                       /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x14 */
+                       cx25840_write(client, 0x127, 0x54);
+                       break;
+
+               case V4L2_AUDCLK_441_KHZ:
+                       /* VID_PLL and AUX_PLL */
+                       cx25840_write4(client, 0x108, 0x0f040918);
+
+                       /* AUX_PLL_FRAC */
+                       cx25840_write4(client, 0x110, 0xd66bec00);
+
+                       /* src1_ctl = 0x08010000 */
+                       cx25840_write4(client, 0x8f8, 0xcd600108);
+
+                       /* src3/4/6_ctl = 0x08020000 */
+                       cx25840_write4(client, 0x900, 0x85730108);
+                       cx25840_write4(client, 0x904, 0x85730108);
+                       cx25840_write4(client, 0x90c, 0x85730108);
+                       break;
+
+               case V4L2_AUDCLK_48_KHZ:
+                       /* VID_PLL and AUX_PLL */
+                       cx25840_write4(client, 0x108, 0x0f040a18);
+
+                       /* AUX_PLL_FRAC */
+                       cx25840_write4(client, 0x110, 0xe5d69800);
+
+                       /* src1_ctl = 0x08010000 */
+                       cx25840_write4(client, 0x8f8, 0x00800108);
+
+                       /* src3/4/6_ctl = 0x08020000 */
+                       cx25840_write4(client, 0x900, 0x55550108);
+                       cx25840_write4(client, 0x904, 0x55550108);
+                       cx25840_write4(client, 0x90c, 0x55550108);
+                       break;
+               }
+               break;
+       }
+
+       /* deassert soft reset */
+       cx25840_and_or(client, 0x810, ~0x1, 0x00);
+
+       state->audclk_freq = freq;
+
+       return 0;
+}
+
+static int set_input(struct i2c_client *client, int audio_input)
+{
+       struct cx25840_state *state = i2c_get_clientdata(client);
+
+       cx25840_dbg("set audio input (%d)\n", audio_input);
+
+       /* stop microcontroller */
+       cx25840_and_or(client, 0x803, ~0x10, 0);
+
+       /* Mute everything to prevent the PFFT! */
+       cx25840_write(client, 0x8d3, 0x1f);
+
+       switch (audio_input) {
+       case AUDIO_TUNER:
+               /* Set Path1 to Analog Demod Main Channel */
+               cx25840_write4(client, 0x8d0, 0x7038061f);
+
+               /* When the microcontroller detects the
+                * audio format, it will unmute the lines */
+               cx25840_and_or(client, 0x803, ~0x10, 0x10);
+               break;
+
+       case AUDIO_EXTERN_1:
+       case AUDIO_EXTERN_2:
+       case AUDIO_INTERN:
+       case AUDIO_RADIO:
+               /* Set Path1 to Serial Audio Input */
+               cx25840_write4(client, 0x8d0, 0x12100101);
+
+               /* The microcontroller should not be started for the
+                * non-tuner inputs: autodetection is specific for
+                * TV audio. */
+               break;
+
+       default:
+               cx25840_dbg("Invalid audio input selection %d\n", audio_input);
+               return -EINVAL;
+       }
+
+       state->audio_input = audio_input;
+
+       return set_audclk_freq(client, state->audclk_freq);
+}
+
+inline static int get_volume(struct i2c_client *client)
+{
+       /* Volume runs +18dB to -96dB in 1/2dB steps
+        * change to fit the msp3400 -114dB to +12dB range */
+
+       /* check PATH1_VOLUME */
+       int vol = 228 - cx25840_read(client, 0x8d4);
+       vol = (vol / 2) + 23;
+       return vol << 9;
+}
+
+inline static void set_volume(struct i2c_client *client, int volume)
+{
+       /* First convert the volume to msp3400 values (0-127) */
+       int vol = volume >> 9;
+       /* now scale it up to cx25840 values
+        * -114dB to -96dB maps to 0
+        * this should be 19, but in my testing that was 4dB too loud */
+       if (vol <= 23) {
+               vol = 0;
+       } else {
+               vol -= 23;
+       }
+
+       /* PATH1_VOLUME */
+       cx25840_write(client, 0x8d4, 228 - (vol * 2));
+}
+
+inline static int get_bass(struct i2c_client *client)
+{
+       /* bass is 49 steps +12dB to -12dB */
+
+       /* check PATH1_EQ_BASS_VOL */
+       int bass = cx25840_read(client, 0x8d9) & 0x3f;
+       bass = (((48 - bass) * 0xffff) + 47) / 48;
+       return bass;
+}
+
+inline static void set_bass(struct i2c_client *client, int bass)
+{
+       /* PATH1_EQ_BASS_VOL */
+       cx25840_and_or(client, 0x8d9, ~0x3f, 48 - (bass * 48 / 0xffff));
+}
+
+inline static int get_treble(struct i2c_client *client)
+{
+       /* treble is 49 steps +12dB to -12dB */
+
+       /* check PATH1_EQ_TREBLE_VOL */
+       int treble = cx25840_read(client, 0x8db) & 0x3f;
+       treble = (((48 - treble) * 0xffff) + 47) / 48;
+       return treble;
+}
+
+inline static void set_treble(struct i2c_client *client, int treble)
+{
+       /* PATH1_EQ_TREBLE_VOL */
+       cx25840_and_or(client, 0x8db, ~0x3f, 48 - (treble * 48 / 0xffff));
+}
+
+inline static int get_balance(struct i2c_client *client)
+{
+       /* balance is 7 bit, 0 to -96dB */
+
+       /* check PATH1_BAL_LEVEL */
+       int balance = cx25840_read(client, 0x8d5) & 0x7f;
+       /* check PATH1_BAL_LEFT */
+       if ((cx25840_read(client, 0x8d5) & 0x80) == 0)
+               balance = 0x80 - balance;
+       else
+               balance = 0x80 + balance;
+       return balance << 8;
+}
+
+inline static void set_balance(struct i2c_client *client, int balance)
+{
+       int bal = balance >> 8;
+       if (bal > 0x80) {
+               /* PATH1_BAL_LEFT */
+               cx25840_and_or(client, 0x8d5, 0x7f, 0x80);
+               /* PATH1_BAL_LEVEL */
+               cx25840_and_or(client, 0x8d5, ~0x7f, bal & 0x7f);
+       } else {
+               /* PATH1_BAL_LEFT */
+               cx25840_and_or(client, 0x8d5, 0x7f, 0x00);
+               /* PATH1_BAL_LEVEL */
+               cx25840_and_or(client, 0x8d5, ~0x7f, 0x80 - bal);
+       }
+}
+
+inline static int get_mute(struct i2c_client *client)
+{
+       /* check SRC1_MUTE_EN */
+       return cx25840_read(client, 0x8d3) & 0x2 ? 1 : 0;
+}
+
+inline static void set_mute(struct i2c_client *client, int mute)
+{
+       struct cx25840_state *state = i2c_get_clientdata(client);
+
+       if (state->audio_input == AUDIO_TUNER) {
+               /* Must turn off microcontroller in order to mute sound.
+                * Not sure if this is the best method, but it does work.
+                * If the microcontroller is running, then it will undo any
+                * changes to the mute register. */
+               if (mute) {
+                       /* disable microcontroller */
+                       cx25840_and_or(client, 0x803, ~0x10, 0x00);
+                       cx25840_write(client, 0x8d3, 0x1f);
+               } else {
+                       /* enable microcontroller */
+                       cx25840_and_or(client, 0x803, ~0x10, 0x10);
+               }
+       } else {
+               /* SRC1_MUTE_EN */
+               cx25840_and_or(client, 0x8d3, ~0x2, mute ? 0x02 : 0x00);
+       }
+}
+
+int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg)
+{
+       struct v4l2_control *ctrl = arg;
+
+       switch (cmd) {
+       case AUDC_SET_INPUT:
+               return set_input(client, *(int *)arg);
+       case VIDIOC_INT_AUDIO_CLOCK_FREQ:
+               return set_audclk_freq(client, *(enum v4l2_audio_clock_freq *)arg);
+       case VIDIOC_G_CTRL:
+               switch (ctrl->id) {
+               case V4L2_CID_AUDIO_VOLUME:
+                       ctrl->value = get_volume(client);
+                       break;
+               case V4L2_CID_AUDIO_BASS:
+                       ctrl->value = get_bass(client);
+                       break;
+               case V4L2_CID_AUDIO_TREBLE:
+                       ctrl->value = get_treble(client);
+                       break;
+               case V4L2_CID_AUDIO_BALANCE:
+                       ctrl->value = get_balance(client);
+                       break;
+               case V4L2_CID_AUDIO_MUTE:
+                       ctrl->value = get_mute(client);
+                       break;
+               default:
+                       return -EINVAL;
+               }
+               break;
+       case VIDIOC_S_CTRL:
+               switch (ctrl->id) {
+               case V4L2_CID_AUDIO_VOLUME:
+                       set_volume(client, ctrl->value);
+                       break;
+               case V4L2_CID_AUDIO_BASS:
+                       set_bass(client, ctrl->value);
+                       break;
+               case V4L2_CID_AUDIO_TREBLE:
+                       set_treble(client, ctrl->value);
+                       break;
+               case V4L2_CID_AUDIO_BALANCE:
+                       set_balance(client, ctrl->value);
+                       break;
+               case V4L2_CID_AUDIO_MUTE:
+                       set_mute(client, ctrl->value);
+                       break;
+               default:
+                       return -EINVAL;
+               }
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
new file mode 100644 (file)
index 0000000..f6afeec
--- /dev/null
@@ -0,0 +1,1020 @@
+/* cx25840 - Conexant CX25840 audio/video decoder driver
+ *
+ * Copyright (C) 2004 Ulf Eklund
+ *
+ * Based on the saa7115 driver and on the first verison of Chris Kennedy's
+ * cx25840 driver.
+ *
+ * Changes by Tyler Trafford <tatrafford@comcast.net>
+ *    - cleanup/rewrite for V4L2 API (2005)
+ *
+ * VBI support by Hans Verkuil <hverkuil@xs4all.nl>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/videodev2.h>
+#include <linux/i2c.h>
+#include <media/audiochip.h>
+#include <media/v4l2-common.h>
+
+#include "cx25840.h"
+
+MODULE_DESCRIPTION("Conexant CX25840 audio/video decoder driver");
+MODULE_AUTHOR("Ulf Eklund, Chris Kennedy, Hans Verkuil, Tyler Trafford");
+MODULE_LICENSE("GPL");
+
+static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END };
+
+
+int cx25840_debug = 0;
+
+module_param(cx25840_debug, bool, 0644);
+
+MODULE_PARM_DESC(cx25840_debug, "Debugging messages [0=Off (default) 1=On]");
+
+I2C_CLIENT_INSMOD;
+
+/* ----------------------------------------------------------------------- */
+
+int cx25840_write(struct i2c_client *client, u16 addr, u8 value)
+{
+       u8 buffer[3];
+       buffer[0] = addr >> 8;
+       buffer[1] = addr & 0xff;
+       buffer[2] = value;
+       return i2c_master_send(client, buffer, 3);
+}
+
+int cx25840_write4(struct i2c_client *client, u16 addr, u32 value)
+{
+       u8 buffer[6];
+       buffer[0] = addr >> 8;
+       buffer[1] = addr & 0xff;
+       buffer[2] = value >> 24;
+       buffer[3] = (value >> 16) & 0xff;
+       buffer[4] = (value >> 8) & 0xff;
+       buffer[5] = value & 0xff;
+       return i2c_master_send(client, buffer, 6);
+}
+
+u8 cx25840_read(struct i2c_client * client, u16 addr)
+{
+       u8 buffer[2];
+       buffer[0] = addr >> 8;
+       buffer[1] = addr & 0xff;
+
+       if (i2c_master_send(client, buffer, 2) < 2)
+               return 0;
+
+       if (i2c_master_recv(client, buffer, 1) < 1)
+               return 0;
+
+       return buffer[0];
+}
+
+u32 cx25840_read4(struct i2c_client * client, u16 addr)
+{
+       u8 buffer[4];
+       buffer[0] = addr >> 8;
+       buffer[1] = addr & 0xff;
+
+       if (i2c_master_send(client, buffer, 2) < 2)
+               return 0;
+
+       if (i2c_master_recv(client, buffer, 4) < 4)
+               return 0;
+
+       return (buffer[0] << 24) | (buffer[1] << 16) |
+           (buffer[2] << 8) | buffer[3];
+}
+
+int cx25840_and_or(struct i2c_client *client, u16 addr, u8 and_mask,
+                  u8 or_value)
+{
+       return cx25840_write(client, addr,
+                            (cx25840_read(client, addr) & and_mask) |
+                            or_value);
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int set_input(struct i2c_client *, enum cx25840_input);
+static void input_change(struct i2c_client *);
+static void log_status(struct i2c_client *client);
+
+/* ----------------------------------------------------------------------- */
+
+static inline void init_dll1(struct i2c_client *client)
+{
+       /* This is the Hauppauge sequence used to
+        * initialize the Delay Lock Loop 1 (ADC DLL). */
+       cx25840_write(client, 0x159, 0x23);
+       cx25840_write(client, 0x15a, 0x87);
+       cx25840_write(client, 0x15b, 0x06);
+       cx25840_write(client, 0x159, 0xe1);
+       cx25840_write(client, 0x15a, 0x86);
+       cx25840_write(client, 0x159, 0xe0);
+       cx25840_write(client, 0x159, 0xe1);
+       cx25840_write(client, 0x15b, 0x10);
+}
+
+static inline void init_dll2(struct i2c_client *client)
+{
+       /* This is the Hauppauge sequence used to
+        * initialize the Delay Lock Loop 2 (ADC DLL). */
+       cx25840_write(client, 0x15d, 0xe3);
+       cx25840_write(client, 0x15e, 0x86);
+       cx25840_write(client, 0x15f, 0x06);
+       cx25840_write(client, 0x15d, 0xe1);
+       cx25840_write(client, 0x15d, 0xe0);
+       cx25840_write(client, 0x15d, 0xe1);
+}
+
+static void cx25840_initialize(struct i2c_client *client, int loadfw)
+{
+       struct cx25840_state *state = i2c_get_clientdata(client);
+
+       /* datasheet startup in numbered steps, refer to page 3-77 */
+       /* 2. */
+       cx25840_and_or(client, 0x803, ~0x10, 0x00);
+       /* The default of this register should be 4, but I get 0 instead.
+        * Set this register to 4 manually. */
+       cx25840_write(client, 0x000, 0x04);
+       /* 3. */
+       init_dll1(client);
+       init_dll2(client);
+       cx25840_write(client, 0x136, 0x0a);
+       /* 4. */
+       cx25840_write(client, 0x13c, 0x01);
+       cx25840_write(client, 0x13c, 0x00);
+       /* 5. */
+       if (loadfw)
+               cx25840_loadfw(client);
+       /* 6. */
+       cx25840_write(client, 0x115, 0x8c);
+       cx25840_write(client, 0x116, 0x07);
+       cx25840_write(client, 0x118, 0x02);
+       /* 7. */
+       cx25840_write(client, 0x4a5, 0x80);
+       cx25840_write(client, 0x4a5, 0x00);
+       cx25840_write(client, 0x402, 0x00);
+       /* 8. */
+       cx25840_write(client, 0x401, 0x18);
+       cx25840_write(client, 0x4a2, 0x10);
+       cx25840_write(client, 0x402, 0x04);
+       /* 10. */
+       cx25840_write(client, 0x8d3, 0x1f);
+       cx25840_write(client, 0x8e3, 0x03);
+
+       cx25840_vbi_setup(client);
+
+       /* trial and error says these are needed to get audio */
+       cx25840_write(client, 0x914, 0xa0);
+       cx25840_write(client, 0x918, 0xa0);
+       cx25840_write(client, 0x919, 0x01);
+
+       /* stereo prefered */
+       cx25840_write(client, 0x809, 0x04);
+       /* AC97 shift */
+       cx25840_write(client, 0x8cf, 0x0f);
+
+       /* (re)set video input */
+       set_input(client, state->input);
+       /* (re)set audio input */
+       cx25840_audio(client, AUDC_SET_INPUT, &state->audio_input);
+
+       /* start microcontroller */
+       cx25840_and_or(client, 0x803, ~0x10, 0x10);
+}
+
+/* ----------------------------------------------------------------------- */
+
+static void input_change(struct i2c_client *client)
+{
+       v4l2_std_id std = cx25840_get_v4lstd(client);
+
+       if (std & V4L2_STD_PAL) {
+               /* Follow tuner change procedure for PAL */
+               cx25840_write(client, 0x808, 0xff);
+               cx25840_write(client, 0x80b, 0x10);
+       } else if (std & V4L2_STD_SECAM) {
+               /* Select autodetect for SECAM */
+               cx25840_write(client, 0x808, 0xff);
+               cx25840_write(client, 0x80b, 0x10);
+       } else if (std & V4L2_STD_NTSC) {
+               /* NTSC */
+               cx25840_write(client, 0x808, 0xf6);
+               cx25840_write(client, 0x80b, 0x00);
+       }
+
+       if (cx25840_read(client, 0x803) & 0x10) {
+               /* restart audio decoder microcontroller */
+               cx25840_and_or(client, 0x803, ~0x10, 0x00);
+               cx25840_and_or(client, 0x803, ~0x10, 0x10);
+       }
+}
+
+static int set_input(struct i2c_client *client, enum cx25840_input input)
+{
+       struct cx25840_state *state = i2c_get_clientdata(client);
+
+       cx25840_dbg("decoder set input (%d)\n", input);
+
+       switch (input) {
+       case CX25840_TUNER:
+               cx25840_dbg("now setting Tuner input\n");
+
+               if (state->cardtype == CARDTYPE_PVR150) {
+                       /* CH_SEL_ADC2=1 */
+                       cx25840_and_or(client, 0x102, ~0x2, 0x02);
+               }
+
+               /* Video Input Control */
+               if (state->cardtype == CARDTYPE_PG600) {
+                       cx25840_write(client, 0x103, 0x11);
+               } else {
+                       cx25840_write(client, 0x103, 0x46);
+               }
+
+               /* INPUT_MODE=0 */
+               cx25840_and_or(client, 0x401, ~0x6, 0x00);
+               break;
+
+       case CX25840_COMPOSITE0:
+       case CX25840_COMPOSITE1:
+               cx25840_dbg("now setting Composite input\n");
+
+               /* Video Input Control */
+               if (state->cardtype == CARDTYPE_PG600) {
+                       cx25840_write(client, 0x103, 0x00);
+               } else {
+                       cx25840_write(client, 0x103, 0x02);
+               }
+
+               /* INPUT_MODE=0 */
+               cx25840_and_or(client, 0x401, ~0x6, 0x00);
+               break;
+
+       case CX25840_SVIDEO0:
+       case CX25840_SVIDEO1:
+               cx25840_dbg("now setting S-Video input\n");
+
+               /* CH_SEL_ADC2=0 */
+               cx25840_and_or(client, 0x102, ~0x2, 0x00);
+
+               /* Video Input Control */
+               if (state->cardtype == CARDTYPE_PG600) {
+                       cx25840_write(client, 0x103, 0x02);
+               } else {
+                       cx25840_write(client, 0x103, 0x10);
+               }
+
+               /* INPUT_MODE=1 */
+               cx25840_and_or(client, 0x401, ~0x6, 0x02);
+               break;
+
+       default:
+               cx25840_err("%d is not a valid input!\n", input);
+               return -EINVAL;
+       }
+
+       state->input = input;
+       input_change(client);
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int set_v4lstd(struct i2c_client *client, v4l2_std_id std)
+{
+       u8 fmt;
+
+       switch (std) {
+       /* zero is autodetect */
+       case 0: fmt = 0x0; break;
+       /* default ntsc to ntsc-m */
+       case V4L2_STD_NTSC:
+       case V4L2_STD_NTSC_M: fmt = 0x1; break;
+       case V4L2_STD_NTSC_M_JP: fmt = 0x2; break;
+       case V4L2_STD_NTSC_443: fmt = 0x3; break;
+       case V4L2_STD_PAL: fmt = 0x4; break;
+       case V4L2_STD_PAL_M: fmt = 0x5; break;
+       case V4L2_STD_PAL_N: fmt = 0x6; break;
+       case V4L2_STD_PAL_Nc: fmt = 0x7; break;
+       case V4L2_STD_PAL_60: fmt = 0x8; break;
+       case V4L2_STD_SECAM: fmt = 0xc; break;
+       default:
+               return -ERANGE;
+       }
+
+       cx25840_and_or(client, 0x400, ~0xf, fmt);
+       cx25840_vbi_setup(client);
+       return 0;
+}
+
+v4l2_std_id cx25840_get_v4lstd(struct i2c_client * client)
+{
+       /* check VID_FMT_SEL first */
+       u8 fmt = cx25840_read(client, 0x400) & 0xf;
+
+       if (!fmt) {
+               /* check AFD_FMT_STAT if set to autodetect */
+               fmt = cx25840_read(client, 0x40d) & 0xf;
+       }
+
+       switch (fmt) {
+       case 0x1: return V4L2_STD_NTSC_M;
+       case 0x2: return V4L2_STD_NTSC_M_JP;
+       case 0x3: return V4L2_STD_NTSC_443;
+       case 0x4: return V4L2_STD_PAL;
+       case 0x5: return V4L2_STD_PAL_M;
+       case 0x6: return V4L2_STD_PAL_N;
+       case 0x7: return V4L2_STD_PAL_Nc;
+       case 0x8: return V4L2_STD_PAL_60;
+       case 0xc: return V4L2_STD_SECAM;
+       default: return V4L2_STD_UNKNOWN;
+       }
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int set_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl)
+{
+       struct cx25840_state *state = i2c_get_clientdata(client);
+
+       switch (ctrl->id) {
+       case CX25840_CID_CARDTYPE:
+               switch (ctrl->value) {
+               case CARDTYPE_PVR150:
+               case CARDTYPE_PG600:
+                       state->cardtype = ctrl->value;
+                       break;
+               default:
+                       return -ERANGE;
+               }
+
+               set_input(client, state->input);
+               break;
+
+       case V4L2_CID_BRIGHTNESS:
+               if (ctrl->value < 0 || ctrl->value > 255) {
+                       cx25840_err("invalid brightness setting %d\n",
+                                   ctrl->value);
+                       return -ERANGE;
+               }
+
+               cx25840_write(client, 0x414, ctrl->value - 128);
+               break;
+
+       case V4L2_CID_CONTRAST:
+               if (ctrl->value < 0 || ctrl->value > 127) {
+                       cx25840_err("invalid contrast setting %d\n",
+                                   ctrl->value);
+                       return -ERANGE;
+               }
+
+               cx25840_write(client, 0x415, ctrl->value << 1);
+               break;
+
+       case V4L2_CID_SATURATION:
+               if (ctrl->value < 0 || ctrl->value > 127) {
+                       cx25840_err("invalid saturation setting %d\n",
+                                   ctrl->value);
+                       return -ERANGE;
+               }
+
+               cx25840_write(client, 0x420, ctrl->value << 1);
+               cx25840_write(client, 0x421, ctrl->value << 1);
+               break;
+
+       case V4L2_CID_HUE:
+               if (ctrl->value < -127 || ctrl->value > 127) {
+                       cx25840_err("invalid hue setting %d\n", ctrl->value);
+                       return -ERANGE;
+               }
+
+               cx25840_write(client, 0x422, ctrl->value);
+               break;
+
+       case V4L2_CID_AUDIO_VOLUME:
+       case V4L2_CID_AUDIO_BASS:
+       case V4L2_CID_AUDIO_TREBLE:
+       case V4L2_CID_AUDIO_BALANCE:
+       case V4L2_CID_AUDIO_MUTE:
+               return cx25840_audio(client, VIDIOC_S_CTRL, ctrl);
+       }
+
+       return 0;
+}
+
+static int get_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl)
+{
+       struct cx25840_state *state = i2c_get_clientdata(client);
+
+       switch (ctrl->id) {
+       case CX25840_CID_CARDTYPE:
+               ctrl->value = state->cardtype;
+               break;
+       case V4L2_CID_BRIGHTNESS:
+               ctrl->value = cx25840_read(client, 0x414) + 128;
+               break;
+       case V4L2_CID_CONTRAST:
+               ctrl->value = cx25840_read(client, 0x415) >> 1;
+               break;
+       case V4L2_CID_SATURATION:
+               ctrl->value = cx25840_read(client, 0x420) >> 1;
+               break;
+       case V4L2_CID_HUE:
+               ctrl->value = cx25840_read(client, 0x422);
+               break;
+       case V4L2_CID_AUDIO_VOLUME:
+       case V4L2_CID_AUDIO_BASS:
+       case V4L2_CID_AUDIO_TREBLE:
+       case V4L2_CID_AUDIO_BALANCE:
+       case V4L2_CID_AUDIO_MUTE:
+               return cx25840_audio(client, VIDIOC_G_CTRL, ctrl);
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int get_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
+{
+       switch (fmt->type) {
+       case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
+               return cx25840_vbi(client, VIDIOC_G_FMT, fmt);
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static int set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
+{
+       struct v4l2_pix_format *pix;
+       int HSC, VSC, Vsrc, Hsrc, filter, Vlines;
+       int is_pal = !(cx25840_get_v4lstd(client) & V4L2_STD_NTSC);
+
+       switch (fmt->type) {
+       case V4L2_BUF_TYPE_VIDEO_CAPTURE:
+               pix = &(fmt->fmt.pix);
+
+               Vsrc = (cx25840_read(client, 0x476) & 0x3f) << 4;
+               Vsrc |= (cx25840_read(client, 0x475) & 0xf0) >> 4;
+
+               Hsrc = (cx25840_read(client, 0x472) & 0x3f) << 4;
+               Hsrc |= (cx25840_read(client, 0x471) & 0xf0) >> 4;
+
+               Vlines = pix->height + (is_pal ? 4 : 7);
+
+               if ((pix->width * 16 < Hsrc) || (Hsrc < pix->width) ||
+                   (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) {
+                       cx25840_err("%dx%d is not a valid size!\n",
+                                   pix->width, pix->height);
+                       return -ERANGE;
+               }
+
+               HSC = (Hsrc * (1 << 20)) / pix->width - (1 << 20);
+               VSC = (1 << 16) - (Vsrc * (1 << 9) / Vlines - (1 << 9));
+               VSC &= 0x1fff;
+
+               if (pix->width >= 385)
+                       filter = 0;
+               else if (pix->width > 192)
+                       filter = 1;
+               else if (pix->width > 96)
+                       filter = 2;
+               else
+                       filter = 3;
+
+               cx25840_dbg("decoder set size %dx%d -> scale  %ux%u\n",
+                           pix->width, pix->height, HSC, VSC);
+
+               /* HSCALE=HSC */
+               cx25840_write(client, 0x418, HSC & 0xff);
+               cx25840_write(client, 0x419, (HSC >> 8) & 0xff);
+               cx25840_write(client, 0x41a, HSC >> 16);
+               /* VSCALE=VSC */
+               cx25840_write(client, 0x41c, VSC & 0xff);
+               cx25840_write(client, 0x41d, VSC >> 8);
+               /* VS_INTRLACE=1 VFILT=filter */
+               cx25840_write(client, 0x41e, 0x8 | filter);
+               break;
+
+       case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
+               return cx25840_vbi(client, VIDIOC_S_FMT, fmt);
+
+       case V4L2_BUF_TYPE_VBI_CAPTURE:
+               return cx25840_vbi(client, VIDIOC_S_FMT, fmt);
+
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int cx25840_command(struct i2c_client *client, unsigned int cmd,
+                          void *arg)
+{
+       struct cx25840_state *state = i2c_get_clientdata(client);
+       struct v4l2_tuner *vt = arg;
+       int result = 0;
+
+       switch (cmd) {
+       case 0:
+               break;
+
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+       /* ioctls to allow direct access to the
+        * cx25840 registers for testing */
+       case VIDIOC_INT_G_REGISTER:
+       {
+               struct v4l2_register *reg = arg;
+
+               if (reg->i2c_id != I2C_DRIVERID_CX25840)
+                       return -EINVAL;
+               reg->val = cx25840_read(client, reg->reg & 0x0fff);
+               break;
+       }
+
+       case VIDIOC_INT_S_REGISTER:
+       {
+               struct v4l2_register *reg = arg;
+
+               if (reg->i2c_id != I2C_DRIVERID_CX25840)
+                       return -EINVAL;
+               if (!capable(CAP_SYS_ADMIN))
+                       return -EPERM;
+               cx25840_write(client, reg->reg & 0x0fff, reg->val & 0xff);
+               break;
+       }
+#endif
+
+       case VIDIOC_INT_DECODE_VBI_LINE:
+               return cx25840_vbi(client, cmd, arg);
+
+       case VIDIOC_INT_AUDIO_CLOCK_FREQ:
+       case AUDC_SET_INPUT:
+               result = cx25840_audio(client, cmd, arg);
+               break;
+
+       case VIDIOC_STREAMON:
+               cx25840_dbg("enable output\n");
+               cx25840_write(client, 0x115, 0x8c);
+               cx25840_write(client, 0x116, 0x07);
+               break;
+
+       case VIDIOC_STREAMOFF:
+               cx25840_dbg("disable output\n");
+               cx25840_write(client, 0x115, 0x00);
+               cx25840_write(client, 0x116, 0x00);
+               break;
+
+       case VIDIOC_LOG_STATUS:
+               log_status(client);
+               break;
+
+       case VIDIOC_G_CTRL:
+               result = get_v4lctrl(client, (struct v4l2_control *)arg);
+               break;
+
+       case VIDIOC_S_CTRL:
+               result = set_v4lctrl(client, (struct v4l2_control *)arg);
+               break;
+
+       case VIDIOC_G_STD:
+               *(v4l2_std_id *)arg = cx25840_get_v4lstd(client);
+               break;
+
+       case VIDIOC_S_STD:
+               result = set_v4lstd(client, *(v4l2_std_id *)arg);
+               break;
+
+       case VIDIOC_G_INPUT:
+               *(int *)arg = state->input;
+               break;
+
+       case VIDIOC_S_INPUT:
+               result = set_input(client, *(int *)arg);
+               break;
+
+       case VIDIOC_S_FREQUENCY:
+               input_change(client);
+               break;
+
+       case VIDIOC_G_TUNER:
+       {
+               u8 mode = cx25840_read(client, 0x804);
+               u8 pref = cx25840_read(client, 0x809) & 0xf;
+               u8 vpres = cx25840_read(client, 0x80a) & 0x10;
+               int val = 0;
+
+               vt->capability |=
+                   V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LANG1 |
+                   V4L2_TUNER_CAP_LANG2 | V4L2_TUNER_CAP_SAP;
+
+               vt->signal = vpres ? 0xffff : 0x0;
+
+               /* get rxsubchans and audmode */
+               if ((mode & 0xf) == 1)
+                       val |= V4L2_TUNER_SUB_STEREO;
+               else
+                       val |= V4L2_TUNER_SUB_MONO;
+
+               if (mode == 2 || mode == 4)
+                       val |= V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
+
+               if (mode & 0x10)
+                       val |= V4L2_TUNER_SUB_SAP;
+
+               vt->rxsubchans = val;
+
+               switch (pref) {
+               case 0:
+                       vt->audmode = V4L2_TUNER_MODE_MONO;
+                       break;
+               case 1:
+               case 2:
+                       vt->audmode = V4L2_TUNER_MODE_LANG2;
+                       break;
+               case 4:
+               default:
+                       vt->audmode = V4L2_TUNER_MODE_STEREO;
+               }
+               break;
+       }
+
+       case VIDIOC_S_TUNER:
+               switch (vt->audmode) {
+               case V4L2_TUNER_MODE_MONO:
+               case V4L2_TUNER_MODE_LANG1:
+                       /* Force PREF_MODE to MONO */
+                       cx25840_and_or(client, 0x809, ~0xf, 0x00);
+                       break;
+               case V4L2_TUNER_MODE_STEREO:
+                       /* Force PREF_MODE to STEREO */
+                       cx25840_and_or(client, 0x809, ~0xf, 0x04);
+                       break;
+               case V4L2_TUNER_MODE_LANG2:
+                       /* Force PREF_MODE to LANG2 */
+                       cx25840_and_or(client, 0x809, ~0xf, 0x01);
+                       break;
+               }
+               break;
+
+       case VIDIOC_G_FMT:
+               result = get_v4lfmt(client, (struct v4l2_format *)arg);
+               break;
+
+       case VIDIOC_S_FMT:
+               result = set_v4lfmt(client, (struct v4l2_format *)arg);
+               break;
+
+       case VIDIOC_INT_RESET:
+               cx25840_initialize(client, 0);
+               break;
+
+       case VIDIOC_INT_G_CHIP_IDENT:
+               *(enum v4l2_chip_ident *)arg =
+                       V4L2_IDENT_CX25840 + ((cx25840_read(client, 0x100) >> 4) & 0xf);
+               break;
+
+       default:
+               cx25840_err("invalid ioctl %x\n", cmd);
+               return -EINVAL;
+       }
+
+       return result;
+}
+
+/* ----------------------------------------------------------------------- */
+
+struct i2c_driver i2c_driver_cx25840;
+
+static int cx25840_detect_client(struct i2c_adapter *adapter, int address,
+                                int kind)
+{
+       struct i2c_client *client;
+       struct cx25840_state *state;
+       u16 device_id;
+
+       /* Check if the adapter supports the needed features
+        * Not until kernel version 2.6.11 did the bit-algo
+        * correctly report that it would do an I2C-level xfer */
+       if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
+               return 0;
+
+       client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
+       if (client == 0)
+               return -ENOMEM;
+
+       memset(client, 0, sizeof(struct i2c_client));
+       client->addr = address;
+       client->adapter = adapter;
+       client->driver = &i2c_driver_cx25840;
+       client->flags = I2C_CLIENT_ALLOW_USE;
+       snprintf(client->name, sizeof(client->name) - 1, "cx25840");
+
+       cx25840_dbg("detecting cx25840 client on address 0x%x\n", address << 1);
+
+       device_id = cx25840_read(client, 0x101) << 8;
+       device_id |= cx25840_read(client, 0x100);
+
+       /* The high byte of the device ID should be
+        * 0x84 if chip is present */
+       if ((device_id & 0xff00) != 0x8400) {
+               cx25840_dbg("cx25840 not found\n");
+               kfree(client);
+               return 0;
+       }
+
+       cx25840_info("cx25%3x-2%x found @ 0x%x (%s)\n",
+                   (device_id & 0xfff0) >> 4,
+                   (device_id & 0x0f) < 3 ? (device_id & 0x0f) + 1 : 3,
+                   address << 1, adapter->name);
+
+       state = kmalloc(sizeof(struct cx25840_state), GFP_KERNEL);
+       if (state == NULL) {
+               kfree(client);
+               return -ENOMEM;
+       }
+
+       i2c_set_clientdata(client, state);
+       memset(state, 0, sizeof(struct cx25840_state));
+       state->input = CX25840_TUNER;
+       state->audclk_freq = V4L2_AUDCLK_48_KHZ;
+       state->audio_input = AUDIO_TUNER;
+       state->cardtype = CARDTYPE_PVR150;
+
+       cx25840_initialize(client, 1);
+
+       i2c_attach_client(client);
+
+       return 0;
+}
+
+static int cx25840_attach_adapter(struct i2c_adapter *adapter)
+{
+#ifdef I2C_CLASS_TV_ANALOG
+       if (adapter->class & I2C_CLASS_TV_ANALOG)
+#else
+       if (adapter->id == I2C_HW_B_BT848)
+#endif
+               return i2c_probe(adapter, &addr_data, &cx25840_detect_client);
+       return 0;
+}
+
+static int cx25840_detach_client(struct i2c_client *client)
+{
+       struct cx25840_state *state = i2c_get_clientdata(client);
+       int err;
+
+       err = i2c_detach_client(client);
+       if (err) {
+               return err;
+       }
+
+       kfree(state);
+       kfree(client);
+
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+struct i2c_driver i2c_driver_cx25840 = {
+       .name = "cx25840",
+
+       .id = I2C_DRIVERID_CX25840,
+       .flags = I2C_DF_NOTIFY,
+
+       .attach_adapter = cx25840_attach_adapter,
+       .detach_client = cx25840_detach_client,
+       .command = cx25840_command,
+       .owner = THIS_MODULE,
+};
+
+
+static int __init m__init(void)
+{
+       return i2c_add_driver(&i2c_driver_cx25840);
+}
+
+static void __exit m__exit(void)
+{
+       i2c_del_driver(&i2c_driver_cx25840);
+}
+
+module_init(m__init);
+module_exit(m__exit);
+
+/* ----------------------------------------------------------------------- */
+
+static void log_status(struct i2c_client *client)
+{
+       static const char *const fmt_strs[] = {
+               "0x0",
+               "NTSC-M", "NTSC-J", "NTSC-4.43",
+               "PAL-BDGHI", "PAL-M", "PAL-N", "PAL-Nc", "PAL-60",
+               "0x9", "0xA", "0xB",
+               "SECAM",
+               "0xD", "0xE", "0xF"
+       };
+
+       struct cx25840_state *state = i2c_get_clientdata(client);
+       u8 microctrl_vidfmt = cx25840_read(client, 0x80a);
+       u8 vidfmt_sel = cx25840_read(client, 0x400) & 0xf;
+       u8 gen_stat1 = cx25840_read(client, 0x40d);
+       u8 download_ctl = cx25840_read(client, 0x803);
+       u8 mod_det_stat0 = cx25840_read(client, 0x804);
+       u8 mod_det_stat1 = cx25840_read(client, 0x805);
+       u8 audio_config = cx25840_read(client, 0x808);
+       u8 pref_mode = cx25840_read(client, 0x809);
+       u8 afc0 = cx25840_read(client, 0x80b);
+       u8 mute_ctl = cx25840_read(client, 0x8d3);
+       char *p;
+
+       cx25840_info("Video signal:              %spresent\n",
+                   (microctrl_vidfmt & 0x10) ? "" : "not ");
+       cx25840_info("Detected format:           %s\n",
+                   fmt_strs[gen_stat1 & 0xf]);
+
+       switch (mod_det_stat0) {
+       case 0x00: p = "mono"; break;
+       case 0x01: p = "stereo"; break;
+       case 0x02: p = "dual"; break;
+       case 0x04: p = "tri"; break;
+       case 0x10: p = "mono with SAP"; break;
+       case 0x11: p = "stereo with SAP"; break;
+       case 0x12: p = "dual with SAP"; break;
+       case 0x14: p = "tri with SAP"; break;
+       case 0xfe: p = "forced mode"; break;
+       default: p = "not defined";
+       }
+       cx25840_info("Detected audio mode:       %s\n", p);
+
+       switch (mod_det_stat1) {
+       case 0x00: p = "not defined"; break;
+       case 0x01: p = "EIAJ"; break;
+       case 0x02: p = "A2-M"; break;
+       case 0x03: p = "A2-BG"; break;
+       case 0x04: p = "A2-DK1"; break;
+       case 0x05: p = "A2-DK2"; break;
+       case 0x06: p = "A2-DK3"; break;
+       case 0x07: p = "A1 (6.0 MHz FM Mono)"; break;
+       case 0x08: p = "AM-L"; break;
+       case 0x09: p = "NICAM-BG"; break;
+       case 0x0a: p = "NICAM-DK"; break;
+       case 0x0b: p = "NICAM-I"; break;
+       case 0x0c: p = "NICAM-L"; break;
+       case 0x0d: p = "BTSC/EIAJ/A2-M Mono (4.5 MHz FMMono)"; break;
+       case 0x0e: p = "IF FM Radio"; break;
+       case 0x0f: p = "BTSC"; break;
+       case 0x10: p = "high-deviation FM"; break;
+       case 0x11: p = "very high-deviation FM"; break;
+       case 0xfd: p = "unknown audio standard"; break;
+       case 0xfe: p = "forced audio standard"; break;
+       case 0xff: p = "no detected audio standard"; break;
+       default: p = "not defined";
+       }
+       cx25840_info("Detected audio standard:   %s\n", p);
+       cx25840_info("Audio muted:               %s\n",
+                   (mute_ctl & 0x2) ? "yes" : "no");
+       cx25840_info("Audio microcontroller:     %s\n",
+                   (download_ctl & 0x10) ? "running" : "stopped");
+
+       switch (audio_config >> 4) {
+       case 0x00: p = "undefined"; break;
+       case 0x01: p = "BTSC"; break;
+       case 0x02: p = "EIAJ"; break;
+       case 0x03: p = "A2-M"; break;
+       case 0x04: p = "A2-BG"; break;
+       case 0x05: p = "A2-DK1"; break;
+       case 0x06: p = "A2-DK2"; break;
+       case 0x07: p = "A2-DK3"; break;
+       case 0x08: p = "A1 (6.0 MHz FM Mono)"; break;
+       case 0x09: p = "AM-L"; break;
+       case 0x0a: p = "NICAM-BG"; break;
+       case 0x0b: p = "NICAM-DK"; break;
+       case 0x0c: p = "NICAM-I"; break;
+       case 0x0d: p = "NICAM-L"; break;
+       case 0x0e: p = "FM radio"; break;
+       case 0x0f: p = "automatic detection"; break;
+       default: p = "undefined";
+       }
+       cx25840_info("Configured audio standard: %s\n", p);
+
+       if ((audio_config >> 4) < 0xF) {
+               switch (audio_config & 0xF) {
+               case 0x00: p = "MONO1 (LANGUAGE A/Mono L+R channel for BTSC, EIAJ, A2)"; break;
+               case 0x01: p = "MONO2 (LANGUAGE B)"; break;
+               case 0x02: p = "MONO3 (STEREO forced MONO)"; break;
+               case 0x03: p = "MONO4 (NICAM ANALOG-Language C/Analog Fallback)"; break;
+               case 0x04: p = "STEREO"; break;
+               case 0x05: p = "DUAL1 (AB)"; break;
+               case 0x06: p = "DUAL2 (AC) (FM)"; break;
+               case 0x07: p = "DUAL3 (BC) (FM)"; break;
+               case 0x08: p = "DUAL4 (AC) (AM)"; break;
+               case 0x09: p = "DUAL5 (BC) (AM)"; break;
+               case 0x0a: p = "SAP"; break;
+               default: p = "undefined";
+               }
+               cx25840_info("Configured audio mode:     %s\n", p);
+       } else {
+               switch (audio_config & 0xF) {
+               case 0x00: p = "BG"; break;
+               case 0x01: p = "DK1"; break;
+               case 0x02: p = "DK2"; break;
+               case 0x03: p = "DK3"; break;
+               case 0x04: p = "I"; break;
+               case 0x05: p = "L"; break;
+               case 0x06: p = "BTSC"; break;
+               case 0x07: p = "EIAJ"; break;
+               case 0x08: p = "A2-M"; break;
+               case 0x09: p = "FM Radio"; break;
+               case 0x0f: p = "automatic standard and mode detection"; break;
+               default: p = "undefined";
+               }
+               cx25840_info("Configured audio system:   %s\n", p);
+       }
+
+       cx25840_info("Specified standard:        %s\n",
+                   vidfmt_sel ? fmt_strs[vidfmt_sel] : "automatic detection");
+
+       switch (state->input) {
+       case CX25840_COMPOSITE0: p = "Composite 0"; break;
+       case CX25840_COMPOSITE1: p = "Composite 1"; break;
+       case CX25840_SVIDEO0: p = "S-Video 0"; break;
+       case CX25840_SVIDEO1: p = "S-Video 1"; break;
+       case CX25840_TUNER: p = "Tuner"; break;
+       }
+       cx25840_info("Specified input:           %s\n", p);
+       cx25840_info("Specified audio input:     %s\n",
+                   state->audio_input == 0 ? "Tuner" : "External");
+
+       switch (state->audclk_freq) {
+       case V4L2_AUDCLK_441_KHZ: p = "44.1 kHz"; break;
+       case V4L2_AUDCLK_48_KHZ: p = "48 kHz"; break;
+       case V4L2_AUDCLK_32_KHZ: p = "32 kHz"; break;
+       default: p = "undefined";
+       }
+       cx25840_info("Specified audioclock freq: %s\n", p);
+
+       switch (pref_mode & 0xf) {
+       case 0: p = "mono/language A"; break;
+       case 1: p = "language B"; break;
+       case 2: p = "language C"; break;
+       case 3: p = "analog fallback"; break;
+       case 4: p = "stereo"; break;
+       case 5: p = "language AC"; break;
+       case 6: p = "language BC"; break;
+       case 7: p = "language AB"; break;
+       default: p = "undefined";
+       }
+       cx25840_info("Preferred audio mode:      %s\n", p);
+
+       if ((audio_config & 0xf) == 0xf) {
+               switch ((afc0 >> 3) & 0x3) {
+               case 0: p = "system DK"; break;
+               case 1: p = "system L"; break;
+               case 2: p = "autodetect"; break;
+               default: p = "undefined";
+               }
+               cx25840_info("Selected 65 MHz format:    %s\n", p);
+
+               switch (afc0 & 0x7) {
+               case 0: p = "chroma"; break;
+               case 1: p = "BTSC"; break;
+               case 2: p = "EIAJ"; break;
+               case 3: p = "A2-M"; break;
+               case 4: p = "autodetect"; break;
+               default: p = "undefined";
+               }
+               cx25840_info("Selected 45 MHz format:    %s\n", p);
+       }
+}
diff --git a/drivers/media/video/cx25840/cx25840-firmware.c b/drivers/media/video/cx25840/cx25840-firmware.c
new file mode 100644 (file)
index 0000000..df9d50a
--- /dev/null
@@ -0,0 +1,167 @@
+/* cx25840 firmware functions
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/i2c-algo-bit.h>
+#include <linux/firmware.h>
+#include <media/v4l2-common.h>
+
+#include "cx25840.h"
+
+#define FWFILE "v4l-cx25840.fw"
+#define FWSEND 1024
+
+#define FWDEV(x) &((x)->adapter->dev)
+
+static int fastfw = 1;
+static char *firmware = FWFILE;
+
+module_param(fastfw, bool, 0444);
+module_param(firmware, charp, 0444);
+
+MODULE_PARM_DESC(fastfw, "Load firmware fast [0=100MHz 1=333MHz (default)]");
+MODULE_PARM_DESC(firmware, "Firmware image [default: " FWFILE "]");
+
+static inline void set_i2c_delay(struct i2c_client *client, int delay)
+{
+       struct i2c_algo_bit_data *algod = client->adapter->algo_data;
+
+       /* We aren't guaranteed to be using algo_bit,
+        * so avoid the null pointer dereference
+        * and disable the 'fast firmware load' */
+       if (algod) {
+               algod->udelay = delay;
+       } else {
+               fastfw = 0;
+       }
+}
+
+static inline void start_fw_load(struct i2c_client *client)
+{
+       /* DL_ADDR_LB=0 DL_ADDR_HB=0 */
+       cx25840_write(client, 0x800, 0x00);
+       cx25840_write(client, 0x801, 0x00);
+       // DL_MAP=3 DL_AUTO_INC=0 DL_ENABLE=1
+       cx25840_write(client, 0x803, 0x0b);
+       /* AUTO_INC_DIS=1 */
+       cx25840_write(client, 0x000, 0x20);
+
+       if (fastfw)
+               set_i2c_delay(client, 3);
+}
+
+static inline void end_fw_load(struct i2c_client *client)
+{
+       if (fastfw)
+               set_i2c_delay(client, 10);
+
+       /* AUTO_INC_DIS=0 */
+       cx25840_write(client, 0x000, 0x00);
+       /* DL_ENABLE=0 */
+       cx25840_write(client, 0x803, 0x03);
+}
+
+static inline int check_fw_load(struct i2c_client *client, int size)
+{
+       /* DL_ADDR_HB DL_ADDR_LB */
+       int s = cx25840_read(client, 0x801) << 8;
+       s |= cx25840_read(client, 0x800);
+
+       if (size != s) {
+               cx25840_err("firmware %s load failed\n", firmware);
+               return -EINVAL;
+       }
+
+       cx25840_info("loaded %s firmware (%d bytes)\n", firmware, size);
+       return 0;
+}
+
+static inline int fw_write(struct i2c_client *client, u8 * data, int size)
+{
+       if (i2c_master_send(client, data, size) < size) {
+
+               if (fastfw) {
+                       cx25840_err("333MHz i2c firmware load failed\n");
+                       fastfw = 0;
+                       set_i2c_delay(client, 10);
+
+                       if (i2c_master_send(client, data, size) < size) {
+                               cx25840_err
+                                   ("100MHz i2c firmware load failed\n");
+                               return -ENOSYS;
+                       }
+
+               } else {
+                       cx25840_err("firmware load i2c failure\n");
+                       return -ENOSYS;
+               }
+
+       }
+
+       return 0;
+}
+
+int cx25840_loadfw(struct i2c_client *client)
+{
+       const struct firmware *fw = NULL;
+       u8 buffer[4], *ptr;
+       int size, send, retval;
+
+       if (request_firmware(&fw, firmware, FWDEV(client)) != 0) {
+               cx25840_err("unable to open firmware %s\n", firmware);
+               return -EINVAL;
+       }
+
+       start_fw_load(client);
+
+       buffer[0] = 0x08;
+       buffer[1] = 0x02;
+       buffer[2] = fw->data[0];
+       buffer[3] = fw->data[1];
+       retval = fw_write(client, buffer, 4);
+
+       if (retval < 0) {
+               release_firmware(fw);
+               return retval;
+       }
+
+       size = fw->size - 2;
+       ptr = fw->data;
+       while (size > 0) {
+               ptr[0] = 0x08;
+               ptr[1] = 0x02;
+               send = size > (FWSEND - 2) ? FWSEND : size + 2;
+               retval = fw_write(client, ptr, send);
+
+               if (retval < 0) {
+                       release_firmware(fw);
+                       return retval;
+               }
+
+               size -= FWSEND - 2;
+               ptr += FWSEND - 2;
+       }
+
+       end_fw_load(client);
+
+       size = fw->size;
+       release_firmware(fw);
+
+       return check_fw_load(client, size);
+}
diff --git a/drivers/media/video/cx25840/cx25840-vbi.c b/drivers/media/video/cx25840/cx25840-vbi.c
new file mode 100644 (file)
index 0000000..13ba4e1
--- /dev/null
@@ -0,0 +1,315 @@
+/* cx25840 VBI functions
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+
+#include <linux/videodev2.h>
+#include <linux/i2c.h>
+#include <media/v4l2-common.h>
+
+#include "cx25840.h"
+
+static inline int odd_parity(u8 c)
+{
+       c ^= (c >> 4);
+       c ^= (c >> 2);
+       c ^= (c >> 1);
+
+       return c & 1;
+}
+
+static inline int decode_vps(u8 * dst, u8 * p)
+{
+       static const u8 biphase_tbl[] = {
+               0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
+               0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0,
+               0xd2, 0x5a, 0x52, 0xd2, 0x96, 0x1e, 0x16, 0x96,
+               0x92, 0x1a, 0x12, 0x92, 0xd2, 0x5a, 0x52, 0xd2,
+               0xd0, 0x58, 0x50, 0xd0, 0x94, 0x1c, 0x14, 0x94,
+               0x90, 0x18, 0x10, 0x90, 0xd0, 0x58, 0x50, 0xd0,
+               0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
+               0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0,
+               0xe1, 0x69, 0x61, 0xe1, 0xa5, 0x2d, 0x25, 0xa5,
+               0xa1, 0x29, 0x21, 0xa1, 0xe1, 0x69, 0x61, 0xe1,
+               0xc3, 0x4b, 0x43, 0xc3, 0x87, 0x0f, 0x07, 0x87,
+               0x83, 0x0b, 0x03, 0x83, 0xc3, 0x4b, 0x43, 0xc3,
+               0xc1, 0x49, 0x41, 0xc1, 0x85, 0x0d, 0x05, 0x85,
+               0x81, 0x09, 0x01, 0x81, 0xc1, 0x49, 0x41, 0xc1,
+               0xe1, 0x69, 0x61, 0xe1, 0xa5, 0x2d, 0x25, 0xa5,
+               0xa1, 0x29, 0x21, 0xa1, 0xe1, 0x69, 0x61, 0xe1,
+               0xe0, 0x68, 0x60, 0xe0, 0xa4, 0x2c, 0x24, 0xa4,
+               0xa0, 0x28, 0x20, 0xa0, 0xe0, 0x68, 0x60, 0xe0,
+               0xc2, 0x4a, 0x42, 0xc2, 0x86, 0x0e, 0x06, 0x86,
+               0x82, 0x0a, 0x02, 0x82, 0xc2, 0x4a, 0x42, 0xc2,
+               0xc0, 0x48, 0x40, 0xc0, 0x84, 0x0c, 0x04, 0x84,
+               0x80, 0x08, 0x00, 0x80, 0xc0, 0x48, 0x40, 0xc0,
+               0xe0, 0x68, 0x60, 0xe0, 0xa4, 0x2c, 0x24, 0xa4,
+               0xa0, 0x28, 0x20, 0xa0, 0xe0, 0x68, 0x60, 0xe0,
+               0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
+               0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0,
+               0xd2, 0x5a, 0x52, 0xd2, 0x96, 0x1e, 0x16, 0x96,
+               0x92, 0x1a, 0x12, 0x92, 0xd2, 0x5a, 0x52, 0xd2,
+               0xd0, 0x58, 0x50, 0xd0, 0x94, 0x1c, 0x14, 0x94,
+               0x90, 0x18, 0x10, 0x90, 0xd0, 0x58, 0x50, 0xd0,
+               0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
+               0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0,
+       };
+
+       u8 c, err = 0;
+       int i;
+
+       for (i = 0; i < 2 * 13; i += 2) {
+               err |= biphase_tbl[p[i]] | biphase_tbl[p[i + 1]];
+               c = (biphase_tbl[p[i + 1]] & 0xf) |
+                   ((biphase_tbl[p[i]] & 0xf) << 4);
+               dst[i / 2] = c;
+       }
+
+       return err & 0xf0;
+}
+
+void cx25840_vbi_setup(struct i2c_client *client)
+{
+       v4l2_std_id std = cx25840_get_v4lstd(client);
+
+       if (std & ~V4L2_STD_NTSC) {
+               /* datasheet startup, step 8d */
+               cx25840_write(client, 0x49f, 0x11);
+
+               cx25840_write(client, 0x470, 0x84);
+               cx25840_write(client, 0x471, 0x00);
+               cx25840_write(client, 0x472, 0x2d);
+               cx25840_write(client, 0x473, 0x5d);
+
+               cx25840_write(client, 0x474, 0x24);
+               cx25840_write(client, 0x475, 0x40);
+               cx25840_write(client, 0x476, 0x24);
+               cx25840_write(client, 0x477, 0x28);
+
+               cx25840_write(client, 0x478, 0x1f);
+               cx25840_write(client, 0x479, 0x02);
+
+               if (std & V4L2_STD_SECAM) {
+                       cx25840_write(client, 0x47a, 0x80);
+                       cx25840_write(client, 0x47b, 0x00);
+                       cx25840_write(client, 0x47c, 0x5f);
+                       cx25840_write(client, 0x47d, 0x42);
+               } else {
+                       cx25840_write(client, 0x47a, 0x90);
+                       cx25840_write(client, 0x47b, 0x20);
+                       cx25840_write(client, 0x47c, 0x63);
+                       cx25840_write(client, 0x47d, 0x82);
+               }
+
+               cx25840_write(client, 0x47e, 0x0a);
+               cx25840_write(client, 0x47f, 0x01);
+       } else {
+               /* datasheet startup, step 8d */
+               cx25840_write(client, 0x49f, 0x14);
+
+               cx25840_write(client, 0x470, 0x7a);
+               cx25840_write(client, 0x471, 0x00);
+               cx25840_write(client, 0x472, 0x2d);
+               cx25840_write(client, 0x473, 0x5b);
+
+               cx25840_write(client, 0x474, 0x1a);
+               cx25840_write(client, 0x475, 0x70);
+               cx25840_write(client, 0x476, 0x1e);
+               cx25840_write(client, 0x477, 0x1e);
+
+               cx25840_write(client, 0x478, 0x1f);
+               cx25840_write(client, 0x479, 0x02);
+               cx25840_write(client, 0x47a, 0x50);
+               cx25840_write(client, 0x47b, 0x66);
+
+               cx25840_write(client, 0x47c, 0x1f);
+               cx25840_write(client, 0x47d, 0x7c);
+               cx25840_write(client, 0x47e, 0x08);
+               cx25840_write(client, 0x47f, 0x00);
+       }
+}
+
+int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
+{
+       struct v4l2_format *fmt;
+       struct v4l2_sliced_vbi_format *svbi;
+
+       switch (cmd) {
+       case VIDIOC_G_FMT:
+       {
+               static u16 lcr2vbi[] = {
+                       0, V4L2_SLICED_TELETEXT_B, 0,   /* 1 */
+                       0, V4L2_SLICED_WSS_625, 0,      /* 4 */
+                       V4L2_SLICED_CAPTION_525,        /* 6 */
+                       0, 0, V4L2_SLICED_VPS, 0, 0,    /* 9 */
+                       0, 0, 0, 0
+               };
+               int i;
+
+               fmt = arg;
+               if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
+                       return -EINVAL;
+               svbi = &fmt->fmt.sliced;
+               memset(svbi, 0, sizeof(*svbi));
+               /* we're done if raw VBI is active */
+               if ((cx25840_read(client, 0x404) & 0x10) == 0)
+                       break;
+
+               for (i = 7; i <= 23; i++) {
+                       u8 v = cx25840_read(client, 0x424 + i - 7);
+
+                       svbi->service_lines[0][i] = lcr2vbi[v >> 4];
+                       svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
+                       svbi->service_set |=
+                                svbi->service_lines[0][i] | svbi->service_lines[1][i];
+               }
+               break;
+       }
+
+       case VIDIOC_S_FMT:
+       {
+               int is_pal = !(cx25840_get_v4lstd(client) & V4L2_STD_NTSC);
+               int vbi_offset = is_pal ? 1 : 0;
+               int i, x;
+               u8 lcr[24];
+
+               fmt = arg;
+               if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
+                       return -EINVAL;
+               svbi = &fmt->fmt.sliced;
+               if (svbi->service_set == 0) {
+                       /* raw VBI */
+                       memset(svbi, 0, sizeof(*svbi));
+
+                       /* Setup VBI */
+                       cx25840_vbi_setup(client);
+
+                       /* VBI Offset */
+                       cx25840_write(client, 0x47f, vbi_offset);
+                       cx25840_write(client, 0x404, 0x2e);
+                       break;
+               }
+
+               for (x = 0; x <= 23; x++)
+                       lcr[x] = 0x00;
+
+               /* Setup VBI */
+               cx25840_vbi_setup(client);
+
+               /* Sliced VBI */
+               cx25840_write(client, 0x404, 0x36);     /* Ancillery data */
+               cx25840_write(client, 0x406, 0x13);
+               cx25840_write(client, 0x47f, vbi_offset);
+
+               if (is_pal) {
+                       for (i = 0; i <= 6; i++)
+                               svbi->service_lines[0][i] =
+                                       svbi->service_lines[1][i] = 0;
+               } else {
+                       for (i = 0; i <= 9; i++)
+                               svbi->service_lines[0][i] =
+                                       svbi->service_lines[1][i] = 0;
+
+                       for (i = 22; i <= 23; i++)
+                               svbi->service_lines[0][i] =
+                                       svbi->service_lines[1][i] = 0;
+               }
+
+               for (i = 7; i <= 23; i++) {
+                       for (x = 0; x <= 1; x++) {
+                               switch (svbi->service_lines[1-x][i]) {
+                               case V4L2_SLICED_TELETEXT_B:
+                                       lcr[i] |= 1 << (4 * x);
+                                       break;
+                               case V4L2_SLICED_WSS_625:
+                                       lcr[i] |= 4 << (4 * x);
+                                       break;
+                               case V4L2_SLICED_CAPTION_525:
+                                       lcr[i] |= 6 << (4 * x);
+                                       break;
+                               case V4L2_SLICED_VPS:
+                                       lcr[i] |= 9 << (4 * x);
+                                       break;
+                               }
+                       }
+               }
+
+               for (x = 1, i = 0x424; i <= 0x434; i++, x++) {
+                       cx25840_write(client, i, lcr[6 + x]);
+               }
+
+               cx25840_write(client, 0x43c, 0x16);
+
+               if (is_pal) {
+                       cx25840_write(client, 0x474, 0x2a);
+               } else {
+                       cx25840_write(client, 0x474, 0x1a + 6);
+               }
+               break;
+       }
+
+       case VIDIOC_INT_DECODE_VBI_LINE:
+       {
+               struct v4l2_decode_vbi_line *vbi = arg;
+               u8 *p = vbi->p;
+               int id1, id2, l, err = 0;
+
+               if (p[0] || p[1] != 0xff || p[2] != 0xff ||
+                   (p[3] != 0x55 && p[3] != 0x91)) {
+                       vbi->line = vbi->type = 0;
+                       break;
+               }
+
+               p += 4;
+               id1 = p[-1];
+               id2 = p[0] & 0xf;
+               l = p[2] & 0x3f;
+               l += 5;
+               p += 4;
+
+               switch (id2) {
+               case 1:
+                       id2 = V4L2_SLICED_TELETEXT_B;
+                       break;
+               case 4:
+                       id2 = V4L2_SLICED_WSS_625;
+                       break;
+               case 6:
+                       id2 = V4L2_SLICED_CAPTION_525;
+                       err = !odd_parity(p[0]) || !odd_parity(p[1]);
+                       break;
+               case 9:
+                       id2 = V4L2_SLICED_VPS;
+                       if (decode_vps(p, p) != 0) {
+                               err = 1;
+                       }
+                       break;
+               default:
+                       id2 = 0;
+                       err = 1;
+                       break;
+               }
+
+               vbi->type = err ? 0 : id2;
+               vbi->line = err ? 0 : l;
+               vbi->is_second_field = err ? 0 : (id1 == 0x55);
+               vbi->p = p;
+               break;
+       }
+       }
+
+       return 0;
+}
diff --git a/drivers/media/video/cx25840/cx25840.h b/drivers/media/video/cx25840/cx25840.h
new file mode 100644 (file)
index 0000000..5c3f063
--- /dev/null
@@ -0,0 +1,85 @@
+/* cx25840 API header
+ *
+ * Copyright (C) 2003-2004 Chris Kennedy
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#ifndef _CX25840_H_
+#define _CX25840_H_
+
+
+#include <linux/videodev2.h>
+#include <linux/i2c.h>
+
+extern int cx25840_debug;
+
+#define cx25840_dbg(fmt, arg...) do { if (cx25840_debug) \
+       printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \
+              i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
+
+#define cx25840_err(fmt, arg...) do { \
+       printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \
+              i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
+
+#define cx25840_info(fmt, arg...) do { \
+       printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \
+              i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
+
+#define CX25840_CID_CARDTYPE (V4L2_CID_PRIVATE_BASE+0)
+
+enum cx25840_cardtype {
+       CARDTYPE_PVR150,
+       CARDTYPE_PG600
+};
+
+enum cx25840_input {
+       CX25840_TUNER,
+       CX25840_COMPOSITE0,
+       CX25840_COMPOSITE1,
+       CX25840_SVIDEO0,
+       CX25840_SVIDEO1
+};
+
+struct cx25840_state {
+       enum cx25840_cardtype cardtype;
+       enum cx25840_input input;
+       int audio_input;
+       enum v4l2_audio_clock_freq audclk_freq;
+};
+
+/* ----------------------------------------------------------------------- */
+/* cx25850-core.c                                                         */
+int cx25840_write(struct i2c_client *client, u16 addr, u8 value);
+int cx25840_write4(struct i2c_client *client, u16 addr, u32 value);
+u8 cx25840_read(struct i2c_client *client, u16 addr);
+u32 cx25840_read4(struct i2c_client *client, u16 addr);
+int cx25840_and_or(struct i2c_client *client, u16 addr, u8 mask, u8 value);
+v4l2_std_id cx25840_get_v4lstd(struct i2c_client *client);
+
+/* ----------------------------------------------------------------------- */
+/* cx25850-firmware.c                                                      */
+int cx25840_loadfw(struct i2c_client *client);
+
+/* ----------------------------------------------------------------------- */
+/* cx25850-audio.c                                                         */
+int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg);
+
+/* ----------------------------------------------------------------------- */
+/* cx25850-vbi.c                                                           */
+void cx25840_vbi_setup(struct i2c_client *client);
+int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg);
+
+#endif
index 9cce91ec334be22dea666fd84bf8903a78e1c97b..99ea955f5987c058a50dabacee8b2377c3fbc75a 100644 (file)
@@ -439,9 +439,6 @@ static int dvb_register(struct cx8802_dev *dev)
        /* Put the analog decoder in standby to keep it quiet */
        cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
 
-       /* Put the analog decoder in standby to keep it quiet */
-       cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
-
        /* register everything */
        return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev);
 }
index 32c49df58adc14c73c304c53adce2af78a8ca78d..9b94f77d6fd731f8926754562a8bbbd6e3e83d6a 100644 (file)
@@ -120,9 +120,6 @@ static int get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
        if (buf[1]==0xff)
                return 0;
 
-       /* avoid fast reapeating */
-       if (buf[1]==ir->old)
-               return 0;
        ir->old=buf[1];
 
        /* Rearranges bits to the right order */
index ed81934ef3cdde8b9fa9b5ab27bf613c73817f12..5abfc0fbf6de984b6473b990afd5a6ac9280fb66 100644 (file)
@@ -221,24 +221,99 @@ static IR_KEYTAB_TYPE ir_codes_conceptronic[IR_KEYTAB_SIZE] = {
        [ 24 ] = KEY_MUTE         // mute/unmute
 };
 
+static IR_KEYTAB_TYPE ir_codes_nebula[IR_KEYTAB_SIZE] = {
+       [0x00] = KEY_KP0,
+       [0x01] = KEY_KP1,
+       [0x02] = KEY_KP2,
+       [0x03] = KEY_KP3,
+       [0x04] = KEY_KP4,
+       [0x05] = KEY_KP5,
+       [0x06] = KEY_KP6,
+       [0x07] = KEY_KP7,
+       [0x08] = KEY_KP8,
+       [0x09] = KEY_KP9,
+       [0x0a] = KEY_TV,
+       [0x0b] = KEY_AUX,
+       [0x0c] = KEY_DVD,
+       [0x0d] = KEY_POWER,
+       [0x0e] = KEY_MHP,       /* labelled 'Picture' */
+       [0x0f] = KEY_AUDIO,
+       [0x10] = KEY_INFO,
+       [0x11] = KEY_F13,       /* 16:9 */
+       [0x12] = KEY_F14,       /* 14:9 */
+       [0x13] = KEY_EPG,
+       [0x14] = KEY_EXIT,
+       [0x15] = KEY_MENU,
+       [0x16] = KEY_UP,
+       [0x17] = KEY_DOWN,
+       [0x18] = KEY_LEFT,
+       [0x19] = KEY_RIGHT,
+       [0x1a] = KEY_ENTER,
+       [0x1b] = KEY_CHANNELUP,
+       [0x1c] = KEY_CHANNELDOWN,
+       [0x1d] = KEY_VOLUMEUP,
+       [0x1e] = KEY_VOLUMEDOWN,
+       [0x1f] = KEY_RED,
+       [0x20] = KEY_GREEN,
+       [0x21] = KEY_YELLOW,
+       [0x22] = KEY_BLUE,
+       [0x23] = KEY_SUBTITLE,
+       [0x24] = KEY_F15,       /* AD */
+       [0x25] = KEY_TEXT,
+       [0x26] = KEY_MUTE,
+       [0x27] = KEY_REWIND,
+       [0x28] = KEY_STOP,
+       [0x29] = KEY_PLAY,
+       [0x2a] = KEY_FASTFORWARD,
+       [0x2b] = KEY_F16,       /* chapter */
+       [0x2c] = KEY_PAUSE,
+       [0x2d] = KEY_PLAY,
+       [0x2e] = KEY_RECORD,
+       [0x2f] = KEY_F17,       /* picture in picture */
+       [0x30] = KEY_KPPLUS,    /* zoom in */
+       [0x31] = KEY_KPMINUS,   /* zoom out */
+       [0x32] = KEY_F18,       /* capture */
+       [0x33] = KEY_F19,       /* web */
+       [0x34] = KEY_EMAIL,
+       [0x35] = KEY_PHONE,
+       [0x36] = KEY_PC
+};
+
 struct IR {
        struct bttv_sub_device  *sub;
        struct input_dev        *input;
        struct ir_input_state   ir;
        char                    name[32];
        char                    phys[32];
+
+       /* Usual gpio signalling */
+
        u32                     mask_keycode;
        u32                     mask_keydown;
        u32                     mask_keyup;
-
-       int                     polling;
+       u32                     polling;
        u32                     last_gpio;
        struct work_struct      work;
        struct timer_list       timer;
+
+       /* RC5 gpio */
+
+       u32 rc5_gpio;
+       struct timer_list timer_end;    /* timer_end for code completion */
+       struct timer_list timer_keyup;  /* timer_end for key release */
+       u32 last_rc5;                   /* last good rc5 code */
+       u32 last_bit;                   /* last raw bit seen */
+       u32 code;                       /* raw code under construction */
+       struct timeval base_time;       /* time of last seen code */
+       int active;                     /* building raw code */
 };
 
 static int debug;
 module_param(debug, int, 0644);    /* debug level (0,1,2) */
+static int repeat_delay = 500;
+module_param(repeat_delay, int, 0644);
+static int repeat_period = 33;
+module_param(repeat_period, int, 0644);
 
 #define DEVNAME "ir-kbd-gpio"
 #define dprintk(fmt, arg...)   if (debug) \
@@ -254,7 +329,7 @@ static struct bttv_sub_driver driver = {
                .probe  = ir_probe,
                .remove = ir_remove,
        },
-       .gpio_irq       = ir_irq,
+       .gpio_irq       = ir_irq,
 };
 
 /* ---------------------------------------------------------------------- */
@@ -327,6 +402,173 @@ static void ir_work(void *data)
        mod_timer(&ir->timer, timeout);
 }
 
+/* ---------------------------------------------------------------*/
+
+static int rc5_remote_gap = 885;
+module_param(rc5_remote_gap, int, 0644);
+static int rc5_key_timeout = 200;
+module_param(rc5_key_timeout, int, 0644);
+
+#define RC5_START(x)   (((x)>>12)&3)
+#define RC5_TOGGLE(x)  (((x)>>11)&1)
+#define RC5_ADDR(x)    (((x)>>6)&31)
+#define RC5_INSTR(x)   ((x)&63)
+
+/* decode raw bit pattern to RC5 code */
+static u32 rc5_decode(unsigned int code)
+{
+       unsigned int org_code = code;
+       unsigned int pair;
+       unsigned int rc5 = 0;
+       int i;
+
+       code = (code << 1) | 1;
+       for (i = 0; i < 14; ++i) {
+               pair = code & 0x3;
+               code >>= 2;
+
+               rc5 <<= 1;
+               switch (pair) {
+               case 0:
+               case 2:
+                       break;
+               case 1:
+                       rc5 |= 1;
+                       break;
+               case 3:
+                       dprintk("bad code: %x\n", org_code);
+                       return 0;
+               }
+       }
+       dprintk("code=%x, rc5=%x, start=%x, toggle=%x, address=%x, "
+               "instr=%x\n", rc5, org_code, RC5_START(rc5),
+               RC5_TOGGLE(rc5), RC5_ADDR(rc5), RC5_INSTR(rc5));
+       return rc5;
+}
+
+static int ir_rc5_irq(struct bttv_sub_device *sub)
+{
+       struct IR *ir = dev_get_drvdata(&sub->dev);
+       struct timeval tv;
+       u32 gpio;
+       u32 gap;
+       unsigned long current_jiffies, timeout;
+
+       /* read gpio port */
+       gpio = bttv_gpio_read(ir->sub->core);
+
+       /* remote IRQ? */
+       if (!(gpio & 0x20))
+               return 0;
+
+       /* get time of bit */
+       current_jiffies = jiffies;
+       do_gettimeofday(&tv);
+
+       /* avoid overflow with gap >1s */
+       if (tv.tv_sec - ir->base_time.tv_sec > 1) {
+               gap = 200000;
+       } else {
+               gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) +
+                   tv.tv_usec - ir->base_time.tv_usec;
+       }
+
+       /* active code => add bit */
+       if (ir->active) {
+               /* only if in the code (otherwise spurious IRQ or timer
+                  late) */
+               if (ir->last_bit < 28) {
+                       ir->last_bit = (gap - rc5_remote_gap / 2) /
+                           rc5_remote_gap;
+                       ir->code |= 1 << ir->last_bit;
+               }
+               /* starting new code */
+       } else {
+               ir->active = 1;
+               ir->code = 0;
+               ir->base_time = tv;
+               ir->last_bit = 0;
+
+               timeout = current_jiffies + (500 + 30 * HZ) / 1000;
+               mod_timer(&ir->timer_end, timeout);
+       }
+
+       /* toggle GPIO pin 4 to reset the irq */
+       bttv_gpio_write(ir->sub->core, gpio & ~(1 << 4));
+       bttv_gpio_write(ir->sub->core, gpio | (1 << 4));
+       return 1;
+}
+
+static void ir_rc5_timer_end(unsigned long data)
+{
+       struct IR *ir = (struct IR *)data;
+       struct timeval tv;
+       unsigned long current_jiffies, timeout;
+       u32 gap;
+
+       /* get time */
+       current_jiffies = jiffies;
+       do_gettimeofday(&tv);
+
+       /* avoid overflow with gap >1s */
+       if (tv.tv_sec - ir->base_time.tv_sec > 1) {
+               gap = 200000;
+       } else {
+               gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) +
+                   tv.tv_usec - ir->base_time.tv_usec;
+       }
+
+       /* Allow some timmer jitter (RC5 is ~24ms anyway so this is ok) */
+       if (gap < 28000) {
+               dprintk("spurious timer_end\n");
+               return;
+       }
+
+       ir->active = 0;
+       if (ir->last_bit < 20) {
+               /* ignore spurious codes (caused by light/other remotes) */
+               dprintk("short code: %x\n", ir->code);
+       } else {
+               u32 rc5 = rc5_decode(ir->code);
+
+               /* two start bits? */
+               if (RC5_START(rc5) != 3) {
+                       dprintk("rc5 start bits invalid: %u\n", RC5_START(rc5));
+
+                       /* right address? */
+               } else if (RC5_ADDR(rc5) == 0x0) {
+                       u32 toggle = RC5_TOGGLE(rc5);
+                       u32 instr = RC5_INSTR(rc5);
+
+                       /* Good code, decide if repeat/repress */
+                       if (toggle != RC5_TOGGLE(ir->last_rc5) ||
+                           instr != RC5_INSTR(ir->last_rc5)) {
+                               dprintk("instruction %x, toggle %x\n", instr,
+                                       toggle);
+                               ir_input_nokey(ir->input, &ir->ir);
+                               ir_input_keydown(ir->input, &ir->ir, instr,
+                                                instr);
+                       }
+
+                       /* Set/reset key-up timer */
+                       timeout = current_jiffies + (500 + rc5_key_timeout
+                                                    * HZ) / 1000;
+                       mod_timer(&ir->timer_keyup, timeout);
+
+                       /* Save code for repeat test */
+                       ir->last_rc5 = rc5;
+               }
+       }
+}
+
+static void ir_rc5_timer_keyup(unsigned long data)
+{
+       struct IR *ir = (struct IR *)data;
+
+       dprintk("key released\n");
+       ir_input_nokey(ir->input, &ir->ir);
+}
+
 /* ---------------------------------------------------------------------- */
 
 static int ir_probe(struct device *dev)
@@ -400,6 +642,12 @@ static int ir_probe(struct device *dev)
                ir->mask_keyup   = 0x006000;
                ir->polling      = 50; // ms
                break;
+       case BTTV_BOARD_NEBULA_DIGITV:
+               ir_codes = ir_codes_nebula;
+               driver.any_irq = ir_rc5_irq;
+               driver.gpio_irq = NULL;
+               ir->rc5_gpio = 1;
+                break;
        }
        if (NULL == ir_codes) {
                kfree(ir);
@@ -407,9 +655,17 @@ static int ir_probe(struct device *dev)
                return -ENODEV;
        }
 
-       /* init hardware-specific stuff */
-       bttv_gpio_inout(sub->core, ir->mask_keycode | ir->mask_keydown, 0);
-       ir->sub = sub;
+       if (ir->rc5_gpio) {
+               u32 gpio;
+               /* enable remote irq */
+               bttv_gpio_inout(sub->core, (1 << 4), 1 << 4);
+               gpio = bttv_gpio_read(sub->core);
+               bttv_gpio_write(sub->core, gpio & ~(1 << 4));
+               bttv_gpio_write(sub->core, gpio | (1 << 4));
+       } else {
+               /* init hardware-specific stuff */
+               bttv_gpio_inout(sub->core, ir->mask_keycode | ir->mask_keydown, 0);
+       }
 
        /* init input device */
        snprintf(ir->name, sizeof(ir->name), "bttv IR (card=%d)",
@@ -417,6 +673,7 @@ static int ir_probe(struct device *dev)
        snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
                 pci_name(sub->core->pci));
 
+       ir->sub = sub;
        ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
        input_dev->name = ir->name;
        input_dev->phys = ir->phys;
@@ -437,11 +694,25 @@ static int ir_probe(struct device *dev)
                ir->timer.function = ir_timer;
                ir->timer.data     = (unsigned long)ir;
                schedule_work(&ir->work);
+       } else if (ir->rc5_gpio) {
+               /* set timer_end for code completion */
+               init_timer(&ir->timer_end);
+               ir->timer_end.function = ir_rc5_timer_end;
+               ir->timer_end.data = (unsigned long)ir;
+
+               init_timer(&ir->timer_keyup);
+               ir->timer_keyup.function = ir_rc5_timer_keyup;
+               ir->timer_keyup.data = (unsigned long)ir;
        }
 
        /* all done */
        dev_set_drvdata(dev, ir);
        input_register_device(ir->input);
+       printk(DEVNAME ": %s detected at %s\n",ir->name,ir->phys);
+
+       /* the remote isn't as bouncy as a keyboard */
+       ir->input->rep[REP_DELAY] = repeat_delay;
+       ir->input->rep[REP_PERIOD] = repeat_period;
 
        return 0;
 }
@@ -454,6 +725,15 @@ static int ir_remove(struct device *dev)
                del_timer(&ir->timer);
                flush_scheduled_work();
        }
+       if (ir->rc5_gpio) {
+               u32 gpio;
+
+               del_timer(&ir->timer_end);
+               flush_scheduled_work();
+
+               gpio = bttv_gpio_read(ir->sub->core);
+               bttv_gpio_write(ir->sub->core, gpio & ~(1 << 4));
+       }
 
        input_unregister_device(ir->input);
        kfree(ir);
index 0085567a1421d3fb5c06b145b0c302ec96a05895..801c736e9328a5c1368db10b7bd4318d4b738525 100644 (file)
@@ -183,6 +183,58 @@ static int get_key_knc1(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
        return 1;
 }
 
+/* The new pinnacle PCTV remote (with the colored buttons)
+ *
+ * Ricardo Cerqueira <v4l@cerqueira.org>
+ */
+
+int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
+{
+       unsigned char b[4];
+       unsigned int start = 0,parity = 0,code = 0;
+
+       /* poll IR chip */
+       if (4 != i2c_master_recv(&ir->c,b,4)) {
+               dprintk(2,"read error\n");
+               return -EIO;
+       }
+
+       for (start = 0; start<4; start++) {
+               if (b[start] == 0x80) {
+                       code=b[(start+3)%4];
+                       parity=b[(start+2)%4];
+               }
+       }
+
+       /* Empty Request */
+       if (parity==0)
+               return 0;
+
+       /* Repeating... */
+       if (ir->old == parity)
+               return 0;
+
+
+       ir->old = parity;
+
+       /* Reduce code value to fit inside IR_KEYTAB_SIZE
+        *
+        * this is the only value that results in 42 unique
+        * codes < 128
+        */
+
+       code %= 0x88;
+
+       *ir_raw = code;
+       *ir_key = code;
+
+       dprintk(1,"Pinnacle PCTV key %02x\n", code);
+
+       return 1;
+}
+
+EXPORT_SYMBOL_GPL(get_key_pinnacle);
+
 /* ----------------------------------------------------------------------- */
 
 static void ir_key_poll(struct IR_i2c *ir)
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
new file mode 100644 (file)
index 0000000..0235cef
--- /dev/null
@@ -0,0 +1,1376 @@
+/* saa7115 - Philips SAA7114/SAA7115 video decoder driver
+ *
+ * Based on saa7114 driver by Maxim Yevtyushkin, which is based on
+ * the saa7111 driver by Dave Perks.
+ *
+ * Copyright (C) 1998 Dave Perks <dperks@ibm.net>
+ * Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com>
+ *
+ * Slight changes for video timing and attachment output by
+ * Wolfgang Scherr <scherr@net4you.net>
+ *
+ * Moved over to the linux >= 2.4.x i2c protocol (1/1/2003)
+ * by Ronald Bultje <rbultje@ronald.bitfreak.net>
+ *
+ * Added saa7115 support by Kevin Thayer <nufan_wfk at yahoo.com>
+ * (2/17/2003)
+ *
+ * VBI support (2004) and cleanups (2005) by Hans Verkuil <hverkuil@xs4all.nl>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/videodev2.h>
+#include <media/v4l2-common.h>
+
+MODULE_DESCRIPTION("Philips SAA7114/SAA7115 video decoder driver");
+MODULE_AUTHOR("Maxim Yevtyushkin, Kevin Thayer, Chris Kennedy, Hans Verkuil");
+MODULE_LICENSE("GPL");
+
+static int debug = 0;
+module_param(debug, int, 0644);
+
+MODULE_PARM_DESC(debug, "Debug level (0-1)");
+
+#define saa7115_dbg(fmt,arg...) \
+       do { \
+               if (debug) \
+                       printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \
+                              i2c_adapter_id(client->adapter), client->addr , ## arg); \
+       } while (0)
+
+#define saa7115_err(fmt, arg...) do { \
+       printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \
+              i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
+#define saa7115_info(fmt, arg...) do { \
+       printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \
+              i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
+
+static unsigned short normal_i2c[] = { 0x42 >> 1, 0x40 >> 1, I2C_CLIENT_END };
+
+
+I2C_CLIENT_INSMOD;
+
+struct saa7115_state {
+       v4l2_std_id std;
+       int input;
+       int enable;
+       int bright;
+       int contrast;
+       int hue;
+       int sat;
+       enum v4l2_chip_ident ident;
+       enum v4l2_audio_clock_freq audclk_freq;
+};
+
+/* ----------------------------------------------------------------------- */
+
+static inline int saa7115_write(struct i2c_client *client, u8 reg, u8 value)
+{
+       return i2c_smbus_write_byte_data(client, reg, value);
+}
+
+static int saa7115_writeregs(struct i2c_client *client, const unsigned char *regs)
+{
+       unsigned char reg, data;
+
+       while (*regs != 0x00) {
+               reg = *(regs++);
+               data = *(regs++);
+               if (saa7115_write(client, reg, data) < 0)
+                       return -1;
+       }
+       return 0;
+}
+
+static inline int saa7115_read(struct i2c_client *client, u8 reg)
+{
+       return i2c_smbus_read_byte_data(client, reg);
+}
+
+/* ----------------------------------------------------------------------- */
+
+/* If a value differs from the Hauppauge driver values, then the comment starts with
+   'was 0xXX' to denote the Hauppauge value. Otherwise the value is identical to what the
+   Hauppauge driver sets. */
+
+static const unsigned char saa7115_init_auto_input[] = {
+       0x01, 0x48,             /* white peak control disabled */
+       0x03, 0x20,             /* was 0x30. 0x20: long vertical blanking */
+       0x04, 0x90,             /* analog gain set to 0 */
+       0x05, 0x90,             /* analog gain set to 0 */
+       0x06, 0xeb,             /* horiz sync begin = -21 */
+       0x07, 0xe0,             /* horiz sync stop = -17 */
+       0x0a, 0x80,             /* was 0x88. decoder brightness, 0x80 is itu standard */
+       0x0b, 0x44,             /* was 0x48. decoder contrast, 0x44 is itu standard */
+       0x0c, 0x40,             /* was 0x47. decoder saturation, 0x40 is itu standard */
+       0x0d, 0x00,             /* chrominance hue control */
+       0x0f, 0x00,             /* chrominance gain control: use automicatic mode */
+       0x10, 0x06,             /* chrominance/luminance control: active adaptive combfilter */
+       0x11, 0x00,             /* delay control */
+       0x12, 0x9d,             /* RTS0 output control: VGATE */
+       0x13, 0x80,             /* X-port output control: ITU656 standard mode, RTCO output enable RTCE */
+       0x14, 0x00,             /* analog/ADC/auto compatibility control */
+       0x18, 0x40,             /* raw data gain 0x00 = nominal */
+       0x19, 0x80,             /* raw data offset 0x80 = 0 LSB */
+       0x1a, 0x77,             /* color killer level control 0x77 = recommended */
+       0x1b, 0x42,             /* misc chroma control 0x42 = recommended */
+       0x1c, 0xa9,             /* combfilter control 0xA9 = recommended */
+       0x1d, 0x01,             /* combfilter control 0x01 = recommended */
+       0x88, 0xd0,             /* reset device */
+       0x88, 0xf0,             /* set device programmed, all in operational mode */
+       0x00, 0x00
+};
+
+static const unsigned char saa7115_cfg_reset_scaler[] = {
+       0x87, 0x00,             /* disable I-port output */
+       0x88, 0xd0,             /* reset scaler */
+       0x88, 0xf0,             /* activate scaler */
+       0x87, 0x01,             /* enable I-port output */
+       0x00, 0x00
+};
+
+/* ============== SAA7715 VIDEO templates =============  */
+
+static const unsigned char saa7115_cfg_60hz_fullres_x[] = {
+       0xcc, 0xd0,             /* hsize low (output), hor. output window size = 0x2d0 = 720 */
+       0xcd, 0x02,             /* hsize hi (output) */
+
+       /* Why not in 60hz-Land, too? */
+       0xd0, 0x01,             /* downscale = 1 */
+       0xd8, 0x00,             /* hor lum scaling 0x0400 = 1 */
+       0xd9, 0x04,
+       0xdc, 0x00,             /* hor chrom scaling 0x0200. must be hor lum scaling / 2 */
+       0xdd, 0x02,             /* H-scaling incr chroma */
+
+       0x00, 0x00
+};
+static const unsigned char saa7115_cfg_60hz_fullres_y[] = {
+       0xce, 0xf8,             /* vsize low (output), ver. output window size = 248 (but 60hz is 240?) */
+       0xcf, 0x00,             /* vsize hi (output) */
+
+       /* Why not in 60hz-Land, too? */
+       0xd5, 0x40,             /* Lum contrast, nominal value = 0x40 */
+       0xd6, 0x40,             /* Chroma satur. nominal value = 0x80 */
+
+       0xe0, 0x00,             /* V-scaling incr luma low */
+       0xe1, 0x04,             /* " hi */
+       0xe2, 0x00,             /* V-scaling incr chroma low */
+       0xe3, 0x04,             /* " hi */
+
+       0x00, 0x00
+};
+
+static const unsigned char saa7115_cfg_60hz_video[] = {
+       0x80, 0x00,             /* reset tasks */
+       0x88, 0xd0,             /* reset scaler */
+
+       0x15, 0x03,             /* VGATE pulse start */
+       0x16, 0x11,             /* VGATE pulse stop */
+       0x17, 0x9c,             /* VGATE MSB and other values */
+
+       0x08, 0x68,             /* 0xBO: auto detection, 0x68 = NTSC */
+       0x0e, 0x07,             /* lots of different stuff... video autodetection is on */
+
+       0x5a, 0x06,             /* Vertical offset, standard 60hz value for ITU656 line counting */
+
+       /* Task A */
+       0x90, 0x80,             /* Task Handling Control */
+       0x91, 0x48,             /* X-port formats/config */
+       0x92, 0x40,             /* Input Ref. signal Def. */
+       0x93, 0x84,             /* I-port config */
+       0x94, 0x01,             /* hoffset low (input), 0x0002 is minimum */
+       0x95, 0x00,             /* hoffset hi (input) */
+       0x96, 0xd0,             /* hsize low (input), 0x02d0 = 720 */
+       0x97, 0x02,             /* hsize hi (input) */
+       0x98, 0x05,             /* voffset low (input) */
+       0x99, 0x00,             /* voffset hi (input) */
+       0x9a, 0x0c,             /* vsize low (input), 0x0c = 12 */
+       0x9b, 0x00,             /* vsize hi (input) */
+       0x9c, 0xa0,             /* hsize low (output), 0x05a0 = 1440 */
+       0x9d, 0x05,             /* hsize hi (output) */
+       0x9e, 0x0c,             /* vsize low (output), 0x0c = 12 */
+       0x9f, 0x00,             /* vsize hi (output) */
+
+       /* Task B */
+       0xc0, 0x00,             /* Task Handling Control */
+       0xc1, 0x08,             /* X-port formats/config */
+       0xc2, 0x00,             /* Input Ref. signal Def. */
+       0xc3, 0x80,             /* I-port config */
+       0xc4, 0x02,             /* hoffset low (input), 0x0002 is minimum */
+       0xc5, 0x00,             /* hoffset hi (input) */
+       0xc6, 0xd0,             /* hsize low (input), 0x02d0 = 720 */
+       0xc7, 0x02,             /* hsize hi (input) */
+       0xc8, 0x12,             /* voffset low (input), 0x12 = 18 */
+       0xc9, 0x00,             /* voffset hi (input) */
+       0xca, 0xf8,             /* vsize low (input), 0xf8 = 248 */
+       0xcb, 0x00,             /* vsize hi (input) */
+       0xcc, 0xd0,             /* hsize low (output), 0x02d0 = 720 */
+       0xcd, 0x02,             /* hsize hi (output) */
+
+       0xf0, 0xad,             /* Set PLL Register. 60hz 525 lines per frame, 27 MHz */
+       0xf1, 0x05,             /* low bit with 0xF0 */
+       0xf5, 0xad,             /* Set pulse generator register */
+       0xf6, 0x01,
+
+       0x87, 0x00,             /* Disable I-port output */
+       0x88, 0xd0,             /* reset scaler */
+       0x80, 0x20,             /* Activate only task "B", continuous mode (was 0xA0) */
+       0x88, 0xf0,             /* activate scaler */
+       0x87, 0x01,             /* Enable I-port output */
+       0x00, 0x00
+};
+
+static const unsigned char saa7115_cfg_50hz_fullres_x[] = {
+       0xcc, 0xd0,             /* hsize low (output), 720 same as 60hz */
+       0xcd, 0x02,             /* hsize hi (output) */
+
+       0xd0, 0x01,             /* down scale = 1 */
+       0xd8, 0x00,             /* hor lum scaling 0x0400 = 1 */
+       0xd9, 0x04,
+       0xdc, 0x00,             /* hor chrom scaling 0x0200. must be hor lum scaling / 2 */
+       0xdd, 0x02,             /* H-scaling incr chroma */
+
+       0x00, 0x00
+};
+static const unsigned char saa7115_cfg_50hz_fullres_y[] = {
+       0xce, 0x20,             /* vsize low (output), 0x0120 = 288 */
+       0xcf, 0x01,             /* vsize hi (output) */
+
+       0xd5, 0x40,             /* Lum contrast, nominal value = 0x40 */
+       0xd6, 0x40,             /* Chroma satur. nominal value = 0x80 */
+
+       0xe0, 0x00,             /* V-scaling incr luma low */
+       0xe1, 0x04,             /* " hi */
+       0xe2, 0x00,             /* V-scaling incr chroma low */
+       0xe3, 0x04,             /* " hi */
+
+       0x00, 0x00
+};
+
+static const unsigned char saa7115_cfg_50hz_video[] = {
+       0x80, 0x00,             /* reset tasks */
+       0x88, 0xd0,             /* reset scaler */
+
+       0x15, 0x37,             /* VGATE start */
+       0x16, 0x16,             /* VGATE stop */
+       0x17, 0x99,             /* VGATE MSB and other values */
+
+       0x08, 0x28,             /* 0x28 = PAL */
+       0x0e, 0x07,             /* chrominance control 1 */
+
+       0x5a, 0x03,             /* Vertical offset, standard 50hz value */
+
+       /* Task A */
+       0x90, 0x81,             /* Task Handling Control */
+       0x91, 0x48,             /* X-port formats/config */
+       0x92, 0x40,             /* Input Ref. signal Def. */
+       0x93, 0x84,             /* I-port config */
+       /* This is weird: the datasheet says that you should use 2 as the minimum value, */
+       /* but Hauppauge uses 0, and changing that to 2 causes indeed problems (for 50hz) */
+       0x94, 0x00,             /* hoffset low (input), 0x0002 is minimum */
+       0x95, 0x00,             /* hoffset hi (input) */
+       0x96, 0xd0,             /* hsize low (input), 0x02d0 = 720 */
+       0x97, 0x02,             /* hsize hi (input) */
+       0x98, 0x03,             /* voffset low (input) */
+       0x99, 0x00,             /* voffset hi (input) */
+       0x9a, 0x12,             /* vsize low (input), 0x12 = 18 */
+       0x9b, 0x00,             /* vsize hi (input) */
+       0x9c, 0xa0,             /* hsize low (output), 0x05a0 = 1440 */
+       0x9d, 0x05,             /* hsize hi (output) */
+       0x9e, 0x12,             /* vsize low (output), 0x12 = 18 */
+       0x9f, 0x00,             /* vsize hi (output) */
+
+       /* Task B */
+       0xc0, 0x00,             /* Task Handling Control */
+       0xc1, 0x08,             /* X-port formats/config */
+       0xc2, 0x00,             /* Input Ref. signal Def. */
+       0xc3, 0x80,             /* I-port config */
+       0xc4, 0x00,             /* hoffset low (input), 0x0002 is minimum. See comment at 0x94 above. */
+       0xc5, 0x00,             /* hoffset hi (input) */
+       0xc6, 0xd0,             /* hsize low (input), 0x02d0 = 720 */
+       0xc7, 0x02,             /* hsize hi (input) */
+       0xc8, 0x16,             /* voffset low (input), 0x16 = 22 */
+       0xc9, 0x00,             /* voffset hi (input) */
+       0xca, 0x20,             /* vsize low (input), 0x0120 = 288 */
+       0xcb, 0x01,             /* vsize hi (input) */
+       0xcc, 0xd0,             /* hsize low (output), 0x02d0 = 720 */
+       0xcd, 0x02,             /* hsize hi (output) */
+       0xce, 0x20,             /* vsize low (output), 0x0120 = 288 */
+       0xcf, 0x01,             /* vsize hi (output) */
+
+       0xf0, 0xb0,             /* Set PLL Register. 50hz 625 lines per frame, 27 MHz */
+       0xf1, 0x05,             /* low bit with 0xF0, (was 0x05) */
+       0xf5, 0xb0,             /* Set pulse generator register */
+       0xf6, 0x01,
+
+       0x87, 0x00,             /* Disable I-port output */
+       0x88, 0xd0,             /* reset scaler (was 0xD0) */
+       0x80, 0x20,             /* Activate only task "B" */
+       0x88, 0xf0,             /* activate scaler */
+       0x87, 0x01,             /* Enable I-port output */
+       0x00, 0x00
+};
+
+/* ============== SAA7715 VIDEO templates (end) =======  */
+
+static const unsigned char saa7115_cfg_vbi_on[] = {
+       0x80, 0x00,             /* reset tasks */
+       0x88, 0xd0,             /* reset scaler */
+       0x80, 0x30,             /* Activate both tasks */
+       0x88, 0xf0,             /* activate scaler */
+       0x87, 0x01,             /* Enable I-port output */
+       0x00, 0x00
+};
+
+static const unsigned char saa7115_cfg_vbi_off[] = {
+       0x80, 0x00,             /* reset tasks */
+       0x88, 0xd0,             /* reset scaler */
+       0x80, 0x20,             /* Activate only task "B" */
+       0x88, 0xf0,             /* activate scaler */
+       0x87, 0x01,             /* Enable I-port output */
+       0x00, 0x00
+};
+
+static const unsigned char saa7115_init_misc[] = {
+       0x38, 0x03,             /* audio stuff */
+       0x39, 0x10,
+       0x3a, 0x08,
+
+       0x81, 0x01,             /* reg 0x15,0x16 define blanking window */
+       0x82, 0x00,
+       0x83, 0x01,             /* I port settings */
+       0x84, 0x20,
+       0x85, 0x21,
+       0x86, 0xc5,
+       0x87, 0x01,
+
+       /* Task A */
+       0xa0, 0x01,             /* down scale = 1 */
+       0xa1, 0x00,             /* prescale accumulation length = 1 */
+       0xa2, 0x00,             /* dc gain and fir prefilter control */
+       0xa4, 0x80,             /* Lum Brightness, nominal value = 0x80 */
+       0xa5, 0x40,             /* Lum contrast, nominal value = 0x40 */
+       0xa6, 0x40,             /* Chroma satur. nominal value = 0x80 */
+       0xa8, 0x00,             /* hor lum scaling 0x0200 = 2 zoom */
+       0xa9, 0x02,             /* note: 2 x zoom ensures that VBI lines have same length as video lines. */
+       0xaa, 0x00,             /* H-phase offset Luma = 0 */
+       0xac, 0x00,             /* hor chrom scaling 0x0200. must be hor lum scaling / 2 */
+       0xad, 0x01,             /* H-scaling incr chroma */
+       0xae, 0x00,             /* H-phase offset chroma. must be offset luma / 2 */
+
+       0xb0, 0x00,             /* V-scaling incr luma low */
+       0xb1, 0x04,             /* " hi */
+       0xb2, 0x00,             /* V-scaling incr chroma low */
+       0xb3, 0x04,             /* " hi */
+       0xb4, 0x01,             /* V-scaling mode control */
+       0xb8, 0x00,             /* V-phase offset chroma 00 */
+       0xb9, 0x00,             /* V-phase offset chroma 01 */
+       0xba, 0x00,             /* V-phase offset chroma 10 */
+       0xbb, 0x00,             /* V-phase offset chroma 11 */
+       0xbc, 0x00,             /* V-phase offset luma 00 */
+       0xbd, 0x00,             /* V-phase offset luma 01 */
+       0xbe, 0x00,             /* V-phase offset luma 10 */
+       0xbf, 0x00,             /* V-phase offset luma 11 */
+
+       /* Task B */
+       0xd0, 0x01,             /* down scale = 1 */
+       0xd1, 0x00,             /* prescale accumulation length = 1 */
+       0xd2, 0x00,             /* dc gain and fir prefilter control */
+       0xd4, 0x80,             /* Lum Brightness, nominal value = 0x80 */
+       0xd5, 0x40,             /* Lum contrast, nominal value = 0x40 */
+       0xd6, 0x40,             /* Chroma satur. nominal value = 0x80 */
+       0xd8, 0x00,             /* hor lum scaling 0x0400 = 1 */
+       0xd9, 0x04,
+       0xda, 0x00,             /* H-phase offset Luma = 0 */
+       0xdc, 0x00,             /* hor chrom scaling 0x0200. must be hor lum scaling / 2 */
+       0xdd, 0x02,             /* H-scaling incr chroma */
+       0xde, 0x00,             /* H-phase offset chroma. must be offset luma / 2 */
+
+       0xe0, 0x00,             /* V-scaling incr luma low */
+       0xe1, 0x04,             /* " hi */
+       0xe2, 0x00,             /* V-scaling incr chroma low */
+       0xe3, 0x04,             /* " hi */
+       0xe4, 0x01,             /* V-scaling mode control */
+       0xe8, 0x00,             /* V-phase offset chroma 00 */
+       0xe9, 0x00,             /* V-phase offset chroma 01 */
+       0xea, 0x00,             /* V-phase offset chroma 10 */
+       0xeb, 0x00,             /* V-phase offset chroma 11 */
+       0xec, 0x00,             /* V-phase offset luma 00 */
+       0xed, 0x00,             /* V-phase offset luma 01 */
+       0xee, 0x00,             /* V-phase offset luma 10 */
+       0xef, 0x00,             /* V-phase offset luma 11 */
+
+       0xf2, 0x50,             /* crystal clock = 24.576 MHz, target = 27MHz */
+       0xf3, 0x46,
+       0xf4, 0x00,
+       0xf7, 0x4b,             /* not the recommended settings! */
+       0xf8, 0x00,
+       0xf9, 0x4b,
+       0xfa, 0x00,
+       0xfb, 0x4b,
+       0xff, 0x88,             /* PLL2 lock detection settings: 71 lines 50% phase error */
+
+       /* Turn off VBI */
+       0x40, 0x20,             /* No framing code errors allowed. */
+       0x41, 0xff,
+       0x42, 0xff,
+       0x43, 0xff,
+       0x44, 0xff,
+       0x45, 0xff,
+       0x46, 0xff,
+       0x47, 0xff,
+       0x48, 0xff,
+       0x49, 0xff,
+       0x4a, 0xff,
+       0x4b, 0xff,
+       0x4c, 0xff,
+       0x4d, 0xff,
+       0x4e, 0xff,
+       0x4f, 0xff,
+       0x50, 0xff,
+       0x51, 0xff,
+       0x52, 0xff,
+       0x53, 0xff,
+       0x54, 0xff,
+       0x55, 0xff,
+       0x56, 0xff,
+       0x57, 0xff,
+       0x58, 0x40,
+       0x59, 0x47,
+       0x5b, 0x83,
+       0x5d, 0xbd,
+       0x5e, 0x35,
+
+       0x02, 0x84,             /* input tuner -> input 4, amplifier active */
+       0x09, 0x53,             /* 0x53, was 0x56 for 60hz. luminance control */
+
+       0x80, 0x20,             /* enable task B */
+       0x88, 0xd0,
+       0x88, 0xf0,
+       0x00, 0x00
+};
+
+/* ============== SAA7715 AUDIO settings ============= */
+
+/* 48.0 kHz */
+static const unsigned char saa7115_cfg_48_audio[] = {
+       0x34, 0xce,
+       0x35, 0xfb,
+       0x36, 0x30,
+       0x00, 0x00
+};
+
+/* 44.1 kHz */
+static const unsigned char saa7115_cfg_441_audio[] = {
+       0x34, 0xf2,
+       0x35, 0x00,
+       0x36, 0x2d,
+       0x00, 0x00
+};
+
+/* 32.0 kHz */
+static const unsigned char saa7115_cfg_32_audio[] = {
+       0x34, 0xdf,
+       0x35, 0xa7,
+       0x36, 0x20,
+       0x00, 0x00
+};
+
+/* 48.0 kHz 60hz */
+static const unsigned char saa7115_cfg_60hz_48_audio[] = {
+       0x30, 0xcd,
+       0x31, 0x20,
+       0x32, 0x03,
+       0x00, 0x00
+};
+
+/* 48.0 kHz 50hz */
+static const unsigned char saa7115_cfg_50hz_48_audio[] = {
+       0x30, 0x00,
+       0x31, 0xc0,
+       0x32, 0x03,
+       0x00, 0x00
+};
+
+/* 44.1 kHz 60hz */
+static const unsigned char saa7115_cfg_60hz_441_audio[] = {
+       0x30, 0xbc,
+       0x31, 0xdf,
+       0x32, 0x02,
+       0x00, 0x00
+};
+
+/* 44.1 kHz 50hz */
+static const unsigned char saa7115_cfg_50hz_441_audio[] = {
+       0x30, 0x00,
+       0x31, 0x72,
+       0x32, 0x03,
+       0x00, 0x00
+};
+
+/* 32.0 kHz 60hz */
+static const unsigned char saa7115_cfg_60hz_32_audio[] = {
+       0x30, 0xde,
+       0x31, 0x15,
+       0x32, 0x02,
+       0x00, 0x00
+};
+
+/* 32.0 kHz 50hz */
+static const unsigned char saa7115_cfg_50hz_32_audio[] = {
+       0x30, 0x00,
+       0x31, 0x80,
+       0x32, 0x02,
+       0x00, 0x00
+};
+
+static int saa7115_odd_parity(u8 c)
+{
+       c ^= (c >> 4);
+       c ^= (c >> 2);
+       c ^= (c >> 1);
+
+       return c & 1;
+}
+
+static int saa7115_decode_vps(u8 * dst, u8 * p)
+{
+       static const u8 biphase_tbl[] = {
+               0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
+               0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0,
+               0xd2, 0x5a, 0x52, 0xd2, 0x96, 0x1e, 0x16, 0x96,
+               0x92, 0x1a, 0x12, 0x92, 0xd2, 0x5a, 0x52, 0xd2,
+               0xd0, 0x58, 0x50, 0xd0, 0x94, 0x1c, 0x14, 0x94,
+               0x90, 0x18, 0x10, 0x90, 0xd0, 0x58, 0x50, 0xd0,
+               0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
+               0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0,
+               0xe1, 0x69, 0x61, 0xe1, 0xa5, 0x2d, 0x25, 0xa5,
+               0xa1, 0x29, 0x21, 0xa1, 0xe1, 0x69, 0x61, 0xe1,
+               0xc3, 0x4b, 0x43, 0xc3, 0x87, 0x0f, 0x07, 0x87,
+               0x83, 0x0b, 0x03, 0x83, 0xc3, 0x4b, 0x43, 0xc3,
+               0xc1, 0x49, 0x41, 0xc1, 0x85, 0x0d, 0x05, 0x85,
+               0x81, 0x09, 0x01, 0x81, 0xc1, 0x49, 0x41, 0xc1,
+               0xe1, 0x69, 0x61, 0xe1, 0xa5, 0x2d, 0x25, 0xa5,
+               0xa1, 0x29, 0x21, 0xa1, 0xe1, 0x69, 0x61, 0xe1,
+               0xe0, 0x68, 0x60, 0xe0, 0xa4, 0x2c, 0x24, 0xa4,
+               0xa0, 0x28, 0x20, 0xa0, 0xe0, 0x68, 0x60, 0xe0,
+               0xc2, 0x4a, 0x42, 0xc2, 0x86, 0x0e, 0x06, 0x86,
+               0x82, 0x0a, 0x02, 0x82, 0xc2, 0x4a, 0x42, 0xc2,
+               0xc0, 0x48, 0x40, 0xc0, 0x84, 0x0c, 0x04, 0x84,
+               0x80, 0x08, 0x00, 0x80, 0xc0, 0x48, 0x40, 0xc0,
+               0xe0, 0x68, 0x60, 0xe0, 0xa4, 0x2c, 0x24, 0xa4,
+               0xa0, 0x28, 0x20, 0xa0, 0xe0, 0x68, 0x60, 0xe0,
+               0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
+               0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0,
+               0xd2, 0x5a, 0x52, 0xd2, 0x96, 0x1e, 0x16, 0x96,
+               0x92, 0x1a, 0x12, 0x92, 0xd2, 0x5a, 0x52, 0xd2,
+               0xd0, 0x58, 0x50, 0xd0, 0x94, 0x1c, 0x14, 0x94,
+               0x90, 0x18, 0x10, 0x90, 0xd0, 0x58, 0x50, 0xd0,
+               0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
+               0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0,
+       };
+       int i;
+       u8 c, err = 0;
+
+       for (i = 0; i < 2 * 13; i += 2) {
+               err |= biphase_tbl[p[i]] | biphase_tbl[p[i + 1]];
+               c = (biphase_tbl[p[i + 1]] & 0xf) | ((biphase_tbl[p[i]] & 0xf) << 4);
+               dst[i / 2] = c;
+       }
+       return err & 0xf0;
+}
+
+static int saa7115_decode_wss(u8 * p)
+{
+       static const int wss_bits[8] = {
+               0, 0, 0, 1, 0, 1, 1, 1
+       };
+       unsigned char parity;
+       int wss = 0;
+       int i;
+
+       for (i = 0; i < 16; i++) {
+               int b1 = wss_bits[p[i] & 7];
+               int b2 = wss_bits[(p[i] >> 3) & 7];
+
+               if (b1 == b2)
+                       return -1;
+               wss |= b2 << i;
+       }
+       parity = wss & 15;
+       parity ^= parity >> 2;
+       parity ^= parity >> 1;
+
+       if (!(parity & 1))
+               return -1;
+
+       return wss;
+}
+
+
+static int saa7115_set_audio_clock_freq(struct i2c_client *client, enum v4l2_audio_clock_freq freq)
+{
+       struct saa7115_state *state = i2c_get_clientdata(client);
+
+       saa7115_dbg("set audio clock freq: %d\n", freq);
+       switch (freq) {
+               case V4L2_AUDCLK_32_KHZ:
+                       saa7115_writeregs(client, saa7115_cfg_32_audio);
+                       if (state->std & V4L2_STD_525_60) {
+                               saa7115_writeregs(client, saa7115_cfg_60hz_32_audio);
+                       } else {
+                               saa7115_writeregs(client, saa7115_cfg_50hz_32_audio);
+                       }
+                       break;
+               case V4L2_AUDCLK_441_KHZ:
+                       saa7115_writeregs(client, saa7115_cfg_441_audio);
+                       if (state->std & V4L2_STD_525_60) {
+                               saa7115_writeregs(client, saa7115_cfg_60hz_441_audio);
+                       } else {
+                               saa7115_writeregs(client, saa7115_cfg_50hz_441_audio);
+                       }
+                       break;
+               case V4L2_AUDCLK_48_KHZ:
+                       saa7115_writeregs(client, saa7115_cfg_48_audio);
+                       if (state->std & V4L2_STD_525_60) {
+                               saa7115_writeregs(client, saa7115_cfg_60hz_48_audio);
+                       } else {
+                               saa7115_writeregs(client, saa7115_cfg_50hz_48_audio);
+                       }
+                       break;
+               default:
+                       saa7115_dbg("invalid audio setting %d\n", freq);
+                       return -EINVAL;
+       }
+       state->audclk_freq = freq;
+       return 0;
+}
+
+static int saa7115_set_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl)
+{
+       struct saa7115_state *state = i2c_get_clientdata(client);
+
+       switch (ctrl->id) {
+       case V4L2_CID_BRIGHTNESS:
+               if (ctrl->value < 0 || ctrl->value > 255) {
+                       saa7115_err("invalid brightness setting %d\n", ctrl->value);
+                       return -ERANGE;
+               }
+
+               state->bright = ctrl->value;
+               saa7115_write(client, 0x0a, state->bright);
+               break;
+
+       case V4L2_CID_CONTRAST:
+               if (ctrl->value < 0 || ctrl->value > 127) {
+                       saa7115_err("invalid contrast setting %d\n", ctrl->value);
+                       return -ERANGE;
+               }
+
+               state->contrast = ctrl->value;
+               saa7115_write(client, 0x0b, state->contrast);
+               break;
+
+       case V4L2_CID_SATURATION:
+               if (ctrl->value < 0 || ctrl->value > 127) {
+                       saa7115_err("invalid saturation setting %d\n", ctrl->value);
+                       return -ERANGE;
+               }
+
+               state->sat = ctrl->value;
+               saa7115_write(client, 0x0c, state->sat);
+               break;
+
+       case V4L2_CID_HUE:
+               if (ctrl->value < -127 || ctrl->value > 127) {
+                       saa7115_err("invalid hue setting %d\n", ctrl->value);
+                       return -ERANGE;
+               }
+
+               state->hue = ctrl->value;
+               saa7115_write(client, 0x0d, state->hue);
+               break;
+       }
+
+       return 0;
+}
+
+static int saa7115_get_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl)
+{
+       struct saa7115_state *state = i2c_get_clientdata(client);
+
+       switch (ctrl->id) {
+       case V4L2_CID_BRIGHTNESS:
+               ctrl->value = state->bright;
+               break;
+       case V4L2_CID_CONTRAST:
+               ctrl->value = state->contrast;
+               break;
+       case V4L2_CID_SATURATION:
+               ctrl->value = state->sat;
+               break;
+       case V4L2_CID_HUE:
+               ctrl->value = state->hue;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static void saa7115_set_v4lstd(struct i2c_client *client, v4l2_std_id std)
+{
+       struct saa7115_state *state = i2c_get_clientdata(client);
+       int taskb = saa7115_read(client, 0x80) & 0x10;
+
+       // This works for NTSC-M, SECAM-L and the 50Hz PAL variants.
+       if (std & V4L2_STD_525_60) {
+               saa7115_dbg("decoder set standard 60 Hz\n");
+               saa7115_writeregs(client, saa7115_cfg_60hz_video);
+       } else {
+               saa7115_dbg("decoder set standard 50 Hz\n");
+               saa7115_writeregs(client, saa7115_cfg_50hz_video);
+       }
+
+       state->std = std;
+
+       /* restart task B if needed */
+       if (taskb && state->ident == V4L2_IDENT_SAA7114) {
+               saa7115_writeregs(client, saa7115_cfg_vbi_on);
+       }
+
+       /* switch audio mode too! */
+       saa7115_set_audio_clock_freq(client, state->audclk_freq);
+}
+
+static v4l2_std_id saa7115_get_v4lstd(struct i2c_client *client)
+{
+       struct saa7115_state *state = i2c_get_clientdata(client);
+
+       return state->std;
+}
+
+static void saa7115_log_status(struct i2c_client *client)
+{
+       static const char * const audclk_freq_strs[] = {
+               "44.1 kHz",
+               "48 kHz",
+               "32 kHz"
+       };
+       struct saa7115_state *state = i2c_get_clientdata(client);
+       int reg1e, reg1f;
+       int signalOk;
+       int vcr;
+
+       saa7115_info("Audio frequency: %s\n", audclk_freq_strs[state->audclk_freq]);
+       if (client->name[6] == '4') {
+               /* status for the saa7114 */
+               reg1f = saa7115_read(client, 0x1f);
+               signalOk = (reg1f & 0xc1) == 0x81;
+               saa7115_info("Video signal:    %s\n", signalOk ? "ok" : "bad");
+               saa7115_info("Frequency:       %s\n", (reg1f & 0x20) ? "60Hz" : "50Hz");
+               return;
+       }
+
+       /* status for the saa7115 */
+       reg1e = saa7115_read(client, 0x1e);
+       reg1f = saa7115_read(client, 0x1f);
+
+       signalOk = (reg1f & 0xc1) == 0x81 && (reg1e & 0xc0) == 0x80;
+       vcr = !(reg1f & 0x10);
+
+       saa7115_info("Video signal:    %s\n", signalOk ? (vcr ? "VCR" : "broadcast/DVD") : "bad");
+       saa7115_info("Frequency:       %s\n", (reg1f & 0x20) ? "60Hz" : "50Hz");
+
+       switch (reg1e & 0x03) {
+               case 1:
+                       saa7115_info("Detected format: NTSC\n");
+                       break;
+               case 2:
+                       saa7115_info("Detected format: PAL\n");
+                       break;
+               case 3:
+                       saa7115_info("Detected format: SECAM\n");
+                       break;
+               default:
+                       saa7115_info("Detected format: BW/No color\n");
+                       break;
+       }
+}
+
+/* setup the sliced VBI lcr registers according to the sliced VBI format */
+static void saa7115_set_lcr(struct i2c_client *client, struct v4l2_sliced_vbi_format *fmt)
+{
+       struct saa7115_state *state = i2c_get_clientdata(client);
+       int is_50hz = (state->std & V4L2_STD_625_50);
+       u8 lcr[24];
+       int i, x;
+
+       /* saa7114 doesn't yet support VBI */
+       if (state->ident == V4L2_IDENT_SAA7114)
+               return;
+
+       for (i = 0; i <= 23; i++)
+               lcr[i] = 0xff;
+
+       if (fmt->service_set == 0) {
+               /* raw VBI */
+               if (is_50hz)
+                       for (i = 6; i <= 23; i++)
+                               lcr[i] = 0xdd;
+               else
+                       for (i = 10; i <= 21; i++)
+                               lcr[i] = 0xdd;
+       } else {
+               /* sliced VBI */
+               /* first clear lines that cannot be captured */
+               if (is_50hz) {
+                       for (i = 0; i <= 5; i++)
+                               fmt->service_lines[0][i] =
+                                       fmt->service_lines[1][i] = 0;
+               }
+               else {
+                       for (i = 0; i <= 9; i++)
+                               fmt->service_lines[0][i] =
+                                       fmt->service_lines[1][i] = 0;
+                       for (i = 22; i <= 23; i++)
+                               fmt->service_lines[0][i] =
+                                       fmt->service_lines[1][i] = 0;
+               }
+
+               /* Now set the lcr values according to the specified service */
+               for (i = 6; i <= 23; i++) {
+                       lcr[i] = 0;
+                       for (x = 0; x <= 1; x++) {
+                               switch (fmt->service_lines[1-x][i]) {
+                                       case 0:
+                                               lcr[i] |= 0xf << (4 * x);
+                                               break;
+                                       case V4L2_SLICED_TELETEXT_B:
+                                               lcr[i] |= 1 << (4 * x);
+                                               break;
+                                       case V4L2_SLICED_CAPTION_525:
+                                               lcr[i] |= 4 << (4 * x);
+                                               break;
+                                       case V4L2_SLICED_WSS_625:
+                                               lcr[i] |= 5 << (4 * x);
+                                               break;
+                                       case V4L2_SLICED_VPS:
+                                               lcr[i] |= 7 << (4 * x);
+                                               break;
+                               }
+                       }
+               }
+       }
+
+       /* write the lcr registers */
+       for (i = 2; i <= 23; i++) {
+               saa7115_write(client, i - 2 + 0x41, lcr[i]);
+       }
+
+       /* enable/disable raw VBI capturing */
+       saa7115_writeregs(client, fmt->service_set == 0 ? saa7115_cfg_vbi_on : saa7115_cfg_vbi_off);
+}
+
+static int saa7115_get_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
+{
+       static u16 lcr2vbi[] = {
+               0, V4L2_SLICED_TELETEXT_B, 0,   /* 1 */
+               0, V4L2_SLICED_CAPTION_525,     /* 4 */
+               V4L2_SLICED_WSS_625, 0,         /* 5 */
+               V4L2_SLICED_VPS, 0, 0, 0, 0,    /* 7 */
+               0, 0, 0, 0
+       };
+       struct v4l2_sliced_vbi_format *sliced = &fmt->fmt.sliced;
+       int i;
+
+       if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
+               return -EINVAL;
+       memset(sliced, 0, sizeof(*sliced));
+       /* done if using raw VBI */
+       if (saa7115_read(client, 0x80) & 0x10)
+               return 0;
+       for (i = 2; i <= 23; i++) {
+               u8 v = saa7115_read(client, i - 2 + 0x41);
+
+               sliced->service_lines[0][i] = lcr2vbi[v >> 4];
+               sliced->service_lines[1][i] = lcr2vbi[v & 0xf];
+               sliced->service_set |=
+                       sliced->service_lines[0][i] | sliced->service_lines[1][i];
+       }
+       return 0;
+}
+
+static int saa7115_set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
+{
+       struct saa7115_state *state = i2c_get_clientdata(client);
+       struct v4l2_pix_format *pix;
+       int HPSC, HFSC;
+       int VSCY, Vsrc;
+       int is_50hz = state->std & V4L2_STD_625_50;
+
+       if (fmt->type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) {
+               saa7115_set_lcr(client, &fmt->fmt.sliced);
+               return 0;
+       }
+       if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+               return -EINVAL;
+
+       pix = &(fmt->fmt.pix);
+
+       saa7115_dbg("decoder set size\n");
+
+       /* FIXME need better bounds checking here */
+       if ((pix->width < 1) || (pix->width > 1440))
+               return -EINVAL;
+       if ((pix->height < 1) || (pix->height > 960))
+               return -EINVAL;
+
+       /* probably have a valid size, let's set it */
+       /* Set output width/height */
+       /* width */
+       saa7115_write(client, 0xcc, (u8) (pix->width & 0xff));
+       saa7115_write(client, 0xcd, (u8) ((pix->width >> 8) & 0xff));
+       /* height */
+       saa7115_write(client, 0xce, (u8) (pix->height & 0xff));
+       saa7115_write(client, 0xcf, (u8) ((pix->height >> 8) & 0xff));
+
+       /* Scaling settings */
+       /* Hprescaler is floor(inres/outres) */
+       /* FIXME hardcoding input res */
+       if (pix->width != 720) {
+               HPSC = (int)(720 / pix->width);
+               /* 0 is not allowed (div. by zero) */
+               HPSC = HPSC ? HPSC : 1;
+               HFSC = (int)((1024 * 720) / (HPSC * pix->width));
+
+               saa7115_dbg("Hpsc: 0x%05x, Hfsc: 0x%05x\n", HPSC, HFSC);
+               /* FIXME hardcodes to "Task B"
+                * write H prescaler integer */
+               saa7115_write(client, 0xd0, (u8) (HPSC & 0x3f));
+
+               /* write H fine-scaling (luminance) */
+               saa7115_write(client, 0xd8, (u8) (HFSC & 0xff));
+               saa7115_write(client, 0xd9, (u8) ((HFSC >> 8) & 0xff));
+               /* write H fine-scaling (chrominance)
+                * must be lum/2, so i'll just bitshift :) */
+               saa7115_write(client, 0xDC, (u8) ((HFSC >> 1) & 0xff));
+               saa7115_write(client, 0xDD, (u8) ((HFSC >> 9) & 0xff));
+       } else {
+               if (is_50hz) {
+                       saa7115_dbg("Setting full 50hz width\n");
+                       saa7115_writeregs(client, saa7115_cfg_50hz_fullres_x);
+               } else {
+                       saa7115_dbg("Setting full 60hz width\n");
+                       saa7115_writeregs(client, saa7115_cfg_60hz_fullres_x);
+               }
+       }
+
+       Vsrc = is_50hz ? 576 : 480;
+
+       if (pix->height != Vsrc) {
+               VSCY = (int)((1024 * Vsrc) / pix->height);
+               saa7115_dbg("Vsrc: %d, Vscy: 0x%05x\n", Vsrc, VSCY);
+
+               /* Correct Contrast and Luminance */
+               saa7115_write(client, 0xd5, (u8) (64 * 1024 / VSCY));
+               saa7115_write(client, 0xd6, (u8) (64 * 1024 / VSCY));
+
+               /* write V fine-scaling (luminance) */
+               saa7115_write(client, 0xe0, (u8) (VSCY & 0xff));
+               saa7115_write(client, 0xe1, (u8) ((VSCY >> 8) & 0xff));
+               /* write V fine-scaling (chrominance) */
+               saa7115_write(client, 0xe2, (u8) (VSCY & 0xff));
+               saa7115_write(client, 0xe3, (u8) ((VSCY >> 8) & 0xff));
+       } else {
+               if (is_50hz) {
+                       saa7115_dbg("Setting full 50Hz height\n");
+                       saa7115_writeregs(client, saa7115_cfg_50hz_fullres_y);
+               } else {
+                       saa7115_dbg("Setting full 60hz height\n");
+                       saa7115_writeregs(client, saa7115_cfg_60hz_fullres_y);
+               }
+       }
+
+       saa7115_writeregs(client, saa7115_cfg_reset_scaler);
+       return 0;
+}
+
+/* Decode the sliced VBI data stream as created by the saa7115.
+   The format is described in the saa7115 datasheet in Tables 25 and 26
+   and in Figure 33.
+   The current implementation uses SAV/EAV codes and not the ancillary data
+   headers. The vbi->p pointer points to the SDID byte right after the SAV
+   code. */
+static void saa7115_decode_vbi_line(struct i2c_client *client,
+                                   struct v4l2_decode_vbi_line *vbi)
+{
+       static const char vbi_no_data_pattern[] = {
+               0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0
+       };
+       struct saa7115_state *state = i2c_get_clientdata(client);
+       u8 *p = vbi->p;
+       u32 wss;
+       int id1, id2;   /* the ID1 and ID2 bytes from the internal header */
+
+       vbi->type = 0;  /* mark result as a failure */
+       id1 = p[2];
+       id2 = p[3];
+       /* Note: the field bit is inverted for 60 Hz video */
+       if (state->std & V4L2_STD_525_60)
+               id1 ^= 0x40;
+
+       /* Skip internal header, p now points to the start of the payload */
+       p += 4;
+       vbi->p = p;
+
+       /* calculate field and line number of the VBI packet (1-23) */
+       vbi->is_second_field = ((id1 & 0x40) != 0);
+       vbi->line = (id1 & 0x3f) << 3;
+       vbi->line |= (id2 & 0x70) >> 4;
+
+       /* Obtain data type */
+       id2 &= 0xf;
+
+       /* If the VBI slicer does not detect any signal it will fill up
+          the payload buffer with 0xa0 bytes. */
+       if (!memcmp(p, vbi_no_data_pattern, sizeof(vbi_no_data_pattern)))
+               return;
+
+       /* decode payloads */
+       switch (id2) {
+       case 1:
+               vbi->type = V4L2_SLICED_TELETEXT_B;
+               break;
+       case 4:
+               if (!saa7115_odd_parity(p[0]) || !saa7115_odd_parity(p[1]))
+                       return;
+               vbi->type = V4L2_SLICED_CAPTION_525;
+               break;
+       case 5:
+               wss = saa7115_decode_wss(p);
+               if (wss == -1)
+                       return;
+               p[0] = wss & 0xff;
+               p[1] = wss >> 8;
+               vbi->type = V4L2_SLICED_WSS_625;
+               break;
+       case 7:
+               if (saa7115_decode_vps(p, p) != 0)
+                       return;
+               vbi->type = V4L2_SLICED_VPS;
+               break;
+       default:
+               return;
+       }
+}
+
+/* ============ SAA7115 AUDIO settings (end) ============= */
+
+static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *arg)
+{
+       struct saa7115_state *state = i2c_get_clientdata(client);
+       int *iarg = arg;
+
+       /* ioctls to allow direct access to the saa7115 registers for testing */
+       switch (cmd) {
+       case VIDIOC_S_FMT:
+               return saa7115_set_v4lfmt(client, (struct v4l2_format *)arg);
+
+       case VIDIOC_G_FMT:
+               return saa7115_get_v4lfmt(client, (struct v4l2_format *)arg);
+
+       case VIDIOC_INT_AUDIO_CLOCK_FREQ:
+               return saa7115_set_audio_clock_freq(client, *(enum v4l2_audio_clock_freq *)arg);
+
+       case VIDIOC_G_TUNER:
+       {
+               struct v4l2_tuner *vt = arg;
+               int status;
+
+               status = saa7115_read(client, 0x1f);
+
+               saa7115_dbg("status: 0x%02x\n", status);
+               vt->signal = ((status & (1 << 6)) == 0) ? 0xffff : 0x0;
+               break;
+       }
+
+       case VIDIOC_LOG_STATUS:
+               saa7115_log_status(client);
+               break;
+
+       case VIDIOC_G_CTRL:
+               return saa7115_get_v4lctrl(client, (struct v4l2_control *)arg);
+
+       case VIDIOC_S_CTRL:
+               return saa7115_set_v4lctrl(client, (struct v4l2_control *)arg);
+
+       case VIDIOC_G_STD:
+               *(v4l2_std_id *)arg = saa7115_get_v4lstd(client);
+               break;
+
+       case VIDIOC_S_STD:
+               saa7115_set_v4lstd(client, *(v4l2_std_id *)arg);
+               break;
+
+       case VIDIOC_G_INPUT:
+               *(int *)arg = state->input;
+               break;
+
+       case VIDIOC_S_INPUT:
+               saa7115_dbg("decoder set input %d\n", *iarg);
+               /* inputs from 0-9 are available */
+               if (*iarg < 0 || *iarg > 9) {
+                       return -EINVAL;
+               }
+
+               if (state->input == *iarg)
+                       break;
+               saa7115_dbg("now setting %s input\n",
+                       *iarg >= 6 ? "S-Video" : "Composite");
+               state->input = *iarg;
+
+               /* select mode */
+               saa7115_write(client, 0x02,
+                             (saa7115_read(client, 0x02) & 0xf0) |
+                              state->input);
+
+               /* bypass chrominance trap for modes 6..9 */
+               saa7115_write(client, 0x09,
+                             (saa7115_read(client, 0x09) & 0x7f) |
+                              (state->input < 6 ? 0x0 : 0x80));
+               break;
+
+       case VIDIOC_STREAMON:
+       case VIDIOC_STREAMOFF:
+               saa7115_dbg("%s output\n",
+                       (cmd == VIDIOC_STREAMON) ? "enable" : "disable");
+
+               if (state->enable != (cmd == VIDIOC_STREAMON)) {
+                       state->enable = (cmd == VIDIOC_STREAMON);
+                       saa7115_write(client, 0x87, state->enable);
+               }
+               break;
+
+       case VIDIOC_INT_DECODE_VBI_LINE:
+               saa7115_decode_vbi_line(client, arg);
+               break;
+
+       case VIDIOC_INT_RESET:
+               saa7115_dbg("decoder RESET\n");
+               saa7115_writeregs(client, saa7115_cfg_reset_scaler);
+               break;
+
+       case VIDIOC_INT_G_VBI_DATA:
+       {
+               struct v4l2_sliced_vbi_data *data = arg;
+
+               switch (data->id) {
+               case V4L2_SLICED_WSS_625:
+                       if (saa7115_read(client, 0x6b) & 0xc0)
+                               return -EIO;
+                       data->data[0] = saa7115_read(client, 0x6c);
+                       data->data[1] = saa7115_read(client, 0x6d);
+                       return 0;
+               case V4L2_SLICED_CAPTION_525:
+                       if (data->field == 0) {
+                               /* CC */
+                               if (saa7115_read(client, 0x66) & 0xc0)
+                                       return -EIO;
+                               data->data[0] = saa7115_read(client, 0x67);
+                               data->data[1] = saa7115_read(client, 0x68);
+                               return 0;
+                       }
+                       /* XDS */
+                       if (saa7115_read(client, 0x66) & 0x30)
+                               return -EIO;
+                       data->data[0] = saa7115_read(client, 0x69);
+                       data->data[1] = saa7115_read(client, 0x6a);
+                       return 0;
+               default:
+                       return -EINVAL;
+               }
+               break;
+       }
+
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+       case VIDIOC_INT_G_REGISTER:
+       {
+               struct v4l2_register *reg = arg;
+
+               if (reg->i2c_id != I2C_DRIVERID_SAA711X)
+                       return -EINVAL;
+               reg->val = saa7115_read(client, reg->reg & 0xff);
+               break;
+       }
+
+       case VIDIOC_INT_S_REGISTER:
+       {
+               struct v4l2_register *reg = arg;
+
+               if (reg->i2c_id != I2C_DRIVERID_SAA711X)
+                       return -EINVAL;
+               if (!capable(CAP_SYS_ADMIN))
+                       return -EPERM;
+               saa7115_write(client, reg->reg & 0xff, reg->val & 0xff);
+               break;
+       }
+#endif
+
+       case VIDIOC_INT_G_CHIP_IDENT:
+               *iarg = state->ident;
+               break;
+
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static struct i2c_driver i2c_driver_saa7115;
+
+static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
+{
+       struct i2c_client *client;
+       struct saa7115_state *state;
+       u8 chip_id;
+
+       /* Check if the adapter supports the needed features */
+       if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+               return 0;
+
+       client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
+       if (client == 0)
+               return -ENOMEM;
+       memset(client, 0, sizeof(struct i2c_client));
+       client->addr = address;
+       client->adapter = adapter;
+       client->driver = &i2c_driver_saa7115;
+       client->flags = I2C_CLIENT_ALLOW_USE;
+       snprintf(client->name, sizeof(client->name) - 1, "saa7115");
+
+       saa7115_dbg("detecting saa7115 client on address 0x%x\n", address << 1);
+
+       saa7115_write(client, 0, 5);
+       chip_id = saa7115_read(client, 0) & 0x0f;
+       if (chip_id != 4 && chip_id != 5) {
+               saa7115_dbg("saa7115 not found\n");
+               kfree(client);
+               return 0;
+       }
+       if (chip_id == 4) {
+               snprintf(client->name, sizeof(client->name) - 1, "saa7114");
+       }
+       saa7115_info("saa711%d found @ 0x%x (%s)\n", chip_id, address << 1, adapter->name);
+
+       state = kmalloc(sizeof(struct saa7115_state), GFP_KERNEL);
+       i2c_set_clientdata(client, state);
+       if (state == NULL) {
+               kfree(client);
+               return -ENOMEM;
+       }
+       memset(state, 0, sizeof(struct saa7115_state));
+       state->std = V4L2_STD_NTSC;
+       state->input = -1;
+       state->enable = 1;
+       state->bright = 128;
+       state->contrast = 64;
+       state->hue = 0;
+       state->sat = 64;
+       state->ident = (chip_id == 4) ? V4L2_IDENT_SAA7114 : V4L2_IDENT_SAA7115;
+       state->audclk_freq = V4L2_AUDCLK_48_KHZ;
+
+       saa7115_dbg("writing init values\n");
+
+       /* init to 60hz/48khz */
+       saa7115_writeregs(client, saa7115_init_auto_input);
+       saa7115_writeregs(client, saa7115_init_misc);
+       saa7115_writeregs(client, saa7115_cfg_60hz_fullres_x);
+       saa7115_writeregs(client, saa7115_cfg_60hz_fullres_y);
+       saa7115_writeregs(client, saa7115_cfg_60hz_video);
+       saa7115_writeregs(client, saa7115_cfg_48_audio);
+       saa7115_writeregs(client, saa7115_cfg_60hz_48_audio);
+       saa7115_writeregs(client, saa7115_cfg_reset_scaler);
+
+       i2c_attach_client(client);
+
+       saa7115_dbg("status: (1E) 0x%02x, (1F) 0x%02x\n",
+               saa7115_read(client, 0x1e), saa7115_read(client, 0x1f));
+
+       return 0;
+}
+
+static int saa7115_probe(struct i2c_adapter *adapter)
+{
+#ifdef I2C_CLASS_TV_ANALOG
+       if (adapter->class & I2C_CLASS_TV_ANALOG)
+#else
+       if (adapter->id == I2C_HW_B_BT848)
+#endif
+               return i2c_probe(adapter, &addr_data, &saa7115_attach);
+       return 0;
+}
+
+static int saa7115_detach(struct i2c_client *client)
+{
+       struct saa7115_state *state = i2c_get_clientdata(client);
+       int err;
+
+       err = i2c_detach_client(client);
+       if (err) {
+               return err;
+       }
+
+       kfree(state);
+       kfree(client);
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+/* i2c implementation */
+static struct i2c_driver i2c_driver_saa7115 = {
+       .name = "saa7115",
+       .id = I2C_DRIVERID_SAA711X,
+       .flags = I2C_DF_NOTIFY,
+       .attach_adapter = saa7115_probe,
+       .detach_client = saa7115_detach,
+       .command = saa7115_command,
+       .owner = THIS_MODULE,
+};
+
+
+static int __init saa7115_init_module(void)
+{
+       return i2c_add_driver(&i2c_driver_saa7115);
+}
+
+static void __exit saa7115_cleanup_module(void)
+{
+       i2c_del_driver(&i2c_driver_saa7115);
+}
+
+module_init(saa7115_init_module);
+module_exit(saa7115_cleanup_module);
index 9aa8827de2c36a3863a2d67fd842ba56dc52537d..25b30f352d84103564e661dca26d6580e5a2afe3 100644 (file)
@@ -36,7 +36,6 @@
 #include <asm/pgtable.h>
 #include <asm/page.h>
 #include <linux/sched.h>
-#include <asm/segment.h>
 #include <linux/types.h>
 #include <asm/uaccess.h>
 #include <linux/videodev.h>
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c
new file mode 100644 (file)
index 0000000..843431f
--- /dev/null
@@ -0,0 +1,849 @@
+/*
+ * saa7127 - Philips SAA7127/SAA7129 video encoder driver
+ *
+ * Copyright (C) 2003 Roy Bulter <rbulter@hetnet.nl>
+ *
+ * Based on SAA7126 video encoder driver by Gillem & Andreas Oberritter
+ *
+ * Copyright (C) 2000-2001 Gillem <htoa@gmx.net>
+ * Copyright (C) 2002 Andreas Oberritter <obi@saftware.de>
+ *
+ * Based on Stadis 4:2:2 MPEG-2 Decoder Driver by Nathan Laredo
+ *
+ * Copyright (C) 1999 Nathan Laredo <laredo@gnu.org>
+ *
+ * This driver is designed for the Hauppauge 250/350 Linux driver
+ * from the ivtv Project
+ *
+ * Copyright (C) 2003 Kevin Thayer <nufan_wfk@yahoo.com>
+ *
+ * Dual output support:
+ * Copyright (C) 2004 Eric Varsanyi
+ *
+ * NTSC Tuning and 7.5 IRE Setup
+ * Copyright (C) 2004  Chris Kennedy <c@groovy.org>
+ *
+ * VBI additions & cleanup:
+ * Copyright (C) 2004, 2005 Hans Verkuil <hverkuil@xs4all.nl>
+ *
+ * Note: the saa7126 is identical to the saa7127, and the saa7128 is
+ * identical to the saa7129, except that the saa7126 and saa7128 have
+ * macrovision anti-taping support. This driver will almost certainly
+ * work find for those chips, except of course for the missing anti-taping
+ * support.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/videodev2.h>
+#include <media/v4l2-common.h>
+
+static int debug = 0;
+static int test_image = 0;
+
+MODULE_DESCRIPTION("Philips SAA7127/9 video encoder driver");
+MODULE_AUTHOR("Kevin Thayer, Chris Kennedy, Hans Verkuil");
+MODULE_LICENSE("GPL");
+module_param(debug, int, 0644);
+module_param(test_image, int, 0644);
+MODULE_PARM_DESC(debug, "debug level (0-2)");
+MODULE_PARM_DESC(test_image, "test_image (0-1)");
+
+#define saa7127_dbg(fmt, arg...) \
+       do { \
+               if (debug >= 1) \
+                       printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \
+                              i2c_adapter_id(client->adapter), client->addr , ## arg); \
+       } while (0)
+
+/* High volume debug. Use with care. */
+#define saa7127_dbg_highvol(fmt, arg...) \
+       do { \
+               if (debug == 2) \
+                       printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \
+                              i2c_adapter_id(client->adapter), client->addr , ## arg); \
+       } while (0)
+
+#define saa7127_err(fmt, arg...) do { \
+       printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \
+              i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
+#define saa7127_info(fmt, arg...) do { \
+       printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \
+              i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
+
+static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END };
+
+
+I2C_CLIENT_INSMOD;
+
+/*
+ * SAA7127 registers
+ */
+
+#define SAA7127_REG_STATUS                           0x00
+#define SAA7127_REG_WIDESCREEN_CONFIG                0x26
+#define SAA7127_REG_WIDESCREEN_ENABLE                0x27
+#define SAA7127_REG_BURST_START                      0x28
+#define SAA7127_REG_BURST_END                        0x29
+#define SAA7127_REG_COPYGEN_0                        0x2a
+#define SAA7127_REG_COPYGEN_1                        0x2b
+#define SAA7127_REG_COPYGEN_2                        0x2c
+#define SAA7127_REG_OUTPUT_PORT_CONTROL              0x2d
+#define SAA7127_REG_GAIN_LUMINANCE_RGB               0x38
+#define SAA7127_REG_GAIN_COLORDIFF_RGB               0x39
+#define SAA7127_REG_INPUT_PORT_CONTROL_1             0x3a
+#define SAA7129_REG_FADE_KEY_COL2                   0x4f
+#define SAA7127_REG_CHROMA_PHASE                     0x5a
+#define SAA7127_REG_GAINU                            0x5b
+#define SAA7127_REG_GAINV                            0x5c
+#define SAA7127_REG_BLACK_LEVEL                      0x5d
+#define SAA7127_REG_BLANKING_LEVEL                   0x5e
+#define SAA7127_REG_VBI_BLANKING                     0x5f
+#define SAA7127_REG_DAC_CONTROL                      0x61
+#define SAA7127_REG_BURST_AMP                        0x62
+#define SAA7127_REG_SUBC3                            0x63
+#define SAA7127_REG_SUBC2                            0x64
+#define SAA7127_REG_SUBC1                            0x65
+#define SAA7127_REG_SUBC0                            0x66
+#define SAA7127_REG_LINE_21_ODD_0                    0x67
+#define SAA7127_REG_LINE_21_ODD_1                    0x68
+#define SAA7127_REG_LINE_21_EVEN_0                   0x69
+#define SAA7127_REG_LINE_21_EVEN_1                   0x6a
+#define SAA7127_REG_RCV_PORT_CONTROL                 0x6b
+#define SAA7127_REG_VTRIG                            0x6c
+#define SAA7127_REG_HTRIG_HI                         0x6d
+#define SAA7127_REG_MULTI                            0x6e
+#define SAA7127_REG_CLOSED_CAPTION                   0x6f
+#define SAA7127_REG_RCV2_OUTPUT_START                0x70
+#define SAA7127_REG_RCV2_OUTPUT_END                  0x71
+#define SAA7127_REG_RCV2_OUTPUT_MSBS                 0x72
+#define SAA7127_REG_TTX_REQUEST_H_START              0x73
+#define SAA7127_REG_TTX_REQUEST_H_DELAY_LENGTH       0x74
+#define SAA7127_REG_CSYNC_ADVANCE_VSYNC_SHIFT        0x75
+#define SAA7127_REG_TTX_ODD_REQ_VERT_START           0x76
+#define SAA7127_REG_TTX_ODD_REQ_VERT_END             0x77
+#define SAA7127_REG_TTX_EVEN_REQ_VERT_START          0x78
+#define SAA7127_REG_TTX_EVEN_REQ_VERT_END            0x79
+#define SAA7127_REG_FIRST_ACTIVE                     0x7a
+#define SAA7127_REG_LAST_ACTIVE                      0x7b
+#define SAA7127_REG_MSB_VERTICAL                     0x7c
+#define SAA7127_REG_DISABLE_TTX_LINE_LO_0            0x7e
+#define SAA7127_REG_DISABLE_TTX_LINE_LO_1            0x7f
+
+/*
+ **********************************************************************
+ *
+ *  Arrays with configuration parameters for the SAA7127
+ *
+ **********************************************************************
+ */
+
+struct i2c_reg_value {
+       unsigned char reg;
+       unsigned char value;
+};
+
+static const struct i2c_reg_value saa7129_init_config_extra[] = {
+       { SAA7127_REG_OUTPUT_PORT_CONTROL,              0x38 },
+       { SAA7127_REG_VTRIG,                            0xfa },
+};
+
+static const struct i2c_reg_value saa7127_init_config_common[] = {
+       { SAA7127_REG_WIDESCREEN_CONFIG,                0x0d },
+       { SAA7127_REG_WIDESCREEN_ENABLE,                0x00 },
+       { SAA7127_REG_COPYGEN_0,                        0x77 },
+       { SAA7127_REG_COPYGEN_1,                        0x41 },
+       { SAA7127_REG_COPYGEN_2,                        0x00 }, /* Macrovision enable/disable */
+       { SAA7127_REG_OUTPUT_PORT_CONTROL,              0x9e },
+       { SAA7127_REG_GAIN_LUMINANCE_RGB,               0x00 },
+       { SAA7127_REG_GAIN_COLORDIFF_RGB,               0x00 },
+       { SAA7127_REG_INPUT_PORT_CONTROL_1,             0x80 }, /* for color bars */
+       { SAA7127_REG_LINE_21_ODD_0,                    0x77 },
+       { SAA7127_REG_LINE_21_ODD_1,                    0x41 },
+       { SAA7127_REG_LINE_21_EVEN_0,                   0x88 },
+       { SAA7127_REG_LINE_21_EVEN_1,                   0x41 },
+       { SAA7127_REG_RCV_PORT_CONTROL,                 0x12 },
+       { SAA7127_REG_VTRIG,                            0xf9 },
+       { SAA7127_REG_HTRIG_HI,                         0x00 },
+       { SAA7127_REG_RCV2_OUTPUT_START,                0x41 },
+       { SAA7127_REG_RCV2_OUTPUT_END,                  0xc3 },
+       { SAA7127_REG_RCV2_OUTPUT_MSBS,                 0x00 },
+       { SAA7127_REG_TTX_REQUEST_H_START,              0x3e },
+       { SAA7127_REG_TTX_REQUEST_H_DELAY_LENGTH,       0xb8 },
+       { SAA7127_REG_CSYNC_ADVANCE_VSYNC_SHIFT,        0x03 },
+       { SAA7127_REG_TTX_ODD_REQ_VERT_START,           0x15 },
+       { SAA7127_REG_TTX_ODD_REQ_VERT_END,             0x16 },
+       { SAA7127_REG_TTX_EVEN_REQ_VERT_START,          0x15 },
+       { SAA7127_REG_TTX_EVEN_REQ_VERT_END,            0x16 },
+       { SAA7127_REG_FIRST_ACTIVE,                     0x1a },
+       { SAA7127_REG_LAST_ACTIVE,                      0x01 },
+       { SAA7127_REG_MSB_VERTICAL,                     0xc0 },
+       { SAA7127_REG_DISABLE_TTX_LINE_LO_0,            0x00 },
+       { SAA7127_REG_DISABLE_TTX_LINE_LO_1,            0x00 },
+       { 0, 0 }
+};
+
+#define SAA7127_60HZ_DAC_CONTROL 0x15
+static const struct i2c_reg_value saa7127_init_config_60hz[] = {
+       { SAA7127_REG_BURST_START,                      0x19 },
+       /* BURST_END is also used as a chip ID in saa7127_detect_client */
+       { SAA7127_REG_BURST_END,                        0x1d },
+       { SAA7127_REG_CHROMA_PHASE,                     0xa3 },
+       { SAA7127_REG_GAINU,                            0x98 },
+       { SAA7127_REG_GAINV,                            0xd3 },
+       { SAA7127_REG_BLACK_LEVEL,                      0x39 },
+       { SAA7127_REG_BLANKING_LEVEL,                   0x2e },
+       { SAA7127_REG_VBI_BLANKING,                     0x2e },
+       { SAA7127_REG_DAC_CONTROL,                      0x15 },
+       { SAA7127_REG_BURST_AMP,                        0x4d },
+       { SAA7127_REG_SUBC3,                            0x1f },
+       { SAA7127_REG_SUBC2,                            0x7c },
+       { SAA7127_REG_SUBC1,                            0xf0 },
+       { SAA7127_REG_SUBC0,                            0x21 },
+       { SAA7127_REG_MULTI,                            0x90 },
+       { SAA7127_REG_CLOSED_CAPTION,                   0x11 },
+       { 0, 0 }
+};
+
+#define SAA7127_50HZ_DAC_CONTROL 0x02
+struct i2c_reg_value saa7127_init_config_50hz[] = {
+       { SAA7127_REG_BURST_START,                      0x21 },
+       /* BURST_END is also used as a chip ID in saa7127_detect_client */
+       { SAA7127_REG_BURST_END,                        0x1d },
+       { SAA7127_REG_CHROMA_PHASE,                     0x3f },
+       { SAA7127_REG_GAINU,                            0x7d },
+       { SAA7127_REG_GAINV,                            0xaf },
+       { SAA7127_REG_BLACK_LEVEL,                      0x33 },
+       { SAA7127_REG_BLANKING_LEVEL,                   0x35 },
+       { SAA7127_REG_VBI_BLANKING,                     0x35 },
+       { SAA7127_REG_DAC_CONTROL,                      0x02 },
+       { SAA7127_REG_BURST_AMP,                        0x2f },
+       { SAA7127_REG_SUBC3,                            0xcb },
+       { SAA7127_REG_SUBC2,                            0x8a },
+       { SAA7127_REG_SUBC1,                            0x09 },
+       { SAA7127_REG_SUBC0,                            0x2a },
+       { SAA7127_REG_MULTI,                            0xa0 },
+       { SAA7127_REG_CLOSED_CAPTION,                   0x00 },
+       { 0, 0 }
+};
+
+/* Enumeration for the Supported input types */
+enum saa7127_input_type {
+       SAA7127_INPUT_TYPE_NORMAL,
+       SAA7127_INPUT_TYPE_TEST_IMAGE
+};
+
+/* Enumeration for the Supported Output signal types */
+enum saa7127_output_type {
+       SAA7127_OUTPUT_TYPE_BOTH,
+       SAA7127_OUTPUT_TYPE_COMPOSITE,
+       SAA7127_OUTPUT_TYPE_SVIDEO,
+       SAA7127_OUTPUT_TYPE_RGB,
+       SAA7127_OUTPUT_TYPE_YUV_C,
+       SAA7127_OUTPUT_TYPE_YUV_V
+};
+
+/*
+ **********************************************************************
+ *
+ *  Encoder Struct, holds the configuration state of the encoder
+ *
+ **********************************************************************
+ */
+
+struct saa7127_state {
+       v4l2_std_id std;
+       enum v4l2_chip_ident ident;
+       enum saa7127_input_type input_type;
+       enum saa7127_output_type output_type;
+       int video_enable;
+       int wss_enable;
+       u16 wss_mode;
+       int cc_enable;
+       u16 cc_data;
+       int xds_enable;
+       u16 xds_data;
+       int vps_enable;
+       u8 vps_data[5];
+       u8 reg_2d;
+       u8 reg_3a;
+       u8 reg_3a_cb;   /* colorbar bit */
+       u8 reg_61;
+};
+
+static const char * const output_strs[] =
+{
+       "S-Video + Composite",
+       "Composite",
+       "S-Video",
+       "RGB",
+       "YUV C",
+       "YUV V"
+};
+
+static const char * const wss_strs[] = {
+       "invalid",
+       "letterbox 14:9 center",
+       "letterbox 14:9 top",
+       "invalid",
+       "letterbox 16:9 top",
+       "invalid",
+       "invalid",
+       "16:9 full format anamorphic"
+       "4:3 full format",
+       "invalid",
+       "invalid",
+       "letterbox 16:9 center",
+       "invalid",
+       "letterbox >16:9 center",
+       "14:9 full format center",
+       "invalid",
+};
+
+/* ----------------------------------------------------------------------- */
+
+static int saa7127_read(struct i2c_client *client, u8 reg)
+{
+       return i2c_smbus_read_byte_data(client, reg);
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int saa7127_write(struct i2c_client *client, u8 reg, u8 val)
+{
+       int i;
+
+       for (i = 0; i < 3; i++) {
+               if (i2c_smbus_write_byte_data(client, reg, val) == 0)
+                       return 0;
+       }
+       saa7127_err("I2C Write Problem\n");
+       return -1;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int saa7127_write_inittab(struct i2c_client *client,
+                                const struct i2c_reg_value *regs)
+{
+       while (regs->reg != 0) {
+               saa7127_write(client, regs->reg, regs->value);
+               regs++;
+       }
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int saa7127_set_vps(struct i2c_client *client, struct v4l2_sliced_vbi_data *data)
+{
+       struct saa7127_state *state = i2c_get_clientdata(client);
+       int enable = (data->line != 0);
+
+       if (enable && (data->field != 0 || data->line != 16))
+               return -EINVAL;
+       if (state->vps_enable != enable) {
+               saa7127_dbg("Turn VPS Signal %s\n", enable ? "on" : "off");
+               saa7127_write(client, 0x54, enable << 7);
+               state->vps_enable = enable;
+       }
+       if (!enable)
+               return 0;
+
+       state->vps_data[0] = data->data[4];
+       state->vps_data[1] = data->data[10];
+       state->vps_data[2] = data->data[11];
+       state->vps_data[3] = data->data[12];
+       state->vps_data[4] = data->data[13];
+       saa7127_dbg("Set VPS data %02x %02x %02x %02x %02x\n",
+               state->vps_data[0], state->vps_data[1],
+               state->vps_data[2], state->vps_data[3],
+               state->vps_data[4]);
+       saa7127_write(client, 0x55, state->vps_data[0]);
+       saa7127_write(client, 0x56, state->vps_data[1]);
+       saa7127_write(client, 0x57, state->vps_data[2]);
+       saa7127_write(client, 0x58, state->vps_data[3]);
+       saa7127_write(client, 0x59, state->vps_data[4]);
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int saa7127_set_cc(struct i2c_client *client, struct v4l2_sliced_vbi_data *data)
+{
+       struct saa7127_state *state = i2c_get_clientdata(client);
+       u16 cc = data->data[0] << 8 | data->data[1];
+       int enable = (data->line != 0);
+
+       if (enable && (data->field != 0 || data->line != 21))
+               return -EINVAL;
+       if (state->cc_enable != enable) {
+               saa7127_dbg("Turn CC %s\n", enable ? "on" : "off");
+               saa7127_write(client, SAA7127_REG_CLOSED_CAPTION,
+                               (enable << 6) | 0x11);
+               state->cc_enable = enable;
+       }
+       if (!enable)
+               return 0;
+
+       saa7127_dbg_highvol("CC data: %04x\n", cc);
+       saa7127_write(client, SAA7127_REG_LINE_21_ODD_0, cc & 0xff);
+       saa7127_write(client, SAA7127_REG_LINE_21_ODD_1, cc >> 8);
+       state->cc_data = cc;
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int saa7127_set_xds(struct i2c_client *client, struct v4l2_sliced_vbi_data *data)
+{
+       struct saa7127_state *state = i2c_get_clientdata(client);
+       u16 xds = data->data[1] << 8 | data->data[0];
+       int enable = (data->line != 0);
+
+       if (enable && (data->field != 1 || data->line != 21))
+               return -EINVAL;
+       if (state->xds_enable != enable) {
+               saa7127_dbg("Turn XDS %s\n", enable ? "on" : "off");
+               saa7127_write(client, SAA7127_REG_CLOSED_CAPTION,
+                               (enable << 7) | 0x11);
+               state->xds_enable = enable;
+       }
+       if (!enable)
+               return 0;
+
+       saa7127_dbg_highvol("XDS data: %04x\n", xds);
+       saa7127_write(client, SAA7127_REG_LINE_21_EVEN_0, xds & 0xff);
+       saa7127_write(client, SAA7127_REG_LINE_21_EVEN_1, xds >> 8);
+       state->xds_data = xds;
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int saa7127_set_wss(struct i2c_client *client, struct v4l2_sliced_vbi_data *data)
+{
+       struct saa7127_state *state = i2c_get_clientdata(client);
+       int enable = (data->line != 0);
+
+       if (enable && (data->field != 0 || data->line != 23))
+               return -EINVAL;
+       if (state->wss_enable != enable) {
+               saa7127_dbg("Turn WSS %s\n", enable ? "on" : "off");
+               saa7127_write(client, 0x27, enable << 7);
+               state->wss_enable = enable;
+       }
+       if (!enable)
+               return 0;
+
+       saa7127_write(client, 0x26, data->data[0]);
+       saa7127_write(client, 0x27, 0x80 | (data->data[1] & 0x3f));
+       saa7127_dbg("WSS mode: %s\n", wss_strs[data->data[0] & 0xf]);
+       state->wss_mode = (data->data[1] & 0x3f) << 8 | data->data[0];
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int saa7127_set_video_enable(struct i2c_client *client, int enable)
+{
+       struct saa7127_state *state = i2c_get_clientdata(client);
+
+       if (enable) {
+               saa7127_dbg("Enable Video Output\n");
+               saa7127_write(client, 0x2d, state->reg_2d);
+               saa7127_write(client, 0x61, state->reg_61);
+       } else {
+               saa7127_dbg("Disable Video Output\n");
+               saa7127_write(client, 0x2d, (state->reg_2d & 0xf0));
+               saa7127_write(client, 0x61, (state->reg_61 | 0xc0));
+       }
+       state->video_enable = enable;
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int saa7127_set_std(struct i2c_client *client, v4l2_std_id std)
+{
+       struct saa7127_state *state = i2c_get_clientdata(client);
+       const struct i2c_reg_value *inittab;
+
+       if (std & V4L2_STD_525_60) {
+               saa7127_dbg("Selecting 60 Hz video Standard\n");
+               inittab = saa7127_init_config_60hz;
+               state->reg_61 = SAA7127_60HZ_DAC_CONTROL;
+       } else {
+               saa7127_dbg("Selecting 50 Hz video Standard\n");
+               inittab = saa7127_init_config_50hz;
+               state->reg_61 = SAA7127_50HZ_DAC_CONTROL;
+       }
+
+       /* Write Table */
+       saa7127_write_inittab(client, inittab);
+       state->std = std;
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int saa7127_set_output_type(struct i2c_client *client, int output)
+{
+       struct saa7127_state *state = i2c_get_clientdata(client);
+
+       switch (output) {
+       case SAA7127_OUTPUT_TYPE_RGB:
+               state->reg_2d = 0x0f;   /* RGB + CVBS (for sync) */
+               state->reg_3a = 0x13;   /* by default switch YUV to RGB-matrix on */
+               break;
+
+       case SAA7127_OUTPUT_TYPE_COMPOSITE:
+               state->reg_2d = 0x08;   /* 00001000 CVBS only, RGB DAC's off (high impedance mode) */
+               state->reg_3a = 0x13;   /* by default switch YUV to RGB-matrix on */
+               break;
+
+       case SAA7127_OUTPUT_TYPE_SVIDEO:
+               state->reg_2d = 0xff;   /* 11111111  croma -> R, luma -> CVBS + G + B */
+               state->reg_3a = 0x13;   /* by default switch YUV to RGB-matrix on */
+               break;
+
+       case SAA7127_OUTPUT_TYPE_YUV_V:
+               state->reg_2d = 0x4f;   /* reg 2D = 01001111, all DAC's on, RGB + VBS */
+               state->reg_3a = 0x0b;   /* reg 3A = 00001011, bypass RGB-matrix */
+               break;
+
+       case SAA7127_OUTPUT_TYPE_YUV_C:
+               state->reg_2d = 0x0f;   /* reg 2D = 00001111, all DAC's on, RGB + CVBS */
+               state->reg_3a = 0x0b;   /* reg 3A = 00001011, bypass RGB-matrix */
+               break;
+
+       case SAA7127_OUTPUT_TYPE_BOTH:
+               state->reg_2d = 0xbf;
+               state->reg_3a = 0x13;   /* by default switch YUV to RGB-matrix on */
+               break;
+
+       default:
+               return -EINVAL;
+       }
+       saa7127_dbg("Selecting %s output type\n", output_strs[output]);
+
+       /* Configure Encoder */
+       saa7127_write(client, 0x2d, state->reg_2d);
+       saa7127_write(client, 0x3a, state->reg_3a | state->reg_3a_cb);
+       state->output_type = output;
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int saa7127_set_input_type(struct i2c_client *client, int input)
+{
+       struct saa7127_state *state = i2c_get_clientdata(client);
+
+       switch (input) {
+       case SAA7127_INPUT_TYPE_NORMAL: /* avia */
+               saa7127_dbg("Selecting Normal Encoder Input\n");
+               state->reg_3a_cb = 0;
+               break;
+
+       case SAA7127_INPUT_TYPE_TEST_IMAGE:     /* color bar */
+               saa7127_dbg("Selecting Color Bar generator\n");
+               state->reg_3a_cb = 0x80;
+               break;
+
+       default:
+               return -EINVAL;
+       }
+       saa7127_write(client, 0x3a, state->reg_3a | state->reg_3a_cb);
+       state->input_type = input;
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int saa7127_command(struct i2c_client *client,
+                          unsigned int cmd, void *arg)
+{
+       struct saa7127_state *state = i2c_get_clientdata(client);
+       struct v4l2_format *fmt = arg;
+       int *iarg = arg;
+
+       switch (cmd) {
+       case VIDIOC_S_STD:
+               if (state->std == *(v4l2_std_id *)arg)
+                       break;
+               return saa7127_set_std(client, *(v4l2_std_id *)arg);
+
+       case VIDIOC_G_STD:
+               *(v4l2_std_id *)arg = state->std;
+               break;
+
+       case VIDIOC_S_INPUT:
+               if (state->input_type == *iarg)
+                       break;
+               return saa7127_set_input_type(client, *iarg);
+
+       case VIDIOC_S_OUTPUT:
+               if (state->output_type == *iarg)
+                       break;
+               return saa7127_set_output_type(client, *iarg);
+
+       case VIDIOC_STREAMON:
+       case VIDIOC_STREAMOFF:
+               if (state->video_enable == (cmd == VIDIOC_STREAMON))
+                       break;
+               return saa7127_set_video_enable(client, cmd == VIDIOC_STREAMON);
+
+       case VIDIOC_G_FMT:
+               if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
+                       return -EINVAL;
+
+               memset(&fmt->fmt.sliced, 0, sizeof(fmt->fmt.sliced));
+               if (state->vps_enable)
+                       fmt->fmt.sliced.service_lines[0][16] = V4L2_SLICED_VPS;
+               if (state->wss_enable)
+                       fmt->fmt.sliced.service_lines[0][23] = V4L2_SLICED_WSS_625;
+               if (state->cc_enable) {
+                       fmt->fmt.sliced.service_lines[0][21] = V4L2_SLICED_CAPTION_525;
+                       fmt->fmt.sliced.service_lines[1][21] = V4L2_SLICED_CAPTION_525;
+               }
+               fmt->fmt.sliced.service_set =
+                       (state->vps_enable ? V4L2_SLICED_VPS : 0) |
+                       (state->wss_enable ? V4L2_SLICED_WSS_625 : 0) |
+                       (state->cc_enable ? V4L2_SLICED_CAPTION_525 : 0);
+               break;
+
+       case VIDIOC_LOG_STATUS:
+               saa7127_info("Standard: %s\n", (state->std & V4L2_STD_525_60) ? "60 Hz" : "50 Hz");
+               saa7127_info("Input:    %s\n", state->input_type ?  "color bars" : "normal");
+               saa7127_info("Output:   %s\n", state->video_enable ?
+                       output_strs[state->output_type] : "disabled");
+               saa7127_info("WSS:      %s\n", state->wss_enable ?
+                       wss_strs[state->wss_mode] : "disabled");
+               saa7127_info("VPS:      %s\n", state->vps_enable ? "enabled" : "disabled");
+               saa7127_info("CC:       %s\n", state->cc_enable ? "enabled" : "disabled");
+               break;
+
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+       case VIDIOC_INT_G_REGISTER:
+       {
+               struct v4l2_register *reg = arg;
+
+               if (reg->i2c_id != I2C_DRIVERID_SAA7127)
+                       return -EINVAL;
+               reg->val = saa7127_read(client, reg->reg & 0xff);
+               break;
+       }
+
+       case VIDIOC_INT_S_REGISTER:
+       {
+               struct v4l2_register *reg = arg;
+
+               if (reg->i2c_id != I2C_DRIVERID_SAA7127)
+                       return -EINVAL;
+               if (!capable(CAP_SYS_ADMIN))
+                       return -EPERM;
+               saa7127_write(client, reg->reg & 0xff, reg->val & 0xff);
+               break;
+       }
+#endif
+
+       case VIDIOC_INT_S_VBI_DATA:
+       {
+               struct v4l2_sliced_vbi_data *data = arg;
+
+               switch (data->id) {
+                       case V4L2_SLICED_WSS_625:
+                               return saa7127_set_wss(client, data);
+                       case V4L2_SLICED_VPS:
+                               return saa7127_set_vps(client, data);
+                       case V4L2_SLICED_CAPTION_525:
+                               if (data->field == 0)
+                                       return saa7127_set_cc(client, data);
+                               return saa7127_set_xds(client, data);
+                       default:
+                               return -EINVAL;
+               }
+               break;
+       }
+
+       case VIDIOC_INT_G_CHIP_IDENT:
+               *(enum v4l2_chip_ident *)arg = state->ident;
+               break;
+
+       default:
+               return -EINVAL;
+       }
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+struct i2c_driver i2c_driver_saa7127;
+
+/* ----------------------------------------------------------------------- */
+
+static int saa7127_attach(struct i2c_adapter *adapter, int address, int kind)
+{
+       struct i2c_client *client;
+       struct saa7127_state *state;
+       struct v4l2_sliced_vbi_data vbi = { 0, 0, 0, 0 };  /* set to disabled */
+       int read_result = 0;
+
+       /* Check if the adapter supports the needed features */
+       if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+               return 0;
+
+       client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
+       if (client == 0)
+               return -ENOMEM;
+
+       memset(client, 0, sizeof(struct i2c_client));
+       client->addr = address;
+       client->adapter = adapter;
+       client->driver = &i2c_driver_saa7127;
+       client->flags = I2C_CLIENT_ALLOW_USE;
+       snprintf(client->name, sizeof(client->name) - 1, "saa7127");
+
+       saa7127_dbg("detecting saa7127 client on address 0x%x\n", address << 1);
+
+       /* First test register 0: Bits 5-7 are a version ID (should be 0),
+          and bit 2 should also be 0.
+          This is rather general, so the second test is more specific and
+          looks at the 'ending point of burst in clock cycles' which is
+          0x1d after a reset and not expected to ever change. */
+       if ((saa7127_read(client, 0) & 0xe4) != 0 ||
+                       (saa7127_read(client, 0x29) & 0x3f) != 0x1d) {
+               saa7127_dbg("saa7127 not found\n");
+               kfree(client);
+               return 0;
+       }
+       state = kmalloc(sizeof(struct saa7127_state), GFP_KERNEL);
+
+       if (state == NULL) {
+               kfree(client);
+               return (-ENOMEM);
+       }
+
+       i2c_set_clientdata(client, state);
+       memset(state, 0, sizeof(struct saa7127_state));
+
+       /* Configure Encoder */
+
+       saa7127_dbg("Configuring encoder\n");
+       saa7127_write_inittab(client, saa7127_init_config_common);
+       saa7127_set_std(client, V4L2_STD_NTSC);
+       saa7127_set_output_type(client, SAA7127_OUTPUT_TYPE_BOTH);
+       saa7127_set_vps(client, &vbi);
+       saa7127_set_wss(client, &vbi);
+       saa7127_set_cc(client, &vbi);
+       saa7127_set_xds(client, &vbi);
+       if (test_image == 1) {
+               /* The Encoder has an internal Colorbar generator */
+               /* This can be used for debugging */
+               saa7127_set_input_type(client, SAA7127_INPUT_TYPE_TEST_IMAGE);
+       } else {
+               saa7127_set_input_type(client, SAA7127_INPUT_TYPE_NORMAL);
+       }
+       saa7127_set_video_enable(client, 1);
+
+       /* Detect if it's an saa7129 */
+       read_result = saa7127_read(client, SAA7129_REG_FADE_KEY_COL2);
+       saa7127_write(client, SAA7129_REG_FADE_KEY_COL2, 0xaa);
+       if (saa7127_read(client, SAA7129_REG_FADE_KEY_COL2) == 0xaa) {
+               saa7127_info("saa7129 found @ 0x%x (%s)\n", address << 1, adapter->name);
+               saa7127_write(client, SAA7129_REG_FADE_KEY_COL2, read_result);
+               saa7127_write_inittab(client, saa7129_init_config_extra);
+               state->ident = V4L2_IDENT_SAA7129;
+       } else {
+               saa7127_info("saa7127 found @ 0x%x (%s)\n", address << 1, adapter->name);
+               state->ident = V4L2_IDENT_SAA7127;
+       }
+
+       i2c_attach_client(client);
+
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int saa7127_probe(struct i2c_adapter *adapter)
+{
+#ifdef I2C_CLASS_TV_ANALOG
+       if (adapter->class & I2C_CLASS_TV_ANALOG)
+#else
+       if (adapter->id == I2C_HW_B_BT848)
+#endif
+               return i2c_probe(adapter, &addr_data, saa7127_attach);
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int saa7127_detach(struct i2c_client *client)
+{
+       struct saa7127_state *state = i2c_get_clientdata(client);
+       int err;
+
+       /* Turn off TV output */
+       saa7127_set_video_enable(client, 0);
+
+       err = i2c_detach_client(client);
+
+       if (err) {
+               return err;
+       }
+
+       kfree(state);
+       kfree(client);
+       return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+struct i2c_driver i2c_driver_saa7127 = {
+       .name = "saa7127",
+       .id = I2C_DRIVERID_SAA7127,
+       .flags = I2C_DF_NOTIFY,
+       .attach_adapter = saa7127_probe,
+       .detach_client = saa7127_detach,
+       .command = saa7127_command,
+       .owner = THIS_MODULE,
+};
+
+
+/* ----------------------------------------------------------------------- */
+
+static int __init saa7127_init_module(void)
+{
+       return i2c_add_driver(&i2c_driver_saa7127);
+}
+
+/* ----------------------------------------------------------------------- */
+
+static void __exit saa7127_cleanup_module(void)
+{
+       i2c_del_driver(&i2c_driver_saa7127);
+}
+
+/* ----------------------------------------------------------------------- */
+
+module_init(saa7127_init_module);
+module_exit(saa7127_cleanup_module);
index 624e8808a517e4d1561a18132b48037a9096ff35..7bdeabe638cacef344f30fc933fbb9b1fe6c95c7 100644 (file)
@@ -1,10 +1,11 @@
 config VIDEO_SAA7134
        tristate "Philips SAA7134 support"
-       depends on VIDEO_DEV && PCI && I2C && SOUND
+       depends on VIDEO_DEV && PCI && I2C && SOUND && SND
        select VIDEO_BUF
        select VIDEO_IR
        select VIDEO_TUNER
        select CRC32
+       select SND_PCM_OSS
        ---help---
          This is a video4linux driver for Philips SAA713x based
          TV cards.
index e0b28f0533af02549d0b9e1722e3e744196d80cd..4226b61cc613a60d5a67ebdb5851aac26ee06619 100644 (file)
@@ -1,10 +1,11 @@
 
 saa7134-objs :=        saa7134-cards.o saa7134-core.o saa7134-i2c.o    \
-               saa7134-oss.o saa7134-ts.o saa7134-tvaudio.o    \
-               saa7134-vbi.o saa7134-video.o saa7134-input.o
+               saa7134-ts.o saa7134-tvaudio.o saa7134-vbi.o    \
+               saa7134-video.o saa7134-input.o
 
 obj-$(CONFIG_VIDEO_SAA7134) +=  saa7134.o saa7134-empress.o \
-                               saa6752hs.o saa7134-alsa.o
+                               saa6752hs.o saa7134-alsa.o \
+                               saa7134-oss.o
 obj-$(CONFIG_VIDEO_SAA7134_DVB) += saa7134-dvb.o
 
 EXTRA_CFLAGS += -I$(src)/..
index 4f3c423543290492cad0fdca4a1ad200ed53d43f..5707c666660b724c592ea170cdea7a03186d0e81 100644 (file)
@@ -30,7 +30,9 @@
 #include <sound/core.h>
 #include <sound/control.h>
 #include <sound/pcm.h>
+#include <sound/pcm_params.h>
 #include <sound/initval.h>
+#include <linux/interrupt.h>
 
 #include "saa7134.h"
 #include "saa7134-reg.h"
@@ -56,6 +58,8 @@ static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
 module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s).");
 
+int position;
+
 #define dprintk(fmt, arg...)    if (debug) \
         printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ## arg)
 
@@ -68,7 +72,7 @@ typedef struct snd_card_saa7134 {
        int mixer_volume[MIXER_ADDR_LAST+1][2];
        int capture_source[MIXER_ADDR_LAST+1][2];
        struct pci_dev *pci;
-       struct saa7134_dev *saadev;
+       struct saa7134_dev *dev;
 
        unsigned long iobase;
        int irq;
@@ -83,12 +87,10 @@ typedef struct snd_card_saa7134 {
  */
 
 typedef struct snd_card_saa7134_pcm {
-       struct saa7134_dev *saadev;
+       struct saa7134_dev *dev;
 
        spinlock_t lock;
-       unsigned int pcm_size;          /* buffer size */
-       unsigned int pcm_count;         /* bytes per period */
-       unsigned int pcm_bps;           /* bytes per second */
+
        snd_pcm_substream_t *substream;
 } snd_card_saa7134_pcm_t;
 
@@ -100,13 +102,11 @@ static snd_card_t *snd_saa7134_cards[SNDRV_CARDS];
  *
  *   Called when the capture device is released or the buffer overflows
  *
- *   - Copied verbatim from saa7134-oss's dsp_dma_stop. Can be dropped
- *     if we just share dsp_dma_stop and use it here
+ *   - Copied verbatim from saa7134-oss's dsp_dma_stop.
  *
  */
 
 static void saa7134_dma_stop(struct saa7134_dev *dev)
-
 {
        dev->dmasound.dma_blk     = -1;
        dev->dmasound.dma_running = 0;
@@ -118,8 +118,7 @@ static void saa7134_dma_stop(struct saa7134_dev *dev)
  *
  *   Called when preparing the capture device for use
  *
- *   - Copied verbatim from saa7134-oss's dsp_dma_start. Can be dropped
- *     if we just share dsp_dma_start and use it here
+ *   - Copied verbatim from saa7134-oss's dsp_dma_start.
  *
  */
 
@@ -170,9 +169,9 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status)
        if (dev->dmasound.read_count >= dev->dmasound.blksize * (dev->dmasound.blocks-2)) {
                dprintk("irq: overrun [full=%d/%d] - Blocks in %d\n",dev->dmasound.read_count,
                        dev->dmasound.bufsize, dev->dmasound.blocks);
+               spin_unlock(&dev->slock);
                snd_pcm_stop(dev->dmasound.substream,SNDRV_PCM_STATE_XRUN);
-               saa7134_dma_stop(dev);
-               goto done;
+               return;
        }
 
        /* next block addr */
@@ -194,6 +193,7 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status)
                snd_pcm_period_elapsed(dev->dmasound.substream);
                spin_lock(&dev->slock);
        }
+
  done:
        spin_unlock(&dev->slock);
 
@@ -209,7 +209,9 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status)
 
 static irqreturn_t saa7134_alsa_irq(int irq, void *dev_id, struct pt_regs *regs)
 {
-       struct saa7134_dev *dev = (struct saa7134_dev*) dev_id;
+        struct saa7134_dmasound *dmasound = dev_id;
+        struct saa7134_dev *dev = dmasound->priv_data;
+
        unsigned long report, status;
        int loop, handled = 0;
 
@@ -248,56 +250,23 @@ static int snd_card_saa7134_capture_trigger(snd_pcm_substream_t * substream,
                                          int cmd)
 {
        snd_pcm_runtime_t *runtime = substream->runtime;
-       snd_card_saa7134_pcm_t *saapcm = runtime->private_data;
-       struct saa7134_dev *dev=saapcm->saadev;
+       snd_card_saa7134_pcm_t *pcm = runtime->private_data;
+       struct saa7134_dev *dev=pcm->dev;
        int err = 0;
 
-       spin_lock_irq(&dev->slock);
-        if (cmd == SNDRV_PCM_TRIGGER_START) {
+       spin_lock(&dev->slock);
+       if (cmd == SNDRV_PCM_TRIGGER_START) {
                /* start dma */
                saa7134_dma_start(dev);
-        } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
+       } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
                /* stop dma */
                saa7134_dma_stop(dev);
-        } else {
-                err = -EINVAL;
-        }
-       spin_unlock_irq(&dev->slock);
-
-        return err;
-}
-
-/*
- * DMA buffer config
- *
- *   Sets the values that will later be used as the size of the buffer,
- *  size of the fragments, and total number of fragments.
- *   Must be called during the preparation stage, before memory is
- *  allocated
- *
- *   - Copied verbatim from saa7134-oss. Can be dropped
- *     if we just share dsp_buffer_conf from OSS.
- */
+       } else {
+               err = -EINVAL;
+       }
+       spin_unlock(&dev->slock);
 
-static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks)
-{
-       if (blksize < 0x100)
-               blksize = 0x100;
-       if (blksize > 0x10000)
-               blksize = 0x10000;
-
-       if (blocks < 2)
-               blocks = 2;
-       if ((blksize * blocks) > 1024*1024)
-               blocks = 1024*1024 / blksize;
-
-       dev->dmasound.blocks  = blocks;
-       dev->dmasound.blksize = blksize;
-       dev->dmasound.bufsize = blksize * blocks;
-
-       dprintk("buffer config: %d blocks / %d bytes, %d kB total\n",
-               blocks,blksize,blksize * blocks / 1024);
-       return 0;
+       return err;
 }
 
 /*
@@ -307,16 +276,16 @@ static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks)
  *  ALSA, but I was unable to use ALSA's own DMA, and had to force the
  *  usage of V4L's
  *
- *   - Copied verbatim from saa7134-oss. Can be dropped
- *     if we just share dsp_buffer_init from OSS.
+ *   - Copied verbatim from saa7134-oss.
+ *
  */
 
 static int dsp_buffer_init(struct saa7134_dev *dev)
 {
        int err;
 
-       if (!dev->dmasound.bufsize)
-               BUG();
+       BUG_ON(!dev->dmasound.bufsize);
+
        videobuf_dma_init(&dev->dmasound.dma);
        err = videobuf_dma_init_kernel(&dev->dmasound.dma, PCI_DMA_FROMDEVICE,
                                       (dev->dmasound.bufsize + PAGE_SIZE) >> PAGE_SHIFT);
@@ -325,6 +294,28 @@ static int dsp_buffer_init(struct saa7134_dev *dev)
        return 0;
 }
 
+/*
+ * DMA buffer release
+ *
+ *   Called after closing the device, during snd_card_saa7134_capture_close
+ *
+ */
+
+static int dsp_buffer_free(struct saa7134_dev *dev)
+{
+       if (!dev->dmasound.blksize)
+               BUG();
+
+       videobuf_dma_free(&dev->dmasound.dma);
+
+       dev->dmasound.blocks  = 0;
+       dev->dmasound.blksize = 0;
+       dev->dmasound.bufsize = 0;
+
+       return 0;
+}
+
+
 /*
  * ALSA PCM preparation
  *
@@ -340,84 +331,30 @@ static int dsp_buffer_init(struct saa7134_dev *dev)
 static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream)
 {
        snd_pcm_runtime_t *runtime = substream->runtime;
-       int err, bswap, sign;
+       int bswap, sign;
        u32 fmt, control;
        snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
        struct saa7134_dev *dev;
-       snd_card_saa7134_pcm_t *saapcm = runtime->private_data;
-       unsigned int bps;
-       unsigned long size;
-       unsigned count;
-
-       size = snd_pcm_lib_buffer_bytes(substream);
-       count = snd_pcm_lib_period_bytes(substream);
-
-       saapcm->saadev->dmasound.substream = substream;
-       bps = runtime->rate * runtime->channels;
-       bps *= snd_pcm_format_width(runtime->format);
-       bps /= 8;
-       if (bps <= 0)
-               return -EINVAL;
-       saapcm->pcm_bps = bps;
-       saapcm->pcm_size = snd_pcm_lib_buffer_bytes(substream);
-       saapcm->pcm_count = snd_pcm_lib_period_bytes(substream);
-
+       snd_card_saa7134_pcm_t *pcm = runtime->private_data;
 
-       dev=saa7134->saadev;
+       pcm->dev->dmasound.substream = substream;
 
-       dsp_buffer_conf(dev,saapcm->pcm_count,(saapcm->pcm_size/saapcm->pcm_count));
+       dev = saa7134->dev;
 
-       err = dsp_buffer_init(dev);
-       if (0 != err)
-               goto fail2;
-
-       /* prepare buffer */
-       if (0 != (err = videobuf_dma_pci_map(dev->pci,&dev->dmasound.dma)))
-               return err;
-       if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt)))
-               goto fail1;
-       if (0 != (err = saa7134_pgtable_build(dev->pci,&dev->dmasound.pt,
-                                             dev->dmasound.dma.sglist,
-                                             dev->dmasound.dma.sglen,
-                                             0)))
-               goto fail2;
-
-
-
-       switch (runtime->format) {
-         case SNDRV_PCM_FORMAT_U8:
-         case SNDRV_PCM_FORMAT_S8:
+       if (snd_pcm_format_width(runtime->format) == 8)
                fmt = 0x00;
-               break;
-         case SNDRV_PCM_FORMAT_U16_LE:
-         case SNDRV_PCM_FORMAT_U16_BE:
-         case SNDRV_PCM_FORMAT_S16_LE:
-         case SNDRV_PCM_FORMAT_S16_BE:
+       else
                fmt = 0x01;
-               break;
-         default:
-               err = -EINVAL;
-               return 1;
-       }
 
-       switch (runtime->format) {
-         case SNDRV_PCM_FORMAT_S8:
-         case SNDRV_PCM_FORMAT_S16_LE:
-         case SNDRV_PCM_FORMAT_S16_BE:
+       if (snd_pcm_format_signed(runtime->format))
                sign = 1;
-               break;
-         default:
+       else
                sign = 0;
-               break;
-       }
 
-       switch (runtime->format) {
-         case SNDRV_PCM_FORMAT_U16_BE:
-         case SNDRV_PCM_FORMAT_S16_BE:
-               bswap = 1; break;
-         default:
-               bswap = 0; break;
-       }
+       if (snd_pcm_format_big_endian(runtime->format))
+               bswap = 1;
+       else
+               bswap = 0;
 
        switch (dev->pci->device) {
          case PCI_DEVICE_ID_PHILIPS_SAA7134:
@@ -445,7 +382,6 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream)
                        fmt |= 0x04;
                saa_writel(SAA7133_NUM_SAMPLES, dev->dmasound.blksize -1);
                saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210 | (fmt << 24));
-               //saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210);
                break;
        }
 
@@ -459,12 +395,6 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream)
        if (bswap)
                control |= SAA7134_RS_CONTROL_BSWAP;
 
-       /* I should be able to use runtime->dma_addr in the control
-          byte, but it doesn't work. So I allocate the DMA using the
-          V4L functions, and force ALSA to use that as the DMA area */
-
-       runtime->dma_area = dev->dmasound.dma.vmalloc;
-
        saa_writel(SAA7134_RS_BA1(6),0);
        saa_writel(SAA7134_RS_BA2(6),dev->dmasound.blksize);
        saa_writel(SAA7134_RS_PITCH(6),0);
@@ -473,12 +403,6 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream)
        dev->dmasound.rate = runtime->rate;
 
        return 0;
- fail2:
-       saa7134_pgtable_free(dev->pci,&dev->dmasound.pt);
- fail1:
-       videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma);
-       return err;
-
 
 }
 
@@ -496,10 +420,8 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream)
 static snd_pcm_uframes_t snd_card_saa7134_capture_pointer(snd_pcm_substream_t * substream)
 {
        snd_pcm_runtime_t *runtime = substream->runtime;
-       snd_card_saa7134_pcm_t *saapcm = runtime->private_data;
-       struct saa7134_dev *dev=saapcm->saadev;
-
-
+       snd_card_saa7134_pcm_t *pcm = runtime->private_data;
+       struct saa7134_dev *dev=pcm->dev;
 
        if (dev->dmasound.read_count) {
                dev->dmasound.read_count  -= snd_pcm_lib_period_bytes(substream);
@@ -540,9 +462,9 @@ static snd_pcm_hardware_t snd_card_saa7134_capture =
 
 static void snd_card_saa7134_runtime_free(snd_pcm_runtime_t *runtime)
 {
-       snd_card_saa7134_pcm_t *saapcm = runtime->private_data;
+       snd_card_saa7134_pcm_t *pcm = runtime->private_data;
 
-       kfree(saapcm);
+       kfree(pcm);
 }
 
 
@@ -552,17 +474,76 @@ static void snd_card_saa7134_runtime_free(snd_pcm_runtime_t *runtime)
  *   - One of the ALSA capture callbacks.
  *
  *   Called on initialization, right before the PCM preparation
- *   Usually used in ALSA to allocate the DMA, but since we don't use the
- *  ALSA DMA it does nothing
  *
  */
 
 static int snd_card_saa7134_hw_params(snd_pcm_substream_t * substream,
                                    snd_pcm_hw_params_t * hw_params)
 {
+       snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
+       struct saa7134_dev *dev;
+       unsigned int period_size, periods;
+       int err;
 
-       return 0;
+       period_size = params_period_bytes(hw_params);
+       periods = params_periods(hw_params);
+
+       snd_assert(period_size >= 0x100 && period_size <= 0x10000,
+                  return -EINVAL);
+       snd_assert(periods >= 2, return -EINVAL);
+       snd_assert(period_size * periods <= 1024 * 1024, return -EINVAL);
 
+       dev = saa7134->dev;
+
+       if (dev->dmasound.blocks == periods &&
+           dev->dmasound.blksize == period_size)
+               return 0;
+
+       /* release the old buffer */
+       if (substream->runtime->dma_area) {
+               saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
+               videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma);
+               dsp_buffer_free(dev);
+               substream->runtime->dma_area = NULL;
+       }
+       dev->dmasound.blocks  = periods;
+       dev->dmasound.blksize = period_size;
+       dev->dmasound.bufsize = period_size * periods;
+
+       err = dsp_buffer_init(dev);
+       if (0 != err) {
+               dev->dmasound.blocks  = 0;
+               dev->dmasound.blksize = 0;
+               dev->dmasound.bufsize = 0;
+               return err;
+       }
+
+       if (0 != (err = videobuf_dma_pci_map(dev->pci, &dev->dmasound.dma))) {
+               dsp_buffer_free(dev);
+               return err;
+       }
+       if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt))) {
+               videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma);
+               dsp_buffer_free(dev);
+               return err;
+       }
+       if (0 != (err = saa7134_pgtable_build(dev->pci,&dev->dmasound.pt,
+                                               dev->dmasound.dma.sglist,
+                                               dev->dmasound.dma.sglen,
+                                               0))) {
+               saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
+               videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma);
+               dsp_buffer_free(dev);
+               return err;
+       }
+
+       /* I should be able to use runtime->dma_addr in the control
+          byte, but it doesn't work. So I allocate the DMA using the
+          V4L functions, and force ALSA to use that as the DMA area */
+
+       substream->runtime->dma_area = dev->dmasound.dma.vmalloc;
+
+       return 1;
 
 }
 
@@ -572,33 +553,23 @@ static int snd_card_saa7134_hw_params(snd_pcm_substream_t * substream,
  *   - One of the ALSA capture callbacks.
  *
  *   Called after closing the device, but before snd_card_saa7134_capture_close
- *   Usually used in ALSA to free the DMA, but since we don't use the
- *  ALSA DMA I'm almost sure this isn't necessary.
+ *   It stops the DMA audio and releases the buffers.
  *
  */
 
 static int snd_card_saa7134_hw_free(snd_pcm_substream_t * substream)
 {
-       return 0;
-}
-
-/*
- * DMA buffer release
- *
- *   Called after closing the device, during snd_card_saa7134_capture_close
- *
- */
-
-static int dsp_buffer_free(struct saa7134_dev *dev)
-{
-       if (!dev->dmasound.blksize)
-               BUG();
+       snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
+       struct saa7134_dev *dev;
 
-       videobuf_dma_free(&dev->dmasound.dma);
+       dev = saa7134->dev;
 
-       dev->dmasound.blocks  = 0;
-       dev->dmasound.blksize = 0;
-       dev->dmasound.bufsize = 0;
+       if (substream->runtime->dma_area) {
+               saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
+               videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma);
+               dsp_buffer_free(dev);
+               substream->runtime->dma_area = NULL;
+       }
 
        return 0;
 }
@@ -608,21 +579,12 @@ static int dsp_buffer_free(struct saa7134_dev *dev)
  *
  *   - One of the ALSA capture callbacks.
  *
- *   Called after closing the device. It stops the DMA audio and releases
- *  the buffers
+ *   Called after closing the device.
  *
  */
 
 static int snd_card_saa7134_capture_close(snd_pcm_substream_t * substream)
 {
-       snd_card_saa7134_t *chip = snd_pcm_substream_chip(substream);
-       struct saa7134_dev *dev = chip->saadev;
-
-       /* unlock buffer */
-       saa7134_pgtable_free(dev->pci,&dev->dmasound.pt);
-       videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma);
-
-       dsp_buffer_free(dev);
        return 0;
 }
 
@@ -639,29 +601,28 @@ static int snd_card_saa7134_capture_close(snd_pcm_substream_t * substream)
 static int snd_card_saa7134_capture_open(snd_pcm_substream_t * substream)
 {
        snd_pcm_runtime_t *runtime = substream->runtime;
-       snd_card_saa7134_pcm_t *saapcm;
+       snd_card_saa7134_pcm_t *pcm;
        snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
-       struct saa7134_dev *dev = saa7134->saadev;
+       struct saa7134_dev *dev = saa7134->dev;
        int err;
 
        down(&dev->dmasound.lock);
 
-       dev->dmasound.afmt        = SNDRV_PCM_FORMAT_U8;
-       dev->dmasound.channels    = 2;
        dev->dmasound.read_count  = 0;
        dev->dmasound.read_offset = 0;
 
        up(&dev->dmasound.lock);
 
-       saapcm = kzalloc(sizeof(*saapcm), GFP_KERNEL);
-       if (saapcm == NULL)
+       pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
+       if (pcm == NULL)
                return -ENOMEM;
-       saapcm->saadev=saa7134->saadev;
 
-       spin_lock_init(&saapcm->lock);
+       pcm->dev=saa7134->dev;
 
-       saapcm->substream = substream;
-       runtime->private_data = saapcm;
+       spin_lock_init(&pcm->lock);
+
+       pcm->substream = substream;
+       runtime->private_data = pcm;
        runtime->private_free = snd_card_saa7134_runtime_free;
        runtime->hw = snd_card_saa7134_capture;
 
@@ -736,7 +697,6 @@ static int snd_saa7134_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
 static int snd_saa7134_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
 {
        snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
        int change, addr = kcontrol->private_value;
        int left, right;
 
@@ -750,12 +710,12 @@ static int snd_saa7134_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
                right = 0;
        if (right > 20)
                right = 20;
-       spin_lock_irqsave(&chip->mixer_lock, flags);
+       spin_lock_irq(&chip->mixer_lock);
        change = chip->mixer_volume[addr][0] != left ||
                 chip->mixer_volume[addr][1] != right;
        chip->mixer_volume[addr][0] = left;
        chip->mixer_volume[addr][1] = right;
-       spin_unlock_irqrestore(&chip->mixer_lock, flags);
+       spin_unlock_irq(&chip->mixer_lock);
        return change;
 }
 
@@ -777,38 +737,37 @@ static int snd_saa7134_capsrc_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_
 static int snd_saa7134_capsrc_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
 {
        snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
        int addr = kcontrol->private_value;
 
-       spin_lock_irqsave(&chip->mixer_lock, flags);
+       spin_lock_irq(&chip->mixer_lock);
        ucontrol->value.integer.value[0] = chip->capture_source[addr][0];
        ucontrol->value.integer.value[1] = chip->capture_source[addr][1];
-       spin_unlock_irqrestore(&chip->mixer_lock, flags);
+       spin_unlock_irq(&chip->mixer_lock);
+
        return 0;
 }
 
 static int snd_saa7134_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
 {
        snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
        int change, addr = kcontrol->private_value;
        int left, right;
        u32 anabar, xbarin;
        int analog_io, rate;
        struct saa7134_dev *dev;
 
-       dev = chip->saadev;
+       dev = chip->dev;
 
        left = ucontrol->value.integer.value[0] & 1;
        right = ucontrol->value.integer.value[1] & 1;
-       spin_lock_irqsave(&chip->mixer_lock, flags);
+       spin_lock_irq(&chip->mixer_lock);
 
        change = chip->capture_source[addr][0] != left ||
                 chip->capture_source[addr][1] != right;
        chip->capture_source[addr][0] = left;
        chip->capture_source[addr][1] = right;
        dev->dmasound.input=addr;
-       spin_unlock_irqrestore(&chip->mixer_lock, flags);
+       spin_unlock_irq(&chip->mixer_lock);
 
 
        if (change) {
@@ -898,43 +857,44 @@ static int snd_card_saa7134_new_mixer(snd_card_saa7134_t * chip)
        return 0;
 }
 
-static int snd_saa7134_free(snd_card_saa7134_t *chip)
+static void snd_saa7134_free(snd_card_t * card)
 {
-       return 0;
-}
+       snd_card_saa7134_t *chip = card->private_data;
+
+       if (chip->dev->dmasound.priv_data == NULL)
+               return;
+
+       if (chip->irq >= 0) {
+               synchronize_irq(chip->irq);
+               free_irq(chip->irq, &chip->dev->dmasound);
+       }
+
+       chip->dev->dmasound.priv_data = NULL;
 
-static int snd_saa7134_dev_free(snd_device_t *device)
-{
-       snd_card_saa7134_t *chip = device->device_data;
-       return snd_saa7134_free(chip);
 }
 
 /*
  * ALSA initialization
  *
- *   Called by saa7134-core, it creates the basic structures and registers
- *  the ALSA devices
+ *   Called by the init routine, once for each saa7134 device present,
+ *  it creates the basic structures and registers the ALSA devices
  *
  */
 
-int alsa_card_saa7134_create (struct saa7134_dev *saadev)
+int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum)
 {
-       static int dev;
 
        snd_card_t *card;
        snd_card_saa7134_t *chip;
        int err;
-       static snd_device_ops_t ops = {
-               .dev_free =     snd_saa7134_dev_free,
-       };
 
 
-       if (dev >= SNDRV_CARDS)
+       if (devnum >= SNDRV_CARDS)
                return -ENODEV;
-       if (!enable[dev])
+       if (!enable[devnum])
                return -ENODEV;
 
-       card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
+       card = snd_card_new(index[devnum], id[devnum], THIS_MODULE, sizeof(snd_card_saa7134_t));
 
        if (card == NULL)
                return -ENOMEM;
@@ -943,34 +903,33 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev)
 
        /* Card "creation" */
 
-       chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
-       if (chip == NULL) {
-               return -ENOMEM;
-       }
+       card->private_free = snd_saa7134_free;
+       chip = (snd_card_saa7134_t *) card->private_data;
 
        spin_lock_init(&chip->lock);
        spin_lock_init(&chip->mixer_lock);
 
-       chip->saadev = saadev;
+       chip->dev = dev;
 
        chip->card = card;
 
-       chip->pci = saadev->pci;
-       chip->irq = saadev->pci->irq;
-       chip->iobase = pci_resource_start(saadev->pci, 0);
+       chip->pci = dev->pci;
+       chip->iobase = pci_resource_start(dev->pci, 0);
 
-       err = request_irq(saadev->pci->irq, saa7134_alsa_irq,
-                               SA_SHIRQ | SA_INTERRUPT, saadev->name, saadev);
+
+       err = request_irq(dev->pci->irq, saa7134_alsa_irq,
+                               SA_SHIRQ | SA_INTERRUPT, dev->name,
+                               (void*) &dev->dmasound);
 
        if (err < 0) {
                printk(KERN_ERR "%s: can't get IRQ %d for ALSA\n",
-                       saadev->name, saadev->pci->irq);
+                       dev->name, dev->pci->irq);
                goto __nodev;
        }
 
-       if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
-               goto __nodev;
-       }
+       chip->irq = dev->pci->irq;
+
+       init_MUTEX(&dev->dmasound.lock);
 
        if ((err = snd_card_saa7134_new_mixer(chip)) < 0)
                goto __nodev;
@@ -984,16 +943,15 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev)
 
        strcpy(card->shortname, "SAA7134");
        sprintf(card->longname, "%s at 0x%lx irq %d",
-               chip->saadev->name, chip->iobase, chip->irq);
+               chip->dev->name, chip->iobase, chip->irq);
 
        if ((err = snd_card_register(card)) == 0) {
-               snd_saa7134_cards[dev] = card;
+               snd_saa7134_cards[devnum] = card;
                return 0;
        }
 
 __nodev:
        snd_card_free(card);
-       kfree(chip);
        return err;
 }
 
@@ -1007,21 +965,29 @@ __nodev:
 
 static int saa7134_alsa_init(void)
 {
-        struct saa7134_dev *saadev = NULL;
-        struct list_head *list;
+       struct saa7134_dev *dev = NULL;
+       struct list_head *list;
 
-       printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n");
+       position = 0;
 
-        list_for_each(list,&saa7134_devlist) {
-                saadev = list_entry(list, struct saa7134_dev, devlist);
-               alsa_card_saa7134_create(saadev);
-        }
+        printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n");
 
-       if (saadev == NULL)
+       list_for_each(list,&saa7134_devlist) {
+               dev = list_entry(list, struct saa7134_dev, devlist);
+               if (dev->dmasound.priv_data == NULL) {
+                       dev->dmasound.priv_data = dev;
+                       alsa_card_saa7134_create(dev,position);
+                       position++;
+               } else {
+                       printk(KERN_ERR "saa7134 ALSA: DMA sound is being handled by OSS. ignoring %s\n",dev->name);
+                       return -EBUSY;
+               }
+       }
+
+       if (dev == NULL)
                printk(KERN_INFO "saa7134 ALSA: no saa7134 cards found\n");
 
        return 0;
-
 }
 
 /*
index 663d03e5bc67331fced022c7143953e93d184adc..75abc20b0ccdbdabd0fa69474df09eaaf69adf61 100644 (file)
@@ -2529,6 +2529,32 @@ struct saa7134_board saa7134_boards[] = {
                        .amux   = LINE1,
                }},
        },
+       [SAA7134_BOARD_MSI_TVATANYWHERE_PLUS] = {
+               .name           = "MSI TV@Anywhere plus",
+               .audio_clock    = 0x00187de7,
+               .tuner_type     = TUNER_PHILIPS_TDA8290,
+               .radio_type     = UNSET,
+               .tuner_addr     = ADDR_UNSET,
+               .radio_addr     = ADDR_UNSET,
+               .inputs = {{
+                       .name   = name_tv,
+                       .vmux   = 1,
+                       .amux   = TV,
+                       .tv     = 1,
+               },{
+                       .name   = name_comp1,
+                       .vmux   = 3,
+                       .amux   = LINE1,
+               },{
+                       .name   = name_svideo,
+                       .vmux   = 0,
+                       .amux   = LINE1,
+               }},
+               .radio = {
+                       .name   = name_radio,
+                       .amux   = LINE1,
+               },
+       },
 };
 
 const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
@@ -2969,6 +2995,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
                .subvendor    = PCI_VENDOR_ID_PHILIPS,
                .subdevice    = 0x2018,
                .driver_data  = SAA7134_BOARD_PHILIPS_TIGER,
+       },{
+               .vendor       = PCI_VENDOR_ID_PHILIPS,
+               .device       = PCI_DEVICE_ID_PHILIPS_SAA7133,
+               .subvendor    = 0x1462,
+               .subdevice    = 0x6231,
+               .driver_data  = SAA7134_BOARD_MSI_TVATANYWHERE_PLUS,
        },{
                /* --- boards without eeprom + subsystem ID --- */
                .vendor       = PCI_VENDOR_ID_PHILIPS,
index 19b88744fb31ab3f252b02aa5e5f6b458011b537..4275d2ddb8640af1e02e83b803ba917b5eda0cb1 100644 (file)
@@ -53,13 +53,13 @@ static unsigned int gpio_tracking = 0;
 module_param(gpio_tracking, int, 0644);
 MODULE_PARM_DESC(gpio_tracking,"enable debug messages [gpio]");
 
-static unsigned int oss = 0;
-module_param(oss, int, 0444);
-MODULE_PARM_DESC(oss,"register oss devices (default: no)");
-
 static unsigned int alsa = 0;
-module_param(alsa, int, 0444);
-MODULE_PARM_DESC(alsa,"register alsa devices (default: no)");
+module_param(alsa, int, 0644);
+MODULE_PARM_DESC(alsa,"enable ALSA DMA sound [dmasound]");
+
+static unsigned int oss = 0;
+module_param(oss, int, 0644);
+MODULE_PARM_DESC(oss,"enable OSS DMA sound [dmasound]");
 
 static unsigned int latency = UNSET;
 module_param(latency, int, 0444);
@@ -68,24 +68,18 @@ MODULE_PARM_DESC(latency,"pci latency timer");
 static unsigned int video_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
 static unsigned int vbi_nr[]   = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
 static unsigned int radio_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
-static unsigned int dsp_nr[]   = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
-static unsigned int mixer_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
 static unsigned int tuner[]    = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
 static unsigned int card[]     = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
 
 module_param_array(video_nr, int, NULL, 0444);
 module_param_array(vbi_nr,   int, NULL, 0444);
 module_param_array(radio_nr, int, NULL, 0444);
-module_param_array(dsp_nr,   int, NULL, 0444);
-module_param_array(mixer_nr, int, NULL, 0444);
 module_param_array(tuner,    int, NULL, 0444);
 module_param_array(card,     int, NULL, 0444);
 
 MODULE_PARM_DESC(video_nr, "video device number");
 MODULE_PARM_DESC(vbi_nr,   "vbi device number");
 MODULE_PARM_DESC(radio_nr, "radio device number");
-MODULE_PARM_DESC(dsp_nr,   "oss dsp device number");
-MODULE_PARM_DESC(mixer_nr, "oss mixer device number");
 MODULE_PARM_DESC(tuner,    "tuner type");
 MODULE_PARM_DESC(card,     "card type");
 
@@ -195,6 +189,7 @@ void saa7134_track_gpio(struct saa7134_dev *dev, char *msg)
 static int need_empress;
 static int need_dvb;
 static int need_alsa;
+static int need_oss;
 
 static int pending_call(struct notifier_block *self, unsigned long state,
                        void *module)
@@ -208,6 +203,8 @@ static int pending_call(struct notifier_block *self, unsigned long state,
                request_module("saa7134-dvb");
        if (need_alsa)
                request_module("saa7134-alsa");
+       if (need_oss)
+               request_module("saa7134-oss");
        return NOTIFY_DONE;
 }
 
@@ -218,10 +215,11 @@ static struct notifier_block pending_notifier = {
 
 static void request_module_depend(char *name, int *flag)
 {
+       int err;
        switch (THIS_MODULE->state) {
        case MODULE_STATE_COMING:
                if (!pending_registered) {
-                       register_module_notifier(&pending_notifier);
+                       err = register_module_notifier(&pending_notifier);
                        pending_registered = 1;
                }
                *flag = 1;
@@ -578,12 +576,14 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id, struct pt_regs *regs)
                        goto out;
                }
 
-               /* If alsa support is active and we get a sound report, exit
-                  and let the saa7134-alsa module deal with it */
+               /* If dmasound support is active and we get a sound report, exit
+                  and let the saa7134-alsa/oss module deal with it */
 
-               if ((report & SAA7134_IRQ_REPORT_DONE_RA3) && alsa)  {
+               if ((report & SAA7134_IRQ_REPORT_DONE_RA3) &&
+                       (dev->dmasound.priv_data != NULL) )
+               {
                        if (irq_debug > 1)
-                               printk(KERN_DEBUG "%s/irq: ignoring interrupt for ALSA\n",
+                               printk(KERN_DEBUG "%s/irq: ignoring interrupt for DMA sound\n",
                                       dev->name);
                        goto out;
                }
@@ -609,12 +609,6 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id, struct pt_regs *regs)
                    card_has_mpeg(dev))
                        saa7134_irq_ts_done(dev,status);
 
-               if ((report & SAA7134_IRQ_REPORT_DONE_RA3))  {
-                       if (oss) {
-                               saa7134_irq_oss_done(dev,status);
-                       }
-               }
-
                if ((report & (SAA7134_IRQ_REPORT_GPIO16 |
                               SAA7134_IRQ_REPORT_GPIO18)) &&
                    dev->remote)
@@ -689,14 +683,6 @@ static int saa7134_hwinit1(struct saa7134_dev *dev)
         * audio will not work.
         */
 
-       switch (dev->pci->device) {
-       case PCI_DEVICE_ID_PHILIPS_SAA7134:
-       case PCI_DEVICE_ID_PHILIPS_SAA7133:
-       case PCI_DEVICE_ID_PHILIPS_SAA7135:
-               saa7134_oss_init1(dev);
-               break;
-       }
-
        /* enable peripheral devices */
        saa_writeb(SAA7134_SPECIAL_MODE, 0x01);
 
@@ -728,8 +714,6 @@ static int saa7134_hwinit2(struct saa7134_dev *dev)
                irq2_mask |= (SAA7134_IRQ2_INTE_GPIO18  |
                              SAA7134_IRQ2_INTE_GPIO18A |
                              SAA7134_IRQ2_INTE_GPIO16  );
-       else if (dev->has_remote == SAA7134_REMOTE_I2C)
-               request_module("ir-kbd-i2c");
 
        saa_writel(SAA7134_IRQ1, 0);
        saa_writel(SAA7134_IRQ2, irq2_mask);
@@ -742,13 +726,6 @@ static int saa7134_hwfini(struct saa7134_dev *dev)
 {
        dprintk("hwfini\n");
 
-       switch (dev->pci->device) {
-       case PCI_DEVICE_ID_PHILIPS_SAA7134:
-       case PCI_DEVICE_ID_PHILIPS_SAA7133:
-       case PCI_DEVICE_ID_PHILIPS_SAA7135:
-               saa7134_oss_fini(dev);
-               break;
-       }
        if (card_has_mpeg(dev))
                saa7134_ts_fini(dev);
        saa7134_input_fini(dev);
@@ -986,11 +963,12 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
        if (card_is_dvb(dev))
                request_module_depend("saa7134-dvb",&need_dvb);
 
-       if (!oss && alsa) {
-               dprintk("Requesting ALSA module\n");
+
+       if (alsa)
                request_module_depend("saa7134-alsa",&need_alsa);
-       }
 
+       if (oss)
+               request_module_depend("saa7134-oss",&need_oss);
 
        v4l2_prio_init(&dev->prio);
 
@@ -1024,32 +1002,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
                       dev->name,dev->radio_dev->minor & 0x1f);
        }
 
-       /* register oss devices */
-       switch (dev->pci->device) {
-       case PCI_DEVICE_ID_PHILIPS_SAA7134:
-       case PCI_DEVICE_ID_PHILIPS_SAA7133:
-       case PCI_DEVICE_ID_PHILIPS_SAA7135:
-               if (oss) {
-                       err = dev->dmasound.minor_dsp =
-                               register_sound_dsp(&saa7134_dsp_fops,
-                                                  dsp_nr[dev->nr]);
-                       if (err < 0) {
-                               goto fail4;
-                       }
-                       printk(KERN_INFO "%s: registered device dsp%d\n",
-                              dev->name,dev->dmasound.minor_dsp >> 4);
-
-                       err = dev->dmasound.minor_mixer =
-                               register_sound_mixer(&saa7134_mixer_fops,
-                                                    mixer_nr[dev->nr]);
-                       if (err < 0)
-                               goto fail5;
-                       printk(KERN_INFO "%s: registered device mixer%d\n",
-                              dev->name,dev->dmasound.minor_mixer >> 4);
-               }
-               break;
-       }
-
        /* everything worked */
        pci_set_drvdata(pci_dev,dev);
        saa7134_devcount++;
@@ -1064,17 +1016,9 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
 
        /* check for signal */
        saa7134_irq_video_intl(dev);
+
        return 0;
 
- fail5:
-       switch (dev->pci->device) {
-       case PCI_DEVICE_ID_PHILIPS_SAA7134:
-       case PCI_DEVICE_ID_PHILIPS_SAA7133:
-       case PCI_DEVICE_ID_PHILIPS_SAA7135:
-               if (oss)
-                       unregister_sound_dsp(dev->dmasound.minor_dsp);
-               break;
-       }
  fail4:
        saa7134_unregister_video(dev);
        saa7134_i2c_unregister(dev);
@@ -1125,19 +1069,16 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
        saa7134_devcount--;
 
        saa7134_i2c_unregister(dev);
-       switch (dev->pci->device) {
-       case PCI_DEVICE_ID_PHILIPS_SAA7134:
-       case PCI_DEVICE_ID_PHILIPS_SAA7133:
-       case PCI_DEVICE_ID_PHILIPS_SAA7135:
-               if (oss) {
-                       unregister_sound_mixer(dev->dmasound.minor_mixer);
-                       unregister_sound_dsp(dev->dmasound.minor_dsp);
-               }
-               break;
-       }
        saa7134_unregister_video(dev);
 
-       /* release ressources */
+       /* the DMA sound modules should be unloaded before reaching
+          this, but just in case they are still present... */
+       if (dev->dmasound.priv_data != NULL) {
+               free_irq(pci_dev->irq, &dev->dmasound);
+               dev->dmasound.priv_data = NULL;
+       }
+
+       /* release resources */
        free_irq(pci_dev->irq, dev);
        iounmap(dev->lmmio);
        release_mem_region(pci_resource_start(pci_dev,0),
@@ -1225,7 +1166,7 @@ EXPORT_SYMBOL(saa7134_i2c_call_clients);
 EXPORT_SYMBOL(saa7134_devlist);
 EXPORT_SYMBOL(saa7134_boards);
 
-/* ----------------- For ALSA -------------------------------- */
+/* ----------------- for the DMA sound modules --------------- */
 
 EXPORT_SYMBOL(saa7134_pgtable_free);
 EXPORT_SYMBOL(saa7134_pgtable_build);
index 329accda6d45a73774bf1bf28cd90c496e3f6582..e648cc3bc96d33220527a7bd409034370ae72e4c 100644 (file)
@@ -485,64 +485,6 @@ static IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE] = {
 
 };
 
-static IR_KEYTAB_TYPE ir_codes_pinnacle[IR_KEYTAB_SIZE] = {
-       [ 0x59 ] = KEY_MUTE,
-       [ 0x4a ] = KEY_POWER,
-
-       [ 0x18 ] = KEY_TEXT,
-       [ 0x26 ] = KEY_TV,
-       [ 0x3d ] = KEY_PRINT,
-
-       [ 0x48 ] = KEY_RED,
-       [ 0x04 ] = KEY_GREEN,
-       [ 0x11 ] = KEY_YELLOW,
-       [ 0x00 ] = KEY_BLUE,
-
-       [ 0x2d ] = KEY_VOLUMEUP,
-       [ 0x1e ] = KEY_VOLUMEDOWN,
-
-       [ 0x49 ] = KEY_MENU,
-
-       [ 0x16 ] = KEY_CHANNELUP,
-       [ 0x17 ] = KEY_CHANNELDOWN,
-
-       [ 0x20 ] = KEY_UP,
-       [ 0x21 ] = KEY_DOWN,
-       [ 0x22 ] = KEY_LEFT,
-       [ 0x23 ] = KEY_RIGHT,
-       [ 0x0d ] = KEY_SELECT,
-
-
-
-       [ 0x08 ] = KEY_BACK,
-       [ 0x07 ] = KEY_REFRESH,
-
-       [ 0x2f ] = KEY_ZOOM,
-       [ 0x29 ] = KEY_RECORD,
-
-       [ 0x4b ] = KEY_PAUSE,
-       [ 0x4d ] = KEY_REWIND,
-       [ 0x2e ] = KEY_PLAY,
-       [ 0x4e ] = KEY_FORWARD,
-       [ 0x53 ] = KEY_PREVIOUS,
-       [ 0x4c ] = KEY_STOP,
-       [ 0x54 ] = KEY_NEXT,
-
-       [ 0x69 ] = KEY_KP0,
-       [ 0x6a ] = KEY_KP1,
-       [ 0x6b ] = KEY_KP2,
-       [ 0x6c ] = KEY_KP3,
-       [ 0x6d ] = KEY_KP4,
-       [ 0x6e ] = KEY_KP5,
-       [ 0x6f ] = KEY_KP6,
-       [ 0x70 ] = KEY_KP7,
-       [ 0x71 ] = KEY_KP8,
-       [ 0x72 ] = KEY_KP9,
-
-       [ 0x74 ] = KEY_CHANNEL,
-       [ 0x0a ] = KEY_BACKSPACE,
-};
-
 /* Mapping for the 28 key remote control as seen at
    http://www.sednacomputer.com/photo/cardbus-tv.jpg
    Pavel Mihaylov <bin@bash.info> */
@@ -635,57 +577,6 @@ static int get_key_purpletv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
        return 1;
 }
 
-/* The new pinnacle PCTV remote (with the colored buttons)
- *
- * Ricardo Cerqueira <v4l@cerqueira.org>
- */
-
-static int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
-{
-       unsigned char b[4];
-       unsigned int start = 0,parity = 0,code = 0;
-
-       /* poll IR chip */
-       if (4 != i2c_master_recv(&ir->c,b,4)) {
-               i2cdprintk("read error\n");
-               return -EIO;
-       }
-
-       for (start = 0; start<4; start++) {
-               if (b[start] == 0x80) {
-                       code=b[(start+3)%4];
-                       parity=b[(start+2)%4];
-               }
-       }
-
-       /* Empty Request */
-       if (parity==0)
-               return 0;
-
-       /* Repeating... */
-       if (ir->old == parity)
-               return 0;
-
-
-       ir->old = parity;
-
-       /* Reduce code value to fit inside IR_KEYTAB_SIZE
-        *
-        * this is the only value that results in 42 unique
-        * codes < 128
-        */
-
-       code %= 0x88;
-
-       *ir_raw = code;
-       *ir_key = code;
-
-       i2cdprintk("Pinnacle PCTV key %02x\n", code);
-
-       return 1;
-}
-
-
 void saa7134_input_irq(struct saa7134_dev *dev)
 {
        struct saa7134_ir *ir = dev->remote;
index fd53dfcc16444eb175a03239cf922991ddf0a425..fd9ed11ab1e29c844649803003ce8dc01e8b3794 100644 (file)
@@ -4,6 +4,8 @@
  * oss dsp interface
  *
  * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
+ *     2005 conversion to standalone module:
+ *         Ricardo Cerqueira <v4l@cerqueira.org>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -25,7 +27,9 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
+#include <linux/interrupt.h>
 #include <linux/slab.h>
+#include <linux/sound.h>
 #include <linux/soundcard.h>
 
 #include "saa7134-reg.h"
 
 /* ------------------------------------------------------------------ */
 
-static unsigned int oss_debug  = 0;
-module_param(oss_debug, int, 0644);
-MODULE_PARM_DESC(oss_debug,"enable debug messages [oss]");
+static unsigned int debug  = 0;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug,"enable debug messages [oss]");
 
-static unsigned int oss_rate  = 0;
-module_param(oss_rate, int, 0444);
-MODULE_PARM_DESC(oss_rate,"sample rate (valid are: 32000,48000)");
+static unsigned int rate  = 0;
+module_param(rate, int, 0444);
+MODULE_PARM_DESC(rate,"sample rate (valid are: 32000,48000)");
 
-#define dprintk(fmt, arg...)   if (oss_debug) \
+static unsigned int dsp_nr[]   = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
+MODULE_PARM_DESC(dsp_nr, "device numbers for SAA7134 capture interface(s).");
+module_param_array(dsp_nr,   int, NULL, 0444);
+
+static unsigned int mixer_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
+MODULE_PARM_DESC(mixer_nr, "mixer numbers for SAA7134 capture interface(s).");
+module_param_array(mixer_nr, int, NULL, 0444);
+
+#define dprintk(fmt, arg...)   if (debug) \
        printk(KERN_DEBUG "%s/oss: " fmt, dev->name , ## arg)
 
 
@@ -369,7 +381,7 @@ static int dsp_ioctl(struct inode *inode, struct file *file,
        int __user *p = argp;
        int val = 0;
 
-       if (oss_debug > 1)
+       if (debug > 1)
                saa7134_print_ioctl(dev->name,cmd);
        switch (cmd) {
        case OSS_GETVERSION:
@@ -665,7 +677,7 @@ static int mixer_ioctl(struct inode *inode, struct file *file,
        void __user *argp = (void __user *) arg;
        int __user *p = argp;
 
-       if (oss_debug > 1)
+       if (debug > 1)
                saa7134_print_ioctl(dev->name,cmd);
        switch (cmd) {
        case OSS_GETVERSION:
@@ -768,8 +780,41 @@ struct file_operations saa7134_mixer_fops = {
 
 /* ------------------------------------------------------------------ */
 
+static irqreturn_t saa7134_oss_irq(int irq, void *dev_id, struct pt_regs *regs)
+{
+        struct saa7134_dmasound *dmasound = dev_id;
+        struct saa7134_dev *dev = dmasound->priv_data;
+        unsigned long report, status;
+        int loop, handled = 0;
+
+        for (loop = 0; loop < 10; loop++) {
+                report = saa_readl(SAA7134_IRQ_REPORT);
+                status = saa_readl(SAA7134_IRQ_STATUS);
+
+                if (report & SAA7134_IRQ_REPORT_DONE_RA3) {
+                        handled = 1;
+                        saa_writel(SAA7134_IRQ_REPORT,report);
+                        saa7134_irq_oss_done(dev, status);
+                } else {
+                        goto out;
+                }
+        }
+
+        if (loop == 10) {
+                dprintk("error! looping IRQ!");
+        }
+out:
+        return IRQ_RETVAL(handled);
+}
+
 int saa7134_oss_init1(struct saa7134_dev *dev)
 {
+
+        if ((request_irq(dev->pci->irq, saa7134_oss_irq,
+                         SA_SHIRQ | SA_INTERRUPT, dev->name,
+                       (void*) &dev->dmasound)) < 0)
+               return -1;
+
        /* general */
        init_MUTEX(&dev->dmasound.lock);
        init_waitqueue_head(&dev->dmasound.wq);
@@ -785,8 +830,8 @@ int saa7134_oss_init1(struct saa7134_dev *dev)
 
        /* dsp */
        dev->dmasound.rate = 32000;
-       if (oss_rate)
-               dev->dmasound.rate = oss_rate;
+       if (rate)
+               dev->dmasound.rate = rate;
        dev->dmasound.rate = (dev->dmasound.rate > 40000) ? 48000 : 32000;
 
        /* mixer */
@@ -840,7 +885,7 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status)
        /* next block addr */
        next_blk = (dev->dmasound.dma_blk + 2) % dev->dmasound.blocks;
        saa_writel(reg,next_blk * dev->dmasound.blksize);
-       if (oss_debug > 2)
+       if (debug > 2)
                dprintk("irq: ok, %s, next_blk=%d, addr=%x\n",
                        (status & 0x10000000) ? "even" : "odd ", next_blk,
                        next_blk * dev->dmasound.blksize);
@@ -854,6 +899,98 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status)
        spin_unlock(&dev->slock);
 }
 
+int saa7134_dsp_create(struct saa7134_dev *dev)
+{
+       int err;
+
+                        err = dev->dmasound.minor_dsp =
+                                register_sound_dsp(&saa7134_dsp_fops,
+                                                   dsp_nr[dev->nr]);
+                        if (err < 0) {
+                                goto fail;
+                        }
+                        printk(KERN_INFO "%s: registered device dsp%d\n",
+                               dev->name,dev->dmasound.minor_dsp >> 4);
+
+                        err = dev->dmasound.minor_mixer =
+                                register_sound_mixer(&saa7134_mixer_fops,
+                                                     mixer_nr[dev->nr]);
+                        if (err < 0)
+                                goto fail;
+                        printk(KERN_INFO "%s: registered device mixer%d\n",
+                               dev->name,dev->dmasound.minor_mixer >> 4);
+
+       return 0;
+
+fail:
+        unregister_sound_dsp(dev->dmasound.minor_dsp);
+       return 0;
+
+
+}
+
+static int saa7134_oss_init(void)
+{
+        struct saa7134_dev *dev = NULL;
+        struct list_head *list;
+
+        printk(KERN_INFO "saa7134 OSS driver for DMA sound loaded\n");
+
+        list_for_each(list,&saa7134_devlist) {
+                dev = list_entry(list, struct saa7134_dev, devlist);
+               if (dev->dmasound.priv_data == NULL) {
+                       dev->dmasound.priv_data = dev;
+                       saa7134_oss_init1(dev);
+                       saa7134_dsp_create(dev);
+               } else {
+                       printk(KERN_ERR "saa7134 OSS: DMA sound is being handled by ALSA, ignoring %s\n",dev->name);
+                       return -EBUSY;
+               }
+        }
+
+        if (dev == NULL)
+                printk(KERN_INFO "saa7134 OSS: no saa7134 cards found\n");
+
+        return 0;
+
+}
+
+void saa7134_oss_exit(void)
+{
+        struct saa7134_dev *dev = NULL;
+        struct list_head *list;
+
+        list_for_each(list,&saa7134_devlist) {
+                dev = list_entry(list, struct saa7134_dev, devlist);
+
+               /* Device isn't registered by OSS, probably ALSA's */
+               if (!dev->dmasound.minor_dsp)
+                       continue;
+
+                unregister_sound_mixer(dev->dmasound.minor_mixer);
+                unregister_sound_dsp(dev->dmasound.minor_dsp);
+
+               saa7134_oss_fini(dev);
+
+               if (dev->pci->irq > 0) {
+                       synchronize_irq(dev->pci->irq);
+                       free_irq(dev->pci->irq,&dev->dmasound);
+               }
+
+               dev->dmasound.priv_data = NULL;
+
+        }
+
+        printk(KERN_INFO "saa7134 OSS driver for DMA sound unloaded\n");
+
+        return;
+}
+
+module_init(saa7134_oss_init);
+module_exit(saa7134_oss_exit);
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
+
 /* ----------------------------------------------------------- */
 /*
  * Local variables:
index fb97274716615e18f52a21537c6d865d3e0ad752..244e1973081cc2e8ca64de7638ec218423f504c0 100644 (file)
@@ -208,6 +208,7 @@ struct saa7134_format {
 #define SAA7134_BOARD_SEDNA_PC_TV_CARDBUS     79
 #define SAA7134_BOARD_ASUSTEK_DIGIMATRIX_TV 80
 #define SAA7134_BOARD_PHILIPS_TIGER  81
+#define SAA7134_BOARD_MSI_TVATANYWHERE_PLUS  82
 
 #define SAA7134_MAXBOARDS 8
 #define SAA7134_INPUT_MAX 8
@@ -383,6 +384,7 @@ struct saa7134_dmasound {
        unsigned int               dma_blk;
        unsigned int               read_offset;
        unsigned int               read_count;
+       void *                     priv_data;
        snd_pcm_substream_t        *substream;
 };
 
index b2dfe07e9f9d7abd055df318b4b08e3567152000..61d94ddaff41f836f925a96a997266623aabb8c8 100644 (file)
@@ -437,6 +437,10 @@ static void set_audio(struct tuner *t)
                t->sgIF = 124;
                t->tda8290_easy_mode = 0x20;
                mode = "L";
+       } else if (t->std & V4L2_STD_SECAM_LC) {
+               t->sgIF = 20;
+               t->tda8290_easy_mode = 0x40;
+               mode = "LC";
        }
     tuner_dbg("setting tda8290 to system %s\n", mode);
 }
index 73c4041c35d78811f1fdd25585c6187c5ffa32b3..e58abdfcaab8bcfc5c64adf572fb55818ef785a5 100644 (file)
@@ -251,7 +251,7 @@ static inline int check_mode(struct tuner *t, char *cmd)
 
 static char pal[] = "-";
 module_param_string(pal, pal, sizeof(pal), 0644);
-static char secam[] = "-";
+static char secam[] = "--";
 module_param_string(secam, secam, sizeof(secam), 0644);
 
 /* get more precise norm info from insmod option */
@@ -307,8 +307,13 @@ static int tuner_fixup_std(struct tuner *t)
                        break;
                case 'l':
                case 'L':
-                       tuner_dbg ("insmod fixup: SECAM => SECAM-L\n");
-                       t->std = V4L2_STD_SECAM_L;
+                       if ((secam[1]=='C')||(secam[1]=='c')) {
+                               tuner_dbg ("insmod fixup: SECAM => SECAM-L'\n");
+                               t->std = V4L2_STD_SECAM_LC;
+                       } else {
+                               tuner_dbg ("insmod fixup: SECAM => SECAM-L\n");
+                               t->std = V4L2_STD_SECAM_L;
+                       }
                        break;
                case '-':
                        /* default parameter, do nothing */
index d832205818f21ef94b0c0d85e4e2e016a938a5db..e0c9fdb9914a673846ba6ffb3aae3cee5d55d7c3 100644 (file)
@@ -233,7 +233,7 @@ static struct tunertype tuners[] = {
        { "Ymec TVision TVF-5533MF", Philips, NTSC,
          16*160.00,16*454.00,0x01,0x02,0x04,0x8e,732},
 
-       /* 60-68 */
+       /* 60-69 */
        { "Thomson DDT 7611 (ATSC/NTSC)", THOMSON, ATSC,
          16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732},
        { "Tena TNF9533-D/IF/TNF9533-B/DF", Philips, PAL,
@@ -252,6 +252,8 @@ static struct tunertype tuners[] = {
          16*160.00,16*442.00,0xa1,0xa2,0xa4,0xc8,623 },
        { "Philips TUV1236D ATSC/NTSC dual in", Philips, ATSC,
          16*157.25,16*454.00,0x01,0x02,0x04,0xce,732 },
+       { "Tena TNF 5335 MF", Philips, NTSC,
+         16*157.25,16*454.00,0x01,0x02,0x04,0x8e,732 },
 };
 
 unsigned const int tuner_count = ARRAY_SIZE(tuners);
index 22f2862220048c4b0c56a09215a16344a675a1ba..a6936ad74fcf49073bc635aba17c84dd09dd262a 100644 (file)
@@ -5,6 +5,11 @@
  *
  * Based on saa7115 driver
  *
+ * Copyright (C) 2005 Hans Verkuil <hverkuil@xs4all.nl>
+ * - Cleanup
+ * - V4L2 API update
+ * - sound fixes
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
@@ -31,7 +36,7 @@
 #include <media/audiochip.h>
 
 MODULE_DESCRIPTION("wm8775 driver");
-MODULE_AUTHOR("Ulf Eklund");
+MODULE_AUTHOR("Ulf Eklund, Hans Verkuil");
 MODULE_LICENSE("GPL");
 
 #define wm8775_err(fmt, arg...) do { \
index 1e6bdba2675639568443cc1afb7ca5e603ae151a..166c9b0ad04ef7a43be4e63f6f5e66483cbdd80a 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <asm/div64.h>
 #include <asm/io.h>
-#include <asm/irq.h>
 #include <asm/scatterlist.h>
 #include <asm/sizes.h>
 #include <asm/hardware/amba.h>
index 48638c8097a56b9204bcec9dad9019121b681d40..846a533323a8ee845da72d8299b6425f6a47ffcd 100644 (file)
@@ -94,7 +94,7 @@ config MTD_NETSC520
 
 config MTD_TS5500
        tristate "JEDEC Flash device mapped on Technologic Systems TS-5500"
-       depends on ELAN
+       depends on X86
        select MTD_PARTITIONS
        select MTD_JEDECPROBE
        select MTD_CFI_AMDSTD
index 977935a3d898d00fcfb6a2c12e297f6a7a49cc83..824e430486c2720dce930244b149dcd0650a60e5 100644 (file)
@@ -84,6 +84,7 @@ static int max_interrupt_work = 10;
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/pm.h>
+#include <linux/pm_legacy.h>
 #include <linux/skbuff.h>
 #include <linux/delay.h>       /* for udelay() */
 #include <linux/spinlock.h>
@@ -173,7 +174,7 @@ struct el3_private {
        /* skb send-queue */
        int head, size;
        struct sk_buff *queue[SKB_QUEUE_SIZE];
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_LEGACY
        struct pm_dev *pmdev;
 #endif
        enum {
@@ -200,7 +201,7 @@ static void el3_tx_timeout (struct net_device *dev);
 static void el3_down(struct net_device *dev);
 static void el3_up(struct net_device *dev);
 static struct ethtool_ops ethtool_ops;
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_LEGACY
 static int el3_suspend(struct pm_dev *pdev);
 static int el3_resume(struct pm_dev *pdev);
 static int el3_pm_callback(struct pm_dev *pdev, pm_request_t rqst, void *data);
@@ -361,7 +362,7 @@ static void el3_common_remove (struct net_device *dev)
        struct el3_private *lp = netdev_priv(dev);
 
        (void) lp;                              /* Keep gcc quiet... */
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_LEGACY
        if (lp->pmdev)
                pm_unregister(lp->pmdev);
 #endif
@@ -571,7 +572,7 @@ no_pnp:
        if (err)
                goto out1;
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_LEGACY
        /* register power management */
        lp->pmdev = pm_register(PM_ISA_DEV, card_idx, el3_pm_callback);
        if (lp->pmdev) {
@@ -1479,7 +1480,7 @@ el3_up(struct net_device *dev)
 }
 
 /* Power Management support functions */
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_LEGACY
 
 static int
 el3_suspend(struct pm_dev *pdev)
@@ -1548,7 +1549,7 @@ el3_pm_callback(struct pm_dev *pdev, pm_request_t rqst, void *data)
        return 0;
 }
 
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM_LEGACY */
 
 /* Parameters that may be passed into the module. */
 static int debug = -1;
index e3a329539f1cc5d14d88fa453359cbac80ff1a47..0f030b73cbb328b246e170d85e9401182659d860 100644 (file)
@@ -6,7 +6,7 @@
  * Based on 8260_io/fcc_enet.c
  *
  * Author: Andy Fleming
- * Maintainer: Kumar Gala (kumar.gala@freescale.com)
+ * Maintainer: Kumar Gala
  *
  * Copyright (c) 2002-2004 Freescale Semiconductor, Inc.
  *
index 220084e53341ddce82122a82489328bd95013bbe..5065ba82cb7608324d7b8d6f1a2a37a2b5b3fff2 100644 (file)
@@ -6,7 +6,7 @@
  * Based on 8260_io/fcc_enet.c
  *
  * Author: Andy Fleming
- * Maintainer: Kumar Gala (kumar.gala@freescale.com)
+ * Maintainer: Kumar Gala
  *
  * Copyright (c) 2002-2004 Freescale Semiconductor, Inc.
  *
index 5a2d810ce57538534dba620dfdb9b547c7096cc4..cfa3cd7c91a0a9c777851379e1c63d9eeae217a9 100644 (file)
@@ -6,7 +6,7 @@
  *  Based on e1000 ethtool support
  *
  *  Author: Andy Fleming
- *  Maintainer: Kumar Gala (kumar.gala@freescale.com)
+ *  Maintainer: Kumar Gala
  *
  *  Copyright (c) 2003,2004 Freescale Semiconductor, Inc.
  *
index 9544279e8bcde06fef3a56e7e37bb8367b5cc517..04a462c2a5b7e8bd47bdb0299841d63840816467 100644 (file)
@@ -5,7 +5,7 @@
  * Provides Bus interface for MIIM regs
  *
  * Author: Andy Fleming
- * Maintainer: Kumar Gala (kumar.gala@freescale.com)
+ * Maintainer: Kumar Gala
  *
  * Copyright (c) 2002-2004 Freescale Semiconductor, Inc.
  *
index 56e5665d5c9b8e072fe2ad4320696ff40c2b7f67..e85eb216fb5be40464e1dfdf0402f77059bfeafb 100644 (file)
@@ -5,7 +5,7 @@
  * Driver for the MDIO bus controller in the Gianfar register space
  *
  * Author: Andy Fleming
- * Maintainer: Kumar Gala (kumar.gala@freescale.com)
+ * Maintainer: Kumar Gala
  *
  * Copyright (c) 2002-2004 Freescale Semiconductor, Inc.
  *
index 9bf34681d3dfecb0920973ff0565f16d29329109..2e7882eb7d6fb02a1d980c2467e638f317a1c915 100644 (file)
@@ -40,6 +40,7 @@
 #include <asm/byteorder.h>
 
 #include <linux/pm.h>
+#include <linux/pm_legacy.h>
 
 #include <net/irda/wrapper.h>
 #include <net/irda/irda.h>
index 805714ec9a8a185db963f1285c2caf0929b14f28..ee717d0e939e5e016726b112b18c914363ce3223 100644 (file)
@@ -59,6 +59,7 @@
 #include <asm/byteorder.h>
 
 #include <linux/pm.h>
+#include <linux/pm_legacy.h>
 
 #include <net/irda/wrapper.h>
 #include <net/irda/irda.h>
index de399563a9db2e02ef20d412820a90bc6e6c00e3..081717d01374349ce68386496f0eb079c064be18 100644 (file)
@@ -128,6 +128,8 @@ static struct pci_device_id gem_pci_tbl[] = {
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
        { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_SH_SUNGEM,
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+       { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_IPID2_GMAC,
+         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
        {0, }
 };
 
index 4a3cecca012c33fcb2a4c5da95838e6e3d718160..2387e75da0feee0ab93e4491fc3b1ee0ad0d0f62 100644 (file)
@@ -31,6 +31,8 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/pci.h>
+#include <linux/interrupt.h>
+
 #include "../pci.h"
 #include "pciehp.h"
 
index a7859a84d1ae9a4280435ce3172ef145461e2caf..4b35097b3d9fba0201dca7e2bca9f6fa8eb07dd9 100644 (file)
@@ -253,7 +253,7 @@ rpaphp_pci_config_slot(struct pci_bus *bus)
        if (!dn || !dn->child)
                return NULL;
 
-       if (systemcfg->platform == PLATFORM_PSERIES_LPAR) {
+       if (_machine == PLATFORM_PSERIES_LPAR) {
                of_scan_bus(dn, bus);
                if (list_empty(&bus->devices)) {
                        err("%s: No new device found\n", __FUNCTION__);
index 40905a6c809414f34fe196c1cd5d2099c2ea2221..9987a6fd65b8522af288925b78fe30361b4f4eea 100644 (file)
@@ -31,6 +31,8 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/pci.h>
+#include <linux/interrupt.h>
+
 #include "shpchp.h"
 
 #ifdef DEBUG
index 5774bdd0e26faaa2e70ba1362978251fac2f19ca..9b988baf0b5191304ca00ac042851b055f002bd7 100644 (file)
@@ -210,27 +210,6 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
        }
 }
 
-static long rtc_compat_ioctl(struct file *file, unsigned int cmd,
-       unsigned long arg)
-{
-       int rval = -ENOIOCTLCMD;
-
-       switch (cmd) {
-       /*
-        * These two are specific to this driver, the generic rtc ioctls
-        * are hanlded elsewhere.
-        */
-       case RTCGET:
-       case RTCSET:
-               lock_kernel();
-               rval = rtc_ioctl(file->f_dentry->d_inode, file, cmd, arg);
-               unlock_kernel();
-               break;
-       }
-
-       return rval;
-}
-
 static int rtc_open(struct inode *inode, struct file *file)
 {
        int ret;
@@ -258,7 +237,6 @@ static struct file_operations rtc_fops = {
        .owner =        THIS_MODULE,
        .llseek =       no_llseek,
        .ioctl =        rtc_ioctl,
-       .compat_ioctl = rtc_compat_ioctl,
        .open =         rtc_open,
        .release =      rtc_release,
 };
index 57ef7ae387d947ee1256feeb0bf125be1523c0e9..4e96ec5f2ff94f003a5fe06ee75d92ae5603ec54 100644 (file)
@@ -134,6 +134,7 @@ enum {
                                  PORT_IRQ_D2H_REG_FIS,
 
        /* PORT_CMD bits */
+       PORT_CMD_ATAPI          = (1 << 24), /* Device is ATAPI */
        PORT_CMD_LIST_ON        = (1 << 15), /* cmd list DMA engine running */
        PORT_CMD_FIS_ON         = (1 << 14), /* FIS DMA engine running */
        PORT_CMD_FIS_RX         = (1 << 4), /* Enable FIS receive DMA engine */
@@ -441,7 +442,7 @@ static void ahci_phy_reset(struct ata_port *ap)
        void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
        struct ata_taskfile tf;
        struct ata_device *dev = &ap->device[0];
-       u32 tmp;
+       u32 new_tmp, tmp;
 
        __sata_phy_reset(ap);
 
@@ -455,8 +456,21 @@ static void ahci_phy_reset(struct ata_port *ap)
        tf.nsect        = (tmp)         & 0xff;
 
        dev->class = ata_dev_classify(&tf);
-       if (!ata_dev_present(dev))
+       if (!ata_dev_present(dev)) {
                ata_port_disable(ap);
+               return;
+       }
+
+       /* Make sure port's ATAPI bit is set appropriately */
+       new_tmp = tmp = readl(port_mmio + PORT_CMD);
+       if (dev->class == ATA_DEV_ATAPI)
+               new_tmp |= PORT_CMD_ATAPI;
+       else
+               new_tmp &= ~PORT_CMD_ATAPI;
+       if (new_tmp != tmp) {
+               writel(new_tmp, port_mmio + PORT_CMD);
+               readl(port_mmio + PORT_CMD); /* flush */
+       }
 }
 
 static u8 ahci_check_status(struct ata_port *ap)
@@ -474,11 +488,12 @@ static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
        ata_tf_from_fis(d2h_fis, tf);
 }
 
-static void ahci_fill_sg(struct ata_queued_cmd *qc)
+static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc)
 {
        struct ahci_port_priv *pp = qc->ap->private_data;
        struct scatterlist *sg;
        struct ahci_sg *ahci_sg;
+       unsigned int n_sg = 0;
 
        VPRINTK("ENTER\n");
 
@@ -493,8 +508,12 @@ static void ahci_fill_sg(struct ata_queued_cmd *qc)
                ahci_sg->addr = cpu_to_le32(addr & 0xffffffff);
                ahci_sg->addr_hi = cpu_to_le32((addr >> 16) >> 16);
                ahci_sg->flags_size = cpu_to_le32(sg_len - 1);
+
                ahci_sg++;
+               n_sg++;
        }
+
+       return n_sg;
 }
 
 static void ahci_qc_prep(struct ata_queued_cmd *qc)
@@ -503,13 +522,14 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc)
        struct ahci_port_priv *pp = ap->private_data;
        u32 opts;
        const u32 cmd_fis_len = 5; /* five dwords */
+       unsigned int n_elem;
 
        /*
         * Fill in command slot information (currently only one slot,
         * slot 0, is currently since we don't do queueing)
         */
 
-       opts = (qc->n_elem << 16) | cmd_fis_len;
+       opts = cmd_fis_len;
        if (qc->tf.flags & ATA_TFLAG_WRITE)
                opts |= AHCI_CMD_WRITE;
        if (is_atapi_taskfile(&qc->tf))
@@ -533,7 +553,9 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc)
        if (!(qc->flags & ATA_QCFLAG_DMAMAP))
                return;
 
-       ahci_fill_sg(qc);
+       n_elem = ahci_fill_sg(qc);
+
+       pp->cmd_slot[0].opts |= cpu_to_le32(n_elem << 16);
 }
 
 static void ahci_intr_error(struct ata_port *ap, u32 irq_stat)
index e51d9a8a2796fc076eff174fcb16ebffd9e5ffe9..d81db3a3d4b9a82a916659574a20f35328329ab4 100644 (file)
@@ -532,8 +532,7 @@ void ata_tf_to_fis(const struct ata_taskfile *tf, u8 *fis, u8 pmp)
  *     @fis: Buffer from which data will be input
  *     @tf: Taskfile to output
  *
- *     Converts a standard ATA taskfile to a Serial ATA
- *     FIS structure (Register - Host to Device).
+ *     Converts a serial ATA FIS structure to a standard ATA taskfile.
  *
  *     LOCKING:
  *     Inherited from caller.
index 261be24e1df36bddfc63cb7e437b7183c31766b4..0df4b682965d41aab2d040edc7914444f3ebe10e 100644 (file)
@@ -2276,6 +2276,12 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
                tf->device = scsicmd[8];
                tf->command = scsicmd[9];
        }
+       /*
+        * If slave is possible, enforce correct master/slave bit
+       */
+       if (qc->ap->flags & ATA_FLAG_SLAVE_POSS)
+               tf->device = qc->dev->devno ?
+                       tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1;
 
        /*
         * Filter SET_FEATURES - XFER MODE command -- otherwise,
index b2f6324a2eb219c511e0e63ae1feb98a5fbece26..4a6d3067d23c3de88cc148847e746c974b248cc0 100644 (file)
@@ -268,7 +268,7 @@ static void qs_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
        writel(val, (void __iomem *)(ap->ioaddr.scr_addr + (sc_reg * 8)));
 }
 
-static void qs_fill_sg(struct ata_queued_cmd *qc)
+static unsigned int qs_fill_sg(struct ata_queued_cmd *qc)
 {
        struct scatterlist *sg;
        struct ata_port *ap = qc->ap;
@@ -296,6 +296,8 @@ static void qs_fill_sg(struct ata_queued_cmd *qc)
                                        (unsigned long long)addr, len);
                nelem++;
        }
+
+       return nelem;
 }
 
 static void qs_qc_prep(struct ata_queued_cmd *qc)
@@ -304,6 +306,7 @@ static void qs_qc_prep(struct ata_queued_cmd *qc)
        u8 dflags = QS_DF_PORD, *buf = pp->pkt;
        u8 hflags = QS_HF_DAT | QS_HF_IEN | QS_HF_VLD;
        u64 addr;
+       unsigned int nelem;
 
        VPRINTK("ENTER\n");
 
@@ -313,7 +316,7 @@ static void qs_qc_prep(struct ata_queued_cmd *qc)
                return;
        }
 
-       qs_fill_sg(qc);
+       nelem = qs_fill_sg(qc);
 
        if ((qc->tf.flags & ATA_TFLAG_WRITE))
                hflags |= QS_HF_DIRO;
@@ -324,7 +327,7 @@ static void qs_qc_prep(struct ata_queued_cmd *qc)
        buf[ 0] = QS_HCB_HDR;
        buf[ 1] = hflags;
        *(__le32 *)(&buf[ 4]) = cpu_to_le32(qc->nsect * ATA_SECT_SIZE);
-       *(__le32 *)(&buf[ 8]) = cpu_to_le32(qc->n_elem);
+       *(__le32 *)(&buf[ 8]) = cpu_to_le32(nelem);
        addr = ((u64)pp->pkt_dma) + QS_CPB_BYTES;
        *(__le64 *)(&buf[16]) = cpu_to_le64(addr);
 
index d3198d9a72c12ffd3084ba39049c1ebeef197411..55e744d6db88338486d4c471dc311f3bb480a080 100644 (file)
@@ -687,6 +687,7 @@ static void sil24_port_stop(struct ata_port *ap)
        struct sil24_port_priv *pp = ap->private_data;
 
        sil24_cblk_free(pp, dev);
+       ata_pad_free(ap, dev);
        kfree(pp);
 }
 
index 2efb317153ce19a8ca7d974c3b18b03bddb62c60..67e9afa000c135bdcd8b621dc39677e36e575945 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/keyboard.h>
 #include <linux/init.h>
 #include <linux/pm.h>
+#include <linux/pm_legacy.h>
 #include <linux/bitops.h>
 #include <linux/delay.h>
 
@@ -1343,7 +1344,7 @@ static void show_serial_version(void)
        printk("MC68328 serial driver version 1.00\n");
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_LEGACY
 /* Serial Power management
  *  The console (currently fixed at line 0) is a special case for power
  *  management because the kernel is so chatty. The console will be 
@@ -1393,7 +1394,7 @@ void startup_console(void)
        struct m68k_serial *info = &m68k_soft[0];
        startup(info);
 }
-#endif
+#endif /* CONFIG_PM_LEGACY */
 
 
 static struct tty_operations rs_ops = {
@@ -1486,7 +1487,7 @@ rs68328_init(void)
                            IRQ_FLG_STD,
                            "M68328_UART", NULL))
                 panic("Unable to attach 68328 serial interrupt\n");
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_LEGACY
            serial_pm[i] = pm_register(PM_SYS_DEV, PM_SYS_COM, serial_pm_callback);
            if (serial_pm[i])
                    serial_pm[i]->data = info;
index 3742753241ee8e5b1ff2e34664d2f7540b406136..e08510d09ff6fa6ef26ec6832781b6dd90ef9b2a 100644 (file)
@@ -999,7 +999,10 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
        serial_outp(up, UART_MCR, save_mcr);
        serial8250_clear_fifos(up);
        (void)serial_in(up, UART_RX);
-       serial_outp(up, UART_IER, 0);
+       if (up->capabilities & UART_CAP_UUE)
+               serial_outp(up, UART_IER, UART_IER_UUE);
+       else
+               serial_outp(up, UART_IER, 0);
 
  out:  
        spin_unlock_irqrestore(&up->port.lock, flags);
index 5d8660a42b77e1a77e805c433e632c34d98a32c5..b79ed0665d519f199c6bb16cf946d42bd7626754 100644 (file)
@@ -323,6 +323,8 @@ static const struct pnp_device_id pnp_dev_table[] = {
        {       "USR9180",              0       },
        /* U.S. Robotics 56K Voice INT PnP*/
        {       "USR9190",              0       },
+       /* HP Compaq Tablet PC tc1100 Wacom tablet */
+       {       "WACF005",              0       },
        /* Rockwell's (PORALiNK) 33600 INT PNP */
        {       "WCI0003",              0       },
        /* Unkown PnP modems */
index 25825f2aba2279abc005ab49c11cfd59c9ab5390..987d22b53c220966152eb22a2b92b07d00517f07 100644 (file)
@@ -7,7 +7,7 @@
  *  Based on ppc8xx.c by Thomas Gleixner
  *  Based on drivers/serial/amba.c by Russell King
  *
- *  Maintainer: Kumar Gala (kumar.gala@freescale.com) (CPM2)
+ *  Maintainer: Kumar Gala (galak@kernel.crashing.org) (CPM2)
  *              Pantelis Antoniou (panto@intracom.gr) (CPM1)
  *
  *  Copyright (C) 2004 Freescale Semiconductor, Inc.
index 4b0786e7eb7ff6ba2ca3b85b4887badef8d72938..d789ee55cbb762c5f17c942af6dade7180d1dbd0 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Driver for CPM (SCC/SMC) serial ports; CPM1 definitions
  *
- *  Maintainer: Kumar Gala (kumar.gala@freescale.com) (CPM2)
+ *  Maintainer: Kumar Gala (galak@kernel.crashing.org) (CPM2)
  *              Pantelis Antoniou (panto@intracom.gr) (CPM1)
  *
  *  Copyright (C) 2004 Freescale Semiconductor, Inc.
index 15ad58d94889f431bfc4899dea71a65b1d2f7e86..fd9e53ed3feb934a2efea256f76cb13f5e9aa546 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Driver for CPM (SCC/SMC) serial ports; CPM2 definitions
  *
- *  Maintainer: Kumar Gala (kumar.gala@freescale.com) (CPM2)
+ *  Maintainer: Kumar Gala (galak@kernel.crashing.org) (CPM2)
  *              Pantelis Antoniou (panto@intracom.gr) (CPM1)
  * 
  *  Copyright (C) 2004 Freescale Semiconductor, Inc.
index e63b9dffc8d7304ecd6fcfaa2b363ffd07838131..4d8516d1bb71692d217e50ab5934c8862643b3ab 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * dz.c: Serial port driver for DECStations equiped 
+ * dz.c: Serial port driver for DECStations equiped
  *       with the DZ chipset.
  *
- * Copyright (C) 1998 Olivier A. D. Lebaillif 
- *             
+ * Copyright (C) 1998 Olivier A. D. Lebaillif
+ *
  * Email: olivier.lebaillif@ifrsys.com
  *
  * [31-AUG-98] triemer
  * removed base_addr code - moving address assignment to setup.c
  * Changed name of dz_init to rs_init to be consistent with tc code
  * [13-NOV-98] triemer fixed code to receive characters
- *    after patches by harald to irq code.  
+ *    after patches by harald to irq code.
  * [09-JAN-99] triemer minor fix for schedule - due to removal of timeout
  *            field from "current" - somewhere between 2.1.121 and 2.1.131
  Qua Jun 27 15:02:26 BRT 2001
  * [27-JUN-2001] Arnaldo Carvalho de Melo <acme@conectiva.com.br> - cleanups
- *  
- * Parts (C) 1999 David Airlie, airlied@linux.ie 
- * [07-SEP-99] Bugfixes 
+ *
+ * Parts (C) 1999 David Airlie, airlied@linux.ie
+ * [07-SEP-99] Bugfixes
  *
  * [06-Jan-2002] Russell King <rmk@arm.linux.org.uk>
  * Converted to new serial core
@@ -64,7 +64,7 @@ static struct dz_port dz_ports[DZ_NB_PORT];
 
 #ifdef DEBUG_DZ
 /*
- * debugging code to send out chars via prom 
+ * debugging code to send out chars via prom
  */
 static void debug_console(const char *s, int count)
 {
@@ -82,7 +82,7 @@ static void debug_console(const char *s, int count)
  * ------------------------------------------------------------
  * dz_in () and dz_out ()
  *
- * These routines are used to access the registers of the DZ 
+ * These routines are used to access the registers of the DZ
  * chip, hiding relocation differences between implementation.
  * ------------------------------------------------------------
  */
@@ -106,8 +106,8 @@ static inline void dz_out(struct dz_port *dport, unsigned offset,
  * ------------------------------------------------------------
  * rs_stop () and rs_start ()
  *
- * These routines are called before setting or resetting 
- * tty->stopped. They enable or disable transmitter interrupts, 
+ * These routines are called before setting or resetting
+ * tty->stopped. They enable or disable transmitter interrupts,
  * as necessary.
  * ------------------------------------------------------------
  */
@@ -156,17 +156,17 @@ static void dz_enable_ms(struct uart_port *port)
 
 /*
  * ------------------------------------------------------------
- * Here starts the interrupt handling routines.  All of the 
- * following subroutines are declared as inline and are folded 
- * into dz_interrupt.  They were separated out for readability's 
- * sake. 
+ * Here starts the interrupt handling routines.  All of the
+ * following subroutines are declared as inline and are folded
+ * into dz_interrupt.  They were separated out for readability's
+ * sake.
  *
  * Note: rs_interrupt() is a "fast" interrupt, which means that it
  * runs with interrupts turned off.  People who may want to modify
  * rs_interrupt() should try to keep the interrupt handler as fast as
  * possible.  After you are done making modifications, it is not a bad
  * idea to do:
- * 
+ *
  *     make drivers/serial/dz.s
  *
  * and look at the resulting assemble code in dz.s.
@@ -403,7 +403,7 @@ static void dz_set_mctrl(struct uart_port *uport, unsigned int mctrl)
  * startup ()
  *
  * various initialization tasks
- * ------------------------------------------------------------------- 
+ * -------------------------------------------------------------------
  */
 static int dz_startup(struct uart_port *uport)
 {
@@ -430,13 +430,13 @@ static int dz_startup(struct uart_port *uport)
        return 0;
 }
 
-/* 
+/*
  * -------------------------------------------------------------------
  * shutdown ()
  *
  * This routine will shutdown a serial port; interrupts are disabled, and
  * DTR is dropped if the hangup on close termio flag is on.
- * ------------------------------------------------------------------- 
+ * -------------------------------------------------------------------
  */
 static void dz_shutdown(struct uart_port *uport)
 {
@@ -451,7 +451,7 @@ static void dz_shutdown(struct uart_port *uport)
  *          release the bus after transmitting. This must be done when
  *          the transmit shift register is empty, not be done when the
  *          transmit holding register is empty.  This functionality
- *          allows an RS485 driver to be written in user space. 
+ *          allows an RS485 driver to be written in user space.
  */
 static unsigned int dz_tx_empty(struct uart_port *uport)
 {
@@ -645,9 +645,9 @@ static void __init dz_init_ports(void)
 
        if (mips_machtype == MACH_DS23100 ||
            mips_machtype == MACH_DS5100)
-               base = (unsigned long) KN01_DZ11_BASE;
+               base = CKSEG1ADDR(KN01_SLOT_BASE + KN01_DZ11);
        else
-               base = (unsigned long) KN02_DZ11_BASE;
+               base = CKSEG1ADDR(KN02_SLOT_BASE + KN02_DZ11);
 
        for (i = 0, dport = dz_ports; i < DZ_NB_PORT; i++, dport++) {
                spin_lock_init(&dport->port.lock);
@@ -695,13 +695,13 @@ static void dz_console_put_char(struct dz_port *dport, unsigned char ch)
 
        spin_unlock_irqrestore(&dport->port.lock, flags);
 }
-/* 
+/*
  * -------------------------------------------------------------------
  * dz_console_print ()
  *
  * dz_console_print is registered for printk.
  * The console must be locked when we get here.
- * ------------------------------------------------------------------- 
+ * -------------------------------------------------------------------
  */
 static void dz_console_print(struct console *cons,
                             const char *str,
index 5d3cb84864474b0449afc551caf8c2d2aa0c80dd..b8727d9bf690d7322007301c70646d8ebd136860 100644 (file)
@@ -725,7 +725,7 @@ mpc52xx_uart_probe(struct platform_device *dev)
        int i, idx, ret;
 
        /* Check validity & presence */
-       idx = pdev->id;
+       idx = dev->id;
        if (idx < 0 || idx >= MPC52xx_PSC_MAXNUM)
                return -EINVAL;
 
@@ -748,7 +748,7 @@ mpc52xx_uart_probe(struct platform_device *dev)
        port->ops       = &mpc52xx_uart_ops;
 
        /* Search for IRQ and mapbase */
-       for (i=0 ; i<pdev->num_resources ; i++, res++) {
+       for (i=0 ; i<dev->num_resources ; i++, res++) {
                if (res->flags & IORESOURCE_MEM)
                        port->mapbase = res->start;
                else if (res->flags & IORESOURCE_IRQ)
index fd9deee20e05108c7f35c0996878200ff4a716db..0e3daf6d7b502575f05baf78d90bb7f37919f2d2 100644 (file)
@@ -156,7 +156,7 @@ static void sa1100_stop_tx(struct uart_port *port)
 }
 
 /*
- * interrupts may not be disabled on entry
+ * port locked and interrupts disabled
  */
 static void sa1100_start_tx(struct uart_port *port)
 {
@@ -164,11 +164,9 @@ static void sa1100_start_tx(struct uart_port *port)
        unsigned long flags;
        u32 utcr3;
 
-       spin_lock_irqsave(&sport->port.lock, flags);
        utcr3 = UART_GET_UTCR3(sport);
        sport->port.read_status_mask |= UTSR0_TO_SM(UTSR0_TFS);
        UART_PUT_UTCR3(sport, utcr3 | UTCR3_TIE);
-       spin_unlock_irqrestore(&sport->port.lock, flags);
 }
 
 /*
index 427a23858076ffe03fcf9a166b7ca852a37533cb..2331296e1e17b068db98d8097bd85e1c80341898 100644 (file)
@@ -209,33 +209,45 @@ static void uart_shutdown(struct uart_state *state)
        struct uart_info *info = state->info;
        struct uart_port *port = state->port;
 
-       if (!(info->flags & UIF_INITIALIZED))
-               return;
-
        /*
-        * Turn off DTR and RTS early.
+        * Set the TTY IO error marker
         */
-       if (!info->tty || (info->tty->termios->c_cflag & HUPCL))
-               uart_clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
+       if (info->tty)
+               set_bit(TTY_IO_ERROR, &info->tty->flags);
 
-       /*
-        * clear delta_msr_wait queue to avoid mem leaks: we may free
-        * the irq here so the queue might never be woken up.  Note
-        * that we won't end up waiting on delta_msr_wait again since
-        * any outstanding file descriptors should be pointing at
-        * hung_up_tty_fops now.
-        */
-       wake_up_interruptible(&info->delta_msr_wait);
+       if (info->flags & UIF_INITIALIZED) {
+               info->flags &= ~UIF_INITIALIZED;
 
-       /*
-        * Free the IRQ and disable the port.
-        */
-       port->ops->shutdown(port);
+               /*
+                * Turn off DTR and RTS early.
+                */
+               if (!info->tty || (info->tty->termios->c_cflag & HUPCL))
+                       uart_clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
+
+               /*
+                * clear delta_msr_wait queue to avoid mem leaks: we may free
+                * the irq here so the queue might never be woken up.  Note
+                * that we won't end up waiting on delta_msr_wait again since
+                * any outstanding file descriptors should be pointing at
+                * hung_up_tty_fops now.
+                */
+               wake_up_interruptible(&info->delta_msr_wait);
+
+               /*
+                * Free the IRQ and disable the port.
+                */
+               port->ops->shutdown(port);
+
+               /*
+                * Ensure that the IRQ handler isn't running on another CPU.
+                */
+               synchronize_irq(port->irq);
+       }
 
        /*
-        * Ensure that the IRQ handler isn't running on another CPU.
+        * kill off our tasklet
         */
-       synchronize_irq(port->irq);
+       tasklet_kill(&info->tlet);
 
        /*
         * Free the transmit buffer page.
@@ -244,15 +256,6 @@ static void uart_shutdown(struct uart_state *state)
                free_page((unsigned long)info->xmit.buf);
                info->xmit.buf = NULL;
        }
-
-       /*
-        * kill off our tasklet
-        */
-       tasklet_kill(&info->tlet);
-       if (info->tty)
-               set_bit(TTY_IO_ERROR, &info->tty->flags);
-
-       info->flags &= ~UIF_INITIALIZED;
 }
 
 /**
@@ -1928,14 +1931,25 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *port)
 
        if (state->info && state->info->flags & UIF_INITIALIZED) {
                struct uart_ops *ops = port->ops;
+               int ret;
 
                ops->set_mctrl(port, 0);
-               ops->startup(port);
-               uart_change_speed(state, NULL);
-               spin_lock_irq(&port->lock);
-               ops->set_mctrl(port, port->mctrl);
-               ops->start_tx(port);
-               spin_unlock_irq(&port->lock);
+               ret = ops->startup(port);
+               if (ret == 0) {
+                       uart_change_speed(state, NULL);
+                       spin_lock_irq(&port->lock);
+                       ops->set_mctrl(port, port->mctrl);
+                       ops->start_tx(port);
+                       spin_unlock_irq(&port->lock);
+               } else {
+                       /*
+                        * Failed to resume - maybe hardware went away?
+                        * Clear the "initialized" flag so we won't try
+                        * to call the low level drivers shutdown method.
+                        */
+                       state->info->flags &= ~UIF_INITIALIZED;
+                       uart_shutdown(state);
+               }
        }
 
        up(&state->sem);
index f53bf3ba127898c01a480b69be8b211bf02ab561..d3728f60961e75230a466aa94172bdb52a64cd42 100644 (file)
@@ -51,6 +51,9 @@ static struct fb_ops bw2_ops = {
        .fb_imageblit           = cfb_imageblit,
        .fb_mmap                = bw2_mmap,
        .fb_ioctl               = bw2_ioctl,
+#ifdef CONFIG_COMPAT
+       .fb_compat_ioctl        = sbusfb_compat_ioctl,
+#endif
 };
 
 /* OBio addresses for the bwtwo registers */
index 030d4b13b1c206a5e0ff8ec61012b00d145d8923..1bed50f2a2767dbb1a7901b0dcd23faa81524060 100644 (file)
@@ -49,6 +49,9 @@ static struct fb_ops cg14_ops = {
        .fb_imageblit           = cfb_imageblit,
        .fb_mmap                = cg14_mmap,
        .fb_ioctl               = cg14_ioctl,
+#ifdef CONFIG_COMPAT
+       .fb_compat_ioctl        = sbusfb_compat_ioctl,
+#endif
 };
 
 #define CG14_MCR_INTENABLE_SHIFT       7
index b94eee8c42d5dbacba3f2ef509d58e60726cfa2a..a1354e7e0513e970b5ddf4bb10a3f305f900de70 100644 (file)
@@ -50,6 +50,9 @@ static struct fb_ops cg3_ops = {
        .fb_imageblit           = cfb_imageblit,
        .fb_mmap                = cg3_mmap,
        .fb_ioctl               = cg3_ioctl,
+#ifdef CONFIG_COMPAT
+       .fb_compat_ioctl        = sbusfb_compat_ioctl,
+#endif
 };
 
 
index 414c4409e92468e0d43c68b3f5d971f84830e3cb..9debe642fd2f8825a0b394112d30ee8bc12c46c1 100644 (file)
@@ -54,6 +54,9 @@ static struct fb_ops cg6_ops = {
        .fb_sync                = cg6_sync,
        .fb_mmap                = cg6_mmap,
        .fb_ioctl               = cg6_ioctl,
+#ifdef CONFIG_COMPAT
+       .fb_compat_ioctl        = sbusfb_compat_ioctl,
+#endif
 };
 
 /* Offset of interesting structures in the OBIO space */
index 94c5f1392ccedb29ecb0dd1d37b31372976e121f..5f74df993406073c883453364855da7281ca8ff8 100644 (file)
@@ -215,12 +215,5 @@ config FONT_10x18
          big letters. It fits between the sun 12x22 and the normal 8x16 font.
          If other fonts are too big or too small for you, say Y, otherwise say N.
 
-config FONT_RL
-       bool "console Roman Large 8x16 font" if FONTS
-       depends on FRAMEBUFFER_CONSOLE
-       help
-         This is the visually-appealing "RL" console font that is
-         included with the kbd package.
-
 endmenu
 
index fed600c9ca5578fb9142f23d5849c7325c7f8450..9b26dda18a38c1e13fde4b3b92610a36d840d7ef 100644 (file)
@@ -15,7 +15,6 @@ font-objs-$(CONFIG_FONT_10x18)     += font_10x18.o
 font-objs-$(CONFIG_FONT_PEARL_8x8) += font_pearl_8x8.o
 font-objs-$(CONFIG_FONT_ACORN_8x8) += font_acorn_8x8.o
 font-objs-$(CONFIG_FONT_MINI_4x6)  += font_mini_4x6.o
-font-objs-$(CONFIG_FONT_RL)  += font_rl.o
 
 font-objs += $(font-objs-y)
 
index e7802ffe549ae402144f82aaf052e0ada28de9be..bcea87c3cc068a5a696d51492c63b3d473659ff3 100644 (file)
@@ -106,8 +106,7 @@ enum {
        FBCON_LOGO_DONTSHOW     = -3    /* do not show the logo */
 };
 
-struct display fb_display[MAX_NR_CONSOLES];
-EXPORT_SYMBOL(fb_display);
+static struct display fb_display[MAX_NR_CONSOLES];
 
 static signed char con2fb_map[MAX_NR_CONSOLES];
 static signed char con2fb_map_boot[MAX_NR_CONSOLES];
@@ -653,13 +652,12 @@ static void set_blitting_type(struct vc_data *vc, struct fb_info *info,
 {
        struct fbcon_ops *ops = info->fbcon_par;
 
+       ops->p = (p) ? p : &fb_display[vc->vc_num];
+
        if ((info->flags & FBINFO_MISC_TILEBLITTING))
                fbcon_set_tileops(vc, info, p, ops);
        else {
-               struct display *disp;
-
-               disp = (p) ? p : &fb_display[vc->vc_num];
-               fbcon_set_rotation(info, disp);
+               fbcon_set_rotation(info, ops->p);
                fbcon_set_bitops(ops);
        }
 }
@@ -668,11 +666,10 @@ static void set_blitting_type(struct vc_data *vc, struct fb_info *info,
                              struct display *p)
 {
        struct fbcon_ops *ops = info->fbcon_par;
-       struct display *disp;
 
        info->flags &= ~FBINFO_MISC_TILEBLITTING;
-       disp = (p) ? p : &fb_display[vc->vc_num];
-       fbcon_set_rotation(info, disp);
+       ops->p = (p) ? p : &fb_display[vc->vc_num];
+       fbcon_set_rotation(info, ops->p);
        fbcon_set_bitops(ops);
 }
 #endif /* CONFIG_MISC_TILEBLITTING */
index accfd7bd8e9317927000ee4a791eaf1100da1d3a..6892e7ff34de87233268b528297cbfa4a8005bdc 100644 (file)
@@ -52,8 +52,6 @@ struct display {
     struct fb_videomode *mode;
 };
 
-extern struct display fb_display[];
-
 struct fbcon_ops {
        void (*bmove)(struct vc_data *vc, struct fb_info *info, int sy,
                      int sx, int dy, int dx, int height, int width);
@@ -73,6 +71,7 @@ struct fbcon_ops {
        struct fb_var_screeninfo var;  /* copy of the current fb_var_screeninfo */
        struct timer_list cursor_timer; /* Cursor timer */
        struct fb_cursor cursor_state;
+       struct display *p;
         int    currcon;                        /* Current VC. */
        int    cursor_flash;
        int    cursor_reset;
index 680aabab73c507eee4ea69a5a8276ce520b2a51a..3afd1eeb1adebc38b5432a36ecaca220a88eba88 100644 (file)
@@ -63,9 +63,9 @@ static inline void ccw_update_attr(u8 *dst, u8 *src, int attribute,
 static void ccw_bmove(struct vc_data *vc, struct fb_info *info, int sy,
                     int sx, int dy, int dx, int height, int width)
 {
-       struct display *p = &fb_display[vc->vc_num];
+       struct fbcon_ops *ops = info->fbcon_par;
        struct fb_copyarea area;
-       u32 vyres = GETVYRES(p->scrollmode, info);
+       u32 vyres = GETVYRES(ops->p->scrollmode, info);
 
        area.sx = sy * vc->vc_font.height;
        area.sy = vyres - ((sx + width) * vc->vc_font.width);
@@ -80,10 +80,10 @@ static void ccw_bmove(struct vc_data *vc, struct fb_info *info, int sy,
 static void ccw_clear(struct vc_data *vc, struct fb_info *info, int sy,
                     int sx, int height, int width)
 {
-       struct display *p = &fb_display[vc->vc_num];
+       struct fbcon_ops *ops = info->fbcon_par;
        struct fb_fillrect region;
        int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
-       u32 vyres = GETVYRES(p->scrollmode, info);
+       u32 vyres = GETVYRES(ops->p->scrollmode, info);
 
        region.color = attr_bgcol_ec(bgshift,vc);
        region.dx = sy * vc->vc_font.height;
@@ -131,7 +131,6 @@ static void ccw_putcs(struct vc_data *vc, struct fb_info *info,
                      int fg, int bg)
 {
        struct fb_image image;
-       struct display *p = &fb_display[vc->vc_num];
        struct fbcon_ops *ops = info->fbcon_par;
        u32 width = (vc->vc_font.height + 7)/8;
        u32 cellsize = width * vc->vc_font.width;
@@ -141,7 +140,7 @@ static void ccw_putcs(struct vc_data *vc, struct fb_info *info,
        u32 cnt, pitch, size;
        u32 attribute = get_attribute(info, scr_readw(s));
        u8 *dst, *buf = NULL;
-       u32 vyres = GETVYRES(p->scrollmode, info);
+       u32 vyres = GETVYRES(ops->p->scrollmode, info);
 
        if (!ops->fontbuffer)
                return;
@@ -397,9 +396,8 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info,
 int ccw_update_start(struct fb_info *info)
 {
        struct fbcon_ops *ops = info->fbcon_par;
-       struct display *p = &fb_display[ops->currcon];
        u32 yoffset;
-       u32 vyres = GETVYRES(p->scrollmode, info);
+       u32 vyres = GETVYRES(ops->p->scrollmode, info);
        int err;
 
        yoffset = (vyres - info->var.yres) - ops->var.xoffset;
index 6c6f3b6dd17563b371b3fba56c64c886c5d1de47..6d92b845620629fbfe7b9353b449ac741fa7b420 100644 (file)
@@ -49,9 +49,9 @@ static inline void cw_update_attr(u8 *dst, u8 *src, int attribute,
 static void cw_bmove(struct vc_data *vc, struct fb_info *info, int sy,
                     int sx, int dy, int dx, int height, int width)
 {
-       struct display *p = &fb_display[vc->vc_num];
+       struct fbcon_ops *ops = info->fbcon_par;
        struct fb_copyarea area;
-       u32 vxres = GETVXRES(p->scrollmode, info);
+       u32 vxres = GETVXRES(ops->p->scrollmode, info);
 
        area.sx = vxres - ((sy + height) * vc->vc_font.height);
        area.sy = sx * vc->vc_font.width;
@@ -66,10 +66,10 @@ static void cw_bmove(struct vc_data *vc, struct fb_info *info, int sy,
 static void cw_clear(struct vc_data *vc, struct fb_info *info, int sy,
                     int sx, int height, int width)
 {
-       struct display *p = &fb_display[vc->vc_num];
+       struct fbcon_ops *ops = info->fbcon_par;
        struct fb_fillrect region;
        int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
-       u32 vxres = GETVXRES(p->scrollmode, info);
+       u32 vxres = GETVXRES(ops->p->scrollmode, info);
 
        region.color = attr_bgcol_ec(bgshift,vc);
        region.dx = vxres - ((sy + height) * vc->vc_font.height);
@@ -117,7 +117,6 @@ static void cw_putcs(struct vc_data *vc, struct fb_info *info,
                      int fg, int bg)
 {
        struct fb_image image;
-       struct display *p = &fb_display[vc->vc_num];
        struct fbcon_ops *ops = info->fbcon_par;
        u32 width = (vc->vc_font.height + 7)/8;
        u32 cellsize = width * vc->vc_font.width;
@@ -127,7 +126,7 @@ static void cw_putcs(struct vc_data *vc, struct fb_info *info,
        u32 cnt, pitch, size;
        u32 attribute = get_attribute(info, scr_readw(s));
        u8 *dst, *buf = NULL;
-       u32 vxres = GETVXRES(p->scrollmode, info);
+       u32 vxres = GETVXRES(ops->p->scrollmode, info);
 
        if (!ops->fontbuffer)
                return;
@@ -381,8 +380,7 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info,
 int cw_update_start(struct fb_info *info)
 {
        struct fbcon_ops *ops = info->fbcon_par;
-       struct display *p = &fb_display[ops->currcon];
-       u32 vxres = GETVXRES(p->scrollmode, info);
+       u32 vxres = GETVXRES(ops->p->scrollmode, info);
        u32 xoffset;
        int err;
 
index 2e1d9d4249cd0c457e5e0d1c2801f34012560d48..c4d7c89212b4bfaa116750c9111124d09bd65714 100644 (file)
@@ -48,10 +48,10 @@ static inline void ud_update_attr(u8 *dst, u8 *src, int attribute,
 static void ud_bmove(struct vc_data *vc, struct fb_info *info, int sy,
                     int sx, int dy, int dx, int height, int width)
 {
-       struct display *p = &fb_display[vc->vc_num];
+       struct fbcon_ops *ops = info->fbcon_par;
        struct fb_copyarea area;
-       u32 vyres = GETVYRES(p->scrollmode, info);
-       u32 vxres = GETVXRES(p->scrollmode, info);
+       u32 vyres = GETVYRES(ops->p->scrollmode, info);
+       u32 vxres = GETVXRES(ops->p->scrollmode, info);
 
        area.sy = vyres - ((sy + height) * vc->vc_font.height);
        area.sx = vxres - ((sx + width) * vc->vc_font.width);
@@ -66,11 +66,11 @@ static void ud_bmove(struct vc_data *vc, struct fb_info *info, int sy,
 static void ud_clear(struct vc_data *vc, struct fb_info *info, int sy,
                     int sx, int height, int width)
 {
-       struct display *p = &fb_display[vc->vc_num];
+       struct fbcon_ops *ops = info->fbcon_par;
        struct fb_fillrect region;
        int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
-       u32 vyres = GETVYRES(p->scrollmode, info);
-       u32 vxres = GETVXRES(p->scrollmode, info);
+       u32 vyres = GETVYRES(ops->p->scrollmode, info);
+       u32 vxres = GETVXRES(ops->p->scrollmode, info);
 
        region.color = attr_bgcol_ec(bgshift,vc);
        region.dy = vyres - ((sy + height) * vc->vc_font.height);
@@ -153,7 +153,6 @@ static void ud_putcs(struct vc_data *vc, struct fb_info *info,
                      int fg, int bg)
 {
        struct fb_image image;
-       struct display *p = &fb_display[vc->vc_num];
        struct fbcon_ops *ops = info->fbcon_par;
        u32 width = (vc->vc_font.width + 7)/8;
        u32 cellsize = width * vc->vc_font.height;
@@ -163,8 +162,8 @@ static void ud_putcs(struct vc_data *vc, struct fb_info *info,
        u32 mod = vc->vc_font.width % 8, cnt, pitch, size;
        u32 attribute = get_attribute(info, scr_readw(s));
        u8 *dst, *buf = NULL;
-       u32 vyres = GETVYRES(p->scrollmode, info);
-       u32 vxres = GETVXRES(p->scrollmode, info);
+       u32 vyres = GETVYRES(ops->p->scrollmode, info);
+       u32 vxres = GETVXRES(ops->p->scrollmode, info);
 
        if (!ops->fontbuffer)
                return;
@@ -421,10 +420,9 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info,
 int ud_update_start(struct fb_info *info)
 {
        struct fbcon_ops *ops = info->fbcon_par;
-       struct display *p = &fb_display[ops->currcon];
        u32 xoffset, yoffset;
-       u32 vyres = GETVYRES(p->scrollmode, info);
-       u32 vxres = GETVXRES(p->scrollmode, info);
+       u32 vyres = GETVYRES(ops->p->scrollmode, info);
+       u32 vxres = GETVXRES(ops->p->scrollmode, info);
        int err;
 
        xoffset = (vxres - info->var.xres) - ops->var.xoffset;
diff --git a/drivers/video/console/font_rl.c b/drivers/video/console/font_rl.c
deleted file mode 100644 (file)
index dfecc27..0000000
+++ /dev/null
@@ -1,4374 +0,0 @@
-
-/* This font is simply the "rl.fnt" console font from the kbd utility.
- * Converted by Zack T Smith, fbui@comcast.net.
- * The original binary file is covered under the GNU Public License.
- */
-
-#include <linux/font.h>
-
-#define FONTDATAMAX 4096
-
-static unsigned char patterns[4096] = {
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x3c,
-0x42,
-0x81,
-0xe7,
-0xa5,
-0x99,
-0x81,
-0x81,
-0x99,
-0x42,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x3c,
-0x7e,
-0xff,
-0x99,
-0xdb,
-0xe7,
-0xff,
-0xff,
-0xe7,
-0x7e,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x6c,
-0xfe,
-0xfe,
-0xfe,
-0xfe,
-0xfe,
-0x7c,
-0x38,
-0x10,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x10,
-0x38,
-0x7c,
-0xfe,
-0x7c,
-0x38,
-0x10,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x38,
-0x38,
-0x10,
-0xd6,
-0xfe,
-0xd6,
-0x10,
-0x10,
-0x38,
-0x7c,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x10,
-0x38,
-0x7c,
-0xfe,
-0xfe,
-0x54,
-0x10,
-0x10,
-0x38,
-0x7c,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x18,
-0x3c,
-0x3c,
-0x18,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xe7,
-0xc3,
-0xc3,
-0xe7,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x3c,
-0x66,
-0x42,
-0x42,
-0x66,
-0x3c,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xc3,
-0x99,
-0xbd,
-0xbd,
-0x99,
-0xc3,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-
-0x00,
-0x00,
-0x0f,
-0x07,
-0x0d,
-0x18,
-0x78,
-0xcc,
-0xcc,
-0xcc,
-0xcc,
-0x78,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x3c,
-0x66,
-0x66,
-0x66,
-0x3c,
-0x18,
-0x7e,
-0x18,
-0x18,
-0x18,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x08,
-0x0c,
-0x0a,
-0x0a,
-0x0a,
-0x08,
-0x08,
-0x08,
-0x38,
-0x78,
-0x30,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x10,
-0x18,
-0x1c,
-0x1e,
-0x1e,
-0x16,
-0x12,
-0x72,
-0xf2,
-0x62,
-0x0e,
-0x1e,
-0x0c,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x10,
-0x92,
-0x54,
-0x38,
-0xfe,
-0x38,
-0x54,
-0x92,
-0x10,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x80,
-0xc0,
-0xe0,
-0xb8,
-0x8e,
-0xb8,
-0xe0,
-0xc0,
-0x80,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x02,
-0x06,
-0x0e,
-0x3a,
-0xe2,
-0x3a,
-0x0e,
-0x06,
-0x02,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x10,
-0x38,
-0x7c,
-0xd6,
-0x10,
-0x10,
-0x10,
-0x10,
-0xd6,
-0x7c,
-0x38,
-0x10,
-0x00,
-0x00,
-
-0x00,
-0x42,
-0xe7,
-0xe7,
-0xe7,
-0xe7,
-0x42,
-0x42,
-0x42,
-0x00,
-0x66,
-0x66,
-0x66,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x7f,
-0xca,
-0xca,
-0xca,
-0xca,
-0x7a,
-0x0a,
-0x0a,
-0x0a,
-0x0a,
-0x0a,
-0x1b,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x1e,
-0x31,
-0x78,
-0xcc,
-0xc6,
-0xc3,
-0x63,
-0x33,
-0x1e,
-0x8c,
-0x78,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xfe,
-0xfe,
-0xfe,
-0xfe,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x10,
-0x38,
-0x7c,
-0xd6,
-0x10,
-0x10,
-0x10,
-0x10,
-0xd6,
-0x7c,
-0x38,
-0x10,
-0xfe,
-0x00,
-
-0x00,
-0x00,
-0x10,
-0x38,
-0x7c,
-0xd6,
-0x10,
-0x10,
-0x10,
-0x10,
-0x10,
-0x10,
-0x10,
-0x10,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x10,
-0x10,
-0x10,
-0x10,
-0x10,
-0x10,
-0x10,
-0x10,
-0xd6,
-0x7c,
-0x38,
-0x10,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x08,
-0x0c,
-0x06,
-0xff,
-0x06,
-0x0c,
-0x08,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x10,
-0x30,
-0x60,
-0xff,
-0x60,
-0x30,
-0x10,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x22,
-0x44,
-0x88,
-0xcc,
-0xee,
-0x44,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x24,
-0x42,
-0xff,
-0x42,
-0x24,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x10,
-0x38,
-0x38,
-0x6c,
-0x6c,
-0xc6,
-0xfe,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0xfe,
-0xc6,
-0x6c,
-0x6c,
-0x38,
-0x38,
-0x10,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x18,
-0x3c,
-0x3c,
-0x3c,
-0x3c,
-0x18,
-0x18,
-0x18,
-0x10,
-0x00,
-0x18,
-0x18,
-0x00,
-0x00,
-0x00,
-
-0x22,
-0x77,
-0x33,
-0x11,
-0x22,
-0x44,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x12,
-0x12,
-0x12,
-0x7f,
-0x24,
-0x24,
-0x24,
-0xfe,
-0x48,
-0x48,
-0x48,
-0x00,
-0x00,
-0x00,
-
-0x10,
-0x10,
-0x7c,
-0xd2,
-0xd0,
-0xd0,
-0xd0,
-0x7c,
-0x16,
-0x16,
-0x16,
-0x96,
-0x7c,
-0x10,
-0x10,
-0x00,
-
-0x00,
-0x42,
-0xbe,
-0x44,
-0x0c,
-0x08,
-0x18,
-0x10,
-0x30,
-0x20,
-0x64,
-0x4a,
-0xc4,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x38,
-0x6c,
-0x6c,
-0x6c,
-0x38,
-0x37,
-0x72,
-0xdc,
-0xcc,
-0xcc,
-0xcc,
-0x77,
-0x00,
-0x00,
-0x00,
-
-0x10,
-0x38,
-0x18,
-0x08,
-0x10,
-0x20,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x04,
-0x08,
-0x10,
-0x10,
-0x30,
-0x30,
-0x30,
-0x30,
-0x30,
-0x10,
-0x10,
-0x08,
-0x04,
-0x00,
-0x00,
-
-0x00,
-0x20,
-0x10,
-0x08,
-0x08,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x08,
-0x08,
-0x10,
-0x20,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x44,
-0x28,
-0x38,
-0xfe,
-0x38,
-0x28,
-0x44,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x18,
-0x18,
-0x7e,
-0x18,
-0x18,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x10,
-0x38,
-0x18,
-0x08,
-0x10,
-0x20,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x7e,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x10,
-0x38,
-0x10,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x06,
-0x06,
-0x0c,
-0x0c,
-0x18,
-0x18,
-0x30,
-0x30,
-0x60,
-0x60,
-0xc0,
-0xc0,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x3c,
-0x46,
-0xc6,
-0xc6,
-0xc6,
-0xc6,
-0xc6,
-0xc4,
-0x78,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x08,
-0x18,
-0x78,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x7e,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x7c,
-0x86,
-0x06,
-0x0c,
-0x18,
-0x20,
-0x40,
-0xc1,
-0xfe,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x3c,
-0x46,
-0x04,
-0x08,
-0x1c,
-0x06,
-0x06,
-0x06,
-0x06,
-0x0c,
-0x70,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x04,
-0x08,
-0x10,
-0x2c,
-0x4c,
-0x8c,
-0x8c,
-0xfe,
-0x0c,
-0x0c,
-0x0c,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x02,
-0x3c,
-0x20,
-0x20,
-0x70,
-0x0c,
-0x06,
-0x06,
-0x06,
-0x06,
-0x0c,
-0x70,
-0x00,
-
-0x00,
-0x00,
-0x18,
-0x20,
-0x40,
-0xc0,
-0xdc,
-0xc6,
-0xc6,
-0xc6,
-0xc6,
-0x44,
-0x38,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x40,
-0x7e,
-0x82,
-0x06,
-0x04,
-0x0c,
-0x18,
-0x18,
-0x30,
-0x30,
-0x30,
-0x30,
-0x00,
-
-0x00,
-0x00,
-0x7c,
-0xc6,
-0xc6,
-0x64,
-0x38,
-0x4c,
-0xc6,
-0xc6,
-0xc6,
-0xc6,
-0x7c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x38,
-0x44,
-0xc6,
-0xc6,
-0x76,
-0x06,
-0x06,
-0x06,
-0x04,
-0x08,
-0x30,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x10,
-0x38,
-0x10,
-0x00,
-0x00,
-0x00,
-0x10,
-0x38,
-0x10,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x10,
-0x38,
-0x10,
-0x00,
-0x00,
-0x00,
-0x10,
-0x38,
-0x18,
-0x08,
-0x10,
-0x20,
-
-0x00,
-0x06,
-0x0c,
-0x18,
-0x30,
-0x60,
-0xa0,
-0xa0,
-0x60,
-0x30,
-0x18,
-0x0c,
-0x06,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x7e,
-0x00,
-0x00,
-0x7e,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x60,
-0x30,
-0x18,
-0x0c,
-0x06,
-0x05,
-0x05,
-0x06,
-0x0c,
-0x18,
-0x30,
-0x60,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x7c,
-0x86,
-0xc6,
-0x06,
-0x04,
-0x08,
-0x10,
-0x10,
-0x18,
-0x00,
-0x18,
-0x18,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x3c,
-0x46,
-0xc6,
-0xce,
-0xd6,
-0xd6,
-0xd6,
-0xdc,
-0xc0,
-0xc4,
-0x78,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x18,
-0x18,
-0x18,
-0x3c,
-0x2c,
-0x2c,
-0x2c,
-0x7e,
-0x46,
-0x46,
-0x46,
-0xef,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xfc,
-0x66,
-0x66,
-0x66,
-0x66,
-0x7c,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0xfc,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x3a,
-0x66,
-0xc2,
-0xc0,
-0xc0,
-0xc0,
-0xc0,
-0xc0,
-0xc0,
-0xc0,
-0x62,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xfc,
-0x66,
-0x63,
-0x63,
-0x63,
-0x63,
-0x63,
-0x63,
-0x63,
-0x63,
-0x66,
-0xfc,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xff,
-0x61,
-0x60,
-0x60,
-0x64,
-0x7c,
-0x64,
-0x60,
-0x60,
-0x60,
-0x61,
-0xfe,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xff,
-0x61,
-0x61,
-0x60,
-0x64,
-0x7c,
-0x64,
-0x60,
-0x60,
-0x60,
-0x60,
-0xf0,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x3a,
-0x66,
-0xc2,
-0xc0,
-0xc0,
-0xc0,
-0xcf,
-0xc6,
-0xc6,
-0xc6,
-0x66,
-0x38,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xf7,
-0x62,
-0x62,
-0x62,
-0x62,
-0x7e,
-0x62,
-0x62,
-0x62,
-0x62,
-0x62,
-0xf7,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x3c,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x1e,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x08,
-0xf0,
-
-0x00,
-0xf7,
-0x64,
-0x6c,
-0x68,
-0x68,
-0x78,
-0x6c,
-0x6c,
-0x6c,
-0x66,
-0x66,
-0xf7,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xf8,
-0x60,
-0x60,
-0x60,
-0x60,
-0x60,
-0x60,
-0x60,
-0x60,
-0x60,
-0x61,
-0xfe,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xc3,
-0x66,
-0x76,
-0x7e,
-0x56,
-0x56,
-0x46,
-0x46,
-0x46,
-0x46,
-0x46,
-0xef,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xe7,
-0x62,
-0x62,
-0x72,
-0x52,
-0x5a,
-0x4a,
-0x4e,
-0x46,
-0x46,
-0x42,
-0xe2,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x3c,
-0x66,
-0xc3,
-0xc3,
-0xc3,
-0xc3,
-0xc3,
-0xc3,
-0xc3,
-0xc3,
-0x66,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xfc,
-0x66,
-0x66,
-0x66,
-0x66,
-0x6c,
-0x60,
-0x60,
-0x60,
-0x60,
-0x60,
-0xf0,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x3c,
-0x66,
-0xc3,
-0xc3,
-0xc3,
-0xc3,
-0xc3,
-0xc3,
-0xc3,
-0xc3,
-0x66,
-0x3c,
-0x10,
-0x39,
-0x0e,
-
-0x00,
-0xfc,
-0x66,
-0x66,
-0x66,
-0x66,
-0x7c,
-0x6c,
-0x66,
-0x66,
-0x66,
-0x66,
-0xf3,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x7a,
-0xc6,
-0xc2,
-0xc0,
-0x70,
-0x3c,
-0x0e,
-0x06,
-0x06,
-0x86,
-0xc6,
-0xbc,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xff,
-0x99,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xf7,
-0x62,
-0x62,
-0x62,
-0x62,
-0x62,
-0x62,
-0x62,
-0x62,
-0x62,
-0x62,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xf7,
-0x62,
-0x62,
-0x62,
-0x76,
-0x34,
-0x34,
-0x34,
-0x3c,
-0x18,
-0x18,
-0x18,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xf7,
-0x62,
-0x62,
-0x62,
-0x62,
-0x6a,
-0x6a,
-0x6a,
-0x6a,
-0x7e,
-0x7e,
-0x34,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xf7,
-0x62,
-0x62,
-0x34,
-0x34,
-0x18,
-0x18,
-0x2c,
-0x2c,
-0x46,
-0x46,
-0xef,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xf7,
-0x62,
-0x62,
-0x62,
-0x34,
-0x34,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x7f,
-0x46,
-0x86,
-0x0c,
-0x0c,
-0x18,
-0x18,
-0x30,
-0x30,
-0x61,
-0x62,
-0xfe,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x3c,
-0x30,
-0x30,
-0x30,
-0x30,
-0x30,
-0x30,
-0x30,
-0x30,
-0x30,
-0x30,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xc0,
-0xc0,
-0x60,
-0x60,
-0x30,
-0x30,
-0x18,
-0x18,
-0x0c,
-0x0c,
-0x06,
-0x06,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x3c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x10,
-0x38,
-0x4c,
-0x86,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xff,
-0x00,
-0x00,
-
-0x00,
-0x18,
-0x20,
-0x30,
-0x38,
-0x10,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x78,
-0x8c,
-0x0c,
-0x3c,
-0xcc,
-0xcc,
-0xcd,
-0x76,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x20,
-0xe0,
-0x60,
-0x60,
-0x6c,
-0x76,
-0x66,
-0x66,
-0x66,
-0x66,
-0x76,
-0x6c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x3c,
-0x66,
-0x60,
-0x60,
-0x60,
-0x60,
-0x62,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x04,
-0x1c,
-0x0c,
-0x0c,
-0x6c,
-0xdc,
-0xcc,
-0xcc,
-0xcc,
-0xcc,
-0xdc,
-0x66,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x3c,
-0x66,
-0x7e,
-0x60,
-0x60,
-0x60,
-0x62,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x1e,
-0x31,
-0x33,
-0x30,
-0x30,
-0x78,
-0x30,
-0x30,
-0x30,
-0x30,
-0x30,
-0x78,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x7b,
-0xce,
-0xcc,
-0xcc,
-0xcc,
-0x78,
-0x60,
-0x7c,
-0x86,
-0xc6,
-0x7c,
-
-0x00,
-0x20,
-0xe0,
-0x60,
-0x60,
-0x6c,
-0x76,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0xf7,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x10,
-0x38,
-0x10,
-0x00,
-0x18,
-0x38,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x08,
-0x1c,
-0x08,
-0x00,
-0x0c,
-0x1c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x0c,
-0x6c,
-0x4c,
-0x38,
-0x00,
-
-0x00,
-0x20,
-0xe0,
-0x60,
-0x60,
-0x67,
-0x66,
-0x6c,
-0x78,
-0x6c,
-0x6c,
-0x66,
-0xe7,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x08,
-0x38,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x6a,
-0xfe,
-0x6a,
-0x6a,
-0x6a,
-0x62,
-0x62,
-0xf7,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x5c,
-0xf6,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0xf7,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x3c,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x5c,
-0xe6,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x7c,
-0x60,
-0x60,
-0xf0,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x76,
-0xcc,
-0xcc,
-0xcc,
-0xcc,
-0xcc,
-0xcc,
-0x7c,
-0x0c,
-0x0c,
-0x1e,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x5e,
-0xf6,
-0x60,
-0x60,
-0x60,
-0x60,
-0x60,
-0xf0,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x7a,
-0xc6,
-0x72,
-0x1c,
-0x06,
-0x86,
-0xc6,
-0xbc,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x10,
-0x30,
-0x7c,
-0x30,
-0x30,
-0x30,
-0x30,
-0x30,
-0x34,
-0x18,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xee,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x67,
-0x3a,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xf7,
-0x62,
-0x76,
-0x34,
-0x34,
-0x3c,
-0x18,
-0x18,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xf7,
-0x62,
-0x6a,
-0x6a,
-0x6a,
-0x6a,
-0x7e,
-0x24,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xf7,
-0x62,
-0x34,
-0x18,
-0x2c,
-0x46,
-0x46,
-0xef,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xf7,
-0x62,
-0x62,
-0x34,
-0x34,
-0x18,
-0x18,
-0x18,
-0x10,
-0xb0,
-0xe0,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xfe,
-0x8c,
-0x18,
-0x30,
-0x30,
-0x60,
-0xc2,
-0xfe,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x0e,
-0x18,
-0x10,
-0x10,
-0x08,
-0x70,
-0x70,
-0x08,
-0x10,
-0x10,
-0x18,
-0x0e,
-0x00,
-0x00,
-0x00,
-
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x00,
-0x00,
-
-0x00,
-0x70,
-0x18,
-0x08,
-0x08,
-0x10,
-0x0e,
-0x0e,
-0x10,
-0x08,
-0x08,
-0x18,
-0x70,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x76,
-0xdc,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x10,
-0x38,
-0x6c,
-0xc6,
-0xc6,
-0xc6,
-0xfe,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x3a,
-0x66,
-0xc2,
-0xc0,
-0xc0,
-0xc0,
-0xc0,
-0xc0,
-0x62,
-0x3c,
-0x18,
-0x0c,
-0x24,
-0x18,
-
-0x00,
-0x00,
-0x66,
-0x00,
-0x00,
-0xee,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x3b,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x0c,
-0x18,
-0x20,
-0x00,
-0x3c,
-0x66,
-0x7e,
-0x60,
-0x60,
-0x60,
-0x62,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x30,
-0x58,
-0x8c,
-0x00,
-0x78,
-0x8c,
-0x0c,
-0x3c,
-0xcc,
-0xcc,
-0xcd,
-0x76,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x66,
-0x00,
-0x00,
-0x78,
-0x8c,
-0x0c,
-0x3c,
-0xcc,
-0xcc,
-0xcd,
-0x76,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x30,
-0x18,
-0x04,
-0x00,
-0x78,
-0x8c,
-0x0c,
-0x3c,
-0xcc,
-0xcc,
-0xcd,
-0x76,
-0x00,
-0x00,
-0x00,
-
-0x38,
-0x44,
-0x44,
-0x38,
-0x00,
-0x78,
-0x8c,
-0x0c,
-0x3c,
-0xcc,
-0xcc,
-0xcd,
-0x76,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x3c,
-0x66,
-0x60,
-0x60,
-0x60,
-0x60,
-0x62,
-0x3c,
-0x08,
-0x24,
-0x18,
-
-0x00,
-0x18,
-0x2c,
-0x46,
-0x00,
-0x3c,
-0x66,
-0x7e,
-0x60,
-0x60,
-0x60,
-0x62,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x66,
-0x00,
-0x00,
-0x3c,
-0x66,
-0x7e,
-0x60,
-0x60,
-0x60,
-0x62,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x30,
-0x18,
-0x04,
-0x00,
-0x3c,
-0x66,
-0x7e,
-0x60,
-0x60,
-0x60,
-0x62,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x66,
-0x00,
-0x00,
-0x38,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x18,
-0x2c,
-0x46,
-0x00,
-0x38,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x60,
-0x30,
-0x08,
-0x00,
-0x38,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x66,
-0x18,
-0x18,
-0x18,
-0x3c,
-0x2c,
-0x2c,
-0x2c,
-0x7e,
-0x46,
-0x46,
-0x46,
-0xef,
-0x00,
-0x00,
-0x00,
-
-0x18,
-0x24,
-0x18,
-0x18,
-0x3c,
-0x2c,
-0x2c,
-0x2c,
-0x7e,
-0x46,
-0x46,
-0x46,
-0xef,
-0x00,
-0x00,
-0x00,
-
-0x0c,
-0x18,
-0xff,
-0x61,
-0x60,
-0x60,
-0x64,
-0x7c,
-0x64,
-0x60,
-0x60,
-0x61,
-0xfe,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x76,
-0x9b,
-0x1b,
-0x3f,
-0xd8,
-0xd8,
-0xd9,
-0x6e,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x1f,
-0x1d,
-0x1d,
-0x3c,
-0x2c,
-0x2e,
-0x2c,
-0x7c,
-0x4c,
-0x4c,
-0x4d,
-0xef,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x18,
-0x2c,
-0x46,
-0x00,
-0x3c,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x66,
-0x00,
-0x00,
-0x3c,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x30,
-0x18,
-0x04,
-0x00,
-0x3c,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x18,
-0x2c,
-0x46,
-0x00,
-0xee,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x67,
-0x3a,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x30,
-0x18,
-0x04,
-0x00,
-0xee,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x67,
-0x3a,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x66,
-0x00,
-0x00,
-0xf7,
-0x62,
-0x62,
-0x34,
-0x34,
-0x18,
-0x18,
-0x18,
-0x10,
-0xb0,
-0xe0,
-
-0x66,
-0x00,
-0x3c,
-0x66,
-0xc3,
-0xc3,
-0xc3,
-0xc3,
-0xc3,
-0xc3,
-0xc3,
-0x66,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x66,
-0x00,
-0xf7,
-0x62,
-0x62,
-0x62,
-0x62,
-0x62,
-0x62,
-0x62,
-0x62,
-0x62,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x10,
-0x10,
-0x10,
-0x7c,
-0xc6,
-0xc0,
-0xc0,
-0xc0,
-0xc0,
-0xc2,
-0x7c,
-0x10,
-0x10,
-0x00,
-
-0x00,
-0x38,
-0x64,
-0x6c,
-0x60,
-0x60,
-0xf0,
-0x60,
-0x60,
-0x60,
-0x60,
-0x66,
-0xfc,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x81,
-0xc3,
-0x66,
-0x3c,
-0x18,
-0xff,
-0x18,
-0x18,
-0xff,
-0x18,
-0x18,
-0x18,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xfe,
-0x63,
-0x63,
-0x63,
-0x63,
-0x6e,
-0x60,
-0x64,
-0x6e,
-0x64,
-0x64,
-0xf5,
-0x06,
-0x00,
-0x00,
-
-0x00,
-0x0e,
-0x19,
-0x1b,
-0x18,
-0x18,
-0x3c,
-0x18,
-0x18,
-0x18,
-0x18,
-0xd8,
-0x98,
-0x70,
-0x00,
-0x00,
-
-0x00,
-0x0c,
-0x18,
-0x20,
-0x00,
-0x78,
-0x8c,
-0x0c,
-0x3c,
-0xcc,
-0xcc,
-0xcd,
-0x76,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x06,
-0x0c,
-0x10,
-0x00,
-0x38,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x0c,
-0x18,
-0x20,
-0x00,
-0x3c,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x0c,
-0x18,
-0x20,
-0x00,
-0xee,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x67,
-0x3a,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x32,
-0x4c,
-0x00,
-0x5c,
-0xf6,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0xf7,
-0x00,
-0x00,
-0x00,
-
-0x32,
-0x4c,
-0x00,
-0xe7,
-0x72,
-0x52,
-0x5a,
-0x4a,
-0x4e,
-0x46,
-0x46,
-0x42,
-0xe2,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x78,
-0x8c,
-0x0c,
-0x3c,
-0xcc,
-0xcc,
-0xcd,
-0x76,
-0x00,
-0xfe,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x3c,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x3c,
-0x00,
-0x7e,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x30,
-0x30,
-0x00,
-0x30,
-0x10,
-0x10,
-0x20,
-0x40,
-0xc0,
-0xc6,
-0xc2,
-0x7c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xfe,
-0xc0,
-0xc0,
-0xc0,
-0xc0,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xfe,
-0x06,
-0x06,
-0x06,
-0x06,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x20,
-0xe0,
-0x63,
-0x66,
-0xfc,
-0x18,
-0x30,
-0x60,
-0xce,
-0x93,
-0x06,
-0x0c,
-0x1f,
-0x00,
-0x00,
-
-0x00,
-0x20,
-0xe0,
-0x63,
-0x66,
-0xfc,
-0x18,
-0x30,
-0x64,
-0xc8,
-0x96,
-0x3f,
-0x06,
-0x06,
-0x00,
-0x00,
-
-0x00,
-0x18,
-0x18,
-0x00,
-0x08,
-0x18,
-0x18,
-0x18,
-0x3c,
-0x3c,
-0x3c,
-0x3c,
-0x18,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x36,
-0x6c,
-0xd8,
-0xd8,
-0x6c,
-0x36,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xd8,
-0x6c,
-0x36,
-0x36,
-0x6c,
-0xd8,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x82,
-0x10,
-0x82,
-0x10,
-0x82,
-0x10,
-0x82,
-0x10,
-0x82,
-0x10,
-0x82,
-0x10,
-0x82,
-0x10,
-0x82,
-0x10,
-
-0x00,
-0x95,
-0x00,
-0xa9,
-0x00,
-0x95,
-0x00,
-0xa9,
-0x00,
-0x95,
-0x00,
-0xa9,
-0x00,
-0x95,
-0x00,
-0xa9,
-
-0x92,
-0x49,
-0x92,
-0x49,
-0x92,
-0x49,
-0x92,
-0x49,
-0x92,
-0x49,
-0x92,
-0x49,
-0x92,
-0x49,
-0x92,
-0x49,
-
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0xf8,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0xf8,
-0x18,
-0x18,
-0xf8,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0xe6,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xfe,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xf8,
-0x18,
-0x18,
-0xf8,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0xe6,
-0x06,
-0x06,
-0xe6,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xfe,
-0x06,
-0x06,
-0xe6,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0xe6,
-0x06,
-0x06,
-0xfe,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0xfe,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0xf8,
-0x18,
-0x18,
-0xf8,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xf8,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x1f,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0xff,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xff,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x1f,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xff,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0xff,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x1f,
-0x18,
-0x18,
-0x1f,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x67,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x67,
-0x60,
-0x60,
-0x7f,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x7f,
-0x60,
-0x60,
-0x67,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0xe7,
-0x00,
-0x00,
-0xff,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xff,
-0x00,
-0x00,
-0xe7,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x67,
-0x60,
-0x60,
-0x67,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xff,
-0x00,
-0x00,
-0xff,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0xe7,
-0x00,
-0x00,
-0xe7,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0xff,
-0x00,
-0x00,
-0xff,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0xff,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xff,
-0x00,
-0x00,
-0xff,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xff,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x7f,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x1f,
-0x18,
-0x18,
-0x1f,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x1f,
-0x18,
-0x18,
-0x1f,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x7f,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0xff,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0xff,
-0x00,
-0x00,
-0xff,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0xf8,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x1f,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-
-0xf0,
-0xf0,
-0xf0,
-0xf0,
-0xf0,
-0xf0,
-0xf0,
-0xf0,
-0xf0,
-0xf0,
-0xf0,
-0xf0,
-0xf0,
-0xf0,
-0xf0,
-0xf0,
-
-0x0f,
-0x0f,
-0x0f,
-0x0f,
-0x0f,
-0x0f,
-0x0f,
-0x0f,
-0x0f,
-0x0f,
-0x0f,
-0x0f,
-0x0f,
-0x0f,
-0x0f,
-0x0f,
-
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0xff,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x77,
-0xcc,
-0xcc,
-0xcc,
-0xcc,
-0xde,
-0x73,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x7c,
-0xc6,
-0xc6,
-0xc6,
-0xc4,
-0xc8,
-0xc4,
-0xc6,
-0xc6,
-0xc6,
-0xc6,
-0xdc,
-0xc0,
-0xc0,
-0x00,
-
-0x00,
-0xff,
-0x61,
-0x60,
-0x60,
-0x60,
-0x60,
-0x60,
-0x60,
-0x60,
-0x60,
-0x60,
-0xf0,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x01,
-0x7e,
-0xa4,
-0x24,
-0x2c,
-0x6c,
-0x6c,
-0x6c,
-0x48,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xff,
-0xc1,
-0x60,
-0x30,
-0x18,
-0x0c,
-0x18,
-0x30,
-0x60,
-0xc0,
-0xc1,
-0xfe,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x7f,
-0xc8,
-0xc8,
-0xc8,
-0xc8,
-0xc8,
-0xc8,
-0x70,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x22,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x7c,
-0x60,
-0x60,
-0x60,
-0xc0,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x76,
-0xdc,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x10,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x38,
-0x10,
-0x7c,
-0xd6,
-0xd6,
-0xd6,
-0xd6,
-0xd6,
-0xd6,
-0x7c,
-0x10,
-0x38,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x38,
-0x6c,
-0xc6,
-0xc6,
-0xc6,
-0xfe,
-0xc6,
-0xc6,
-0xc6,
-0xc6,
-0x6c,
-0x38,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x3c,
-0x66,
-0xc3,
-0xc3,
-0xc3,
-0xc3,
-0xc3,
-0x66,
-0x24,
-0x24,
-0xa5,
-0xe7,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x1e,
-0x31,
-0x30,
-0x18,
-0x0c,
-0x3e,
-0x66,
-0x66,
-0x66,
-0x66,
-0x66,
-0x3c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x6e,
-0xff,
-0x99,
-0x99,
-0x99,
-0x99,
-0xff,
-0x76,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x02,
-0x04,
-0x7c,
-0xca,
-0x92,
-0xa6,
-0x7c,
-0x40,
-0x80,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x1c,
-0x30,
-0x60,
-0x60,
-0x60,
-0x7c,
-0x60,
-0x60,
-0x60,
-0x60,
-0x30,
-0x1c,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x7c,
-0xc6,
-0xc6,
-0xc6,
-0xc6,
-0xc6,
-0xc6,
-0xc6,
-0xc6,
-0xc6,
-0xc6,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0xfe,
-0x00,
-0x00,
-0x00,
-0x7c,
-0x00,
-0x00,
-0x00,
-0xfe,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x18,
-0x18,
-0x7e,
-0x18,
-0x18,
-0x00,
-0x00,
-0x7e,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x30,
-0x18,
-0x0c,
-0x06,
-0x0c,
-0x18,
-0x30,
-0x00,
-0x7e,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x0c,
-0x18,
-0x30,
-0x60,
-0x30,
-0x18,
-0x0c,
-0x00,
-0x7e,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x0e,
-0x19,
-0x1b,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0x18,
-0xd8,
-0x98,
-0x70,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x18,
-0x18,
-0x00,
-0x7e,
-0x00,
-0x18,
-0x18,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x76,
-0xdc,
-0x00,
-0x00,
-0x76,
-0xdc,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x38,
-0x44,
-0x44,
-0x44,
-0x38,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x18,
-0x18,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x18,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x07,
-0x06,
-0x06,
-0x0c,
-0x0c,
-0x08,
-0x98,
-0xd0,
-0xf0,
-0x60,
-0x20,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0xcc,
-0x76,
-0x66,
-0x66,
-0x66,
-0x66,
-0xf7,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x70,
-0x98,
-0x18,
-0x30,
-0x60,
-0x88,
-0xf8,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x7c,
-0x64,
-0x64,
-0x64,
-0x64,
-0x64,
-0x7c,
-0x00,
-0x00,
-0x00,
-0x00,
-
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-0x00,
-
-};
-
-
-const struct font_desc font_rl = {
-       RL_IDX,
-       "RomanLarge",
-       8,
-       16,
-       patterns,
-       -1
-};
index 9be83bed19597dd45bfec2736b51b2d8c7b0c1fa..4fd07d9eca039d062c9968c452757f952b962a7e 100644 (file)
@@ -64,10 +64,6 @@ static const struct font_desc *fonts[] = {
 #undef NO_FONTS
     &font_mini_4x6,
 #endif
-#ifdef CONFIG_FONT_RL
-#undef NO_FONTS
-    &font_rl,
-#endif
 };
 
 #define num_fonts (sizeof(fonts)/sizeof(*fonts))
index 04417dc16c2e3572084a9edaad40a7af3982d71b..2584daec7bbf2132c0df085ede3bcf4b2a692b21 100644 (file)
@@ -57,6 +57,9 @@ static struct fb_ops ffb_ops = {
        .fb_sync                = ffb_sync,
        .fb_mmap                = ffb_mmap,
        .fb_ioctl               = ffb_ioctl,
+#ifdef CONFIG_COMPAT
+       .fb_compat_ioctl        = sbusfb_compat_ioctl,
+#endif
 };
 
 /* Register layout and definitions */
index 84a7fe435bb82bd082c770b51cbae2b511c8d361..376d4a171ec7bd4fb4d0ca6698d6fdb6522cfa72 100644 (file)
@@ -51,6 +51,9 @@ static struct fb_ops leo_ops = {
        .fb_imageblit           = cfb_imageblit,
        .fb_mmap                = leo_mmap,
        .fb_ioctl               = leo_ioctl,
+#ifdef CONFIG_COMPAT
+       .fb_compat_ioctl        = sbusfb_compat_ioctl,
+#endif
 };
 
 #define LEO_OFF_LC_SS0_KRN     0x00200000UL
index f60b1f4322700d2554e729245145c9c8407714d3..3353103e8b0bd7416bb2ba05dbfb4ac21f52ec5c 100644 (file)
@@ -42,7 +42,7 @@ int nvidia_probe_i2c_connector(struct fb_info *info, int conn,
 #define nvidia_probe_i2c_connector(p, c, edid) (-1)
 #endif
 
-#ifdef CONFIG_FB_OF
+#ifdef CONFIG_PPC_OF
 int nvidia_probe_of_connector(struct fb_info *info, int conn,
                              u8 ** out_edid);
 #else
index 0b40a2a721c180609c15b16e82e3209b195a846e..bee09c6e48f61ce28224fa2282f6bd8f113f114a 100644 (file)
@@ -1301,7 +1301,7 @@ static int nvidiafb_pan_display(struct fb_var_screeninfo *var,
        struct nvidia_par *par = info->par;
        u32 total;
 
-       total = info->var.yoffset * info->fix.line_length + info->var.xoffset;
+       total = var->yoffset * info->fix.line_length + var->xoffset;
 
        NVSetStartAddress(par, total);
 
index 9aaf65fb623ae99e0df6dc2289c1f7e7379af89d..18bcda23d2cf7b7a2a9d39ae03b87b4cad91799f 100644 (file)
@@ -48,6 +48,9 @@ static struct fb_ops p9100_ops = {
        .fb_imageblit           = cfb_imageblit,
        .fb_mmap                = p9100_mmap,
        .fb_ioctl               = p9100_ioctl,
+#ifdef CONFIG_COMPAT
+       .fb_compat_ioctl        = sbusfb_compat_ioctl,
+#endif
 };
 
 /* P9100 control registers */
index 34f72edba820e0edd638b7c8e2556440dec1bee6..646c43f921c55b3bc0774fecbd92cb38778b3b33 100644 (file)
@@ -3,6 +3,7 @@
  * Copyright (C) 2003 David S. Miller (davem@redhat.com)
  */
 
+#include <linux/compat.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/string.h>
@@ -182,3 +183,109 @@ int sbusfb_ioctl_helper(unsigned long cmd, unsigned long arg,
        };
 }
 EXPORT_SYMBOL(sbusfb_ioctl_helper);
+
+#ifdef CONFIG_COMPAT
+struct  fbcmap32 {
+       int             index;          /* first element (0 origin) */
+       int             count;
+       u32             red;
+       u32             green;
+       u32             blue;
+};
+
+#define FBIOPUTCMAP32  _IOW('F', 3, struct fbcmap32)
+#define FBIOGETCMAP32  _IOW('F', 4, struct fbcmap32)
+
+static int fbiogetputcmap(struct file *file, struct fb_info *info,
+               unsigned int cmd, unsigned long arg)
+{
+       struct fbcmap32 __user *argp = (void __user *)arg;
+       struct fbcmap __user *p = compat_alloc_user_space(sizeof(*p));
+       u32 addr;
+       int ret;
+
+       ret = copy_in_user(p, argp, 2 * sizeof(int));
+       ret |= get_user(addr, &argp->red);
+       ret |= put_user(compat_ptr(addr), &p->red);
+       ret |= get_user(addr, &argp->green);
+       ret |= put_user(compat_ptr(addr), &p->green);
+       ret |= get_user(addr, &argp->blue);
+       ret |= put_user(compat_ptr(addr), &p->blue);
+       if (ret)
+               return -EFAULT;
+       return info->fbops->fb_ioctl(file->f_dentry->d_inode, file,
+                       (cmd == FBIOPUTCMAP32) ?
+                       FBIOPUTCMAP_SPARC : FBIOGETCMAP_SPARC,
+                       (unsigned long)p, info);
+}
+
+struct fbcursor32 {
+       short set;              /* what to set, choose from the list above */
+       short enable;           /* cursor on/off */
+       struct fbcurpos pos;    /* cursor position */
+       struct fbcurpos hot;    /* cursor hot spot */
+       struct fbcmap32 cmap;   /* color map info */
+       struct fbcurpos size;   /* cursor bit map size */
+       u32     image;          /* cursor image bits */
+       u32     mask;           /* cursor mask bits */
+};
+
+#define FBIOSCURSOR32  _IOW('F', 24, struct fbcursor32)
+#define FBIOGCURSOR32  _IOW('F', 25, struct fbcursor32)
+
+static int fbiogscursor(struct file *file, struct fb_info *info,
+               unsigned long arg)
+{
+       struct fbcursor __user *p = compat_alloc_user_space(sizeof(*p));
+       struct fbcursor32 __user *argp =  (void __user *)arg;
+       compat_uptr_t addr;
+       int ret;
+
+       ret = copy_in_user(p, argp,
+                             2 * sizeof (short) + 2 * sizeof(struct fbcurpos));
+       ret |= copy_in_user(&p->size, &argp->size, sizeof(struct fbcurpos));
+       ret |= copy_in_user(&p->cmap, &argp->cmap, 2 * sizeof(int));
+       ret |= get_user(addr, &argp->cmap.red);
+       ret |= put_user(compat_ptr(addr), &p->cmap.red);
+       ret |= get_user(addr, &argp->cmap.green);
+       ret |= put_user(compat_ptr(addr), &p->cmap.green);
+       ret |= get_user(addr, &argp->cmap.blue);
+       ret |= put_user(compat_ptr(addr), &p->cmap.blue);
+       ret |= get_user(addr, &argp->mask);
+       ret |= put_user(compat_ptr(addr), &p->mask);
+       ret |= get_user(addr, &argp->image);
+       ret |= put_user(compat_ptr(addr), &p->image);
+       if (ret)
+               return -EFAULT;
+       return info->fbops->fb_ioctl(file->f_dentry->d_inode, file,
+                       FBIOSCURSOR, (unsigned long)p, info);
+}
+
+long sbusfb_compat_ioctl(struct file *file, unsigned int cmd,
+               unsigned long arg, struct fb_info *info)
+{
+       switch (cmd) {
+       case FBIOGTYPE:
+       case FBIOSATTR:
+       case FBIOGATTR:
+       case FBIOSVIDEO:
+       case FBIOGVIDEO:
+       case FBIOGCURSOR32:     /* This is not implemented yet.
+                                  Later it should be converted... */
+       case FBIOSCURPOS:
+       case FBIOGCURPOS:
+       case FBIOGCURMAX:
+               return info->fbops->fb_ioctl(file->f_dentry->d_inode,
+                               file, cmd, arg, info);
+       case FBIOPUTCMAP32:
+               return fbiogetputcmap(file, info, cmd, arg);
+       case FBIOGETCMAP32:
+               return fbiogetputcmap(file, info, cmd, arg);
+       case FBIOSCURSOR32:
+               return fbiogscursor(file, info, arg);
+       default:
+               return -ENOIOCTLCMD;
+       }
+}
+EXPORT_SYMBOL(sbusfb_compat_ioctl);
+#endif
index a6aa33ba09d6e80c4c2be7a34a00e0c80603cf06..b470e52ce9e2ffdc162beb7be3b05d50af395267 100644 (file)
@@ -20,5 +20,7 @@ extern int sbusfb_mmap_helper(struct sbus_mmap_map *map,
 int sbusfb_ioctl_helper(unsigned long cmd, unsigned long arg,
                        struct fb_info *info,
                        int type, int fb_depth, unsigned long fb_size);
+long sbusfb_compat_ioctl(struct file *file, unsigned int cmd,
+               unsigned long arg, struct fb_info *info);
 
 #endif /* _SBUSLIB_H */
index 59fff29bc02e528c8c4d1c845d340da1de88ee35..fe4f63f3849d530b9511da463050bcb74cb174c2 100644 (file)
@@ -52,6 +52,9 @@ static struct fb_ops tcx_ops = {
        .fb_imageblit           = cfb_imageblit,
        .fb_mmap                = tcx_mmap,
        .fb_ioctl               = tcx_ioctl,
+#ifdef CONFIG_COMPAT
+       .fb_compat_ioctl        = sbusfb_compat_ioctl,
+#endif
 };
 
 /* THC definitions */
index 2c3aa2fcfd917e5098c465ab97836ba90037c3a5..3e58ddc2bc3829de17a73ddb496ad67ac7624534 100644 (file)
@@ -413,6 +413,7 @@ static int __init vesafb_probe(struct platform_device *dev)
         * region already (FIXME) */
        request_region(0x3c0, 32, "vesafb");
 
+#ifdef CONFIG_MTRR
        if (mtrr) {
                unsigned int temp_size = size_total;
                unsigned int type = 0;
@@ -450,6 +451,7 @@ static int __init vesafb_probe(struct platform_device *dev)
                        } while (temp_size >= PAGE_SIZE && rc == -EINVAL);
                }
        }
+#endif
        
        info->fbops = &vesafb_ops;
        info->var = vesafb_defined;
index daa46051f55df8ea5b77f2c5245d677e0ed5c179..f6e24ee85f077db2e0f6d3021aef12a652f6e383 100644 (file)
@@ -514,7 +514,7 @@ int __init w100fb_probe(struct platform_device *pdev)
        if (remapped_fbuf == NULL)
                goto out;
 
-       info=framebuffer_alloc(sizeof(struct w100fb_par), dev);
+       info=framebuffer_alloc(sizeof(struct w100fb_par), &pdev->dev);
        if (!info) {
                err = -ENOMEM;
                goto out;
index 20bb919eb1958e6e4dbbf96f6f04812a23983a24..5a28b69ad223b243121c8eb65495f9a519891d33 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -457,6 +457,8 @@ static inline struct kiocb *aio_get_req(struct kioctx *ctx)
 
 static inline void really_put_req(struct kioctx *ctx, struct kiocb *req)
 {
+       assert_spin_locked(&ctx->ctx_lock);
+
        if (req->ki_dtor)
                req->ki_dtor(req);
        kmem_cache_free(kiocb_cachep, req);
@@ -498,6 +500,8 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req)
        dprintk(KERN_DEBUG "aio_put(%p): f_count=%d\n",
                req, atomic_read(&req->ki_filp->f_count));
 
+       assert_spin_locked(&ctx->ctx_lock);
+
        req->ki_users --;
        if (unlikely(req->ki_users < 0))
                BUG();
@@ -619,14 +623,13 @@ static void unuse_mm(struct mm_struct *mm)
  * the kiocb (to tell the caller to activate the work
  * queue to process it), or 0, if it found that it was
  * already queued.
- *
- * Should be called with the spin lock iocb->ki_ctx->ctx_lock
- * held
  */
 static inline int __queue_kicked_iocb(struct kiocb *iocb)
 {
        struct kioctx *ctx = iocb->ki_ctx;
 
+       assert_spin_locked(&ctx->ctx_lock);
+
        if (list_empty(&iocb->ki_run_list)) {
                list_add_tail(&iocb->ki_run_list,
                        &ctx->run_list);
@@ -771,13 +774,15 @@ out:
  *     Process all pending retries queued on the ioctx
  *     run list.
  * Assumes it is operating within the aio issuer's mm
- * context. Expects to be called with ctx->ctx_lock held
+ * context.
  */
 static int __aio_run_iocbs(struct kioctx *ctx)
 {
        struct kiocb *iocb;
        LIST_HEAD(run_list);
 
+       assert_spin_locked(&ctx->ctx_lock);
+
        list_splice_init(&ctx->run_list, &run_list);
        while (!list_empty(&run_list)) {
                iocb = list_entry(run_list.next, struct kiocb,
@@ -937,28 +942,19 @@ int fastcall aio_complete(struct kiocb *iocb, long res, long res2)
        unsigned long   tail;
        int             ret;
 
-       /* Special case handling for sync iocbs: events go directly
-        * into the iocb for fast handling.  Note that this will not 
-        * work if we allow sync kiocbs to be cancelled. in which
-        * case the usage count checks will have to move under ctx_lock
-        * for all cases.
+       /*
+        * Special case handling for sync iocbs:
+        *  - events go directly into the iocb for fast handling
+        *  - the sync task with the iocb in its stack holds the single iocb
+        *    ref, no other paths have a way to get another ref
+        *  - the sync task helpfully left a reference to itself in the iocb
         */
        if (is_sync_kiocb(iocb)) {
-               int ret;
-
+               BUG_ON(iocb->ki_users != 1);
                iocb->ki_user_data = res;
-               if (iocb->ki_users == 1) {
-                       iocb->ki_users = 0;
-                       ret = 1;
-               } else {
-                       spin_lock_irq(&ctx->ctx_lock);
-                       iocb->ki_users--;
-                       ret = (0 == iocb->ki_users);
-                       spin_unlock_irq(&ctx->ctx_lock);
-               }
-               /* sync iocbs put the task here for us */
+               iocb->ki_users = 0;
                wake_up_process(iocb->ki_obj.tsk);
-               return ret;
+               return 1;
        }
 
        info = &ctx->ring_info;
@@ -1613,12 +1609,14 @@ asmlinkage long sys_io_submit(aio_context_t ctx_id, long nr,
 
 /* lookup_kiocb
  *     Finds a given iocb for cancellation.
- *     MUST be called with ctx->ctx_lock held.
  */
 static struct kiocb *lookup_kiocb(struct kioctx *ctx, struct iocb __user *iocb,
                                  u32 key)
 {
        struct list_head *pos;
+
+       assert_spin_locked(&ctx->ctx_lock);
+
        /* TODO: use a hash or array, this sucks. */
        list_for_each(pos, &ctx->active_reqs) {
                struct kiocb *kiocb = list_kiocb(pos);
index e4ed4b31a4333d47472936bfcc7b061e298e8496..522fa70dd8ea140cca303ea7724d32461a0a5dad 100644 (file)
@@ -881,7 +881,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
        }
        if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL))
                ext2_warning(sb, __FUNCTION__,
-                       "mounting ext3 filesystem as ext2\n");
+                       "mounting ext3 filesystem as ext2");
        ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY);
        percpu_counter_mod(&sbi->s_freeblocks_counter,
                                ext2_count_free_blocks(sb));
index 5d9b00e2883720a8b0e2cc48a72d05a65d696a7b..8824e84f8a56a58b8f0aee6ac99cbc9307038565 100644 (file)
@@ -1384,8 +1384,10 @@ static int ext3_journalled_writepage(struct page *page,
                ClearPageChecked(page);
                ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE,
                                        ext3_get_block);
-               if (ret != 0)
+               if (ret != 0) {
+                       ext3_journal_stop(handle);
                        goto out_unlock;
+               }
                ret = walk_page_buffers(handle, page_buffers(page), 0,
                        PAGE_CACHE_SIZE, NULL, do_journal_get_write_access);
 
index 0e7456ec99fd05a778738da5ab69ec57cd1629a4..3e51dd1da8aa7f271dc1205139d9dc0d658cec52 100644 (file)
@@ -284,9 +284,6 @@ int jffs2_fill_scan_buf (struct jffs2_sb_info *c, void *buf,
                D1(printk(KERN_WARNING "Read at 0x%x gave only 0x%zx bytes\n", ofs, retlen));
                return -EIO;
        }
-       D2(printk(KERN_DEBUG "Read 0x%x bytes from 0x%08x into buf\n", len, ofs));
-       D2(printk(KERN_DEBUG "000: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
-                 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]));
        return 0;
 }
 
index a1e8b2248014c0aa1d7ae8b2766440f753929908..250ef53d25ef8cfce06e333b83a746ef2577aa3d 100644 (file)
@@ -1105,7 +1105,6 @@ static void time_out_leases(struct inode *inode)
                        before = &fl->fl_next;
                        continue;
                }
-               printk(KERN_INFO "lease broken - owner pid = %d\n", fl->fl_pid);
                lease_modify(before, fl->fl_type & ~F_INPROGRESS);
                if (fl == *before)      /* lease_modify may have freed fl */
                        before = &fl->fl_next;
@@ -1430,7 +1429,7 @@ int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
        lock_kernel();
 
        error = __setlease(filp, arg, &flp);
-       if (error)
+       if (error || arg == F_UNLCK)
                goto out_unlock;
 
        error = fasync_helper(fd, filp, 1, &flp->fl_fasync);
index d2fa42006d8fe96cbc8fc0413d710c1df9a4255e..9ab97cef0daa001dded3c6d667e95ea4134fc0a7 100644 (file)
@@ -195,7 +195,7 @@ static int show_map_internal(struct seq_file *m, void *v, struct mem_size_stats
 
 static int show_map(struct seq_file *m, void *v)
 {
-       return show_map_internal(m, v, 0);
+       return show_map_internal(m, v, NULL);
 }
 
 static void smaps_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
index 20ac3d95ecd9ae34ab3fcba2c58a5656c72be6d7..36505bb4e8cbb8790e4be3d44b067f44e3ede462 100644 (file)
@@ -177,6 +177,18 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
        return result;
 }
 
+#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
+
+#define atomic_add_unless(v, a, u)                             \
+({                                                             \
+       int c, old;                                             \
+       c = atomic_read(v);                                     \
+       while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+               c = old;                                        \
+       c != (u);                                               \
+})
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 #define atomic_dec_return(v) atomic_sub_return(1,(v))
 #define atomic64_dec_return(v) atomic64_sub_return(1,(v))
 
index 2885972b0855cafb87e922641560d3fcd9c4c2d8..75b802719723ad459d719b6f598254fe0dfe02e4 100644 (file)
@@ -80,6 +80,23 @@ static inline int atomic_sub_return(int i, atomic_t *v)
        return result;
 }
 
+static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
+{
+       u32 oldval, res;
+
+       do {
+               __asm__ __volatile__("@ atomic_cmpxchg\n"
+               "ldrex  %1, [%2]\n"
+               "teq    %1, %3\n"
+               "strexeq %0, %4, [%2]\n"
+                   : "=&r" (res), "=&r" (oldval)
+                   : "r" (&ptr->counter), "Ir" (old), "r" (new)
+                   : "cc");
+       } while (res);
+
+       return oldval;
+}
+
 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
 {
        unsigned long tmp, tmp2;
@@ -131,6 +148,20 @@ static inline int atomic_sub_return(int i, atomic_t *v)
        return val;
 }
 
+static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
+{
+       int ret;
+       unsigned long flags;
+
+       local_irq_save(flags);
+       ret = v->counter;
+       if (likely(ret == old))
+               v->counter = new;
+       local_irq_restore(flags);
+
+       return ret;
+}
+
 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
 {
        unsigned long flags;
@@ -142,6 +173,17 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
 
 #endif /* __LINUX_ARM_ARCH__ */
 
+static inline int atomic_add_unless(atomic_t *v, int a, int u)
+{
+       int c, old;
+
+       c = atomic_read(v);
+       while (c != u && (old = atomic_cmpxchg((v), c, c + a)) != c)
+               c = old;
+       return c != u;
+}
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 #define atomic_add(i, v)       (void) atomic_add_return(i, v)
 #define atomic_inc(v)          (void) atomic_add_return(1, v)
 #define atomic_sub(i, v)       (void) atomic_sub_return(i, v)
index 4a88235c0e76a4fc41ca372d6df413ba811ded02..a47cadc59686237260877f1874b2c18ff0ed9421 100644 (file)
@@ -62,6 +62,35 @@ static inline int atomic_sub_return(int i, atomic_t *v)
         return val;
 }
 
+static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
+{
+       int ret;
+       unsigned long flags;
+
+       local_irq_save(flags);
+       ret = v->counter;
+       if (likely(ret == old))
+               v->counter = new;
+       local_irq_restore(flags);
+
+       return ret;
+}
+
+static inline int atomic_add_unless(atomic_t *v, int a, int u)
+{
+       int ret;
+       unsigned long flags;
+
+       local_irq_save(flags);
+       ret = v->counter;
+       if (ret != u)
+               v->counter += a;
+       local_irq_restore(flags);
+
+       return ret != u;
+}
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
 {
         unsigned long flags;
index 8c2e78304523c24da5904dc9b3d85d2988383979..683b05a57d88068527bea8d99343c2425503318c 100644 (file)
@@ -123,6 +123,33 @@ static inline int atomic_inc_and_test(volatile atomic_t *v)
        return retval;
 }
 
+static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
+{
+       int ret;
+       unsigned long flags;
+
+       cris_atomic_save(v, flags);
+       ret = v->counter;
+       if (likely(ret == old))
+               v->counter = new;
+       cris_atomic_restore(v, flags);
+       return ret;
+}
+
+static inline int atomic_add_unless(atomic_t *v, int a, int u)
+{
+       int ret;
+       unsigned long flags;
+
+       cris_atomic_save(v, flags);
+       ret = v->counter;
+       if (ret != u)
+               v->counter += a;
+       cris_atomic_restore(v, flags);
+       return ret != u;
+}
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 /* Atomic operations are already serializing */
 #define smp_mb__before_atomic_dec()    barrier()
 #define smp_mb__after_atomic_dec()     barrier()
index e7596846342879c7bcaa21c1b082a3d3bc07b27b..f6539ff569c5278abece2c6442cbab205dd80311 100644 (file)
@@ -414,4 +414,16 @@ extern uint32_t __cmpxchg_32(uint32_t *v, uint32_t test, uint32_t new);
 
 #endif
 
+#define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new))
+
+#define atomic_add_unless(v, a, u)                             \
+({                                                             \
+       int c, old;                                             \
+       c = atomic_read(v);                                     \
+       while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+               c = old;                                        \
+       c != (u);                                               \
+})
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 #endif /* _ASM_ATOMIC_H */
index 7230f650799501e59044322fd7196f72eddb4400..f23d86819ea82b83fb75bcce32516b78817524e0 100644 (file)
@@ -82,6 +82,33 @@ static __inline__ int atomic_dec_and_test(atomic_t *v)
        return ret == 0;
 }
 
+static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
+{
+       int ret;
+       unsigned long flags;
+
+       local_irq_save(flags);
+       ret = v->counter;
+       if (likely(ret == old))
+               v->counter = new;
+       local_irq_restore(flags);
+       return ret;
+}
+
+static inline int atomic_add_unless(atomic_t *v, int a, int u)
+{
+       int ret;
+       unsigned long flags;
+
+       local_irq_save(flags);
+       ret = v->counter;
+       if (ret != u)
+               v->counter += a;
+       local_irq_restore(flags);
+       return ret != u;
+}
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 static __inline__ void atomic_clear_mask(unsigned long mask, unsigned long *v)
 {
        __asm__ __volatile__("stc ccr,r1l\n\t"
index 509720be772a4121aad122b2ec5fd9cf83a7cdf0..c68557aa04b2b0ef9246086f6d52b156c72966c0 100644 (file)
@@ -215,6 +215,27 @@ static __inline__ int atomic_sub_return(int i, atomic_t *v)
        return atomic_add_return(-i,v);
 }
 
+#define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new))
+
+/**
+ * atomic_add_unless - add unless the number is a given value
+ * @v: pointer of type atomic_t
+ * @a: the amount to add to v...
+ * @u: ...unless v is equal to u.
+ *
+ * Atomically adds @a to @v, so long as it was not @u.
+ * Returns non-zero if @v was not @u, and zero otherwise.
+ */
+#define atomic_add_unless(v, a, u)                             \
+({                                                             \
+       int c, old;                                             \
+       c = atomic_read(v);                                     \
+       while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+               c = old;                                        \
+       c != (u);                                               \
+})
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 #define atomic_inc_return(v)  (atomic_add_return(1,v))
 #define atomic_dec_return(v)  (atomic_sub_return(1,v))
 
index 97d52ac49e46626eac3018e388695147525c476b..772f85da1206af441de3d5df59892921931a8b51 100644 (file)
@@ -263,6 +263,10 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
 
 #ifdef CONFIG_X86_CMPXCHG
 #define __HAVE_ARCH_CMPXCHG 1
+#define cmpxchg(ptr,o,n)\
+       ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\
+                                       (unsigned long)(n),sizeof(*(ptr))))
+#endif
 
 static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
                                      unsigned long new, int size)
@@ -291,10 +295,42 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
        return old;
 }
 
-#define cmpxchg(ptr,o,n)\
-       ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\
-                                       (unsigned long)(n),sizeof(*(ptr))))
+#ifndef CONFIG_X86_CMPXCHG
+/*
+ * Building a kernel capable running on 80386. It may be necessary to
+ * simulate the cmpxchg on the 80386 CPU. For that purpose we define
+ * a function for each of the sizes we support.
+ */
 
+extern unsigned long cmpxchg_386_u8(volatile void *, u8, u8);
+extern unsigned long cmpxchg_386_u16(volatile void *, u16, u16);
+extern unsigned long cmpxchg_386_u32(volatile void *, u32, u32);
+
+static inline unsigned long cmpxchg_386(volatile void *ptr, unsigned long old,
+                                     unsigned long new, int size)
+{
+       switch (size) {
+       case 1:
+               return cmpxchg_386_u8(ptr, old, new);
+       case 2:
+               return cmpxchg_386_u16(ptr, old, new);
+       case 4:
+               return cmpxchg_386_u32(ptr, old, new);
+       }
+       return old;
+}
+
+#define cmpxchg(ptr,o,n)                                               \
+({                                                                     \
+       __typeof__(*(ptr)) __ret;                                       \
+       if (likely(boot_cpu_data.x86 > 3))                              \
+               __ret = __cmpxchg((ptr), (unsigned long)(o),            \
+                                       (unsigned long)(n), sizeof(*(ptr))); \
+       else                                                            \
+               __ret = cmpxchg_386((ptr), (unsigned long)(o),          \
+                                       (unsigned long)(n), sizeof(*(ptr))); \
+       __ret;                                                          \
+})
 #endif
 
 #ifdef CONFIG_X86_CMPXCHG64
index 874a6f890e75c14fc2677c1b29252ef60b662234..2fbebf85c31d55a1b1ac8b5f7d69a62f5c554860 100644 (file)
@@ -88,6 +88,18 @@ ia64_atomic64_sub (__s64 i, atomic64_t *v)
        return new;
 }
 
+#define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new))
+
+#define atomic_add_unless(v, a, u)                             \
+({                                                             \
+       int c, old;                                             \
+       c = atomic_read(v);                                     \
+       while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+               c = old;                                        \
+       c != (u);                                               \
+})
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 #define atomic_add_return(i,v)                                         \
 ({                                                                     \
        int __ia64_aar_i = (i);                                         \
index 38f3043e7fe1acfb9be1b8c8286eb4f488c1672b..e3c962eeabf3d37871d24e87638fcc8005bf3048 100644 (file)
@@ -139,6 +139,18 @@ static inline void atomic_set_mask(unsigned long mask, unsigned long *v)
        __asm__ __volatile__("orl %1,%0" : "+m" (*v) : "id" (mask));
 }
 
+#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
+
+#define atomic_add_unless(v, a, u)                             \
+({                                                             \
+       int c, old;                                             \
+       c = atomic_read(v);                                     \
+       while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+               c = old;                                        \
+       c != (u);                                               \
+})
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 /* Atomic operations are already serializing */
 #define smp_mb__before_atomic_dec()    barrier()
 #define smp_mb__after_atomic_dec()     barrier()
index df1575db32afb0df7efbb3827762feb3fd2fd917..7982285e84edcdaf3d3f3647b45ed87687ebb542 100644 (file)
@@ -14,6 +14,7 @@
 #define current_text_addr() ({ __label__ _l; _l: &&_l;})
 
 #include <linux/config.h>
+#include <linux/thread_info.h>
 #include <asm/segment.h>
 #include <asm/fpu.h>
 #include <asm/ptrace.h>
@@ -55,17 +56,6 @@ static inline void wrusp(unsigned long usp)
 #endif
 #define TASK_UNMAPPED_ALIGN(addr, off) PAGE_ALIGN(addr)
 
-struct task_work {
-       unsigned char sigpending;
-       unsigned char notify_resume;    /* request for notification on
-                                          userspace execution resumption */
-       char          need_resched;
-       unsigned char delayed_trace;    /* single step a syscall */
-       unsigned char syscall_trace;    /* count of syscall interceptors */
-       unsigned char memdie;           /* task was selected to be killed */
-       unsigned char pad[2];
-};
-
 struct thread_struct {
        unsigned long  ksp;             /* kernel stack pointer */
        unsigned long  usp;             /* user stack pointer */
@@ -78,7 +68,7 @@ struct thread_struct {
        unsigned long  fp[8*3];
        unsigned long  fpcntl[3];       /* fp control regs */
        unsigned char  fpstate[FPSTATESIZE];  /* floating point state */
-       struct task_work work;
+       struct thread_info info;
 };
 
 #define INIT_THREAD  {                                                 \
index 2aed24f6fd2e75a1193036f4f14ab0bbe22eb0bd..9532ca3c45cbea08906689234ad6a3e0f6224515 100644 (file)
@@ -2,17 +2,15 @@
 #define _ASM_M68K_THREAD_INFO_H
 
 #include <asm/types.h>
-#include <asm/processor.h>
 #include <asm/page.h>
 
 struct thread_info {
        struct task_struct      *task;          /* main task structure */
+       unsigned long           flags;
        struct exec_domain      *exec_domain;   /* execution domain */
        int                     preempt_count;  /* 0 => preemptable, <0 => BUG */
        __u32 cpu; /* should always be 0 on m68k */
        struct restart_block    restart_block;
-
-       __u8                    supervisor_stack[0];
 };
 
 #define PREEMPT_ACTIVE         0x4000000
@@ -35,84 +33,29 @@ struct thread_info {
 #define free_thread_info(ti)  free_pages((unsigned long)(ti),1)
 #endif /* PAGE_SHIFT == 13 */
 
-//#define init_thread_info     (init_task.thread.info)
+#define init_thread_info       (init_task.thread.info)
 #define init_stack             (init_thread_union.stack)
 
-#define current_thread_info()  (current->thread_info)
-
+#define task_thread_info(tsk)  (&(tsk)->thread.info)
+#define current_thread_info()  task_thread_info(current)
 
 #define __HAVE_THREAD_FUNCTIONS
 
-#define TIF_SYSCALL_TRACE      0       /* syscall trace active */
-#define TIF_DELAYED_TRACE      1       /* single step a syscall */
-#define TIF_NOTIFY_RESUME      2       /* resumption notification requested */
-#define TIF_SIGPENDING         3       /* signal pending */
-#define TIF_NEED_RESCHED       4       /* rescheduling necessary */
-#define TIF_MEMDIE             5
-
-extern int thread_flag_fixme(void);
-
-/*
- * flag set/clear/test wrappers
- * - pass TIF_xxxx constants to these functions
- */
-
-#define __set_tsk_thread_flag(tsk, flag, val) ({       \
-       switch (flag) {                                 \
-       case TIF_SIGPENDING:                            \
-               tsk->thread.work.sigpending = val;      \
-               break;                                  \
-       case TIF_NEED_RESCHED:                          \
-               tsk->thread.work.need_resched = val;    \
-               break;                                  \
-       case TIF_SYSCALL_TRACE:                         \
-               tsk->thread.work.syscall_trace = val;   \
-               break;                                  \
-       case TIF_MEMDIE:                                \
-               tsk->thread.work.memdie = val;          \
-               break;                                  \
-       default:                                        \
-               thread_flag_fixme();                    \
-       }                                               \
+#define setup_thread_stack(p, org) ({                  \
+       *(struct task_struct **)(p)->thread_info = (p); \
+       task_thread_info(p)->task = (p);                \
 })
 
-#define __get_tsk_thread_flag(tsk, flag) ({            \
-       int ___res;                                     \
-       switch (flag) {                                 \
-       case TIF_SIGPENDING:                            \
-               ___res = tsk->thread.work.sigpending;   \
-               break;                                  \
-       case TIF_NEED_RESCHED:                          \
-               ___res = tsk->thread.work.need_resched; \
-               break;                                  \
-       case TIF_SYSCALL_TRACE:                         \
-               ___res = tsk->thread.work.syscall_trace;\
-               break;                                  \
-       case TIF_MEMDIE:                                \
-               ___res = tsk->thread.work.memdie;\
-               break;                                  \
-       default:                                        \
-               ___res = thread_flag_fixme();           \
-       }                                               \
-       ___res;                                         \
-})
-
-#define __get_set_tsk_thread_flag(tsk, flag, val) ({   \
-       int __res = __get_tsk_thread_flag(tsk, flag);   \
-       __set_tsk_thread_flag(tsk, flag, val);          \
-       __res;                                          \
-})
+#define end_of_stack(p) ((unsigned long *)(p)->thread_info + 1)
 
-#define set_tsk_thread_flag(tsk, flag) __set_tsk_thread_flag(tsk, flag, ~0)
-#define clear_tsk_thread_flag(tsk, flag) __set_tsk_thread_flag(tsk, flag, 0)
-#define test_and_set_tsk_thread_flag(tsk, flag) __get_set_tsk_thread_flag(tsk, flag, ~0)
-#define test_tsk_thread_flag(tsk, flag) __get_tsk_thread_flag(tsk, flag)
-
-#define set_thread_flag(flag) set_tsk_thread_flag(current, flag)
-#define clear_thread_flag(flag) clear_tsk_thread_flag(current, flag)
-#define test_thread_flag(flag) test_tsk_thread_flag(current, flag)
-
-#define set_need_resched() set_thread_flag(TIF_NEED_RESCHED)
-#define clear_need_resched() clear_thread_flag(TIF_NEED_RESCHED)
+/* entry.S relies on these definitions!
+ * bits 0-7 are tested at every exception exit
+ * bits 8-15 are also tested at syscall exit
+ */
+#define TIF_SIGPENDING         6       /* signal pending */
+#define TIF_NEED_RESCHED       7       /* rescheduling necessary */
+#define TIF_DELAYED_TRACE      14      /* single step a syscall */
+#define TIF_SYSCALL_TRACE      15      /* syscall trace active */
+#define TIF_MEMDIE             16
 
 #endif /* _ASM_M68K_THREAD_INFO_H */
index a83631ed8c8f7a487b446893562b80e12172b346..3c1cc153c4154c233fc05dc6f0f0b8f7f3b8e9f9 100644 (file)
@@ -128,6 +128,18 @@ static inline int atomic_sub_return(int i, atomic_t * v)
        return temp;
 }
 
+#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
+
+#define atomic_add_unless(v, a, u)                             \
+({                                                             \
+       int c, old;                                             \
+       c = atomic_read(v);                                     \
+       while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+               c = old;                                        \
+       c != (u);                                               \
+})
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 #define atomic_dec_return(v) atomic_sub_return(1,(v))
 #define atomic_inc_return(v) atomic_add_return(1,(v))
 
index 6202eb8a14b75ac161db078b6566a15aad325ad0..2c87b41e69baa60019143bfed35550fc13fc6e2f 100644 (file)
@@ -287,6 +287,27 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
        return result;
 }
 
+#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
+
+/**
+ * atomic_add_unless - add unless the number is a given value
+ * @v: pointer of type atomic_t
+ * @a: the amount to add to v...
+ * @u: ...unless v is equal to u.
+ *
+ * Atomically adds @a to @v, so long as it was not @u.
+ * Returns non-zero if @v was not @u, and zero otherwise.
+ */
+#define atomic_add_unless(v, a, u)                             \
+({                                                             \
+       int c, old;                                             \
+       c = atomic_read(v);                                     \
+       while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+               c = old;                                        \
+       c != (u);                                               \
+})
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 #define atomic_dec_return(v) atomic_sub_return(1,(v))
 #define atomic_inc_return(v) atomic_add_return(1,(v))
 
index 048a2c7fd0c0a54530fdabb5350915652fa1e2c0..983e9a2b6042858b492d8dbde8b97b9d5f96b701 100644 (file)
@@ -164,6 +164,26 @@ static __inline__ int atomic_read(const atomic_t *v)
 }
 
 /* exported interface */
+#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
+
+/**
+ * atomic_add_unless - add unless the number is a given value
+ * @v: pointer of type atomic_t
+ * @a: the amount to add to v...
+ * @u: ...unless v is equal to u.
+ *
+ * Atomically adds @a to @v, so long as it was not @u.
+ * Returns non-zero if @v was not @u, and zero otherwise.
+ */
+#define atomic_add_unless(v, a, u)                             \
+({                                                             \
+       int c, old;                                             \
+       c = atomic_read(v);                                     \
+       while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+               c = old;                                        \
+       c != (u);                                               \
+})
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
 
 #define atomic_add(i,v)        ((void)(__atomic_add_return( ((int)i),(v))))
 #define atomic_sub(i,v)        ((void)(__atomic_add_return(-((int)i),(v))))
index 9c0b372a46e1ffb4f0160857ff0f21192f401692..ec4b14468959e295dc29ebbd0b212b6899597f70 100644 (file)
@@ -164,6 +164,33 @@ static __inline__ int atomic_dec_return(atomic_t *v)
        return t;
 }
 
+#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
+
+/**
+ * atomic_add_unless - add unless the number is a given value
+ * @v: pointer of type atomic_t
+ * @a: the amount to add to v...
+ * @u: ...unless v is equal to u.
+ *
+ * Atomically adds @a to @v, so long as it was not @u.
+ * Returns non-zero if @v was not @u, and zero otherwise.
+ */
+#define atomic_add_unless(v, a, u)                                                      \
+({                                                                                                                      \
+          int c, old;                                                                                   \
+          c = atomic_read(v);                                                                   \
+          for (;;) {                                                                                     \
+                          if (unlikely(c == (u)))                                               \
+                                          break;                                                                 \
+                          old = atomic_cmpxchg((v), c, c + (a));                 \
+                          if (likely(old == c))                                                   \
+                                          break;                                                                 \
+                          c = old;                                                                             \
+          }                                                                                                       \
+          c != (u);                                                                                       \
+})
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 #define atomic_sub_and_test(a, v)      (atomic_sub_return((a), (v)) == 0)
 #define atomic_dec_and_test(v)         (atomic_dec_return((v)) == 0)
 
index 50fb5e47094a169e26714857e90f909c280b7f9e..9383d0c13ff810a64c8f6c65b10f35097f9b8e95 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC85xx Internal Memory Map
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2004 Freescale Semiconductor, Inc
  *
index 9092b920997a6012151ddd3cb08f43e11616ac0f..0fe396a2b666aa7b3481828c00365adc0761e9ed 100644 (file)
@@ -3,7 +3,7 @@
  *
  * IPIC external definitions and structure.
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2005 Freescale Semiconductor, Inc
  *
index ce212201db2aeec7c7ea9d161d4f66228c79953d..7cdf60fa69b63a91baf01b3bec3348471ce9378d 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC83xx definitions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2005 Freescale Semiconductor, Inc
  *
index d98db980cd498cdfbdf424c471d166a4fd652eb1..9d14baea3d71000e0cebab13ed01fed743159b3e 100644 (file)
@@ -3,7 +3,7 @@
  *
  * MPC85xx definitions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2004 Freescale Semiconductor, Inc
  *
index bba5305c29ed72f6c9407be3373183f030ecd569..83d8c77c124df3e2bae74b046c0cfce1d797821f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * PPC system definitions and library functions
  *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2005 Freescale Semiconductor, Inc
  *
index 9d86ba6f12d004031b0338c2e1ffd9ccb5f1fae2..b3bd4f679f727d2c3bc24293d845e6f6166ff471 100644 (file)
@@ -198,6 +198,18 @@ atomic_compare_and_swap(int expected_oldval,int new_val,atomic_t *v)
         return retval;
 }
 
+#define atomic_cmpxchg(v, o, n) (atomic_compare_and_swap((o), (n), &((v)->counter)))
+
+#define atomic_add_unless(v, a, u)                             \
+({                                                             \
+       int c, old;                                             \
+       c = atomic_read(v);                                     \
+       while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+               c = old;                                        \
+       c != (u);                                               \
+})
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 #define smp_mb__before_atomic_dec()    smp_mb()
 #define smp_mb__after_atomic_dec()     smp_mb()
 #define smp_mb__before_atomic_inc()    smp_mb()
index 3c4f805da1ac929fd7e7d7bdcb562882a7847645..aabfd334462c178bbba76327a86a48a1efef70ab 100644 (file)
@@ -87,6 +87,35 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
 #define atomic_inc(v) atomic_add(1,(v))
 #define atomic_dec(v) atomic_sub(1,(v))
 
+static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
+{
+       int ret;
+       unsigned long flags;
+
+       local_irq_save(flags);
+       ret = v->counter;
+       if (likely(ret == old))
+               v->counter = new;
+       local_irq_restore(flags);
+
+       return ret;
+}
+
+static inline int atomic_add_unless(atomic_t *v, int a, int u)
+{
+       int ret;
+       unsigned long flags;
+
+       local_irq_save(flags);
+       ret = v->counter;
+       if (ret != u)
+               v->counter += a;
+       local_irq_restore(flags);
+
+       return ret != u;
+}
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 static __inline__ void atomic_clear_mask(unsigned int mask, atomic_t *v)
 {
        unsigned long flags;
index 8c3872d3e65f6f4e12ac10c3d2144ff14af7e22a..927a2bc27b3086140bea65c7345f49b2f97bd995 100644 (file)
@@ -99,6 +99,35 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
 #define atomic_inc(v) atomic_add(1,(v))
 #define atomic_dec(v) atomic_sub(1,(v))
 
+static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
+{
+       int ret;
+       unsigned long flags;
+
+       local_irq_save(flags);
+       ret = v->counter;
+       if (likely(ret == old))
+               v->counter = new;
+       local_irq_restore(flags);
+
+       return ret;
+}
+
+static inline int atomic_add_unless(atomic_t *v, int a, int u)
+{
+       int ret;
+       unsigned long flags;
+
+       local_irq_save(flags);
+       ret = v->counter;
+       if (ret != u)
+               v->counter += a;
+       local_irq_restore(flags);
+
+       return ret != u;
+}
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 static __inline__ void atomic_clear_mask(unsigned int mask, atomic_t *v)
 {
        unsigned long flags;
index 37f6ab601c3ddf846392e1ef8d732a778e10a55e..62bec7ad271c496e81a8f2d95d4f4377cb16c952 100644 (file)
@@ -19,6 +19,8 @@ typedef struct { volatile int counter; } atomic_t;
 #define ATOMIC_INIT(i)  { (i) }
 
 extern int __atomic_add_return(int, atomic_t *);
+extern int atomic_cmpxchg(atomic_t *, int, int);
+extern int atomic_add_unless(atomic_t *, int, int);
 extern void atomic_set(atomic_t *, int);
 
 #define atomic_read(v)          ((v)->counter)
@@ -48,6 +50,8 @@ extern void atomic_set(atomic_t *, int);
 #define atomic_dec_and_test(v) (atomic_dec_return(v) == 0)
 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
 
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 /* This is the old 24-bit implementation.  It's still used internally
  * by some sparc-specific code, notably the semaphore implementation.
  */
index e175afcf2cdeb852d712a40f51b87678dbb26521..8198c3d0d0074368b0d9fbba5d72969b403c4884 100644 (file)
@@ -70,6 +70,18 @@ extern int atomic64_sub_ret(int, atomic64_t *);
 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
 
+#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
+
+#define atomic_add_unless(v, a, u)                             \
+({                                                             \
+       int c, old;                                             \
+       c = atomic_read(v);                                     \
+       while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+               c = old;                                        \
+       c != (u);                                               \
+})
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 /* Atomic operations are already serializing */
 #ifdef CONFIG_SMP
 #define smp_mb__before_atomic_dec()    membar_storeload_loadload();
index 395268a8c0dec1787fca9f39d29eab8df1d51797..bede3172ce7f7e999e202fde6b04d31a6e281478 100644 (file)
@@ -90,6 +90,36 @@ static __inline__ void atomic_clear_mask (unsigned long mask, unsigned long *add
 #define atomic_dec_and_test(v)         (atomic_sub_return (1, (v)) == 0)
 #define atomic_add_negative(i,v)       (atomic_add_return ((i), (v)) < 0)
 
+static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
+{
+       int ret;
+       unsigned long flags;
+
+       local_irq_save(flags);
+       ret = v->counter;
+       if (likely(ret == old))
+               v->counter = new;
+       local_irq_restore(flags);
+
+       return ret;
+}
+
+static inline int atomic_add_unless(atomic_t *v, int a, int u)
+{
+       int ret;
+       unsigned long flags;
+
+       local_irq_save(flags);
+       ret = v->counter;
+       if (ret != u)
+               v->counter += a;
+       local_irq_restore(flags);
+
+       return ret != u;
+}
+
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 /* Atomic operations are already serializing on ARM */
 #define smp_mb__before_atomic_dec()    barrier()
 #define smp_mb__after_atomic_dec()     barrier()
index fc4c5956e1eaf82d76b4f1e1bc98de2b26bbfab3..0866ef67f198d8380a8241727ea21f0a16a19ec1 100644 (file)
@@ -360,6 +360,27 @@ static __inline__ int atomic_sub_return(int i, atomic_t *v)
        return atomic_add_return(-i,v);
 }
 
+#define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new))
+
+/**
+ * atomic_add_unless - add unless the number is a given value
+ * @v: pointer of type atomic_t
+ * @a: the amount to add to v...
+ * @u: ...unless v is equal to u.
+ *
+ * Atomically adds @a to @v, so long as it was not @u.
+ * Returns non-zero if @v was not @u, and zero otherwise.
+ */
+#define atomic_add_unless(v, a, u)                             \
+({                                                             \
+       int c, old;                                             \
+       c = atomic_read(v);                                     \
+       while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+               c = old;                                        \
+       c != (u);                                               \
+})
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
 #define atomic_inc_return(v)  (atomic_add_return(1,v))
 #define atomic_dec_return(v)  (atomic_sub_return(1,v))
 
index 68ac3c62fe3defd95145eb2bc80b7c2361c2e1d7..b837820c90733c51534d7eb100a160f19e251fe5 100644 (file)
@@ -129,9 +129,16 @@ static inline void set_tssldt_descriptor(void *ptr, unsigned long tss, unsigned
 
 static inline void set_tss_desc(unsigned cpu, void *addr)
 { 
-       set_tssldt_descriptor(&cpu_gdt_table[cpu][GDT_ENTRY_TSS], (unsigned long)addr, 
-                             DESC_TSS,
-                             sizeof(struct tss_struct) - 1);
+       /*
+        * sizeof(unsigned long) coming from an extra "long" at the end
+        * of the iobitmap. See tss_struct definition in processor.h
+        *
+        * -1? seg base+limit should be pointing to the address of the
+        * last valid byte
+        */
+       set_tssldt_descriptor(&cpu_gdt_table[cpu][GDT_ENTRY_TSS],
+               (unsigned long)addr, DESC_TSS,
+               IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1);
 } 
 
 static inline void set_ldt_desc(unsigned cpu, void *addr, int size)
index 12b5732dc6e5986ef4966ca87afe7f019745ef3e..3670cc7695dad79d3326323e8c974abf417851f6 100644 (file)
@@ -223,6 +223,26 @@ static inline int atomic_sub_return(int i, atomic_t * v)
  */
 #define atomic_add_negative(i,v) (atomic_add_return((i),(v)) < 0)
 
+#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
+
+/**
+ * atomic_add_unless - add unless the number is a given value
+ * @v: pointer of type atomic_t
+ * @a: the amount to add to v...
+ * @u: ...unless v is equal to u.
+ *
+ * Atomically adds @a to @v, so long as it was not @u.
+ * Returns non-zero if @v was not @u, and zero otherwise.
+ */
+#define atomic_add_unless(v, a, u)                             \
+({                                                             \
+       int c, old;                                             \
+       c = atomic_read(v);                                     \
+       while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+               c = old;                                        \
+       c != (u);                                               \
+})
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
 
 static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
 {
index 93c5b3cdf9519a34d73f6e4eec697b3b0836b395..9a66401073fc1b8ff8e90b2d70d020c032a9900e 100644 (file)
@@ -16,6 +16,8 @@
 #define _LINUX_ACCT_H
 
 #include <linux/types.h>
+#include <linux/jiffies.h>
+
 #include <asm/param.h>
 #include <asm/byteorder.h>
 
index 403d71dcb7c818beb2b43101af33d6133f6d5622..49fd37629ee475a64a7f82a84e74e5e1e204f9cc 100644 (file)
@@ -124,7 +124,7 @@ struct kiocb {
                (x)->ki_users = 1;                      \
                (x)->ki_key = KIOCB_SYNC_KEY;           \
                (x)->ki_filp = (filp);                  \
-               (x)->ki_ctx = &tsk->active_mm->default_kioctx;  \
+               (x)->ki_ctx = NULL;                     \
                (x)->ki_cancel = NULL;                  \
                (x)->ki_dtor = NULL;                    \
                (x)->ki_obj.tsk = tsk;                  \
@@ -210,8 +210,15 @@ struct kioctx *lookup_ioctx(unsigned long ctx_id);
 int FASTCALL(io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
                                  struct iocb *iocb));
 
-#define get_ioctx(kioctx)      do { if (unlikely(atomic_read(&(kioctx)->users) <= 0)) BUG(); atomic_inc(&(kioctx)->users); } while (0)
-#define put_ioctx(kioctx)      do { if (unlikely(atomic_dec_and_test(&(kioctx)->users))) __put_ioctx(kioctx); else if (unlikely(atomic_read(&(kioctx)->users) < 0)) BUG(); } while (0)
+#define get_ioctx(kioctx) do {                                         \
+       BUG_ON(unlikely(atomic_read(&(kioctx)->users) <= 0));           \
+       atomic_inc(&(kioctx)->users);                                   \
+} while (0)
+#define put_ioctx(kioctx) do {                                         \
+       BUG_ON(unlikely(atomic_read(&(kioctx)->users) <= 0));           \
+       if (unlikely(atomic_dec_and_test(&(kioctx)->users)))            \
+               __put_ioctx(kioctx);                                    \
+} while (0)
 
 #define in_aio() !is_sync_wait(current->io_wait)
 /* may be used for debugging */
index 025a7f084dbd82b2caf7a290736287bc3f012d37..a33a31e71bbc6cb02acf3409c926137c8664b882 100644 (file)
@@ -406,6 +406,7 @@ struct request_queue
 
        atomic_t                refcnt;
 
+       unsigned int            nr_sorted;
        unsigned int            in_flight;
 
        /*
@@ -631,6 +632,7 @@ static inline void elv_dispatch_add_tail(struct request_queue *q,
 {
        if (q->last_merge == rq)
                q->last_merge = NULL;
+       q->nr_sorted--;
 
        q->end_sector = rq_end_sector(rq);
        q->boundary_rq = rq;
diff --git a/include/linux/cm4000_cs.h b/include/linux/cm4000_cs.h
new file mode 100644 (file)
index 0000000..605ebe2
--- /dev/null
@@ -0,0 +1,66 @@
+#ifndef        _CM4000_H_
+#define        _CM4000_H_
+
+#define        MAX_ATR                 33
+
+#define        CM4000_MAX_DEV          4
+
+/* those two structures are passed via ioctl() from/to userspace.  They are
+ * used by existing userspace programs, so I kepth the awkward "bIFSD" naming
+ * not to break compilation of userspace apps. -HW */
+
+typedef struct atreq {
+       int32_t atr_len;
+       unsigned char atr[64];
+       int32_t power_act;
+       unsigned char bIFSD;
+       unsigned char bIFSC;
+} atreq_t;
+
+
+/* what is particularly stupid in the original driver is the arch-dependant
+ * member sizes. This leads to CONFIG_COMPAT breakage, since 32bit userspace
+ * will lay out the structure members differently than the 64bit kernel.
+ *
+ * I've changed "ptsreq.protocol" from "unsigned long" to "u_int32_t".
+ * On 32bit this will make no difference.  With 64bit kernels, it will make
+ * 32bit apps work, too.
+ */
+
+typedef struct ptsreq {
+       u_int32_t protocol; /*T=0: 2^0, T=1:  2^1*/
+       unsigned char flags;
+       unsigned char pts1;
+       unsigned char pts2;
+       unsigned char pts3;
+} ptsreq_t;
+
+#define        CM_IOC_MAGIC            'c'
+#define        CM_IOC_MAXNR            255
+
+#define        CM_IOCGSTATUS           _IOR (CM_IOC_MAGIC, 0, unsigned char *)
+#define        CM_IOCGATR              _IOWR(CM_IOC_MAGIC, 1, atreq_t *)
+#define        CM_IOCSPTS              _IOW (CM_IOC_MAGIC, 2, ptsreq_t *)
+#define        CM_IOCSRDR              _IO  (CM_IOC_MAGIC, 3)
+#define CM_IOCARDOFF            _IO  (CM_IOC_MAGIC, 4)
+
+#define CM_IOSDBGLVL            _IOW(CM_IOC_MAGIC, 250, int*)
+
+/* card and device states */
+#define        CM_CARD_INSERTED                0x01
+#define        CM_CARD_POWERED                 0x02
+#define        CM_ATR_PRESENT                  0x04
+#define        CM_ATR_VALID                    0x08
+#define        CM_STATE_VALID                  0x0f
+/* extra info only from CM4000 */
+#define        CM_NO_READER                    0x10
+#define        CM_BAD_CARD                     0x20
+
+
+#ifdef __KERNEL__
+
+#define        DEVICE_NAME             "cmm"
+#define        MODULE_NAME             "cm4000_cs"
+
+#endif /* __KERNEL__ */
+#endif /* _CM4000_H_ */
index 2209ad3499a3b4b9dd0be3a32451dd161e0765d5..174f3379e5d9a76b30affb43e2679c4ea55b5351 100644 (file)
@@ -259,6 +259,14 @@ COMPATIBLE_IOCTL(RTC_RD_TIME)
 COMPATIBLE_IOCTL(RTC_SET_TIME)
 COMPATIBLE_IOCTL(RTC_WKALM_SET)
 COMPATIBLE_IOCTL(RTC_WKALM_RD)
+/*
+ * These two are only for the sbus rtc driver, but
+ * hwclock tries them on every rtc device first when
+ * running on sparc.  On other architectures the entries
+ * are useless but harmless.
+ */
+COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */
+COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
 /* Little m */
 COMPATIBLE_IOCTL(MTIOCTOP)
 /* Socket level stuff */
index d3b1a15d5f21b378731bd2fca44edd2be5d3dc5d..418b6101b59a02d8b9efb7501e3de51808a59f95 100644 (file)
@@ -33,13 +33,13 @@ struct fdtable {
  * Open file table structure
  */
 struct files_struct {
-        atomic_t count;
-        spinlock_t file_lock;     /* Protects all the below members.  Nests inside tsk->alloc_lock */
+       atomic_t count;
        struct fdtable *fdt;
        struct fdtable fdtab;
-        fd_set close_on_exec_init;
-        fd_set open_fds_init;
-        struct file * fd_array[NR_OPEN_DEFAULT];
+       fd_set close_on_exec_init;
+       fd_set open_fds_init;
+       struct file * fd_array[NR_OPEN_DEFAULT];
+       spinlock_t file_lock;     /* Protects concurrent writers.  Nests inside tsk->alloc_lock */
 };
 
 #define files_fdtable(files) (rcu_dereference((files)->fdt))
index 8aac48c37f3db1c7ef6fa00383e1a41a987d44d2..53b129f07f6f294a896ce4bcc62133641f79d9ef 100644 (file)
@@ -31,7 +31,6 @@ struct font_desc {
 #define SUN12x22_IDX   7
 #define ACORN8x8_IDX   8
 #define        MINI4x6_IDX     9
-#define        RL_IDX  10
 
 extern const struct font_desc  font_vga_8x8,
                        font_vga_8x16,
@@ -42,7 +41,6 @@ extern const struct font_desc font_vga_8x8,
                        font_sun_8x16,
                        font_sun_12x22,
                        font_acorn_8x8,
-                       font_rl,
                        font_mini_4x6;
 
 /* Find a font with a specific name */
index 114d5d59f695bf952837620e4c26e1b024462ca7..934aa9bda481b29bb83ba045aba298c20f3825c6 100644 (file)
@@ -4,7 +4,7 @@
  * Definitions for any platform device related flags or structures for
  * Freescale processor devices
  *
- * Maintainer: Kumar Gala (kumar.gala@freescale.com)
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  *
  * Copyright 2004 Freescale Semiconductor, Inc
  *
index 8eeaa53a68c9fb2a669ac23d9e81abbe62815d37..eef5ccdcd7317942755af990969ca3c9c20030d2 100644 (file)
@@ -78,7 +78,7 @@ struct hd_struct {
        sector_t start_sect;
        sector_t nr_sects;
        struct kobject kobj;
-       unsigned ios[2], sectors[2];
+       unsigned ios[2], sectors[2];    /* READs and WRITEs */
        int policy, partno;
 };
 
@@ -89,7 +89,7 @@ struct hd_struct {
 #define GENHD_FL_SUPPRESS_PARTITION_INFO       32
 
 struct disk_stats {
-       unsigned sectors[2];
+       unsigned sectors[2];            /* READs and WRITEs */
        unsigned ios[2];
        unsigned merges[2];
        unsigned ticks[2];
index c3779432a7239b5e2b85494f594d69db3adb6fb8..23279d8f19b1a05cd5a09b9403bea9a17ed8baca 100644 (file)
@@ -39,8 +39,7 @@ struct vm_area_struct;
 #define __GFP_COMP     ((__force gfp_t)0x4000u)/* Add compound page metadata */
 #define __GFP_ZERO     ((__force gfp_t)0x8000u)/* Return zeroed page on success */
 #define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don't use emergency reserves */
-#define __GFP_NORECLAIM  ((__force gfp_t)0x20000u) /* No realy zone reclaim during allocation */
-#define __GFP_HARDWALL   ((__force gfp_t)0x40000u) /* Enforce hardwall cpuset memory allocs */
+#define __GFP_HARDWALL   ((__force gfp_t)0x20000u) /* Enforce hardwall cpuset memory allocs */
 
 #define __GFP_BITS_SHIFT 20    /* Room for 20 __GFP_FOO bits */
 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
@@ -49,7 +48,7 @@ struct vm_area_struct;
 #define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \
                        __GFP_COLD|__GFP_NOWARN|__GFP_REPEAT| \
                        __GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP| \
-                       __GFP_NOMEMALLOC|__GFP_NORECLAIM|__GFP_HARDWALL)
+                       __GFP_NOMEMALLOC|__GFP_HARDWALL)
 
 #define GFP_ATOMIC     (__GFP_HIGH)
 #define GFP_NOIO       (__GFP_WAIT)
index 5912874ca83c829494775fc479fed5ebb664cca3..71d2b8a723b9ad24529f1e8c5896e38cd6419a6b 100644 (file)
@@ -90,6 +90,8 @@ extern void synchronize_irq(unsigned int irq);
 #define nmi_enter()            irq_enter()
 #define nmi_exit()             sub_preempt_count(HARDIRQ_OFFSET)
 
+struct task_struct;
+
 #ifndef CONFIG_VIRT_CPU_ACCOUNTING
 static inline void account_user_vtime(struct task_struct *tsk)
 {
index 0cea162b08c0a4fc601a96f92fcb09d90dc8f946..1056717ee5013added4ea995fdfbbe202231a22b 100644 (file)
@@ -102,8 +102,8 @@ static inline unsigned long hugetlb_total_pages(void)
 #define hugetlb_fault(mm, vma, addr, write)    ({ BUG(); 0; })
 
 #ifndef HPAGE_MASK
-#define HPAGE_MASK     0               /* Keep the compiler happy */
-#define HPAGE_SIZE     0
+#define HPAGE_MASK     PAGE_MASK               /* Keep the compiler happy */
+#define HPAGE_SIZE     PAGE_SIZE
 #endif
 
 #endif /* !CONFIG_HUGETLB_PAGE */
index 68ab5f2ab9cdb35bd8249f03b7e3b5b0bc54e443..dcfd2ecccb5d63dbcb2718a2f3e827aef9d68a23 100644 (file)
@@ -51,7 +51,6 @@
        .page_table_lock =  SPIN_LOCK_UNLOCKED,                 \
        .mmlist         = LIST_HEAD_INIT(name.mmlist),          \
        .cpu_vm_mask    = CPU_MASK_ALL,                         \
-       .default_kioctx = INIT_KIOCTX(name.default_kioctx, name),       \
 }
 
 #define INIT_SIGNALS(sig) {    \
index 0a90205184b0b4511776604fd0b37a6fc0cf6bc1..41f150a3d2dda5a2445b100d55c87a904834ccd8 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/preempt.h>
 #include <linux/cpumask.h>
 #include <linux/hardirq.h>
+#include <linux/sched.h>
 #include <asm/atomic.h>
 #include <asm/ptrace.h>
 #include <asm/system.h>
index f5fa3082fd6a56c628730c67873429f64f8d9cbb..6cfb114a0c34444756bda25bdc362dd673585dd2 100644 (file)
@@ -329,7 +329,7 @@ void get_zone_counts(unsigned long *active, unsigned long *inactive,
 void build_all_zonelists(void);
 void wakeup_kswapd(struct zone *zone, int order);
 int zone_watermark_ok(struct zone *z, int order, unsigned long mark,
-               int alloc_type, int can_try_harder, gfp_t gfp_high);
+               int classzone_idx, int alloc_flags);
 
 #ifdef CONFIG_HAVE_MEMORY_PRESENT
 void memory_present(int nid, unsigned long start, unsigned long end);
index ba6c310a055fa123c0169dfd47ecdbdd11dcfb19..ee700c6eb4427f5582438aaf9f861c134f626a41 100644 (file)
@@ -53,12 +53,12 @@ void release_pages(struct page **pages, int nr, int cold);
 
 static inline struct page *page_cache_alloc(struct address_space *x)
 {
-       return alloc_pages(mapping_gfp_mask(x)|__GFP_NORECLAIM, 0);
+       return alloc_pages(mapping_gfp_mask(x), 0);
 }
 
 static inline struct page *page_cache_alloc_cold(struct address_space *x)
 {
-       return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD|__GFP_NORECLAIM, 0);
+       return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD, 0);
 }
 
 typedef int filler_t(void *, struct page *);
index d00f8ba7f22bbd28b5c6a84ed58830e8a3cc8225..d4c1c8fd2925da655638664493a86d2c4b549f44 100644 (file)
 #define PCI_DEVICE_ID_APPLE_SH_SUNGEM   0x0051
 #define PCI_DEVICE_ID_APPLE_U3L_AGP    0x0058
 #define PCI_DEVICE_ID_APPLE_U3H_AGP    0x0059
+#define PCI_DEVICE_ID_APPLE_IPID2_AGP  0x0066
+#define PCI_DEVICE_ID_APPLE_IPID2_ATA  0x0069
+#define PCI_DEVICE_ID_APPLE_IPID2_FW   0x006a
+#define PCI_DEVICE_ID_APPLE_IPID2_GMAC 0x006b
 #define PCI_DEVICE_ID_APPLE_TIGON3     0x1645
 
 #define PCI_VENDOR_ID_YAMAHA           0x1073
index 5451eb1e781d37f67d29ab2e140bef34182fec8e..fb8d2d24e4bb1d855b4d6017202c6dca2882dfa1 100644 (file)
@@ -38,7 +38,7 @@ extern void free_percpu(const void *);
 
 #else /* CONFIG_SMP */
 
-#define per_cpu_ptr(ptr, cpu) (ptr)
+#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); })
 
 static inline void *__alloc_percpu(size_t size, size_t align)
 {
index 1514098d156d897ba02956517bc544f7626f5f87..5be87ba3b7ac2f92ebadbe0bf30076704a2f5fe6 100644 (file)
@@ -94,55 +94,6 @@ struct pm_dev
        struct list_head entry;
 };
 
-#ifdef CONFIG_PM
-
-extern int pm_active;
-
-#define PM_IS_ACTIVE() (pm_active != 0)
-
-/*
- * Register a device with power management
- */
-struct pm_dev __deprecated *
-pm_register(pm_dev_t type, unsigned long id, pm_callback callback);
-
-/*
- * Unregister a device with power management
- */
-void __deprecated pm_unregister(struct pm_dev *dev);
-
-/*
- * Unregister all devices with matching callback
- */
-void __deprecated pm_unregister_all(pm_callback callback);
-
-/*
- * Send a request to all devices
- */
-int __deprecated pm_send_all(pm_request_t rqst, void *data);
-
-#else /* CONFIG_PM */
-
-#define PM_IS_ACTIVE() 0
-
-static inline struct pm_dev *pm_register(pm_dev_t type,
-                                        unsigned long id,
-                                        pm_callback callback)
-{
-       return NULL;
-}
-
-static inline void pm_unregister(struct pm_dev *dev) {}
-
-static inline void pm_unregister_all(pm_callback callback) {}
-
-static inline int pm_send_all(pm_request_t rqst, void *data)
-{
-       return 0;
-}
-
-#endif /* CONFIG_PM */
-
 /* Functions above this comment are list-based old-style power
  * managment. Please avoid using them.  */
 
diff --git a/include/linux/pm_legacy.h b/include/linux/pm_legacy.h
new file mode 100644 (file)
index 0000000..1252b45
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef __LINUX_PM_LEGACY_H__
+#define __LINUX_PM_LEGACY_H__
+
+#include <linux/config.h>
+
+#ifdef CONFIG_PM_LEGACY
+
+extern int pm_active;
+
+#define PM_IS_ACTIVE() (pm_active != 0)
+
+/*
+ * Register a device with power management
+ */
+struct pm_dev __deprecated *
+pm_register(pm_dev_t type, unsigned long id, pm_callback callback);
+
+/*
+ * Unregister a device with power management
+ */
+void __deprecated pm_unregister(struct pm_dev *dev);
+
+/*
+ * Unregister all devices with matching callback
+ */
+void __deprecated pm_unregister_all(pm_callback callback);
+
+/*
+ * Send a request to all devices
+ */
+int __deprecated pm_send_all(pm_request_t rqst, void *data);
+
+#else /* CONFIG_PM_LEGACY */
+
+#define PM_IS_ACTIVE() 0
+
+static inline struct pm_dev *pm_register(pm_dev_t type,
+                                        unsigned long id,
+                                        pm_callback callback)
+{
+       return NULL;
+}
+
+static inline void pm_unregister(struct pm_dev *dev) {}
+
+static inline void pm_unregister_all(pm_callback callback) {}
+
+static inline int pm_send_all(pm_request_t rqst, void *data)
+{
+       return 0;
+}
+
+#endif /* CONFIG_PM_LEGACY */
+
+#endif /* __LINUX_PM_LEGACY_H__ */
+
index dd98c54a23b4b44afd860603f2a3da73bb29ecbc..d9a2f5254a51194858091bec44bf6bfb43cb9168 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/thread_info.h>
 #include <linux/linkage.h>
 
 #ifdef CONFIG_DEBUG_PREEMPT
index 2bbf968b23d9b62cdc58094f5799db09ecc51ff2..2038bd27b0413c74bcb66290adc3cfe33b5c0fd3 100644 (file)
@@ -357,7 +357,6 @@ struct mm_struct {
        /* aio bits */
        rwlock_t                ioctx_list_lock;
        struct kioctx           *ioctx_list;
-       struct kioctx           default_kioctx;
 };
 
 struct sighand_struct {
@@ -1233,32 +1232,49 @@ static inline void task_unlock(struct task_struct *p)
        spin_unlock(&p->alloc_lock);
 }
 
+#ifndef __HAVE_THREAD_FUNCTIONS
+
+#define task_thread_info(task) (task)->thread_info
+
+static inline void setup_thread_stack(struct task_struct *p, struct task_struct *org)
+{
+       *task_thread_info(p) = *task_thread_info(org);
+       task_thread_info(p)->task = p;
+}
+
+static inline unsigned long *end_of_stack(struct task_struct *p)
+{
+       return (unsigned long *)(p->thread_info + 1);
+}
+
+#endif
+
 /* set thread flags in other task's structures
  * - see asm/thread_info.h for TIF_xxxx flags available
  */
 static inline void set_tsk_thread_flag(struct task_struct *tsk, int flag)
 {
-       set_ti_thread_flag(tsk->thread_info,flag);
+       set_ti_thread_flag(task_thread_info(tsk), flag);
 }
 
 static inline void clear_tsk_thread_flag(struct task_struct *tsk, int flag)
 {
-       clear_ti_thread_flag(tsk->thread_info,flag);
+       clear_ti_thread_flag(task_thread_info(tsk), flag);
 }
 
 static inline int test_and_set_tsk_thread_flag(struct task_struct *tsk, int flag)
 {
-       return test_and_set_ti_thread_flag(tsk->thread_info,flag);
+       return test_and_set_ti_thread_flag(task_thread_info(tsk), flag);
 }
 
 static inline int test_and_clear_tsk_thread_flag(struct task_struct *tsk, int flag)
 {
-       return test_and_clear_ti_thread_flag(tsk->thread_info,flag);
+       return test_and_clear_ti_thread_flag(task_thread_info(tsk), flag);
 }
 
 static inline int test_tsk_thread_flag(struct task_struct *tsk, int flag)
 {
-       return test_ti_thread_flag(tsk->thread_info,flag);
+       return test_ti_thread_flag(task_thread_info(tsk), flag);
 }
 
 static inline void set_tsk_need_resched(struct task_struct *tsk)
@@ -1329,12 +1345,12 @@ extern void signal_wake_up(struct task_struct *t, int resume_stopped);
 
 static inline unsigned int task_cpu(const struct task_struct *p)
 {
-       return p->thread_info->cpu;
+       return task_thread_info(p)->cpu;
 }
 
 static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
 {
-       p->thread_info->cpu = cpu;
+       task_thread_info(p)->cpu = cpu;
 }
 
 #else
index b63ce70140931e4f07079f50447b08de8bd63fcd..fa1ff3b165fe167739099c19625282eaa5ecd2e7 100644 (file)
@@ -2,11 +2,10 @@
 #define __LINUX_SMPLOCK_H
 
 #include <linux/config.h>
+#ifdef CONFIG_LOCK_KERNEL
 #include <linux/sched.h>
 #include <linux/spinlock.h>
 
-#ifdef CONFIG_LOCK_KERNEL
-
 #define kernel_locked()                (current->lock_depth >= 0)
 
 extern int __lockfunc __reacquire_kernel_lock(void);
index d252f45a0f9b6747ceb1d1c9d3d75cfecab29b28..1c4eb41dbd89df9182c3fcdbf9f418c5958cc5c6 100644 (file)
@@ -27,31 +27,6 @@ extern long do_no_restart_syscall(struct restart_block *parm);
  * - pass TIF_xxxx constants to these functions
  */
 
-static inline void set_thread_flag(int flag)
-{
-       set_bit(flag,&current_thread_info()->flags);
-}
-
-static inline void clear_thread_flag(int flag)
-{
-       clear_bit(flag,&current_thread_info()->flags);
-}
-
-static inline int test_and_set_thread_flag(int flag)
-{
-       return test_and_set_bit(flag,&current_thread_info()->flags);
-}
-
-static inline int test_and_clear_thread_flag(int flag)
-{
-       return test_and_clear_bit(flag,&current_thread_info()->flags);
-}
-
-static inline int test_thread_flag(int flag)
-{
-       return test_bit(flag,&current_thread_info()->flags);
-}
-
 static inline void set_ti_thread_flag(struct thread_info *ti, int flag)
 {
        set_bit(flag,&ti->flags);
@@ -77,15 +52,19 @@ static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
        return test_bit(flag,&ti->flags);
 }
 
-static inline void set_need_resched(void)
-{
-       set_thread_flag(TIF_NEED_RESCHED);
-}
-
-static inline void clear_need_resched(void)
-{
-       clear_thread_flag(TIF_NEED_RESCHED);
-}
+#define set_thread_flag(flag) \
+       set_ti_thread_flag(current_thread_info(), flag)
+#define clear_thread_flag(flag) \
+       clear_ti_thread_flag(current_thread_info(), flag)
+#define test_and_set_thread_flag(flag) \
+       test_and_set_ti_thread_flag(current_thread_info(), flag)
+#define test_and_clear_thread_flag(flag) \
+       test_and_clear_ti_thread_flag(current_thread_info(), flag)
+#define test_thread_flag(flag) \
+       test_ti_thread_flag(current_thread_info(), flag)
+
+#define set_need_resched()     set_thread_flag(TIF_NEED_RESCHED)
+#define clear_need_resched()   clear_thread_flag(TIF_NEED_RESCHED)
 
 #endif
 
index 8e83f4e778bb11657f2363cf82eb491562615439..bfbe92d0767c62a61f09db17b5b59cb8e4a080a6 100644 (file)
@@ -101,7 +101,7 @@ extern struct timespec timespec_trunc(struct timespec t, unsigned gran);
 static inline void
 set_normalized_timespec (struct timespec *ts, time_t sec, long nsec)
 {
-       while (nsec > NSEC_PER_SEC) {
+       while (nsec >= NSEC_PER_SEC) {
                nsec -= NSEC_PER_SEC;
                ++sec;
        }
index 748d04385256dc1063249bd282267b55834bb6e7..856d232c756235bcf66ce5d20d0609914d5d5cfd 100644 (file)
@@ -819,7 +819,7 @@ typedef void (*usb_complete_t)(struct urb *, struct pt_regs *);
  */
 struct urb
 {
-       /* private, usb core and host controller only fields in the urb */
+       /* private: usb core and host controller only fields in the urb */
        struct kref kref;               /* reference count of the URB */
        spinlock_t lock;                /* lock for the URB */
        void *hcpriv;                   /* private data for host controller */
@@ -827,7 +827,7 @@ struct urb
        atomic_t use_count;             /* concurrent submissions counter */
        u8 reject;                      /* submissions will fail */
 
-       /* public, documented fields in the urb that can be used by drivers */
+       /* public: documented fields in the urb that can be used by drivers */
        struct list_head urb_list;      /* list head for use by the urb's
                                         * current owner */
        struct usb_device *dev;         /* (in) pointer to associated device */
@@ -1045,7 +1045,7 @@ struct usb_sg_request {
        size_t                  bytes;
 
        /* 
-        * members below are private to usbcore,
+        * members below are private: to usbcore,
         * and are not provided for driver access!
         */
        spinlock_t              lock;
index a114fff6568b18d303dd28d579fe591033c5f9c8..1cded681eb6d2a1041270441f99dd4473e7c6c96 100644 (file)
@@ -636,6 +636,7 @@ typedef __u64 v4l2_std_id;
 #define V4L2_STD_SECAM_K        ((v4l2_std_id)0x00100000)
 #define V4L2_STD_SECAM_K1       ((v4l2_std_id)0x00200000)
 #define V4L2_STD_SECAM_L        ((v4l2_std_id)0x00400000)
+#define V4L2_STD_SECAM_LC       ((v4l2_std_id)0x00800000)
 
 /* ATSC/HDTV */
 #define V4L2_STD_ATSC_8_VSB     ((v4l2_std_id)0x01000000)
index 0f1ba95ec8d654ad2102ff0b08ef934a4c59197f..ad3e9bb670c3eb93c58e5707cd0052f35c316b6a 100644 (file)
@@ -49,6 +49,7 @@ struct ir_input_state {
 
 extern IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE];
 extern IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE];
+extern IR_KEYTAB_TYPE ir_codes_pinnacle[IR_KEYTAB_SIZE];
 extern IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE];
 extern IR_KEYTAB_TYPE ir_codes_hauppauge_new[IR_KEYTAB_SIZE];
 extern IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE];
index 00fa57eb9fde928fc04d440ae39cdde2205266ee..730f21ed91db18aa28b705147da6e377c517ac14 100644 (file)
@@ -19,4 +19,6 @@ struct IR_i2c {
        char                   phys[32];
        int                    (*get_key)(struct IR_i2c*, u32*, u32*);
 };
+
+int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw);
 #endif
index 9184e534b7efce2a31253a09e4913a31394943d2..faa0f8e3091bf623f97939d69a61efbdc5e5d466 100644 (file)
 #define TUNER_PHILIPS_TD1316           67
 
 #define TUNER_PHILIPS_TUV1236D         68      /* ATI HDTV Wonder */
+#define TUNER_TNF_5335MF                69     /* Sabrent Bt848   */
 
 #define NOTUNER 0
 #define PAL     1      /* PAL_BG */
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
new file mode 100644 (file)
index 0000000..d3fd481
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+    v4l2 common internal API header
+
+    This header contains internal shared ioctl definitions for use by the
+    internal low-level v4l2 drivers.
+    Each ioctl begins with VIDIOC_INT_ to clearly mark that it is an internal
+    define,
+
+    Copyright (C) 2005  Hans Verkuil <hverkuil@xs4all.nl>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef V4L2_COMMON_H_
+#define V4L2_COMMON_H_
+
+/* VIDIOC_INT_AUDIO_CLOCK_FREQ */
+enum v4l2_audio_clock_freq {
+       V4L2_AUDCLK_32_KHZ  = 32000,
+       V4L2_AUDCLK_441_KHZ = 44100,
+       V4L2_AUDCLK_48_KHZ  = 48000,
+};
+
+/* VIDIOC_INT_G_REGISTER and VIDIOC_INT_S_REGISTER */
+struct v4l2_register {
+       u32 i2c_id;             /* I2C driver ID of the I2C chip. 0 for the I2C adapter. */
+       unsigned long reg;
+       u32 val;
+};
+
+/* VIDIOC_INT_DECODE_VBI_LINE */
+struct v4l2_decode_vbi_line {
+       u32 is_second_field;    /* Set to 0 for the first (odd) field,
+                                  set to 1 for the second (even) field. */
+       u8 *p;                  /* Pointer to the sliced VBI data from the decoder.
+                                  On exit points to the start of the payload. */
+       u32 line;               /* Line number of the sliced VBI data (1-23) */
+       u32 type;               /* VBI service type (V4L2_SLICED_*). 0 if no service found */
+};
+
+/* VIDIOC_INT_G_CHIP_IDENT: identifies the actual chip installed on the board */
+enum v4l2_chip_ident {
+       /* general idents: reserved range 0-49 */
+       V4L2_IDENT_UNKNOWN = 0,
+
+       /* module saa7115: reserved range 100-149 */
+       V4L2_IDENT_SAA7114 = 104,
+       V4L2_IDENT_SAA7115 = 105,
+
+       /* module saa7127: reserved range 150-199 */
+       V4L2_IDENT_SAA7127 = 157,
+       V4L2_IDENT_SAA7129 = 159,
+
+       /* module cx25840: reserved range 200-249 */
+       V4L2_IDENT_CX25840 = 240,
+       V4L2_IDENT_CX25841 = 241,
+       V4L2_IDENT_CX25842 = 242,
+       V4L2_IDENT_CX25843 = 243,
+};
+
+/* only implemented if CONFIG_VIDEO_ADV_DEBUG is defined */
+#define        VIDIOC_INT_S_REGISTER           _IOR ('d', 100, struct v4l2_register)
+#define        VIDIOC_INT_G_REGISTER           _IOWR('d', 101, struct v4l2_register)
+
+/* Reset the I2C chip */
+#define VIDIOC_INT_RESET               _IO  ('d', 102)
+
+/* Set the frequency of the audio clock output.
+   Used to slave an audio processor to the video decoder, ensuring that audio
+   and video remain synchronized. */
+#define VIDIOC_INT_AUDIO_CLOCK_FREQ    _IOR ('d', 103, enum v4l2_audio_clock_freq)
+
+/* Video decoders that support sliced VBI need to implement this ioctl.
+   Field p of the v4l2_sliced_vbi_line struct is set to the start of the VBI
+   data that was generated by the decoder. The driver then parses the sliced
+   VBI data and sets the other fields in the struct accordingly. The pointer p
+   is updated to point to the start of the payload which can be copied
+   verbatim into the data field of the v4l2_sliced_vbi_data struct. If no
+   valid VBI data was found, then the type field is set to 0 on return. */
+#define VIDIOC_INT_DECODE_VBI_LINE     _IOWR('d', 104, struct v4l2_decode_vbi_line)
+
+/* Used to generate VBI signals on a video signal. v4l2_sliced_vbi_data is
+   filled with the data packets that should be output. Note that if you set
+   the line field to 0, then that VBI signal is disabled. */
+#define VIDIOC_INT_S_VBI_DATA          _IOW ('d', 105, struct v4l2_sliced_vbi_data)
+
+/* Used to obtain the sliced VBI packet from a readback register. Not all
+   video decoders support this. If no data is available because the readback
+   register contains invalid or erroneous data -EIO is returned. Note that
+   you must fill in the 'id' member and the 'field' member (to determine
+   whether CC data from the first or second field should be obtained). */
+#define VIDIOC_INT_G_VBI_DATA          _IOWR('d', 106, struct v4l2_sliced_vbi_data *)
+
+/* Returns the chip identifier or V4L2_IDENT_UNKNOWN if no identification can
+   be made. */
+#define VIDIOC_INT_G_CHIP_IDENT                _IOR ('d', 107, enum v4l2_chip_ident *)
+
+#endif /* V4L2_COMMON_H_ */
index 5a737ed9dac79d8cf2fe184e6a79574680afa01b..7430640f9816dcf7e82c9aad6b445f6678e9be1f 100644 (file)
@@ -1809,11 +1809,12 @@ int cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
        if (gfp_mask & __GFP_HARDWALL)  /* If hardwall request, stop here */
                return 0;
 
+       if (current->flags & PF_EXITING) /* Let dying task have memory */
+               return 1;
+
        /* Not hardwall and node outside mems_allowed: scan up cpusets */
        down(&callback_sem);
 
-       if (current->flags & PF_EXITING) /* Let dying task have memory */
-               return 1;
        task_lock(current);
        cs = nearest_exclusive_ancestor(current->cpuset);
        task_unlock(current);
index 452a1d1161782130204c934542aa2cb7f5f44b25..ee515683b92db35decaaeea608d9be919bb73f33 100644 (file)
@@ -859,7 +859,7 @@ fastcall NORET_TYPE void do_exit(long code)
        if (group_dead && tsk->signal->leader)
                disassociate_ctty(1);
 
-       module_put(tsk->thread_info->exec_domain->module);
+       module_put(task_thread_info(tsk)->exec_domain->module);
        if (tsk->binfmt)
                module_put(tsk->binfmt->module);
 
index 158710d22566006a36e6fbfb2583641eea24369e..e0d0b77343f880b60d8551338c26e05420c47291 100644 (file)
@@ -171,10 +171,9 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
                return NULL;
        }
 
-       *ti = *orig->thread_info;
        *tsk = *orig;
        tsk->thread_info = ti;
-       ti->task = tsk;
+       setup_thread_stack(tsk, orig);
 
        /* One for us, one for whoever does the "release_task()" (usually parent) */
        atomic_set(&tsk->usage,2);
@@ -324,7 +323,6 @@ static struct mm_struct * mm_init(struct mm_struct * mm)
        spin_lock_init(&mm->page_table_lock);
        rwlock_init(&mm->ioctx_list_lock);
        mm->ioctx_list = NULL;
-       mm->default_kioctx = (struct kioctx)INIT_KIOCTX(mm->default_kioctx, *mm);
        mm->free_area_cache = TASK_UNMAPPED_BASE;
        mm->cached_hole_size = ~0UL;
 
@@ -919,7 +917,7 @@ static task_t *copy_process(unsigned long clone_flags,
        if (nr_threads >= max_threads)
                goto bad_fork_cleanup_count;
 
-       if (!try_module_get(p->thread_info->exec_domain->module))
+       if (!try_module_get(task_thread_info(p)->exec_domain->module))
                goto bad_fork_cleanup_count;
 
        if (p->binfmt && !try_module_get(p->binfmt->module))
@@ -1180,7 +1178,7 @@ bad_fork_cleanup:
        if (p->binfmt)
                module_put(p->binfmt->module);
 bad_fork_cleanup_put_domain:
-       module_put(p->thread_info->exec_domain->module);
+       module_put(task_thread_info(p)->exec_domain->module);
 bad_fork_cleanup_count:
        put_group_info(p->group_info);
        atomic_dec(&p->user->processes);
index ea55c7a1cd75a3dbaa50040b3d55255c12a5786f..5870efb3e2007e70ae577c76f4d71e71245914f2 100644 (file)
@@ -270,7 +270,7 @@ static void tstojiffie(struct timespec *tp, int res, u64 *jiff)
        long sec = tp->tv_sec;
        long nsec = tp->tv_nsec + res - 1;
 
-       if (nsec > NSEC_PER_SEC) {
+       if (nsec >= NSEC_PER_SEC) {
                sec++;
                nsec -= NSEC_PER_SEC;
        }
@@ -1209,13 +1209,9 @@ static int do_posix_clock_monotonic_get(clockid_t clock, struct timespec *tp)
 
        do_posix_clock_monotonic_gettime_parts(tp, &wall_to_mono);
 
-       tp->tv_sec += wall_to_mono.tv_sec;
-       tp->tv_nsec += wall_to_mono.tv_nsec;
+       set_normalized_timespec(tp, tp->tv_sec + wall_to_mono.tv_sec,
+                               tp->tv_nsec + wall_to_mono.tv_nsec);
 
-       if ((tp->tv_nsec - NSEC_PER_SEC) > 0) {
-               tp->tv_nsec -= NSEC_PER_SEC;
-               tp->tv_sec++;
-       }
        return 0;
 }
 
index 46a5e5acff97aaa86b4d3429e33fe07ca03d7bf4..5ec248cb7f4aff47261b9425c606e473e3548c74 100644 (file)
@@ -19,6 +19,15 @@ config PM
          will issue the hlt instruction if nothing is to be done, thereby
          sending the processor to sleep and saving power.
 
+config PM_LEGACY
+       bool "Legacy Power Management API"
+       depends on PM
+       default y
+       ---help---
+          Support for pm_register() and friends.
+
+          If unsure, say Y.
+
 config PM_DEBUG
        bool "Power Management Debug Support"
        depends on PM
index c71eb4579c079040265dced9de7e97a82d7c27f3..04be7d0d96a7d6ecaad42f031685b66715e0e3ff 100644 (file)
@@ -3,7 +3,8 @@ ifeq ($(CONFIG_PM_DEBUG),y)
 EXTRA_CFLAGS   +=      -DDEBUG
 endif
 
-obj-y                          := main.o process.o console.o pm.o
+obj-y                          := main.o process.o console.o
+obj-$(CONFIG_PM_LEGACY)                += pm.o
 obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o disk.o snapshot.o
 
 obj-$(CONFIG_SUSPEND_SMP)      += smp.o
index 159149321b3c2adb4dcf20372ada8edb2a098c7a..33c508e857dd1a68607c553e30ddc7c3be3cd3ae 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/pm.h>
+#include <linux/pm_legacy.h>
 #include <linux/interrupt.h>
 
 int pm_active;
index e9be027bc9300d03322a7ecf5681bdb2dec69f4b..ac8a08f3620786f266374d321312629c73e6ac01 100644 (file)
@@ -491,7 +491,10 @@ __attribute__((weak)) unsigned long long printk_clock(void)
        return sched_clock();
 }
 
-/*
+/**
+ * printk - print a kernel message
+ * @fmt: format string
+ *
  * This is printk.  It can be called from any context.  We want it to work.
  *
  * We try to grab the console_sem.  If we succeed, it's easy - we log the output and
@@ -503,6 +506,9 @@ __attribute__((weak)) unsigned long long printk_clock(void)
  * One effect of this deferred printing is that code which calls printk() and
  * then changes console_loglevel may break. This is because console_loglevel
  * is inspected when the actual printing occurs.
+ *
+ * See also:
+ * printf(3)
  */
 
 asmlinkage int printk(const char *fmt, ...)
@@ -655,6 +661,9 @@ static void call_console_drivers(unsigned long start, unsigned long end)
 
 /**
  * add_preferred_console - add a device to the list of preferred consoles.
+ * @name: device name
+ * @idx: device index
+ * @options: options for this console
  *
  * The last preferred console added will be used for kernel messages
  * and stdin/out/err for init.  Normally this is used by console_setup
@@ -764,7 +773,8 @@ void release_console_sem(void)
 }
 EXPORT_SYMBOL(release_console_sem);
 
-/** console_conditional_schedule - yield the CPU if required
+/**
+ * console_conditional_schedule - yield the CPU if required
  *
  * If the console code is currently allowed to sleep, and
  * if this CPU should yield the CPU to another task, do
@@ -976,6 +986,8 @@ EXPORT_SYMBOL(unregister_console);
 
 /**
  * tty_write_message - write a message to a certain tty, not just the console.
+ * @tty: the destination tty_struct
+ * @msg: the message to write
  *
  * This is used for messages that need to be redirected to a specific tty.
  * We don't put it into the syslog queue right now maybe in the future if
index b88d4186cd7ac2733c3adf231d5b4daa4e14b0a9..17ee7e5a34516f7485250b7a7ef94546907f9b39 100644 (file)
@@ -470,7 +470,7 @@ asmlinkage long sys_ptrace(long request, long pid, long addr, long data)
 
        if (request == PTRACE_ATTACH) {
                ret = ptrace_attach(child);
-               goto out;
+               goto out_put_task_struct;
        }
 
        ret = ptrace_check_attach(child, request == PTRACE_KILL);
index 9b58f1eff3ca8990d29f4e4f9b9ad52a621babd4..eb6719c50b4e0deb4546e7479a42bb82a9db90e4 100644 (file)
@@ -195,6 +195,8 @@ rcu_torture_writer(void *arg)
        static DEFINE_RCU_RANDOM(rand);
 
        VERBOSE_PRINTK_STRING("rcu_torture_writer task started");
+       set_user_nice(current, 19);
+
        do {
                schedule_timeout_uninterruptible(1);
                if (rcu_batches_completed() == oldbatch)
@@ -238,6 +240,8 @@ rcu_torture_reader(void *arg)
        int pipe_count;
 
        VERBOSE_PRINTK_STRING("rcu_torture_reader task started");
+       set_user_nice(current, 19);
+
        do {
                rcu_read_lock();
                completed = rcu_batches_completed();
index b6506671b2be08c8da0a5582800d3ec0fffc7280..6f46c94cc29ea4f46d79eb50b36da77208024df3 100644 (file)
@@ -1437,7 +1437,7 @@ void fastcall sched_fork(task_t *p, int clone_flags)
 #endif
 #ifdef CONFIG_PREEMPT
        /* Want to start with kernel preemption disabled. */
-       p->thread_info->preempt_count = 1;
+       task_thread_info(p)->preempt_count = 1;
 #endif
        /*
         * Share the timeslice between parent and child, thus the
@@ -4327,10 +4327,10 @@ static void show_task(task_t *p)
 #endif
 #ifdef CONFIG_DEBUG_STACK_USAGE
        {
-               unsigned long *n = (unsigned long *) (p->thread_info+1);
+               unsigned long *n = end_of_stack(p);
                while (!*n)
                        n++;
-               free = (unsigned long) n - (unsigned long)(p->thread_info+1);
+               free = (unsigned long)n - (unsigned long)end_of_stack(p);
        }
 #endif
        printk("%5lu %5d %6d ", free, p->pid, p->parent->pid);
@@ -4410,9 +4410,9 @@ void __devinit init_idle(task_t *idle, int cpu)
 
        /* Set the preempt count _outside_ the spinlocks! */
 #if defined(CONFIG_PREEMPT) && !defined(CONFIG_PREEMPT_BKL)
-       idle->thread_info->preempt_count = (idle->lock_depth >= 0);
+       task_thread_info(idle)->preempt_count = (idle->lock_depth >= 0);
 #else
-       idle->thread_info->preempt_count = 0;
+       task_thread_info(idle)->preempt_count = 0;
 #endif
 }
 
index 80789a59b4dbc6553a21b6f8075f803ad76fc5be..d7611f189ef7ac33ef7610e7a92a3584f5c7028b 100644 (file)
@@ -513,16 +513,7 @@ static int __dequeue_signal(struct sigpending *pending, sigset_t *mask,
 {
        int sig = 0;
 
-       /* SIGKILL must have priority, otherwise it is quite easy
-        * to create an unkillable process, sending sig < SIGKILL
-        * to self */
-       if (unlikely(sigismember(&pending->signal, SIGKILL))) {
-               if (!sigismember(mask, SIGKILL))
-                       sig = SIGKILL;
-       }
-
-       if (likely(!sig))
-               sig = next_signal(pending, mask);
+       sig = next_signal(pending, mask);
        if (sig) {
                if (current->notifier) {
                        if (sigismember(current->notifier_mask, sig)) {
index 84a9d18aa8da0ecb9309c6b58a2b8b694a1493e2..b3d4dc858e3540a521ee69c32a9eab1798a67a44 100644 (file)
@@ -119,13 +119,12 @@ static int stop_machine(void)
                return ret;
        }
 
-       /* Don't schedule us away at this point, please. */
-       local_irq_disable();
-
        /* Now they are all started, make them hold the CPUs, ready. */
+       preempt_disable();
        stopmachine_set_state(STOPMACHINE_PREPARE);
 
        /* Make them disable irqs. */
+       local_irq_disable();
        stopmachine_set_state(STOPMACHINE_DISABLE_IRQ);
 
        return 0;
@@ -135,6 +134,7 @@ static void restart_machine(void)
 {
        stopmachine_set_state(STOPMACHINE_EXIT);
        local_irq_enable();
+       preempt_enable_no_resched();
 }
 
 struct stop_machine_data
index 0f60baf6f69b36c0b0a5ddd65021be62c7150690..2998cfc12f5bc2c2a60d5ad6a724e953e7765e1b 100644 (file)
@@ -549,10 +549,10 @@ int copy_page_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,
        return 0;
 }
 
-static void zap_pte_range(struct mmu_gather *tlb,
+static unsigned long zap_pte_range(struct mmu_gather *tlb,
                                struct vm_area_struct *vma, pmd_t *pmd,
                                unsigned long addr, unsigned long end,
-                               struct zap_details *details)
+                               long *zap_work, struct zap_details *details)
 {
        struct mm_struct *mm = tlb->mm;
        pte_t *pte;
@@ -563,10 +563,15 @@ static void zap_pte_range(struct mmu_gather *tlb,
        pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
        do {
                pte_t ptent = *pte;
-               if (pte_none(ptent))
+               if (pte_none(ptent)) {
+                       (*zap_work)--;
                        continue;
+               }
                if (pte_present(ptent)) {
                        struct page *page = NULL;
+
+                       (*zap_work) -= PAGE_SIZE;
+
                        if (!(vma->vm_flags & VM_RESERVED)) {
                                unsigned long pfn = pte_pfn(ptent);
                                if (unlikely(!pfn_valid(pfn)))
@@ -624,16 +629,18 @@ static void zap_pte_range(struct mmu_gather *tlb,
                if (!pte_file(ptent))
                        free_swap_and_cache(pte_to_swp_entry(ptent));
                pte_clear_full(mm, addr, pte, tlb->fullmm);
-       } while (pte++, addr += PAGE_SIZE, addr != end);
+       } while (pte++, addr += PAGE_SIZE, (addr != end && *zap_work > 0));
 
        add_mm_rss(mm, file_rss, anon_rss);
        pte_unmap_unlock(pte - 1, ptl);
+
+       return addr;
 }
 
-static inline void zap_pmd_range(struct mmu_gather *tlb,
+static inline unsigned long zap_pmd_range(struct mmu_gather *tlb,
                                struct vm_area_struct *vma, pud_t *pud,
                                unsigned long addr, unsigned long end,
-                               struct zap_details *details)
+                               long *zap_work, struct zap_details *details)
 {
        pmd_t *pmd;
        unsigned long next;
@@ -641,16 +648,21 @@ static inline void zap_pmd_range(struct mmu_gather *tlb,
        pmd = pmd_offset(pud, addr);
        do {
                next = pmd_addr_end(addr, end);
-               if (pmd_none_or_clear_bad(pmd))
+               if (pmd_none_or_clear_bad(pmd)) {
+                       (*zap_work)--;
                        continue;
-               zap_pte_range(tlb, vma, pmd, addr, next, details);
-       } while (pmd++, addr = next, addr != end);
+               }
+               next = zap_pte_range(tlb, vma, pmd, addr, next,
+                                               zap_work, details);
+       } while (pmd++, addr = next, (addr != end && *zap_work > 0));
+
+       return addr;
 }
 
-static inline void zap_pud_range(struct mmu_gather *tlb,
+static inline unsigned long zap_pud_range(struct mmu_gather *tlb,
                                struct vm_area_struct *vma, pgd_t *pgd,
                                unsigned long addr, unsigned long end,
-                               struct zap_details *details)
+                               long *zap_work, struct zap_details *details)
 {
        pud_t *pud;
        unsigned long next;
@@ -658,15 +670,21 @@ static inline void zap_pud_range(struct mmu_gather *tlb,
        pud = pud_offset(pgd, addr);
        do {
                next = pud_addr_end(addr, end);
-               if (pud_none_or_clear_bad(pud))
+               if (pud_none_or_clear_bad(pud)) {
+                       (*zap_work)--;
                        continue;
-               zap_pmd_range(tlb, vma, pud, addr, next, details);
-       } while (pud++, addr = next, addr != end);
+               }
+               next = zap_pmd_range(tlb, vma, pud, addr, next,
+                                               zap_work, details);
+       } while (pud++, addr = next, (addr != end && *zap_work > 0));
+
+       return addr;
 }
 
-static void unmap_page_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
+static unsigned long unmap_page_range(struct mmu_gather *tlb,
+                               struct vm_area_struct *vma,
                                unsigned long addr, unsigned long end,
-                               struct zap_details *details)
+                               long *zap_work, struct zap_details *details)
 {
        pgd_t *pgd;
        unsigned long next;
@@ -679,11 +697,16 @@ static void unmap_page_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
        pgd = pgd_offset(vma->vm_mm, addr);
        do {
                next = pgd_addr_end(addr, end);
-               if (pgd_none_or_clear_bad(pgd))
+               if (pgd_none_or_clear_bad(pgd)) {
+                       (*zap_work)--;
                        continue;
-               zap_pud_range(tlb, vma, pgd, addr, next, details);
-       } while (pgd++, addr = next, addr != end);
+               }
+               next = zap_pud_range(tlb, vma, pgd, addr, next,
+                                               zap_work, details);
+       } while (pgd++, addr = next, (addr != end && *zap_work > 0));
        tlb_end_vma(tlb, vma);
+
+       return addr;
 }
 
 #ifdef CONFIG_PREEMPT
@@ -724,7 +747,7 @@ unsigned long unmap_vmas(struct mmu_gather **tlbp,
                unsigned long end_addr, unsigned long *nr_accounted,
                struct zap_details *details)
 {
-       unsigned long zap_bytes = ZAP_BLOCK_SIZE;
+       long zap_work = ZAP_BLOCK_SIZE;
        unsigned long tlb_start = 0;    /* For tlb_finish_mmu */
        int tlb_start_valid = 0;
        unsigned long start = start_addr;
@@ -745,27 +768,25 @@ unsigned long unmap_vmas(struct mmu_gather **tlbp,
                        *nr_accounted += (end - start) >> PAGE_SHIFT;
 
                while (start != end) {
-                       unsigned long block;
-
                        if (!tlb_start_valid) {
                                tlb_start = start;
                                tlb_start_valid = 1;
                        }
 
-                       if (is_vm_hugetlb_page(vma)) {
-                               block = end - start;
+                       if (unlikely(is_vm_hugetlb_page(vma))) {
                                unmap_hugepage_range(vma, start, end);
-                       } else {
-                               block = min(zap_bytes, end - start);
-                               unmap_page_range(*tlbp, vma, start,
-                                               start + block, details);
+                               zap_work -= (end - start) /
+                                               (HPAGE_SIZE / PAGE_SIZE);
+                               start = end;
+                       } else
+                               start = unmap_page_range(*tlbp, vma,
+                                               start, end, &zap_work, details);
+
+                       if (zap_work > 0) {
+                               BUG_ON(start != end);
+                               break;
                        }
 
-                       start += block;
-                       zap_bytes -= block;
-                       if ((long)zap_bytes > 0)
-                               continue;
-
                        tlb_finish_mmu(*tlbp, tlb_start, start);
 
                        if (need_resched() ||
@@ -779,7 +800,7 @@ unsigned long unmap_vmas(struct mmu_gather **tlbp,
 
                        *tlbp = tlb_gather_mmu(vma->vm_mm, fullmm);
                        tlb_start_valid = 0;
-                       zap_bytes = ZAP_BLOCK_SIZE;
+                       zap_work = ZAP_BLOCK_SIZE;
                }
        }
 out:
index 987225bdd661c33cffa0674e3fae7245a6b85a1f..3c5cf664abd2eca14d2613a57023dcfcac6b6fde 100644 (file)
@@ -732,9 +732,7 @@ buffered_rmqueue(struct zone *zone, int order, gfp_t gfp_flags)
                }
                local_irq_restore(flags);
                put_cpu();
-       }
-
-       if (page == NULL) {
+       } else {
                spin_lock_irqsave(&zone->lock, flags);
                page = __rmqueue(zone, order);
                spin_unlock_irqrestore(&zone->lock, flags);
@@ -754,20 +752,25 @@ buffered_rmqueue(struct zone *zone, int order, gfp_t gfp_flags)
        return page;
 }
 
+#define ALLOC_NO_WATERMARKS    0x01 /* don't check watermarks at all */
+#define ALLOC_HARDER           0x02 /* try to alloc harder */
+#define ALLOC_HIGH             0x04 /* __GFP_HIGH set */
+#define ALLOC_CPUSET           0x08 /* check for correct cpuset */
+
 /*
  * Return 1 if free pages are above 'mark'. This takes into account the order
  * of the allocation.
  */
 int zone_watermark_ok(struct zone *z, int order, unsigned long mark,
-                     int classzone_idx, int can_try_harder, gfp_t gfp_high)
+                     int classzone_idx, int alloc_flags)
 {
        /* free_pages my go negative - that's OK */
        long min = mark, free_pages = z->free_pages - (1 << order) + 1;
        int o;
 
-       if (gfp_high)
+       if (alloc_flags & ALLOC_HIGH)
                min -= min / 2;
-       if (can_try_harder)
+       if (alloc_flags & ALLOC_HARDER)
                min -= min / 4;
 
        if (free_pages <= min + z->lowmem_reserve[classzone_idx])
@@ -785,14 +788,40 @@ int zone_watermark_ok(struct zone *z, int order, unsigned long mark,
        return 1;
 }
 
-static inline int
-should_reclaim_zone(struct zone *z, gfp_t gfp_mask)
+/*
+ * get_page_from_freeliest goes through the zonelist trying to allocate
+ * a page.
+ */
+static struct page *
+get_page_from_freelist(gfp_t gfp_mask, unsigned int order,
+               struct zonelist *zonelist, int alloc_flags)
 {
-       if (!z->reclaim_pages)
-               return 0;
-       if (gfp_mask & __GFP_NORECLAIM)
-               return 0;
-       return 1;
+       struct zone **z = zonelist->zones;
+       struct page *page = NULL;
+       int classzone_idx = zone_idx(*z);
+
+       /*
+        * Go through the zonelist once, looking for a zone with enough free.
+        * See also cpuset_zone_allowed() comment in kernel/cpuset.c.
+        */
+       do {
+               if ((alloc_flags & ALLOC_CPUSET) &&
+                               !cpuset_zone_allowed(*z, gfp_mask))
+                       continue;
+
+               if (!(alloc_flags & ALLOC_NO_WATERMARKS)) {
+                       if (!zone_watermark_ok(*z, order, (*z)->pages_low,
+                                   classzone_idx, alloc_flags))
+                               continue;
+               }
+
+               page = buffered_rmqueue(*z, order, gfp_mask);
+               if (page) {
+                       zone_statistics(zonelist, *z);
+                       break;
+               }
+       } while (*(++z) != NULL);
+       return page;
 }
 
 /*
@@ -803,105 +832,75 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order,
                struct zonelist *zonelist)
 {
        const gfp_t wait = gfp_mask & __GFP_WAIT;
-       struct zone **zones, *z;
+       struct zone **z;
        struct page *page;
        struct reclaim_state reclaim_state;
        struct task_struct *p = current;
-       int i;
-       int classzone_idx;
        int do_retry;
-       int can_try_harder;
+       int alloc_flags;
        int did_some_progress;
 
        might_sleep_if(wait);
 
-       /*
-        * The caller may dip into page reserves a bit more if the caller
-        * cannot run direct reclaim, or is the caller has realtime scheduling
-        * policy
-        */
-       can_try_harder = (unlikely(rt_task(p)) && !in_interrupt()) || !wait;
+       z = zonelist->zones;  /* the list of zones suitable for gfp_mask */
 
-       zones = zonelist->zones;  /* the list of zones suitable for gfp_mask */
-
-       if (unlikely(zones[0] == NULL)) {
+       if (unlikely(*z == NULL)) {
                /* Should this ever happen?? */
                return NULL;
        }
+restart:
+       page = get_page_from_freelist(gfp_mask|__GFP_HARDWALL, order,
+                               zonelist, ALLOC_CPUSET);
+       if (page)
+               goto got_pg;
 
-       classzone_idx = zone_idx(zones[0]);
+       do
+               wakeup_kswapd(*z, order);
+       while (*(++z));
 
-restart:
        /*
-        * Go through the zonelist once, looking for a zone with enough free.
-        * See also cpuset_zone_allowed() comment in kernel/cpuset.c.
+        * OK, we're below the kswapd watermark and have kicked background
+        * reclaim. Now things get more complex, so set up alloc_flags according
+        * to how we want to proceed.
+        *
+        * The caller may dip into page reserves a bit more if the caller
+        * cannot run direct reclaim, or if the caller has realtime scheduling
+        * policy.
         */
-       for (i = 0; (z = zones[i]) != NULL; i++) {
-               int do_reclaim = should_reclaim_zone(z, gfp_mask);
-
-               if (!cpuset_zone_allowed(z, __GFP_HARDWALL))
-                       continue;
-
-               /*
-                * If the zone is to attempt early page reclaim then this loop
-                * will try to reclaim pages and check the watermark a second
-                * time before giving up and falling back to the next zone.
-                */
-zone_reclaim_retry:
-               if (!zone_watermark_ok(z, order, z->pages_low,
-                                      classzone_idx, 0, 0)) {
-                       if (!do_reclaim)
-                               continue;
-                       else {
-                               zone_reclaim(z, gfp_mask, order);
-                               /* Only try reclaim once */
-                               do_reclaim = 0;
-                               goto zone_reclaim_retry;
-                       }
-               }
-
-               page = buffered_rmqueue(z, order, gfp_mask);
-               if (page)
-                       goto got_pg;
-       }
-
-       for (i = 0; (z = zones[i]) != NULL; i++)
-               wakeup_kswapd(z, order);
+       alloc_flags = 0;
+       if ((unlikely(rt_task(p)) && !in_interrupt()) || !wait)
+               alloc_flags |= ALLOC_HARDER;
+       if (gfp_mask & __GFP_HIGH)
+               alloc_flags |= ALLOC_HIGH;
+       if (wait)
+               alloc_flags |= ALLOC_CPUSET;
 
        /*
         * Go through the zonelist again. Let __GFP_HIGH and allocations
-        * coming from realtime tasks to go deeper into reserves
+        * coming from realtime tasks go deeper into reserves.
         *
         * This is the last chance, in general, before the goto nopage.
         * Ignore cpuset if GFP_ATOMIC (!wait) rather than fail alloc.
         * See also cpuset_zone_allowed() comment in kernel/cpuset.c.
         */
-       for (i = 0; (z = zones[i]) != NULL; i++) {
-               if (!zone_watermark_ok(z, order, z->pages_min,
-                                      classzone_idx, can_try_harder,
-                                      gfp_mask & __GFP_HIGH))
-                       continue;
-
-               if (wait && !cpuset_zone_allowed(z, gfp_mask))
-                       continue;
-
-               page = buffered_rmqueue(z, order, gfp_mask);
-               if (page)
-                       goto got_pg;
-       }
+       page = get_page_from_freelist(gfp_mask, order, zonelist, alloc_flags);
+       if (page)
+               goto got_pg;
 
        /* This allocation should allow future memory freeing. */
 
        if (((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE)))
                        && !in_interrupt()) {
                if (!(gfp_mask & __GFP_NOMEMALLOC)) {
+nofail_alloc:
                        /* go through the zonelist yet again, ignoring mins */
-                       for (i = 0; (z = zones[i]) != NULL; i++) {
-                               if (!cpuset_zone_allowed(z, gfp_mask))
-                                       continue;
-                               page = buffered_rmqueue(z, order, gfp_mask);
-                               if (page)
-                                       goto got_pg;
+                       page = get_page_from_freelist(gfp_mask, order,
+                               zonelist, ALLOC_NO_WATERMARKS|ALLOC_CPUSET);
+                       if (page)
+                               goto got_pg;
+                       if (gfp_mask & __GFP_NOFAIL) {
+                               blk_congestion_wait(WRITE, HZ/50);
+                               goto nofail_alloc;
                        }
                }
                goto nopage;
@@ -919,7 +918,7 @@ rebalance:
        reclaim_state.reclaimed_slab = 0;
        p->reclaim_state = &reclaim_state;
 
-       did_some_progress = try_to_free_pages(zones, gfp_mask);
+       did_some_progress = try_to_free_pages(zonelist->zones, gfp_mask);
 
        p->reclaim_state = NULL;
        p->flags &= ~PF_MEMALLOC;
@@ -927,19 +926,10 @@ rebalance:
        cond_resched();
 
        if (likely(did_some_progress)) {
-               for (i = 0; (z = zones[i]) != NULL; i++) {
-                       if (!zone_watermark_ok(z, order, z->pages_min,
-                                              classzone_idx, can_try_harder,
-                                              gfp_mask & __GFP_HIGH))
-                               continue;
-
-                       if (!cpuset_zone_allowed(z, gfp_mask))
-                               continue;
-
-                       page = buffered_rmqueue(z, order, gfp_mask);
-                       if (page)
-                               goto got_pg;
-               }
+               page = get_page_from_freelist(gfp_mask, order,
+                                               zonelist, alloc_flags);
+               if (page)
+                       goto got_pg;
        } else if ((gfp_mask & __GFP_FS) && !(gfp_mask & __GFP_NORETRY)) {
                /*
                 * Go through the zonelist yet one more time, keep
@@ -947,18 +937,10 @@ rebalance:
                 * a parallel oom killing, we must fail if we're still
                 * under heavy pressure.
                 */
-               for (i = 0; (z = zones[i]) != NULL; i++) {
-                       if (!zone_watermark_ok(z, order, z->pages_high,
-                                              classzone_idx, 0, 0))
-                               continue;
-
-                       if (!cpuset_zone_allowed(z, __GFP_HARDWALL))
-                               continue;
-
-                       page = buffered_rmqueue(z, order, gfp_mask);
-                       if (page)
-                               goto got_pg;
-               }
+               page = get_page_from_freelist(gfp_mask|__GFP_HARDWALL, order,
+                                               zonelist, ALLOC_CPUSET);
+               if (page)
+                       goto got_pg;
 
                out_of_memory(gfp_mask, order);
                goto restart;
@@ -991,9 +973,7 @@ nopage:
                dump_stack();
                show_mem();
        }
-       return NULL;
 got_pg:
-       zone_statistics(zonelist, z);
        return page;
 }
 
@@ -2417,13 +2397,18 @@ void setup_per_zone_pages_min(void)
        }
 
        for_each_zone(zone) {
+               unsigned long tmp;
                spin_lock_irqsave(&zone->lru_lock, flags);
+               tmp = (pages_min * zone->present_pages) / lowmem_pages;
                if (is_highmem(zone)) {
                        /*
-                        * Often, highmem doesn't need to reserve any pages.
-                        * But the pages_min/low/high values are also used for
-                        * batching up page reclaim activity so we need a
-                        * decent value here.
+                        * __GFP_HIGH and PF_MEMALLOC allocations usually don't
+                        * need highmem pages, so cap pages_min to a small
+                        * value here.
+                        *
+                        * The (pages_high-pages_low) and (pages_low-pages_min)
+                        * deltas controls asynch page reclaim, and so should
+                        * not be capped for highmem.
                         */
                        int min_pages;
 
@@ -2434,19 +2419,15 @@ void setup_per_zone_pages_min(void)
                                min_pages = 128;
                        zone->pages_min = min_pages;
                } else {
-                       /* if it's a lowmem zone, reserve a number of pages
+                       /*
+                        * If it's a lowmem zone, reserve a number of pages
                         * proportionate to the zone's size.
                         */
-                       zone->pages_min = (pages_min * zone->present_pages) /
-                                          lowmem_pages;
+                       zone->pages_min = tmp;
                }
 
-               /*
-                * When interpreting these watermarks, just keep in mind that:
-                * zone->pages_min == (zone->pages_min * 4) / 4;
-                */
-               zone->pages_low   = (zone->pages_min * 5) / 4;
-               zone->pages_high  = (zone->pages_min * 6) / 4;
+               zone->pages_low   = zone->pages_min + tmp / 4;
+               zone->pages_high  = zone->pages_min + tmp / 2;
                spin_unlock_irqrestore(&zone->lru_lock, flags);
        }
 }
index 8a73dcfc6a2760f04a4d67c5cf40762b24f00515..e5ec26e0c4603c9ee19a7ea5878426ea2420cddd 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -565,14 +565,29 @@ static void **dbg_userword(kmem_cache_t *cachep, void *objp)
 #define        BREAK_GFP_ORDER_LO      0
 static int slab_break_gfp_order = BREAK_GFP_ORDER_LO;
 
-/* Macros for storing/retrieving the cachep and or slab from the
+/* Functions for storing/retrieving the cachep and or slab from the
  * global 'mem_map'. These are used to find the slab an obj belongs to.
  * With kfree(), these are used to find the cache which an obj belongs to.
  */
-#define        SET_PAGE_CACHE(pg,x)  ((pg)->lru.next = (struct list_head *)(x))
-#define        GET_PAGE_CACHE(pg)    ((kmem_cache_t *)(pg)->lru.next)
-#define        SET_PAGE_SLAB(pg,x)   ((pg)->lru.prev = (struct list_head *)(x))
-#define        GET_PAGE_SLAB(pg)     ((struct slab *)(pg)->lru.prev)
+static inline void page_set_cache(struct page *page, struct kmem_cache *cache)
+{
+       page->lru.next = (struct list_head *)cache;
+}
+
+static inline struct kmem_cache *page_get_cache(struct page *page)
+{
+       return (struct kmem_cache *)page->lru.next;
+}
+
+static inline void page_set_slab(struct page *page, struct slab *slab)
+{
+       page->lru.prev = (struct list_head *)slab;
+}
+
+static inline struct slab *page_get_slab(struct page *page)
+{
+       return (struct slab *)page->lru.prev;
+}
 
 /* These are the default caches for kmalloc. Custom caches can have other sizes. */
 struct cache_sizes malloc_sizes[] = {
@@ -1190,11 +1205,7 @@ static void *kmem_getpages(kmem_cache_t *cachep, gfp_t flags, int nodeid)
        int i;
 
        flags |= cachep->gfpflags;
-       if (likely(nodeid == -1)) {
-               page = alloc_pages(flags, cachep->gfporder);
-       } else {
-               page = alloc_pages_node(nodeid, flags, cachep->gfporder);
-       }
+       page = alloc_pages_node(nodeid, flags, cachep->gfporder);
        if (!page)
                return NULL;
        addr = page_address(page);
@@ -1368,7 +1379,7 @@ static void check_poison_obj(kmem_cache_t *cachep, void *objp)
                /* Print some data about the neighboring objects, if they
                 * exist:
                 */
-               struct slab *slabp = GET_PAGE_SLAB(virt_to_page(objp));
+               struct slab *slabp = page_get_slab(virt_to_page(objp));
                int objnr;
 
                objnr = (objp-slabp->s_mem)/cachep->objsize;
@@ -2138,8 +2149,8 @@ static void set_slab_attr(kmem_cache_t *cachep, struct slab *slabp, void *objp)
        i = 1 << cachep->gfporder;
        page = virt_to_page(objp);
        do {
-               SET_PAGE_CACHE(page, cachep);
-               SET_PAGE_SLAB(page, slabp);
+               page_set_cache(page, cachep);
+               page_set_slab(page, slabp);
                page++;
        } while (--i);
 }
@@ -2269,14 +2280,14 @@ static void *cache_free_debugcheck(kmem_cache_t *cachep, void *objp,
        kfree_debugcheck(objp);
        page = virt_to_page(objp);
 
-       if (GET_PAGE_CACHE(page) != cachep) {
+       if (page_get_cache(page) != cachep) {
                printk(KERN_ERR "mismatch in kmem_cache_free: expected cache %p, got %p\n",
-                               GET_PAGE_CACHE(page),cachep);
+                               page_get_cache(page),cachep);
                printk(KERN_ERR "%p is %s.\n", cachep, cachep->name);
-               printk(KERN_ERR "%p is %s.\n", GET_PAGE_CACHE(page), GET_PAGE_CACHE(page)->name);
+               printk(KERN_ERR "%p is %s.\n", page_get_cache(page), page_get_cache(page)->name);
                WARN_ON(1);
        }
-       slabp = GET_PAGE_SLAB(page);
+       slabp = page_get_slab(page);
 
        if (cachep->flags & SLAB_RED_ZONE) {
                if (*dbg_redzone1(cachep, objp) != RED_ACTIVE || *dbg_redzone2(cachep, objp) != RED_ACTIVE) {
@@ -2628,7 +2639,7 @@ static void free_block(kmem_cache_t *cachep, void **objpp, int nr_objects, int n
                struct slab *slabp;
                unsigned int objnr;
 
-               slabp = GET_PAGE_SLAB(virt_to_page(objp));
+               slabp = page_get_slab(virt_to_page(objp));
                l3 = cachep->nodelists[node];
                list_del(&slabp->list);
                objnr = (objp - slabp->s_mem) / cachep->objsize;
@@ -2744,7 +2755,7 @@ static inline void __cache_free(kmem_cache_t *cachep, void *objp)
 #ifdef CONFIG_NUMA
        {
                struct slab *slabp;
-               slabp = GET_PAGE_SLAB(virt_to_page(objp));
+               slabp = page_get_slab(virt_to_page(objp));
                if (unlikely(slabp->nodeid != numa_node_id())) {
                        struct array_cache *alien = NULL;
                        int nodeid = slabp->nodeid;
@@ -2830,7 +2841,7 @@ int fastcall kmem_ptr_validate(kmem_cache_t *cachep, void *ptr)
        page = virt_to_page(ptr);
        if (unlikely(!PageSlab(page)))
                goto out;
-       if (unlikely(GET_PAGE_CACHE(page) != cachep))
+       if (unlikely(page_get_cache(page) != cachep))
                goto out;
        return 1;
 out:
@@ -3026,7 +3037,7 @@ void kfree(const void *objp)
                return;
        local_irq_save(flags);
        kfree_debugcheck(objp);
-       c = GET_PAGE_CACHE(virt_to_page(objp));
+       c = page_get_cache(virt_to_page(objp));
        __cache_free(c, (void*)objp);
        local_irq_restore(flags);
 }
@@ -3596,7 +3607,7 @@ unsigned int ksize(const void *objp)
        if (unlikely(objp == NULL))
                return 0;
 
-       return obj_reallen(GET_PAGE_CACHE(virt_to_page(objp)));
+       return obj_reallen(page_get_cache(virt_to_page(objp)));
 }
 
 
index 135bf8ca96ee60ac78783caac94fa30f2bfabfc8..28130541270f5ad35b3e18ac878b349c61c6e01f 100644 (file)
@@ -1074,7 +1074,7 @@ loop_again:
                                        continue;
 
                                if (!zone_watermark_ok(zone, order,
-                                               zone->pages_high, 0, 0, 0)) {
+                                               zone->pages_high, 0, 0)) {
                                        end_zone = i;
                                        goto scan;
                                }
@@ -1111,7 +1111,7 @@ scan:
 
                        if (nr_pages == 0) {    /* Not software suspend */
                                if (!zone_watermark_ok(zone, order,
-                                               zone->pages_high, end_zone, 0, 0))
+                                               zone->pages_high, end_zone, 0))
                                        all_zones_ok = 0;
                        }
                        zone->temp_priority = priority;
@@ -1259,7 +1259,7 @@ void wakeup_kswapd(struct zone *zone, int order)
                return;
 
        pgdat = zone->zone_pgdat;
-       if (zone_watermark_ok(zone, order, zone->pages_low, 0, 0, 0))
+       if (zone_watermark_ok(zone, order, zone->pages_low, 0, 0))
                return;
        if (pgdat->kswapd_max_order < order)
                pgdat->kswapd_max_order = order;
index 468c6003b4c78c7715bdffd7cedffefc66bc0989..5b3f5220f2896cc965d809f1678847b1471e79f8 100644 (file)
@@ -814,6 +814,7 @@ static u8 tcp_valid_flags[(TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG) + 1] =
 {
        [TH_SYN]                        = 1,
        [TH_SYN|TH_ACK]                 = 1,
+       [TH_SYN|TH_PUSH]                = 1,
        [TH_SYN|TH_ACK|TH_PUSH]         = 1,
        [TH_RST]                        = 1,
        [TH_RST|TH_ACK]                 = 1,
index f7f42c3e96cb537f5cd885610d00972916e6e591..9a71a8d1078a248165378073058e47f2ff4ab1d6 100644 (file)
@@ -1701,10 +1701,8 @@ static void fib6_dump_end(struct netlink_callback *cb)
                fib6_walker_unlink(w);
                kfree(w);
        }
-       if (cb->args[1]) {
-               cb->done = (void*)cb->args[1];
-               cb->args[1] = 0;
-       }
+       cb->done = (void*)cb->args[1];
+       cb->args[1] = 0;
 }
 
 static int fib6_dump_done(struct netlink_callback *cb)
@@ -1734,7 +1732,7 @@ int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
                /*
                 * 2. allocate and initialize walker.
                 */
-               w = kmalloc(sizeof(*w), GFP_ATOMIC);
+               w = kmalloc(sizeof(*w), GFP_KERNEL);
                if (w == NULL)
                        return -ENOMEM;
                RT6_TRACE("dump<%p", w);
index 83d90dd624f05638fd0aac1e99e6583c4eeb69e2..156680ddb042e2f9fff86b5e862b1aac48c93aed 100644 (file)
@@ -779,6 +779,7 @@ static u8 tcp_valid_flags[(TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG) + 1] =
 {
        [TH_SYN]                        = 1,
        [TH_SYN|TH_ACK]                 = 1,
+       [TH_SYN|TH_PUSH]                = 1,
        [TH_SYN|TH_ACK|TH_PUSH]         = 1,
        [TH_RST]                        = 1,
        [TH_RST|TH_ACK]                 = 1,
index 8aaf74e64183ff46972acb0ac1d312aed4c16bfb..2f45fd2969d09080c37e3b1b150179714c886602 100755 (executable)
@@ -117,6 +117,8 @@ use strict;
 # struct my_struct {
 #     int a;
 #     int b;
+# /* private: */
+#     int c;
 # };
 #
 # All descriptions can be multiline, except the short function description.
@@ -1304,6 +1306,12 @@ sub dump_struct($$) {
        # ignore embedded structs or unions
        $members =~ s/{.*?}//g;
 
+       # ignore members marked private:
+       $members =~ s/\/\*.*?private:.*?public:.*?\*\///gos;
+       $members =~ s/\/\*.*?private:.*//gos;
+       # strip comments:
+       $members =~ s/\/\*.*?\*\///gos;
+
        create_parameterlist($members, ';', $file);
 
        output_declaration($declaration_name,
@@ -1329,6 +1337,7 @@ sub dump_enum($$) {
     my $x = shift;
     my $file = shift;
 
+    $x =~ s@/\*.*?\*/@@gos;    # strip comments.
     if ($x =~ /enum\s+(\w+)\s*{(.*)}/) {
         $declaration_name = $1;
         my $members = $2;
@@ -1365,6 +1374,7 @@ sub dump_typedef($$) {
     my $x = shift;
     my $file = shift;
 
+    $x =~ s@/\*.*?\*/@@gos;    # strip comments.
     while (($x =~ /\(*.\)\s*;$/) || ($x =~ /\[*.\]\s*;$/)) {
         $x =~ s/\(*.\)\s*;$/;/;
        $x =~ s/\[*.\]\s*;$/;/;
@@ -1420,7 +1430,7 @@ sub create_parameterlist($$$) {
            $type = $arg;
            $type =~ s/([^\(]+\(\*)$param/$1/;
            push_parameter($param, $type, $file);
-       } else {
+       } elsif ($arg) {
            $arg =~ s/\s*:\s*/:/g;
            $arg =~ s/\s*\[/\[/g;
 
@@ -1628,7 +1638,6 @@ sub process_state3_type($$) {
     my $x = shift;
     my $file = shift;
 
-    $x =~ s@/\*.*?\*/@@gos;    # strip comments.
     $x =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
     $x =~ s@^\s+@@gos; # strip leading spaces
     $x =~ s@\s+$@@gos; # strip trailing spaces
index 7c835abd99bc9ab2abc919b3cb8da9c48341004c..3f30c57676c18c816e2653245833c67214791839 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/module.h>
 #include <linux/stddef.h>
 #include <linux/pm.h>
+#include <linux/pm_legacy.h>
 #include <linux/isapnp.h>
 #include <linux/pnp.h>
 #include <linux/spinlock.h>
index d0d3963e1b83f1010d5b01496f10f6371de4f41a..adc689649fe1c06e5ce3d6fc568d4b523fd0741d 100644 (file)
@@ -298,6 +298,7 @@ struct cs4281_state {
        struct cs4281_pipeline pl[CS4281_NUMBER_OF_PIPELINES];
 };
 
+#include <linux/pm_legacy.h>
 #include "cs4281pm-24.c"
 
 #if CSDEBUG
index 3dce504e6d6d764ee330e47392238553e7fccf8a..3abd3541cbc724cd940a1ba4eedc76b799dc78a4 100644 (file)
 #include <asm/uaccess.h>
 
 #include <linux/pm.h>
+#include <linux/pm_legacy.h>
 static int maestro_pm_callback(struct pm_dev *dev, pm_request_t rqst, void *d);
 
 #include "maestro.h"
index 66970062eb363a3bd48493039d4e0f239525f798..0ce2c404a730782ca234eb5827aa2fa045003fce 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pm.h>
+#include <linux/pm_legacy.h>
 #include <linux/delay.h>
 #include <linux/spinlock.h>
 #include "sound_config.h"
index 2efbd865109bf350f7c1f1c8809ea70c20106ab0..cd41d0e4706a90721ee09982b1d50a3f66eeb819 100644 (file)
@@ -70,6 +70,7 @@
 #include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/pm.h>
+#include <linux/pm_legacy.h>
 #include "sound_config.h"
 
 #include "ad1848.h"
@@ -138,7 +139,7 @@ typedef struct {
        struct pnp_dev* pdev;
        int activated;                  /* Whether said devices have been activated */
 #endif
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_LEGACY
        unsigned int    in_suspend;
        struct pm_dev   *pmdev;
 #endif
@@ -341,7 +342,7 @@ static void opl3sa2_mixer_reset(opl3sa2_state_t* devc)
 }
 
 /* Currently only used for power management */
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_LEGACY
 static void opl3sa2_mixer_restore(opl3sa2_state_t* devc)
 {
        if (devc) {
@@ -354,7 +355,7 @@ static void opl3sa2_mixer_restore(opl3sa2_state_t* devc)
                }
        }
 }
-#endif
+#endif /* CONFIG_PM_LEGACY */
 
 static inline void arg_to_vol_mono(unsigned int vol, int* value)
 {
@@ -831,7 +832,8 @@ static struct pnp_driver opl3sa2_driver = {
 
 /* End of component functions */
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_LEGACY
+
 static DEFINE_SPINLOCK(opl3sa2_lock);
 
 /* Power Management support functions */
@@ -906,7 +908,7 @@ static int opl3sa2_pm_callback(struct pm_dev *pdev, pm_request_t rqst, void *dat
        }
        return 0;
 }
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM_LEGACY */
 
 /*
  * Install OPL3-SA2 based card(s).
@@ -1019,12 +1021,12 @@ static int __init init_opl3sa2(void)
 
                /* ewww =) */
                opl3sa2_state[card].card = card;
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_LEGACY
                /* register our power management capabilities */
                opl3sa2_state[card].pmdev = pm_register(PM_ISA_DEV, card, opl3sa2_pm_callback);
                if (opl3sa2_state[card].pmdev)
                        opl3sa2_state[card].pmdev->data = &opl3sa2_state[card];
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM_LEGACY */
 
                /*
                 * Set the Yamaha 3D enhancement mode (aka Ymersion) if asked to and
@@ -1081,7 +1083,7 @@ static void __exit cleanup_opl3sa2(void)
        int card;
 
        for(card = 0; card < opl3sa2_cards_num; card++) {
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_LEGACY
                if (opl3sa2_state[card].pmdev)
                        pm_unregister(opl3sa2_state[card].pmdev);
 #endif