Merge branch 'for-linus' of git://oss.sgi.com/xfs/xfs
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 18 Jan 2010 22:08:07 +0000 (14:08 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 18 Jan 2010 22:08:07 +0000 (14:08 -0800)
* 'for-linus' of git://oss.sgi.com/xfs/xfs:
  xfs: xfs_swap_extents needs to handle dynamic fork offsets
  xfs: fix missing error check in xfs_rtfree_range
  xfs: fix stale inode flush avoidance
  xfs: Remove inode iolock held check during allocation
  xfs: reclaim all inodes by background tree walks
  xfs: Avoid inodes in reclaim when flushing from inode cache
  xfs: reclaim inodes under a write lock

269 files changed:
Documentation/feature-removal-schedule.txt
MAINTAINERS
Makefile
arch/alpha/include/asm/topology.h
arch/arm/mach-davinci/include/mach/keyscan.h
arch/arm/mach-s3c2440/mach-mini2440.c
arch/arm/mach-s3c6410/mach-smdk6410.c
arch/arm/plat-s3c/dev-nand.c
arch/m68knommu/platform/coldfire/pit.c
arch/powerpc/boot/Makefile
arch/s390/include/asm/bug.h
arch/s390/include/asm/sigp.h
arch/s390/include/asm/thread_info.h
arch/s390/include/asm/unistd.h
arch/s390/kernel/compat_linux.c
arch/s390/kernel/compat_wrapper.S
arch/s390/kernel/process.c
arch/s390/kernel/ptrace.c
arch/s390/kernel/setup.c
arch/s390/kernel/signal.c
arch/s390/kernel/smp.c
arch/s390/kernel/syscalls.S
arch/s390/kernel/topology.c
arch/s390/lib/spinlock.c
arch/s390/mm/mmap.c
arch/sh/boards/mach-ecovec24/setup.c
arch/sh/tools/Makefile
arch/um/drivers/mconsole_kern.c
arch/x86/include/asm/mce.h
arch/x86/include/asm/uv/uv_hub.h
arch/x86/kernel/aperture_64.c
arch/x86/kernel/apic/x2apic_uv_x.c
arch/x86/kernel/dumpstack.c
arch/x86/kernel/process.c
arch/x86/xen/enlighten.c
drivers/base/memory.c
drivers/char/agp/amd64-agp.c
drivers/char/agp/intel-agp.c
drivers/char/hw_random/virtio-rng.c
drivers/edac/amd64_edac.c
drivers/edac/i5000_edac.c
drivers/gpu/drm/drm_crtc_helper.c
drivers/gpu/drm/i915/i915_dma.c
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_irq.c
drivers/gpu/drm/i915/i915_reg.h
drivers/gpu/drm/i915/intel_bios.c
drivers/gpu/drm/i915/intel_bios.h
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_hdmi.c
drivers/gpu/drm/i915/intel_lvds.c
drivers/gpu/drm/i915/intel_sdvo.c
drivers/gpu/drm/i915/intel_tv.c
drivers/gpu/drm/radeon/r600.c
drivers/gpu/drm/radeon/radeon_combios.c
drivers/gpu/drm/radeon/radeon_connectors.c
drivers/gpu/drm/radeon/radeon_legacy_encoders.c
drivers/gpu/drm/radeon/radeon_ttm.c
drivers/hid/hid-apple.c
drivers/hid/hid-core.c
drivers/hid/hid-ids.h
drivers/hid/hid-samsung.c
drivers/hid/hid-wacom.c
drivers/i2c/busses/i2c-ali1563.c
drivers/i2c/busses/i2c-pca-isa.c
drivers/i2c/busses/i2c-pca-platform.c
drivers/i2c/busses/i2c-piix4.c
drivers/i2c/busses/i2c-viapro.c
drivers/i2c/i2c-core.c
drivers/input/evdev.c
drivers/input/input.c
drivers/input/joystick/gf2k.c
drivers/input/joystick/xpad.c
drivers/input/keyboard/atkbd.c
drivers/input/keyboard/davinci_keyscan.c
drivers/input/mouse/bcm5974.c
drivers/input/mouse/psmouse-base.c
drivers/input/mouse/sentelic.c
drivers/input/mouse/synaptics.c
drivers/input/mouse/synaptics.h
drivers/input/serio/i8042-x86ia64io.h
drivers/media/IR/ir-keytable.c
drivers/media/common/tuners/tda8290.c
drivers/media/dvb/Kconfig
drivers/media/dvb/Makefile
drivers/media/dvb/frontends/Kconfig
drivers/media/dvb/frontends/Makefile
drivers/media/dvb/frontends/dib8000.h
drivers/media/dvb/frontends/lgdt3305.h
drivers/media/dvb/frontends/mb86a16.c [new file with mode: 0644]
drivers/media/dvb/frontends/mb86a16.h [new file with mode: 0644]
drivers/media/dvb/frontends/mb86a16_priv.h [new file with mode: 0644]
drivers/media/dvb/frontends/tda10021.c
drivers/media/dvb/frontends/tda665x.c [new file with mode: 0644]
drivers/media/dvb/frontends/tda665x.h [new file with mode: 0644]
drivers/media/dvb/mantis/Kconfig [new file with mode: 0644]
drivers/media/dvb/mantis/Makefile [new file with mode: 0644]
drivers/media/dvb/mantis/hopper_cards.c [new file with mode: 0644]
drivers/media/dvb/mantis/hopper_vp3028.c [new file with mode: 0644]
drivers/media/dvb/mantis/hopper_vp3028.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_ca.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_ca.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_cards.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_common.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_core.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_core.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_dma.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_dma.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_dvb.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_dvb.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_evm.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_hif.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_hif.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_i2c.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_i2c.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_input.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_ioc.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_ioc.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_link.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_pci.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_pci.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_pcmcia.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_reg.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_uart.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_uart.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_vp1033.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_vp1033.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_vp1034.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_vp1034.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_vp1041.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_vp1041.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_vp2033.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_vp2033.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_vp2040.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_vp2040.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_vp3028.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_vp3028.h [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_vp3030.c [new file with mode: 0644]
drivers/media/dvb/mantis/mantis_vp3030.h [new file with mode: 0644]
drivers/media/video/gspca/gspca.c
drivers/media/video/gspca/m5602/m5602_s5k4aa.c
drivers/media/video/gspca/ov534.c
drivers/media/video/gspca/sn9c20x.c
drivers/media/video/gspca/stv06xx/stv06xx_vv6410.h
drivers/media/video/gspca/sunplus.c
drivers/media/video/gspca/vc032x.c
drivers/media/video/mx1_camera.c
drivers/media/video/rj54n1cb0c.c
drivers/media/video/saa7134/saa7134-core.c
drivers/media/video/saa7134/saa7134-ts.c
drivers/media/video/sh_mobile_ceu_camera.c
drivers/media/video/uvc/uvc_ctrl.c
drivers/media/video/uvc/uvc_queue.c
drivers/media/video/uvc/uvc_video.c
drivers/media/video/uvc/uvcvideo.h
drivers/net/e1000e/e1000.h
drivers/net/e1000e/ich8lan.c
drivers/net/e1000e/phy.c
drivers/net/ixgbe/Makefile
drivers/net/ixgbe/ixgbe.h
drivers/net/ixgbe/ixgbe_82598.c
drivers/net/ixgbe/ixgbe_82599.c
drivers/net/ixgbe/ixgbe_common.c
drivers/net/ixgbe/ixgbe_common.h
drivers/net/ixgbe/ixgbe_dcb.c
drivers/net/ixgbe/ixgbe_dcb.h
drivers/net/ixgbe/ixgbe_dcb_82598.c
drivers/net/ixgbe/ixgbe_dcb_82598.h
drivers/net/ixgbe/ixgbe_dcb_82599.c
drivers/net/ixgbe/ixgbe_dcb_82599.h
drivers/net/ixgbe/ixgbe_dcb_nl.c
drivers/net/ixgbe/ixgbe_ethtool.c
drivers/net/ixgbe/ixgbe_fcoe.c
drivers/net/ixgbe/ixgbe_fcoe.h
drivers/net/ixgbe/ixgbe_main.c
drivers/net/ixgbe/ixgbe_phy.c
drivers/net/ixgbe/ixgbe_phy.h
drivers/net/ixgbe/ixgbe_type.h
drivers/net/sfc/mcdi.c
drivers/net/sfc/selftest.c
drivers/net/tg3.c
drivers/net/tg3.h
drivers/net/wireless/ath/ath5k/eeprom.c
drivers/net/wireless/ath/ath5k/eeprom.h
drivers/net/wireless/ath/ath9k/Kconfig
drivers/net/wireless/ath/ath9k/ath9k.h
drivers/net/wireless/iwlwifi/iwl-4965.c
drivers/net/wireless/iwlwifi/iwl-core.c
drivers/net/wireless/iwlwifi/iwl-dev.h
drivers/net/wireless/mwl8k.c
drivers/net/wireless/rt2x00/rt2800lib.c
drivers/net/wireless/rt2x00/rt2x00.h
drivers/net/wireless/rt2x00/rt2x00dev.c
drivers/net/wireless/rt2x00/rt2x00queue.c
drivers/net/wireless/zd1211rw/zd_mac.c
drivers/s390/block/dasd_eckd.c
drivers/s390/block/dasd_ioctl.c
drivers/s390/char/con3215.c
drivers/s390/char/fs3270.c
drivers/s390/char/tape_block.c
drivers/s390/char/tape_char.c
drivers/s390/char/vmcp.c
drivers/s390/cio/chsc_sch.c
drivers/s390/crypto/zcrypt_api.c
drivers/serial/8250_pnp.c
drivers/serial/sh-sci.c
drivers/staging/cx25821/cx25821-medusa-video.c
drivers/video/s3c-fb.c
drivers/video/via/accel.c
drivers/video/via/viafbdev.c
drivers/virtio/virtio_balloon.c
drivers/xen/manage.c
fs/9p/vfs_inode.c
fs/cifs/cifs_dfs_ref.c
fs/configfs/symlink.c
fs/ecryptfs/inode.c
fs/fcntl.c
fs/hppfs/hppfs.c
fs/namei.c
fs/namespace.c
fs/notify/inotify/inotify_fsnotify.c
fs/notify/inotify/inotify_user.c
fs/proc/base.c
fs/ramfs/file-nommu.c
include/linux/fs.h
include/linux/kernel.h
include/linux/kfifo.h
include/linux/mm.h
include/linux/mm_types.h
include/linux/sched.h
include/linux/serio.h
include/linux/string.h
include/linux/tty.h
include/net/ip.h
ipc/shm.c
kernel/futex.c
kernel/kfifo.c
kernel/smp.c
kernel/trace/ftrace.c
kernel/trace/ring_buffer.c
kernel/trace/trace_events_filter.c
lib/string.c
lib/zlib_inflate/inffast.c
mm/memcontrol.c
mm/nommu.c
mm/page_alloc.c
mm/truncate.c
mm/util.c
mm/vmscan.c
net/ipv6/exthdrs.c
net/mac80211/iface.c
net/mac80211/mlme.c
net/mac80211/rx.c
net/mac80211/scan.c
net/mac80211/tx.c
net/mac80211/util.c
net/mac80211/wme.c
net/mac80211/wme.h
net/wireless/core.c
net/wireless/reg.c
scripts/Makefile.lib
scripts/markup_oops.pl
scripts/mod/file2alias.c
scripts/recordmcount.pl
security/tomoyo/tomoyo.c
tools/perf/Makefile

index 870d190..0a46833 100644 (file)
@@ -493,3 +493,52 @@ Why:       These two features use non-standard interfaces. There are the
 Who:   Corentin Chary <corentin.chary@gmail.com>
 
 ----------------------------
+
+What:  usbvideo quickcam_messenger driver
+When:  2.6.35
+Files: drivers/media/video/usbvideo/quickcam_messenger.[ch]
+Why:   obsolete v4l1 driver replaced by gspca_stv06xx
+Who:   Hans de Goede <hdegoede@redhat.com>
+
+----------------------------
+
+What:  ov511 v4l1 driver
+When:  2.6.35
+Files: drivers/media/video/ov511.[ch]
+Why:   obsolete v4l1 driver replaced by gspca_ov519
+Who:   Hans de Goede <hdegoede@redhat.com>
+
+----------------------------
+
+What:  w9968cf v4l1 driver
+When:  2.6.35
+Files: drivers/media/video/w9968cf*.[ch]
+Why:   obsolete v4l1 driver replaced by gspca_ov519
+Who:   Hans de Goede <hdegoede@redhat.com>
+
+----------------------------
+
+What:  ovcamchip sensor framework
+When:  2.6.35
+Files: drivers/media/video/ovcamchip/*
+Why:   Only used by obsoleted v4l1 drivers
+Who:   Hans de Goede <hdegoede@redhat.com>
+
+----------------------------
+
+What:  stv680 v4l1 driver
+When:  2.6.35
+Files: drivers/media/video/stv680.[ch]
+Why:   obsolete v4l1 driver replaced by gspca_stv0680
+Who:   Hans de Goede <hdegoede@redhat.com>
+
+----------------------------
+
+What:  zc0301 v4l driver
+When:  2.6.35
+Files: drivers/media/video/zc0301/*
+Why:   Duplicate functionality with the gspca_zc3xx driver, zc0301 only
+       supports 2 USB-ID's (because it only supports a limited set of
+       sensors) wich are also supported by the gspca_zc3xx driver
+       (which supports 53 USB-ID's in total)
+Who:   Hans de Goede <hdegoede@redhat.com>
index c8f47bf..1858646 100644 (file)
@@ -410,9 +410,8 @@ F:  drivers/i2c/busses/i2c-ali1563.c
 
 ALPHA PORT
 M:     Richard Henderson <rth@twiddle.net>
-S:     Odd Fixes for 2.4; Maintained for 2.6.
 M:     Ivan Kokshaysky <ink@jurassic.park.msu.ru>
-S:     Maintained for 2.4; PCI support for 2.6.
+M:     Matt Turner <mattst88@gmail.com>
 L:     linux-alpha@vger.kernel.org
 F:     arch/alpha/
 
@@ -1638,9 +1637,8 @@ S:        Maintained
 F:     sound/pci/cs5535audio/
 
 CX18 VIDEO4LINUX DRIVER
-M:     Hans Verkuil <hverkuil@xs4all.nl>
 M:     Andy Walls <awalls@radix.net>
-L:     ivtv-devel@ivtvdriver.org
+L:     ivtv-devel@ivtvdriver.org (moderated for non-subscribers)
 L:     linux-media@vger.kernel.org
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6.git
 W:     http://linuxtv.org
@@ -3012,8 +3010,8 @@ S:        Maintained
 F:     drivers/isdn/hardware/eicon/
 
 IVTV VIDEO4LINUX DRIVER
-M:     Hans Verkuil <hverkuil@xs4all.nl>
-L:     ivtv-devel@ivtvdriver.org
+M:     Andy Walls <awalls@radix.net>
+L:     ivtv-devel@ivtvdriver.org (moderated for non-subscribers)
 L:     linux-media@vger.kernel.org
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6.git
 W:     http://www.ivtvdriver.org
index 9f64552..5f333bf 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -18,10 +18,9 @@ MAKEFLAGS += -rR --no-print-directory
 
 # Avoid funny character set dependencies
 unexport LC_ALL
-LC_CTYPE=C
 LC_COLLATE=C
 LC_NUMERIC=C
-export LC_CTYPE LC_COLLATE LC_NUMERIC
+export LC_COLLATE LC_NUMERIC
 
 # We are using a recursive build, so we need to do a little thinking
 # to get the ordering right.
index 36b3a30..9251e13 100644 (file)
@@ -28,6 +28,9 @@ static const struct cpumask *cpumask_of_node(int node)
 {
        int cpu;
 
+       if (node == -1)
+               return cpu_all_mask;
+
        cpumask_clear(&node_to_cpumask_map[node]);
 
        for_each_online_cpu(cpu) {
index b4e21a2..7a560e0 100644 (file)
@@ -29,6 +29,7 @@ enum davinci_matrix_types {
 };
 
 struct davinci_ks_platform_data {
+       int             (*device_enable)(struct device *dev);
        unsigned short  *keymap;
        u32             keymapsize;
        u8              rep:1;
index 547d4fc..2068e90 100644 (file)
@@ -288,7 +288,7 @@ static struct s3c2410_platform_nand mini2440_nand_info __initdata = {
 
 /* DM9000AEP 10/100 ethernet controller */
 
-static struct resource mini2440_dm9k_resource[] __initdata = {
+static struct resource mini2440_dm9k_resource[] = {
        [0] = {
                .start = MACH_MINI2440_DM9K_BASE,
                .end   = MACH_MINI2440_DM9K_BASE + 3,
@@ -310,11 +310,11 @@ static struct resource mini2440_dm9k_resource[] __initdata = {
  * The DM9000 has no eeprom, and it's MAC address is set by
  * the bootloader before starting the kernel.
  */
-static struct dm9000_plat_data mini2440_dm9k_pdata __initdata = {
+static struct dm9000_plat_data mini2440_dm9k_pdata = {
        .flags          = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
 };
 
-static struct platform_device mini2440_device_eth __initdata = {
+static struct platform_device mini2440_device_eth = {
        .name           = "dm9000",
        .id             = -1,
        .num_resources  = ARRAY_SIZE(mini2440_dm9k_resource),
@@ -341,7 +341,7 @@ static struct platform_device mini2440_device_eth __initdata = {
  *     |  |  +----+  +----+
  *       .....
  */
-static struct gpio_keys_button mini2440_buttons[] __initdata = {
+static struct gpio_keys_button mini2440_buttons[] = {
        {
                .gpio           = S3C2410_GPG(0),               /* K1 */
                .code           = KEY_F1,
@@ -384,12 +384,12 @@ static struct gpio_keys_button mini2440_buttons[] __initdata = {
 #endif
 };
 
-static struct gpio_keys_platform_data mini2440_button_data __initdata = {
+static struct gpio_keys_platform_data mini2440_button_data = {
        .buttons        = mini2440_buttons,
        .nbuttons       = ARRAY_SIZE(mini2440_buttons),
 };
 
-static struct platform_device mini2440_button_device __initdata = {
+static struct platform_device mini2440_button_device = {
        .name           = "gpio-keys",
        .id             = -1,
        .dev            = {
@@ -399,41 +399,41 @@ static struct platform_device mini2440_button_device __initdata = {
 
 /* LEDS */
 
-static struct s3c24xx_led_platdata mini2440_led1_pdata __initdata = {
+static struct s3c24xx_led_platdata mini2440_led1_pdata = {
        .name           = "led1",
        .gpio           = S3C2410_GPB(5),
        .flags          = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
        .def_trigger    = "heartbeat",
 };
 
-static struct s3c24xx_led_platdata mini2440_led2_pdata __initdata = {
+static struct s3c24xx_led_platdata mini2440_led2_pdata = {
        .name           = "led2",
        .gpio           = S3C2410_GPB(6),
        .flags          = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
        .def_trigger    = "nand-disk",
 };
 
-static struct s3c24xx_led_platdata mini2440_led3_pdata __initdata = {
+static struct s3c24xx_led_platdata mini2440_led3_pdata = {
        .name           = "led3",
        .gpio           = S3C2410_GPB(7),
        .flags          = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
        .def_trigger    = "mmc0",
 };
 
-static struct s3c24xx_led_platdata mini2440_led4_pdata __initdata = {
+static struct s3c24xx_led_platdata mini2440_led4_pdata = {
        .name           = "led4",
        .gpio           = S3C2410_GPB(8),
        .flags          = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
        .def_trigger    = "",
 };
 
-static struct s3c24xx_led_platdata mini2440_led_backlight_pdata __initdata = {
+static struct s3c24xx_led_platdata mini2440_led_backlight_pdata = {
        .name           = "backlight",
        .gpio           = S3C2410_GPG(4),
        .def_trigger    = "backlight",
 };
 
-static struct platform_device mini2440_led1 __initdata = {
+static struct platform_device mini2440_led1 = {
        .name           = "s3c24xx_led",
        .id             = 1,
        .dev            = {
@@ -441,7 +441,7 @@ static struct platform_device mini2440_led1 __initdata = {
        },
 };
 
-static struct platform_device mini2440_led2 __initdata = {
+static struct platform_device mini2440_led2 = {
        .name           = "s3c24xx_led",
        .id             = 2,
        .dev            = {
@@ -449,7 +449,7 @@ static struct platform_device mini2440_led2 __initdata = {
        },
 };
 
-static struct platform_device mini2440_led3 __initdata = {
+static struct platform_device mini2440_led3 = {
        .name           = "s3c24xx_led",
        .id             = 3,
        .dev            = {
@@ -457,7 +457,7 @@ static struct platform_device mini2440_led3 __initdata = {
        },
 };
 
-static struct platform_device mini2440_led4 __initdata = {
+static struct platform_device mini2440_led4 = {
        .name           = "s3c24xx_led",
        .id             = 4,
        .dev            = {
@@ -465,7 +465,7 @@ static struct platform_device mini2440_led4 __initdata = {
        },
 };
 
-static struct platform_device mini2440_led_backlight __initdata = {
+static struct platform_device mini2440_led_backlight = {
        .name           = "s3c24xx_led",
        .id             = 5,
        .dev            = {
@@ -475,14 +475,14 @@ static struct platform_device mini2440_led_backlight __initdata = {
 
 /* AUDIO */
 
-static struct s3c24xx_uda134x_platform_data mini2440_audio_pins __initdata = {
+static struct s3c24xx_uda134x_platform_data mini2440_audio_pins = {
        .l3_clk = S3C2410_GPB(4),
        .l3_mode = S3C2410_GPB(2),
        .l3_data = S3C2410_GPB(3),
        .model = UDA134X_UDA1341
 };
 
-static struct platform_device mini2440_audio __initdata = {
+static struct platform_device mini2440_audio = {
        .name           = "s3c24xx_uda134x",
        .id             = 0,
        .dev            = {
index 480d297..8969fe7 100644 (file)
@@ -211,6 +211,7 @@ static struct fixed_voltage_config smdk6410_b_pwr_5v_pdata = {
        .supply_name = "B_PWR_5V",
        .microvolts = 5000000,
        .init_data = &smdk6410_b_pwr_5v_data,
+       .gpio = -EINVAL,
 };
 
 static struct platform_device smdk6410_b_pwr_5v = {
index 84808cc..a52fb6c 100644 (file)
@@ -58,8 +58,8 @@ static int __init s3c_nand_copy_set(struct s3c2410_nand_set *set)
                        return -ENOMEM;
        }
        
-       size = sizeof(int) * set->nr_chips;
-       if (size) {
+       if (set->nr_map && set->nr_chips) {
+               size = sizeof(int) * set->nr_chips;
                ptr = kmemdup(set->nr_map, size, GFP_KERNEL);
                set->nr_map = ptr;
 
index d8720ee..aebea19 100644 (file)
@@ -146,7 +146,6 @@ static struct clocksource pit_clk = {
        .read   = pit_read_clk,
        .shift  = 20,
        .mask   = CLOCKSOURCE_MASK(32),
-       .flags  = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
 /***************************************************************************/
index 826a30a..bb2465b 100644 (file)
@@ -20,7 +20,7 @@
 all: $(obj)/zImage
 
 BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-                -fno-strict-aliasing -Os -msoft-float -pipe -D__KERNEL__\
+                -fno-strict-aliasing -Os -msoft-float -pipe \
                 -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
                 -isystem $(shell $(CROSS32CC) -print-file-name=include)
 BOOTAFLAGS     := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
@@ -34,8 +34,6 @@ BOOTCFLAGS    += -fno-stack-protector
 endif
 
 BOOTCFLAGS     += -I$(obj) -I$(srctree)/$(obj)
-BOOTCFLAGS     += -include include/linux/autoconf.h -Iarch/powerpc/include
-BOOTCFLAGS     += -Iinclude
 
 DTS_FLAGS      ?= -p 1024
 
index efb74fd..b1066b9 100644 (file)
        unreachable();                                  \
 } while (0)
 
+#define __WARN() do {                                  \
+       __EMIT_BUG(BUGFLAG_WARNING);                    \
+} while (0)
+
 #define WARN_ON(x) ({                                  \
        int __ret_warn_on = !!(x);                      \
        if (__builtin_constant_p(__ret_warn_on)) {      \
index ec403d4..f72d611 100644 (file)
 #ifndef __SIGP__
 #define __SIGP__
 
-#include <asm/ptrace.h>
-#include <asm/atomic.h>
+#include <asm/system.h>
 
 /* get real cpu address from logical cpu number */
-extern volatile int __cpu_logical_map[];
+extern int __cpu_logical_map[];
+
+static inline int cpu_logical_map(int cpu)
+{
+#ifdef CONFIG_SMP
+       return __cpu_logical_map[cpu];
+#else
+       return stap();
+#endif
+}
 
 typedef enum
 {
@@ -79,7 +87,7 @@ signal_processor(__u16 cpu_addr, sigp_order_code order_code)
                "       ipm     %0\n"
                "       srl     %0,28\n"
                :       "=d"    (ccode)
-               : "d" (reg1), "d" (__cpu_logical_map[cpu_addr]),
+               : "d" (reg1), "d" (cpu_logical_map(cpu_addr)),
                  "a" (order_code) : "cc" , "memory");
        return ccode;
 }
@@ -98,7 +106,7 @@ signal_processor_p(__u32 parameter, __u16 cpu_addr, sigp_order_code order_code)
                "       ipm     %0\n"
                "       srl     %0,28\n"
                : "=d" (ccode)
-               : "d" (reg1), "d" (__cpu_logical_map[cpu_addr]),
+               : "d" (reg1), "d" (cpu_logical_map(cpu_addr)),
                  "a" (order_code) : "cc" , "memory");
        return ccode;
 }
@@ -118,7 +126,7 @@ signal_processor_ps(__u32 *statusptr, __u32 parameter, __u16 cpu_addr,
                "       ipm     %0\n"
                "       srl     %0,28\n"
                : "=d" (ccode), "+d" (reg1)
-               : "d" (__cpu_logical_map[cpu_addr]), "a" (order_code)
+               : "d" (cpu_logical_map(cpu_addr)), "a" (order_code)
                : "cc" , "memory");
        *statusptr = reg1;
        return ccode;
index 07eb61b..66069e7 100644 (file)
@@ -93,13 +93,12 @@ static inline struct thread_info *current_thread_info(void)
 #define TIF_SYSCALL_AUDIT      9       /* syscall auditing active */
 #define TIF_SECCOMP            10      /* secure computing */
 #define TIF_SYSCALL_TRACEPOINT 11      /* syscall tracepoint instrumentation */
-#define TIF_USEDFPU            16      /* FPU was used by this task this quantum (SMP) */
-#define TIF_POLLING_NRFLAG     17      /* true if poll_idle() is polling 
+#define TIF_POLLING_NRFLAG     16      /* true if poll_idle() is polling
                                           TIF_NEED_RESCHED */
-#define TIF_31BIT              18      /* 32bit process */ 
-#define TIF_MEMDIE             19
-#define TIF_RESTORE_SIGMASK    20      /* restore signal mask in do_signal() */
-#define TIF_FREEZE             21      /* thread is freezing for suspend */
+#define TIF_31BIT              17      /* 32bit process */
+#define TIF_MEMDIE             18
+#define TIF_RESTORE_SIGMASK    19      /* restore signal mask in do_signal() */
+#define TIF_FREEZE             20      /* thread is freezing for suspend */
 
 #define _TIF_NOTIFY_RESUME     (1<<TIF_NOTIFY_RESUME)
 #define _TIF_RESTORE_SIGMASK   (1<<TIF_RESTORE_SIGMASK)
@@ -112,7 +111,6 @@ static inline struct thread_info *current_thread_info(void)
 #define _TIF_SYSCALL_AUDIT     (1<<TIF_SYSCALL_AUDIT)
 #define _TIF_SECCOMP           (1<<TIF_SECCOMP)
 #define _TIF_SYSCALL_TRACEPOINT        (1<<TIF_SYSCALL_TRACEPOINT)
-#define _TIF_USEDFPU           (1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG    (1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT             (1<<TIF_31BIT)
 #define _TIF_FREEZE            (1<<TIF_FREEZE)
index 192a720..6e9f049 100644 (file)
 #define        __NR_pwritev            329
 #define __NR_rt_tgsigqueueinfo 330
 #define __NR_perf_event_open   331
-#define __NR_recvmmsg          332
-#define NR_syscalls 333
+#define NR_syscalls 332
 
 /* 
  * There are some system calls that are not present on 64 bit, some
 #define __IGNORE_migrate_pages
 #define __IGNORE_move_pages
 
+/* Ignore system calls that are also reachable via sys_socket */
+#define __IGNORE_recvmmsg
+
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_SYS_ALARM
index 22c9e55..11c3aba 100644 (file)
@@ -616,44 +616,35 @@ asmlinkage long sys32_fstatat64(unsigned int dfd, char __user *filename,
  */
 
 struct mmap_arg_struct_emu31 {
-       u32     addr;
-       u32     len;
-       u32     prot;
-       u32     flags;
-       u32     fd;
-       u32     offset;
+       compat_ulong_t addr;
+       compat_ulong_t len;
+       compat_ulong_t prot;
+       compat_ulong_t flags;
+       compat_ulong_t fd;
+       compat_ulong_t offset;
 };
 
-asmlinkage unsigned long
-old32_mmap(struct mmap_arg_struct_emu31 __user *arg)
+asmlinkage unsigned long old32_mmap(struct mmap_arg_struct_emu31 __user *arg)
 {
        struct mmap_arg_struct_emu31 a;
-       int error = -EFAULT;
 
        if (copy_from_user(&a, arg, sizeof(a)))
-               goto out;
-
-       error = -EINVAL;
+               return -EFAULT;
        if (a.offset & ~PAGE_MASK)
-               goto out;
-
-       error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
-                              a.offset >> PAGE_SHIFT);
-out:
-       return error;
+               return -EINVAL;
+       a.addr = (unsigned long) compat_ptr(a.addr);
+       return sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
+                             a.offset >> PAGE_SHIFT);
 }
 
-asmlinkage long 
-sys32_mmap2(struct mmap_arg_struct_emu31 __user *arg)
+asmlinkage long sys32_mmap2(struct mmap_arg_struct_emu31 __user *arg)
 {
        struct mmap_arg_struct_emu31 a;
-       int error = -EFAULT;
 
        if (copy_from_user(&a, arg, sizeof(a)))
-               goto out;
-       error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
-out:
-       return error;
+               return -EFAULT;
+       a.addr = (unsigned long) compat_ptr(a.addr);
+       return sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
 }
 
 asmlinkage long sys32_read(unsigned int fd, char __user * buf, size_t count)
index faeaccc..30de2d0 100644 (file)
@@ -1853,12 +1853,3 @@ sys32_execve_wrapper:
        llgtr   %r3,%r3                 # compat_uptr_t *
        llgtr   %r4,%r4                 # compat_uptr_t *
        jg      sys32_execve            # branch to system call
-
-       .globl  compat_sys_recvmmsg_wrapper
-compat_sys_recvmmsg_wrapper:
-       lgfr    %r2,%r2                 # int
-       llgtr   %r3,%r3                 # struct compat_mmsghdr *
-       llgfr   %r4,%r4                 # unsigned int
-       llgfr   %r5,%r5                 # unsigned int
-       llgtr   %r6,%r6                 # struct compat_timespec *
-       jg      compat_sys_recvmmsg
index 5417eb5..00b6d1d 100644 (file)
@@ -153,8 +153,6 @@ void exit_thread(void)
 
 void flush_thread(void)
 {
-       clear_used_math();
-       clear_tsk_thread_flag(current, TIF_USEDFPU);
 }
 
 void release_thread(struct task_struct *dead_task)
@@ -217,6 +215,7 @@ int copy_thread(unsigned long clone_flags, unsigned long new_stackp,
        p->thread.mm_segment = get_fs();
        /* Don't copy debug registers */
        memset(&p->thread.per_info, 0, sizeof(p->thread.per_info));
+       clear_tsk_thread_flag(p, TIF_SINGLE_STEP);
        /* Initialize per thread user and system timer values */
        ti = task_thread_info(p);
        ti->user_timer = 0;
index 13815d3..7cf4642 100644 (file)
@@ -65,6 +65,7 @@ FixPerRegisters(struct task_struct *task)
 {
        struct pt_regs *regs;
        per_struct *per_info;
+       per_cr_words cr_words;
 
        regs = task_pt_regs(task);
        per_info = (per_struct *) &task->thread.per_info;
@@ -98,6 +99,13 @@ FixPerRegisters(struct task_struct *task)
                per_info->control_regs.bits.storage_alt_space_ctl = 1;
        else
                per_info->control_regs.bits.storage_alt_space_ctl = 0;
+
+       if (task == current) {
+               __ctl_store(cr_words, 9, 11);
+               if (memcmp(&cr_words, &per_info->control_regs.words,
+                          sizeof(cr_words)) != 0)
+                       __ctl_load(per_info->control_regs.words, 9, 11);
+       }
 }
 
 void user_enable_single_step(struct task_struct *task)
index 0663287..8d8957b 100644 (file)
@@ -87,7 +87,6 @@ unsigned long elf_hwcap = 0;
 char elf_platform[ELF_PLATFORM_SIZE];
 
 struct mem_chunk __initdata memory_chunk[MEMORY_CHUNKS];
-volatile int __cpu_logical_map[NR_CPUS]; /* logical cpu to cpu address */
 
 int __initdata memory_end_set;
 unsigned long __initdata memory_end;
@@ -124,12 +123,6 @@ void __cpuinit cpu_init(void)
          */
        get_cpu_id(&S390_lowcore.cpu_id);
 
-        /*
-         * Force FPU initialization:
-         */
-        clear_thread_flag(TIF_USEDFPU);
-        clear_used_math();
-
        atomic_inc(&init_mm.mm_count);
        current->active_mm = &init_mm;
        BUG_ON(current->mm);
@@ -855,7 +848,6 @@ setup_arch(char **cmdline_p)
        setup_lowcore();
 
         cpu_init();
-       __cpu_logical_map[0] = stap();
        s390_init_cpu_topology();
 
        /*
index 6b4fef8..1675c48 100644 (file)
@@ -500,18 +500,10 @@ void do_signal(struct pt_regs *regs)
                                clear_thread_flag(TIF_RESTORE_SIGMASK);
 
                        /*
-                        * If we would have taken a single-step trap
-                        * for a normal instruction, act like we took
-                        * one for the handler setup.
-                        */
-                       if (current->thread.per_info.single_step)
-                               set_thread_flag(TIF_SINGLE_STEP);
-
-                       /*
                         * Let tracing know that we've done the handler setup.
                         */
                        tracehook_signal_handler(signr, &info, &ka, regs,
-                                        test_thread_flag(TIF_SINGLE_STEP));
+                                       current->thread.per_info.single_step);
                }
                return;
        }
index 93e5203..76a6fdd 100644 (file)
@@ -52,6 +52,9 @@
 #include <asm/cpu.h>
 #include "entry.h"
 
+/* logical cpu to cpu address */
+int __cpu_logical_map[NR_CPUS];
+
 static struct task_struct *current_set[NR_CPUS];
 
 static u8 smp_cpu_type;
@@ -717,6 +720,12 @@ void __init smp_cpus_done(unsigned int max_cpus)
 {
 }
 
+void __init smp_setup_processor_id(void)
+{
+       S390_lowcore.cpu_nr = 0;
+       __cpu_logical_map[0] = stap();
+}
+
 /*
  * the frequency of the profiling timer can be changed
  * by writing a multiplier value into /proc/profile.
index 4f292c9..30eca07 100644 (file)
@@ -340,4 +340,3 @@ SYSCALL(sys_preadv,sys_preadv,compat_sys_preadv_wrapper)
 SYSCALL(sys_pwritev,sys_pwritev,compat_sys_pwritev_wrapper)
 SYSCALL(sys_rt_tgsigqueueinfo,sys_rt_tgsigqueueinfo,compat_sys_rt_tgsigqueueinfo_wrapper) /* 330 */
 SYSCALL(sys_perf_event_open,sys_perf_event_open,sys_perf_event_open_wrapper)
-SYSCALL(sys_recvmmsg,sys_recvmmsg,compat_sys_recvmmsg_wrapper)
index 3c72c9c..14ef6f0 100644 (file)
@@ -114,7 +114,7 @@ static void add_cpus_to_core(struct tl_cpu *tl_cpu, struct core_info *core)
 
                rcpu = CPU_BITS - 1 - cpu + tl_cpu->origin;
                for_each_present_cpu(lcpu) {
-                       if (__cpu_logical_map[lcpu] == rcpu) {
+                       if (cpu_logical_map(lcpu) == rcpu) {
                                cpu_set(lcpu, core->mask);
                                smp_cpu_polarization[lcpu] = tl_cpu->pp;
                        }
index 10754a3..cff327f 100644 (file)
@@ -34,7 +34,7 @@ static inline void _raw_yield_cpu(int cpu)
 {
        if (MACHINE_HAS_DIAG9C)
                asm volatile("diag %0,0,0x9c"
-                            : : "d" (__cpu_logical_map[cpu]));
+                            : : "d" (cpu_logical_map(cpu)));
        else
                _raw_yield();
 }
index f4558cc..869efba 100644 (file)
@@ -40,7 +40,7 @@
 
 static inline unsigned long mmap_base(void)
 {
-       unsigned long gap = current->signal->rlim[RLIMIT_STACK].rlim_cur;
+       unsigned long gap = rlimit(RLIMIT_STACK);
 
        if (gap < MIN_GAP)
                gap = MIN_GAP;
@@ -61,7 +61,7 @@ static inline int mmap_is_legacy(void)
 #endif
        return sysctl_legacy_va_layout ||
            (current->personality & ADDR_COMPAT_LAYOUT) ||
-           current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY;
+           rlimit(RLIMIT_STACK) == RLIM_INFINITY;
 }
 
 #ifndef CONFIG_64BIT
index 6a8861b..5c24628 100644 (file)
@@ -353,6 +353,10 @@ static struct i2c_board_info i2c1_devices[] = {
        {
                I2C_BOARD_INFO("r2025sd", 0x32),
        },
+       {
+               I2C_BOARD_INFO("lis3lv02d", 0x1c),
+               .irq = 33,
+       }
 };
 
 /* KEYSC */
@@ -1115,6 +1119,10 @@ static int __init arch_setup(void)
        gpio_direction_output(GPIO_PTU0, 0);
        mdelay(20);
 
+       /* enable motion sensor */
+       gpio_request(GPIO_FN_INTC_IRQ1, NULL);
+       gpio_direction_input(GPIO_FN_INTC_IRQ1);
+
        /* enable I2C device */
        i2c_register_board_info(0, i2c0_devices,
                                ARRAY_SIZE(i2c0_devices));
index 558a56b..2082af1 100644 (file)
@@ -13,4 +13,4 @@
 include/generated/machtypes.h: $(src)/gen-mach-types $(src)/mach-types
        @echo '  Generating $@'
        $(Q)mkdir -p $(dir $@)
-       $(Q)$(AWK) -f $^ > $@ || { rm -f $@; /bin/false; }
+       $(Q)LC_ALL=C $(AWK) -f $^ > $@ || { rm -f $@; /bin/false; }
index 5106924..3b3c366 100644 (file)
@@ -125,50 +125,36 @@ void mconsole_log(struct mc_request *req)
 void mconsole_proc(struct mc_request *req)
 {
        struct nameidata nd;
-       struct file_system_type *proc;
-       struct super_block *super;
+       struct vfsmount *mnt = current->nsproxy->pid_ns->proc_mnt;
        struct file *file;
        int n, err;
        char *ptr = req->request.data, *buf;
+       mm_segment_t old_fs = get_fs();
 
        ptr += strlen("proc");
        ptr = skip_spaces(ptr);
 
-       proc = get_fs_type("proc");
-       if (proc == NULL) {
-               mconsole_reply(req, "procfs not registered", 1, 0);
+       err = vfs_path_lookup(mnt->mnt_root, mnt, ptr, LOOKUP_FOLLOW, &nd);
+       if (err) {
+               mconsole_reply(req, "Failed to look up file", 1, 0);
                goto out;
        }
 
-       super = (*proc->get_sb)(proc, 0, NULL, NULL);
-       put_filesystem(proc);
-       if (super == NULL) {
-               mconsole_reply(req, "Failed to get procfs superblock", 1, 0);
+       err = may_open(&nd.path, MAY_READ, FMODE_READ);
+       if (result) {
+               mconsole_reply(req, "Failed to open file", 1, 0);
+               path_put(&nd.path);
                goto out;
        }
-       up_write(&super->s_umount);
-
-       nd.path.dentry = super->s_root;
-       nd.path.mnt = NULL;
-       nd.flags = O_RDONLY + 1;
-       nd.last_type = LAST_ROOT;
-
-       /* START: it was experienced that the stability problems are closed
-        * if commenting out these two calls + the below read cycle. To
-        * make UML crash again, it was enough to readd either one.*/
-       err = link_path_walk(ptr, &nd);
-       if (err) {
-               mconsole_reply(req, "Failed to look up file", 1, 0);
-               goto out_kill;
-       }
 
        file = dentry_open(nd.path.dentry, nd.path.mnt, O_RDONLY,
                           current_cred());
+       err = PTR_ERR(file);
        if (IS_ERR(file)) {
                mconsole_reply(req, "Failed to open file", 1, 0);
-               goto out_kill;
+               path_put(&nd.path);
+               goto out;
        }
-       /*END*/
 
        buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
        if (buf == NULL) {
@@ -176,10 +162,13 @@ void mconsole_proc(struct mc_request *req)
                goto out_fput;
        }
 
-       if ((file->f_op != NULL) && (file->f_op->read != NULL)) {
+       if (file->f_op->read) {
                do {
-                       n = (*file->f_op->read)(file, buf, PAGE_SIZE - 1,
-                                               &file->f_pos);
+                       loff_t pos;
+                       set_fs(KERNEL_DS);
+                       n = vfs_read(file, buf, PAGE_SIZE - 1, &pos);
+                       file_pos_write(file, pos);
+                       set_fs(old_fs);
                        if (n >= 0) {
                                buf[n] = '\0';
                                mconsole_reply(req, buf, 0, (n > 0));
@@ -197,8 +186,6 @@ void mconsole_proc(struct mc_request *req)
        kfree(buf);
  out_fput:
        fput(file);
- out_kill:
-       deactivate_super(super);
  out: ;
 }
 #endif
index 858baa0..6c3fdd6 100644 (file)
@@ -108,10 +108,11 @@ struct mce_log {
 #define K8_MCE_THRESHOLD_BANK_5    (MCE_THRESHOLD_BASE + 5 * 9)
 #define K8_MCE_THRESHOLD_DRAM_ECC  (MCE_THRESHOLD_BANK_4 + 0)
 
-extern struct atomic_notifier_head x86_mce_decoder_chain;
 
 #ifdef __KERNEL__
 
+extern struct atomic_notifier_head x86_mce_decoder_chain;
+
 #include <linux/percpu.h>
 #include <linux/init.h>
 #include <asm/atomic.h>
index bc54fa9..40be813 100644 (file)
@@ -495,5 +495,17 @@ static inline void uv_hub_send_ipi(int pnode, int apicid, int vector)
        uv_write_global_mmr64(pnode, UVH_IPI_INT, val);
 }
 
+/*
+ * Get the minimum revision number of the hub chips within the partition.
+ *     1 - initial rev 1.0 silicon
+ *     2 - rev 2.0 production silicon
+ */
+static inline int uv_get_min_hub_revision_id(void)
+{
+       extern int uv_min_hub_revision_id;
+
+       return uv_min_hub_revision_id;
+}
+
 #endif /* CONFIG_X86_64 */
 #endif /* _ASM_X86_UV_UV_HUB_H */
index 3704997..f147a95 100644 (file)
@@ -31,6 +31,7 @@
 #include <asm/x86_init.h>
 
 int gart_iommu_aperture;
+EXPORT_SYMBOL_GPL(gart_iommu_aperture);
 int gart_iommu_aperture_disabled __initdata;
 int gart_iommu_aperture_allowed __initdata;
 
index 5f92494..21db3cb 100644 (file)
@@ -36,6 +36,8 @@ DEFINE_PER_CPU(int, x2apic_extra_bits);
 
 static enum uv_system_type uv_system_type;
 static u64 gru_start_paddr, gru_end_paddr;
+int uv_min_hub_revision_id;
+EXPORT_SYMBOL_GPL(uv_min_hub_revision_id);
 
 static inline bool is_GRU_range(u64 start, u64 end)
 {
@@ -55,12 +57,19 @@ static int early_get_nodeid(void)
        mmr = early_ioremap(UV_LOCAL_MMR_BASE | UVH_NODE_ID, sizeof(*mmr));
        node_id.v = *mmr;
        early_iounmap(mmr, sizeof(*mmr));
+
+       /* Currently, all blades have same revision number */
+       uv_min_hub_revision_id = node_id.s.revision;
+
        return node_id.s.node_id;
 }
 
 static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
 {
+       int nodeid;
+
        if (!strcmp(oem_id, "SGI")) {
+               nodeid = early_get_nodeid();
                x86_platform.is_untracked_pat_range =  uv_is_untracked_pat_range;
                if (!strcmp(oem_table_id, "UVL"))
                        uv_system_type = UV_LEGACY_APIC;
@@ -68,7 +77,7 @@ static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
                        uv_system_type = UV_X2APIC;
                else if (!strcmp(oem_table_id, "UVH")) {
                        __get_cpu_var(x2apic_extra_bits) =
-                               early_get_nodeid() << (UV_APIC_PNODE_SHIFT - 1);
+                               nodeid << (UV_APIC_PNODE_SHIFT - 1);
                        uv_system_type = UV_NON_UNIQUE_APIC;
                        return 1;
                }
@@ -374,13 +383,13 @@ static __init void get_lowmem_redirect(unsigned long *base, unsigned long *size)
 
 enum map_type {map_wb, map_uc};
 
-static __init void map_high(char *id, unsigned long base, int shift,
-                           int max_pnode, enum map_type map_type)
+static __init void map_high(char *id, unsigned long base, int pshift,
+                       int bshift, int max_pnode, enum map_type map_type)
 {
        unsigned long bytes, paddr;
 
-       paddr = base << shift;
-       bytes = (1UL << shift) * (max_pnode + 1);
+       paddr = base << pshift;
+       bytes = (1UL << bshift) * (max_pnode + 1);
        printk(KERN_INFO "UV: Map %s_HI 0x%lx - 0x%lx\n", id, paddr,
                                                paddr + bytes);
        if (map_type == map_uc)
@@ -396,7 +405,7 @@ static __init void map_gru_high(int max_pnode)
 
        gru.v = uv_read_local_mmr(UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR);
        if (gru.s.enable) {
-               map_high("GRU", gru.s.base, shift, max_pnode, map_wb);
+               map_high("GRU", gru.s.base, shift, shift, max_pnode, map_wb);
                gru_start_paddr = ((u64)gru.s.base << shift);
                gru_end_paddr = gru_start_paddr + (1UL << shift) * (max_pnode + 1);
 
@@ -410,7 +419,7 @@ static __init void map_mmr_high(int max_pnode)
 
        mmr.v = uv_read_local_mmr(UVH_RH_GAM_MMR_OVERLAY_CONFIG_MMR);
        if (mmr.s.enable)
-               map_high("MMR", mmr.s.base, shift, max_pnode, map_uc);
+               map_high("MMR", mmr.s.base, shift, shift, max_pnode, map_uc);
 }
 
 static __init void map_mmioh_high(int max_pnode)
@@ -420,7 +429,8 @@ static __init void map_mmioh_high(int max_pnode)
 
        mmioh.v = uv_read_local_mmr(UVH_RH_GAM_MMIOH_OVERLAY_CONFIG_MMR);
        if (mmioh.s.enable)
-               map_high("MMIOH", mmioh.s.base, shift, max_pnode, map_uc);
+               map_high("MMIOH", mmioh.s.base, shift, mmioh.s.m_io,
+                       max_pnode, map_uc);
 }
 
 static __init void map_low_mmrs(void)
index c56bc28..6d81755 100644 (file)
@@ -123,13 +123,15 @@ print_context_stack_bp(struct thread_info *tinfo,
        while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
                unsigned long addr = *ret_addr;
 
-               if (__kernel_text_address(addr)) {
-                       ops->address(data, addr, 1);
-                       frame = frame->next_frame;
-                       ret_addr = &frame->return_address;
-                       print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
-               }
+               if (!__kernel_text_address(addr))
+                       break;
+
+               ops->address(data, addr, 1);
+               frame = frame->next_frame;
+               ret_addr = &frame->return_address;
+               print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
        }
+
        return (unsigned long)frame;
 }
 EXPORT_SYMBOL_GPL(print_context_stack_bp);
index c6ee241..02c3ee0 100644 (file)
@@ -288,6 +288,8 @@ int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
        regs.es = __USER_DS;
        regs.fs = __KERNEL_PERCPU;
        regs.gs = __KERNEL_STACK_CANARY;
+#else
+       regs.ss = __KERNEL_DS;
 #endif
 
        regs.orig_ax = -1;
index 2b26dd5..36daccb 100644 (file)
@@ -1151,9 +1151,13 @@ asmlinkage void __init xen_start_kernel(void)
 
        /* keep using Xen gdt for now; no urgent need to change it */
 
+#ifdef CONFIG_X86_32
        pv_info.kernel_rpl = 1;
        if (xen_feature(XENFEAT_supervisor_mode_kernel))
                pv_info.kernel_rpl = 0;
+#else
+       pv_info.kernel_rpl = 0;
+#endif
 
        /* set the limit of our address space */
        xen_reserve_top();
index d7d77d4..ae6b6c4 100644 (file)
@@ -309,17 +309,19 @@ static SYSDEV_ATTR(removable, 0444, show_mem_removable, NULL);
  * Block size attribute stuff
  */
 static ssize_t
-print_block_size(struct class *class, char *buf)
+print_block_size(struct sysdev_class *class,
+                struct sysdev_class_attribute *class_attr,
+                char *buf)
 {
-       return sprintf(buf, "%lx\n", (unsigned long)PAGES_PER_SECTION * PAGE_SIZE);
+       return sprintf(buf, "%#lx\n", (unsigned long)PAGES_PER_SECTION * PAGE_SIZE);
 }
 
-static CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL);
+static SYSDEV_CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL);
 
 static int block_size_init(void)
 {
        return sysfs_create_file(&memory_sysdev_class.kset.kobj,
-                               &class_attr_block_size_bytes.attr);
+                               &attr_block_size_bytes.attr);
 }
 
 /*
@@ -330,7 +332,9 @@ static int block_size_init(void)
  */
 #ifdef CONFIG_ARCH_MEMORY_PROBE
 static ssize_t
-memory_probe_store(struct class *class, const char *buf, size_t count)
+memory_probe_store(struct sysdev_class *class,
+                  struct sysdev_class_attribute *class_attr,
+                  const char *buf, size_t count)
 {
        u64 phys_addr;
        int nid;
@@ -346,12 +350,12 @@ memory_probe_store(struct class *class, const char *buf, size_t count)
 
        return count;
 }
-static CLASS_ATTR(probe, S_IWUSR, NULL, memory_probe_store);
+static SYSDEV_CLASS_ATTR(probe, S_IWUSR, NULL, memory_probe_store);
 
 static int memory_probe_init(void)
 {
        return sysfs_create_file(&memory_sysdev_class.kset.kobj,
-                               &class_attr_probe.attr);
+                               &attr_probe.attr);
 }
 #else
 static inline int memory_probe_init(void)
@@ -367,7 +371,9 @@ static inline int memory_probe_init(void)
 
 /* Soft offline a page */
 static ssize_t
-store_soft_offline_page(struct class *class, const char *buf, size_t count)
+store_soft_offline_page(struct sysdev_class *class,
+                       struct sysdev_class_attribute *class_attr,
+                       const char *buf, size_t count)
 {
        int ret;
        u64 pfn;
@@ -384,7 +390,9 @@ store_soft_offline_page(struct class *class, const char *buf, size_t count)
 
 /* Forcibly offline a page, including killing processes. */
 static ssize_t
-store_hard_offline_page(struct class *class, const char *buf, size_t count)
+store_hard_offline_page(struct sysdev_class *class,
+                       struct sysdev_class_attribute *class_attr,
+                       const char *buf, size_t count)
 {
        int ret;
        u64 pfn;
@@ -397,18 +405,18 @@ store_hard_offline_page(struct class *class, const char *buf, size_t count)
        return ret ? ret : count;
 }
 
-static CLASS_ATTR(soft_offline_page, 0644, NULL, store_soft_offline_page);
-static CLASS_ATTR(hard_offline_page, 0644, NULL, store_hard_offline_page);
+static SYSDEV_CLASS_ATTR(soft_offline_page, 0644, NULL, store_soft_offline_page);
+static SYSDEV_CLASS_ATTR(hard_offline_page, 0644, NULL, store_hard_offline_page);
 
 static __init int memory_fail_init(void)
 {
        int err;
 
        err = sysfs_create_file(&memory_sysdev_class.kset.kobj,
-                               &class_attr_soft_offline_page.attr);
+                               &attr_soft_offline_page.attr);
        if (!err)
                err = sysfs_create_file(&memory_sysdev_class.kset.kobj,
-                               &class_attr_hard_offline_page.attr);
+                               &attr_hard_offline_page.attr);
        return err;
 }
 #else
index 5aa7a58..1afb896 100644 (file)
@@ -725,12 +725,11 @@ static struct pci_driver agp_amd64_pci_driver = {
 int __init agp_amd64_init(void)
 {
        int err = 0;
-       static int done = 0;
 
        if (agp_off)
                return -EINVAL;
 
-       if (done++)
+       if (gart_iommu_aperture)
                return agp_bridges_found ? 0 : -ENODEV;
 
        err = pci_register_driver(&agp_amd64_pci_driver);
@@ -771,6 +770,8 @@ int __init agp_amd64_init(void)
 
 static void __exit agp_amd64_cleanup(void)
 {
+       if (gart_iommu_aperture)
+               return;
        if (aperture_resource)
                release_resource(aperture_resource);
        pci_unregister_driver(&agp_amd64_pci_driver);
index 30c36ac..3999a5f 100644 (file)
@@ -2460,10 +2460,14 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
                                &bridge->mode);
        }
 
-       if (bridge->driver->mask_memory == intel_i965_mask_memory)
+       if (bridge->driver->mask_memory == intel_i965_mask_memory) {
                if (pci_set_dma_mask(intel_private.pcidev, DMA_BIT_MASK(36)))
                        dev_err(&intel_private.pcidev->dev,
                                "set gfx device dma mask 36bit failed!\n");
+               else
+                       pci_set_consistent_dma_mask(intel_private.pcidev,
+                                                   DMA_BIT_MASK(36));
+       }
 
        pci_set_drvdata(pdev, bridge);
        return agp_add_bridge(bridge);
index bdaef8e..64fe0a7 100644 (file)
@@ -114,7 +114,7 @@ static struct virtio_device_id id_table[] = {
        { 0 },
 };
 
-static struct virtio_driver virtio_rng = {
+static struct virtio_driver virtio_rng_driver = {
        .driver.name =  KBUILD_MODNAME,
        .driver.owner = THIS_MODULE,
        .id_table =     id_table,
@@ -124,12 +124,12 @@ static struct virtio_driver virtio_rng = {
 
 static int __init init(void)
 {
-       return register_virtio_driver(&virtio_rng);
+       return register_virtio_driver(&virtio_rng_driver);
 }
 
 static void __exit fini(void)
 {
-       unregister_virtio_driver(&virtio_rng);
+       unregister_virtio_driver(&virtio_rng_driver);
 }
 module_init(init);
 module_exit(fini);
index c5facd9..000dc67 100644 (file)
@@ -197,7 +197,7 @@ static int amd64_get_scrub_rate(struct mem_ctl_info *mci, u32 *bw)
        edac_printk(KERN_DEBUG, EDAC_MC,
                    "pci-read, sdram scrub control value: %d \n", scrubval);
 
-       for (i = 0; ARRAY_SIZE(scrubrates); i++) {
+       for (i = 0; i < ARRAY_SIZE(scrubrates); i++) {
                if (scrubrates[i].scrubval == scrubval) {
                        *bw = scrubrates[i].bandwidth;
                        status = 0;
index 77a9579..adc10a2 100644 (file)
@@ -577,7 +577,13 @@ static void i5000_process_nonfatal_error_info(struct mem_ctl_info *mci,
                debugf0("\tUncorrected bits= 0x%x\n", ue_errors);
 
                branch = EXTRACT_FBDCHAN_INDX(info->ferr_nf_fbd);
-               channel = branch;
+
+               /*
+                * According with i5000 datasheet, bit 28 has no significance
+                * for errors M4Err-M12Err and M17Err-M21Err, on FERR_NF_FBD
+                */
+               channel = branch & 2;
+
                bank = NREC_BANK(info->nrecmema);
                rank = NREC_RANK(info->nrecmema);
                rdwr = NREC_RDWR(info->nrecmema);
index 077313f..7d0f00a 100644 (file)
@@ -702,7 +702,7 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
                if (encoder->crtc != crtc)
                        continue;
 
-               DRM_INFO("%s: set mode %s %x\n", drm_get_encoder_name(encoder),
+               DRM_DEBUG("%s: set mode %s %x\n", drm_get_encoder_name(encoder),
                         mode->name, mode->base.id);
                encoder_funcs = encoder->helper_private;
                encoder_funcs->mode_set(encoder, mode, adjusted_mode);
@@ -1032,7 +1032,8 @@ bool drm_helper_initial_config(struct drm_device *dev)
        /*
         * we shouldn't end up with no modes here.
         */
-       printk(KERN_INFO "No connectors reported conncted with modes\n");
+       if (count == 0)
+               printk(KERN_INFO "No connectors reported connected with modes\n");
 
        drm_setup_crtcs(dev);
 
index bbe4781..e660ac0 100644 (file)
@@ -134,6 +134,10 @@ static int i915_init_phys_hws(struct drm_device *dev)
 
        memset(dev_priv->hw_status_page, 0, PAGE_SIZE);
 
+       if (IS_I965G(dev))
+               dev_priv->dma_status_page |= (dev_priv->dma_status_page >> 28) &
+                                            0xf0;
+
        I915_WRITE(HWS_PGA, dev_priv->dma_status_page);
        DRM_DEBUG_DRIVER("Enabled hardware status page\n");
        return 0;
index be631cc..46d8896 100644 (file)
@@ -45,6 +45,9 @@ module_param_named(fbpercrtc, i915_fbpercrtc, int, 0400);
 unsigned int i915_powersave = 1;
 module_param_named(powersave, i915_powersave, int, 0400);
 
+unsigned int i915_lvds_downclock = 0;
+module_param_named(lvds_downclock, i915_lvds_downclock, int, 0400);
+
 static struct drm_driver driver;
 
 #define INTEL_VGA_DEVICE(id, info) {           \
@@ -464,8 +467,11 @@ static struct drm_driver driver = {
        .lastclose = i915_driver_lastclose,
        .preclose = i915_driver_preclose,
        .postclose = i915_driver_postclose,
+
+       /* Used in place of i915_pm_ops for non-DRIVER_MODESET */
        .suspend = i915_suspend,
        .resume = i915_resume,
+
        .device_is_agp = i915_driver_device_is_agp,
        .enable_vblank = i915_enable_vblank,
        .disable_vblank = i915_disable_vblank,
index 29dd676..2c16694 100644 (file)
@@ -283,6 +283,7 @@ typedef struct drm_i915_private {
        unsigned int lvds_use_ssc:1;
        unsigned int edp_support:1;
        int lvds_ssc_freq;
+       int edp_bpp;
 
        struct notifier_block lid_notifier;
 
@@ -722,6 +723,7 @@ extern struct drm_ioctl_desc i915_ioctls[];
 extern int i915_max_ioctl;
 extern unsigned int i915_fbpercrtc;
 extern unsigned int i915_powersave;
+extern unsigned int i915_lvds_downclock;
 
 extern void i915_save_display(struct drm_device *dev);
 extern void i915_restore_display(struct drm_device *dev);
@@ -864,6 +866,7 @@ int i915_do_wait_request(struct drm_device *dev, uint32_t seqno, int interruptib
 int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
 int i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj,
                                      int write);
+int i915_gem_object_set_to_display_plane(struct drm_gem_object *obj);
 int i915_gem_attach_phys_object(struct drm_device *dev,
                                struct drm_gem_object *obj, int id);
 void i915_gem_detach_phys_object(struct drm_device *dev,
index 2748609..0c67924 100644 (file)
@@ -2837,6 +2837,57 @@ i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj, int write)
        return 0;
 }
 
+/*
+ * Prepare buffer for display plane. Use uninterruptible for possible flush
+ * wait, as in modesetting process we're not supposed to be interrupted.
+ */
+int
+i915_gem_object_set_to_display_plane(struct drm_gem_object *obj)
+{
+       struct drm_device *dev = obj->dev;
+       struct drm_i915_gem_object *obj_priv = obj->driver_private;
+       uint32_t old_write_domain, old_read_domains;
+       int ret;
+
+       /* Not valid to be called on unbound objects. */
+       if (obj_priv->gtt_space == NULL)
+               return -EINVAL;
+
+       i915_gem_object_flush_gpu_write_domain(obj);
+
+       /* Wait on any GPU rendering and flushing to occur. */
+       if (obj_priv->active) {
+#if WATCH_BUF
+               DRM_INFO("%s: object %p wait for seqno %08x\n",
+                         __func__, obj, obj_priv->last_rendering_seqno);
+#endif
+               ret = i915_do_wait_request(dev, obj_priv->last_rendering_seqno, 0);
+               if (ret != 0)
+                       return ret;
+       }
+
+       old_write_domain = obj->write_domain;
+       old_read_domains = obj->read_domains;
+
+       obj->read_domains &= I915_GEM_DOMAIN_GTT;
+
+       i915_gem_object_flush_cpu_write_domain(obj);
+
+       /* It should now be out of any other write domains, and we can update
+        * the domain values for our changes.
+        */
+       BUG_ON((obj->write_domain & ~I915_GEM_DOMAIN_GTT) != 0);
+       obj->read_domains |= I915_GEM_DOMAIN_GTT;
+       obj->write_domain = I915_GEM_DOMAIN_GTT;
+       obj_priv->dirty = 1;
+
+       trace_i915_gem_object_change_domain(obj,
+                                           old_read_domains,
+                                           old_write_domain);
+
+       return 0;
+}
+
 /**
  * Moves a single object to the CPU read, and possibly write domain.
  *
@@ -4000,8 +4051,6 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
                                  "back to user (%d)\n",
                                  args->buffer_count, ret);
                }
-       } else {
-               DRM_ERROR("i915_gem_do_execbuffer returns %d\n", ret);
        }
 
        drm_free_large(exec_list);
index 7cd8110..89a071a 100644 (file)
@@ -274,7 +274,6 @@ irqreturn_t ironlake_irq_handler(struct drm_device *dev)
        drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
        int ret = IRQ_NONE;
        u32 de_iir, gt_iir, de_ier, pch_iir;
-       u32 new_de_iir, new_gt_iir, new_pch_iir;
        struct drm_i915_master_private *master_priv;
 
        /* disable master interrupt before clearing iir  */
@@ -286,51 +285,42 @@ irqreturn_t ironlake_irq_handler(struct drm_device *dev)
        gt_iir = I915_READ(GTIIR);
        pch_iir = I915_READ(SDEIIR);
 
-       for (;;) {
-               if (de_iir == 0 && gt_iir == 0 && pch_iir == 0)
-                       break;
-
-               ret = IRQ_HANDLED;
+       if (de_iir == 0 && gt_iir == 0 && pch_iir == 0)
+               goto done;
 
-               /* should clear PCH hotplug event before clear CPU irq */
-               I915_WRITE(SDEIIR, pch_iir);
-               new_pch_iir = I915_READ(SDEIIR);
+       ret = IRQ_HANDLED;
 
-               I915_WRITE(DEIIR, de_iir);
-               new_de_iir = I915_READ(DEIIR);
-               I915_WRITE(GTIIR, gt_iir);
-               new_gt_iir = I915_READ(GTIIR);
-
-               if (dev->primary->master) {
-                       master_priv = dev->primary->master->driver_priv;
-                       if (master_priv->sarea_priv)
-                               master_priv->sarea_priv->last_dispatch =
-                                       READ_BREADCRUMB(dev_priv);
-               }
-
-               if (gt_iir & GT_USER_INTERRUPT) {
-                       u32 seqno = i915_get_gem_seqno(dev);
-                       dev_priv->mm.irq_gem_seqno = seqno;
-                       trace_i915_gem_request_complete(dev, seqno);
-                       DRM_WAKEUP(&dev_priv->irq_queue);
-                       dev_priv->hangcheck_count = 0;
-                       mod_timer(&dev_priv->hangcheck_timer, jiffies + DRM_I915_HANGCHECK_PERIOD);
-               }
+       if (dev->primary->master) {
+               master_priv = dev->primary->master->driver_priv;
+               if (master_priv->sarea_priv)
+                       master_priv->sarea_priv->last_dispatch =
+                               READ_BREADCRUMB(dev_priv);
+       }
 
-               if (de_iir & DE_GSE)
-                       ironlake_opregion_gse_intr(dev);
+       if (gt_iir & GT_USER_INTERRUPT) {
+               u32 seqno = i915_get_gem_seqno(dev);
+               dev_priv->mm.irq_gem_seqno = seqno;
+               trace_i915_gem_request_complete(dev, seqno);
+               DRM_WAKEUP(&dev_priv->irq_queue);
+               dev_priv->hangcheck_count = 0;
+               mod_timer(&dev_priv->hangcheck_timer, jiffies + DRM_I915_HANGCHECK_PERIOD);
+       }
 
-               /* check event from PCH */
-               if ((de_iir & DE_PCH_EVENT) &&
-                       (pch_iir & SDE_HOTPLUG_MASK)) {
-                       queue_work(dev_priv->wq, &dev_priv->hotplug_work);
-               }
+       if (de_iir & DE_GSE)
+               ironlake_opregion_gse_intr(dev);
 
-               de_iir = new_de_iir;
-               gt_iir = new_gt_iir;
-               pch_iir = new_pch_iir;
+       /* check event from PCH */
+       if ((de_iir & DE_PCH_EVENT) &&
+           (pch_iir & SDE_HOTPLUG_MASK)) {
+               queue_work(dev_priv->wq, &dev_priv->hotplug_work);
        }
 
+       /* should clear PCH hotplug event before clear CPU irq */
+       I915_WRITE(SDEIIR, pch_iir);
+       I915_WRITE(GTIIR, gt_iir);
+       I915_WRITE(DEIIR, de_iir);
+
+done:
        I915_WRITE(DEIER, de_ier);
        (void)I915_READ(DEIER);
 
index 149d360..847006c 100644 (file)
 #define   DSPFW_PLANEB_SHIFT   8
 #define DSPFW2                 0x70038
 #define   DSPFW_CURSORA_MASK   0x00003f00
-#define   DSPFW_CURSORA_SHIFT  16
+#define   DSPFW_CURSORA_SHIFT  8
 #define DSPFW3                 0x7003c
 #define   DSPFW_HPLL_SR_EN     (1<<31)
 #define   DSPFW_CURSOR_SR_SHIFT        24
index f275677..15fbc1b 100644 (file)
@@ -33,6 +33,8 @@
 #define        SLAVE_ADDR1     0x70
 #define        SLAVE_ADDR2     0x72
 
+static int panel_type;
+
 static void *
 find_section(struct bdb_header *bdb, int section_id)
 {
@@ -128,6 +130,7 @@ parse_lfp_panel_data(struct drm_i915_private *dev_priv,
        dev_priv->lvds_dither = lvds_options->pixel_dither;
        if (lvds_options->panel_type == 0xff)
                return;
+       panel_type = lvds_options->panel_type;
 
        lvds_lfp_data = find_section(bdb, BDB_LVDS_LFP_DATA);
        if (!lvds_lfp_data)
@@ -197,7 +200,8 @@ parse_lfp_panel_data(struct drm_i915_private *dev_priv,
                memset(temp_mode, 0, sizeof(*temp_mode));
        }
        kfree(temp_mode);
-       if (temp_downclock < panel_fixed_mode->clock) {
+       if (temp_downclock < panel_fixed_mode->clock &&
+           i915_lvds_downclock) {
                dev_priv->lvds_downclock_avail = 1;
                dev_priv->lvds_downclock = temp_downclock;
                DRM_DEBUG_KMS("LVDS downclock is found in VBT. ",
@@ -405,6 +409,34 @@ parse_driver_features(struct drm_i915_private *dev_priv,
 }
 
 static void
+parse_edp(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
+{
+       struct bdb_edp *edp;
+
+       edp = find_section(bdb, BDB_EDP);
+       if (!edp) {
+               if (SUPPORTS_EDP(dev_priv->dev) && dev_priv->edp_support) {
+                       DRM_DEBUG_KMS("No eDP BDB found but eDP panel supported,\
+                                      assume 18bpp panel color depth.\n");
+                       dev_priv->edp_bpp = 18;
+               }
+               return;
+       }
+
+       switch ((edp->color_depth >> (panel_type * 2)) & 3) {
+       case EDP_18BPP:
+               dev_priv->edp_bpp = 18;
+               break;
+       case EDP_24BPP:
+               dev_priv->edp_bpp = 24;
+               break;
+       case EDP_30BPP:
+               dev_priv->edp_bpp = 30;
+               break;
+       }
+}
+
+static void
 parse_device_mapping(struct drm_i915_private *dev_priv,
                       struct bdb_header *bdb)
 {
@@ -521,6 +553,7 @@ intel_init_bios(struct drm_device *dev)
        parse_sdvo_device_mapping(dev_priv, bdb);
        parse_device_mapping(dev_priv, bdb);
        parse_driver_features(dev_priv, bdb);
+       parse_edp(dev_priv, bdb);
 
        pci_unmap_rom(pdev, bios);
 
index 425ac9d..4c18514 100644 (file)
@@ -98,6 +98,7 @@ struct vbios_data {
 #define BDB_SDVO_LVDS_PNP_IDS   24
 #define BDB_SDVO_LVDS_POWER_SEQ         25
 #define BDB_TV_OPTIONS          26
+#define BDB_EDP                         27
 #define BDB_LVDS_OPTIONS        40
 #define BDB_LVDS_LFP_DATA_PTRS  41
 #define BDB_LVDS_LFP_DATA       42
@@ -426,6 +427,45 @@ struct bdb_driver_features {
        u8 custom_vbt_version;
 } __attribute__((packed));
 
+#define EDP_18BPP      0
+#define EDP_24BPP      1
+#define EDP_30BPP      2
+#define EDP_RATE_1_62  0
+#define EDP_RATE_2_7   1
+#define EDP_LANE_1     0
+#define EDP_LANE_2     1
+#define EDP_LANE_4     3
+#define EDP_PREEMPHASIS_NONE   0
+#define EDP_PREEMPHASIS_3_5dB  1
+#define EDP_PREEMPHASIS_6dB    2
+#define EDP_PREEMPHASIS_9_5dB  3
+#define EDP_VSWING_0_4V                0
+#define EDP_VSWING_0_6V                1
+#define EDP_VSWING_0_8V                2
+#define EDP_VSWING_1_2V                3
+
+struct edp_power_seq {
+       u16 t3;
+       u16 t7;
+       u16 t9;
+       u16 t10;
+       u16 t12;
+} __attribute__ ((packed));
+
+struct edp_link_params {
+       u8 rate:4;
+       u8 lanes:4;
+       u8 preemphasis:4;
+       u8 vswing:4;
+} __attribute__ ((packed));
+
+struct bdb_edp {
+       struct edp_power_seq power_seqs[16];
+       u32 color_depth;
+       u32 sdrrs_msa_timing_delay;
+       struct edp_link_params link_params[16];
+} __attribute__ ((packed));
+
 bool intel_init_bios(struct drm_device *dev);
 
 /*
index 002612f..45da78e 100644 (file)
@@ -70,8 +70,6 @@ struct intel_limit {
     intel_p2_t     p2;
     bool (* find_pll)(const intel_limit_t *, struct drm_crtc *,
                      int, int, intel_clock_t *);
-    bool (* find_reduced_pll)(const intel_limit_t *, struct drm_crtc *,
-                             int, int, intel_clock_t *);
 };
 
 #define I8XX_DOT_MIN             25000
@@ -243,11 +241,11 @@ struct intel_limit {
 #define IRONLAKE_VCO_MIN         1760000
 #define IRONLAKE_VCO_MAX         3510000
 #define IRONLAKE_N_MIN           1
-#define IRONLAKE_N_MAX           5
+#define IRONLAKE_N_MAX           6
 #define IRONLAKE_M_MIN           79
-#define IRONLAKE_M_MAX           118
+#define IRONLAKE_M_MAX           127
 #define IRONLAKE_M1_MIN          12
-#define IRONLAKE_M1_MAX          23
+#define IRONLAKE_M1_MAX          22
 #define IRONLAKE_M2_MIN          5
 #define IRONLAKE_M2_MAX          9
 #define IRONLAKE_P_SDVO_DAC_MIN  5
@@ -274,9 +272,6 @@ static bool
 intel_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
                    int target, int refclk, intel_clock_t *best_clock);
 static bool
-intel_find_best_reduced_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
-                           int target, int refclk, intel_clock_t *best_clock);
-static bool
 intel_g4x_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
                        int target, int refclk, intel_clock_t *best_clock);
 
@@ -299,7 +294,6 @@ static const intel_limit_t intel_limits_i8xx_dvo = {
        .p2  = { .dot_limit = I8XX_P2_SLOW_LIMIT,
                 .p2_slow = I8XX_P2_SLOW,       .p2_fast = I8XX_P2_FAST },
        .find_pll = intel_find_best_PLL,
-       .find_reduced_pll = intel_find_best_reduced_PLL,
 };
 
 static const intel_limit_t intel_limits_i8xx_lvds = {
@@ -314,7 +308,6 @@ static const intel_limit_t intel_limits_i8xx_lvds = {
        .p2  = { .dot_limit = I8XX_P2_SLOW_LIMIT,
                 .p2_slow = I8XX_P2_LVDS_SLOW,  .p2_fast = I8XX_P2_LVDS_FAST },
        .find_pll = intel_find_best_PLL,
-       .find_reduced_pll = intel_find_best_reduced_PLL,
 };
        
 static const intel_limit_t intel_limits_i9xx_sdvo = {
@@ -329,7 +322,6 @@ static const intel_limit_t intel_limits_i9xx_sdvo = {
        .p2  = { .dot_limit = I9XX_P2_SDVO_DAC_SLOW_LIMIT,
                 .p2_slow = I9XX_P2_SDVO_DAC_SLOW,      .p2_fast = I9XX_P2_SDVO_DAC_FAST },
        .find_pll = intel_find_best_PLL,
-       .find_reduced_pll = intel_find_best_reduced_PLL,
 };
 
 static const intel_limit_t intel_limits_i9xx_lvds = {
@@ -347,7 +339,6 @@ static const intel_limit_t intel_limits_i9xx_lvds = {
        .p2  = { .dot_limit = I9XX_P2_LVDS_SLOW_LIMIT,
                 .p2_slow = I9XX_P2_LVDS_SLOW,  .p2_fast = I9XX_P2_LVDS_FAST },
        .find_pll = intel_find_best_PLL,
-       .find_reduced_pll = intel_find_best_reduced_PLL,
 };
 
     /* below parameter and function is for G4X Chipset Family*/
@@ -365,7 +356,6 @@ static const intel_limit_t intel_limits_g4x_sdvo = {
                 .p2_fast = G4X_P2_SDVO_FAST
        },
        .find_pll = intel_g4x_find_best_PLL,
-       .find_reduced_pll = intel_g4x_find_best_PLL,
 };
 
 static const intel_limit_t intel_limits_g4x_hdmi = {
@@ -382,7 +372,6 @@ static const intel_limit_t intel_limits_g4x_hdmi = {
                 .p2_fast = G4X_P2_HDMI_DAC_FAST
        },
        .find_pll = intel_g4x_find_best_PLL,
-       .find_reduced_pll = intel_g4x_find_best_PLL,
 };
 
 static const intel_limit_t intel_limits_g4x_single_channel_lvds = {
@@ -407,7 +396,6 @@ static const intel_limit_t intel_limits_g4x_single_channel_lvds = {
                 .p2_fast = G4X_P2_SINGLE_CHANNEL_LVDS_FAST
        },
        .find_pll = intel_g4x_find_best_PLL,
-       .find_reduced_pll = intel_g4x_find_best_PLL,
 };
 
 static const intel_limit_t intel_limits_g4x_dual_channel_lvds = {
@@ -432,7 +420,6 @@ static const intel_limit_t intel_limits_g4x_dual_channel_lvds = {
                 .p2_fast = G4X_P2_DUAL_CHANNEL_LVDS_FAST
        },
        .find_pll = intel_g4x_find_best_PLL,
-       .find_reduced_pll = intel_g4x_find_best_PLL,
 };
 
 static const intel_limit_t intel_limits_g4x_display_port = {
@@ -470,7 +457,6 @@ static const intel_limit_t intel_limits_pineview_sdvo = {
        .p2  = { .dot_limit = I9XX_P2_SDVO_DAC_SLOW_LIMIT,
                 .p2_slow = I9XX_P2_SDVO_DAC_SLOW,      .p2_fast = I9XX_P2_SDVO_DAC_FAST },
        .find_pll = intel_find_best_PLL,
-       .find_reduced_pll = intel_find_best_reduced_PLL,
 };
 
 static const intel_limit_t intel_limits_pineview_lvds = {
@@ -486,7 +472,6 @@ static const intel_limit_t intel_limits_pineview_lvds = {
        .p2  = { .dot_limit = I9XX_P2_LVDS_SLOW_LIMIT,
                 .p2_slow = I9XX_P2_LVDS_SLOW,  .p2_fast = I9XX_P2_LVDS_SLOW },
        .find_pll = intel_find_best_PLL,
-       .find_reduced_pll = intel_find_best_reduced_PLL,
 };
 
 static const intel_limit_t intel_limits_ironlake_sdvo = {
@@ -768,46 +753,6 @@ intel_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
        return (err != target);
 }
 
-
-static bool
-intel_find_best_reduced_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
-                           int target, int refclk, intel_clock_t *best_clock)
-
-{
-       struct drm_device *dev = crtc->dev;
-       intel_clock_t clock;
-       int err = target;
-       bool found = false;
-
-       memcpy(&clock, best_clock, sizeof(intel_clock_t));
-
-       for (clock.m1 = limit->m1.min; clock.m1 <= limit->m1.max; clock.m1++) {
-               for (clock.m2 = limit->m2.min; clock.m2 <= limit->m2.max; clock.m2++) {
-                       /* m1 is always 0 in Pineview */
-                       if (clock.m2 >= clock.m1 && !IS_PINEVIEW(dev))
-                               break;
-                       for (clock.n = limit->n.min; clock.n <= limit->n.max;
-                            clock.n++) {
-                               int this_err;
-
-                               intel_clock(dev, refclk, &clock);
-
-                               if (!intel_PLL_is_valid(crtc, &clock))
-                                       continue;
-
-                               this_err = abs(clock.dot - target);
-                               if (this_err < err) {
-                                       *best_clock = clock;
-                                       err = this_err;
-                                       found = true;
-                               }
-                       }
-               }
-       }
-
-       return found;
-}
-
 static bool
 intel_g4x_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
                        int target, int refclk, intel_clock_t *best_clock)
@@ -1262,7 +1207,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
                return ret;
        }
 
-       ret = i915_gem_object_set_to_gtt_domain(obj, 1);
+       ret = i915_gem_object_set_to_display_plane(obj);
        if (ret != 0) {
                i915_gem_object_unpin(obj);
                mutex_unlock(&dev->struct_mutex);
@@ -2910,10 +2855,8 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
                return -EINVAL;
        }
 
-       if (is_lvds && limit->find_reduced_pll &&
-                       dev_priv->lvds_downclock_avail) {
-               memcpy(&reduced_clock, &clock, sizeof(intel_clock_t));
-               has_reduced_clock = limit->find_reduced_pll(limit, crtc,
+       if (is_lvds && dev_priv->lvds_downclock_avail) {
+               has_reduced_clock = limit->find_pll(limit, crtc,
                                                            dev_priv->lvds_downclock,
                                                            refclk,
                                                            &reduced_clock);
@@ -2981,6 +2924,21 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
                                temp |= PIPE_8BPC;
                        else
                                temp |= PIPE_6BPC;
+               } else if (is_edp) {
+                       switch (dev_priv->edp_bpp/3) {
+                       case 8:
+                               temp |= PIPE_8BPC;
+                               break;
+                       case 10:
+                               temp |= PIPE_10BPC;
+                               break;
+                       case 6:
+                               temp |= PIPE_6BPC;
+                               break;
+                       case 12:
+                               temp |= PIPE_12BPC;
+                               break;
+                       }
                } else
                        temp |= PIPE_8BPC;
                I915_WRITE(pipeconf_reg, temp);
index 1349d9f..439506c 100644 (file)
@@ -125,9 +125,15 @@ intel_dp_link_clock(uint8_t link_bw)
 
 /* I think this is a fiction */
 static int
-intel_dp_link_required(int pixel_clock)
+intel_dp_link_required(struct drm_device *dev,
+                      struct intel_output *intel_output, int pixel_clock)
 {
-       return pixel_clock * 3;
+       struct drm_i915_private *dev_priv = dev->dev_private;
+
+       if (IS_eDP(intel_output))
+               return (pixel_clock * dev_priv->edp_bpp) / 8;
+       else
+               return pixel_clock * 3;
 }
 
 static int
@@ -138,7 +144,8 @@ intel_dp_mode_valid(struct drm_connector *connector,
        int max_link_clock = intel_dp_link_clock(intel_dp_max_link_bw(intel_output));
        int max_lanes = intel_dp_max_lane_count(intel_output);
 
-       if (intel_dp_link_required(mode->clock) > max_link_clock * max_lanes)
+       if (intel_dp_link_required(connector->dev, intel_output, mode->clock)
+                       > max_link_clock * max_lanes)
                return MODE_CLOCK_HIGH;
 
        if (mode->clock < 10000)
@@ -492,7 +499,8 @@ intel_dp_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
                for (clock = 0; clock <= max_clock; clock++) {
                        int link_avail = intel_dp_link_clock(bws[clock]) * lane_count;
 
-                       if (intel_dp_link_required(mode->clock) <= link_avail) {
+                       if (intel_dp_link_required(encoder->dev, intel_output, mode->clock)
+                                       <= link_avail) {
                                dp_priv->link_bw = bws[clock];
                                dp_priv->lane_count = lane_count;
                                adjusted_mode->clock = intel_dp_link_clock(dp_priv->link_bw);
@@ -1289,53 +1297,7 @@ intel_dp_hot_plug(struct intel_output *intel_output)
        if (dp_priv->dpms_mode == DRM_MODE_DPMS_ON)
                intel_dp_check_link_status(intel_output);
 }
-/*
- * Enumerate the child dev array parsed from VBT to check whether
- * the given DP is present.
- * If it is present, return 1.
- * If it is not present, return false.
- * If no child dev is parsed from VBT, it is assumed that the given
- * DP is present.
- */
-static int dp_is_present_in_vbt(struct drm_device *dev, int dp_reg)
-{
-       struct drm_i915_private *dev_priv = dev->dev_private;
-       struct child_device_config *p_child;
-       int i, dp_port, ret;
-
-       if (!dev_priv->child_dev_num)
-               return 1;
-
-       dp_port = 0;
-       if (dp_reg == DP_B || dp_reg == PCH_DP_B)
-               dp_port = PORT_IDPB;
-       else if (dp_reg == DP_C || dp_reg == PCH_DP_C)
-               dp_port = PORT_IDPC;
-       else if (dp_reg == DP_D || dp_reg == PCH_DP_D)
-               dp_port = PORT_IDPD;
-
-       ret = 0;
-       for (i = 0; i < dev_priv->child_dev_num; i++) {
-               p_child = dev_priv->child_dev + i;
-               /*
-                * If the device type is not DP, continue.
-                */
-               if (p_child->device_type != DEVICE_TYPE_DP &&
-                       p_child->device_type != DEVICE_TYPE_eDP)
-                       continue;
-               /* Find the eDP port */
-               if (dp_reg == DP_A && p_child->device_type == DEVICE_TYPE_eDP) {
-                       ret = 1;
-                       break;
-               }
-               /* Find the DP port */
-               if (p_child->dvo_port == dp_port) {
-                       ret = 1;
-                       break;
-               }
-       }
-       return ret;
-}
+
 void
 intel_dp_init(struct drm_device *dev, int output_reg)
 {
@@ -1345,10 +1307,6 @@ intel_dp_init(struct drm_device *dev, int output_reg)
        struct intel_dp_priv *dp_priv;
        const char *name = NULL;
 
-       if (!dp_is_present_in_vbt(dev, output_reg)) {
-               DRM_DEBUG_KMS("DP is not present. Ignore it\n");
-               return;
-       }
        intel_output = kcalloc(sizeof(struct intel_output) + 
                               sizeof(struct intel_dp_priv), 1, GFP_KERNEL);
        if (!intel_output)
@@ -1373,11 +1331,10 @@ intel_dp_init(struct drm_device *dev, int output_reg)
        else if (output_reg == DP_D || output_reg == PCH_DP_D)
                intel_output->clone_mask = (1 << INTEL_DP_D_CLONE_BIT);
 
-       if (IS_eDP(intel_output)) {
-               intel_output->crtc_mask = (1 << 1);
+       if (IS_eDP(intel_output))
                intel_output->clone_mask = (1 << INTEL_EDP_CLONE_BIT);
-       } else
-               intel_output->crtc_mask = (1 << 0) | (1 << 1);
+
+       intel_output->crtc_mask = (1 << 0) | (1 << 1);
        connector->interlace_allowed = true;
        connector->doublescan_allowed = 0;
 
index 0643194..0e268de 100644 (file)
@@ -225,52 +225,6 @@ static const struct drm_encoder_funcs intel_hdmi_enc_funcs = {
        .destroy = intel_hdmi_enc_destroy,
 };
 
-/*
- * Enumerate the child dev array parsed from VBT to check whether
- * the given HDMI is present.
- * If it is present, return 1.
- * If it is not present, return false.
- * If no child dev is parsed from VBT, it assumes that the given
- * HDMI is present.
- */
-static int hdmi_is_present_in_vbt(struct drm_device *dev, int hdmi_reg)
-{
-       struct drm_i915_private *dev_priv = dev->dev_private;
-       struct child_device_config *p_child;
-       int i, hdmi_port, ret;
-
-       if (!dev_priv->child_dev_num)
-               return 1;
-
-       if (hdmi_reg == SDVOB)
-               hdmi_port = DVO_B;
-       else if (hdmi_reg == SDVOC)
-               hdmi_port = DVO_C;
-       else if (hdmi_reg == HDMIB)
-               hdmi_port = DVO_B;
-       else if (hdmi_reg == HDMIC)
-               hdmi_port = DVO_C;
-       else if (hdmi_reg == HDMID)
-               hdmi_port = DVO_D;
-       else
-               return 0;
-
-       ret = 0;
-       for (i = 0; i < dev_priv->child_dev_num; i++) {
-               p_child = dev_priv->child_dev + i;
-               /*
-                * If the device type is not HDMI, continue.
-                */
-               if (p_child->device_type != DEVICE_TYPE_HDMI)
-                       continue;
-               /* Find the HDMI port */
-               if (p_child->dvo_port == hdmi_port) {
-                       ret = 1;
-                       break;
-               }
-       }
-       return ret;
-}
 void intel_hdmi_init(struct drm_device *dev, int sdvox_reg)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
@@ -278,10 +232,6 @@ void intel_hdmi_init(struct drm_device *dev, int sdvox_reg)
        struct intel_output *intel_output;
        struct intel_hdmi_priv *hdmi_priv;
 
-       if (!hdmi_is_present_in_vbt(dev, sdvox_reg)) {
-               DRM_DEBUG_KMS("HDMI is not present. Ignored it \n");
-               return;
-       }
        intel_output = kcalloc(sizeof(struct intel_output) +
                               sizeof(struct intel_hdmi_priv), 1, GFP_KERNEL);
        if (!intel_output)
index f4b4aa2..aa74e59 100644 (file)
@@ -602,6 +602,20 @@ static void intel_lvds_mode_set(struct drm_encoder *encoder,
 /* Some lid devices report incorrect lid status, assume they're connected */
 static const struct dmi_system_id bad_lid_status[] = {
        {
+               .ident = "Compaq nx9020",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
+                       DMI_MATCH(DMI_BOARD_NAME, "3084"),
+               },
+       },
+       {
+               .ident = "Samsung SX20S",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Phoenix Technologies LTD"),
+                       DMI_MATCH(DMI_BOARD_NAME, "SX20S"),
+               },
+       },
+       {
                .ident = "Aspire One",
                .matches = {
                        DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
@@ -912,7 +926,8 @@ static void intel_find_lvds_downclock(struct drm_device *dev,
                }
        }
        mutex_unlock(&dev->mode_config.mutex);
-       if (temp_downclock < panel_fixed_mode->clock) {
+       if (temp_downclock < panel_fixed_mode->clock &&
+           i915_lvds_downclock) {
                /* We found the downclock for LVDS. */
                dev_priv->lvds_downclock_avail = 1;
                dev_priv->lvds_downclock = temp_downclock;
index de5144c..eaacfd0 100644 (file)
@@ -462,14 +462,63 @@ static int intel_sdvo_get_pixel_multiplier(struct drm_display_mode *mode)
 }
 
 /**
- * Don't check status code from this as it switches the bus back to the
- * SDVO chips which defeats the purpose of doing a bus switch in the first
- * place.
+ * Try to read the response after issuie the DDC switch command. But it
+ * is noted that we must do the action of reading response and issuing DDC
+ * switch command in one I2C transaction. Otherwise when we try to start
+ * another I2C transaction after issuing the DDC bus switch, it will be
+ * switched to the internal SDVO register.
  */
 static void intel_sdvo_set_control_bus_switch(struct intel_output *intel_output,
                                              u8 target)
 {
-       intel_sdvo_write_cmd(intel_output, SDVO_CMD_SET_CONTROL_BUS_SWITCH, &target, 1);
+       struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
+       u8 out_buf[2], cmd_buf[2], ret_value[2], ret;
+       struct i2c_msg msgs[] = {
+               {
+                       .addr = sdvo_priv->slave_addr >> 1,
+                       .flags = 0,
+                       .len = 2,
+                       .buf = out_buf,
+               },
+               /* the following two are to read the response */
+               {
+                       .addr = sdvo_priv->slave_addr >> 1,
+                       .flags = 0,
+                       .len = 1,
+                       .buf = cmd_buf,
+               },
+               {
+                       .addr = sdvo_priv->slave_addr >> 1,
+                       .flags = I2C_M_RD,
+                       .len = 1,
+                       .buf = ret_value,
+               },
+       };
+
+       intel_sdvo_debug_write(intel_output, SDVO_CMD_SET_CONTROL_BUS_SWITCH,
+                                       &target, 1);
+       /* write the DDC switch command argument */
+       intel_sdvo_write_byte(intel_output, SDVO_I2C_ARG_0, target);
+
+       out_buf[0] = SDVO_I2C_OPCODE;
+       out_buf[1] = SDVO_CMD_SET_CONTROL_BUS_SWITCH;
+       cmd_buf[0] = SDVO_I2C_CMD_STATUS;
+       cmd_buf[1] = 0;
+       ret_value[0] = 0;
+       ret_value[1] = 0;
+
+       ret = i2c_transfer(intel_output->i2c_bus, msgs, 3);
+       if (ret != 3) {
+               /* failure in I2C transfer */
+               DRM_DEBUG_KMS("I2c transfer returned %d\n", ret);
+               return;
+       }
+       if (ret_value[0] != SDVO_CMD_STATUS_SUCCESS) {
+               DRM_DEBUG_KMS("DDC switch command returns response %d\n",
+                                       ret_value[0]);
+               return;
+       }
+       return;
 }
 
 static bool intel_sdvo_set_target_input(struct intel_output *intel_output, bool target_0, bool target_1)
@@ -1579,6 +1628,32 @@ intel_sdvo_hdmi_sink_detect(struct drm_connector *connector, u16 response)
        edid = drm_get_edid(&intel_output->base,
                            intel_output->ddc_bus);
 
+       /* This is only applied to SDVO cards with multiple outputs */
+       if (edid == NULL && intel_sdvo_multifunc_encoder(intel_output)) {
+               uint8_t saved_ddc, temp_ddc;
+               saved_ddc = sdvo_priv->ddc_bus;
+               temp_ddc = sdvo_priv->ddc_bus >> 1;
+               /*
+                * Don't use the 1 as the argument of DDC bus switch to get
+                * the EDID. It is used for SDVO SPD ROM.
+                */
+               while(temp_ddc > 1) {
+                       sdvo_priv->ddc_bus = temp_ddc;
+                       edid = drm_get_edid(&intel_output->base,
+                               intel_output->ddc_bus);
+                       if (edid) {
+                               /*
+                                * When we can get the EDID, maybe it is the
+                                * correct DDC bus. Update it.
+                                */
+                               sdvo_priv->ddc_bus = temp_ddc;
+                               break;
+                       }
+                       temp_ddc >>= 1;
+               }
+               if (edid == NULL)
+                       sdvo_priv->ddc_bus = saved_ddc;
+       }
        /* when there is no edid and no monitor is connected with VGA
         * port, try to use the CRT ddc to read the EDID for DVI-connector
         */
index 1d5b9b7..552ec11 100644 (file)
@@ -1840,8 +1840,6 @@ intel_tv_init(struct drm_device *dev)
        drm_connector_attach_property(connector,
                                   dev->mode_config.tv_bottom_margin_property,
                                   tv_priv->margin[TV_MARGIN_BOTTOM]);
-
-       dev_priv->hotplug_supported_mask |= TV_HOTPLUG_INT_STATUS;
 out:
        drm_sysfs_connector_add(connector);
 }
index c065199..f5ff349 100644 (file)
@@ -2729,7 +2729,7 @@ restart_ih:
                                }
                                break;
                        default:
-                               DRM_ERROR("Unhandled interrupt: %d %d\n", src_id, src_data);
+                               DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data);
                                break;
                        }
                        break;
@@ -2749,7 +2749,7 @@ restart_ih:
                                }
                                break;
                        default:
-                               DRM_ERROR("Unhandled interrupt: %d %d\n", src_id, src_data);
+                               DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data);
                                break;
                        }
                        break;
@@ -2798,7 +2798,7 @@ restart_ih:
                                }
                                break;
                        default:
-                               DRM_ERROR("Unhandled interrupt: %d %d\n", src_id, src_data);
+                               DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data);
                                break;
                        }
                        break;
@@ -2812,7 +2812,7 @@ restart_ih:
                        DRM_DEBUG("IH: CP EOP\n");
                        break;
                default:
-                       DRM_ERROR("Unhandled interrupt: %d %d\n", src_id, src_data);
+                       DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data);
                        break;
                }
 
index 7914455..579c892 100644 (file)
@@ -687,6 +687,9 @@ radeon_combios_get_tv_info(struct radeon_device *rdev)
        uint16_t tv_info;
        enum radeon_tv_std tv_std = TV_STD_NTSC;
 
+       if (rdev->bios == NULL)
+               return tv_std;
+
        tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
        if (tv_info) {
                if (RBIOS8(tv_info + 6) == 'T') {
index 9da10dd..5526641 100644 (file)
@@ -900,10 +900,18 @@ static void radeon_dvi_force(struct drm_connector *connector)
 static int radeon_dvi_mode_valid(struct drm_connector *connector,
                                  struct drm_display_mode *mode)
 {
+       struct drm_device *dev = connector->dev;
+       struct radeon_device *rdev = dev->dev_private;
        struct radeon_connector *radeon_connector = to_radeon_connector(connector);
 
        /* XXX check mode bandwidth */
 
+       /* clocks over 135 MHz have heat issues with DVI on RV100 */
+       if (radeon_connector->use_digital &&
+           (rdev->family == CHIP_RV100) &&
+           (mode->clock > 135000))
+               return MODE_CLOCK_HIGH;
+
        if (radeon_connector->use_digital && (mode->clock > 165000)) {
                if ((radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I) ||
                    (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D) ||
index 981508f..38e45e2 100644 (file)
@@ -46,6 +46,7 @@ static void radeon_legacy_lvds_dpms(struct drm_encoder *encoder, int mode)
        struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
        uint32_t lvds_gen_cntl, lvds_pll_cntl, pixclks_cntl, disp_pwr_man;
        int panel_pwr_delay = 2000;
+       bool is_mac = false;
        DRM_DEBUG("\n");
 
        if (radeon_encoder->enc_priv) {
@@ -58,6 +59,15 @@ static void radeon_legacy_lvds_dpms(struct drm_encoder *encoder, int mode)
                }
        }
 
+       /* macs (and possibly some x86 oem systems?) wire up LVDS strangely
+        * Taken from radeonfb.
+        */
+       if ((rdev->mode_info.connector_table == CT_IBOOK) ||
+           (rdev->mode_info.connector_table == CT_POWERBOOK_EXTERNAL) ||
+           (rdev->mode_info.connector_table == CT_POWERBOOK_INTERNAL) ||
+           (rdev->mode_info.connector_table == CT_POWERBOOK_VGA))
+               is_mac = true;
+
        switch (mode) {
        case DRM_MODE_DPMS_ON:
                disp_pwr_man = RREG32(RADEON_DISP_PWR_MAN);
@@ -74,6 +84,8 @@ static void radeon_legacy_lvds_dpms(struct drm_encoder *encoder, int mode)
 
                lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL);
                lvds_gen_cntl |= (RADEON_LVDS_ON | RADEON_LVDS_EN | RADEON_LVDS_DIGON | RADEON_LVDS_BLON);
+               if (is_mac)
+                       lvds_gen_cntl |= RADEON_LVDS_BL_MOD_EN;
                lvds_gen_cntl &= ~(RADEON_LVDS_DISPLAY_DIS);
                udelay(panel_pwr_delay * 1000);
                WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl);
@@ -85,7 +97,14 @@ static void radeon_legacy_lvds_dpms(struct drm_encoder *encoder, int mode)
                WREG32_PLL_P(RADEON_PIXCLKS_CNTL, 0, ~RADEON_PIXCLK_LVDS_ALWAYS_ONb);
                lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL);
                lvds_gen_cntl |= RADEON_LVDS_DISPLAY_DIS;
-               lvds_gen_cntl &= ~(RADEON_LVDS_ON | RADEON_LVDS_BLON | RADEON_LVDS_EN | RADEON_LVDS_DIGON);
+               if (is_mac) {
+                       lvds_gen_cntl &= ~RADEON_LVDS_BL_MOD_EN;
+                       WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl);
+                       lvds_gen_cntl &= ~(RADEON_LVDS_ON | RADEON_LVDS_EN);
+               } else {
+                       WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl);
+                       lvds_gen_cntl &= ~(RADEON_LVDS_ON | RADEON_LVDS_BLON | RADEON_LVDS_EN | RADEON_LVDS_DIGON);
+               }
                udelay(panel_pwr_delay * 1000);
                WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl);
                WREG32_PLL(RADEON_PIXCLKS_CNTL, pixclks_cntl);
index 3b0c07b..58b5adf 100644 (file)
@@ -215,7 +215,10 @@ static void radeon_evict_flags(struct ttm_buffer_object *bo,
        rbo = container_of(bo, struct radeon_bo, tbo);
        switch (bo->mem.mem_type) {
        case TTM_PL_VRAM:
-               radeon_ttm_placement_from_domain(rbo, RADEON_GEM_DOMAIN_GTT);
+               if (rbo->rdev->cp.ready == false)
+                       radeon_ttm_placement_from_domain(rbo, RADEON_GEM_DOMAIN_CPU);
+               else
+                       radeon_ttm_placement_from_domain(rbo, RADEON_GEM_DOMAIN_GTT);
                break;
        case TTM_PL_TT:
        default:
index 4b96e7a..5b4d66d 100644 (file)
@@ -431,6 +431,13 @@ static const struct hid_device_id apple_devices[] = {
                .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS),
                .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
+       { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
+               .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
+       { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
+               .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
+                       APPLE_ISO_KEYBOARD },
+       { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS),
+               .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY),
                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY),
index 80792d3..eabe5f8 100644 (file)
@@ -1285,6 +1285,9 @@ static const struct hid_device_id hid_blacklist[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) },
+       { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
+       { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
+       { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
        { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) },
@@ -1553,6 +1556,7 @@ static const struct hid_device_id hid_ignore_list[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) },
        { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) },
        { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) },
        { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) },
        { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) },
        { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0003) },
index 3839340..010368e 100644 (file)
@@ -88,6 +88,9 @@
 #define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI   0x0236
 #define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO    0x0237
 #define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS    0x0238
+#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI  0x0239
+#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO   0x023a
+#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS   0x023b
 #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY   0x030a
 #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY    0x030b
 #define USB_DEVICE_ID_APPLE_ATV_IRCONTROL      0x8241
 #define USB_VENDOR_ID_ESSENTIAL_REALITY        0x0d7f
 #define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100
 
+#define USB_VENDOR_ID_ETT              0x0664
+#define USB_DEVICE_ID_TC5UH            0x0309
+
 #define USB_VENDOR_ID_EZKEY            0x0518
 #define USB_DEVICE_ID_BTC_8193         0x0002
 
index 5b222ee..510dd13 100644 (file)
  *
  * 3. 135 byte report descriptor
  * Report #4 has an array field with logical range 0..17 instead of 1..14.
+ *
+ * 4. 171 byte report descriptor
+ * Report #3 has an array field with logical range 0..1 instead of 1..3.
  */
+static inline void samsung_dev_trace(struct hid_device *hdev,
+               unsigned int rsize)
+{
+       dev_info(&hdev->dev, "fixing up Samsung IrDA %d byte report "
+                       "descriptor\n", rsize);
+}
+
 static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
                unsigned int rsize)
 {
@@ -47,8 +57,7 @@ static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
                        rdesc[177] == 0x75 && rdesc[178] == 0x30 &&
                        rdesc[179] == 0x95 && rdesc[180] == 0x01 &&
                        rdesc[182] == 0x40) {
-               dev_info(&hdev->dev, "fixing up Samsung IrDA %d byte report "
-                               "descriptor\n", 184);
+               samsung_dev_trace(hdev, 184);
                rdesc[176] = 0xff;
                rdesc[178] = 0x08;
                rdesc[180] = 0x06;
@@ -56,17 +65,21 @@ static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
        } else
        if (rsize == 203 && rdesc[192] == 0x15 && rdesc[193] == 0x0 &&
                        rdesc[194] == 0x25 && rdesc[195] == 0x12) {
-               dev_info(&hdev->dev, "fixing up Samsung IrDA %d byte report "
-                               "descriptor\n", 203);
+               samsung_dev_trace(hdev, 203);
                rdesc[193] = 0x1;
                rdesc[195] = 0xf;
        } else
        if (rsize == 135 && rdesc[124] == 0x15 && rdesc[125] == 0x0 &&
                        rdesc[126] == 0x25 && rdesc[127] == 0x11) {
-               dev_info(&hdev->dev, "fixing up Samsung IrDA %d byte report "
-                               "descriptor\n", 135);
+               samsung_dev_trace(hdev, 135);
                rdesc[125] = 0x1;
                rdesc[127] = 0xe;
+       } else
+       if (rsize == 171 && rdesc[160] == 0x15 && rdesc[161] == 0x0 &&
+                       rdesc[162] == 0x25 && rdesc[163] == 0x01) {
+               samsung_dev_trace(hdev, 171);
+               rdesc[161] = 0x1;
+               rdesc[163] = 0x3;
        }
 }
 
index 7475421..12dcda5 100644 (file)
@@ -142,6 +142,7 @@ static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
                wdata->butstate = rw;
                input_report_key(input, BTN_0, rw & 0x02);
                input_report_key(input, BTN_1, rw & 0x01);
+               input_report_key(input, BTN_TOOL_FINGER, 0xf0);
                input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
                input_sync(input);
        }
@@ -196,6 +197,9 @@ static int wacom_probe(struct hid_device *hdev,
        /* Pad */
        input->evbit[0] |= BIT(EV_MSC);
        input->mscbit[0] |= BIT(MSC_SERIAL);
+       set_bit(BTN_0, input->keybit);
+       set_bit(BTN_1, input->keybit);
+       set_bit(BTN_TOOL_FINGER, input->keybit);
 
        /* Distance, rubber and mouse */
        input->absbit[0] |= BIT(ABS_DISTANCE);
index f70f465..4687af4 100644 (file)
@@ -87,9 +87,9 @@ static int ali1563_transaction(struct i2c_adapter * a, int size)
        outb_p(inb_p(SMB_HST_CNTL2) | HST_CNTL2_START, SMB_HST_CNTL2);
 
        timeout = ALI1563_MAX_TIMEOUT;
-       do
+       do {
                msleep(1);
-       while (((data = inb_p(SMB_HST_STS)) & HST_STS_BUSY) && --timeout);
+       while (((data = inb_p(SMB_HST_STS)) & HST_STS_BUSY) && --timeout);
 
        dev_dbg(&a->dev, "Transaction (post): STS=%02x, CNTL1=%02x, "
                "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n",
@@ -157,9 +157,9 @@ static int ali1563_block_start(struct i2c_adapter * a)
        outb_p(inb_p(SMB_HST_CNTL2) | HST_CNTL2_START, SMB_HST_CNTL2);
 
        timeout = ALI1563_MAX_TIMEOUT;
-       do
+       do {
                msleep(1);
-       while (!((data = inb_p(SMB_HST_STS)) & HST_STS_DONE) && --timeout);
+       while (!((data = inb_p(SMB_HST_STS)) & HST_STS_DONE) && --timeout);
 
        dev_dbg(&a->dev, "Block (post): STS=%02x, CNTL1=%02x, "
                "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n",
index 0ed68e2..f7346a9 100644 (file)
@@ -75,7 +75,7 @@ static int pca_isa_waitforcompletion(void *pd)
        unsigned long timeout;
 
        if (irq > -1) {
-               ret = wait_event_interruptible_timeout(pca_wait,
+               ret = wait_event_timeout(pca_wait,
                                pca_isa_readbyte(pd, I2C_PCA_CON)
                                & I2C_PCA_CON_SI, pca_isa_ops.timeout);
        } else {
@@ -96,7 +96,7 @@ static void pca_isa_resetchip(void *pd)
 }
 
 static irqreturn_t pca_handler(int this_irq, void *dev_id) {
-       wake_up_interruptible(&pca_wait);
+       wake_up(&pca_wait);
        return IRQ_HANDLED;
 }
 
index c4df9d4..5b2213d 100644 (file)
@@ -84,7 +84,7 @@ static int i2c_pca_pf_waitforcompletion(void *pd)
        unsigned long timeout;
 
        if (i2c->irq) {
-               ret = wait_event_interruptible_timeout(i2c->wait,
+               ret = wait_event_timeout(i2c->wait,
                        i2c->algo_data.read_byte(i2c, I2C_PCA_CON)
                        & I2C_PCA_CON_SI, i2c->adap.timeout);
        } else {
@@ -122,7 +122,7 @@ static irqreturn_t i2c_pca_pf_handler(int this_irq, void *dev_id)
        if ((i2c->algo_data.read_byte(i2c, I2C_PCA_CON) & I2C_PCA_CON_SI) == 0)
                return IRQ_NONE;
 
-       wake_up_interruptible(&i2c->wait);
+       wake_up(&i2c->wait);
 
        return IRQ_HANDLED;
 }
index 1e245e9..e56e4b6 100644 (file)
@@ -324,12 +324,12 @@ static int piix4_transaction(void)
        else
                msleep(1);
 
-       while ((timeout++ < MAX_TIMEOUT) &&
+       while ((++timeout < MAX_TIMEOUT) &&
               ((temp = inb_p(SMBHSTSTS)) & 0x01))
                msleep(1);
 
        /* If the SMBus is still busy, we give up */
-       if (timeout >= MAX_TIMEOUT) {
+       if (timeout == MAX_TIMEOUT) {
                dev_err(&piix4_adapter.dev, "SMBus Timeout!\n");
                result = -ETIMEDOUT;
        }
index e4b1543..a84a909 100644 (file)
@@ -165,10 +165,10 @@ static int vt596_transaction(u8 size)
        do {
                msleep(1);
                temp = inb_p(SMBHSTSTS);
-       } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
+       } while ((temp & 0x01) && (++timeout < MAX_TIMEOUT));
 
        /* If the SMBus is still busy, we give up */
-       if (timeout >= MAX_TIMEOUT) {
+       if (timeout == MAX_TIMEOUT) {
                result = -ETIMEDOUT;
                dev_err(&vt596_adapter.dev, "SMBus timeout!\n");
        }
index 0ac2f90..10be7b5 100644 (file)
@@ -248,7 +248,7 @@ static const struct attribute_group *i2c_dev_attr_groups[] = {
        NULL
 };
 
-const static struct dev_pm_ops i2c_device_pm_ops = {
+static const struct dev_pm_ops i2c_device_pm_ops = {
        .suspend = i2c_device_pm_suspend,
        .resume = i2c_device_pm_resume,
 };
@@ -843,6 +843,9 @@ int i2c_del_adapter(struct i2c_adapter *adap)
                                 adap->dev.parent);
 #endif
 
+       /* device name is gone after device_unregister */
+       dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name);
+
        /* clean up the sysfs representation */
        init_completion(&adap->dev_released);
        device_unregister(&adap->dev);
@@ -855,8 +858,6 @@ int i2c_del_adapter(struct i2c_adapter *adap)
        idr_remove(&i2c_adapter_idr, adap->nr);
        mutex_unlock(&core_lock);
 
-       dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name);
-
        /* Clear the device structure in case this adapter is ever going to be
           added again */
        memset(&adap->dev, 0, sizeof(adap->dev));
index dee6706..258c639 100644 (file)
@@ -59,7 +59,8 @@ static void evdev_pass_event(struct evdev_client *client,
        client->head &= EVDEV_BUFFER_SIZE - 1;
        spin_unlock(&client->buffer_lock);
 
-       kill_fasync(&client->fasync, SIGIO, POLL_IN);
+       if (event->type == EV_SYN)
+               kill_fasync(&client->fasync, SIGIO, POLL_IN);
 }
 
 /*
index ab06071..30b503b 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/mutex.h>
 #include <linux/rcupdate.h>
 #include <linux/smp_lock.h>
+#include "input-compat.h"
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
 MODULE_DESCRIPTION("Input core");
@@ -764,6 +765,40 @@ static int input_attach_handler(struct input_dev *dev, struct input_handler *han
        return error;
 }
 
+#ifdef CONFIG_COMPAT
+
+static int input_bits_to_string(char *buf, int buf_size,
+                               unsigned long bits, bool skip_empty)
+{
+       int len = 0;
+
+       if (INPUT_COMPAT_TEST) {
+               u32 dword = bits >> 32;
+               if (dword || !skip_empty)
+                       len += snprintf(buf, buf_size, "%x ", dword);
+
+               dword = bits & 0xffffffffUL;
+               if (dword || !skip_empty || len)
+                       len += snprintf(buf + len, max(buf_size - len, 0),
+                                       "%x", dword);
+       } else {
+               if (bits || !skip_empty)
+                       len += snprintf(buf, buf_size, "%lx", bits);
+       }
+
+       return len;
+}
+
+#else /* !CONFIG_COMPAT */
+
+static int input_bits_to_string(char *buf, int buf_size,
+                               unsigned long bits, bool skip_empty)
+{
+       return bits || !skip_empty ?
+               snprintf(buf, buf_size, "%lx", bits) : 0;
+}
+
+#endif
 
 #ifdef CONFIG_PROC_FS
 
@@ -832,14 +867,25 @@ static void input_seq_print_bitmap(struct seq_file *seq, const char *name,
                                   unsigned long *bitmap, int max)
 {
        int i;
-
-       for (i = BITS_TO_LONGS(max) - 1; i > 0; i--)
-               if (bitmap[i])
-                       break;
+       bool skip_empty = true;
+       char buf[18];
 
        seq_printf(seq, "B: %s=", name);
-       for (; i >= 0; i--)
-               seq_printf(seq, "%lx%s", bitmap[i], i > 0 ? " " : "");
+
+       for (i = BITS_TO_LONGS(max) - 1; i >= 0; i--) {
+               if (input_bits_to_string(buf, sizeof(buf),
+                                        bitmap[i], skip_empty)) {
+                       skip_empty = false;
+                       seq_printf(seq, "%s%s", buf, i > 0 ? " " : "");
+               }
+       }
+
+       /*
+        * If no output was produced print a single 0.
+        */
+       if (skip_empty)
+               seq_puts(seq, "0");
+
        seq_putc(seq, '\n');
 }
 
@@ -1128,14 +1174,23 @@ static int input_print_bitmap(char *buf, int buf_size, unsigned long *bitmap,
 {
        int i;
        int len = 0;
+       bool skip_empty = true;
+
+       for (i = BITS_TO_LONGS(max) - 1; i >= 0; i--) {
+               len += input_bits_to_string(buf + len, max(buf_size - len, 0),
+                                           bitmap[i], skip_empty);
+               if (len) {
+                       skip_empty = false;
+                       if (i > 0)
+                               len += snprintf(buf + len, max(buf_size - len, 0), " ");
+               }
+       }
 
-       for (i = BITS_TO_LONGS(max) - 1; i > 0; i--)
-               if (bitmap[i])
-                       break;
-
-       for (; i >= 0; i--)
-               len += snprintf(buf + len, max(buf_size - len, 0),
-                               "%lx%s", bitmap[i], i > 0 ? " " : "");
+       /*
+        * If no output was produced print a single 0.
+        */
+       if (len == 0)
+               len = snprintf(buf, buf_size, "%d", 0);
 
        if (add_cr)
                len += snprintf(buf + len, max(buf_size - len, 0), "\n");
@@ -1150,7 +1205,8 @@ static ssize_t input_dev_show_cap_##bm(struct device *dev,                \
 {                                                                      \
        struct input_dev *input_dev = to_input_dev(dev);                \
        int len = input_print_bitmap(buf, PAGE_SIZE,                    \
-                                    input_dev->bm##bit, ev##_MAX, 1);  \
+                                    input_dev->bm##bit, ev##_MAX,      \
+                                    true);                             \
        return min_t(int, len, PAGE_SIZE);                              \
 }                                                                      \
 static DEVICE_ATTR(bm, S_IRUGO, input_dev_show_cap_##bm, NULL)
@@ -1214,7 +1270,7 @@ static int input_add_uevent_bm_var(struct kobj_uevent_env *env,
 
        len = input_print_bitmap(&env->buf[env->buflen - 1],
                                 sizeof(env->buf) - env->buflen,
-                                bitmap, max, 0);
+                                bitmap, max, false);
        if (len >= (sizeof(env->buf) - env->buflen))
                return -ENOMEM;
 
index 67c207f..45ac70e 100644 (file)
@@ -277,7 +277,7 @@ static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv)
        }
 
 #ifdef RESET_WORKS
-       if ((gf2k->id != (GB(19,2,0) | GB(15,3,2) | GB(12,3,5))) ||
+       if ((gf2k->id != (GB(19,2,0) | GB(15,3,2) | GB(12,3,5))) &&
            (gf2k->id != (GB(31,2,0) | GB(27,3,2) | GB(24,3,5)))) {
                err = -ENODEV;
                goto fail2;
index 482cb12..8a28fb7 100644 (file)
@@ -446,7 +446,7 @@ static void xpad_irq_in(struct urb *urb)
        }
 
 exit:
-       retval = usb_submit_urb (urb, GFP_ATOMIC);
+       retval = usb_submit_urb(urb, GFP_ATOMIC);
        if (retval)
                err ("%s - usb_submit_urb failed with result %d",
                     __func__, retval);
@@ -571,7 +571,7 @@ static int xpad_play_effect(struct input_dev *dev, void *data,
                xpad->odata[6] = 0x00;
                xpad->odata[7] = 0x00;
                xpad->irq_out->transfer_buffer_length = 8;
-               usb_submit_urb(xpad->irq_out, GFP_KERNEL);
+               usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
        }
 
        return 0;
index 1f5e2ce..7b40562 100644 (file)
@@ -225,8 +225,10 @@ struct atkbd {
 
        struct delayed_work event_work;
        unsigned long event_jiffies;
-       struct mutex event_mutex;
        unsigned long event_mask;
+
+       /* Serializes reconnect(), attr->set() and event work */
+       struct mutex mutex;
 };
 
 /*
@@ -577,7 +579,7 @@ static void atkbd_event_work(struct work_struct *work)
 {
        struct atkbd *atkbd = container_of(work, struct atkbd, event_work.work);
 
-       mutex_lock(&atkbd->event_mutex);
+       mutex_lock(&atkbd->mutex);
 
        if (!atkbd->enabled) {
                /*
@@ -596,7 +598,7 @@ static void atkbd_event_work(struct work_struct *work)
                        atkbd_set_repeat_rate(atkbd);
        }
 
-       mutex_unlock(&atkbd->event_mutex);
+       mutex_unlock(&atkbd->mutex);
 }
 
 /*
@@ -612,7 +614,7 @@ static void atkbd_schedule_event_work(struct atkbd *atkbd, int event_bit)
 
        atkbd->event_jiffies = jiffies;
        set_bit(event_bit, &atkbd->event_mask);
-       wmb();
+       mb();
        schedule_delayed_work(&atkbd->event_work, delay);
 }
 
@@ -849,13 +851,20 @@ static void atkbd_disconnect(struct serio *serio)
 {
        struct atkbd *atkbd = serio_get_drvdata(serio);
 
+       sysfs_remove_group(&serio->dev.kobj, &atkbd_attribute_group);
+
        atkbd_disable(atkbd);
 
-       /* make sure we don't have a command in flight */
+       input_unregister_device(atkbd->dev);
+
+       /*
+        * Make sure we don't have a command in flight.
+        * Note that since atkbd->enabled is false event work will keep
+        * rescheduling itself until it gets canceled and will not try
+        * accessing freed input device or serio port.
+        */
        cancel_delayed_work_sync(&atkbd->event_work);
 
-       sysfs_remove_group(&serio->dev.kobj, &atkbd_attribute_group);
-       input_unregister_device(atkbd->dev);
        serio_close(serio);
        serio_set_drvdata(serio, NULL);
        kfree(atkbd);
@@ -1087,7 +1096,7 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
        atkbd->dev = dev;
        ps2_init(&atkbd->ps2dev, serio);
        INIT_DELAYED_WORK(&atkbd->event_work, atkbd_event_work);
-       mutex_init(&atkbd->event_mutex);
+       mutex_init(&atkbd->mutex);
 
        switch (serio->id.type) {
 
@@ -1160,19 +1169,23 @@ static int atkbd_reconnect(struct serio *serio)
 {
        struct atkbd *atkbd = serio_get_drvdata(serio);
        struct serio_driver *drv = serio->drv;
+       int retval = -1;
 
        if (!atkbd || !drv) {
                printk(KERN_DEBUG "atkbd: reconnect request, but serio is disconnected, ignoring...\n");
                return -1;
        }
 
+       mutex_lock(&atkbd->mutex);
+
        atkbd_disable(atkbd);
 
        if (atkbd->write) {
                if (atkbd_probe(atkbd))
-                       return -1;
+                       goto out;
+
                if (atkbd->set != atkbd_select_set(atkbd, atkbd->set, atkbd->extra))
-                       return -1;
+                       goto out;
 
                atkbd_activate(atkbd);
 
@@ -1190,8 +1203,11 @@ static int atkbd_reconnect(struct serio *serio)
        }
 
        atkbd_enable(atkbd);
+       retval = 0;
 
-       return 0;
+ out:
+       mutex_unlock(&atkbd->mutex);
+       return retval;
 }
 
 static struct serio_device_id atkbd_serio_ids[] = {
@@ -1235,47 +1251,28 @@ static ssize_t atkbd_attr_show_helper(struct device *dev, char *buf,
                                ssize_t (*handler)(struct atkbd *, char *))
 {
        struct serio *serio = to_serio_port(dev);
-       int retval;
-
-       retval = serio_pin_driver(serio);
-       if (retval)
-               return retval;
-
-       if (serio->drv != &atkbd_drv) {
-               retval = -ENODEV;
-               goto out;
-       }
-
-       retval = handler((struct atkbd *)serio_get_drvdata(serio), buf);
+       struct atkbd *atkbd = serio_get_drvdata(serio);
 
-out:
-       serio_unpin_driver(serio);
-       return retval;
+       return handler(atkbd, buf);
 }
 
 static ssize_t atkbd_attr_set_helper(struct device *dev, const char *buf, size_t count,
                                ssize_t (*handler)(struct atkbd *, const char *, size_t))
 {
        struct serio *serio = to_serio_port(dev);
-       struct atkbd *atkbd;
+       struct atkbd *atkbd = serio_get_drvdata(serio);
        int retval;
 
-       retval = serio_pin_driver(serio);
+       retval = mutex_lock_interruptible(&atkbd->mutex);
        if (retval)
                return retval;
 
-       if (serio->drv != &atkbd_drv) {
-               retval = -ENODEV;
-               goto out;
-       }
-
-       atkbd = serio_get_drvdata(serio);
        atkbd_disable(atkbd);
        retval = handler(atkbd, buf, count);
        atkbd_enable(atkbd);
 
-out:
-       serio_unpin_driver(serio);
+       mutex_unlock(&atkbd->mutex);
+
        return retval;
 }
 
index 6e52d85..d410d7a 100644 (file)
@@ -174,6 +174,14 @@ static int __init davinci_ks_probe(struct platform_device *pdev)
        struct davinci_ks_platform_data *pdata = pdev->dev.platform_data;
        int error, i;
 
+       if (pdata->device_enable) {
+               error = pdata->device_enable(dev);
+               if (error < 0) {
+                       dev_dbg(dev, "device enable function failed\n");
+                       return error;
+               }
+       }
+
        if (!pdata->keymap) {
                dev_dbg(dev, "no keymap from pdata\n");
                return -EINVAL;
index 0d1d334..4f8fe08 100644 (file)
@@ -139,6 +139,7 @@ struct tp_finger {
 /* trackpad finger data size, empirically at least ten fingers */
 #define SIZEOF_FINGER          sizeof(struct tp_finger)
 #define SIZEOF_ALL_FINGERS     (16 * SIZEOF_FINGER)
+#define MAX_FINGER_ORIENTATION 16384
 
 /* device-specific parameters */
 struct bcm5974_param {
@@ -284,6 +285,26 @@ static void setup_events_to_report(struct input_dev *input_dev,
        input_set_abs_params(input_dev, ABS_Y,
                                0, cfg->y.dim, cfg->y.fuzz, 0);
 
+       /* finger touch area */
+       input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
+                            cfg->w.devmin, cfg->w.devmax, 0, 0);
+       input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR,
+                            cfg->w.devmin, cfg->w.devmax, 0, 0);
+       /* finger approach area */
+       input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR,
+                            cfg->w.devmin, cfg->w.devmax, 0, 0);
+       input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR,
+                            cfg->w.devmin, cfg->w.devmax, 0, 0);
+       /* finger orientation */
+       input_set_abs_params(input_dev, ABS_MT_ORIENTATION,
+                            -MAX_FINGER_ORIENTATION,
+                            MAX_FINGER_ORIENTATION, 0, 0);
+       /* finger position */
+       input_set_abs_params(input_dev, ABS_MT_POSITION_X,
+                            cfg->x.devmin, cfg->x.devmax, 0, 0);
+       input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
+                            cfg->y.devmin, cfg->y.devmax, 0, 0);
+
        __set_bit(EV_KEY, input_dev->evbit);
        __set_bit(BTN_TOUCH, input_dev->keybit);
        __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
@@ -310,13 +331,29 @@ static int report_bt_state(struct bcm5974 *dev, int size)
        return 0;
 }
 
+static void report_finger_data(struct input_dev *input,
+                              const struct bcm5974_config *cfg,
+                              const struct tp_finger *f)
+{
+       input_report_abs(input, ABS_MT_TOUCH_MAJOR, raw2int(f->force_major));
+       input_report_abs(input, ABS_MT_TOUCH_MINOR, raw2int(f->force_minor));
+       input_report_abs(input, ABS_MT_WIDTH_MAJOR, raw2int(f->size_major));
+       input_report_abs(input, ABS_MT_WIDTH_MINOR, raw2int(f->size_minor));
+       input_report_abs(input, ABS_MT_ORIENTATION,
+                        MAX_FINGER_ORIENTATION - raw2int(f->orientation));
+       input_report_abs(input, ABS_MT_POSITION_X, raw2int(f->abs_x));
+       input_report_abs(input, ABS_MT_POSITION_Y,
+                        cfg->y.devmin + cfg->y.devmax - raw2int(f->abs_y));
+       input_mt_sync(input);
+}
+
 /* report trackpad data as logical trackpad state */
 static int report_tp_state(struct bcm5974 *dev, int size)
 {
        const struct bcm5974_config *c = &dev->cfg;
        const struct tp_finger *f;
        struct input_dev *input = dev->input;
-       int raw_p, raw_w, raw_x, raw_y, raw_n;
+       int raw_p, raw_w, raw_x, raw_y, raw_n, i;
        int ptest, origin, ibt = 0, nmin = 0, nmax = 0;
        int abs_p = 0, abs_w = 0, abs_x = 0, abs_y = 0;
 
@@ -329,6 +366,11 @@ static int report_tp_state(struct bcm5974 *dev, int size)
 
        /* always track the first finger; when detached, start over */
        if (raw_n) {
+
+               /* report raw trackpad data */
+               for (i = 0; i < raw_n; i++)
+                       report_finger_data(input, c, &f[i]);
+
                raw_p = raw2int(f->force_major);
                raw_w = raw2int(f->size_major);
                raw_x = raw2int(f->abs_x);
index 401ac6b..9774bdf 100644 (file)
@@ -627,8 +627,15 @@ static int psmouse_extensions(struct psmouse *psmouse,
                synaptics_hardware = true;
 
                if (max_proto > PSMOUSE_IMEX) {
-                       if (!set_properties || synaptics_init(psmouse) == 0)
+/*
+ * Try activating protocol, but check if support is enabled first, since
+ * we try detecting Synaptics even when protocol is disabled.
+ */
+                       if (synaptics_supported() &&
+                           (!set_properties || synaptics_init(psmouse) == 0)) {
                                return PSMOUSE_SYNAPTICS;
+                       }
+
 /*
  * Some Synaptics touchpads can emulate extended protocols (like IMPS/2).
  * Unfortunately Logitech/Genius probes confuse some firmware versions so
@@ -683,19 +690,6 @@ static int psmouse_extensions(struct psmouse *psmouse,
                max_proto = PSMOUSE_IMEX;
        }
 
-/*
- * Try Finger Sensing Pad
- */
-       if (max_proto > PSMOUSE_IMEX) {
-               if (fsp_detect(psmouse, set_properties) == 0) {
-                       if (!set_properties || fsp_init(psmouse) == 0)
-                               return PSMOUSE_FSP;
-/*
- * Init failed, try basic relative protocols
- */
-                       max_proto = PSMOUSE_IMEX;
-               }
-       }
 
        if (max_proto > PSMOUSE_IMEX) {
                if (genius_detect(psmouse, set_properties) == 0)
@@ -712,6 +706,21 @@ static int psmouse_extensions(struct psmouse *psmouse,
        }
 
 /*
+ * Try Finger Sensing Pad. We do it here because its probe upsets
+ * Trackpoint devices (causing TP_READ_ID command to time out).
+ */
+       if (max_proto > PSMOUSE_IMEX) {
+               if (fsp_detect(psmouse, set_properties) == 0) {
+                       if (!set_properties || fsp_init(psmouse) == 0)
+                               return PSMOUSE_FSP;
+/*
+ * Init failed, try basic relative protocols
+ */
+                       max_proto = PSMOUSE_IMEX;
+               }
+       }
+
+/*
  * Reset to defaults in case the device got confused by extended
  * protocol probes. Note that we follow up with full reset because
  * some mice put themselves to sleep when they see PSMOUSE_RESET_DIS.
@@ -1450,24 +1459,10 @@ ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *de
        struct serio *serio = to_serio_port(dev);
        struct psmouse_attribute *attr = to_psmouse_attr(devattr);
        struct psmouse *psmouse;
-       int retval;
-
-       retval = serio_pin_driver(serio);
-       if (retval)
-               return retval;
-
-       if (serio->drv != &psmouse_drv) {
-               retval = -ENODEV;
-               goto out;
-       }
 
        psmouse = serio_get_drvdata(serio);
 
-       retval = attr->show(psmouse, attr->data, buf);
-
-out:
-       serio_unpin_driver(serio);
-       return retval;
+       return attr->show(psmouse, attr->data, buf);
 }
 
 ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *devattr,
@@ -1478,18 +1473,9 @@ ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *dev
        struct psmouse *psmouse, *parent = NULL;
        int retval;
 
-       retval = serio_pin_driver(serio);
-       if (retval)
-               return retval;
-
-       if (serio->drv != &psmouse_drv) {
-               retval = -ENODEV;
-               goto out_unpin;
-       }
-
        retval = mutex_lock_interruptible(&psmouse_mutex);
        if (retval)
-               goto out_unpin;
+               goto out;
 
        psmouse = serio_get_drvdata(serio);
 
@@ -1519,8 +1505,7 @@ ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *dev
 
  out_unlock:
        mutex_unlock(&psmouse_mutex);
- out_unpin:
-       serio_unpin_driver(serio);
+ out:
        return retval;
 }
 
@@ -1582,9 +1567,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
                }
 
                mutex_unlock(&psmouse_mutex);
-               serio_unpin_driver(serio);
                serio_unregister_child_port(serio);
-               serio_pin_driver_uninterruptible(serio);
                mutex_lock(&psmouse_mutex);
 
                if (serio->drv != &psmouse_drv) {
index 77b9fd0..81a6b81 100644 (file)
@@ -2,7 +2,7 @@
  * Finger Sensing Pad PS/2 mouse driver.
  *
  * Copyright (C) 2005-2007 Asia Vital Components Co., Ltd.
- * Copyright (C) 2005-2009 Tai-hwa Liang, Sentelic Corporation.
+ * Copyright (C) 2005-2010 Tai-hwa Liang, Sentelic Corporation.
  *
  *   This program is free software; you can redistribute it and/or
  *   modify it under the terms of the GNU General Public License
@@ -658,9 +658,9 @@ static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)
                        if (packet[3] & BIT(1))
                                button_status |= 0x0f;  /* wheel up */
                        if (packet[3] & BIT(2))
-                               button_status |= BIT(5);/* horizontal left */
+                               button_status |= BIT(4);/* horizontal left */
                        if (packet[3] & BIT(3))
-                               button_status |= BIT(4);/* horizontal right */
+                               button_status |= BIT(5);/* horizontal right */
                        /* push back to packet queue */
                        if (button_status != 0)
                                packet[3] = button_status;
index 05689e7..d3f5243 100644 (file)
@@ -743,6 +743,11 @@ int synaptics_init(struct psmouse *psmouse)
        return -1;
 }
 
+bool synaptics_supported(void)
+{
+       return true;
+}
+
 #else /* CONFIG_MOUSE_PS2_SYNAPTICS */
 
 void __init synaptics_module_init(void)
@@ -754,5 +759,10 @@ int synaptics_init(struct psmouse *psmouse)
        return -ENOSYS;
 }
 
+bool synaptics_supported(void)
+{
+       return false;
+}
+
 #endif /* CONFIG_MOUSE_PS2_SYNAPTICS */
 
index 838e7f2..f0f40a3 100644 (file)
@@ -109,5 +109,6 @@ void synaptics_module_init(void);
 int synaptics_detect(struct psmouse *psmouse, bool set_properties);
 int synaptics_init(struct psmouse *psmouse);
 void synaptics_reset(struct psmouse *psmouse);
+bool synaptics_supported(void);
 
 #endif /* _SYNAPTICS_H */
index 64b688d..2a5982e 100644 (file)
@@ -524,6 +524,13 @@ static const struct dmi_system_id __initconst i8042_dmi_laptop_table[] = {
  */
 static const struct dmi_system_id __initconst i8042_dmi_dritek_table[] = {
        {
+               /* Acer Aspire 5610 */
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5610"),
+               },
+       },
+       {
                /* Acer Aspire 5630 */
                .matches = {
                        DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
index bff7a53..b521ed9 100644 (file)
@@ -13,7 +13,7 @@
  */
 
 
-#include <linux/usb/input.h>
+#include <linux/input.h>
 #include <media/ir-common.h>
 
 #define IR_TAB_MIN_SIZE        32
index c190b0d..2833137 100644 (file)
@@ -144,7 +144,8 @@ static void set_audio(struct dvb_frontend *fe,
        }
 
        if (params->mode == V4L2_TUNER_RADIO) {
-               priv->tda8290_easy_mode = 0x01;         /* Start with MN values */
+               /* Set TDA8295 to FM radio; Start TDA8290 with MN values */
+               priv->tda8290_easy_mode = (priv->ver & TDA8295) ? 0x80 : 0x01;
                tuner_dbg("setting to radio FM\n");
        } else {
                tuner_dbg("setting tda829x to system %s\n", mode);
@@ -672,16 +673,19 @@ static int tda8290_probe(struct tuner_i2c_props *i2c_props)
 static int tda8295_probe(struct tuner_i2c_props *i2c_props)
 {
 #define TDA8295_ID 0x8a
+#define TDA8295C2_ID 0x8b
        unsigned char tda8295_id[] = { 0x2f, 0x00 };
 
        /* detect tda8295 */
        tuner_i2c_xfer_send(i2c_props, &tda8295_id[0], 1);
        tuner_i2c_xfer_recv(i2c_props, &tda8295_id[1], 1);
 
-       if (tda8295_id[1] == TDA8295_ID) {
+       if ((tda8295_id[1] & 0xfe) == TDA8295_ID) {
                if (debug)
-                       printk(KERN_DEBUG "%s: tda8295 detected @ %d-%04x\n",
-                              __func__, i2c_adapter_id(i2c_props->adap),
+                       printk(KERN_DEBUG "%s: %s detected @ %d-%04x\n",
+                              __func__, (tda8295_id[1] == TDA8295_ID) ?
+                              "tda8295c1" : "tda8295c2",
+                              i2c_adapter_id(i2c_props->adap),
                               i2c_props->addr);
                return 0;
        }
index 35d0817..cf8f65f 100644 (file)
@@ -72,6 +72,10 @@ comment "Supported Earthsoft PT1 Adapters"
        depends on DVB_CORE && PCI && I2C
 source "drivers/media/dvb/pt1/Kconfig"
 
+comment "Supported Mantis Adapters"
+       depends on DVB_CORE && PCI && I2C
+       source "drivers/media/dvb/mantis/Kconfig"
+
 comment "Supported DVB Frontends"
        depends on DVB_CORE
 source "drivers/media/dvb/frontends/Kconfig"
index 16d262d..c12922c 100644 (file)
@@ -2,6 +2,18 @@
 # Makefile for the kernel multimedia device drivers.
 #
 
-obj-y        := dvb-core/ frontends/ ttpci/ ttusb-dec/ ttusb-budget/ b2c2/ bt8xx/ dvb-usb/ pluto2/ siano/ dm1105/ pt1/
+obj-y        := dvb-core/      \
+               frontends/      \
+               ttpci/          \
+               ttusb-dec/      \
+               ttusb-budget/   \
+               b2c2/           \
+               bt8xx/          \
+               dvb-usb/        \
+               pluto2/         \
+               siano/          \
+               dm1105/         \
+               pt1/            \
+               mantis/
 
 obj-$(CONFIG_DVB_FIREDTV)      += firewire/
index a3b8b69..cd7f9b7 100644 (file)
@@ -208,6 +208,14 @@ config DVB_DS3000
        help
          A DVB-S/S2 tuner module. Say Y when you want to support this frontend.
 
+config DVB_MB86A16
+       tristate "Fujitsu MB86A16 based"
+       depends on DVB_CORE && I2C
+       default m if DVB_FE_CUSTOMISE
+       help
+         A DVB-S/DSS Direct Conversion reveiver.
+         Say Y when you want to support this frontend.
+
 comment "DVB-T (terrestrial) frontends"
        depends on DVB_CORE
 
@@ -587,6 +595,17 @@ config DVB_ATBM8830
        help
          A DMB-TH tuner module. Say Y when you want to support this frontend.
 
+config DVB_TDA665x
+       tristate "TDA665x tuner"
+       depends on DVB_CORE && I2C
+       default m if DVB_FE_CUSTOMISE
+       help
+         Support for tuner modules based on Philips TDA6650/TDA6651 chips.
+         Say Y when you want to support this chip.
+
+         Currently supported tuners:
+         * Panasonic ENV57H12D5 (ET-50DT)
+
 comment "Tools to develop new frontends"
 
 config DVB_DUMMY_FE
index 47575cc..874e8ad 100644 (file)
@@ -64,6 +64,7 @@ obj-$(CONFIG_DVB_TDA10048) += tda10048.o
 obj-$(CONFIG_DVB_TUNER_CX24113) += cx24113.o
 obj-$(CONFIG_DVB_S5H1411) += s5h1411.o
 obj-$(CONFIG_DVB_LGS8GL5) += lgs8gl5.o
+obj-$(CONFIG_DVB_TDA665x) += tda665x.o
 obj-$(CONFIG_DVB_LGS8GXX) += lgs8gxx.o
 obj-$(CONFIG_DVB_ATBM8830) += atbm8830.o
 obj-$(CONFIG_DVB_DUMMY_FE) += dvb_dummy_fe.o
@@ -80,3 +81,4 @@ obj-$(CONFIG_DVB_STV6110x) += stv6110x.o
 obj-$(CONFIG_DVB_ISL6423) += isl6423.o
 obj-$(CONFIG_DVB_EC100) += ec100.o
 obj-$(CONFIG_DVB_DS3000) += ds3000.o
+obj-$(CONFIG_DVB_MB86A16) += mb86a16.o
index d99619a..b1ee207 100644 (file)
@@ -100,7 +100,7 @@ static inline int dib8000_set_tune_state(struct dvb_frontend *fe, enum frontend_
 static inline enum frontend_tune_state dib8000_get_tune_state(struct dvb_frontend *fe)
 {
        printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
-    return CT_SHUTDOWN,
+       return CT_SHUTDOWN;
 }
 static inline void dib8000_pwm_agc_reset(struct dvb_frontend *fe)
 {
index 4fa6e52..9cb11c9 100644 (file)
@@ -54,13 +54,13 @@ struct lgdt3305_config {
        u16 usref_qam256; /* default: 0x2a80 */
 
        /* disable i2c repeater - 0:repeater enabled 1:repeater disabled */
-       int deny_i2c_rptr:1;
+       unsigned int deny_i2c_rptr:1;
 
        /* spectral inversion - 0:disabled 1:enabled */
-       int spectral_inversion:1;
+       unsigned int spectral_inversion:1;
 
        /* use RF AGC loop - 0:disabled 1:enabled */
-       int rf_agc_loop:1;
+       unsigned int rf_agc_loop:1;
 
        enum lgdt3305_mpeg_mode mpeg_mode;
        enum lgdt3305_tp_clock_edge tpclk_edge;
diff --git a/drivers/media/dvb/frontends/mb86a16.c b/drivers/media/dvb/frontends/mb86a16.c
new file mode 100644 (file)
index 0000000..d05f750
--- /dev/null
@@ -0,0 +1,1878 @@
+/*
+       Fujitsu MB86A16 DVB-S/DSS DC Receiver driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+
+#include "dvb_frontend.h"
+#include "mb86a16.h"
+#include "mb86a16_priv.h"
+
+unsigned int verbose = 5;
+module_param(verbose, int, 0644);
+
+#define ABS(x)         ((x) < 0 ? (-x) : (x))
+
+struct mb86a16_state {
+       struct i2c_adapter              *i2c_adap;
+       const struct mb86a16_config     *config;
+       struct dvb_frontend             frontend;
+
+       /* tuning parameters */
+       int                             frequency;
+       int                             srate;
+
+       /* Internal stuff */
+       int                             master_clk;
+       int                             deci;
+       int                             csel;
+       int                             rsel;
+};
+
+#define MB86A16_ERROR          0
+#define MB86A16_NOTICE         1
+#define MB86A16_INFO           2
+#define MB86A16_DEBUG          3
+
+#define dprintk(x, y, z, format, arg...) do {                                          \
+       if (z) {                                                                        \
+               if      ((x > MB86A16_ERROR) && (x > y))                                \
+                       printk(KERN_ERR "%s: " format "\n", __func__, ##arg);           \
+               else if ((x > MB86A16_NOTICE) && (x > y))                               \
+                       printk(KERN_NOTICE "%s: " format "\n", __func__, ##arg);        \
+               else if ((x > MB86A16_INFO) && (x > y))                                 \
+                       printk(KERN_INFO "%s: " format "\n", __func__, ##arg);          \
+               else if ((x > MB86A16_DEBUG) && (x > y))                                \
+                       printk(KERN_DEBUG "%s: " format "\n", __func__, ##arg);         \
+       } else {                                                                        \
+               if (x > y)                                                              \
+                       printk(format, ##arg);                                          \
+       }                                                                               \
+} while (0)
+
+#define TRACE_IN       dprintk(verbose, MB86A16_DEBUG, 1, "-->()")
+#define TRACE_OUT      dprintk(verbose, MB86A16_DEBUG, 1, "()-->")
+
+static int mb86a16_write(struct mb86a16_state *state, u8 reg, u8 val)
+{
+       int ret;
+       u8 buf[] = { reg, val };
+
+       struct i2c_msg msg = {
+               .addr = state->config->demod_address,
+               .flags = 0,
+               .buf = buf,
+               .len = 2
+       };
+
+       dprintk(verbose, MB86A16_DEBUG, 1,
+               "writing to [0x%02x],Reg[0x%02x],Data[0x%02x]",
+               state->config->demod_address, buf[0], buf[1]);
+
+       ret = i2c_transfer(state->i2c_adap, &msg, 1);
+
+       return (ret != 1) ? -EREMOTEIO : 0;
+}
+
+static int mb86a16_read(struct mb86a16_state *state, u8 reg, u8 *val)
+{
+       int ret;
+       u8 b0[] = { reg };
+       u8 b1[] = { 0 };
+
+       struct i2c_msg msg[] = {
+               {
+                       .addr = state->config->demod_address,
+                       .flags = 0,
+                       .buf = b0,
+                       .len = 1
+               }, {
+                       .addr = state->config->demod_address,
+                       .flags = I2C_M_RD,
+                       .buf = b1,
+                       .len = 1
+               }
+       };
+       ret = i2c_transfer(state->i2c_adap, msg, 2);
+       if (ret != 2) {
+               dprintk(verbose, MB86A16_ERROR, 1, "read error(reg=0x%02x, ret=0x%i)",
+                       reg, ret);
+
+               return -EREMOTEIO;
+       }
+       *val = b1[0];
+
+       return ret;
+}
+
+static int CNTM_set(struct mb86a16_state *state,
+                   unsigned char timint1,
+                   unsigned char timint2,
+                   unsigned char cnext)
+{
+       unsigned char val;
+
+       val = (timint1 << 4) | (timint2 << 2) | cnext;
+       if (mb86a16_write(state, MB86A16_CNTMR, val) < 0)
+               goto err;
+
+       return 0;
+
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+}
+
+static int smrt_set(struct mb86a16_state *state, int rate)
+{
+       int tmp ;
+       int m ;
+       unsigned char STOFS0, STOFS1;
+
+       m = 1 << state->deci;
+       tmp = (8192 * state->master_clk - 2 * m * rate * 8192 + state->master_clk / 2) / state->master_clk;
+
+       STOFS0 = tmp & 0x0ff;
+       STOFS1 = (tmp & 0xf00) >> 8;
+
+       if (mb86a16_write(state, MB86A16_SRATE1, (state->deci << 2) |
+                                      (state->csel << 1) |
+                                       state->rsel) < 0)
+               goto err;
+       if (mb86a16_write(state, MB86A16_SRATE2, STOFS0) < 0)
+               goto err;
+       if (mb86a16_write(state, MB86A16_SRATE3, STOFS1) < 0)
+               goto err;
+
+       return 0;
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -1;
+}
+
+static int srst(struct mb86a16_state *state)
+{
+       if (mb86a16_write(state, MB86A16_RESET, 0x04) < 0)
+               goto err;
+
+       return 0;
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+
+}
+
+static int afcex_data_set(struct mb86a16_state *state,
+                         unsigned char AFCEX_L,
+                         unsigned char AFCEX_H)
+{
+       if (mb86a16_write(state, MB86A16_AFCEXL, AFCEX_L) < 0)
+               goto err;
+       if (mb86a16_write(state, MB86A16_AFCEXH, AFCEX_H) < 0)
+               goto err;
+
+       return 0;
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+
+       return -1;
+}
+
+static int afcofs_data_set(struct mb86a16_state *state,
+                          unsigned char AFCEX_L,
+                          unsigned char AFCEX_H)
+{
+       if (mb86a16_write(state, 0x58, AFCEX_L) < 0)
+               goto err;
+       if (mb86a16_write(state, 0x59, AFCEX_H) < 0)
+               goto err;
+
+       return 0;
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+}
+
+static int stlp_set(struct mb86a16_state *state,
+                   unsigned char STRAS,
+                   unsigned char STRBS)
+{
+       if (mb86a16_write(state, MB86A16_STRFILTCOEF1, (STRBS << 3) | (STRAS)) < 0)
+               goto err;
+
+       return 0;
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+}
+
+static int Vi_set(struct mb86a16_state *state, unsigned char ETH, unsigned char VIA)
+{
+       if (mb86a16_write(state, MB86A16_VISET2, 0x04) < 0)
+               goto err;
+       if (mb86a16_write(state, MB86A16_VISET3, 0xf5) < 0)
+               goto err;
+
+       return 0;
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+}
+
+static int initial_set(struct mb86a16_state *state)
+{
+       if (stlp_set(state, 5, 7))
+               goto err;
+
+       udelay(100);
+       if (afcex_data_set(state, 0, 0))
+               goto err;
+
+       udelay(100);
+       if (afcofs_data_set(state, 0, 0))
+               goto err;
+
+       udelay(100);
+       if (mb86a16_write(state, MB86A16_CRLFILTCOEF1, 0x16) < 0)
+               goto err;
+       if (mb86a16_write(state, 0x2f, 0x21) < 0)
+               goto err;
+       if (mb86a16_write(state, MB86A16_VIMAG, 0x38) < 0)
+               goto err;
+       if (mb86a16_write(state, MB86A16_FAGCS1, 0x00) < 0)
+               goto err;
+       if (mb86a16_write(state, MB86A16_FAGCS2, 0x1c) < 0)
+               goto err;
+       if (mb86a16_write(state, MB86A16_FAGCS3, 0x20) < 0)
+               goto err;
+       if (mb86a16_write(state, MB86A16_FAGCS4, 0x1e) < 0)
+               goto err;
+       if (mb86a16_write(state, MB86A16_FAGCS5, 0x23) < 0)
+               goto err;
+       if (mb86a16_write(state, 0x54, 0xff) < 0)
+               goto err;
+       if (mb86a16_write(state, MB86A16_TSOUT, 0x00) < 0)
+               goto err;
+
+       return 0;
+
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+}
+
+static int S01T_set(struct mb86a16_state *state,
+                   unsigned char s1t,
+                   unsigned s0t)
+{
+       if (mb86a16_write(state, 0x33, (s1t << 3) | s0t) < 0)
+               goto err;
+
+       return 0;
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+}
+
+
+static int EN_set(struct mb86a16_state *state,
+                 int cren,
+                 int afcen)
+{
+       unsigned char val;
+
+       val = 0x7a | (cren << 7) | (afcen << 2);
+       if (mb86a16_write(state, 0x49, val) < 0)
+               goto err;
+
+       return 0;
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+}
+
+static int AFCEXEN_set(struct mb86a16_state *state,
+                      int afcexen,
+                      int smrt)
+{
+       unsigned char AFCA ;
+
+       if (smrt > 18875)
+               AFCA = 4;
+       else if (smrt > 9375)
+               AFCA = 3;
+       else if (smrt > 2250)
+               AFCA = 2;
+       else
+               AFCA = 1;
+
+       if (mb86a16_write(state, 0x2a, 0x02 | (afcexen << 5) | (AFCA << 2)) < 0)
+               goto err;
+
+       return 0;
+
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+}
+
+static int DAGC_data_set(struct mb86a16_state *state,
+                        unsigned char DAGCA,
+                        unsigned char DAGCW)
+{
+       if (mb86a16_write(state, 0x2d, (DAGCA << 3) | DAGCW) < 0)
+               goto err;
+
+       return 0;
+
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+}
+
+static void smrt_info_get(struct mb86a16_state *state, int rate)
+{
+       if (rate >= 37501) {
+               state->deci = 0; state->csel = 0; state->rsel = 0;
+       } else if (rate >= 30001) {
+               state->deci = 0; state->csel = 0; state->rsel = 1;
+       } else if (rate >= 26251) {
+               state->deci = 0; state->csel = 1; state->rsel = 0;
+       } else if (rate >= 22501) {
+               state->deci = 0; state->csel = 1; state->rsel = 1;
+       } else if (rate >= 18751) {
+               state->deci = 1; state->csel = 0; state->rsel = 0;
+       } else if (rate >= 15001) {
+               state->deci = 1; state->csel = 0; state->rsel = 1;
+       } else if (rate >= 13126) {
+               state->deci = 1; state->csel = 1; state->rsel = 0;
+       } else if (rate >= 11251) {
+               state->deci = 1; state->csel = 1; state->rsel = 1;
+       } else if (rate >= 9376) {
+               state->deci = 2; state->csel = 0; state->rsel = 0;
+       } else if (rate >= 7501) {
+               state->deci = 2; state->csel = 0; state->rsel = 1;
+       } else if (rate >= 6563) {
+               state->deci = 2; state->csel = 1; state->rsel = 0;
+       } else if (rate >= 5626) {
+               state->deci = 2; state->csel = 1; state->rsel = 1;
+       } else if (rate >= 4688) {
+               state->deci = 3; state->csel = 0; state->rsel = 0;
+       } else if (rate >= 3751) {
+               state->deci = 3; state->csel = 0; state->rsel = 1;
+       } else if (rate >= 3282) {
+               state->deci = 3; state->csel = 1; state->rsel = 0;
+       } else if (rate >= 2814) {
+               state->deci = 3; state->csel = 1; state->rsel = 1;
+       } else if (rate >= 2344) {
+               state->deci = 4; state->csel = 0; state->rsel = 0;
+       } else if (rate >= 1876) {
+               state->deci = 4; state->csel = 0; state->rsel = 1;
+       } else if (rate >= 1641) {
+               state->deci = 4; state->csel = 1; state->rsel = 0;
+       } else if (rate >= 1407) {
+               state->deci = 4; state->csel = 1; state->rsel = 1;
+       } else if (rate >= 1172) {
+               state->deci = 5; state->csel = 0; state->rsel = 0;
+       } else if (rate >=  939) {
+               state->deci = 5; state->csel = 0; state->rsel = 1;
+       } else if (rate >=  821) {
+               state->deci = 5; state->csel = 1; state->rsel = 0;
+       } else {
+               state->deci = 5; state->csel = 1; state->rsel = 1;
+       }
+
+       if (state->csel == 0)
+               state->master_clk = 92000;
+       else
+               state->master_clk = 61333;
+
+}
+
+static int signal_det(struct mb86a16_state *state,
+                     int smrt,
+                     unsigned char *SIG)
+{
+
+       int ret ;
+       int smrtd ;
+       int wait_sym ;
+
+       u32 wait_t;
+       unsigned char S[3] ;
+       int i ;
+
+       if (*SIG > 45) {
+               if (CNTM_set(state, 2, 1, 2) < 0) {
+                       dprintk(verbose, MB86A16_ERROR, 1, "CNTM set Error");
+                       return -1;
+               }
+               wait_sym = 40000;
+       } else {
+               if (CNTM_set(state, 3, 1, 2) < 0) {
+                       dprintk(verbose, MB86A16_ERROR, 1, "CNTM set Error");
+                       return -1;
+               }
+               wait_sym = 80000;
+       }
+       for (i = 0; i < 3; i++) {
+               if (i == 0)
+                       smrtd = smrt * 98 / 100;
+               else if (i == 1)
+                       smrtd = smrt;
+               else
+                       smrtd = smrt * 102 / 100;
+               smrt_info_get(state, smrtd);
+               smrt_set(state, smrtd);
+               srst(state);
+               wait_t = (wait_sym + 99 * smrtd / 100) / smrtd;
+               if (wait_t == 0)
+                       wait_t = 1;
+               msleep_interruptible(10);
+               if (mb86a16_read(state, 0x37, &(S[i])) != 2) {
+                       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+                       return -EREMOTEIO;
+               }
+       }
+       if ((S[1] > S[0] * 112 / 100) &&
+           (S[1] > S[2] * 112 / 100)) {
+
+               ret = 1;
+       } else {
+               ret = 0;
+       }
+       *SIG = S[1];
+
+       if (CNTM_set(state, 0, 1, 2) < 0) {
+               dprintk(verbose, MB86A16_ERROR, 1, "CNTM set Error");
+               return -1;
+       }
+
+       return ret;
+}
+
+static int rf_val_set(struct mb86a16_state *state,
+                     int f,
+                     int smrt,
+                     unsigned char R)
+{
+       unsigned char C, F, B;
+       int M;
+       unsigned char rf_val[5];
+       int ack = -1;
+
+       if (smrt > 37750)
+               C = 1;
+       else if (smrt > 18875)
+               C = 2;
+       else if (smrt > 5500)
+               C = 3;
+       else
+               C = 4;
+
+       if (smrt > 30500)
+               F = 3;
+       else if (smrt > 9375)
+               F = 1;
+       else if (smrt > 4625)
+               F = 0;
+       else
+               F = 2;
+
+       if (f < 1060)
+               B = 0;
+       else if (f < 1175)
+               B = 1;
+       else if (f < 1305)
+               B = 2;
+       else if (f < 1435)
+               B = 3;
+       else if (f < 1570)
+               B = 4;
+       else if (f < 1715)
+               B = 5;
+       else if (f < 1845)
+               B = 6;
+       else if (f < 1980)
+               B = 7;
+       else if (f < 2080)
+               B = 8;
+       else
+               B = 9;
+
+       M = f * (1 << R) / 2;
+
+       rf_val[0] = 0x01 | (C << 3) | (F << 1);
+       rf_val[1] = (R << 5) | ((M & 0x1f000) >> 12);
+       rf_val[2] = (M & 0x00ff0) >> 4;
+       rf_val[3] = ((M & 0x0000f) << 4) | B;
+
+       /* Frequency Set */
+       if (mb86a16_write(state, 0x21, rf_val[0]) < 0)
+               ack = 0;
+       if (mb86a16_write(state, 0x22, rf_val[1]) < 0)
+               ack = 0;
+       if (mb86a16_write(state, 0x23, rf_val[2]) < 0)
+               ack = 0;
+       if (mb86a16_write(state, 0x24, rf_val[3]) < 0)
+               ack = 0;
+       if (mb86a16_write(state, 0x25, 0x01) < 0)
+               ack = 0;
+       if (ack == 0) {
+               dprintk(verbose, MB86A16_ERROR, 1, "RF Setup - I2C transfer error");
+               return -EREMOTEIO;
+       }
+
+       return 0;
+}
+
+static int afcerr_chk(struct mb86a16_state *state)
+{
+       unsigned char AFCM_L, AFCM_H ;
+       int AFCM ;
+       int afcm, afcerr ;
+
+       if (mb86a16_read(state, 0x0e, &AFCM_L) != 2)
+               goto err;
+       if (mb86a16_read(state, 0x0f, &AFCM_H) != 2)
+               goto err;
+
+       AFCM = (AFCM_H << 8) + AFCM_L;
+
+       if (AFCM > 2048)
+               afcm = AFCM - 4096;
+       else
+               afcm = AFCM;
+       afcerr = afcm * state->master_clk / 8192;
+
+       return afcerr;
+
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+}
+
+static int dagcm_val_get(struct mb86a16_state *state)
+{
+       int DAGCM;
+       unsigned char DAGCM_H, DAGCM_L;
+
+       if (mb86a16_read(state, 0x45, &DAGCM_L) != 2)
+               goto err;
+       if (mb86a16_read(state, 0x46, &DAGCM_H) != 2)
+               goto err;
+
+       DAGCM = (DAGCM_H << 8) + DAGCM_L;
+
+       return DAGCM;
+
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+}
+
+static int mb86a16_read_status(struct dvb_frontend *fe, fe_status_t *status)
+{
+       u8 stat, stat2;
+       struct mb86a16_state *state = fe->demodulator_priv;
+
+       *status = 0;
+
+       if (mb86a16_read(state, MB86A16_SIG1, &stat) != 2)
+               goto err;
+       if (mb86a16_read(state, MB86A16_SIG2, &stat2) != 2)
+               goto err;
+       if ((stat > 25) && (stat2 > 25))
+               *status |= FE_HAS_SIGNAL;
+       if ((stat > 45) && (stat2 > 45))
+               *status |= FE_HAS_CARRIER;
+
+       if (mb86a16_read(state, MB86A16_STATUS, &stat) != 2)
+               goto err;
+
+       if (stat & 0x01)
+               *status |= FE_HAS_SYNC;
+       if (stat & 0x01)
+               *status |= FE_HAS_VITERBI;
+
+       if (mb86a16_read(state, MB86A16_FRAMESYNC, &stat) != 2)
+               goto err;
+
+       if ((stat & 0x0f) && (*status & FE_HAS_VITERBI))
+               *status |= FE_HAS_LOCK;
+
+       return 0;
+
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+}
+
+static int sync_chk(struct mb86a16_state *state,
+                   unsigned char *VIRM)
+{
+       unsigned char val;
+       int sync;
+
+       if (mb86a16_read(state, 0x0d, &val) != 2)
+               goto err;
+
+       dprintk(verbose, MB86A16_INFO, 1, "Status = %02x,", val);
+       sync = val & 0x01;
+       *VIRM = (val & 0x1c) >> 2;
+
+       return sync;
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+
+}
+
+static int freqerr_chk(struct mb86a16_state *state,
+                      int fTP,
+                      int smrt,
+                      int unit)
+{
+       unsigned char CRM, AFCML, AFCMH;
+       unsigned char temp1, temp2, temp3;
+       int crm, afcm, AFCM;
+       int crrerr, afcerr;             /* kHz */
+       int frqerr;                     /* MHz */
+       int afcen, afcexen = 0;
+       int R, M, fOSC, fOSC_OFS;
+
+       if (mb86a16_read(state, 0x43, &CRM) != 2)
+               goto err;
+
+       if (CRM > 127)
+               crm = CRM - 256;
+       else
+               crm = CRM;
+
+       crrerr = smrt * crm / 256;
+       if (mb86a16_read(state, 0x49, &temp1) != 2)
+               goto err;
+
+       afcen = (temp1 & 0x04) >> 2;
+       if (afcen == 0) {
+               if (mb86a16_read(state, 0x2a, &temp1) != 2)
+                       goto err;
+               afcexen = (temp1 & 0x20) >> 5;
+       }
+
+       if (afcen == 1) {
+               if (mb86a16_read(state, 0x0e, &AFCML) != 2)
+                       goto err;
+               if (mb86a16_read(state, 0x0f, &AFCMH) != 2)
+                       goto err;
+       } else if (afcexen == 1) {
+               if (mb86a16_read(state, 0x2b, &AFCML) != 2)
+                       goto err;
+               if (mb86a16_read(state, 0x2c, &AFCMH) != 2)
+                       goto err;
+       }
+       if ((afcen == 1) || (afcexen == 1)) {
+               smrt_info_get(state, smrt);
+               AFCM = ((AFCMH & 0x01) << 8) + AFCML;
+               if (AFCM > 255)
+                       afcm = AFCM - 512;
+               else
+                       afcm = AFCM;
+
+               afcerr = afcm * state->master_clk / 8192;
+       } else
+               afcerr = 0;
+
+       if (mb86a16_read(state, 0x22, &temp1) != 2)
+               goto err;
+       if (mb86a16_read(state, 0x23, &temp2) != 2)
+               goto err;
+       if (mb86a16_read(state, 0x24, &temp3) != 2)
+               goto err;
+
+       R = (temp1 & 0xe0) >> 5;
+       M = ((temp1 & 0x1f) << 12) + (temp2 << 4) + (temp3 >> 4);
+       if (R == 0)
+               fOSC = 2 * M;
+       else
+               fOSC = M;
+
+       fOSC_OFS = fOSC - fTP;
+
+       if (unit == 0) {        /* MHz */
+               if (crrerr + afcerr + fOSC_OFS * 1000 >= 0)
+                       frqerr = (crrerr + afcerr + fOSC_OFS * 1000 + 500) / 1000;
+               else
+                       frqerr = (crrerr + afcerr + fOSC_OFS * 1000 - 500) / 1000;
+       } else {        /* kHz */
+               frqerr = crrerr + afcerr + fOSC_OFS * 1000;
+       }
+
+       return frqerr;
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+}
+
+static unsigned char vco_dev_get(struct mb86a16_state *state, int smrt)
+{
+       unsigned char R;
+
+       if (smrt > 9375)
+               R = 0;
+       else
+               R = 1;
+
+       return R;
+}
+
+static void swp_info_get(struct mb86a16_state *state,
+                        int fOSC_start,
+                        int smrt,
+                        int v, int R,
+                        int swp_ofs,
+                        int *fOSC,
+                        int *afcex_freq,
+                        unsigned char *AFCEX_L,
+                        unsigned char *AFCEX_H)
+{
+       int AFCEX ;
+       int crnt_swp_freq ;
+
+       crnt_swp_freq = fOSC_start * 1000 + v * swp_ofs;
+
+       if (R == 0)
+               *fOSC = (crnt_swp_freq + 1000) / 2000 * 2;
+       else
+               *fOSC = (crnt_swp_freq + 500) / 1000;
+
+       if (*fOSC >= crnt_swp_freq)
+               *afcex_freq = *fOSC * 1000 - crnt_swp_freq;
+       else
+               *afcex_freq = crnt_swp_freq - *fOSC * 1000;
+
+       AFCEX = *afcex_freq * 8192 / state->master_clk;
+       *AFCEX_L =  AFCEX & 0x00ff;
+       *AFCEX_H = (AFCEX & 0x0f00) >> 8;
+}
+
+
+static int swp_freq_calcuation(struct mb86a16_state *state, int i, int v, int *V,  int vmax, int vmin,
+                              int SIGMIN, int fOSC, int afcex_freq, int swp_ofs, unsigned char *SIG1)
+{
+       int swp_freq ;
+
+       if ((i % 2 == 1) && (v <= vmax)) {
+               /* positive v (case 1) */
+               if ((v - 1 == vmin)                             &&
+                   (*(V + 30 + v) >= 0)                        &&
+                   (*(V + 30 + v - 1) >= 0)                    &&
+                   (*(V + 30 + v - 1) > *(V + 30 + v))         &&
+                   (*(V + 30 + v - 1) > SIGMIN)) {
+
+                       swp_freq = fOSC * 1000 + afcex_freq - swp_ofs;
+                       *SIG1 = *(V + 30 + v - 1);
+               } else if ((v == vmax)                          &&
+                          (*(V + 30 + v) >= 0)                 &&
+                          (*(V + 30 + v - 1) >= 0)             &&
+                          (*(V + 30 + v) > *(V + 30 + v - 1))  &&
+                          (*(V + 30 + v) > SIGMIN)) {
+                       /* (case 2) */
+                       swp_freq = fOSC * 1000 + afcex_freq;
+                       *SIG1 = *(V + 30 + v);
+               } else if ((*(V + 30 + v) > 0)                  &&
+                          (*(V + 30 + v - 1) > 0)              &&
+                          (*(V + 30 + v - 2) > 0)              &&
+                          (*(V + 30 + v - 3) > 0)              &&
+                          (*(V + 30 + v - 1) > *(V + 30 + v))  &&
+                          (*(V + 30 + v - 2) > *(V + 30 + v - 3)) &&
+                          ((*(V + 30 + v - 1) > SIGMIN)        ||
+                          (*(V + 30 + v - 2) > SIGMIN))) {
+                       /* (case 3) */
+                       if (*(V + 30 + v - 1) >= *(V + 30 + v - 2)) {
+                               swp_freq = fOSC * 1000 + afcex_freq - swp_ofs;
+                               *SIG1 = *(V + 30 + v - 1);
+                       } else {
+                               swp_freq = fOSC * 1000 + afcex_freq - swp_ofs * 2;
+                               *SIG1 = *(V + 30 + v - 2);
+                       }
+               } else if ((v == vmax)                          &&
+                          (*(V + 30 + v) >= 0)                 &&
+                          (*(V + 30 + v - 1) >= 0)             &&
+                          (*(V + 30 + v - 2) >= 0)             &&
+                          (*(V + 30 + v) > *(V + 30 + v - 2))  &&
+                          (*(V + 30 + v - 1) > *(V + 30 + v - 2)) &&
+                          ((*(V + 30 + v) > SIGMIN)            ||
+                          (*(V + 30 + v - 1) > SIGMIN))) {
+                       /* (case 4) */
+                       if (*(V + 30 + v) >= *(V + 30 + v - 1)) {
+                               swp_freq = fOSC * 1000 + afcex_freq;
+                               *SIG1 = *(V + 30 + v);
+                       } else {
+                               swp_freq = fOSC * 1000 + afcex_freq - swp_ofs;
+                               *SIG1 = *(V + 30 + v - 1);
+                       }
+               } else  {
+                       swp_freq = -1 ;
+               }
+       } else if ((i % 2 == 0) && (v >= vmin)) {
+               /* Negative v (case 1) */
+               if ((*(V + 30 + v) > 0)                         &&
+                   (*(V + 30 + v + 1) > 0)                     &&
+                   (*(V + 30 + v + 2) > 0)                     &&
+                   (*(V + 30 + v + 1) > *(V + 30 + v))         &&
+                   (*(V + 30 + v + 1) > *(V + 30 + v + 2))     &&
+                   (*(V + 30 + v + 1) > SIGMIN)) {
+
+                       swp_freq = fOSC * 1000 + afcex_freq + swp_ofs;
+                       *SIG1 = *(V + 30 + v + 1);
+               } else if ((v + 1 == vmax)                      &&
+                          (*(V + 30 + v) >= 0)                 &&
+                          (*(V + 30 + v + 1) >= 0)             &&
+                          (*(V + 30 + v + 1) > *(V + 30 + v))  &&
+                          (*(V + 30 + v + 1) > SIGMIN)) {
+                       /* (case 2) */
+                       swp_freq = fOSC * 1000 + afcex_freq + swp_ofs;
+                       *SIG1 = *(V + 30 + v);
+               } else if ((v == vmin)                          &&
+                          (*(V + 30 + v) > 0)                  &&
+                          (*(V + 30 + v + 1) > 0)              &&
+                          (*(V + 30 + v + 2) > 0)              &&
+                          (*(V + 30 + v) > *(V + 30 + v + 1))  &&
+                          (*(V + 30 + v) > *(V + 30 + v + 2))  &&
+                          (*(V + 30 + v) > SIGMIN)) {
+                       /* (case 3) */
+                       swp_freq = fOSC * 1000 + afcex_freq;
+                       *SIG1 = *(V + 30 + v);
+               } else if ((*(V + 30 + v) >= 0)                 &&
+                          (*(V + 30 + v + 1) >= 0)             &&
+                          (*(V + 30 + v + 2) >= 0)             &&
+                          (*(V + 30 + v + 3) >= 0)             &&
+                          (*(V + 30 + v + 1) > *(V + 30 + v))  &&
+                          (*(V + 30 + v + 2) > *(V + 30 + v + 3)) &&
+                          ((*(V + 30 + v + 1) > SIGMIN)        ||
+                           (*(V + 30 + v + 2) > SIGMIN))) {
+                       /* (case 4) */
+                       if (*(V + 30 + v + 1) >= *(V + 30 + v + 2)) {
+                               swp_freq = fOSC * 1000 + afcex_freq + swp_ofs;
+                               *SIG1 = *(V + 30 + v + 1);
+                       } else {
+                               swp_freq = fOSC * 1000 + afcex_freq + swp_ofs * 2;
+                               *SIG1 = *(V + 30 + v + 2);
+                       }
+               } else if ((*(V + 30 + v) >= 0)                 &&
+                          (*(V + 30 + v + 1) >= 0)             &&
+                          (*(V + 30 + v + 2) >= 0)             &&
+                          (*(V + 30 + v + 3) >= 0)             &&
+                          (*(V + 30 + v) > *(V + 30 + v + 2))  &&
+                          (*(V + 30 + v + 1) > *(V + 30 + v + 2)) &&
+                          (*(V + 30 + v) > *(V + 30 + v + 3))  &&
+                          (*(V + 30 + v + 1) > *(V + 30 + v + 3)) &&
+                          ((*(V + 30 + v) > SIGMIN)            ||
+                           (*(V + 30 + v + 1) > SIGMIN))) {
+                       /* (case 5) */
+                       if (*(V + 30 + v) >= *(V + 30 + v + 1)) {
+                               swp_freq = fOSC * 1000 + afcex_freq;
+                               *SIG1 = *(V + 30 + v);
+                       } else {
+                               swp_freq = fOSC * 1000 + afcex_freq + swp_ofs;
+                               *SIG1 = *(V + 30 + v + 1);
+                       }
+               } else if ((v + 2 == vmin)                      &&
+                          (*(V + 30 + v) >= 0)                 &&
+                          (*(V + 30 + v + 1) >= 0)             &&
+                          (*(V + 30 + v + 2) >= 0)             &&
+                          (*(V + 30 + v + 1) > *(V + 30 + v))  &&
+                          (*(V + 30 + v + 2) > *(V + 30 + v))  &&
+                          ((*(V + 30 + v + 1) > SIGMIN)        ||
+                           (*(V + 30 + v + 2) > SIGMIN))) {
+                       /* (case 6) */
+                       if (*(V + 30 + v + 1) >= *(V + 30 + v + 2)) {
+                               swp_freq = fOSC * 1000 + afcex_freq + swp_ofs;
+                               *SIG1 = *(V + 30 + v + 1);
+                       } else {
+                               swp_freq = fOSC * 1000 + afcex_freq + swp_ofs * 2;
+                               *SIG1 = *(V + 30 + v + 2);
+                       }
+               } else if ((vmax == 0) && (vmin == 0) && (*(V + 30 + v) > SIGMIN)) {
+                       swp_freq = fOSC * 1000;
+                       *SIG1 = *(V + 30 + v);
+               } else
+                       swp_freq = -1;
+       } else
+               swp_freq = -1;
+
+       return swp_freq;
+}
+
+static void swp_info_get2(struct mb86a16_state *state,
+                         int smrt,
+                         int R,
+                         int swp_freq,
+                         int *afcex_freq,
+                         int *fOSC,
+                         unsigned char *AFCEX_L,
+                         unsigned char *AFCEX_H)
+{
+       int AFCEX ;
+
+       if (R == 0)
+               *fOSC = (swp_freq + 1000) / 2000 * 2;
+       else
+               *fOSC = (swp_freq + 500) / 1000;
+
+       if (*fOSC >= swp_freq)
+               *afcex_freq = *fOSC * 1000 - swp_freq;
+       else
+               *afcex_freq = swp_freq - *fOSC * 1000;
+
+       AFCEX = *afcex_freq * 8192 / state->master_clk;
+       *AFCEX_L =  AFCEX & 0x00ff;
+       *AFCEX_H = (AFCEX & 0x0f00) >> 8;
+}
+
+static void afcex_info_get(struct mb86a16_state *state,
+                          int afcex_freq,
+                          unsigned char *AFCEX_L,
+                          unsigned char *AFCEX_H)
+{
+       int AFCEX ;
+
+       AFCEX = afcex_freq * 8192 / state->master_clk;
+       *AFCEX_L =  AFCEX & 0x00ff;
+       *AFCEX_H = (AFCEX & 0x0f00) >> 8;
+}
+
+static int SEQ_set(struct mb86a16_state *state, unsigned char loop)
+{
+       /* SLOCK0 = 0 */
+       if (mb86a16_write(state, 0x32, 0x02 | (loop << 2)) < 0) {
+               dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+               return -EREMOTEIO;
+       }
+
+       return 0;
+}
+
+static int iq_vt_set(struct mb86a16_state *state, unsigned char IQINV)
+{
+       /* Viterbi Rate, IQ Settings */
+       if (mb86a16_write(state, 0x06, 0xdf | (IQINV << 5)) < 0) {
+               dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+               return -EREMOTEIO;
+       }
+
+       return 0;
+}
+
+static int FEC_srst(struct mb86a16_state *state)
+{
+       if (mb86a16_write(state, MB86A16_RESET, 0x02) < 0) {
+               dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+               return -EREMOTEIO;
+       }
+
+       return 0;
+}
+
+static int S2T_set(struct mb86a16_state *state, unsigned char S2T)
+{
+       if (mb86a16_write(state, 0x34, 0x70 | S2T) < 0) {
+               dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+               return -EREMOTEIO;
+       }
+
+       return 0;
+}
+
+static int S45T_set(struct mb86a16_state *state, unsigned char S4T, unsigned char S5T)
+{
+       if (mb86a16_write(state, 0x35, 0x00 | (S5T << 4) | S4T) < 0) {
+               dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+               return -EREMOTEIO;
+       }
+
+       return 0;
+}
+
+
+static int mb86a16_set_fe(struct mb86a16_state *state)
+{
+       u8 agcval, cnmval;
+
+       int i, j;
+       int fOSC = 0;
+       int fOSC_start = 0;
+       int wait_t;
+       int fcp;
+       int swp_ofs;
+       int V[60];
+       u8 SIG1MIN;
+
+       unsigned char CREN, AFCEN, AFCEXEN;
+       unsigned char SIG1;
+       unsigned char TIMINT1, TIMINT2, TIMEXT;
+       unsigned char S0T, S1T;
+       unsigned char S2T;
+/*     unsigned char S2T, S3T; */
+       unsigned char S4T, S5T;
+       unsigned char AFCEX_L, AFCEX_H;
+       unsigned char R;
+       unsigned char VIRM;
+       unsigned char ETH, VIA;
+       unsigned char junk;
+
+       int loop;
+       int ftemp;
+       int v, vmax, vmin;
+       int vmax_his, vmin_his;
+       int swp_freq, prev_swp_freq[20];
+       int prev_freq_num;
+       int signal_dupl;
+       int afcex_freq;
+       int signal;
+       int afcerr;
+       int temp_freq, delta_freq;
+       int dagcm[4];
+       int smrt_d;
+/*     int freq_err; */
+       int n;
+       int ret = -1;
+       int sync;
+
+       dprintk(verbose, MB86A16_INFO, 1, "freq=%d Mhz, symbrt=%d Ksps", state->frequency, state->srate);
+
+       fcp = 3000;
+       swp_ofs = state->srate / 4;
+
+       for (i = 0; i < 60; i++)
+               V[i] = -1;
+
+       for (i = 0; i < 20; i++)
+               prev_swp_freq[i] = 0;
+
+       SIG1MIN = 25;
+
+       for (n = 0; ((n < 3) && (ret == -1)); n++) {
+               SEQ_set(state, 0);
+               iq_vt_set(state, 0);
+
+               CREN = 0;
+               AFCEN = 0;
+               AFCEXEN = 1;
+               TIMINT1 = 0;
+               TIMINT2 = 1;
+               TIMEXT = 2;
+               S1T = 0;
+               S0T = 0;
+
+               if (initial_set(state) < 0) {
+                       dprintk(verbose, MB86A16_ERROR, 1, "initial set failed");
+                       return -1;
+               }
+               if (DAGC_data_set(state, 3, 2) < 0) {
+                       dprintk(verbose, MB86A16_ERROR, 1, "DAGC data set error");
+                       return -1;
+               }
+               if (EN_set(state, CREN, AFCEN) < 0) {
+                       dprintk(verbose, MB86A16_ERROR, 1, "EN set error");
+                       return -1; /* (0, 0) */
+               }
+               if (AFCEXEN_set(state, AFCEXEN, state->srate) < 0) {
+                       dprintk(verbose, MB86A16_ERROR, 1, "AFCEXEN set error");
+                       return -1; /* (1, smrt) = (1, symbolrate) */
+               }
+               if (CNTM_set(state, TIMINT1, TIMINT2, TIMEXT) < 0) {
+                       dprintk(verbose, MB86A16_ERROR, 1, "CNTM set error");
+                       return -1; /* (0, 1, 2) */
+               }
+               if (S01T_set(state, S1T, S0T) < 0) {
+                       dprintk(verbose, MB86A16_ERROR, 1, "S01T set error");
+                       return -1; /* (0, 0) */
+               }
+               smrt_info_get(state, state->srate);
+               if (smrt_set(state, state->srate) < 0) {
+                       dprintk(verbose, MB86A16_ERROR, 1, "smrt info get error");
+                       return -1;
+               }
+
+               R = vco_dev_get(state, state->srate);
+               if (R == 1)
+                       fOSC_start = state->frequency;
+
+               else if (R == 0) {
+                       if (state->frequency % 2 == 0) {
+                               fOSC_start = state->frequency;
+                       } else {
+                               fOSC_start = state->frequency + 1;
+                               if (fOSC_start > 2150)
+                                       fOSC_start = state->frequency - 1;
+                       }
+               }
+               loop = 1;
+               ftemp = fOSC_start * 1000;
+               vmax = 0 ;
+               while (loop == 1) {
+                       ftemp = ftemp + swp_ofs;
+                       vmax++;
+
+                       /* Upper bound */
+                       if (ftemp > 2150000) {
+                               loop = 0;
+                               vmax--;
+                       } else {
+                               if ((ftemp == 2150000) ||
+                                   (ftemp - state->frequency * 1000 >= fcp + state->srate / 4))
+                                       loop = 0;
+                       }
+               }
+
+               loop = 1;
+               ftemp = fOSC_start * 1000;
+               vmin = 0 ;
+               while (loop == 1) {
+                       ftemp = ftemp - swp_ofs;
+                       vmin--;
+
+                       /* Lower bound */
+                       if (ftemp < 950000) {
+                               loop = 0;
+                               vmin++;
+                       } else {
+                               if ((ftemp == 950000) ||
+                                   (state->frequency * 1000 - ftemp >= fcp + state->srate / 4))
+                                       loop = 0;
+                       }
+               }
+
+               wait_t = (8000 + state->srate / 2) / state->srate;
+               if (wait_t == 0)
+                       wait_t = 1;
+
+               i = 0;
+               j = 0;
+               prev_freq_num = 0;
+               loop = 1;
+               signal = 0;
+               vmax_his = 0;
+               vmin_his = 0;
+               v = 0;
+
+               while (loop == 1) {
+                       swp_info_get(state, fOSC_start, state->srate,
+                                    v, R, swp_ofs, &fOSC,
+                                    &afcex_freq, &AFCEX_L, &AFCEX_H);
+
+                       udelay(100);
+                       if (rf_val_set(state, fOSC, state->srate, R) < 0) {
+                               dprintk(verbose, MB86A16_ERROR, 1, "rf val set error");
+                               return -1;
+                       }
+                       udelay(100);
+                       if (afcex_data_set(state, AFCEX_L, AFCEX_H) < 0) {
+                               dprintk(verbose, MB86A16_ERROR, 1, "afcex data set error");
+                               return -1;
+                       }
+                       if (srst(state) < 0) {
+                               dprintk(verbose, MB86A16_ERROR, 1, "srst error");
+                               return -1;
+                       }
+                       msleep_interruptible(wait_t);
+
+                       if (mb86a16_read(state, 0x37, &SIG1) != 2) {
+                               dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+                               return -1;
+                       }
+                       V[30 + v] = SIG1 ;
+                       swp_freq = swp_freq_calcuation(state, i, v, V, vmax, vmin,
+                                                     SIG1MIN, fOSC, afcex_freq,
+                                                     swp_ofs, &SIG1);  /* changed */
+
+                       signal_dupl = 0;
+                       for (j = 0; j < prev_freq_num; j++) {
+                               if ((ABS(prev_swp_freq[j] - swp_freq)) < (swp_ofs * 3 / 2)) {
+                                       signal_dupl = 1;
+                                       dprintk(verbose, MB86A16_INFO, 1, "Probably Duplicate Signal, j = %d", j);
+                               }
+                       }
+                       if ((signal_dupl == 0) && (swp_freq > 0) && (ABS(swp_freq - state->frequency * 1000) < fcp + state->srate / 6)) {
+                               dprintk(verbose, MB86A16_DEBUG, 1, "------ Signal detect ------ [swp_freq=[%07d, srate=%05d]]", swp_freq, state->srate);
+                               prev_swp_freq[prev_freq_num] = swp_freq;
+                               prev_freq_num++;
+                               swp_info_get2(state, state->srate, R, swp_freq,
+                                             &afcex_freq, &fOSC,
+                                             &AFCEX_L, &AFCEX_H);
+
+                               if (rf_val_set(state, fOSC, state->srate, R) < 0) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "rf val set error");
+                                       return -1;
+                               }
+                               if (afcex_data_set(state, AFCEX_L, AFCEX_H) < 0) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "afcex data set error");
+                                       return -1;
+                               }
+                               signal = signal_det(state, state->srate, &SIG1);
+                               if (signal == 1) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "***** Signal Found *****");
+                                       loop = 0;
+                               } else {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "!!!!! No signal !!!!!, try again...");
+                                       smrt_info_get(state, state->srate);
+                                       if (smrt_set(state, state->srate) < 0) {
+                                               dprintk(verbose, MB86A16_ERROR, 1, "smrt set error");
+                                               return -1;
+                                       }
+                               }
+                       }
+                       if (v > vmax)
+                               vmax_his = 1 ;
+                       if (v < vmin)
+                               vmin_his = 1 ;
+                       i++;
+
+                       if ((i % 2 == 1) && (vmax_his == 1))
+                               i++;
+                       if ((i % 2 == 0) && (vmin_his == 1))
+                               i++;
+
+                       if (i % 2 == 1)
+                               v = (i + 1) / 2;
+                       else
+                               v = -i / 2;
+
+                       if ((vmax_his == 1) && (vmin_his == 1))
+                               loop = 0 ;
+               }
+
+               if (signal == 1) {
+                       dprintk(verbose, MB86A16_INFO, 1, " Start Freq Error Check");
+                       S1T = 7 ;
+                       S0T = 1 ;
+                       CREN = 0 ;
+                       AFCEN = 1 ;
+                       AFCEXEN = 0 ;
+
+                       if (S01T_set(state, S1T, S0T) < 0) {
+                               dprintk(verbose, MB86A16_ERROR, 1, "S01T set error");
+                               return -1;
+                       }
+                       smrt_info_get(state, state->srate);
+                       if (smrt_set(state, state->srate) < 0) {
+                               dprintk(verbose, MB86A16_ERROR, 1, "smrt set error");
+                               return -1;
+                       }
+                       if (EN_set(state, CREN, AFCEN) < 0) {
+                               dprintk(verbose, MB86A16_ERROR, 1, "EN set error");
+                               return -1;
+                       }
+                       if (AFCEXEN_set(state, AFCEXEN, state->srate) < 0) {
+                               dprintk(verbose, MB86A16_ERROR, 1, "AFCEXEN set error");
+                               return -1;
+                       }
+                       afcex_info_get(state, afcex_freq, &AFCEX_L, &AFCEX_H);
+                       if (afcofs_data_set(state, AFCEX_L, AFCEX_H) < 0) {
+                               dprintk(verbose, MB86A16_ERROR, 1, "AFCOFS data set error");
+                               return -1;
+                       }
+                       if (srst(state) < 0) {
+                               dprintk(verbose, MB86A16_ERROR, 1, "srst error");
+                               return -1;
+                       }
+                       /* delay 4~200 */
+                       wait_t = 200000 / state->master_clk + 200000 / state->srate;
+                       msleep(wait_t);
+                       afcerr = afcerr_chk(state);
+                       if (afcerr == -1)
+                               return -1;
+
+                       swp_freq = fOSC * 1000 + afcerr ;
+                       AFCEXEN = 1 ;
+                       if (state->srate >= 1500)
+                               smrt_d = state->srate / 3;
+                       else
+                               smrt_d = state->srate / 2;
+                       smrt_info_get(state, smrt_d);
+                       if (smrt_set(state, smrt_d) < 0) {
+                               dprintk(verbose, MB86A16_ERROR, 1, "smrt set error");
+                               return -1;
+                       }
+                       if (AFCEXEN_set(state, AFCEXEN, smrt_d) < 0) {
+                               dprintk(verbose, MB86A16_ERROR, 1, "AFCEXEN set error");
+                               return -1;
+                       }
+                       R = vco_dev_get(state, smrt_d);
+                       if (DAGC_data_set(state, 2, 0) < 0) {
+                               dprintk(verbose, MB86A16_ERROR, 1, "DAGC data set error");
+                               return -1;
+                       }
+                       for (i = 0; i < 3; i++) {
+                               temp_freq = swp_freq + (i - 1) * state->srate / 8;
+                               swp_info_get2(state, smrt_d, R, temp_freq, &afcex_freq, &fOSC, &AFCEX_L, &AFCEX_H);
+                               if (rf_val_set(state, fOSC, smrt_d, R) < 0) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "rf val set error");
+                                       return -1;
+                               }
+                               if (afcex_data_set(state, AFCEX_L, AFCEX_H) < 0) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "afcex data set error");
+                                       return -1;
+                               }
+                               wait_t = 200000 / state->master_clk + 40000 / smrt_d;
+                               msleep(wait_t);
+                               dagcm[i] = dagcm_val_get(state);
+                       }
+                       if ((dagcm[0] > dagcm[1]) &&
+                           (dagcm[0] > dagcm[2]) &&
+                           (dagcm[0] - dagcm[1] > 2 * (dagcm[2] - dagcm[1]))) {
+
+                               temp_freq = swp_freq - 2 * state->srate / 8;
+                               swp_info_get2(state, smrt_d, R, temp_freq, &afcex_freq, &fOSC, &AFCEX_L, &AFCEX_H);
+                               if (rf_val_set(state, fOSC, smrt_d, R) < 0) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "rf val set error");
+                                       return -1;
+                               }
+                               if (afcex_data_set(state, AFCEX_L, AFCEX_H) < 0) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "afcex data set");
+                                       return -1;
+                               }
+                               wait_t = 200000 / state->master_clk + 40000 / smrt_d;
+                               msleep(wait_t);
+                               dagcm[3] = dagcm_val_get(state);
+                               if (dagcm[3] > dagcm[1])
+                                       delta_freq = (dagcm[2] - dagcm[0] + dagcm[1] - dagcm[3]) * state->srate / 300;
+                               else
+                                       delta_freq = 0;
+                       } else if ((dagcm[2] > dagcm[1]) &&
+                                  (dagcm[2] > dagcm[0]) &&
+                                  (dagcm[2] - dagcm[1] > 2 * (dagcm[0] - dagcm[1]))) {
+
+                               temp_freq = swp_freq + 2 * state->srate / 8;
+                               swp_info_get2(state, smrt_d, R, temp_freq, &afcex_freq, &fOSC, &AFCEX_L, &AFCEX_H);
+                               if (rf_val_set(state, fOSC, smrt_d, R) < 0) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "rf val set");
+                                       return -1;
+                               }
+                               if (afcex_data_set(state, AFCEX_L, AFCEX_H) < 0) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "afcex data set");
+                                       return -1;
+                               }
+                               wait_t = 200000 / state->master_clk + 40000 / smrt_d;
+                               msleep(wait_t);
+                               dagcm[3] = dagcm_val_get(state);
+                               if (dagcm[3] > dagcm[1])
+                                       delta_freq = (dagcm[2] - dagcm[0] + dagcm[3] - dagcm[1]) * state->srate / 300;
+                               else
+                                       delta_freq = 0 ;
+
+                       } else {
+                               delta_freq = 0 ;
+                       }
+                       dprintk(verbose, MB86A16_INFO, 1, "SWEEP Frequency = %d", swp_freq);
+                       swp_freq += delta_freq;
+                       dprintk(verbose, MB86A16_INFO, 1, "Adjusting .., DELTA Freq = %d, SWEEP Freq=%d", delta_freq, swp_freq);
+                       if (ABS(state->frequency * 1000 - swp_freq) > 3800) {
+                               dprintk(verbose, MB86A16_INFO, 1, "NO  --  SIGNAL !");
+                       } else {
+
+                               S1T = 0;
+                               S0T = 3;
+                               CREN = 1;
+                               AFCEN = 0;
+                               AFCEXEN = 1;
+
+                               if (S01T_set(state, S1T, S0T) < 0) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "S01T set error");
+                                       return -1;
+                               }
+                               if (DAGC_data_set(state, 0, 0) < 0) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "DAGC data set error");
+                                       return -1;
+                               }
+                               R = vco_dev_get(state, state->srate);
+                               smrt_info_get(state, state->srate);
+                               if (smrt_set(state, state->srate) < 0) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "smrt set error");
+                                       return -1;
+                               }
+                               if (EN_set(state, CREN, AFCEN) < 0) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "EN set error");
+                                       return -1;
+                               }
+                               if (AFCEXEN_set(state, AFCEXEN, state->srate) < 0) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "AFCEXEN set error");
+                                       return -1;
+                               }
+                               swp_info_get2(state, state->srate, R, swp_freq, &afcex_freq, &fOSC, &AFCEX_L, &AFCEX_H);
+                               if (rf_val_set(state, fOSC, state->srate, R) < 0) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "rf val set error");
+                                       return -1;
+                               }
+                               if (afcex_data_set(state, AFCEX_L, AFCEX_H) < 0) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "afcex data set error");
+                                       return -1;
+                               }
+                               if (srst(state) < 0) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "srst error");
+                                       return -1;
+                               }
+                               wait_t = 7 + (10000 + state->srate / 2) / state->srate;
+                               if (wait_t == 0)
+                                       wait_t = 1;
+                               msleep_interruptible(wait_t);
+                               if (mb86a16_read(state, 0x37, &SIG1) != 2) {
+                                       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+                                       return -EREMOTEIO;
+                               }
+
+                               if (SIG1 > 110) {
+                                       S2T = 4; S4T = 1; S5T = 6; ETH = 4; VIA = 6;
+                                       wait_t = 7 + (917504 + state->srate / 2) / state->srate;
+                               } else if (SIG1 > 105) {
+                                       S2T = 4; S4T = 2; S5T = 8; ETH = 7; VIA = 2;
+                                       wait_t = 7 + (1048576 + state->srate / 2) / state->srate;
+                               } else if (SIG1 > 85) {
+                                       S2T = 5; S4T = 2; S5T = 8; ETH = 7; VIA = 2;
+                                       wait_t = 7 + (1310720 + state->srate / 2) / state->srate;
+                               } else if (SIG1 > 65) {
+                                       S2T = 6; S4T = 2; S5T = 8; ETH = 7; VIA = 2;
+                                       wait_t = 7 + (1572864 + state->srate / 2) / state->srate;
+                               } else {
+                                       S2T = 7; S4T = 2; S5T = 8; ETH = 7; VIA = 2;
+                                       wait_t = 7 + (2097152 + state->srate / 2) / state->srate;
+                               }
+                               wait_t *= 2; /* FOS */
+                               S2T_set(state, S2T);
+                               S45T_set(state, S4T, S5T);
+                               Vi_set(state, ETH, VIA);
+                               srst(state);
+                               msleep_interruptible(wait_t);
+                               sync = sync_chk(state, &VIRM);
+                               dprintk(verbose, MB86A16_INFO, 1, "-------- Viterbi=[%d] SYNC=[%d] ---------", VIRM, sync);
+                               if (VIRM) {
+                                       if (VIRM == 4) {
+                                               /* 5/6 */
+                                               if (SIG1 > 110)
+                                                       wait_t = (786432 + state->srate / 2) / state->srate;
+                                               else
+                                                       wait_t = (1572864 + state->srate / 2) / state->srate;
+                                               if (state->srate < 5000)
+                                                       /* FIXME ! , should be a long wait ! */
+                                                       msleep_interruptible(wait_t);
+                                               else
+                                                       msleep_interruptible(wait_t);
+
+                                               if (sync_chk(state, &junk) == 0) {
+                                                       iq_vt_set(state, 1);
+                                                       FEC_srst(state);
+                                               }
+                                       }
+                                       /* 1/2, 2/3, 3/4, 7/8 */
+                                       if (SIG1 > 110)
+                                               wait_t = (786432 + state->srate / 2) / state->srate;
+                                       else
+                                               wait_t = (1572864 + state->srate / 2) / state->srate;
+                                       msleep_interruptible(wait_t);
+                                       SEQ_set(state, 1);
+                               } else {
+                                       dprintk(verbose, MB86A16_INFO, 1, "NO  -- SYNC");
+                                       SEQ_set(state, 1);
+                                       ret = -1;
+                               }
+                       }
+               } else {
+                       dprintk(verbose, MB86A16_INFO, 1, "NO  -- SIGNAL");
+                       ret = -1;
+               }
+
+               sync = sync_chk(state, &junk);
+               if (sync) {
+                       dprintk(verbose, MB86A16_INFO, 1, "******* SYNC *******");
+                       freqerr_chk(state, state->frequency, state->srate, 1);
+                       ret = 0;
+                       break;
+               }
+       }
+
+       mb86a16_read(state, 0x15, &agcval);
+       mb86a16_read(state, 0x26, &cnmval);
+       dprintk(verbose, MB86A16_INFO, 1, "AGC = %02x CNM = %02x", agcval, cnmval);
+
+       return ret;
+}
+
+static int mb86a16_send_diseqc_msg(struct dvb_frontend *fe,
+                                  struct dvb_diseqc_master_cmd *cmd)
+{
+       struct mb86a16_state *state = fe->demodulator_priv;
+       int i;
+       u8 regs;
+
+       if (mb86a16_write(state, MB86A16_DCC1, MB86A16_DCC1_DISTA) < 0)
+               goto err;
+       if (mb86a16_write(state, MB86A16_DCCOUT, 0x00) < 0)
+               goto err;
+       if (mb86a16_write(state, MB86A16_TONEOUT2, 0x04) < 0)
+               goto err;
+
+       regs = 0x18;
+
+       if (cmd->msg_len > 5 || cmd->msg_len < 4)
+               return -EINVAL;
+
+       for (i = 0; i < cmd->msg_len; i++) {
+               if (mb86a16_write(state, regs, cmd->msg[i]) < 0)
+                       goto err;
+
+               regs++;
+       }
+       i += 0x90;
+
+       msleep_interruptible(10);
+
+       if (mb86a16_write(state, MB86A16_DCC1, i) < 0)
+               goto err;
+       if (mb86a16_write(state, MB86A16_DCCOUT, MB86A16_DCCOUT_DISEN) < 0)
+               goto err;
+
+       return 0;
+
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+}
+
+static int mb86a16_send_diseqc_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t burst)
+{
+       struct mb86a16_state *state = fe->demodulator_priv;
+
+       switch (burst) {
+       case SEC_MINI_A:
+               if (mb86a16_write(state, MB86A16_DCC1, MB86A16_DCC1_DISTA |
+                                                      MB86A16_DCC1_TBEN  |
+                                                      MB86A16_DCC1_TBO) < 0)
+                       goto err;
+               if (mb86a16_write(state, MB86A16_DCCOUT, MB86A16_DCCOUT_DISEN) < 0)
+                       goto err;
+               break;
+       case SEC_MINI_B:
+               if (mb86a16_write(state, MB86A16_DCC1, MB86A16_DCC1_DISTA |
+                                                      MB86A16_DCC1_TBEN) < 0)
+                       goto err;
+               if (mb86a16_write(state, MB86A16_DCCOUT, MB86A16_DCCOUT_DISEN) < 0)
+                       goto err;
+               break;
+       }
+
+       return 0;
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+}
+
+static int mb86a16_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
+{
+       struct mb86a16_state *state = fe->demodulator_priv;
+
+       switch (tone) {
+       case SEC_TONE_ON:
+               if (mb86a16_write(state, MB86A16_TONEOUT2, 0x00) < 0)
+                       goto err;
+               if (mb86a16_write(state, MB86A16_DCC1, MB86A16_DCC1_DISTA |
+                                                      MB86A16_DCC1_CTOE) < 0)
+
+                       goto err;
+               if (mb86a16_write(state, MB86A16_DCCOUT, MB86A16_DCCOUT_DISEN) < 0)
+                       goto err;
+               break;
+       case SEC_TONE_OFF:
+               if (mb86a16_write(state, MB86A16_TONEOUT2, 0x04) < 0)
+                       goto err;
+               if (mb86a16_write(state, MB86A16_DCC1, MB86A16_DCC1_DISTA) < 0)
+                       goto err;
+               if (mb86a16_write(state, MB86A16_DCCOUT, 0x00) < 0)
+                       goto err;
+               break;
+       default:
+               return -EINVAL;
+       }
+       return 0;
+
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+}
+
+static enum dvbfe_search mb86a16_search(struct dvb_frontend *fe,
+                                       struct dvb_frontend_parameters *p)
+{
+       struct mb86a16_state *state = fe->demodulator_priv;
+
+       state->frequency = p->frequency / 1000;
+       state->srate = p->u.qpsk.symbol_rate / 1000;
+
+       if (!mb86a16_set_fe(state)) {
+               dprintk(verbose, MB86A16_ERROR, 1, "Succesfully acquired LOCK");
+               return DVBFE_ALGO_SEARCH_SUCCESS;
+       }
+
+       dprintk(verbose, MB86A16_ERROR, 1, "Lock acquisition failed!");
+       return DVBFE_ALGO_SEARCH_FAILED;
+}
+
+static void mb86a16_release(struct dvb_frontend *fe)
+{
+       struct mb86a16_state *state = fe->demodulator_priv;
+       kfree(state);
+}
+
+static int mb86a16_init(struct dvb_frontend *fe)
+{
+       return 0;
+}
+
+static int mb86a16_sleep(struct dvb_frontend *fe)
+{
+       return 0;
+}
+
+static int mb86a16_read_ber(struct dvb_frontend *fe, u32 *ber)
+{
+       u8 ber_mon, ber_tab, ber_lsb, ber_mid, ber_msb, ber_tim, ber_rst;
+       u32 timer;
+
+       struct mb86a16_state *state = fe->demodulator_priv;
+
+       *ber = 0;
+       if (mb86a16_read(state, MB86A16_BERMON, &ber_mon) != 2)
+               goto err;
+       if (mb86a16_read(state, MB86A16_BERTAB, &ber_tab) != 2)
+               goto err;
+       if (mb86a16_read(state, MB86A16_BERLSB, &ber_lsb) != 2)
+               goto err;
+       if (mb86a16_read(state, MB86A16_BERMID, &ber_mid) != 2)
+               goto err;
+       if (mb86a16_read(state, MB86A16_BERMSB, &ber_msb) != 2)
+               goto err;
+       /* BER monitor invalid when BER_EN = 0  */
+       if (ber_mon & 0x04) {
+               /* coarse, fast calculation     */
+               *ber = ber_tab & 0x1f;
+               dprintk(verbose, MB86A16_DEBUG, 1, "BER coarse=[0x%02x]", *ber);
+               if (ber_mon & 0x01) {
+                       /*
+                        * BER_SEL = 1, The monitored BER is the estimated
+                        * value with a Reed-Solomon decoder error amount at
+                        * the deinterleaver output.
+                        * monitored BER is expressed as a 20 bit output in total
+                        */
+                       ber_rst = ber_mon >> 3;
+                       *ber = (((ber_msb << 8) | ber_mid) << 8) | ber_lsb;
+                       if (ber_rst == 0)
+                               timer =  12500000;
+                       if (ber_rst == 1)
+                               timer =  25000000;
+                       if (ber_rst == 2)
+                               timer =  50000000;
+                       if (ber_rst == 3)
+                               timer = 100000000;
+
+                       *ber /= timer;
+                       dprintk(verbose, MB86A16_DEBUG, 1, "BER fine=[0x%02x]", *ber);
+               } else {
+                       /*
+                        * BER_SEL = 0, The monitored BER is the estimated
+                        * value with a Viterbi decoder error amount at the
+                        * QPSK demodulator output.
+                        * monitored BER is expressed as a 24 bit output in total
+                        */
+                       ber_tim = ber_mon >> 1;
+                       *ber = (((ber_msb << 8) | ber_mid) << 8) | ber_lsb;
+                       if (ber_tim == 0)
+                               timer = 16;
+                       if (ber_tim == 1)
+                               timer = 24;
+
+                       *ber /= 2 ^ timer;
+                       dprintk(verbose, MB86A16_DEBUG, 1, "BER fine=[0x%02x]", *ber);
+               }
+       }
+       return 0;
+err:
+       dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+       return -EREMOTEIO;
+}
+
+static int mb86a16_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
+{
+       u8 agcm = 0;
+       struct mb86a16_state *state = fe->demodulator_priv;
+
+       *strength = 0;
+       if (mb86a16_read(state, MB86A16_AGCM, &agcm) != 2) {
+               dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+               return -EREMOTEIO;
+       }
+
+       *strength = ((0xff - agcm) * 100) / 256;
+       dprintk(verbose, MB86A16_DEBUG, 1, "Signal strength=[%d %%]", (u8) *strength);
+       *strength = (0xffff - 0xff) + agcm;
+
+       return 0;
+}
+
+struct cnr {
+       u8 cn_reg;
+       u8 cn_val;
+};
+
+static const struct cnr cnr_tab[] = {
+       {  35,  2 },
+       {  40,  3 },
+       {  50,  4 },
+       {  60,  5 },
+       {  70,  6 },
+       {  80,  7 },
+       {  92,  8 },
+       { 103,  9 },
+       { 115, 10 },
+       { 138, 12 },
+       { 162, 15 },
+       { 180, 18 },
+       { 185, 19 },
+       { 189, 20 },
+       { 195, 22 },
+       { 199, 24 },
+       { 201, 25 },
+       { 202, 26 },
+       { 203, 27 },
+       { 205, 28 },
+       { 208, 30 }
+};
+
+static int mb86a16_read_snr(struct dvb_frontend *fe, u16 *snr)
+{
+       struct mb86a16_state *state = fe->demodulator_priv;
+       int i = 0;
+       int low_tide = 2, high_tide = 30, q_level;
+       u8  cn;
+
+       *snr = 0;
+       if (mb86a16_read(state, 0x26, &cn) != 2) {
+               dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+               return -EREMOTEIO;
+       }
+
+       for (i = 0; i < ARRAY_SIZE(cnr_tab); i++) {
+               if (cn < cnr_tab[i].cn_reg) {
+                       *snr = cnr_tab[i].cn_val;
+                       break;
+               }
+       }
+       q_level = (*snr * 100) / (high_tide - low_tide);
+       dprintk(verbose, MB86A16_ERROR, 1, "SNR (Quality) = [%d dB], Level=%d %%", *snr, q_level);
+       *snr = (0xffff - 0xff) + *snr;
+
+       return 0;
+}
+
+static int mb86a16_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
+{
+       u8 dist;
+       struct mb86a16_state *state = fe->demodulator_priv;
+
+       if (mb86a16_read(state, MB86A16_DISTMON, &dist) != 2) {
+               dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+               return -EREMOTEIO;
+       }
+       *ucblocks = dist;
+
+       return 0;
+}
+
+static enum dvbfe_algo mb86a16_frontend_algo(struct dvb_frontend *fe)
+{
+       return DVBFE_ALGO_CUSTOM;
+}
+
+static struct dvb_frontend_ops mb86a16_ops = {
+       .info = {
+               .name                   = "Fujitsu MB86A16 DVB-S",
+               .type                   = FE_QPSK,
+               .frequency_min          = 950000,
+               .frequency_max          = 2150000,
+               .frequency_stepsize     = 3000,
+               .frequency_tolerance    = 0,
+               .symbol_rate_min        = 1000000,
+               .symbol_rate_max        = 45000000,
+               .symbol_rate_tolerance  = 500,
+               .caps                   = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
+                                         FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 |
+                                         FE_CAN_FEC_7_8 | FE_CAN_QPSK    |
+                                         FE_CAN_FEC_AUTO
+       },
+       .release                        = mb86a16_release,
+
+       .get_frontend_algo              = mb86a16_frontend_algo,
+       .search                         = mb86a16_search,
+       .read_status                    = mb86a16_read_status,
+       .init                           = mb86a16_init,
+       .sleep                          = mb86a16_sleep,
+       .read_status                    = mb86a16_read_status,
+
+       .read_ber                       = mb86a16_read_ber,
+       .read_signal_strength           = mb86a16_read_signal_strength,
+       .read_snr                       = mb86a16_read_snr,
+       .read_ucblocks                  = mb86a16_read_ucblocks,
+
+       .diseqc_send_master_cmd         = mb86a16_send_diseqc_msg,
+       .diseqc_send_burst              = mb86a16_send_diseqc_burst,
+       .set_tone                       = mb86a16_set_tone,
+};
+
+struct dvb_frontend *mb86a16_attach(const struct mb86a16_config *config,
+                                   struct i2c_adapter *i2c_adap)
+{
+       u8 dev_id = 0;
+       struct mb86a16_state *state = NULL;
+
+       state = kmalloc(sizeof(struct mb86a16_state), GFP_KERNEL);
+       if (state == NULL)
+               goto error;
+
+       state->config = config;
+       state->i2c_adap = i2c_adap;
+
+       mb86a16_read(state, 0x7f, &dev_id);
+       if (dev_id != 0xfe)
+               goto error;
+
+       memcpy(&state->frontend.ops, &mb86a16_ops, sizeof(struct dvb_frontend_ops));
+       state->frontend.demodulator_priv = state;
+       state->frontend.ops.set_voltage = state->config->set_voltage;
+
+       return &state->frontend;
+error:
+       kfree(state);
+       return NULL;
+}
+EXPORT_SYMBOL(mb86a16_attach);
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Manu Abraham");
diff --git a/drivers/media/dvb/frontends/mb86a16.h b/drivers/media/dvb/frontends/mb86a16.h
new file mode 100644 (file)
index 0000000..6ea8c37
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+       Fujitsu MB86A16 DVB-S/DSS DC Receiver driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MB86A16_H
+#define __MB86A16_H
+
+#include <linux/dvb/frontend.h>
+#include "dvb_frontend.h"
+
+
+struct mb86a16_config {
+       u8 demod_address;
+
+       int (*set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage);
+};
+
+
+
+#if defined(CONFIG_DVB_MB86A16) || (defined(CONFIG_DVB_MB86A16_MODULE) && defined(MODULE))
+
+extern struct dvb_frontend *mb86a16_attach(const struct mb86a16_config *config,
+                                          struct i2c_adapter *i2c_adap);
+
+#else
+
+static inline struct dvb_frontend *mb86a16_attach(const struct mb86a16_config *config,
+                                          struct i2c_adapter *i2c_adap)
+{
+       printk(KERN_WARNING "%s: Driver disabled by Kconfig\n", __func__);
+       return NULL;
+}
+
+#endif /* CONFIG_DVB_MB86A16 */
+
+#endif /* __MB86A16_H */
diff --git a/drivers/media/dvb/frontends/mb86a16_priv.h b/drivers/media/dvb/frontends/mb86a16_priv.h
new file mode 100644 (file)
index 0000000..360a35a
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+       Fujitsu MB86A16 DVB-S/DSS DC Receiver driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MB86A16_PRIV_H
+#define __MB86A16_PRIV_H
+
+#define MB86A16_TSOUT          0x00
+#define MB86A16_TSOUT_HIZSEL   (0x01 << 5)
+#define MB86A16_TSOUT_HIZCNTI  (0x01 << 4)
+#define MB86A16_TSOUT_MODE     (0x01 << 3)
+#define MB86A16_TSOUT_ORDER    (0x01 << 2)
+#define MB86A16_TSOUT_ERROR    (0x01 << 1)
+#define Mb86A16_TSOUT_EDGE     (0x01 << 0)
+
+#define MB86A16_FEC            0x01
+#define MB86A16_FEC_FSYNC      (0x01 << 5)
+#define MB86A16_FEC_PCKB8      (0x01 << 4)
+#define MB86A16_FEC_DVDS       (0x01 << 3)
+#define MB86A16_FEC_EREN       (0x01 << 2)
+#define Mb86A16_FEC_RSEN       (0x01 << 1)
+#define MB86A16_FEC_DIEN       (0x01 << 0)
+
+#define MB86A16_AGC            0x02
+#define MB86A16_AGC_AGMD       (0x01 << 6)
+#define MB86A16_AGC_AGCW       (0x0f << 2)
+#define MB86A16_AGC_AGCP       (0x01 << 1)
+#define MB86A16_AGC_AGCR       (0x01 << 0)
+
+#define MB86A16_SRATE1         0x03
+#define MB86A16_SRATE1_DECI    (0x07 << 2)
+#define MB86A16_SRATE1_CSEL    (0x01 << 1)
+#define MB86A16_SRATE1_RSEL    (0x01 << 0)
+
+#define MB86A16_SRATE2         0x04
+#define MB86A16_SRATE2_STOFSL  (0xff << 0)
+
+#define MB86A16_SRATE3         0x05
+#define MB86A16_SRATE2_STOFSH  (0xff << 0)
+
+#define MB86A16_VITERBI                0x06
+#define MB86A16_FRAMESYNC      0x07
+#define MB86A16_CRLFILTCOEF1   0x08
+#define MB86A16_CRLFILTCOEF2   0x09
+#define MB86A16_STRFILTCOEF1   0x0a
+#define MB86A16_STRFILTCOEF2   0x0b
+#define MB86A16_RESET          0x0c
+#define MB86A16_STATUS         0x0d
+#define MB86A16_AFCML          0x0e
+#define MB86A16_AFCMH          0x0f
+#define MB86A16_BERMON         0x10
+#define MB86A16_BERTAB         0x11
+#define MB86A16_BERLSB         0x12
+#define MB86A16_BERMID         0x13
+#define MB86A16_BERMSB         0x14
+#define MB86A16_AGCM           0x15
+
+#define MB86A16_DCC1           0x16
+#define MB86A16_DCC1_DISTA     (0x01 << 7)
+#define MB86A16_DCC1_PRTY      (0x01 << 6)
+#define MB86A16_DCC1_CTOE      (0x01 << 5)
+#define MB86A16_DCC1_TBEN      (0x01 << 4)
+#define MB86A16_DCC1_TBO       (0x01 << 3)
+#define MB86A16_DCC1_NUM       (0x07 << 0)
+
+#define MB86A16_DCC2           0x17
+#define MB86A16_DCC2_DCBST     (0x01 << 0)
+
+#define MB86A16_DCC3           0x18
+#define MB86A16_DCC3_CODE0     (0xff << 0)
+
+#define MB86A16_DCC4           0x19
+#define MB86A16_DCC4_CODE1     (0xff << 0)
+
+#define MB86A16_DCC5           0x1a
+#define MB86A16_DCC5_CODE2     (0xff << 0)
+
+#define MB86A16_DCC6           0x1b
+#define MB86A16_DCC6_CODE3     (0xff << 0)
+
+#define MB86A16_DCC7           0x1c
+#define MB86A16_DCC7_CODE4     (0xff << 0)
+
+#define MB86A16_DCC8           0x1d
+#define MB86A16_DCC8_CODE5     (0xff << 0)
+
+#define MB86A16_DCCOUT         0x1e
+#define MB86A16_DCCOUT_DISEN   (0x01 << 0)
+
+#define MB86A16_TONEOUT1       0x1f
+#define MB86A16_TONE_TDIVL     (0xff << 0)
+
+#define MB86A16_TONEOUT2       0x20
+#define MB86A16_TONE_TMD       (0x03 << 2)
+#define MB86A16_TONE_TDIVH     (0x03 << 0)
+
+#define MB86A16_FREQ1          0x21
+#define MB86A16_FREQ2          0x22
+#define MB86A16_FREQ3          0x23
+#define MB86A16_FREQ4          0x24
+#define MB86A16_FREQSET                0x25
+#define MB86A16_CNM            0x26
+#define MB86A16_PORT0          0x27
+#define MB86A16_PORT1          0x28
+#define MB86A16_DRCFILT                0x29
+#define MB86A16_AFC            0x2a
+#define MB86A16_AFCEXL         0x2b
+#define MB86A16_AFCEXH         0x2c
+#define MB86A16_DAGC           0x2d
+#define MB86A16_SEQMODE                0x32
+#define MB86A16_S0S1T          0x33
+#define MB86A16_S2S3T          0x34
+#define MB86A16_S4S5T          0x35
+#define MB86A16_CNTMR          0x36
+#define MB86A16_SIG1           0x37
+#define MB86A16_SIG2           0x38
+#define MB86A16_VIMAG          0x39
+#define MB86A16_VISET1         0x3a
+#define MB86A16_VISET2         0x3b
+#define MB86A16_VISET3         0x3c
+#define MB86A16_FAGCS1         0x3d
+#define MB86A16_FAGCS2         0x3e
+#define MB86A16_FAGCS3         0x3f
+#define MB86A16_FAGCS4         0x40
+#define MB86A16_FAGCS5         0x41
+#define MB86A16_FAGCS6         0x42
+#define MB86A16_CRM            0x43
+#define MB86A16_STRM           0x44
+#define MB86A16_DAGCML         0x45
+#define MB86A16_DAGCMH         0x46
+#define MB86A16_QPSKTST                0x49
+#define MB86A16_DISTMON                0x52
+#define MB86A16_VERSION                0x7f
+
+#endif /* __MB86A16_PRIV_H */
index 6c1dbf9..6ca533e 100644 (file)
@@ -426,6 +426,10 @@ struct dvb_frontend* tda10021_attach(const struct tda1002x_config* config,
        id = tda10021_readreg(state, 0x1a);
        if ((id & 0xf0) != 0x70) goto error;
 
+       /* Don't claim TDA10023 */
+       if (id == 0x7d)
+               goto error;
+
        printk("TDA10021: i2c-addr = 0x%02x, id = 0x%02x\n",
               state->config->demod_address, id);
 
diff --git a/drivers/media/dvb/frontends/tda665x.c b/drivers/media/dvb/frontends/tda665x.c
new file mode 100644 (file)
index 0000000..87d5273
--- /dev/null
@@ -0,0 +1,257 @@
+/*
+       TDA665x tuner driver
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#include "dvb_frontend.h"
+#include "tda665x.h"
+
+struct tda665x_state {
+       struct dvb_frontend             *fe;
+       struct i2c_adapter              *i2c;
+       const struct tda665x_config     *config;
+
+       u32 frequency;
+       u32 bandwidth;
+};
+
+static int tda665x_read(struct tda665x_state *state, u8 *buf)
+{
+       const struct tda665x_config *config = state->config;
+       int err = 0;
+       struct i2c_msg msg = { .addr = config->addr, .flags = I2C_M_RD, .buf = buf, .len = 2 };
+
+       err = i2c_transfer(state->i2c, &msg, 1);
+       if (err != 1)
+               goto exit;
+
+       return err;
+exit:
+       printk(KERN_ERR "%s: I/O Error err=<%d>\n", __func__, err);
+       return err;
+}
+
+static int tda665x_write(struct tda665x_state *state, u8 *buf, u8 length)
+{
+       const struct tda665x_config *config = state->config;
+       int err = 0;
+       struct i2c_msg msg = { .addr = config->addr, .flags = 0, .buf = buf, .len = length };
+
+       err = i2c_transfer(state->i2c, &msg, 1);
+       if (err != 1)
+               goto exit;
+
+       return err;
+exit:
+       printk(KERN_ERR "%s: I/O Error err=<%d>\n", __func__, err);
+       return err;
+}
+
+static int tda665x_get_state(struct dvb_frontend *fe,
+                            enum tuner_param param,
+                            struct tuner_state *tstate)
+{
+       struct tda665x_state *state = fe->tuner_priv;
+       int err = 0;
+
+       switch (param) {
+       case DVBFE_TUNER_FREQUENCY:
+               tstate->frequency = state->frequency;
+               break;
+       case DVBFE_TUNER_BANDWIDTH:
+               break;
+       default:
+               printk(KERN_ERR "%s: Unknown parameter (param=%d)\n", __func__, param);
+               err = -EINVAL;
+               break;
+       }
+
+       return err;
+}
+
+static int tda665x_get_status(struct dvb_frontend *fe, u32 *status)
+{
+       struct tda665x_state *state = fe->tuner_priv;
+       u8 result = 0;
+       int err = 0;
+
+       *status = 0;
+
+       err = tda665x_read(state, &result);
+       if (err < 0)
+               goto exit;
+
+       if ((result >> 6) & 0x01) {
+               printk(KERN_DEBUG "%s: Tuner Phase Locked\n", __func__);
+               *status = 1;
+       }
+
+       return err;
+exit:
+       printk(KERN_ERR "%s: I/O Error\n", __func__);
+       return err;
+}
+
+static int tda665x_set_state(struct dvb_frontend *fe,
+                            enum tuner_param param,
+                            struct tuner_state *tstate)
+{
+       struct tda665x_state *state = fe->tuner_priv;
+       const struct tda665x_config *config = state->config;
+       u32 frequency, status = 0;
+       u8 buf[4];
+       int err = 0;
+
+       if (param & DVBFE_TUNER_FREQUENCY) {
+
+               frequency = tstate->frequency;
+               if ((frequency < config->frequency_max) || (frequency > config->frequency_min)) {
+                       printk(KERN_ERR "%s: Frequency beyond limits, frequency=%d\n", __func__, frequency);
+                       return -EINVAL;
+               }
+
+               frequency += config->frequency_offst;
+               frequency *= config->ref_multiplier;
+               frequency += config->ref_divider >> 1;
+               frequency /= config->ref_divider;
+
+               buf[0] = (u8) (frequency & 0x7f00) >> 8;
+               buf[1] = (u8) (frequency & 0x00ff) >> 0;
+               buf[2] = 0x80 | 0x40 | 0x02;
+               buf[3] = 0x00;
+
+               /* restore frequency */
+               frequency = tstate->frequency;
+
+               if (frequency < 153000000) {
+                       /* VHF-L */
+                       buf[3] |= 0x01; /* fc, Low Band, 47 - 153 MHz */
+                       if (frequency < 68000000)
+                               buf[3] |= 0x40; /* 83uA */
+                       if (frequency < 1040000000)
+                               buf[3] |= 0x60; /* 122uA */
+                       if (frequency < 1250000000)
+                               buf[3] |= 0x80; /* 163uA */
+                       else
+                               buf[3] |= 0xa0; /* 254uA */
+               } else if (frequency < 438000000) {
+                       /* VHF-H */
+                       buf[3] |= 0x02; /* fc, Mid Band, 153 - 438 MHz */
+                       if (frequency < 230000000)
+                               buf[3] |= 0x40;
+                       if (frequency < 300000000)
+                               buf[3] |= 0x60;
+                       else
+                               buf[3] |= 0x80;
+               } else {
+                       /* UHF */
+                       buf[3] |= 0x04; /* fc, High Band, 438 - 862 MHz */
+                       if (frequency < 470000000)
+                               buf[3] |= 0x60;
+                       if (frequency < 526000000)
+                               buf[3] |= 0x80;
+                       else
+                               buf[3] |= 0xa0;
+               }
+
+               /* Set params */
+               err = tda665x_write(state, buf, 5);
+               if (err < 0)
+                       goto exit;
+
+               /* sleep for some time */
+               printk(KERN_DEBUG "%s: Waiting to Phase LOCK\n", __func__);
+               msleep(20);
+               /* check status */
+               err = tda665x_get_status(fe, &status);
+               if (err < 0)
+                       goto exit;
+
+               if (status == 1) {
+                       printk(KERN_DEBUG "%s: Tuner Phase locked: status=%d\n", __func__, status);
+                       state->frequency = frequency; /* cache successful state */
+               } else {
+                       printk(KERN_ERR "%s: No Phase lock: status=%d\n", __func__, status);
+               }
+       } else {
+               printk(KERN_ERR "%s: Unknown parameter (param=%d)\n", __func__, param);
+               return -EINVAL;
+       }
+
+       return 0;
+exit:
+       printk(KERN_ERR "%s: I/O Error\n", __func__);
+       return err;
+}
+
+static int tda665x_release(struct dvb_frontend *fe)
+{
+       struct tda665x_state *state = fe->tuner_priv;
+
+       fe->tuner_priv = NULL;
+       kfree(state);
+       return 0;
+}
+
+static struct dvb_tuner_ops tda665x_ops = {
+
+       .set_state      = tda665x_set_state,
+       .get_state      = tda665x_get_state,
+       .get_status     = tda665x_get_status,
+       .release        = tda665x_release
+};
+
+struct dvb_frontend *tda665x_attach(struct dvb_frontend *fe,
+                                   const struct tda665x_config *config,
+                                   struct i2c_adapter *i2c)
+{
+       struct tda665x_state *state = NULL;
+       struct dvb_tuner_info *info;
+
+       state = kzalloc(sizeof(struct tda665x_state), GFP_KERNEL);
+       if (state == NULL)
+               goto exit;
+
+       state->config           = config;
+       state->i2c              = i2c;
+       state->fe               = fe;
+       fe->tuner_priv          = state;
+       fe->ops.tuner_ops       = tda665x_ops;
+       info                     = &fe->ops.tuner_ops.info;
+
+       memcpy(info->name, config->name, sizeof(config->name));
+       info->frequency_min     = config->frequency_min;
+       info->frequency_max     = config->frequency_max;
+       info->frequency_step    = config->frequency_offst;
+
+       printk(KERN_DEBUG "%s: Attaching TDA665x (%s) tuner\n", __func__, info->name);
+
+       return fe;
+
+exit:
+       kfree(state);
+       return NULL;
+}
+EXPORT_SYMBOL(tda665x_attach);
+
+MODULE_DESCRIPTION("TDA665x driver");
+MODULE_AUTHOR("Manu Abraham");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/tda665x.h b/drivers/media/dvb/frontends/tda665x.h
new file mode 100644 (file)
index 0000000..ec7927a
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+       TDA665x tuner driver
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __TDA665x_H
+#define __TDA665x_H
+
+struct tda665x_config {
+       char name[128];
+
+       u8      addr;
+       u32     frequency_min;
+       u32     frequency_max;
+       u32     frequency_offst;
+       u32     ref_multiplier;
+       u32     ref_divider;
+};
+
+#if defined(CONFIG_DVB_TDA665x) || (defined(CONFIG_DVB_TDA665x_MODULE) && defined(MODULE))
+
+extern struct dvb_frontend *tda665x_attach(struct dvb_frontend *fe,
+                                          const struct tda665x_config *config,
+                                          struct i2c_adapter *i2c);
+
+#else
+
+static inline struct dvb_frontend *tda665x_attach(struct dvb_frontend *fe,
+                                                 const struct tda665x_config *config,
+                                                 struct i2c_adapter *i2c)
+{
+       printk(KERN_WARNING "%s: Driver disabled by Kconfig\n", __func__);
+       return NULL;
+}
+
+#endif /* CONFIG_DVB_TDA665x */
+
+#endif /* __TDA665x_H */
diff --git a/drivers/media/dvb/mantis/Kconfig b/drivers/media/dvb/mantis/Kconfig
new file mode 100644 (file)
index 0000000..f7b72a3
--- /dev/null
@@ -0,0 +1,32 @@
+config MANTIS_CORE
+       tristate "Mantis/Hopper PCI bridge based devices"
+       depends on PCI && I2C && INPUT
+
+       help
+         Support for PCI cards based on the Mantis and Hopper PCi bridge.
+
+         Say Y if you own such a device and want to use it.
+
+config DVB_MANTIS
+       tristate "MANTIS based cards"
+       depends on MANTIS_CORE && DVB_CORE && PCI && I2C
+       select DVB_MB86A16
+       select DVB_ZL10353
+       select DVB_STV0299
+       select DVB_PLL
+       help
+         Support for PCI cards based on the Mantis PCI bridge.
+         Say Y when you have a Mantis based DVB card and want to use it.
+
+         If unsure say N.
+
+config DVB_HOPPER
+       tristate "HOPPER based cards"
+       depends on MANTIS_CORE && DVB_CORE && PCI && I2C
+       select DVB_ZL10353
+       select DVB_PLL
+       help
+         Support for PCI cards based on the Hopper  PCI bridge.
+         Say Y when you have a Hopper based DVB card and want to use it.
+
+         If unsure say N
diff --git a/drivers/media/dvb/mantis/Makefile b/drivers/media/dvb/mantis/Makefile
new file mode 100644 (file)
index 0000000..98dc5cd
--- /dev/null
@@ -0,0 +1,28 @@
+mantis_core-objs :=    mantis_ioc.o    \
+                       mantis_uart.o   \
+                       mantis_dma.o    \
+                       mantis_pci.o    \
+                       mantis_i2c.o    \
+                       mantis_dvb.o    \
+                       mantis_evm.o    \
+                       mantis_hif.o    \
+                       mantis_ca.o     \
+                       mantis_pcmcia.o \
+                       mantis_input.o
+
+mantis-objs    :=      mantis_cards.o  \
+                       mantis_vp1033.o \
+                       mantis_vp1034.o \
+                       mantis_vp1041.o \
+                       mantis_vp2033.o \
+                       mantis_vp2040.o \
+                       mantis_vp3030.o
+
+hopper-objs    :=      hopper_cards.o  \
+                       hopper_vp3028.o
+
+obj-$(CONFIG_MANTIS_CORE)      += mantis_core.o
+obj-$(CONFIG_DVB_MANTIS)       += mantis.o
+obj-$(CONFIG_DVB_HOPPER)       += hopper.o
+
+EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
diff --git a/drivers/media/dvb/mantis/hopper_cards.c b/drivers/media/dvb/mantis/hopper_cards.c
new file mode 100644 (file)
index 0000000..d073c61
--- /dev/null
@@ -0,0 +1,275 @@
+/*
+       Hopper PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <asm/irq.h>
+#include <linux/interrupt.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "mantis_common.h"
+#include "hopper_vp3028.h"
+#include "mantis_dma.h"
+#include "mantis_dvb.h"
+#include "mantis_uart.h"
+#include "mantis_ioc.h"
+#include "mantis_pci.h"
+#include "mantis_i2c.h"
+#include "mantis_reg.h"
+
+static unsigned int verbose;
+module_param(verbose, int, 0644);
+MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");
+
+#define DRIVER_NAME    "Hopper"
+
+static char *label[10] = {
+       "DMA",
+       "IRQ-0",
+       "IRQ-1",
+       "OCERR",
+       "PABRT",
+       "RIPRR",
+       "PPERR",
+       "FTRGT",
+       "RISCI",
+       "RACK"
+};
+
+static int devs;
+
+static irqreturn_t hopper_irq_handler(int irq, void *dev_id)
+{
+       u32 stat = 0, mask = 0, lstat = 0, mstat = 0;
+       u32 rst_stat = 0, rst_mask = 0;
+
+       struct mantis_pci *mantis;
+       struct mantis_ca *ca;
+
+       mantis = (struct mantis_pci *) dev_id;
+       if (unlikely(mantis == NULL)) {
+               dprintk(MANTIS_ERROR, 1, "Mantis == NULL");
+               return IRQ_NONE;
+       }
+       ca = mantis->mantis_ca;
+
+       stat = mmread(MANTIS_INT_STAT);
+       mask = mmread(MANTIS_INT_MASK);
+       mstat = lstat = stat & ~MANTIS_INT_RISCSTAT;
+       if (!(stat & mask))
+               return IRQ_NONE;
+
+       rst_mask  = MANTIS_GPIF_WRACK  |
+                   MANTIS_GPIF_OTHERR |
+                   MANTIS_SBUF_WSTO   |
+                   MANTIS_GPIF_EXTIRQ;
+
+       rst_stat  = mmread(MANTIS_GPIF_STATUS);
+       rst_stat &= rst_mask;
+       mmwrite(rst_stat, MANTIS_GPIF_STATUS);
+
+       mantis->mantis_int_stat = stat;
+       mantis->mantis_int_mask = mask;
+       dprintk(MANTIS_DEBUG, 0, "\n-- Stat=<%02x> Mask=<%02x> --", stat, mask);
+       if (stat & MANTIS_INT_RISCEN) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[0]);
+       }
+       if (stat & MANTIS_INT_IRQ0) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[1]);
+               mantis->gpif_status = rst_stat;
+               wake_up(&ca->hif_write_wq);
+               schedule_work(&ca->hif_evm_work);
+       }
+       if (stat & MANTIS_INT_IRQ1) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[2]);
+               schedule_work(&mantis->uart_work);
+       }
+       if (stat & MANTIS_INT_OCERR) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[3]);
+       }
+       if (stat & MANTIS_INT_PABORT) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[4]);
+       }
+       if (stat & MANTIS_INT_RIPERR) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[5]);
+       }
+       if (stat & MANTIS_INT_PPERR) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[6]);
+       }
+       if (stat & MANTIS_INT_FTRGT) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[7]);
+       }
+       if (stat & MANTIS_INT_RISCI) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[8]);
+               mantis->finished_block = (stat & MANTIS_INT_RISCSTAT) >> 28;
+               tasklet_schedule(&mantis->tasklet);
+       }
+       if (stat & MANTIS_INT_I2CDONE) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[9]);
+               wake_up(&mantis->i2c_wq);
+       }
+       mmwrite(stat, MANTIS_INT_STAT);
+       stat &= ~(MANTIS_INT_RISCEN   | MANTIS_INT_I2CDONE |
+                 MANTIS_INT_I2CRACK  | MANTIS_INT_PCMCIA7 |
+                 MANTIS_INT_PCMCIA6  | MANTIS_INT_PCMCIA5 |
+                 MANTIS_INT_PCMCIA4  | MANTIS_INT_PCMCIA3 |
+                 MANTIS_INT_PCMCIA2  | MANTIS_INT_PCMCIA1 |
+                 MANTIS_INT_PCMCIA0  | MANTIS_INT_IRQ1    |
+                 MANTIS_INT_IRQ0     | MANTIS_INT_OCERR   |
+                 MANTIS_INT_PABORT   | MANTIS_INT_RIPERR  |
+                 MANTIS_INT_PPERR    | MANTIS_INT_FTRGT   |
+                 MANTIS_INT_RISCI);
+
+       if (stat)
+               dprintk(MANTIS_DEBUG, 0, "<Unknown> Stat=<%02x> Mask=<%02x>", stat, mask);
+
+       dprintk(MANTIS_DEBUG, 0, "\n");
+       return IRQ_HANDLED;
+}
+
+static int __devinit hopper_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
+{
+       struct mantis_pci *mantis;
+       struct mantis_hwconfig *config;
+       int err = 0;
+
+       mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL);
+       if (mantis == NULL) {
+               printk(KERN_ERR "%s ERROR: Out of memory\n", __func__);
+               err = -ENOMEM;
+               goto fail0;
+       }
+
+       mantis->num             = devs;
+       mantis->verbose         = verbose;
+       mantis->pdev            = pdev;
+       config                  = (struct mantis_hwconfig *) pci_id->driver_data;
+       config->irq_handler     = &hopper_irq_handler;
+       mantis->hwconfig        = config;
+
+       err = mantis_pci_init(mantis);
+       if (err) {
+               dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI initialization failed <%d>", err);
+               goto fail1;
+       }
+
+       err = mantis_stream_control(mantis, STREAM_TO_HIF);
+       if (err < 0) {
+               dprintk(MANTIS_ERROR, 1, "ERROR: Mantis stream control failed <%d>", err);
+               goto fail1;
+       }
+
+       err = mantis_i2c_init(mantis);
+       if (err < 0) {
+               dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C initialization failed <%d>", err);
+               goto fail2;
+       }
+
+       err = mantis_get_mac(mantis);
+       if (err < 0) {
+               dprintk(MANTIS_ERROR, 1, "ERROR: Mantis MAC address read failed <%d>", err);
+               goto fail2;
+       }
+
+       err = mantis_dma_init(mantis);
+       if (err < 0) {
+               dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA initialization failed <%d>", err);
+               goto fail3;
+       }
+
+       err = mantis_dvb_init(mantis);
+       if (err < 0) {
+               dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization failed <%d>", err);
+               goto fail4;
+       }
+       devs++;
+
+       return err;
+
+fail4:
+       dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA exit! <%d>", err);
+       mantis_dma_exit(mantis);
+
+fail3:
+       dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C exit! <%d>", err);
+       mantis_i2c_exit(mantis);
+
+fail2:
+       dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI exit! <%d>", err);
+       mantis_pci_exit(mantis);
+
+fail1:
+       dprintk(MANTIS_ERROR, 1, "ERROR: Mantis free! <%d>", err);
+       kfree(mantis);
+
+fail0:
+       return err;
+}
+
+static void __devexit hopper_pci_remove(struct pci_dev *pdev)
+{
+       struct mantis_pci *mantis = pci_get_drvdata(pdev);
+
+       if (mantis) {
+               mantis_dvb_exit(mantis);
+               mantis_dma_exit(mantis);
+               mantis_i2c_exit(mantis);
+               mantis_pci_exit(mantis);
+               kfree(mantis);
+       }
+       return;
+
+}
+
+static struct pci_device_id hopper_pci_table[] = {
+       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_3028_DVB_T, &vp3028_config),
+       { }
+};
+
+static struct pci_driver hopper_pci_driver = {
+       .name           = DRIVER_NAME,
+       .id_table       = hopper_pci_table,
+       .probe          = hopper_pci_probe,
+       .remove         = hopper_pci_remove,
+};
+
+static int __devinit hopper_init(void)
+{
+       return pci_register_driver(&hopper_pci_driver);
+}
+
+static void __devexit hopper_exit(void)
+{
+       return pci_unregister_driver(&hopper_pci_driver);
+}
+
+module_init(hopper_init);
+module_exit(hopper_exit);
+
+MODULE_DESCRIPTION("HOPPER driver");
+MODULE_AUTHOR("Manu Abraham");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/mantis/hopper_vp3028.c b/drivers/media/dvb/mantis/hopper_vp3028.c
new file mode 100644 (file)
index 0000000..96674c7
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+       Hopper VP-3028 driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "zl10353.h"
+#include "mantis_common.h"
+#include "mantis_ioc.h"
+#include "mantis_dvb.h"
+#include "hopper_vp3028.h"
+
+struct zl10353_config hopper_vp3028_config = {
+       .demod_address  = 0x0f,
+};
+
+#define MANTIS_MODEL_NAME      "VP-3028"
+#define MANTIS_DEV_TYPE                "DVB-T"
+
+static int vp3028_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
+{
+       struct i2c_adapter *adapter     = &mantis->adapter;
+       struct mantis_hwconfig *config  = mantis->hwconfig;
+       int err = 0;
+
+       gpio_set_bits(mantis, config->reset, 0);
+       msleep(100);
+       err = mantis_frontend_power(mantis, POWER_ON);
+       msleep(100);
+       gpio_set_bits(mantis, config->reset, 1);
+
+       err = mantis_frontend_power(mantis, POWER_ON);
+       if (err == 0) {
+               msleep(250);
+               dprintk(MANTIS_ERROR, 1, "Probing for 10353 (DVB-T)");
+               fe = zl10353_attach(&hopper_vp3028_config, adapter);
+
+               if (!fe)
+                       return -1;
+       } else {
+               dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
+                       adapter->name,
+                       err);
+
+               return -EIO;
+       }
+       dprintk(MANTIS_ERROR, 1, "Done!");
+
+       return 0;
+}
+
+struct mantis_hwconfig vp3028_config = {
+       .model_name     = MANTIS_MODEL_NAME,
+       .dev_type       = MANTIS_DEV_TYPE,
+       .ts_size        = MANTIS_TS_188,
+
+       .baud_rate      = MANTIS_BAUD_9600,
+       .parity         = MANTIS_PARITY_NONE,
+       .bytes          = 0,
+
+       .frontend_init  = vp3028_frontend_init,
+       .power          = GPIF_A00,
+       .reset          = GPIF_A03,
+};
diff --git a/drivers/media/dvb/mantis/hopper_vp3028.h b/drivers/media/dvb/mantis/hopper_vp3028.h
new file mode 100644 (file)
index 0000000..5723949
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+       Hopper VP-3028 driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_VP3028_H
+#define __MANTIS_VP3028_H
+
+#include "mantis_common.h"
+
+#define MANTIS_VP_3028_DVB_T   0x0028
+
+extern struct mantis_hwconfig vp3028_config;
+
+#endif /* __MANTIS_VP3028_H */
diff --git a/drivers/media/dvb/mantis/mantis_ca.c b/drivers/media/dvb/mantis/mantis_ca.c
new file mode 100644 (file)
index 0000000..403ce04
--- /dev/null
@@ -0,0 +1,207 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "mantis_common.h"
+#include "mantis_link.h"
+#include "mantis_hif.h"
+#include "mantis_reg.h"
+
+#include "mantis_ca.h"
+
+static int mantis_ca_read_attr_mem(struct dvb_ca_en50221 *en50221, int slot, int addr)
+{
+       struct mantis_ca *ca = en50221->data;
+       struct mantis_pci *mantis = ca->ca_priv;
+
+       dprintk(MANTIS_DEBUG, 1, "Slot(%d): Request Attribute Mem Read", slot);
+
+       if (slot != 0)
+               return -EINVAL;
+
+       return mantis_hif_read_mem(ca, addr);
+}
+
+static int mantis_ca_write_attr_mem(struct dvb_ca_en50221 *en50221, int slot, int addr, u8 data)
+{
+       struct mantis_ca *ca = en50221->data;
+       struct mantis_pci *mantis = ca->ca_priv;
+
+       dprintk(MANTIS_DEBUG, 1, "Slot(%d): Request Attribute Mem Write", slot);
+
+       if (slot != 0)
+               return -EINVAL;
+
+       return mantis_hif_write_mem(ca, addr, data);
+}
+
+static int mantis_ca_read_cam_ctl(struct dvb_ca_en50221 *en50221, int slot, u8 addr)
+{
+       struct mantis_ca *ca = en50221->data;
+       struct mantis_pci *mantis = ca->ca_priv;
+
+       dprintk(MANTIS_DEBUG, 1, "Slot(%d): Request CAM control Read", slot);
+
+       if (slot != 0)
+               return -EINVAL;
+
+       return mantis_hif_read_iom(ca, addr);
+}
+
+static int mantis_ca_write_cam_ctl(struct dvb_ca_en50221 *en50221, int slot, u8 addr, u8 data)
+{
+       struct mantis_ca *ca = en50221->data;
+       struct mantis_pci *mantis = ca->ca_priv;
+
+       dprintk(MANTIS_DEBUG, 1, "Slot(%d): Request CAM control Write", slot);
+
+       if (slot != 0)
+               return -EINVAL;
+
+       return mantis_hif_write_iom(ca, addr, data);
+}
+
+static int mantis_ca_slot_reset(struct dvb_ca_en50221 *en50221, int slot)
+{
+       struct mantis_ca *ca = en50221->data;
+       struct mantis_pci *mantis = ca->ca_priv;
+
+       dprintk(MANTIS_DEBUG, 1, "Slot(%d): Slot RESET", slot);
+       udelay(500); /* Wait.. */
+       mmwrite(0xda, MANTIS_PCMCIA_RESET); /* Leading edge assert */
+       udelay(500);
+       mmwrite(0x00, MANTIS_PCMCIA_RESET); /* Trailing edge deassert */
+       msleep(1000);
+       dvb_ca_en50221_camready_irq(&ca->en50221, 0);
+
+       return 0;
+}
+
+static int mantis_ca_slot_shutdown(struct dvb_ca_en50221 *en50221, int slot)
+{
+       struct mantis_ca *ca = en50221->data;
+       struct mantis_pci *mantis = ca->ca_priv;
+
+       dprintk(MANTIS_DEBUG, 1, "Slot(%d): Slot shutdown", slot);
+
+       return 0;
+}
+
+static int mantis_ts_control(struct dvb_ca_en50221 *en50221, int slot)
+{
+       struct mantis_ca *ca = en50221->data;
+       struct mantis_pci *mantis = ca->ca_priv;
+
+       dprintk(MANTIS_DEBUG, 1, "Slot(%d): TS control", slot);
+/*     mantis_set_direction(mantis, 1); */ /* Enable TS through CAM */
+
+       return 0;
+}
+
+static int mantis_slot_status(struct dvb_ca_en50221 *en50221, int slot, int open)
+{
+       struct mantis_ca *ca = en50221->data;
+       struct mantis_pci *mantis = ca->ca_priv;
+
+       dprintk(MANTIS_DEBUG, 1, "Slot(%d): Poll Slot status", slot);
+
+       if (ca->slot_state == MODULE_INSERTED) {
+               dprintk(MANTIS_DEBUG, 1, "CA Module present and ready");
+               return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY;
+       } else {
+               dprintk(MANTIS_DEBUG, 1, "CA Module not present or not ready");
+       }
+
+       return 0;
+}
+
+int mantis_ca_init(struct mantis_pci *mantis)
+{
+       struct dvb_adapter *dvb_adapter = &mantis->dvb_adapter;
+       struct mantis_ca *ca;
+       int ca_flags = 0, result;
+
+       dprintk(MANTIS_DEBUG, 1, "Initializing Mantis CA");
+       ca = kzalloc(sizeof(struct mantis_ca), GFP_KERNEL);
+       if (!ca) {
+               dprintk(MANTIS_ERROR, 1, "Out of memory!, exiting ..");
+               result = -ENOMEM;
+               goto err;
+       }
+
+       ca->ca_priv             = mantis;
+       mantis->mantis_ca       = ca;
+       ca_flags                = DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE;
+       /* register CA interface */
+       ca->en50221.owner               = THIS_MODULE;
+       ca->en50221.read_attribute_mem  = mantis_ca_read_attr_mem;
+       ca->en50221.write_attribute_mem = mantis_ca_write_attr_mem;
+       ca->en50221.read_cam_control    = mantis_ca_read_cam_ctl;
+       ca->en50221.write_cam_control   = mantis_ca_write_cam_ctl;
+       ca->en50221.slot_reset          = mantis_ca_slot_reset;
+       ca->en50221.slot_shutdown       = mantis_ca_slot_shutdown;
+       ca->en50221.slot_ts_enable      = mantis_ts_control;
+       ca->en50221.poll_slot_status    = mantis_slot_status;
+       ca->en50221.data                = ca;
+
+       mutex_init(&ca->ca_lock);
+
+       init_waitqueue_head(&ca->hif_data_wq);
+       init_waitqueue_head(&ca->hif_opdone_wq);
+       init_waitqueue_head(&ca->hif_write_wq);
+
+       dprintk(MANTIS_ERROR, 1, "Registering EN50221 device");
+       result = dvb_ca_en50221_init(dvb_adapter, &ca->en50221, ca_flags, 1);
+       if (result != 0) {
+               dprintk(MANTIS_ERROR, 1, "EN50221: Initialization failed <%d>", result);
+               goto err;
+       }
+       dprintk(MANTIS_ERROR, 1, "Registered EN50221 device");
+       mantis_evmgr_init(ca);
+       return 0;
+err:
+       kfree(ca);
+       return result;
+}
+EXPORT_SYMBOL_GPL(mantis_ca_init);
+
+void mantis_ca_exit(struct mantis_pci *mantis)
+{
+       struct mantis_ca *ca = mantis->mantis_ca;
+
+       dprintk(MANTIS_DEBUG, 1, "Mantis CA exit");
+
+       mantis_evmgr_exit(ca);
+       dprintk(MANTIS_ERROR, 1, "Unregistering EN50221 device");
+       if (ca)
+               dvb_ca_en50221_release(&ca->en50221);
+
+       kfree(ca);
+}
+EXPORT_SYMBOL_GPL(mantis_ca_exit);
diff --git a/drivers/media/dvb/mantis/mantis_ca.h b/drivers/media/dvb/mantis/mantis_ca.h
new file mode 100644 (file)
index 0000000..dc63e55
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_CA_H
+#define __MANTIS_CA_H
+
+extern int mantis_ca_init(struct mantis_pci *mantis);
+extern void mantis_ca_exit(struct mantis_pci *mantis);
+
+#endif /* __MANTIS_CA_H */
diff --git a/drivers/media/dvb/mantis/mantis_cards.c b/drivers/media/dvb/mantis/mantis_cards.c
new file mode 100644 (file)
index 0000000..16f1708
--- /dev/null
@@ -0,0 +1,305 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <asm/irq.h>
+#include <linux/interrupt.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "mantis_common.h"
+
+#include "mantis_vp1033.h"
+#include "mantis_vp1034.h"
+#include "mantis_vp1041.h"
+#include "mantis_vp2033.h"
+#include "mantis_vp2040.h"
+#include "mantis_vp3030.h"
+
+#include "mantis_dma.h"
+#include "mantis_ca.h"
+#include "mantis_dvb.h"
+#include "mantis_uart.h"
+#include "mantis_ioc.h"
+#include "mantis_pci.h"
+#include "mantis_i2c.h"
+#include "mantis_reg.h"
+
+static unsigned int verbose;
+module_param(verbose, int, 0644);
+MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");
+
+static int devs;
+
+#define DRIVER_NAME    "Mantis"
+
+static char *label[10] = {
+       "DMA",
+       "IRQ-0",
+       "IRQ-1",
+       "OCERR",
+       "PABRT",
+       "RIPRR",
+       "PPERR",
+       "FTRGT",
+       "RISCI",
+       "RACK"
+};
+
+static irqreturn_t mantis_irq_handler(int irq, void *dev_id)
+{
+       u32 stat = 0, mask = 0, lstat = 0, mstat = 0;
+       u32 rst_stat = 0, rst_mask = 0;
+
+       struct mantis_pci *mantis;
+       struct mantis_ca *ca;
+
+       mantis = (struct mantis_pci *) dev_id;
+       if (unlikely(mantis == NULL)) {
+               dprintk(MANTIS_ERROR, 1, "Mantis == NULL");
+               return IRQ_NONE;
+       }
+       ca = mantis->mantis_ca;
+
+       stat = mmread(MANTIS_INT_STAT);
+       mask = mmread(MANTIS_INT_MASK);
+       mstat = lstat = stat & ~MANTIS_INT_RISCSTAT;
+       if (!(stat & mask))
+               return IRQ_NONE;
+
+       rst_mask  = MANTIS_GPIF_WRACK  |
+                   MANTIS_GPIF_OTHERR |
+                   MANTIS_SBUF_WSTO   |
+                   MANTIS_GPIF_EXTIRQ;
+
+       rst_stat  = mmread(MANTIS_GPIF_STATUS);
+       rst_stat &= rst_mask;
+       mmwrite(rst_stat, MANTIS_GPIF_STATUS);
+
+       mantis->mantis_int_stat = stat;
+       mantis->mantis_int_mask = mask;
+       dprintk(MANTIS_DEBUG, 0, "\n-- Stat=<%02x> Mask=<%02x> --", stat, mask);
+       if (stat & MANTIS_INT_RISCEN) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[0]);
+       }
+       if (stat & MANTIS_INT_IRQ0) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[1]);
+               mantis->gpif_status = rst_stat;
+               wake_up(&ca->hif_write_wq);
+               schedule_work(&ca->hif_evm_work);
+       }
+       if (stat & MANTIS_INT_IRQ1) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[2]);
+               schedule_work(&mantis->uart_work);
+       }
+       if (stat & MANTIS_INT_OCERR) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[3]);
+       }
+       if (stat & MANTIS_INT_PABORT) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[4]);
+       }
+       if (stat & MANTIS_INT_RIPERR) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[5]);
+       }
+       if (stat & MANTIS_INT_PPERR) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[6]);
+       }
+       if (stat & MANTIS_INT_FTRGT) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[7]);
+       }
+       if (stat & MANTIS_INT_RISCI) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[8]);
+               mantis->finished_block = (stat & MANTIS_INT_RISCSTAT) >> 28;
+               tasklet_schedule(&mantis->tasklet);
+       }
+       if (stat & MANTIS_INT_I2CDONE) {
+               dprintk(MANTIS_DEBUG, 0, "<%s>", label[9]);
+               wake_up(&mantis->i2c_wq);
+       }
+       mmwrite(stat, MANTIS_INT_STAT);
+       stat &= ~(MANTIS_INT_RISCEN   | MANTIS_INT_I2CDONE |
+                 MANTIS_INT_I2CRACK  | MANTIS_INT_PCMCIA7 |
+                 MANTIS_INT_PCMCIA6  | MANTIS_INT_PCMCIA5 |
+                 MANTIS_INT_PCMCIA4  | MANTIS_INT_PCMCIA3 |
+                 MANTIS_INT_PCMCIA2  | MANTIS_INT_PCMCIA1 |
+                 MANTIS_INT_PCMCIA0  | MANTIS_INT_IRQ1    |
+                 MANTIS_INT_IRQ0     | MANTIS_INT_OCERR   |
+                 MANTIS_INT_PABORT   | MANTIS_INT_RIPERR  |
+                 MANTIS_INT_PPERR    | MANTIS_INT_FTRGT   |
+                 MANTIS_INT_RISCI);
+
+       if (stat)
+               dprintk(MANTIS_DEBUG, 0, "<Unknown> Stat=<%02x> Mask=<%02x>", stat, mask);
+
+       dprintk(MANTIS_DEBUG, 0, "\n");
+       return IRQ_HANDLED;
+}
+
+static int __devinit mantis_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
+{
+       struct mantis_pci *mantis;
+       struct mantis_hwconfig *config;
+       int err = 0;
+
+       mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL);
+       if (mantis == NULL) {
+               printk(KERN_ERR "%s ERROR: Out of memory\n", __func__);
+               err = -ENOMEM;
+               goto fail0;
+       }
+
+       mantis->num             = devs;
+       mantis->verbose         = verbose;
+       mantis->pdev            = pdev;
+       config                  = (struct mantis_hwconfig *) pci_id->driver_data;
+       config->irq_handler     = &mantis_irq_handler;
+       mantis->hwconfig        = config;
+
+       err = mantis_pci_init(mantis);
+       if (err) {
+               dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI initialization failed <%d>", err);
+               goto fail1;
+       }
+
+       err = mantis_stream_control(mantis, STREAM_TO_HIF);
+       if (err < 0) {
+               dprintk(MANTIS_ERROR, 1, "ERROR: Mantis stream control failed <%d>", err);
+               goto fail1;
+       }
+
+       err = mantis_i2c_init(mantis);
+       if (err < 0) {
+               dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C initialization failed <%d>", err);
+               goto fail2;
+       }
+
+       err = mantis_get_mac(mantis);
+       if (err < 0) {
+               dprintk(MANTIS_ERROR, 1, "ERROR: Mantis MAC address read failed <%d>", err);
+               goto fail2;
+       }
+
+       err = mantis_dma_init(mantis);
+       if (err < 0) {
+               dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA initialization failed <%d>", err);
+               goto fail3;
+       }
+
+       err = mantis_dvb_init(mantis);
+       if (err < 0) {
+               dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization failed <%d>", err);
+               goto fail4;
+       }
+       err = mantis_uart_init(mantis);
+       if (err < 0) {
+               dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART initialization failed <%d>", err);
+               goto fail6;
+       }
+
+       devs++;
+
+       return err;
+
+
+       dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART exit! <%d>", err);
+       mantis_uart_exit(mantis);
+
+fail6:
+fail4:
+       dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA exit! <%d>", err);
+       mantis_dma_exit(mantis);
+
+fail3:
+       dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C exit! <%d>", err);
+       mantis_i2c_exit(mantis);
+
+fail2:
+       dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI exit! <%d>", err);
+       mantis_pci_exit(mantis);
+
+fail1:
+       dprintk(MANTIS_ERROR, 1, "ERROR: Mantis free! <%d>", err);
+       kfree(mantis);
+
+fail0:
+       return err;
+}
+
+static void __devexit mantis_pci_remove(struct pci_dev *pdev)
+{
+       struct mantis_pci *mantis = pci_get_drvdata(pdev);
+
+       if (mantis) {
+
+               mantis_uart_exit(mantis);
+               mantis_dvb_exit(mantis);
+               mantis_dma_exit(mantis);
+               mantis_i2c_exit(mantis);
+               mantis_pci_exit(mantis);
+               kfree(mantis);
+       }
+       return;
+}
+
+static struct pci_device_id mantis_pci_table[] = {
+       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1033_DVB_S, &vp1033_config),
+       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1034_DVB_S, &vp1034_config),
+       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1041_DVB_S2, &vp1041_config),
+       MAKE_ENTRY(TECHNISAT, SKYSTAR_HD2_10, &vp1041_config),
+       MAKE_ENTRY(TECHNISAT, SKYSTAR_HD2_20, &vp1041_config),
+       MAKE_ENTRY(TERRATEC, CINERGY_S2_PCI_HD, &vp1041_config),
+       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_2033_DVB_C, &vp2033_config),
+       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_2040_DVB_C, &vp2040_config),
+       MAKE_ENTRY(TECHNISAT, CABLESTAR_HD2, &vp2040_config),
+       MAKE_ENTRY(TERRATEC, CINERGY_C, &vp2033_config),
+       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_3030_DVB_T, &vp3030_config),
+       { }
+};
+
+static struct pci_driver mantis_pci_driver = {
+       .name           = DRIVER_NAME,
+       .id_table       = mantis_pci_table,
+       .probe          = mantis_pci_probe,
+       .remove         = mantis_pci_remove,
+};
+
+static int __devinit mantis_init(void)
+{
+       return pci_register_driver(&mantis_pci_driver);
+}
+
+static void __devexit mantis_exit(void)
+{
+       return pci_unregister_driver(&mantis_pci_driver);
+}
+
+module_init(mantis_init);
+module_exit(mantis_exit);
+
+MODULE_DESCRIPTION("MANTIS driver");
+MODULE_AUTHOR("Manu Abraham");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/mantis/mantis_common.h b/drivers/media/dvb/mantis/mantis_common.h
new file mode 100644 (file)
index 0000000..d0b645a
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_COMMON_H
+#define __MANTIS_COMMON_H
+
+#include <linux/mutex.h>
+#include <linux/workqueue.h>
+
+#include "mantis_uart.h"
+
+#include "mantis_link.h"
+
+#define MANTIS_ERROR           0
+#define MANTIS_NOTICE          1
+#define MANTIS_INFO            2
+#define MANTIS_DEBUG           3
+#define MANTIS_TMG             9
+
+#define dprintk(y, z, format, arg...) do {                                                             \
+       if (z) {                                                                                        \
+               if      ((mantis->verbose > MANTIS_ERROR) && (mantis->verbose > y))                     \
+                       printk(KERN_ERR "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);      \
+               else if ((mantis->verbose > MANTIS_NOTICE) && (mantis->verbose > y))                    \
+                       printk(KERN_NOTICE "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);   \
+               else if ((mantis->verbose > MANTIS_INFO) && (mantis->verbose > y))                      \
+                       printk(KERN_INFO "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);     \
+               else if ((mantis->verbose > MANTIS_DEBUG) && (mantis->verbose > y))                     \
+                       printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);    \
+               else if ((mantis->verbose > MANTIS_TMG) && (mantis->verbose > y))                       \
+                       printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);    \
+       } else {                                                                                        \
+               if (mantis->verbose > y)                                                                \
+                       printk(format , ##arg);                                                         \
+       }                                                                                               \
+} while(0)
+
+#define mwrite(dat, addr)      writel((dat), addr)
+#define mread(addr)            readl(addr)
+
+#define mmwrite(dat, addr)     mwrite((dat), (mantis->mmio + (addr)))
+#define mmread(addr)           mread(mantis->mmio + (addr))
+
+#define MANTIS_TS_188          0
+#define MANTIS_TS_204          1
+
+#define TWINHAN_TECHNOLOGIES   0x1822
+#define MANTIS                 0x4e35
+
+#define TECHNISAT              0x1ae4
+#define TERRATEC               0x153b
+
+#define MAKE_ENTRY(__subven, __subdev, __configptr) {                  \
+               .vendor         = TWINHAN_TECHNOLOGIES,                 \
+               .device         = MANTIS,                               \
+               .subvendor      = (__subven),                           \
+               .subdevice      = (__subdev),                           \
+               .driver_data    = (unsigned long) (__configptr)         \
+}
+
+enum mantis_i2c_mode {
+       MANTIS_PAGE_MODE = 0,
+       MANTIS_BYTE_MODE,
+};
+
+struct mantis_pci;
+
+struct mantis_hwconfig {
+       char                    *model_name;
+       char                    *dev_type;
+       u32                     ts_size;
+
+       enum mantis_baud        baud_rate;
+       enum mantis_parity      parity;
+       u32                     bytes;
+
+       irqreturn_t (*irq_handler)(int irq, void *dev_id);
+       int (*frontend_init)(struct mantis_pci *mantis, struct dvb_frontend *fe);
+
+       u8                      power;
+       u8                      reset;
+
+       enum mantis_i2c_mode    i2c_mode;
+};
+
+struct mantis_pci {
+       unsigned int            verbose;
+
+       /*      PCI stuff               */
+       u16                     vendor_id;
+       u16                     device_id;
+       u16                     subsystem_vendor;
+       u16                     subsystem_device;
+
+       u8                      latency;
+
+       struct pci_dev          *pdev;
+
+       unsigned long           mantis_addr;
+       void __iomem            *mmio;
+
+       u8                      irq;
+       u8                      revision;
+
+       unsigned int            num;
+
+       /*      RISC Core               */
+       u32                     finished_block;
+       u32                     last_block;
+       u32                     line_bytes;
+       u32                     line_count;
+       u32                     risc_pos;
+       u8                      *buf_cpu;
+       dma_addr_t              buf_dma;
+       u32                     *risc_cpu;
+       dma_addr_t              risc_dma;
+
+       struct tasklet_struct   tasklet;
+
+       struct i2c_adapter      adapter;
+       int                     i2c_rc;
+       wait_queue_head_t       i2c_wq;
+       struct mutex            i2c_lock;
+
+       /*      DVB stuff               */
+       struct dvb_adapter      dvb_adapter;
+       struct dvb_frontend     *fe;
+       struct dvb_demux        demux;
+       struct dmxdev           dmxdev;
+       struct dmx_frontend     fe_hw;
+       struct dmx_frontend     fe_mem;
+       struct dvb_net          dvbnet;
+
+       u8                      feeds;
+
+       struct mantis_hwconfig  *hwconfig;
+
+       u32                     mantis_int_stat;
+       u32                     mantis_int_mask;
+
+       /*      board specific          */
+       u8                      mac_address[8];
+       u32                     sub_vendor_id;
+       u32                     sub_device_id;
+
+        /*     A12 A13 A14             */
+       u32                     gpio_status;
+
+       u32                     gpif_status;
+
+       struct mantis_ca        *mantis_ca;
+
+       wait_queue_head_t       uart_wq;
+       struct work_struct      uart_work;
+       spinlock_t              uart_lock;
+
+       struct input_dev        *rc;
+};
+
+#define MANTIS_HIF_STATUS      (mantis->gpio_status)
+
+#endif /* __MANTIS_COMMON_H */
diff --git a/drivers/media/dvb/mantis/mantis_core.c b/drivers/media/dvb/mantis/mantis_core.c
new file mode 100644 (file)
index 0000000..8113b23
--- /dev/null
@@ -0,0 +1,238 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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 "mantis_common.h"
+#include "mantis_core.h"
+#include "mantis_vp1033.h"
+#include "mantis_vp1034.h"
+#include "mantis_vp1041.h"
+#include "mantis_vp2033.h"
+#include "mantis_vp2040.h"
+#include "mantis_vp3030.h"
+
+static int read_eeprom_byte(struct mantis_pci *mantis, u8 *data, u8 length)
+{
+       int err;
+       struct i2c_msg msg[] = {
+               {
+                       .addr = 0x50,
+                       .flags = 0,
+                       .buf = data,
+                       .len = 1
+               }, {
+                       .addr = 0x50,
+                       .flags = I2C_M_RD,
+                       .buf = data,
+                       .len = length
+               },
+       };
+
+       err = i2c_transfer(&mantis->adapter, msg, 2);
+       if (err < 0) {
+               dprintk(verbose, MANTIS_ERROR, 1,
+                       "ERROR: i2c read: < err=%i d0=0x%02x d1=0x%02x >",
+                       err, data[0], data[1]);
+
+               return err;
+       }
+
+       return 0;
+}
+
+static int write_eeprom_byte(struct mantis_pci *mantis, u8 *data, u8 length)
+{
+       int err;
+
+       struct i2c_msg msg = {
+               .addr = 0x50,
+               .flags = 0,
+               .buf = data,
+               .len = length
+       };
+
+       err = i2c_transfer(&mantis->adapter, &msg, 1);
+       if (err < 0) {
+               dprintk(verbose, MANTIS_ERROR, 1,
+                       "ERROR: i2c write: < err=%i length=0x%02x d0=0x%02x, d1=0x%02x >",
+                       err, length, data[0], data[1]);
+
+               return err;
+       }
+
+       return 0;
+}
+
+static int get_mac_address(struct mantis_pci *mantis)
+{
+       int err;
+
+       mantis->mac_address[0] = 0x08;
+       err = read_eeprom_byte(mantis, &mantis->mac_address[0], 6);
+       if (err < 0) {
+               dprintk(verbose, MANTIS_ERROR, 1, "Mantis EEPROM read error");
+
+               return err;
+       }
+       dprintk(verbose, MANTIS_ERROR, 0,
+               "    MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]\n",
+               mantis->mac_address[0], mantis->mac_address[1],
+               mantis->mac_address[2], mantis->mac_address[3],
+               mantis->mac_address[4], mantis->mac_address[5]);
+
+       return 0;
+}
+
+#define MANTIS_MODEL_UNKNOWN   "UNKNOWN"
+#define MANTIS_DEV_UNKNOWN     "UNKNOWN"
+
+struct mantis_hwconfig unknown_device = {
+       .model_name     = MANTIS_MODEL_UNKNOWN,
+       .dev_type       = MANTIS_DEV_UNKNOWN,
+};
+
+static void mantis_load_config(struct mantis_pci *mantis)
+{
+       switch (mantis->subsystem_device) {
+       case MANTIS_VP_1033_DVB_S:      /* VP-1033 */
+               mantis->hwconfig = &vp1033_mantis_config;
+               break;
+       case MANTIS_VP_1034_DVB_S:      /* VP-1034 */
+               mantis->hwconfig = &vp1034_mantis_config;
+               break;
+       case MANTIS_VP_1041_DVB_S2:     /* VP-1041 */
+       case TECHNISAT_SKYSTAR_HD2:
+               mantis->hwconfig = &vp1041_mantis_config;
+               break;
+       case MANTIS_VP_2033_DVB_C:      /* VP-2033 */
+               mantis->hwconfig = &vp2033_mantis_config;
+               break;
+       case MANTIS_VP_2040_DVB_C:      /* VP-2040 */
+       case TERRATEC_CINERGY_C_PCI:    /* VP-2040 clone */
+       case TECHNISAT_CABLESTAR_HD2:
+               mantis->hwconfig = &vp2040_mantis_config;
+               break;
+       case MANTIS_VP_3030_DVB_T:      /* VP-3030 */
+               mantis->hwconfig = &vp3030_mantis_config;
+               break;
+       default:
+               mantis->hwconfig = &unknown_device;
+               break;
+       }
+}
+
+int mantis_core_init(struct mantis_pci *mantis)
+{
+       int err = 0;
+
+       mantis_load_config(mantis);
+       dprintk(verbose, MANTIS_ERROR, 0, "found a %s PCI %s device on (%02x:%02x.%x),\n",
+               mantis->hwconfig->model_name, mantis->hwconfig->dev_type,
+               mantis->pdev->bus->number, PCI_SLOT(mantis->pdev->devfn), PCI_FUNC(mantis->pdev->devfn));
+       dprintk(verbose, MANTIS_ERROR, 0, "    Mantis Rev %d [%04x:%04x], ",
+               mantis->revision,
+               mantis->subsystem_vendor, mantis->subsystem_device);
+       dprintk(verbose, MANTIS_ERROR, 0,
+               "irq: %d, latency: %d\n    memory: 0x%lx, mmio: 0x%p\n",
+               mantis->pdev->irq, mantis->latency,
+               mantis->mantis_addr, mantis->mantis_mmio);
+
+       err = mantis_i2c_init(mantis);
+       if (err < 0) {
+               dprintk(verbose, MANTIS_ERROR, 1, "Mantis I2C init failed");
+               return err;
+       }
+       err = get_mac_address(mantis);
+       if (err < 0) {
+               dprintk(verbose, MANTIS_ERROR, 1, "get MAC address failed");
+               return err;
+       }
+       err = mantis_dma_init(mantis);
+       if (err < 0) {
+               dprintk(verbose, MANTIS_ERROR, 1, "Mantis DMA init failed");
+               return err;
+       }
+       err = mantis_dvb_init(mantis);
+       if (err < 0) {
+               dprintk(verbose, MANTIS_DEBUG, 1, "Mantis DVB init failed");
+               return err;
+       }
+       err = mantis_uart_init(mantis);
+       if (err < 0) {
+               dprintk(verbose, MANTIS_DEBUG, 1, "Mantis UART init failed");
+               return err;
+       }
+
+       return 0;
+}
+
+int mantis_core_exit(struct mantis_pci *mantis)
+{
+       mantis_dma_stop(mantis);
+       dprintk(verbose, MANTIS_ERROR, 1, "DMA engine stopping");
+
+       mantis_uart_exit(mantis);
+       dprintk(verbose, MANTIS_ERROR, 1, "UART exit failed");
+
+       if (mantis_dma_exit(mantis) < 0)
+               dprintk(verbose, MANTIS_ERROR, 1, "DMA exit failed");
+       if (mantis_dvb_exit(mantis) < 0)
+               dprintk(verbose, MANTIS_ERROR, 1, "DVB exit failed");
+       if (mantis_i2c_exit(mantis) < 0)
+               dprintk(verbose, MANTIS_ERROR, 1, "I2C adapter delete.. failed");
+
+       return 0;
+}
+
+/* Turn the given bit on or off. */
+void gpio_set_bits(struct mantis_pci *mantis, u32 bitpos, u8 value)
+{
+       u32 cur;
+
+       cur = mmread(MANTIS_GPIF_ADDR);
+       if (value)
+               mantis->gpio_status = cur | (1 << bitpos);
+       else
+               mantis->gpio_status = cur & (~(1 << bitpos));
+
+       mmwrite(mantis->gpio_status, MANTIS_GPIF_ADDR);
+       mmwrite(0x00, MANTIS_GPIF_DOUT);
+       udelay(100);
+}
+
+/* direction = 0 , no CI passthrough ; 1 , CI passthrough */
+void mantis_set_direction(struct mantis_pci *mantis, int direction)
+{
+       u32 reg;
+
+       reg = mmread(0x28);
+       dprintk(verbose, MANTIS_DEBUG, 1, "TS direction setup");
+       if (direction == 0x01) {
+               /* to CI */
+               reg |= 0x04;
+               mmwrite(reg, 0x28);
+               reg &= 0xff - 0x04;
+               mmwrite(reg, 0x28);
+       } else {
+               reg &= 0xff - 0x04;
+               mmwrite(reg, 0x28);
+               reg |= 0x04;
+               mmwrite(reg, 0x28);
+       }
+}
diff --git a/drivers/media/dvb/mantis/mantis_core.h b/drivers/media/dvb/mantis/mantis_core.h
new file mode 100644 (file)
index 0000000..833ee42
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_CORE_H
+#define __MANTIS_CORE_H
+
+#include "mantis_common.h"
+
+
+#define FE_TYPE_SAT    0
+#define FE_TYPE_CAB    1
+#define FE_TYPE_TER    2
+
+#define FE_TYPE_TS204  0
+#define FE_TYPE_TS188  1
+
+
+struct vendorname {
+       u8  *sub_vendor_name;
+       u32 sub_vendor_id;
+};
+
+struct devicetype {
+       u8  *sub_device_name;
+       u32 sub_device_id;
+       u8  device_type;
+       u32 type_flags;
+};
+
+
+extern int mantis_dma_init(struct mantis_pci *mantis);
+extern int mantis_dma_exit(struct mantis_pci *mantis);
+extern void mantis_dma_start(struct mantis_pci *mantis);
+extern void mantis_dma_stop(struct mantis_pci *mantis);
+extern int mantis_i2c_init(struct mantis_pci *mantis);
+extern int mantis_i2c_exit(struct mantis_pci *mantis);
+extern int mantis_core_init(struct mantis_pci *mantis);
+extern int mantis_core_exit(struct mantis_pci *mantis);
+
+#endif /* __MANTIS_CORE_H */
diff --git a/drivers/media/dvb/mantis/mantis_dma.c b/drivers/media/dvb/mantis/mantis_dma.c
new file mode 100644 (file)
index 0000000..46202a4
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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 <asm/page.h>
+#include <linux/vmalloc.h>
+#include <linux/pci.h>
+
+#include <asm/irq.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "mantis_common.h"
+#include "mantis_reg.h"
+#include "mantis_dma.h"
+
+#define RISC_WRITE             (0x01 << 28)
+#define RISC_JUMP              (0x07 << 28)
+#define RISC_IRQ               (0x01 << 24)
+
+#define RISC_STATUS(status)    ((((~status) & 0x0f) << 20) | ((status & 0x0f) << 16))
+#define RISC_FLUSH()           (mantis->risc_pos = 0)
+#define RISC_INSTR(opcode)     (mantis->risc_cpu[mantis->risc_pos++] = cpu_to_le32(opcode))
+
+#define MANTIS_BUF_SIZE                (64 * 1024)
+#define MANTIS_BLOCK_BYTES     (MANTIS_BUF_SIZE >> 4)
+#define MANTIS_BLOCK_COUNT     (1 << 4)
+#define MANTIS_RISC_SIZE       PAGE_SIZE
+
+int mantis_dma_exit(struct mantis_pci *mantis)
+{
+       if (mantis->buf_cpu) {
+               dprintk(MANTIS_ERROR, 1,
+                       "DMA=0x%lx cpu=0x%p size=%d",
+                       (unsigned long) mantis->buf_dma,
+                        mantis->buf_cpu,
+                        MANTIS_BUF_SIZE);
+
+               pci_free_consistent(mantis->pdev, MANTIS_BUF_SIZE,
+                                   mantis->buf_cpu, mantis->buf_dma);
+
+               mantis->buf_cpu = NULL;
+       }
+       if (mantis->risc_cpu) {
+               dprintk(MANTIS_ERROR, 1,
+                       "RISC=0x%lx cpu=0x%p size=%lx",
+                       (unsigned long) mantis->risc_dma,
+                       mantis->risc_cpu,
+                       MANTIS_RISC_SIZE);
+
+               pci_free_consistent(mantis->pdev, MANTIS_RISC_SIZE,
+                                   mantis->risc_cpu, mantis->risc_dma);
+
+               mantis->risc_cpu = NULL;
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(mantis_dma_exit);
+
+static inline int mantis_alloc_buffers(struct mantis_pci *mantis)
+{
+       if (!mantis->buf_cpu) {
+               mantis->buf_cpu = pci_alloc_consistent(mantis->pdev,
+                                                      MANTIS_BUF_SIZE,
+                                                      &mantis->buf_dma);
+               if (!mantis->buf_cpu) {
+                       dprintk(MANTIS_ERROR, 1,
+                               "DMA buffer allocation failed");
+
+                       goto err;
+               }
+               dprintk(MANTIS_ERROR, 1,
+                       "DMA=0x%lx cpu=0x%p size=%d",
+                       (unsigned long) mantis->buf_dma,
+                       mantis->buf_cpu, MANTIS_BUF_SIZE);
+       }
+       if (!mantis->risc_cpu) {
+               mantis->risc_cpu = pci_alloc_consistent(mantis->pdev,
+                                                       MANTIS_RISC_SIZE,
+                                                       &mantis->risc_dma);
+
+               if (!mantis->risc_cpu) {
+                       dprintk(MANTIS_ERROR, 1,
+                               "RISC program allocation failed");
+
+                       mantis_dma_exit(mantis);
+
+                       goto err;
+               }
+               dprintk(MANTIS_ERROR, 1,
+                       "RISC=0x%lx cpu=0x%p size=%lx",
+                       (unsigned long) mantis->risc_dma,
+                       mantis->risc_cpu, MANTIS_RISC_SIZE);
+       }
+
+       return 0;
+err:
+       dprintk(MANTIS_ERROR, 1, "Out of memory (?) .....");
+       return -ENOMEM;
+}
+
+static inline int mantis_calc_lines(struct mantis_pci *mantis)
+{
+       mantis->line_bytes = MANTIS_BLOCK_BYTES;
+       mantis->line_count = MANTIS_BLOCK_COUNT;
+
+       while (mantis->line_bytes > 4095) {
+               mantis->line_bytes >>= 1;
+               mantis->line_count <<= 1;
+       }
+
+       dprintk(MANTIS_DEBUG, 1, "Mantis RISC block bytes=[%d], line bytes=[%d], line count=[%d]",
+               MANTIS_BLOCK_BYTES, mantis->line_bytes, mantis->line_count);
+
+       if (mantis->line_count > 255) {
+               dprintk(MANTIS_ERROR, 1, "Buffer size error");
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+int mantis_dma_init(struct mantis_pci *mantis)
+{
+       int err = 0;
+
+       dprintk(MANTIS_DEBUG, 1, "Mantis DMA init");
+       if (mantis_alloc_buffers(mantis) < 0) {
+               dprintk(MANTIS_ERROR, 1, "Error allocating DMA buffer");
+
+               /* Stop RISC Engine */
+               mmwrite(0, MANTIS_DMA_CTL);
+
+               goto err;
+       }
+       err = mantis_calc_lines(mantis);
+       if (err < 0) {
+               dprintk(MANTIS_ERROR, 1, "Mantis calc lines failed");
+
+               goto err;
+       }
+
+       return 0;
+err:
+       return err;
+}
+EXPORT_SYMBOL_GPL(mantis_dma_init);
+
+static inline void mantis_risc_program(struct mantis_pci *mantis)
+{
+       u32 buf_pos = 0;
+       u32 line;
+
+       dprintk(MANTIS_DEBUG, 1, "Mantis create RISC program");
+       RISC_FLUSH();
+
+       dprintk(MANTIS_DEBUG, 1, "risc len lines %u, bytes per line %u",
+               mantis->line_count, mantis->line_bytes);
+
+       for (line = 0; line < mantis->line_count; line++) {
+               dprintk(MANTIS_DEBUG, 1, "RISC PROG line=[%d]", line);
+               if (!(buf_pos % MANTIS_BLOCK_BYTES)) {
+                       RISC_INSTR(RISC_WRITE   |
+                                  RISC_IRQ     |
+                                  RISC_STATUS(((buf_pos / MANTIS_BLOCK_BYTES) +
+                                  (MANTIS_BLOCK_COUNT - 1)) %
+                                   MANTIS_BLOCK_COUNT) |
+                                   mantis->line_bytes);
+               } else {
+                       RISC_INSTR(RISC_WRITE   | mantis->line_bytes);
+               }
+               RISC_INSTR(mantis->buf_dma + buf_pos);
+               buf_pos += mantis->line_bytes;
+       }
+       RISC_INSTR(RISC_JUMP);
+       RISC_INSTR(mantis->risc_dma);
+}
+
+void mantis_dma_start(struct mantis_pci *mantis)
+{
+       dprintk(MANTIS_DEBUG, 1, "Mantis Start DMA engine");
+
+       mantis_risc_program(mantis);
+       mmwrite(mantis->risc_dma, MANTIS_RISC_START);
+       mmwrite(mmread(MANTIS_GPIF_ADDR) | MANTIS_GPIF_HIFRDWRN, MANTIS_GPIF_ADDR);
+
+       mmwrite(0, MANTIS_DMA_CTL);
+       mantis->last_block = mantis->finished_block = 0;
+
+       mmwrite(mmread(MANTIS_INT_MASK) | MANTIS_INT_RISCI, MANTIS_INT_MASK);
+
+       mmwrite(MANTIS_FIFO_EN | MANTIS_DCAP_EN
+                              | MANTIS_RISC_EN, MANTIS_DMA_CTL);
+
+}
+
+void mantis_dma_stop(struct mantis_pci *mantis)
+{
+       u32 stat = 0, mask = 0;
+
+       stat = mmread(MANTIS_INT_STAT);
+       mask = mmread(MANTIS_INT_MASK);
+       dprintk(MANTIS_DEBUG, 1, "Mantis Stop DMA engine");
+
+       mmwrite((mmread(MANTIS_GPIF_ADDR) & (~(MANTIS_GPIF_HIFRDWRN))), MANTIS_GPIF_ADDR);
+
+       mmwrite((mmread(MANTIS_DMA_CTL) & ~(MANTIS_FIFO_EN |
+                                           MANTIS_DCAP_EN |
+                                           MANTIS_RISC_EN)), MANTIS_DMA_CTL);
+
+       mmwrite(mmread(MANTIS_INT_STAT), MANTIS_INT_STAT);
+
+       mmwrite(mmread(MANTIS_INT_MASK) & ~(MANTIS_INT_RISCI |
+                                           MANTIS_INT_RISCEN), MANTIS_INT_MASK);
+}
+
+
+void mantis_dma_xfer(unsigned long data)
+{
+       struct mantis_pci *mantis = (struct mantis_pci *) data;
+       struct mantis_hwconfig *config = mantis->hwconfig;
+
+       while (mantis->last_block != mantis->finished_block) {
+               dprintk(MANTIS_DEBUG, 1, "last block=[%d] finished block=[%d]",
+                       mantis->last_block, mantis->finished_block);
+
+               (config->ts_size ? dvb_dmx_swfilter_204 : dvb_dmx_swfilter)
+               (&mantis->demux, &mantis->buf_cpu[mantis->last_block * MANTIS_BLOCK_BYTES], MANTIS_BLOCK_BYTES);
+               mantis->last_block = (mantis->last_block + 1) % MANTIS_BLOCK_COUNT;
+       }
+}
diff --git a/drivers/media/dvb/mantis/mantis_dma.h b/drivers/media/dvb/mantis/mantis_dma.h
new file mode 100644 (file)
index 0000000..6be00fa
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_DMA_H
+#define __MANTIS_DMA_H
+
+extern int mantis_dma_init(struct mantis_pci *mantis);
+extern int mantis_dma_exit(struct mantis_pci *mantis);
+extern void mantis_dma_start(struct mantis_pci *mantis);
+extern void mantis_dma_stop(struct mantis_pci *mantis);
+extern void mantis_dma_xfer(unsigned long data);
+
+#endif /* __MANTIS_DMA_H */
diff --git a/drivers/media/dvb/mantis/mantis_dvb.c b/drivers/media/dvb/mantis/mantis_dvb.c
new file mode 100644 (file)
index 0000000..99d82ee
--- /dev/null
@@ -0,0 +1,296 @@
+/*
+       Mantis PCI bridge driver
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/bitops.h>
+
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/pci.h>
+#include <linux/i2c.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "mantis_common.h"
+#include "mantis_dma.h"
+#include "mantis_ca.h"
+#include "mantis_ioc.h"
+#include "mantis_dvb.h"
+
+DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
+
+int mantis_frontend_power(struct mantis_pci *mantis, enum mantis_power power)
+{
+       struct mantis_hwconfig *config = mantis->hwconfig;
+
+       switch (power) {
+       case POWER_ON:
+               dprintk(MANTIS_DEBUG, 1, "Power ON");
+               gpio_set_bits(mantis, config->power, POWER_ON);
+               msleep(100);
+               gpio_set_bits(mantis, config->power, POWER_ON);
+               msleep(100);
+               break;
+
+       case POWER_OFF:
+               dprintk(MANTIS_DEBUG, 1, "Power OFF");
+               gpio_set_bits(mantis, config->power, POWER_OFF);
+               msleep(100);
+               break;
+
+       default:
+               dprintk(MANTIS_DEBUG, 1, "Unknown state <%02x>", power);
+               return -1;
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(mantis_frontend_power);
+
+void mantis_frontend_soft_reset(struct mantis_pci *mantis)
+{
+       struct mantis_hwconfig *config = mantis->hwconfig;
+
+       dprintk(MANTIS_DEBUG, 1, "Frontend RESET");
+       gpio_set_bits(mantis, config->reset, 0);
+       msleep(100);
+       gpio_set_bits(mantis, config->reset, 0);
+       msleep(100);
+       gpio_set_bits(mantis, config->reset, 1);
+       msleep(100);
+       gpio_set_bits(mantis, config->reset, 1);
+       msleep(100);
+
+       return;
+}
+EXPORT_SYMBOL_GPL(mantis_frontend_soft_reset);
+
+static int mantis_frontend_shutdown(struct mantis_pci *mantis)
+{
+       int err;
+
+       mantis_frontend_soft_reset(mantis);
+       err = mantis_frontend_power(mantis, POWER_OFF);
+       if (err != 0) {
+               dprintk(MANTIS_ERROR, 1, "Frontend POWER OFF failed! <%d>", err);
+               return 1;
+       }
+
+       return 0;
+}
+
+static int mantis_dvb_start_feed(struct dvb_demux_feed *dvbdmxfeed)
+{
+       struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
+       struct mantis_pci *mantis = dvbdmx->priv;
+
+       dprintk(MANTIS_DEBUG, 1, "Mantis DVB Start feed");
+       if (!dvbdmx->dmx.frontend) {
+               dprintk(MANTIS_DEBUG, 1, "no frontend ?");
+               return -EINVAL;
+       }
+
+       mantis->feeds++;
+       dprintk(MANTIS_DEBUG, 1, "mantis start feed, feeds=%d", mantis->feeds);
+
+       if (mantis->feeds == 1)  {
+               dprintk(MANTIS_DEBUG, 1, "mantis start feed & dma");
+               mantis_dma_start(mantis);
+       }
+
+       return mantis->feeds;
+}
+
+static int mantis_dvb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
+{
+       struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
+       struct mantis_pci *mantis = dvbdmx->priv;
+
+       dprintk(MANTIS_DEBUG, 1, "Mantis DVB Stop feed");
+       if (!dvbdmx->dmx.frontend) {
+               dprintk(MANTIS_DEBUG, 1, "no frontend ?");
+               return -EINVAL;
+       }
+
+       mantis->feeds--;
+       if (mantis->feeds == 0) {
+               dprintk(MANTIS_DEBUG, 1, "mantis stop feed and dma");
+               mantis_dma_stop(mantis);
+       }
+
+       return 0;
+}
+
+int __devinit mantis_dvb_init(struct mantis_pci *mantis)
+{
+       struct mantis_hwconfig *config = mantis->hwconfig;
+       int result = -1;
+
+       dprintk(MANTIS_DEBUG, 1, "dvb_register_adapter");
+
+       result = dvb_register_adapter(&mantis->dvb_adapter,
+                                     "Mantis DVB adapter",
+                                     THIS_MODULE,
+                                     &mantis->pdev->dev,
+                                     adapter_nr);
+
+       if (result < 0) {
+
+               dprintk(MANTIS_ERROR, 1, "Error registering adapter");
+               return -ENODEV;
+       }
+
+       mantis->dvb_adapter.priv        = mantis;
+       mantis->demux.dmx.capabilities  = DMX_TS_FILTERING      |
+                                        DMX_SECTION_FILTERING  |
+                                        DMX_MEMORY_BASED_FILTERING;
+
+       mantis->demux.priv              = mantis;
+       mantis->demux.filternum         = 256;
+       mantis->demux.feednum           = 256;
+       mantis->demux.start_feed        = mantis_dvb_start_feed;
+       mantis->demux.stop_feed         = mantis_dvb_stop_feed;
+       mantis->demux.write_to_decoder  = NULL;
+
+       dprintk(MANTIS_DEBUG, 1, "dvb_dmx_init");
+       result = dvb_dmx_init(&mantis->demux);
+       if (result < 0) {
+               dprintk(MANTIS_ERROR, 1, "dvb_dmx_init failed, ERROR=%d", result);
+
+               goto err0;
+       }
+
+       mantis->dmxdev.filternum        = 256;
+       mantis->dmxdev.demux            = &mantis->demux.dmx;
+       mantis->dmxdev.capabilities     = 0;
+       dprintk(MANTIS_DEBUG, 1, "dvb_dmxdev_init");
+
+       result = dvb_dmxdev_init(&mantis->dmxdev, &mantis->dvb_adapter);
+       if (result < 0) {
+
+               dprintk(MANTIS_ERROR, 1, "dvb_dmxdev_init failed, ERROR=%d", result);
+               goto err1;
+       }
+
+       mantis->fe_hw.source            = DMX_FRONTEND_0;
+       result = mantis->demux.dmx.add_frontend(&mantis->demux.dmx, &mantis->fe_hw);
+       if (result < 0) {
+
+               dprintk(MANTIS_ERROR, 1, "dvb_dmx_init failed, ERROR=%d", result);
+               goto err2;
+       }
+
+       mantis->fe_mem.source           = DMX_MEMORY_FE;
+       result = mantis->demux.dmx.add_frontend(&mantis->demux.dmx, &mantis->fe_mem);
+       if (result < 0) {
+               dprintk(MANTIS_ERROR, 1, "dvb_dmx_init failed, ERROR=%d", result);
+               goto err3;
+       }
+
+       result = mantis->demux.dmx.connect_frontend(&mantis->demux.dmx, &mantis->fe_hw);
+       if (result < 0) {
+               dprintk(MANTIS_ERROR, 1, "dvb_dmx_init failed, ERROR=%d", result);
+               goto err4;
+       }
+
+       dvb_net_init(&mantis->dvb_adapter, &mantis->dvbnet, &mantis->demux.dmx);
+       tasklet_init(&mantis->tasklet, mantis_dma_xfer, (unsigned long) mantis);
+       if (mantis->hwconfig) {
+               result = config->frontend_init(mantis, mantis->fe);
+               if (result < 0) {
+                       dprintk(MANTIS_ERROR, 1, "!!! NO Frontends found !!!");
+                       goto err5;
+               } else {
+                       if (mantis->fe == NULL) {
+                               dprintk(MANTIS_ERROR, 1, "FE <NULL>");
+                               goto err5;
+                       }
+
+                       if (dvb_register_frontend(&mantis->dvb_adapter, mantis->fe)) {
+                               dprintk(MANTIS_ERROR, 1, "ERROR: Frontend registration failed");
+
+                               if (mantis->fe->ops.release)
+                                       mantis->fe->ops.release(mantis->fe);
+
+                               mantis->fe = NULL;
+                               goto err5;
+                       }
+               }
+       }
+
+       return 0;
+
+       /* Error conditions ..  */
+err5:
+       tasklet_kill(&mantis->tasklet);
+       dvb_net_release(&mantis->dvbnet);
+       dvb_unregister_frontend(mantis->fe);
+       dvb_frontend_detach(mantis->fe);
+err4:
+       mantis->demux.dmx.remove_frontend(&mantis->demux.dmx, &mantis->fe_mem);
+
+err3:
+       mantis->demux.dmx.remove_frontend(&mantis->demux.dmx, &mantis->fe_hw);
+
+err2:
+       dvb_dmxdev_release(&mantis->dmxdev);
+
+err1:
+       dvb_dmx_release(&mantis->demux);
+
+err0:
+       dvb_unregister_adapter(&mantis->dvb_adapter);
+
+       return result;
+}
+EXPORT_SYMBOL_GPL(mantis_dvb_init);
+
+int __devexit mantis_dvb_exit(struct mantis_pci *mantis)
+{
+       int err;
+
+       if (mantis->fe) {
+               /* mantis_ca_exit(mantis); */
+               err = mantis_frontend_shutdown(mantis);
+               if (err != 0)
+                       dprintk(MANTIS_ERROR, 1, "Frontend exit while POWER ON! <%d>", err);
+               dvb_unregister_frontend(mantis->fe);
+               dvb_frontend_detach(mantis->fe);
+       }
+
+       tasklet_kill(&mantis->tasklet);
+       dvb_net_release(&mantis->dvbnet);
+
+       mantis->demux.dmx.remove_frontend(&mantis->demux.dmx, &mantis->fe_mem);
+       mantis->demux.dmx.remove_frontend(&mantis->demux.dmx, &mantis->fe_hw);
+
+       dvb_dmxdev_release(&mantis->dmxdev);
+       dvb_dmx_release(&mantis->demux);
+
+       dprintk(MANTIS_DEBUG, 1, "dvb_unregister_adapter");
+       dvb_unregister_adapter(&mantis->dvb_adapter);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(mantis_dvb_exit);
diff --git a/drivers/media/dvb/mantis/mantis_dvb.h b/drivers/media/dvb/mantis/mantis_dvb.h
new file mode 100644 (file)
index 0000000..464199d
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_DVB_H
+#define __MANTIS_DVB_H
+
+enum mantis_power {
+       POWER_OFF       = 0,
+       POWER_ON        = 1
+};
+
+extern int mantis_frontend_power(struct mantis_pci *mantis, enum mantis_power power);
+extern void mantis_frontend_soft_reset(struct mantis_pci *mantis);
+
+extern int mantis_dvb_init(struct mantis_pci *mantis);
+extern int mantis_dvb_exit(struct mantis_pci *mantis);
+
+#endif /* __MANTIS_DVB_H */
diff --git a/drivers/media/dvb/mantis/mantis_evm.c b/drivers/media/dvb/mantis/mantis_evm.c
new file mode 100644 (file)
index 0000000..a7b369a
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "mantis_common.h"
+#include "mantis_link.h"
+#include "mantis_hif.h"
+#include "mantis_reg.h"
+
+static void mantis_hifevm_work(struct work_struct *work)
+{
+       struct mantis_ca *ca = container_of(work, struct mantis_ca, hif_evm_work);
+       struct mantis_pci *mantis = ca->ca_priv;
+
+       u32 gpif_stat, gpif_mask;
+
+       gpif_stat = mmread(MANTIS_GPIF_STATUS);
+       gpif_mask = mmread(MANTIS_GPIF_IRQCFG);
+
+       if (gpif_stat & MANTIS_GPIF_DETSTAT) {
+               if (gpif_stat & MANTIS_CARD_PLUGIN) {
+                       dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num);
+                       mmwrite(0xdada0000, MANTIS_CARD_RESET);
+                       mantis_event_cam_plugin(ca);
+                       dvb_ca_en50221_camchange_irq(&ca->en50221,
+                                                    0,
+                                                    DVB_CA_EN50221_CAMCHANGE_INSERTED);
+               }
+       } else {
+               if (gpif_stat & MANTIS_CARD_PLUGOUT) {
+                       dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Unplug", mantis->num);
+                       mmwrite(0xdada0000, MANTIS_CARD_RESET);
+                       mantis_event_cam_unplug(ca);
+                       dvb_ca_en50221_camchange_irq(&ca->en50221,
+                                                    0,
+                                                    DVB_CA_EN50221_CAMCHANGE_REMOVED);
+               }
+       }
+
+       if (mantis->gpif_status & MANTIS_GPIF_EXTIRQ)
+               dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num);
+
+       if (mantis->gpif_status & MANTIS_SBUF_WSTO)
+               dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num);
+
+       if (mantis->gpif_status & MANTIS_GPIF_OTHERR)
+               dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num);
+
+       if (gpif_stat & MANTIS_SBUF_OVFLW)
+               dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Overflow", mantis->num);
+
+       if (gpif_stat & MANTIS_GPIF_BRRDY)
+               dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num);
+
+       if (gpif_stat & MANTIS_GPIF_INTSTAT)
+               dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): GPIF IRQ", mantis->num);
+
+       if (gpif_stat & MANTIS_SBUF_EMPTY)
+               dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty", mantis->num);
+
+       if (gpif_stat & MANTIS_SBUF_OPDONE) {
+               dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num);
+               ca->sbuf_status = MANTIS_SBUF_DATA_AVAIL;
+               ca->hif_event = MANTIS_SBUF_OPDONE;
+               wake_up(&ca->hif_opdone_wq);
+       }
+}
+
+int mantis_evmgr_init(struct mantis_ca *ca)
+{
+       struct mantis_pci *mantis = ca->ca_priv;
+
+       dprintk(MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager");
+       INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work);
+       mantis_pcmcia_init(ca);
+       schedule_work(&ca->hif_evm_work);
+       mantis_hif_init(ca);
+       return 0;
+}
+
+void mantis_evmgr_exit(struct mantis_ca *ca)
+{
+       struct mantis_pci *mantis = ca->ca_priv;
+
+       dprintk(MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting");
+       flush_scheduled_work();
+       mantis_hif_exit(ca);
+       mantis_pcmcia_exit(ca);
+}
diff --git a/drivers/media/dvb/mantis/mantis_hif.c b/drivers/media/dvb/mantis/mantis_hif.c
new file mode 100644 (file)
index 0000000..7477dac
--- /dev/null
@@ -0,0 +1,240 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/signal.h>
+#include <linux/sched.h>
+
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "mantis_common.h"
+
+#include "mantis_hif.h"
+#include "mantis_link.h" /* temporary due to physical layer stuff */
+
+#include "mantis_reg.h"
+
+
+static int mantis_hif_sbuf_opdone_wait(struct mantis_ca *ca)
+{
+       struct mantis_pci *mantis = ca->ca_priv;
+       int rc = 0;
+
+       if (wait_event_timeout(ca->hif_opdone_wq,
+                              ca->hif_event & MANTIS_SBUF_OPDONE,
+                              msecs_to_jiffies(500)) == -ERESTARTSYS) {
+
+               dprintk(MANTIS_ERROR, 1, "Adapter(%d) Slot(0): Smart buffer operation timeout !", mantis->num);
+               rc = -EREMOTEIO;
+       }
+       dprintk(MANTIS_DEBUG, 1, "Smart Buffer Operation complete");
+       ca->hif_event &= ~MANTIS_SBUF_OPDONE;
+       return rc;
+}
+
+static int mantis_hif_write_wait(struct mantis_ca *ca)
+{
+       struct mantis_pci *mantis = ca->ca_priv;
+       u32 opdone = 0, timeout = 0;
+       int rc = 0;
+
+       if (wait_event_timeout(ca->hif_write_wq,
+                              mantis->gpif_status & MANTIS_GPIF_WRACK,
+                              msecs_to_jiffies(500)) == -ERESTARTSYS) {
+
+               dprintk(MANTIS_ERROR, 1, "Adapter(%d) Slot(0): Write ACK timed out !", mantis->num);
+               rc = -EREMOTEIO;
+       }
+       dprintk(MANTIS_DEBUG, 1, "Write Acknowledged");
+       mantis->gpif_status &= ~MANTIS_GPIF_WRACK;
+       while (!opdone) {
+               opdone = (mmread(MANTIS_GPIF_STATUS) & MANTIS_SBUF_OPDONE);
+               udelay(500);
+               timeout++;
+               if (timeout > 100) {
+                       dprintk(MANTIS_ERROR, 1, "Adater(%d) Slot(0): Write operation timed out!", mantis->num);
+                       rc = -ETIMEDOUT;
+                       break;
+               }
+       }
+       dprintk(MANTIS_DEBUG, 1, "HIF Write success");
+       return rc;
+}
+
+
+int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr)
+{
+       struct mantis_pci *mantis = ca->ca_priv;
+       u32 hif_addr = 0, data, count = 4;
+
+       dprintk(MANTIS_DEBUG, 1, "Adapter(%d) Slot(0): Request HIF Mem Read", mantis->num);
+       mutex_lock(&ca->ca_lock);
+       hif_addr &= ~MANTIS_GPIF_PCMCIAREG;
+       hif_addr &= ~MANTIS_GPIF_PCMCIAIOM;
+       hif_addr |=  MANTIS_HIF_STATUS;
+       hif_addr |=  addr;
+
+       mmwrite(hif_addr, MANTIS_GPIF_BRADDR);
+       mmwrite(count, MANTIS_GPIF_BRBYTES);
+       udelay(20);
+       mmwrite(hif_addr | MANTIS_GPIF_HIFRDWRN, MANTIS_GPIF_ADDR);
+
+       if (mantis_hif_sbuf_opdone_wait(ca) != 0) {
+               dprintk(MANTIS_ERROR, 1, "Adapter(%d) Slot(0): GPIF Smart Buffer operation failed", mantis->num);
+               mutex_unlock(&ca->ca_lock);
+               return -EREMOTEIO;
+       }
+       data = mmread(MANTIS_GPIF_DIN);
+       mutex_unlock(&ca->ca_lock);
+       dprintk(MANTIS_DEBUG, 1, "Mem Read: 0x%02x", data);
+       return (data >> 24) & 0xff;
+}
+
+int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data)
+{
+       struct mantis_slot *slot = ca->slot;
+       struct mantis_pci *mantis = ca->ca_priv;
+       u32 hif_addr = 0;
+
+       dprintk(MANTIS_DEBUG, 1, "Adapter(%d) Slot(0): Request HIF Mem Write", mantis->num);
+       mutex_lock(&ca->ca_lock);
+       hif_addr &= ~MANTIS_GPIF_HIFRDWRN;
+       hif_addr &= ~MANTIS_GPIF_PCMCIAREG;
+       hif_addr &= ~MANTIS_GPIF_PCMCIAIOM;
+       hif_addr |=  MANTIS_HIF_STATUS;
+       hif_addr |=  addr;
+
+       mmwrite(slot->slave_cfg, MANTIS_GPIF_CFGSLA); /* Slot0 alone for now */
+       mmwrite(hif_addr, MANTIS_GPIF_ADDR);
+       mmwrite(data, MANTIS_GPIF_DOUT);
+
+       if (mantis_hif_write_wait(ca) != 0) {
+               dprintk(MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Smart Buffer operation failed", mantis->num);
+               mutex_unlock(&ca->ca_lock);
+               return -EREMOTEIO;
+       }
+       dprintk(MANTIS_DEBUG, 1, "Mem Write: (0x%02x to 0x%02x)", data, addr);
+       mutex_unlock(&ca->ca_lock);
+
+       return 0;
+}
+
+int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr)
+{
+       struct mantis_pci *mantis = ca->ca_priv;
+       u32 data, hif_addr = 0;
+
+       dprintk(MANTIS_DEBUG, 1, "Adapter(%d) Slot(0): Request HIF I/O Read", mantis->num);
+       mutex_lock(&ca->ca_lock);
+       hif_addr &= ~MANTIS_GPIF_PCMCIAREG;
+       hif_addr |=  MANTIS_GPIF_PCMCIAIOM;
+       hif_addr |=  MANTIS_HIF_STATUS;
+       hif_addr |=  addr;
+
+       mmwrite(hif_addr, MANTIS_GPIF_BRADDR);
+       mmwrite(1, MANTIS_GPIF_BRBYTES);
+       udelay(20);
+       mmwrite(hif_addr | MANTIS_GPIF_HIFRDWRN, MANTIS_GPIF_ADDR);
+
+       if (mantis_hif_sbuf_opdone_wait(ca) != 0) {
+               dprintk(MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Smart Buffer operation failed", mantis->num);
+               mutex_unlock(&ca->ca_lock);
+               return -EREMOTEIO;
+       }
+       data = mmread(MANTIS_GPIF_DIN);
+       dprintk(MANTIS_DEBUG, 1, "I/O Read: 0x%02x", data);
+       udelay(50);
+       mutex_unlock(&ca->ca_lock);
+
+       return (u8) data;
+}
+
+int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u8 data)
+{
+       struct mantis_pci *mantis = ca->ca_priv;
+       u32 hif_addr = 0;
+
+       dprintk(MANTIS_DEBUG, 1, "Adapter(%d) Slot(0): Request HIF I/O Write", mantis->num);
+       mutex_lock(&ca->ca_lock);
+       hif_addr &= ~MANTIS_GPIF_PCMCIAREG;
+       hif_addr &= ~MANTIS_GPIF_HIFRDWRN;
+       hif_addr |=  MANTIS_GPIF_PCMCIAIOM;
+       hif_addr |=  MANTIS_HIF_STATUS;
+       hif_addr |=  addr;
+
+       mmwrite(hif_addr, MANTIS_GPIF_ADDR);
+       mmwrite(data, MANTIS_GPIF_DOUT);
+
+       if (mantis_hif_write_wait(ca) != 0) {
+               dprintk(MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Smart Buffer operation failed", mantis->num);
+               mutex_unlock(&ca->ca_lock);
+               return -EREMOTEIO;
+       }
+       dprintk(MANTIS_DEBUG, 1, "I/O Write: (0x%02x to 0x%02x)", data, addr);
+       mutex_unlock(&ca->ca_lock);
+       udelay(50);
+
+       return 0;
+}
+
+int mantis_hif_init(struct mantis_ca *ca)
+{
+       struct mantis_slot *slot = ca->slot;
+       struct mantis_pci *mantis = ca->ca_priv;
+       u32 irqcfg;
+
+       slot[0].slave_cfg = 0x70773028;
+       dprintk(MANTIS_ERROR, 1, "Adapter(%d) Initializing Mantis Host Interface", mantis->num);
+
+       mutex_lock(&ca->ca_lock);
+       irqcfg = mmread(MANTIS_GPIF_IRQCFG);
+       irqcfg = MANTIS_MASK_BRRDY      |
+                MANTIS_MASK_WRACK      |
+                MANTIS_MASK_EXTIRQ     |
+                MANTIS_MASK_WSTO       |
+                MANTIS_MASK_OTHERR     |
+                MANTIS_MASK_OVFLW;
+
+       mmwrite(irqcfg, MANTIS_GPIF_IRQCFG);
+       mutex_unlock(&ca->ca_lock);
+
+       return 0;
+}
+
+void mantis_hif_exit(struct mantis_ca *ca)
+{
+       struct mantis_pci *mantis = ca->ca_priv;
+       u32 irqcfg;
+
+       dprintk(MANTIS_ERROR, 1, "Adapter(%d) Exiting Mantis Host Interface", mantis->num);
+       mutex_lock(&ca->ca_lock);
+       irqcfg = mmread(MANTIS_GPIF_IRQCFG);
+       irqcfg &= ~MANTIS_MASK_BRRDY;
+       mmwrite(irqcfg, MANTIS_GPIF_IRQCFG);
+       mutex_unlock(&ca->ca_lock);
+}
diff --git a/drivers/media/dvb/mantis/mantis_hif.h b/drivers/media/dvb/mantis/mantis_hif.h
new file mode 100644 (file)
index 0000000..9094f9e
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_HIF_H
+#define __MANTIS_HIF_H
+
+#define MANTIS_HIF_MEMRD               1
+#define MANTIS_HIF_MEMWR               2
+#define MANTIS_HIF_IOMRD               3
+#define MANTIS_HIF_IOMWR               4
+
+#endif /* __MANTIS_HIF_H */
diff --git a/drivers/media/dvb/mantis/mantis_i2c.c b/drivers/media/dvb/mantis/mantis_i2c.c
new file mode 100644 (file)
index 0000000..7870bcf
--- /dev/null
@@ -0,0 +1,267 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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 <asm/io.h>
+#include <linux/ioport.h>
+#include <linux/pci.h>
+#include <linux/i2c.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "mantis_common.h"
+#include "mantis_reg.h"
+#include "mantis_i2c.h"
+
+#define TRIALS                 10000
+
+static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg)
+{
+       u32 rxd, i, stat, trials;
+
+       dprintk(MANTIS_INFO, 0, "        %s:  Address=[0x%02x] <R>[ ",
+               __func__, msg->addr);
+
+       for (i = 0; i < msg->len; i++) {
+               rxd = (msg->addr << 25) | (1 << 24)
+                                       | MANTIS_I2C_RATE_3
+                                       | MANTIS_I2C_STOP
+                                       | MANTIS_I2C_PGMODE;
+
+               if (i == (msg->len - 1))
+                       rxd &= ~MANTIS_I2C_STOP;
+
+               mmwrite(MANTIS_INT_I2CDONE, MANTIS_INT_STAT);
+               mmwrite(rxd, MANTIS_I2CDATA_CTL);
+
+               /* wait for xfer completion */
+               for (trials = 0; trials < TRIALS; trials++) {
+                       stat = mmread(MANTIS_INT_STAT);
+                       if (stat & MANTIS_INT_I2CDONE)
+                               break;
+               }
+
+               dprintk(MANTIS_TMG, 0, "I2CDONE: trials=%d\n", trials);
+
+               /* wait for xfer completion */
+               for (trials = 0; trials < TRIALS; trials++) {
+                       stat = mmread(MANTIS_INT_STAT);
+                       if (stat & MANTIS_INT_I2CRACK)
+                               break;
+               }
+
+               dprintk(MANTIS_TMG, 0, "I2CRACK: trials=%d\n", trials);
+
+               rxd = mmread(MANTIS_I2CDATA_CTL);
+               msg->buf[i] = (u8)((rxd >> 8) & 0xFF);
+               dprintk(MANTIS_INFO, 0, "%02x ", msg->buf[i]);
+       }
+       dprintk(MANTIS_INFO, 0, "]\n");
+
+       return 0;
+}
+
+static int mantis_i2c_write(struct mantis_pci *mantis, const struct i2c_msg *msg)
+{
+       int i;
+       u32 txd = 0, stat, trials;
+
+       dprintk(MANTIS_INFO, 0, "        %s: Address=[0x%02x] <W>[ ",
+               __func__, msg->addr);
+
+       for (i = 0; i < msg->len; i++) {
+               dprintk(MANTIS_INFO, 0, "%02x ", msg->buf[i]);
+               txd = (msg->addr << 25) | (msg->buf[i] << 8)
+                                       | MANTIS_I2C_RATE_3
+                                       | MANTIS_I2C_STOP
+                                       | MANTIS_I2C_PGMODE;
+
+               if (i == (msg->len - 1))
+                       txd &= ~MANTIS_I2C_STOP;
+
+               mmwrite(MANTIS_INT_I2CDONE, MANTIS_INT_STAT);
+               mmwrite(txd, MANTIS_I2CDATA_CTL);
+
+               /* wait for xfer completion */
+               for (trials = 0; trials < TRIALS; trials++) {
+                       stat = mmread(MANTIS_INT_STAT);
+                       if (stat & MANTIS_INT_I2CDONE)
+                               break;
+               }
+
+               dprintk(MANTIS_TMG, 0, "I2CDONE: trials=%d\n", trials);
+
+               /* wait for xfer completion */
+               for (trials = 0; trials < TRIALS; trials++) {
+                       stat = mmread(MANTIS_INT_STAT);
+                       if (stat & MANTIS_INT_I2CRACK)
+                               break;
+               }
+
+               dprintk(MANTIS_TMG, 0, "I2CRACK: trials=%d\n", trials);
+       }
+       dprintk(MANTIS_INFO, 0, "]\n");
+
+       return 0;
+}
+
+static int mantis_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num)
+{
+       int ret = 0, i = 0, trials;
+       u32 stat, data, txd;
+       struct mantis_pci *mantis;
+       struct mantis_hwconfig *config;
+
+       mantis = i2c_get_adapdata(adapter);
+       BUG_ON(!mantis);
+       config = mantis->hwconfig;
+       BUG_ON(!config);
+
+       dprintk(MANTIS_DEBUG, 1, "Messages:%d", num);
+       mutex_lock(&mantis->i2c_lock);
+
+       while (i < num) {
+               /* Byte MODE */
+               if ((config->i2c_mode & MANTIS_BYTE_MODE) &&
+                   ((i + 1) < num)                     &&
+                   (msgs[i].len < 2)                   &&
+                   (msgs[i + 1].len < 2)               &&
+                   (msgs[i + 1].flags & I2C_M_RD)) {
+
+                       dprintk(MANTIS_DEBUG, 0, "        Byte MODE:\n");
+
+                       /* Read operation */
+                       txd = msgs[i].addr << 25 | (0x1 << 24)
+                                                | (msgs[i].buf[0] << 16)
+                                                | MANTIS_I2C_RATE_3;
+
+                       mmwrite(txd, MANTIS_I2CDATA_CTL);
+                       /* wait for xfer completion */
+                       for (trials = 0; trials < TRIALS; trials++) {
+                               stat = mmread(MANTIS_INT_STAT);
+                               if (stat & MANTIS_INT_I2CDONE)
+                                       break;
+                       }
+
+                       /* check for xfer completion */
+                       if (stat & MANTIS_INT_I2CDONE) {
+                               /* check xfer was acknowledged */
+                               if (stat & MANTIS_INT_I2CRACK) {
+                                       data = mmread(MANTIS_I2CDATA_CTL);
+                                       msgs[i + 1].buf[0] = (data >> 8) & 0xff;
+                                       dprintk(MANTIS_DEBUG, 0, "        Byte <%d> RXD=0x%02x  [%02x]\n", 0x0, data, msgs[i + 1].buf[0]);
+                               } else {
+                                       /* I/O error */
+                                       dprintk(MANTIS_ERROR, 1, "        I/O error, LINE:%d", __LINE__);
+                                       ret = -EIO;
+                                       break;
+                               }
+                       } else {
+                               /* I/O error */
+                               dprintk(MANTIS_ERROR, 1, "        I/O error, LINE:%d", __LINE__);
+                               ret = -EIO;
+                               break;
+                       }
+                       i += 2; /* Write/Read operation in one go */
+               }
+
+               if (i < num) {
+                       if (msgs[i].flags & I2C_M_RD)
+                               ret = mantis_i2c_read(mantis, &msgs[i]);
+                       else
+                               ret = mantis_i2c_write(mantis, &msgs[i]);
+
+                       i++;
+                       if (ret < 0)
+                               goto bail_out;
+               }
+
+       }
+
+       mutex_unlock(&mantis->i2c_lock);
+
+       return num;
+
+bail_out:
+       mutex_unlock(&mantis->i2c_lock);
+       return ret;
+}
+
+static u32 mantis_i2c_func(struct i2c_adapter *adapter)
+{
+       return I2C_FUNC_SMBUS_EMUL;
+}
+
+static struct i2c_algorithm mantis_algo = {
+       .master_xfer            = mantis_i2c_xfer,
+       .functionality          = mantis_i2c_func,
+};
+
+int __devinit mantis_i2c_init(struct mantis_pci *mantis)
+{
+       u32 intstat, intmask;
+       struct i2c_adapter *i2c_adapter = &mantis->adapter;
+       struct pci_dev *pdev            = mantis->pdev;
+
+       init_waitqueue_head(&mantis->i2c_wq);
+       mutex_init(&mantis->i2c_lock);
+       strncpy(i2c_adapter->name, "Mantis I2C", sizeof(i2c_adapter->name));
+       i2c_set_adapdata(i2c_adapter, mantis);
+
+       i2c_adapter->owner      = THIS_MODULE;
+       i2c_adapter->class      = I2C_CLASS_TV_DIGITAL;
+       i2c_adapter->algo       = &mantis_algo;
+       i2c_adapter->algo_data  = NULL;
+       i2c_adapter->timeout    = 500;
+       i2c_adapter->retries    = 3;
+       i2c_adapter->dev.parent = &pdev->dev;
+
+       mantis->i2c_rc          = i2c_add_adapter(i2c_adapter);
+       if (mantis->i2c_rc < 0)
+               return mantis->i2c_rc;
+
+       dprintk(MANTIS_DEBUG, 1, "Initializing I2C ..");
+
+       intstat = mmread(MANTIS_INT_STAT);
+       intmask = mmread(MANTIS_INT_MASK);
+       mmwrite(intstat, MANTIS_INT_STAT);
+       dprintk(MANTIS_DEBUG, 1, "Disabling I2C interrupt");
+       intmask = mmread(MANTIS_INT_MASK);
+       mmwrite((intmask & ~MANTIS_INT_I2CDONE), MANTIS_INT_MASK);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(mantis_i2c_init);
+
+int mantis_i2c_exit(struct mantis_pci *mantis)
+{
+       u32 intmask;
+
+       dprintk(MANTIS_DEBUG, 1, "Disabling I2C interrupt");
+       intmask = mmread(MANTIS_INT_MASK);
+       mmwrite((intmask & ~MANTIS_INT_I2CDONE), MANTIS_INT_MASK);
+
+       dprintk(MANTIS_DEBUG, 1, "Removing I2C adapter");
+       return i2c_del_adapter(&mantis->adapter);
+}
+EXPORT_SYMBOL_GPL(mantis_i2c_exit);
diff --git a/drivers/media/dvb/mantis/mantis_i2c.h b/drivers/media/dvb/mantis/mantis_i2c.h
new file mode 100644 (file)
index 0000000..1342df2
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_I2C_H
+#define __MANTIS_I2C_H
+
+#define I2C_STOP               (1 <<  0)
+#define I2C_READ               (1 <<  1)
+
+extern int mantis_i2c_init(struct mantis_pci *mantis);
+extern int mantis_i2c_exit(struct mantis_pci *mantis);
+
+#endif /* __MANTIS_I2C_H */
diff --git a/drivers/media/dvb/mantis/mantis_input.c b/drivers/media/dvb/mantis/mantis_input.c
new file mode 100644 (file)
index 0000000..6a9df77
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/input.h>
+#include <media/ir-common.h>
+#include <linux/pci.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "mantis_common.h"
+#include "mantis_reg.h"
+#include "mantis_uart.h"
+
+static struct ir_scancode mantis_ir_table[] = {
+       { 0x29, KEY_POWER       },
+       { 0x28, KEY_FAVORITES   },
+       { 0x30, KEY_TEXT        },
+       { 0x17, KEY_INFO        }, /* Preview */
+       { 0x23, KEY_EPG         },
+       { 0x3b, KEY_F22         }, /* Record List */
+       { 0x3c, KEY_1           },
+       { 0x3e, KEY_2           },
+       { 0x39, KEY_3           },
+       { 0x36, KEY_4           },
+       { 0x22, KEY_5           },
+       { 0x20, KEY_6           },
+       { 0x32, KEY_7           },
+       { 0x26, KEY_8           },
+       { 0x24, KEY_9           },
+       { 0x2a, KEY_0           },
+
+       { 0x33, KEY_CANCEL      },
+       { 0x2c, KEY_BACK        },
+       { 0x15, KEY_CLEAR       },
+       { 0x3f, KEY_TAB         },
+       { 0x10, KEY_ENTER       },
+       { 0x14, KEY_UP          },
+       { 0x0d, KEY_RIGHT       },
+       { 0x0e, KEY_DOWN        },
+       { 0x11, KEY_LEFT        },
+
+       { 0x21, KEY_VOLUMEUP    },
+       { 0x35, KEY_VOLUMEDOWN  },
+       { 0x3d, KEY_CHANNELDOWN },
+       { 0x3a, KEY_CHANNELUP   },
+       { 0x2e, KEY_RECORD      },
+       { 0x2b, KEY_PLAY        },
+       { 0x13, KEY_PAUSE       },
+       { 0x25, KEY_STOP        },
+
+       { 0x1f, KEY_REWIND      },
+       { 0x2d, KEY_FASTFORWARD },
+       { 0x1e, KEY_PREVIOUS    }, /* Replay |< */
+       { 0x1d, KEY_NEXT        }, /* Skip   >| */
+
+       { 0x0b, KEY_CAMERA      }, /* Capture */
+       { 0x0f, KEY_LANGUAGE    }, /* SAP */
+       { 0x18, KEY_MODE        }, /* PIP */
+       { 0x12, KEY_ZOOM        }, /* Full screen */
+       { 0x1c, KEY_SUBTITLE    },
+       { 0x2f, KEY_MUTE        },
+       { 0x16, KEY_F20         }, /* L/R */
+       { 0x38, KEY_F21         }, /* Hibernate */
+
+       { 0x37, KEY_SWITCHVIDEOMODE }, /* A/V */
+       { 0x31, KEY_AGAIN       }, /* Recall */
+       { 0x1a, KEY_KPPLUS      }, /* Zoom+ */
+       { 0x19, KEY_KPMINUS     }, /* Zoom- */
+       { 0x27, KEY_RED         },
+       { 0x0C, KEY_GREEN       },
+       { 0x01, KEY_YELLOW      },
+       { 0x00, KEY_BLUE        },
+};
+
+struct ir_scancode_table ir_mantis = {
+       .scan = mantis_ir_table,
+       .size = ARRAY_SIZE(mantis_ir_table),
+};
+EXPORT_SYMBOL_GPL(ir_mantis);
+
+int mantis_input_init(struct mantis_pci *mantis)
+{
+       struct input_dev *rc;
+       struct ir_input_state rc_state;
+       char name[80], dev[80];
+       int err;
+
+       rc = input_allocate_device();
+       if (!rc) {
+               dprintk(MANTIS_ERROR, 1, "Input device allocate failed");
+               return -ENOMEM;
+       }
+
+       sprintf(name, "Mantis %s IR receiver", mantis->hwconfig->model_name);
+       sprintf(dev, "pci-%s/ir0", pci_name(mantis->pdev));
+
+       rc->name = name;
+       rc->phys = dev;
+
+       ir_input_init(rc, &rc_state, IR_TYPE_OTHER);
+
+       rc->id.bustype  = BUS_PCI;
+       rc->id.vendor   = mantis->vendor_id;
+       rc->id.product  = mantis->device_id;
+       rc->id.version  = 1;
+       rc->dev         = mantis->pdev->dev;
+
+       err = ir_input_register(rc, &ir_mantis);
+       if (err) {
+               dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err);
+               input_free_device(rc);
+               return -ENODEV;
+       }
+
+       mantis->rc = rc;
+
+       return 0;
+}
+
+int mantis_exit(struct mantis_pci *mantis)
+{
+       struct input_dev *rc = mantis->rc;
+
+       ir_input_unregister(rc);
+
+       return 0;
+}
diff --git a/drivers/media/dvb/mantis/mantis_ioc.c b/drivers/media/dvb/mantis/mantis_ioc.c
new file mode 100644 (file)
index 0000000..de148de
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/i2c.h>
+
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "mantis_common.h"
+#include "mantis_reg.h"
+#include "mantis_ioc.h"
+
+static int read_eeprom_bytes(struct mantis_pci *mantis, u8 reg, u8 *data, u8 length)
+{
+       struct i2c_adapter *adapter = &mantis->adapter;
+       int err;
+       u8 buf = reg;
+
+       struct i2c_msg msg[] = {
+               { .addr = 0x50, .flags = 0, .buf = &buf, .len = 1 },
+               { .addr = 0x50, .flags = I2C_M_RD, .buf = data, .len = length },
+       };
+
+       err = i2c_transfer(adapter, msg, 2);
+       if (err < 0) {
+               dprintk(MANTIS_ERROR, 1, "ERROR: i2c read: < err=%i d0=0x%02x d1=0x%02x >",
+                       err, data[0], data[1]);
+
+               return err;
+       }
+
+       return 0;
+}
+int mantis_get_mac(struct mantis_pci *mantis)
+{
+       int err;
+       u8 mac_addr[6] = {0};
+
+       err = read_eeprom_bytes(mantis, 0x08, mac_addr, 6);
+       if (err < 0) {
+               dprintk(MANTIS_ERROR, 1, "ERROR: Mantis EEPROM read error <%d>", err);
+
+               return err;
+       }
+
+       dprintk(MANTIS_ERROR, 0,
+               "    MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]\n",
+               mac_addr[0],
+               mac_addr[1],
+               mac_addr[2],
+               mac_addr[3],
+               mac_addr[4],
+               mac_addr[5]);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(mantis_get_mac);
+
+/* Turn the given bit on or off. */
+void gpio_set_bits(struct mantis_pci *mantis, u32 bitpos, u8 value)
+{
+       u32 cur;
+
+       dprintk(MANTIS_DEBUG, 1, "Set Bit <%d> to <%d>", bitpos, value);
+       cur = mmread(MANTIS_GPIF_ADDR);
+       if (value)
+               mantis->gpio_status = cur | (1 << bitpos);
+       else
+               mantis->gpio_status = cur & (~(1 << bitpos));
+
+       dprintk(MANTIS_DEBUG, 1, "GPIO Value <%02x>", mantis->gpio_status);
+       mmwrite(mantis->gpio_status, MANTIS_GPIF_ADDR);
+       mmwrite(0x00, MANTIS_GPIF_DOUT);
+}
+EXPORT_SYMBOL_GPL(gpio_set_bits);
+
+int mantis_stream_control(struct mantis_pci *mantis, enum mantis_stream_control stream_ctl)
+{
+       u32 reg;
+
+       reg = mmread(MANTIS_CONTROL);
+       switch (stream_ctl) {
+       case STREAM_TO_HIF:
+               dprintk(MANTIS_DEBUG, 1, "Set stream to HIF");
+               reg &= 0xff - MANTIS_BYPASS;
+               mmwrite(reg, MANTIS_CONTROL);
+               reg |= MANTIS_BYPASS;
+               mmwrite(reg, MANTIS_CONTROL);
+               break;
+
+       case STREAM_TO_CAM:
+               dprintk(MANTIS_DEBUG, 1, "Set stream to CAM");
+               reg |= MANTIS_BYPASS;
+               mmwrite(reg, MANTIS_CONTROL);
+               reg &= 0xff - MANTIS_BYPASS;
+               mmwrite(reg, MANTIS_CONTROL);
+               break;
+       default:
+               dprintk(MANTIS_ERROR, 1, "Unknown MODE <%02x>", stream_ctl);
+               return -1;
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(mantis_stream_control);
diff --git a/drivers/media/dvb/mantis/mantis_ioc.h b/drivers/media/dvb/mantis/mantis_ioc.h
new file mode 100644 (file)
index 0000000..188fe5a
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_IOC_H
+#define __MANTIS_IOC_H
+
+#define GPIF_A00               0x00
+#define GPIF_A01               0x01
+#define GPIF_A02               0x02
+#define GPIF_A03               0x03
+#define GPIF_A04               0x04
+#define GPIF_A05               0x05
+#define GPIF_A06               0x06
+#define GPIF_A07               0x07
+#define GPIF_A08               0x08
+#define GPIF_A09               0x09
+#define GPIF_A10               0x0a
+#define GPIF_A11               0x0b
+
+#define GPIF_A12               0x0c
+#define GPIF_A13               0x0d
+#define GPIF_A14               0x0e
+
+enum mantis_stream_control {
+       STREAM_TO_HIF = 0,
+       STREAM_TO_CAM
+};
+
+extern int mantis_get_mac(struct mantis_pci *mantis);
+extern void gpio_set_bits(struct mantis_pci *mantis, u32 bitpos, u8 value);
+
+extern int mantis_stream_control(struct mantis_pci *mantis, enum mantis_stream_control stream_ctl);
+
+#endif /* __MANTIS_IOC_H */
diff --git a/drivers/media/dvb/mantis/mantis_link.h b/drivers/media/dvb/mantis/mantis_link.h
new file mode 100644 (file)
index 0000000..2a81477
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_LINK_H
+#define __MANTIS_LINK_H
+
+#include <linux/mutex.h>
+#include <linux/workqueue.h>
+#include "dvb_ca_en50221.h"
+
+enum mantis_sbuf_status {
+       MANTIS_SBUF_DATA_AVAIL          = 1,
+       MANTIS_SBUF_DATA_EMPTY          = 2,
+       MANTIS_SBUF_DATA_OVFLW          = 3
+};
+
+struct mantis_slot {
+       u32                             timeout;
+       u32                             slave_cfg;
+       u32                             bar;
+};
+
+/* Physical layer */
+enum mantis_slot_state {
+       MODULE_INSERTED                 = 3,
+       MODULE_XTRACTED                 = 4
+};
+
+struct mantis_ca {
+       struct mantis_slot              slot[4];
+
+       struct work_struct              hif_evm_work;
+
+       u32                             hif_event;
+       wait_queue_head_t               hif_opdone_wq;
+       wait_queue_head_t               hif_brrdyw_wq;
+       wait_queue_head_t               hif_data_wq;
+       wait_queue_head_t               hif_write_wq; /* HIF Write op */
+
+       enum mantis_sbuf_status         sbuf_status;
+
+       enum mantis_slot_state          slot_state;
+
+       void                            *ca_priv;
+
+       struct dvb_ca_en50221           en50221;
+       struct mutex                    ca_lock;
+};
+
+/* CA */
+extern void mantis_event_cam_plugin(struct mantis_ca *ca);
+extern void mantis_event_cam_unplug(struct mantis_ca *ca);
+extern int mantis_pcmcia_init(struct mantis_ca *ca);
+extern void mantis_pcmcia_exit(struct mantis_ca *ca);
+extern int mantis_evmgr_init(struct mantis_ca *ca);
+extern void mantis_evmgr_exit(struct mantis_ca *ca);
+
+/* HIF */
+extern int mantis_hif_init(struct mantis_ca *ca);
+extern void mantis_hif_exit(struct mantis_ca *ca);
+extern int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr);
+extern int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data);
+extern int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr);
+extern int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u8 data);
+
+#endif /* __MANTIS_LINK_H */
diff --git a/drivers/media/dvb/mantis/mantis_pci.c b/drivers/media/dvb/mantis/mantis_pci.c
new file mode 100644 (file)
index 0000000..6c7534a
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <asm/io.h>
+#include <asm/pgtable.h>
+#include <asm/page.h>
+#include <linux/kmod.h>
+#include <linux/vmalloc.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/pci.h>
+
+#include <asm/irq.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include <asm/irq.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+
+#include "mantis_common.h"
+#include "mantis_reg.h"
+#include "mantis_pci.h"
+
+#define DRIVER_NAME            "Mantis Core"
+
+int __devinit mantis_pci_init(struct mantis_pci *mantis)
+{
+       u8 revision, latency;
+       struct mantis_hwconfig *config  = mantis->hwconfig;
+       struct pci_dev *pdev            = mantis->pdev;
+       int err, ret = 0;
+
+       dprintk(MANTIS_ERROR, 0, "found a %s PCI %s device on (%02x:%02x.%x),\n",
+               config->model_name,
+               config->dev_type,
+               mantis->pdev->bus->number,
+               PCI_SLOT(mantis->pdev->devfn),
+               PCI_FUNC(mantis->pdev->devfn));
+
+       err = pci_enable_device(pdev);
+       if (err != 0) {
+               ret = -ENODEV;
+               dprintk(MANTIS_ERROR, 1, "ERROR: PCI enable failed <%i>", err);
+               goto fail0;
+       }
+
+       err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+       if (err != 0) {
+               dprintk(MANTIS_ERROR, 1, "ERROR: Unable to obtain 32 bit DMA <%i>", err);
+               ret = -ENOMEM;
+               goto fail1;
+       }
+
+       pci_set_master(pdev);
+
+       if (!request_mem_region(pci_resource_start(pdev, 0),
+                               pci_resource_len(pdev, 0),
+                               DRIVER_NAME)) {
+
+               dprintk(MANTIS_ERROR, 1, "ERROR: BAR0 Request failed !");
+               ret = -ENODEV;
+               goto fail1;
+       }
+
+       mantis->mmio = ioremap(pci_resource_start(pdev, 0),
+                              pci_resource_len(pdev, 0));
+
+       if (!mantis->mmio) {
+               dprintk(MANTIS_ERROR, 1, "ERROR: BAR0 remap failed !");
+               ret = -ENODEV;
+               goto fail2;
+       }
+
+       pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
+       pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision);
+       mantis->latency = latency;
+       mantis->revision = revision;
+
+       dprintk(MANTIS_ERROR, 0, "    Mantis Rev %d [%04x:%04x], ",
+               mantis->revision,
+               mantis->pdev->subsystem_vendor,
+               mantis->pdev->subsystem_device);
+
+       dprintk(MANTIS_ERROR, 0,
+               "irq: %d, latency: %d\n    memory: 0x%lx, mmio: 0x%p\n",
+               mantis->pdev->irq,
+               mantis->latency,
+               mantis->mantis_addr,
+               mantis->mmio);
+
+       err = request_irq(pdev->irq,
+                         config->irq_handler,
+                         IRQF_SHARED,
+                         DRIVER_NAME,
+                         mantis);
+
+       if (err != 0) {
+
+               dprintk(MANTIS_ERROR, 1, "ERROR: IRQ registration failed ! <%d>", err);
+               ret = -ENODEV;
+               goto fail3;
+       }
+
+       pci_set_drvdata(pdev, mantis);
+       return ret;
+
+       /* Error conditions */
+fail3:
+       dprintk(MANTIS_ERROR, 1, "ERROR: <%d> I/O unmap", ret);
+       if (mantis->mmio)
+               iounmap(mantis->mmio);
+
+fail2:
+       dprintk(MANTIS_ERROR, 1, "ERROR: <%d> releasing regions", ret);
+       release_mem_region(pci_resource_start(pdev, 0),
+                          pci_resource_len(pdev, 0));
+
+fail1:
+       dprintk(MANTIS_ERROR, 1, "ERROR: <%d> disabling device", ret);
+       pci_disable_device(pdev);
+
+fail0:
+       dprintk(MANTIS_ERROR, 1, "ERROR: <%d> exiting", ret);
+       pci_set_drvdata(pdev, NULL);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(mantis_pci_init);
+
+void mantis_pci_exit(struct mantis_pci *mantis)
+{
+       struct pci_dev *pdev = mantis->pdev;
+
+       dprintk(MANTIS_NOTICE, 1, " mem: 0x%p", mantis->mmio);
+       free_irq(pdev->irq, mantis);
+       if (mantis->mmio) {
+               iounmap(mantis->mmio);
+               release_mem_region(pci_resource_start(pdev, 0),
+                                  pci_resource_len(pdev, 0));
+       }
+
+       pci_disable_device(pdev);
+       pci_set_drvdata(pdev, NULL);
+}
+EXPORT_SYMBOL_GPL(mantis_pci_exit);
+
+MODULE_DESCRIPTION("Mantis PCI DTV bridge driver");
+MODULE_AUTHOR("Manu Abraham");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/mantis/mantis_pci.h b/drivers/media/dvb/mantis/mantis_pci.h
new file mode 100644 (file)
index 0000000..65f0045
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_PCI_H
+#define __MANTIS_PCI_H
+
+extern int mantis_pci_init(struct mantis_pci *mantis);
+extern void mantis_pci_exit(struct mantis_pci *mantis);
+
+#endif /* __MANTIS_PCI_H */
diff --git a/drivers/media/dvb/mantis/mantis_pcmcia.c b/drivers/media/dvb/mantis/mantis_pcmcia.c
new file mode 100644 (file)
index 0000000..5cb545b
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "mantis_common.h"
+#include "mantis_link.h" /* temporary due to physical layer stuff */
+#include "mantis_reg.h"
+
+/*
+ * If Slot state is already PLUG_IN event and we are called
+ * again, definitely it is jitter alone
+ */
+void mantis_event_cam_plugin(struct mantis_ca *ca)
+{
+       struct mantis_pci *mantis = ca->ca_priv;
+
+       u32 gpif_irqcfg;
+
+       if (ca->slot_state == MODULE_XTRACTED) {
+               dprintk(MANTIS_DEBUG, 1, "Event: CAM Plugged IN: Adapter(%d) Slot(0)", mantis->num);
+               udelay(50);
+               mmwrite(0xda000000, MANTIS_CARD_RESET);
+               gpif_irqcfg  = mmread(MANTIS_GPIF_IRQCFG);
+               gpif_irqcfg |= MANTIS_MASK_PLUGOUT;
+               gpif_irqcfg &= ~MANTIS_MASK_PLUGIN;
+               mmwrite(gpif_irqcfg, MANTIS_GPIF_IRQCFG);
+               udelay(500);
+               ca->slot_state = MODULE_INSERTED;
+       }
+       udelay(100);
+}
+
+/*
+ * If Slot state is already UN_PLUG event and we are called
+ * again, definitely it is jitter alone
+ */
+void mantis_event_cam_unplug(struct mantis_ca *ca)
+{
+       struct mantis_pci *mantis = ca->ca_priv;
+
+       u32 gpif_irqcfg;
+
+       if (ca->slot_state == MODULE_INSERTED) {
+               dprintk(MANTIS_DEBUG, 1, "Event: CAM Unplugged: Adapter(%d) Slot(0)", mantis->num);
+               udelay(50);
+               mmwrite(0x00da0000, MANTIS_CARD_RESET);
+               gpif_irqcfg  = mmread(MANTIS_GPIF_IRQCFG);
+               gpif_irqcfg |= MANTIS_MASK_PLUGIN;
+               gpif_irqcfg &= ~MANTIS_MASK_PLUGOUT;
+               mmwrite(gpif_irqcfg, MANTIS_GPIF_IRQCFG);
+               udelay(500);
+               ca->slot_state = MODULE_XTRACTED;
+       }
+       udelay(100);
+}
+
+int mantis_pcmcia_init(struct mantis_ca *ca)
+{
+       struct mantis_pci *mantis = ca->ca_priv;
+
+       u32 gpif_stat, card_stat;
+
+       mmwrite(mmread(MANTIS_INT_MASK) | MANTIS_INT_IRQ0, MANTIS_INT_MASK);
+       gpif_stat = mmread(MANTIS_GPIF_STATUS);
+       card_stat = mmread(MANTIS_GPIF_IRQCFG);
+
+       if (gpif_stat & MANTIS_GPIF_DETSTAT) {
+               dprintk(MANTIS_DEBUG, 1, "CAM found on Adapter(%d) Slot(0)", mantis->num);
+               mmwrite(card_stat | MANTIS_MASK_PLUGOUT, MANTIS_GPIF_IRQCFG);
+               ca->slot_state = MODULE_INSERTED;
+               dvb_ca_en50221_camchange_irq(&ca->en50221,
+                                            0,
+                                            DVB_CA_EN50221_CAMCHANGE_INSERTED);
+       } else {
+               dprintk(MANTIS_DEBUG, 1, "Empty Slot on Adapter(%d) Slot(0)", mantis->num);
+               mmwrite(card_stat | MANTIS_MASK_PLUGIN, MANTIS_GPIF_IRQCFG);
+               ca->slot_state = MODULE_XTRACTED;
+               dvb_ca_en50221_camchange_irq(&ca->en50221,
+                                            0,
+                                            DVB_CA_EN50221_CAMCHANGE_REMOVED);
+       }
+
+       return 0;
+}
+
+void mantis_pcmcia_exit(struct mantis_ca *ca)
+{
+       struct mantis_pci *mantis = ca->ca_priv;
+
+       mmwrite(mmread(MANTIS_GPIF_STATUS) & (~MANTIS_CARD_PLUGOUT | ~MANTIS_CARD_PLUGIN), MANTIS_GPIF_STATUS);
+       mmwrite(mmread(MANTIS_INT_MASK) & ~MANTIS_INT_IRQ0, MANTIS_INT_MASK);
+}
diff --git a/drivers/media/dvb/mantis/mantis_reg.h b/drivers/media/dvb/mantis/mantis_reg.h
new file mode 100644 (file)
index 0000000..7761f9d
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_REG_H
+#define __MANTIS_REG_H
+
+/* Interrupts */
+#define MANTIS_INT_STAT                        0x00
+#define MANTIS_INT_MASK                        0x04
+
+#define MANTIS_INT_RISCSTAT            (0x0f << 28)
+#define MANTIS_INT_RISCEN              (0x01 << 27)
+#define MANTIS_INT_I2CRACK             (0x01 << 26)
+
+/* #define MANTIS_INT_GPIF                     (0xff << 12) */
+
+#define MANTIS_INT_PCMCIA7             (0x01 << 19)
+#define MANTIS_INT_PCMCIA6             (0x01 << 18)
+#define MANTIS_INT_PCMCIA5             (0x01 << 17)
+#define MANTIS_INT_PCMCIA4             (0x01 << 16)
+#define MANTIS_INT_PCMCIA3             (0x01 << 15)
+#define MANTIS_INT_PCMCIA2             (0x01 << 14)
+#define MANTIS_INT_PCMCIA1             (0x01 << 13)
+#define MANTIS_INT_PCMCIA0             (0x01 << 12)
+#define MANTIS_INT_IRQ1                        (0x01 << 11)
+#define MANTIS_INT_IRQ0                        (0x01 << 10)
+#define MANTIS_INT_OCERR               (0x01 <<  8)
+#define MANTIS_INT_PABORT              (0x01 <<  7)
+#define MANTIS_INT_RIPERR              (0x01 <<  6)
+#define MANTIS_INT_PPERR               (0x01 <<  5)
+#define MANTIS_INT_FTRGT               (0x01 <<  3)
+#define MANTIS_INT_RISCI               (0x01 <<  1)
+#define MANTIS_INT_I2CDONE             (0x01 <<  0)
+
+/* DMA */
+#define MANTIS_DMA_CTL                 0x08
+#define MANTIS_GPIF_RD                 (0xff << 24)
+#define MANTIS_GPIF_WR                 (0xff << 16)
+#define MANTIS_CPU_DO                  (0x01 << 10)
+#define MANTIS_DRV_DO                  (0x01 <<  9)
+#define        MANTIS_I2C_RD                   (0x01 <<  7)
+#define MANTIS_I2C_WR                  (0x01 <<  6)
+#define MANTIS_DCAP_MODE               (0x01 <<  5)
+#define MANTIS_FIFO_TP_4               (0x00 <<  3)
+#define MANTIS_FIFO_TP_8               (0x01 <<  3)
+#define MANTIS_FIFO_TP_16              (0x02 <<  3)
+#define MANTIS_FIFO_EN                 (0x01 <<  2)
+#define MANTIS_DCAP_EN                 (0x01 <<  1)
+#define MANTIS_RISC_EN                 (0x01 <<  0)
+
+/* DEBUG */
+#define MANTIS_DEBUGREG                        0x0c
+#define MANTIS_DATINV                  (0x0e <<  7)
+#define MANTIS_TOP_DEBUGSEL            (0x07 <<  4)
+#define MANTIS_PCMCIA_DEBUGSEL         (0x0f <<  0)
+
+#define MANTIS_RISC_START              0x10
+#define MANTIS_RISC_PC                 0x14
+
+/* I2C */
+#define MANTIS_I2CDATA_CTL             0x18
+#define MANTIS_I2C_RATE_1              (0x00 <<  6)
+#define MANTIS_I2C_RATE_2              (0x01 <<  6)
+#define MANTIS_I2C_RATE_3              (0x02 <<  6)
+#define MANTIS_I2C_RATE_4              (0x03 <<  6)
+#define MANTIS_I2C_STOP                        (0x01 <<  5)
+#define MANTIS_I2C_PGMODE              (0x01 <<  3)
+
+/* DATA */
+#define MANTIS_CMD_DATA_R1             0x20
+#define MANTIS_CMD_DATA_3              (0xff << 24)
+#define MANTIS_CMD_DATA_2              (0xff << 16)
+#define MANTIS_CMD_DATA_1              (0xff <<  8)
+#define MANTIS_CMD_DATA_0              (0xff <<  0)
+
+#define MANTIS_CMD_DATA_R2             0x24
+#define MANTIS_CMD_DATA_7              (0xff << 24)
+#define MANTIS_CMD_DATA_6              (0xff << 16)
+#define MANTIS_CMD_DATA_5              (0xff <<  8)
+#define MANTIS_CMD_DATA_4              (0xff <<  0)
+
+#define MANTIS_CONTROL                 0x28
+#define MANTIS_DET                     (0x01 <<  7)
+#define MANTIS_DAT_CF_EN               (0x01 <<  6)
+#define MANTIS_ACS                     (0x03 <<  4)
+#define MANTIS_VCCEN                   (0x01 <<  3)
+#define MANTIS_BYPASS                  (0x01 <<  2)
+#define MANTIS_MRST                    (0x01 <<  1)
+#define MANTIS_CRST_INT                        (0x01 <<  0)
+
+#define MANTIS_GPIF_CFGSLA             0x84
+#define MANTIS_GPIF_WAITSMPL           (0x07 << 28)
+#define MANTIS_GPIF_BYTEADDRSUB                (0x01 << 25)
+#define MANTIS_GPIF_WAITPOL            (0x01 << 24)
+#define MANTIS_GPIF_NCDELAY            (0x07 << 20)
+#define MANTIS_GPIF_RW2CSDELAY         (0x07 << 16)
+#define MANTIS_GPIF_SLFTIMEDMODE       (0x01 << 15)
+#define MANTIS_GPIF_SLFTIMEDDELY       (0x7f <<  8)
+#define MANTIS_GPIF_DEVTYPE            (0x07 <<  4)
+#define MANTIS_GPIF_BIGENDIAN          (0x01 <<  3)
+#define MANTIS_GPIF_FETCHCMD           (0x03 <<  1)
+#define MANTIS_GPIF_HWORDDEV           (0x01 <<  0)
+
+#define MANTIS_GPIF_WSTOPER            0x90
+#define MANTIS_GPIF_WSTOPERWREN3       (0x01 << 31)
+#define MANTIS_GPIF_PARBOOTN           (0x01 << 29)
+#define MANTIS_GPIF_WSTOPERSLID3       (0x1f << 24)
+#define MANTIS_GPIF_WSTOPERWREN2       (0x01 << 23)
+#define MANTIS_GPIF_WSTOPERSLID2       (0x1f << 16)
+#define MANTIS_GPIF_WSTOPERWREN1       (0x01 << 15)
+#define MANTIS_GPIF_WSTOPERSLID1       (0x1f <<  8)
+#define MANTIS_GPIF_WSTOPERWREN0       (0x01 <<  7)
+#define MANTIS_GPIF_WSTOPERSLID0       (0x1f <<  0)
+
+#define MANTIS_GPIF_CS2RW              0x94
+#define MANTIS_GPIF_CS2RWWREN3         (0x01 << 31)
+#define MANTIS_GPIF_CS2RWDELY3         (0x3f << 24)
+#define MANTIS_GPIF_CS2RWWREN2         (0x01 << 23)
+#define MANTIS_GPIF_CS2RWDELY2         (0x3f << 16)
+#define MANTIS_GPIF_CS2RWWREN1         (0x01 << 15)
+#define MANTIS_GPIF_CS2RWDELY1         (0x3f <<  8)
+#define MANTIS_GPIF_CS2RWWREN0         (0x01 <<  7)
+#define MANTIS_GPIF_CS2RWDELY0         (0x3f <<  0)
+
+#define MANTIS_GPIF_IRQCFG             0x98
+#define MANTIS_GPIF_IRQPOL             (0x01 <<  8)
+#define MANTIS_MASK_WRACK              (0x01 <<  7)
+#define MANTIS_MASK_BRRDY              (0x01 <<  6)
+#define MANTIS_MASK_OVFLW              (0x01 <<  5)
+#define MANTIS_MASK_OTHERR             (0x01 <<  4)
+#define MANTIS_MASK_WSTO               (0x01 <<  3)
+#define MANTIS_MASK_EXTIRQ             (0x01 <<  2)
+#define MANTIS_MASK_PLUGIN             (0x01 <<  1)
+#define MANTIS_MASK_PLUGOUT            (0x01 <<  0)
+
+#define MANTIS_GPIF_STATUS             0x9c
+#define MANTIS_SBUF_KILLOP             (0x01 << 15)
+#define MANTIS_SBUF_OPDONE             (0x01 << 14)
+#define MANTIS_SBUF_EMPTY              (0x01 << 13)
+#define MANTIS_GPIF_DETSTAT            (0x01 <<  9)
+#define MANTIS_GPIF_INTSTAT            (0x01 <<  8)
+#define MANTIS_GPIF_WRACK              (0x01 <<  7)
+#define MANTIS_GPIF_BRRDY              (0x01 <<  6)
+#define MANTIS_SBUF_OVFLW              (0x01 <<  5)
+#define MANTIS_GPIF_OTHERR             (0x01 <<  4)
+#define MANTIS_SBUF_WSTO               (0x01 <<  3)
+#define MANTIS_GPIF_EXTIRQ             (0x01 <<  2)
+#define MANTIS_CARD_PLUGIN             (0x01 <<  1)
+#define MANTIS_CARD_PLUGOUT            (0x01 <<  0)
+
+#define MANTIS_GPIF_BRADDR             0xa0
+#define MANTIS_GPIF_PCMCIAREG          (0x01           << 27)
+#define MANTIS_GPIF_PCMCIAIOM          (0x01           << 26)
+#define MANTIS_GPIF_BR_ADDR            (0xfffffff      <<  0)
+
+#define MANTIS_GPIF_BRBYTES            0xa4
+#define MANTIS_GPIF_BRCNT              (0xfff          <<  0)
+
+#define MANTIS_PCMCIA_RESET            0xa8
+#define MANTIS_PCMCIA_RSTVAL           (0xff << 0)
+
+#define MANTIS_CARD_RESET              0xac
+
+#define MANTIS_GPIF_ADDR               0xb0
+#define MANTIS_GPIF_HIFRDWRN           (0x01           << 31)
+#define MANTIS_GPIF_PCMCIAREG          (0x01           << 27)
+#define MANTIS_GPIF_PCMCIAIOM          (0x01           << 26)
+#define MANTIS_GPIF_HIFADDR            (0xfffffff      <<  0)
+
+#define MANTIS_GPIF_DOUT               0xb4
+#define MANTIS_GPIF_HIFDOUT            (0xfffffff      <<  0)
+
+#define MANTIS_GPIF_DIN                        0xb8
+#define MANTIS_GPIF_HIFDIN             (0xfffffff      <<  0)
+
+#define MANTIS_GPIF_SPARE              0xbc
+#define MANTIS_GPIF_LOGICRD            (0xffff         << 16)
+#define MANTIS_GPIF_LOGICRW            (0xffff         <<  0)
+
+#endif /* __MANTIS_REG_H */
diff --git a/drivers/media/dvb/mantis/mantis_uart.c b/drivers/media/dvb/mantis/mantis_uart.c
new file mode 100644 (file)
index 0000000..7d2f239
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/spinlock.h>
+
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "mantis_common.h"
+#include "mantis_reg.h"
+#include "mantis_uart.h"
+
+struct mantis_uart_params {
+       enum mantis_baud        baud_rate;
+       enum mantis_parity      parity;
+};
+
+static struct {
+       char string[7];
+} rates[5] = {
+       { "9600" },
+       { "19200" },
+       { "38400" },
+       { "57600" },
+       { "115200" }
+};
+
+static struct {
+       char string[5];
+} parity[3] = {
+       { "NONE" },
+       { "ODD" },
+       { "EVEN" }
+};
+
+#define UART_MAX_BUF                   16
+
+int mantis_uart_read(struct mantis_pci *mantis, u8 *data)
+{
+       struct mantis_hwconfig *config = mantis->hwconfig;
+       u32 stat = 0, i;
+
+       /* get data */
+       for (i = 0; i < (config->bytes + 1); i++) {
+
+               stat = mmread(MANTIS_UART_STAT);
+
+               if (stat & MANTIS_UART_RXFIFO_FULL) {
+                       dprintk(MANTIS_ERROR, 1, "RX Fifo FULL");
+               }
+               data[i] = mmread(MANTIS_UART_RXD) & 0x3f;
+
+               dprintk(MANTIS_DEBUG, 1, "Reading ... <%02x>", data[i] & 0x3f);
+
+               if (data[i] & (1 << 7)) {
+                       dprintk(MANTIS_ERROR, 1, "UART framing error");
+                       return -EINVAL;
+               }
+               if (data[i] & (1 << 6)) {
+                       dprintk(MANTIS_ERROR, 1, "UART parity error");
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
+static void mantis_uart_work(struct work_struct *work)
+{
+       struct mantis_pci *mantis = container_of(work, struct mantis_pci, uart_work);
+       struct mantis_hwconfig *config = mantis->hwconfig;
+       u8 buf[16];
+       int i;
+
+       mantis_uart_read(mantis, buf);
+
+       for (i = 0; i < (config->bytes + 1); i++)
+               dprintk(MANTIS_INFO, 1, "UART BUF:%d <%02x> ", i, buf[i]);
+
+       dprintk(MANTIS_DEBUG, 0, "\n");
+}
+
+static int mantis_uart_setup(struct mantis_pci *mantis,
+                            struct mantis_uart_params *params)
+{
+       u32 reg;
+
+       mmwrite((mmread(MANTIS_UART_CTL) | (params->parity & 0x3)), MANTIS_UART_CTL);
+
+       reg = mmread(MANTIS_UART_BAUD);
+
+       switch (params->baud_rate) {
+       case MANTIS_BAUD_9600:
+               reg |= 0xd8;
+               break;
+       case MANTIS_BAUD_19200:
+               reg |= 0x6c;
+               break;
+       case MANTIS_BAUD_38400:
+               reg |= 0x36;
+               break;
+       case MANTIS_BAUD_57600:
+               reg |= 0x23;
+               break;
+       case MANTIS_BAUD_115200:
+               reg |= 0x11;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       mmwrite(reg, MANTIS_UART_BAUD);
+
+       return 0;
+}
+
+int mantis_uart_init(struct mantis_pci *mantis)
+{
+       struct mantis_hwconfig *config = mantis->hwconfig;
+       struct mantis_uart_params params;
+
+       /* default parity: */
+       params.baud_rate = config->baud_rate;
+       params.parity = config->parity;
+       dprintk(MANTIS_INFO, 1, "Initializing UART @ %sbps parity:%s",
+               rates[params.baud_rate].string,
+               parity[params.parity].string);
+
+       init_waitqueue_head(&mantis->uart_wq);
+       spin_lock_init(&mantis->uart_lock);
+
+       INIT_WORK(&mantis->uart_work, mantis_uart_work);
+
+       /* disable interrupt */
+       mmwrite(mmread(MANTIS_UART_CTL) & 0xffef, MANTIS_UART_CTL);
+
+       mantis_uart_setup(mantis, &params);
+
+       /* default 1 byte */
+       mmwrite((mmread(MANTIS_UART_BAUD) | (config->bytes << 8)), MANTIS_UART_BAUD);
+
+       /* flush buffer */
+       mmwrite((mmread(MANTIS_UART_CTL) | MANTIS_UART_RXFLUSH), MANTIS_UART_CTL);
+
+       /* enable interrupt */
+       mmwrite(mmread(MANTIS_INT_MASK) | 0x800, MANTIS_INT_MASK);
+       mmwrite(mmread(MANTIS_UART_CTL) | MANTIS_UART_RXINT, MANTIS_UART_CTL);
+
+       schedule_work(&mantis->uart_work);
+       dprintk(MANTIS_DEBUG, 1, "UART succesfully initialized");
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(mantis_uart_init);
+
+void mantis_uart_exit(struct mantis_pci *mantis)
+{
+       /* disable interrupt */
+       mmwrite(mmread(MANTIS_UART_CTL) & 0xffef, MANTIS_UART_CTL);
+}
+EXPORT_SYMBOL_GPL(mantis_uart_exit);
diff --git a/drivers/media/dvb/mantis/mantis_uart.h b/drivers/media/dvb/mantis/mantis_uart.h
new file mode 100644 (file)
index 0000000..ffb62a0
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+       Mantis PCI bridge driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_UART_H
+#define __MANTIS_UART_H
+
+#define MANTIS_UART_CTL                        0xe0
+#define MANTIS_UART_RXINT              (1 << 4)
+#define MANTIS_UART_RXFLUSH            (1 << 2)
+
+#define MANTIS_UART_RXD                        0xe8
+#define MANTIS_UART_BAUD               0xec
+
+#define MANTIS_UART_STAT               0xf0
+#define MANTIS_UART_RXFIFO_DATA                (1 << 7)
+#define MANTIS_UART_RXFIFO_EMPTY       (1 << 6)
+#define MANTIS_UART_RXFIFO_FULL                (1 << 3)
+#define MANTIS_UART_FRAME_ERR          (1 << 2)
+#define MANTIS_UART_PARITY_ERR         (1 << 1)
+#define MANTIS_UART_RXTHRESH_INT       (1 << 0)
+
+enum mantis_baud {
+       MANTIS_BAUD_9600        = 0,
+       MANTIS_BAUD_19200,
+       MANTIS_BAUD_38400,
+       MANTIS_BAUD_57600,
+       MANTIS_BAUD_115200
+};
+
+enum mantis_parity {
+       MANTIS_PARITY_NONE      = 0,
+       MANTIS_PARITY_EVEN,
+       MANTIS_PARITY_ODD,
+};
+
+struct mantis_pci;
+
+extern int mantis_uart_init(struct mantis_pci *mantis);
+extern void mantis_uart_exit(struct mantis_pci *mantis);
+
+#endif /* __MANTIS_UART_H */
diff --git a/drivers/media/dvb/mantis/mantis_vp1033.c b/drivers/media/dvb/mantis/mantis_vp1033.c
new file mode 100644 (file)
index 0000000..4a723bd
--- /dev/null
@@ -0,0 +1,212 @@
+/*
+       Mantis VP-1033 driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "stv0299.h"
+#include "mantis_common.h"
+#include "mantis_ioc.h"
+#include "mantis_dvb.h"
+#include "mantis_vp1033.h"
+#include "mantis_reg.h"
+
+u8 lgtdqcs001f_inittab[] = {
+       0x01, 0x15,
+       0x02, 0x00,
+       0x03, 0x00,
+       0x04, 0x2a,
+       0x05, 0x85,
+       0x06, 0x02,
+       0x07, 0x00,
+       0x08, 0x00,
+       0x0c, 0x01,
+       0x0d, 0x81,
+       0x0e, 0x44,
+       0x0f, 0x94,
+       0x10, 0x3c,
+       0x11, 0x84,
+       0x12, 0xb9,
+       0x13, 0xb5,
+       0x14, 0x4f,
+       0x15, 0xc9,
+       0x16, 0x80,
+       0x17, 0x36,
+       0x18, 0xfb,
+       0x19, 0xcf,
+       0x1a, 0xbc,
+       0x1c, 0x2b,
+       0x1d, 0x27,
+       0x1e, 0x00,
+       0x1f, 0x0b,
+       0x20, 0xa1,
+       0x21, 0x60,
+       0x22, 0x00,
+       0x23, 0x00,
+       0x28, 0x00,
+       0x29, 0x28,
+       0x2a, 0x14,
+       0x2b, 0x0f,
+       0x2c, 0x09,
+       0x2d, 0x05,
+       0x31, 0x1f,
+       0x32, 0x19,
+       0x33, 0xfc,
+       0x34, 0x13,
+       0xff, 0xff,
+};
+
+#define MANTIS_MODEL_NAME      "VP-1033"
+#define MANTIS_DEV_TYPE                "DVB-S/DSS"
+
+int lgtdqcs001f_tuner_set(struct dvb_frontend *fe,
+                         struct dvb_frontend_parameters *params)
+{
+       struct mantis_pci *mantis       = fe->dvb->priv;
+       struct i2c_adapter *adapter     = &mantis->adapter;
+
+       u8 buf[4];
+       u32 div;
+
+
+       struct i2c_msg msg = {.addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf)};
+
+       div = params->frequency / 250;
+
+       buf[0] = (div >> 8) & 0x7f;
+       buf[1] =  div & 0xff;
+       buf[2] =  0x83;
+       buf[3] =  0xc0;
+
+       if (params->frequency < 1531000)
+               buf[3] |= 0x04;
+       else
+               buf[3] &= ~0x04;
+       if (i2c_transfer(adapter, &msg, 1) < 0) {
+               dprintk(MANTIS_ERROR, 1, "Write: I2C Transfer failed");
+               return -EIO;
+       }
+       msleep_interruptible(100);
+
+       return 0;
+}
+
+int lgtdqcs001f_set_symbol_rate(struct dvb_frontend *fe,
+                               u32 srate, u32 ratio)
+{
+       u8 aclk = 0;
+       u8 bclk = 0;
+
+       if (srate < 1500000) {
+               aclk = 0xb7;
+               bclk = 0x47;
+       } else if (srate < 3000000) {
+               aclk = 0xb7;
+               bclk = 0x4b;
+       } else if (srate < 7000000) {
+               aclk = 0xb7;
+               bclk = 0x4f;
+       } else if (srate < 14000000) {
+               aclk = 0xb7;
+               bclk = 0x53;
+       } else if (srate < 30000000) {
+               aclk = 0xb6;
+               bclk = 0x53;
+       } else if (srate < 45000000) {
+               aclk = 0xb4;
+               bclk = 0x51;
+       }
+       stv0299_writereg(fe, 0x13, aclk);
+       stv0299_writereg(fe, 0x14, bclk);
+
+       stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
+       stv0299_writereg(fe, 0x20, (ratio >>  8) & 0xff);
+       stv0299_writereg(fe, 0x21,  ratio & 0xf0);
+
+       return 0;
+}
+
+struct stv0299_config lgtdqcs001f_config = {
+       .demod_address          = 0x68,
+       .inittab                = lgtdqcs001f_inittab,
+       .mclk                   = 88000000UL,
+       .invert                 = 0,
+       .skip_reinit            = 0,
+       .volt13_op0_op1         = STV0299_VOLT13_OP0,
+       .min_delay_ms           = 100,
+       .set_symbol_rate        = lgtdqcs001f_set_symbol_rate,
+};
+
+static int vp1033_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
+{
+       struct i2c_adapter *adapter     = &mantis->adapter;
+
+       int err = 0;
+
+       err = mantis_frontend_power(mantis, POWER_ON);
+       if (err == 0) {
+               mantis_frontend_soft_reset(mantis);
+               msleep(250);
+
+               dprintk(MANTIS_ERROR, 1, "Probing for STV0299 (DVB-S)");
+               fe = stv0299_attach(&lgtdqcs001f_config, adapter);
+
+               if (fe) {
+                       fe->ops.tuner_ops.set_params = lgtdqcs001f_tuner_set;
+                       dprintk(MANTIS_ERROR, 1, "found STV0299 DVB-S frontend @ 0x%02x",
+                               lgtdqcs001f_config.demod_address);
+
+                       dprintk(MANTIS_ERROR, 1, "Mantis DVB-S STV0299 frontend attach success");
+               } else {
+                       return -1;
+               }
+       } else {
+               dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
+                       adapter->name,
+                       err);
+
+               return -EIO;
+       }
+       mantis->fe = fe;
+       dprintk(MANTIS_ERROR, 1, "Done!");
+
+       return 0;
+}
+
+struct mantis_hwconfig vp1033_config = {
+       .model_name             = MANTIS_MODEL_NAME,
+       .dev_type               = MANTIS_DEV_TYPE,
+       .ts_size                = MANTIS_TS_204,
+
+       .baud_rate              = MANTIS_BAUD_9600,
+       .parity                 = MANTIS_PARITY_NONE,
+       .bytes                  = 0,
+
+       .frontend_init          = vp1033_frontend_init,
+       .power                  = GPIF_A12,
+       .reset                  = GPIF_A13,
+};
diff --git a/drivers/media/dvb/mantis/mantis_vp1033.h b/drivers/media/dvb/mantis/mantis_vp1033.h
new file mode 100644 (file)
index 0000000..7daaa1b
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+       Mantis VP-1033 driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_VP1033_H
+#define __MANTIS_VP1033_H
+
+#include "mantis_common.h"
+
+#define MANTIS_VP_1033_DVB_S   0x0016
+
+extern struct mantis_hwconfig vp1033_config;
+
+#endif /* __MANTIS_VP1033_H */
diff --git a/drivers/media/dvb/mantis/mantis_vp1034.c b/drivers/media/dvb/mantis/mantis_vp1034.c
new file mode 100644 (file)
index 0000000..8e6ae55
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+       Mantis VP-1034 driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "mb86a16.h"
+#include "mantis_common.h"
+#include "mantis_ioc.h"
+#include "mantis_dvb.h"
+#include "mantis_vp1034.h"
+#include "mantis_reg.h"
+
+struct mb86a16_config vp1034_mb86a16_config = {
+       .demod_address  = 0x08,
+       .set_voltage    = vp1034_set_voltage,
+};
+
+#define MANTIS_MODEL_NAME      "VP-1034"
+#define MANTIS_DEV_TYPE                "DVB-S/DSS"
+
+int vp1034_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
+{
+       struct mantis_pci *mantis = fe->dvb->priv;
+
+       switch (voltage) {
+       case SEC_VOLTAGE_13:
+               dprintk(MANTIS_ERROR, 1, "Polarization=[13V]");
+               gpio_set_bits(mantis, 13, 1);
+               gpio_set_bits(mantis, 14, 0);
+               break;
+       case SEC_VOLTAGE_18:
+               dprintk(MANTIS_ERROR, 1, "Polarization=[18V]");
+               gpio_set_bits(mantis, 13, 1);
+               gpio_set_bits(mantis, 14, 1);
+               break;
+       case SEC_VOLTAGE_OFF:
+               dprintk(MANTIS_ERROR, 1, "Frontend (dummy) POWERDOWN");
+               break;
+       default:
+               dprintk(MANTIS_ERROR, 1, "Invalid = (%d)", (u32) voltage);
+               return -EINVAL;
+       }
+       mmwrite(0x00, MANTIS_GPIF_DOUT);
+
+       return 0;
+}
+
+static int vp1034_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
+{
+       struct i2c_adapter *adapter     = &mantis->adapter;
+
+       int err = 0;
+
+       err = mantis_frontend_power(mantis, POWER_ON);
+       if (err == 0) {
+               mantis_frontend_soft_reset(mantis);
+               msleep(250);
+
+               dprintk(MANTIS_ERROR, 1, "Probing for MB86A16 (DVB-S/DSS)");
+               fe = mb86a16_attach(&vp1034_mb86a16_config, adapter);
+               if (fe) {
+                       dprintk(MANTIS_ERROR, 1,
+                       "found MB86A16 DVB-S/DSS frontend @0x%02x",
+                       vp1034_mb86a16_config.demod_address);
+
+               } else {
+                       return -1;
+               }
+       } else {
+               dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
+                       adapter->name,
+                       err);
+
+               return -EIO;
+       }
+       mantis->fe = fe;
+       dprintk(MANTIS_ERROR, 1, "Done!");
+
+       return 0;
+}
+
+struct mantis_hwconfig vp1034_config = {
+       .model_name     = MANTIS_MODEL_NAME,
+       .dev_type       = MANTIS_DEV_TYPE,
+       .ts_size        = MANTIS_TS_204,
+
+       .baud_rate      = MANTIS_BAUD_9600,
+       .parity         = MANTIS_PARITY_NONE,
+       .bytes          = 0,
+
+       .frontend_init  = vp1034_frontend_init,
+       .power          = GPIF_A12,
+       .reset          = GPIF_A13,
+};
diff --git a/drivers/media/dvb/mantis/mantis_vp1034.h b/drivers/media/dvb/mantis/mantis_vp1034.h
new file mode 100644 (file)
index 0000000..323f38e
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+       Mantis VP-1034 driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_VP1034_H
+#define __MANTIS_VP1034_H
+
+#include "dvb_frontend.h"
+#include "mantis_common.h"
+
+
+#define MANTIS_VP_1034_DVB_S   0x0014
+
+extern struct mantis_hwconfig vp1034_config;
+extern int vp1034_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage);
+
+#endif /* __MANTIS_VP1034_H */
diff --git a/drivers/media/dvb/mantis/mantis_vp1041.c b/drivers/media/dvb/mantis/mantis_vp1041.c
new file mode 100644 (file)
index 0000000..515346d
--- /dev/null
@@ -0,0 +1,358 @@
+/*
+       Mantis VP-1041 driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "mantis_common.h"
+#include "mantis_ioc.h"
+#include "mantis_dvb.h"
+#include "mantis_vp1041.h"
+#include "stb0899_reg.h"
+#include "stb0899_drv.h"
+#include "stb0899_cfg.h"
+#include "stb6100_cfg.h"
+#include "stb6100.h"
+#include "lnbp21.h"
+
+#define MANTIS_MODEL_NAME      "VP-1041"
+#define MANTIS_DEV_TYPE                "DSS/DVB-S/DVB-S2"
+
+static const struct stb0899_s1_reg vp1041_stb0899_s1_init_1[] = {
+
+       /* 0x0000000b, *//* SYSREG */
+       { STB0899_DEV_ID                , 0x30 },
+       { STB0899_DISCNTRL1             , 0x32 },
+       { STB0899_DISCNTRL2             , 0x80 },
+       { STB0899_DISRX_ST0             , 0x04 },
+       { STB0899_DISRX_ST1             , 0x00 },
+       { STB0899_DISPARITY             , 0x00 },
+       { STB0899_DISFIFO               , 0x00 },
+       { STB0899_DISSTATUS             , 0x20 },
+       { STB0899_DISF22                , 0x99 },
+       { STB0899_DISF22RX              , 0xa8 },
+       /* SYSREG ? */
+       { STB0899_ACRPRESC              , 0x11 },
+       { STB0899_ACRDIV1               , 0x0a },
+       { STB0899_ACRDIV2               , 0x05 },
+       { STB0899_DACR1                 , 0x00 },
+       { STB0899_DACR2                 , 0x00 },
+       { STB0899_OUTCFG                , 0x00 },
+       { STB0899_MODECFG               , 0x00 },
+       { STB0899_IRQSTATUS_3           , 0xfe },
+       { STB0899_IRQSTATUS_2           , 0x03 },
+       { STB0899_IRQSTATUS_1           , 0x7c },
+       { STB0899_IRQSTATUS_0           , 0xf4 },
+       { STB0899_IRQMSK_3              , 0xf3 },
+       { STB0899_IRQMSK_2              , 0xfc },
+       { STB0899_IRQMSK_1              , 0xff },
+       { STB0899_IRQMSK_0              , 0xff },
+       { STB0899_IRQCFG                , 0x00 },
+       { STB0899_I2CCFG                , 0x88 },
+       { STB0899_I2CRPT                , 0x58 },
+       { STB0899_IOPVALUE5             , 0x00 },
+       { STB0899_IOPVALUE4             , 0x33 },
+       { STB0899_IOPVALUE3             , 0x6d },
+       { STB0899_IOPVALUE2             , 0x90 },
+       { STB0899_IOPVALUE1             , 0x60 },
+       { STB0899_IOPVALUE0             , 0x00 },
+       { STB0899_GPIO00CFG             , 0x82 },
+       { STB0899_GPIO01CFG             , 0x82 },
+       { STB0899_GPIO02CFG             , 0x82 },
+       { STB0899_GPIO03CFG             , 0x82 },
+       { STB0899_GPIO04CFG             , 0x82 },
+       { STB0899_GPIO05CFG             , 0x82 },
+       { STB0899_GPIO06CFG             , 0x82 },
+       { STB0899_GPIO07CFG             , 0x82 },
+       { STB0899_GPIO08CFG             , 0x82 },
+       { STB0899_GPIO09CFG             , 0x82 },
+       { STB0899_GPIO10CFG             , 0x82 },
+       { STB0899_GPIO11CFG             , 0x82 },
+       { STB0899_GPIO12CFG             , 0x82 },
+       { STB0899_GPIO13CFG             , 0x82 },
+       { STB0899_GPIO14CFG             , 0x82 },
+       { STB0899_GPIO15CFG             , 0x82 },
+       { STB0899_GPIO16CFG             , 0x82 },
+       { STB0899_GPIO17CFG             , 0x82 },
+       { STB0899_GPIO18CFG             , 0x82 },
+       { STB0899_GPIO19CFG             , 0x82 },
+       { STB0899_GPIO20CFG             , 0x82 },
+       { STB0899_SDATCFG               , 0xb8 },
+       { STB0899_SCLTCFG               , 0xba },
+       { STB0899_AGCRFCFG              , 0x1c }, /* 0x11 */
+       { STB0899_GPIO22                , 0x82 }, /* AGCBB2CFG */
+       { STB0899_GPIO21                , 0x91 }, /* AGCBB1CFG */
+       { STB0899_DIRCLKCFG             , 0x82 },
+       { STB0899_CLKOUT27CFG           , 0x7e },
+       { STB0899_STDBYCFG              , 0x82 },
+       { STB0899_CS0CFG                , 0x82 },
+       { STB0899_CS1CFG                , 0x82 },
+       { STB0899_DISEQCOCFG            , 0x20 },
+       { STB0899_GPIO32CFG             , 0x82 },
+       { STB0899_GPIO33CFG             , 0x82 },
+       { STB0899_GPIO34CFG             , 0x82 },
+       { STB0899_GPIO35CFG             , 0x82 },
+       { STB0899_GPIO36CFG             , 0x82 },
+       { STB0899_GPIO37CFG             , 0x82 },
+       { STB0899_GPIO38CFG             , 0x82 },
+       { STB0899_GPIO39CFG             , 0x82 },
+       { STB0899_NCOARSE               , 0x17 }, /* 0x15 = 27 Mhz Clock, F/3 = 198MHz, F/6 = 99MHz */
+       { STB0899_SYNTCTRL              , 0x02 }, /* 0x00 = CLK from CLKI, 0x02 = CLK from XTALI */
+       { STB0899_FILTCTRL              , 0x00 },
+       { STB0899_SYSCTRL               , 0x01 },
+       { STB0899_STOPCLK1              , 0x20 },
+       { STB0899_STOPCLK2              , 0x00 },
+       { STB0899_INTBUFSTATUS          , 0x00 },
+       { STB0899_INTBUFCTRL            , 0x0a },
+       { 0xffff                        , 0xff },
+};
+
+static const struct stb0899_s1_reg vp1041_stb0899_s1_init_3[] = {
+       { STB0899_DEMOD                 , 0x00 },
+       { STB0899_RCOMPC                , 0xc9 },
+       { STB0899_AGC1CN                , 0x01 },
+       { STB0899_AGC1REF               , 0x10 },
+       { STB0899_RTC                   , 0x23 },
+       { STB0899_TMGCFG                , 0x4e },
+       { STB0899_AGC2REF               , 0x34 },
+       { STB0899_TLSR                  , 0x84 },
+       { STB0899_CFD                   , 0xf7 },
+       { STB0899_ACLC                  , 0x87 },
+       { STB0899_BCLC                  , 0x94 },
+       { STB0899_EQON                  , 0x41 },
+       { STB0899_LDT                   , 0xf1 },
+       { STB0899_LDT2                  , 0xe3 },
+       { STB0899_EQUALREF              , 0xb4 },
+       { STB0899_TMGRAMP               , 0x10 },
+       { STB0899_TMGTHD                , 0x30 },
+       { STB0899_IDCCOMP               , 0xfd },
+       { STB0899_QDCCOMP               , 0xff },
+       { STB0899_POWERI                , 0x0c },
+       { STB0899_POWERQ                , 0x0f },
+       { STB0899_RCOMP                 , 0x6c },
+       { STB0899_AGCIQIN               , 0x80 },
+       { STB0899_AGC2I1                , 0x06 },
+       { STB0899_AGC2I2                , 0x00 },
+       { STB0899_TLIR                  , 0x30 },
+       { STB0899_RTF                   , 0x7f },
+       { STB0899_DSTATUS               , 0x00 },
+       { STB0899_LDI                   , 0xbc },
+       { STB0899_CFRM                  , 0xea },
+       { STB0899_CFRL                  , 0x31 },
+       { STB0899_NIRM                  , 0x2b },
+       { STB0899_NIRL                  , 0x80 },
+       { STB0899_ISYMB                 , 0x1d },
+       { STB0899_QSYMB                 , 0xa6 },
+       { STB0899_SFRH                  , 0x2f },
+       { STB0899_SFRM                  , 0x68 },
+       { STB0899_SFRL                  , 0x40 },
+       { STB0899_SFRUPH                , 0x2f },
+       { STB0899_SFRUPM                , 0x68 },
+       { STB0899_SFRUPL                , 0x40 },
+       { STB0899_EQUAI1                , 0x02 },
+       { STB0899_EQUAQ1                , 0xff },
+       { STB0899_EQUAI2                , 0x04 },
+       { STB0899_EQUAQ2                , 0x05 },
+       { STB0899_EQUAI3                , 0x02 },
+       { STB0899_EQUAQ3                , 0xfd },
+       { STB0899_EQUAI4                , 0x03 },
+       { STB0899_EQUAQ4                , 0x07 },
+       { STB0899_EQUAI5                , 0x08 },
+       { STB0899_EQUAQ5                , 0xf5 },
+       { STB0899_DSTATUS2              , 0x00 },
+       { STB0899_VSTATUS               , 0x00 },
+       { STB0899_VERROR                , 0x86 },
+       { STB0899_IQSWAP                , 0x2a },
+       { STB0899_ECNT1M                , 0x00 },
+       { STB0899_ECNT1L                , 0x00 },
+       { STB0899_ECNT2M                , 0x00 },
+       { STB0899_ECNT2L                , 0x00 },
+       { STB0899_ECNT3M                , 0x0a },
+       { STB0899_ECNT3L                , 0xad },
+       { STB0899_FECAUTO1              , 0x06 },
+       { STB0899_FECM                  , 0x01 },
+       { STB0899_VTH12                 , 0xb0 },
+       { STB0899_VTH23                 , 0x7a },
+       { STB0899_VTH34                 , 0x58 },
+       { STB0899_VTH56                 , 0x38 },
+       { STB0899_VTH67                 , 0x34 },
+       { STB0899_VTH78                 , 0x24 },
+       { STB0899_PRVIT                 , 0xff },
+       { STB0899_VITSYNC               , 0x19 },
+       { STB0899_RSULC                 , 0xb1 }, /* DVB = 0xb1, DSS = 0xa1 */
+       { STB0899_TSULC                 , 0x42 },
+       { STB0899_RSLLC                 , 0x41 },
+       { STB0899_TSLPL                 , 0x12 },
+       { STB0899_TSCFGH                , 0x0c },
+       { STB0899_TSCFGM                , 0x00 },
+       { STB0899_TSCFGL                , 0x00 },
+       { STB0899_TSOUT                 , 0x69 }, /* 0x0d for CAM */
+       { STB0899_RSSYNCDEL             , 0x00 },
+       { STB0899_TSINHDELH             , 0x02 },
+       { STB0899_TSINHDELM             , 0x00 },
+       { STB0899_TSINHDELL             , 0x00 },
+       { STB0899_TSLLSTKM              , 0x1b },
+       { STB0899_TSLLSTKL              , 0xb3 },
+       { STB0899_TSULSTKM              , 0x00 },
+       { STB0899_TSULSTKL              , 0x00 },
+       { STB0899_PCKLENUL              , 0xbc },
+       { STB0899_PCKLENLL              , 0xcc },
+       { STB0899_RSPCKLEN              , 0xbd },
+       { STB0899_TSSTATUS              , 0x90 },
+       { STB0899_ERRCTRL1              , 0xb6 },
+       { STB0899_ERRCTRL2              , 0x95 },
+       { STB0899_ERRCTRL3              , 0x8d },
+       { STB0899_DMONMSK1              , 0x27 },
+       { STB0899_DMONMSK0              , 0x03 },
+       { STB0899_DEMAPVIT              , 0x5c },
+       { STB0899_PLPARM                , 0x19 },
+       { STB0899_PDELCTRL              , 0x48 },
+       { STB0899_PDELCTRL2             , 0x00 },
+       { STB0899_BBHCTRL1              , 0x00 },
+       { STB0899_BBHCTRL2              , 0x00 },
+       { STB0899_HYSTTHRESH            , 0x77 },
+       { STB0899_MATCSTM               , 0x00 },
+       { STB0899_MATCSTL               , 0x00 },
+       { STB0899_UPLCSTM               , 0x00 },
+       { STB0899_UPLCSTL               , 0x00 },
+       { STB0899_DFLCSTM               , 0x00 },
+       { STB0899_DFLCSTL               , 0x00 },
+       { STB0899_SYNCCST               , 0x00 },
+       { STB0899_SYNCDCSTM             , 0x00 },
+       { STB0899_SYNCDCSTL             , 0x00 },
+       { STB0899_ISI_ENTRY             , 0x00 },
+       { STB0899_ISI_BIT_EN            , 0x00 },
+       { STB0899_MATSTRM               , 0xf0 },
+       { STB0899_MATSTRL               , 0x02 },
+       { STB0899_UPLSTRM               , 0x45 },
+       { STB0899_UPLSTRL               , 0x60 },
+       { STB0899_DFLSTRM               , 0xe3 },
+       { STB0899_DFLSTRL               , 0x00 },
+       { STB0899_SYNCSTR               , 0x47 },
+       { STB0899_SYNCDSTRM             , 0x05 },
+       { STB0899_SYNCDSTRL             , 0x18 },
+       { STB0899_CFGPDELSTATUS1        , 0x19 },
+       { STB0899_CFGPDELSTATUS2        , 0x2b },
+       { STB0899_BBFERRORM             , 0x00 },
+       { STB0899_BBFERRORL             , 0x01 },
+       { STB0899_UPKTERRORM            , 0x00 },
+       { STB0899_UPKTERRORL            , 0x00 },
+       { 0xffff                        , 0xff },
+};
+
+struct stb0899_config vp1041_stb0899_config = {
+       .init_dev               = vp1041_stb0899_s1_init_1,
+       .init_s2_demod          = stb0899_s2_init_2,
+       .init_s1_demod          = vp1041_stb0899_s1_init_3,
+       .init_s2_fec            = stb0899_s2_init_4,
+       .init_tst               = stb0899_s1_init_5,
+
+       .demod_address          = 0x68, /*  0xd0 >> 1 */
+
+       .xtal_freq              = 27000000,
+       .inversion              = IQ_SWAP_ON, /* 1 */
+
+       .lo_clk                 = 76500000,
+       .hi_clk                 = 99000000,
+
+       .esno_ave               = STB0899_DVBS2_ESNO_AVE,
+       .esno_quant             = STB0899_DVBS2_ESNO_QUANT,
+       .avframes_coarse        = STB0899_DVBS2_AVFRAMES_COARSE,
+       .avframes_fine          = STB0899_DVBS2_AVFRAMES_FINE,
+       .miss_threshold         = STB0899_DVBS2_MISS_THRESHOLD,
+       .uwp_threshold_acq      = STB0899_DVBS2_UWP_THRESHOLD_ACQ,
+       .uwp_threshold_track    = STB0899_DVBS2_UWP_THRESHOLD_TRACK,
+       .uwp_threshold_sof      = STB0899_DVBS2_UWP_THRESHOLD_SOF,
+       .sof_search_timeout     = STB0899_DVBS2_SOF_SEARCH_TIMEOUT,
+
+       .btr_nco_bits           = STB0899_DVBS2_BTR_NCO_BITS,
+       .btr_gain_shift_offset  = STB0899_DVBS2_BTR_GAIN_SHIFT_OFFSET,
+       .crl_nco_bits           = STB0899_DVBS2_CRL_NCO_BITS,
+       .ldpc_max_iter          = STB0899_DVBS2_LDPC_MAX_ITER,
+
+       .tuner_get_frequency    = stb6100_get_frequency,
+       .tuner_set_frequency    = stb6100_set_frequency,
+       .tuner_set_bandwidth    = stb6100_set_bandwidth,
+       .tuner_get_bandwidth    = stb6100_get_bandwidth,
+       .tuner_set_rfsiggain    = NULL,
+};
+
+struct stb6100_config vp1041_stb6100_config = {
+       .tuner_address  = 0x60,
+       .refclock       = 27000000,
+};
+
+static int vp1041_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
+{
+       struct i2c_adapter *adapter     = &mantis->adapter;
+
+       int err = 0;
+
+       err = mantis_frontend_power(mantis, POWER_ON);
+       if (err == 0) {
+               mantis_frontend_soft_reset(mantis);
+               msleep(250);
+               mantis->fe = stb0899_attach(&vp1041_stb0899_config, adapter);
+               if (mantis->fe) {
+                       dprintk(MANTIS_ERROR, 1,
+                               "found STB0899 DVB-S/DVB-S2 frontend @0x%02x",
+                               vp1041_stb0899_config.demod_address);
+
+                       if (stb6100_attach(mantis->fe, &vp1041_stb6100_config, adapter)) {
+                               if (!lnbp21_attach(mantis->fe, adapter, 0, 0))
+                                       dprintk(MANTIS_ERROR, 1, "No LNBP21 found!");
+                       }
+               } else {
+                       return -EREMOTEIO;
+               }
+       } else {
+               dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
+                       adapter->name,
+                       err);
+
+               return -EIO;
+       }
+
+
+       dprintk(MANTIS_ERROR, 1, "Done!");
+
+       return 0;
+}
+
+struct mantis_hwconfig vp1041_config = {
+       .model_name     = MANTIS_MODEL_NAME,
+       .dev_type       = MANTIS_DEV_TYPE,
+       .ts_size        = MANTIS_TS_188,
+
+       .baud_rate      = MANTIS_BAUD_9600,
+       .parity         = MANTIS_PARITY_NONE,
+       .bytes          = 0,
+
+       .frontend_init  = vp1041_frontend_init,
+       .power          = GPIF_A12,
+       .reset          = GPIF_A13,
+};
diff --git a/drivers/media/dvb/mantis/mantis_vp1041.h b/drivers/media/dvb/mantis/mantis_vp1041.h
new file mode 100644 (file)
index 0000000..1ae5b3d
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+       Mantis VP-1041 driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_VP1041_H
+#define __MANTIS_VP1041_H
+
+#include "mantis_common.h"
+
+#define MANTIS_VP_1041_DVB_S2  0x0031
+#define SKYSTAR_HD2_10         0x0001
+#define SKYSTAR_HD2_20         0x0003
+#define CINERGY_S2_PCI_HD      0x1179
+
+extern struct mantis_hwconfig vp1041_config;
+
+#endif /* __MANTIS_VP1041_H */
diff --git a/drivers/media/dvb/mantis/mantis_vp2033.c b/drivers/media/dvb/mantis/mantis_vp2033.c
new file mode 100644 (file)
index 0000000..10ce817
--- /dev/null
@@ -0,0 +1,187 @@
+/*
+       Mantis VP-2033 driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "tda1002x.h"
+#include "mantis_common.h"
+#include "mantis_ioc.h"
+#include "mantis_dvb.h"
+#include "mantis_vp2033.h"
+
+#define MANTIS_MODEL_NAME      "VP-2033"
+#define MANTIS_DEV_TYPE                "DVB-C"
+
+struct tda1002x_config vp2033_tda1002x_cu1216_config = {
+       .demod_address = 0x18 >> 1,
+       .invert = 1,
+};
+
+struct tda10023_config vp2033_tda10023_cu1216_config = {
+       .demod_address = 0x18 >> 1,
+       .invert = 1,
+};
+
+static u8 read_pwm(struct mantis_pci *mantis)
+{
+       struct i2c_adapter *adapter = &mantis->adapter;
+
+       u8 b = 0xff;
+       u8 pwm;
+       struct i2c_msg msg[] = {
+               {.addr = 0x50, .flags = 0, .buf = &b, .len = 1},
+               {.addr = 0x50, .flags = I2C_M_RD, .buf = &pwm, .len = 1}
+       };
+
+       if ((i2c_transfer(adapter, msg, 2) != 2)
+           || (pwm == 0xff))
+               pwm = 0x48;
+
+       return pwm;
+}
+
+static int tda1002x_cu1216_tuner_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
+{
+       struct mantis_pci *mantis = fe->dvb->priv;
+       struct i2c_adapter *adapter = &mantis->adapter;
+
+       u8 buf[6];
+       struct i2c_msg msg = {.addr = 0x60, .flags = 0, .buf = buf, .len = sizeof(buf)};
+       int i;
+
+#define CU1216_IF 36125000
+#define TUNER_MUL 62500
+
+       u32 div = (params->frequency + CU1216_IF + TUNER_MUL / 2) / TUNER_MUL;
+
+       buf[0] = (div >> 8) & 0x7f;
+       buf[1] = div & 0xff;
+       buf[2] = 0xce;
+       buf[3] = (params->frequency < 150000000 ? 0x01 :
+                 params->frequency < 445000000 ? 0x02 : 0x04);
+       buf[4] = 0xde;
+       buf[5] = 0x20;
+
+       if (fe->ops.i2c_gate_ctrl)
+               fe->ops.i2c_gate_ctrl(fe, 1);
+
+       if (i2c_transfer(adapter, &msg, 1) != 1)
+               return -EIO;
+
+       /* wait for the pll lock */
+       msg.flags = I2C_M_RD;
+       msg.len = 1;
+       for (i = 0; i < 20; i++) {
+               if (fe->ops.i2c_gate_ctrl)
+                       fe->ops.i2c_gate_ctrl(fe, 1);
+
+               if (i2c_transfer(adapter, &msg, 1) == 1 && (buf[0] & 0x40))
+                       break;
+
+               msleep(10);
+       }
+
+       /* switch the charge pump to the lower current */
+       msg.flags = 0;
+       msg.len = 2;
+       msg.buf = &buf[2];
+       buf[2] &= ~0x40;
+       if (fe->ops.i2c_gate_ctrl)
+               fe->ops.i2c_gate_ctrl(fe, 1);
+
+       if (i2c_transfer(adapter, &msg, 1) != 1)
+               return -EIO;
+
+       return 0;
+}
+
+static int vp2033_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
+{
+       struct i2c_adapter *adapter = &mantis->adapter;
+
+       int err = 0;
+
+       err = mantis_frontend_power(mantis, POWER_ON);
+       if (err == 0) {
+               mantis_frontend_soft_reset(mantis);
+               msleep(250);
+
+               dprintk(MANTIS_ERROR, 1, "Probing for CU1216 (DVB-C)");
+               fe = tda10021_attach(&vp2033_tda1002x_cu1216_config,
+                                    adapter,
+                                    read_pwm(mantis));
+
+               if (fe) {
+                       dprintk(MANTIS_ERROR, 1,
+                               "found Philips CU1216 DVB-C frontend (TDA10021) @ 0x%02x",
+                               vp2033_tda1002x_cu1216_config.demod_address);
+               } else {
+                       fe = tda10023_attach(&vp2033_tda10023_cu1216_config,
+                                            adapter,
+                                            read_pwm(mantis));
+
+                       if (fe) {
+                               dprintk(MANTIS_ERROR, 1,
+                                       "found Philips CU1216 DVB-C frontend (TDA10023) @ 0x%02x",
+                                       vp2033_tda1002x_cu1216_config.demod_address);
+                       }
+               }
+
+               if (fe) {
+                       fe->ops.tuner_ops.set_params = tda1002x_cu1216_tuner_set;
+                       dprintk(MANTIS_ERROR, 1, "Mantis DVB-C Philips CU1216 frontend attach success");
+               } else {
+                       return -1;
+               }
+       } else {
+               dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
+                       adapter->name,
+                       err);
+
+               return -EIO;
+       }
+
+       mantis->fe = fe;
+       dprintk(MANTIS_DEBUG, 1, "Done!");
+
+       return 0;
+}
+
+struct mantis_hwconfig vp2033_config = {
+       .model_name     = MANTIS_MODEL_NAME,
+       .dev_type       = MANTIS_DEV_TYPE,
+       .ts_size        = MANTIS_TS_204,
+
+       .baud_rate      = MANTIS_BAUD_9600,
+       .parity         = MANTIS_PARITY_NONE,
+       .bytes          = 0,
+
+       .frontend_init  = vp2033_frontend_init,
+       .power          = GPIF_A12,
+       .reset          = GPIF_A13,
+};
diff --git a/drivers/media/dvb/mantis/mantis_vp2033.h b/drivers/media/dvb/mantis/mantis_vp2033.h
new file mode 100644 (file)
index 0000000..c55242b
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+       Mantis VP-2033 driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_VP2033_H
+#define __MANTIS_VP2033_H
+
+#include "mantis_common.h"
+
+#define MANTIS_VP_2033_DVB_C   0x0008
+
+extern struct mantis_hwconfig vp2033_config;
+
+#endif /* __MANTIS_VP2033_H */
diff --git a/drivers/media/dvb/mantis/mantis_vp2040.c b/drivers/media/dvb/mantis/mantis_vp2040.c
new file mode 100644 (file)
index 0000000..a7ca233
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+       Mantis VP-2040 driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "tda1002x.h"
+#include "mantis_common.h"
+#include "mantis_ioc.h"
+#include "mantis_dvb.h"
+#include "mantis_vp2040.h"
+
+#define MANTIS_MODEL_NAME      "VP-2040"
+#define MANTIS_DEV_TYPE                "DVB-C"
+
+struct tda1002x_config vp2040_tda1002x_cu1216_config = {
+       .demod_address  = 0x18 >> 1,
+       .invert         = 1,
+};
+
+struct tda10023_config vp2040_tda10023_cu1216_config = {
+       .demod_address  = 0x18 >> 1,
+       .invert         = 1,
+};
+
+static int tda1002x_cu1216_tuner_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
+{
+       struct mantis_pci *mantis       = fe->dvb->priv;
+       struct i2c_adapter *adapter     = &mantis->adapter;
+
+       u8 buf[6];
+       struct i2c_msg msg = {.addr = 0x60, .flags = 0, .buf = buf, .len = sizeof(buf)};
+       int i;
+
+#define CU1216_IF 36125000
+#define TUNER_MUL 62500
+
+       u32 div = (params->frequency + CU1216_IF + TUNER_MUL / 2) / TUNER_MUL;
+
+       buf[0] = (div >> 8) & 0x7f;
+       buf[1] = div & 0xff;
+       buf[2] = 0xce;
+       buf[3] = (params->frequency < 150000000 ? 0x01 :
+                 params->frequency < 445000000 ? 0x02 : 0x04);
+       buf[4] = 0xde;
+       buf[5] = 0x20;
+
+       if (fe->ops.i2c_gate_ctrl)
+               fe->ops.i2c_gate_ctrl(fe, 1);
+
+       if (i2c_transfer(adapter, &msg, 1) != 1)
+               return -EIO;
+
+       /* wait for the pll lock */
+       msg.flags = I2C_M_RD;
+       msg.len = 1;
+       for (i = 0; i < 20; i++) {
+               if (fe->ops.i2c_gate_ctrl)
+                       fe->ops.i2c_gate_ctrl(fe, 1);
+
+               if (i2c_transfer(adapter, &msg, 1) == 1 && (buf[0] & 0x40))
+                       break;
+
+               msleep(10);
+       }
+
+       /* switch the charge pump to the lower current */
+       msg.flags = 0;
+       msg.len = 2;
+       msg.buf = &buf[2];
+       buf[2] &= ~0x40;
+       if (fe->ops.i2c_gate_ctrl)
+               fe->ops.i2c_gate_ctrl(fe, 1);
+
+       if (i2c_transfer(adapter, &msg, 1) != 1)
+               return -EIO;
+
+       return 0;
+}
+
+static u8 read_pwm(struct mantis_pci *mantis)
+{
+       struct i2c_adapter *adapter = &mantis->adapter;
+
+       u8 b = 0xff;
+       u8 pwm;
+       struct i2c_msg msg[] = {
+               {.addr = 0x50, .flags = 0, .buf = &b, .len = 1},
+               {.addr = 0x50, .flags = I2C_M_RD, .buf = &pwm, .len = 1}
+       };
+
+       if ((i2c_transfer(adapter, msg, 2) != 2)
+           || (pwm == 0xff))
+               pwm = 0x48;
+
+       return pwm;
+}
+
+static int vp2040_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
+{
+       struct i2c_adapter *adapter = &mantis->adapter;
+
+       int err = 0;
+
+       err = mantis_frontend_power(mantis, POWER_ON);
+       if (err == 0) {
+               mantis_frontend_soft_reset(mantis);
+               msleep(250);
+
+               dprintk(MANTIS_ERROR, 1, "Probing for CU1216 (DVB-C)");
+               fe = tda10021_attach(&vp2040_tda1002x_cu1216_config,
+                                    adapter,
+                                    read_pwm(mantis));
+
+               if (fe) {
+                       dprintk(MANTIS_ERROR, 1,
+                               "found Philips CU1216 DVB-C frontend (TDA10021) @ 0x%02x",
+                               vp2040_tda1002x_cu1216_config.demod_address);
+               } else {
+                       fe = tda10023_attach(&vp2040_tda10023_cu1216_config,
+                                            adapter,
+                                            read_pwm(mantis));
+
+                       if (fe) {
+                               dprintk(MANTIS_ERROR, 1,
+                                       "found Philips CU1216 DVB-C frontend (TDA10023) @ 0x%02x",
+                                       vp2040_tda1002x_cu1216_config.demod_address);
+                       }
+               }
+
+               if (fe) {
+                       fe->ops.tuner_ops.set_params = tda1002x_cu1216_tuner_set;
+                       dprintk(MANTIS_ERROR, 1, "Mantis DVB-C Philips CU1216 frontend attach success");
+               } else {
+                       return -1;
+               }
+       } else {
+               dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
+                       adapter->name,
+                       err);
+
+               return -EIO;
+       }
+       mantis->fe = fe;
+       dprintk(MANTIS_DEBUG, 1, "Done!");
+
+       return 0;
+}
+
+struct mantis_hwconfig vp2040_config = {
+       .model_name     = MANTIS_MODEL_NAME,
+       .dev_type       = MANTIS_DEV_TYPE,
+       .ts_size        = MANTIS_TS_204,
+
+       .baud_rate      = MANTIS_BAUD_9600,
+       .parity         = MANTIS_PARITY_NONE,
+       .bytes          = 0,
+
+       .frontend_init  = vp2040_frontend_init,
+       .power          = GPIF_A12,
+       .reset          = GPIF_A13,
+};
diff --git a/drivers/media/dvb/mantis/mantis_vp2040.h b/drivers/media/dvb/mantis/mantis_vp2040.h
new file mode 100644 (file)
index 0000000..d125e21
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+       Mantis VP-2040 driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_VP2040_H
+#define __MANTIS_VP2040_H
+
+#include "mantis_common.h"
+
+#define MANTIS_VP_2040_DVB_C   0x0043
+#define CINERGY_C              0x1178
+#define CABLESTAR_HD2          0x0002
+
+extern struct mantis_hwconfig vp2040_config;
+
+#endif /* __MANTIS_VP2040_H */
diff --git a/drivers/media/dvb/mantis/mantis_vp3028.c b/drivers/media/dvb/mantis/mantis_vp3028.c
new file mode 100644 (file)
index 0000000..4155c83
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+       Mantis VP-3028 driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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 "mantis_common.h"
+#include "mantis_vp3028.h"
+
+struct zl10353_config mantis_vp3028_config = {
+       .demod_address  = 0x0f,
+};
+
+#define MANTIS_MODEL_NAME      "VP-3028"
+#define MANTIS_DEV_TYPE                "DVB-T"
+
+struct mantis_hwconfig vp3028_mantis_config = {
+       .model_name     = MANTIS_MODEL_NAME,
+       .dev_type       = MANTIS_DEV_TYPE,
+       .ts_size        = MANTIS_TS_188,
+       .baud_rate      = MANTIS_BAUD_9600,
+       .parity         = MANTIS_PARITY_NONE,
+       .bytes          = 0,
+};
diff --git a/drivers/media/dvb/mantis/mantis_vp3028.h b/drivers/media/dvb/mantis/mantis_vp3028.h
new file mode 100644 (file)
index 0000000..b07be6a
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+       Mantis VP-3028 driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_VP3028_H
+#define __MANTIS_VP3028_H
+
+#include "dvb_frontend.h"
+#include "mantis_common.h"
+#include "zl10353.h"
+
+#define MANTIS_VP_3028_DVB_T   0x0028
+
+extern struct zl10353_config mantis_vp3028_config;
+extern struct mantis_hwconfig vp3028_mantis_config;
+
+#endif /* __MANTIS_VP3028_H */
diff --git a/drivers/media/dvb/mantis/mantis_vp3030.c b/drivers/media/dvb/mantis/mantis_vp3030.c
new file mode 100644 (file)
index 0000000..1f43342
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+       Mantis VP-3030 driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "zl10353.h"
+#include "tda665x.h"
+#include "mantis_common.h"
+#include "mantis_ioc.h"
+#include "mantis_dvb.h"
+#include "mantis_vp3030.h"
+
+struct zl10353_config mantis_vp3030_config = {
+       .demod_address          = 0x0f,
+};
+
+struct tda665x_config env57h12d5_config = {
+       .name                   = "ENV57H12D5 (ET-50DT)",
+       .addr                   = 0x60,
+       .frequency_min          =  47000000,
+       .frequency_max          = 862000000,
+       .frequency_offst        =   3616667,
+       .ref_multiplier         = 6, /* 1/6 MHz */
+       .ref_divider            = 100000, /* 1/6 MHz */
+};
+
+#define MANTIS_MODEL_NAME      "VP-3030"
+#define MANTIS_DEV_TYPE                "DVB-T"
+
+
+static int vp3030_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
+{
+       struct i2c_adapter *adapter     = &mantis->adapter;
+       struct mantis_hwconfig *config  = mantis->hwconfig;
+       int err = 0;
+
+       gpio_set_bits(mantis, config->reset, 0);
+       msleep(100);
+       err = mantis_frontend_power(mantis, POWER_ON);
+       msleep(100);
+       gpio_set_bits(mantis, config->reset, 1);
+
+       if (err == 0) {
+               msleep(250);
+               dprintk(MANTIS_ERROR, 1, "Probing for 10353 (DVB-T)");
+               fe = zl10353_attach(&mantis_vp3030_config, adapter);
+
+               if (!fe)
+                       return -1;
+
+               tda665x_attach(fe, &env57h12d5_config, adapter);
+       } else {
+               dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
+                       adapter->name,
+                       err);
+
+               return -EIO;
+
+       }
+       mantis->fe = fe;
+       dprintk(MANTIS_ERROR, 1, "Done!");
+
+       return 0;
+}
+
+struct mantis_hwconfig vp3030_config = {
+       .model_name     = MANTIS_MODEL_NAME,
+       .dev_type       = MANTIS_DEV_TYPE,
+       .ts_size        = MANTIS_TS_188,
+
+       .baud_rate      = MANTIS_BAUD_9600,
+       .parity         = MANTIS_PARITY_NONE,
+       .bytes          = 0,
+
+       .frontend_init  = vp3030_frontend_init,
+       .power          = GPIF_A12,
+       .reset          = GPIF_A13,
+
+       .i2c_mode       = MANTIS_BYTE_MODE
+};
diff --git a/drivers/media/dvb/mantis/mantis_vp3030.h b/drivers/media/dvb/mantis/mantis_vp3030.h
new file mode 100644 (file)
index 0000000..5f12c42
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+       Mantis VP-3030 driver
+
+       Copyright (C) Manu Abraham (abraham.manu@gmail.com)
+
+       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.
+*/
+
+#ifndef __MANTIS_VP3030_H
+#define __MANTIS_VP3030_H
+
+#include "mantis_common.h"
+
+#define MANTIS_VP_3030_DVB_T   0x0024
+
+extern struct mantis_hwconfig vp3030_config;
+
+#endif /* __MANTIS_VP3030_H */
index e930a67..bd6214d 100644 (file)
@@ -1815,6 +1815,8 @@ static int vidioc_qbuf(struct file *file, void *priv,
        /* put the buffer in the 'queued' queue */
        i = gspca_dev->fr_q;
        gspca_dev->fr_queue[i] = index;
+       if (gspca_dev->fr_i == i)
+               gspca_dev->cur_frame = frame;
        gspca_dev->fr_q = (i + 1) % gspca_dev->nframes;
        PDEBUG(D_FRAM, "qbuf q:%d i:%d o:%d",
                gspca_dev->fr_q,
index aa2f3c7..1b536f7 100644 (file)
@@ -48,6 +48,12 @@ static
                        DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Xa 2528")
                }
        }, {
+               .ident = "Fujitsu-Siemens Amilo Xi 2428",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Xi 2428")
+               }
+       }, {
                .ident = "Fujitsu-Siemens Amilo Xi 2528",
                .matches = {
                        DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
index 4dbb882..0a6b8f0 100644 (file)
@@ -1533,7 +1533,7 @@ static void setexposure_96(struct gspca_dev *gspca_dev)
 static void setsharpness_96(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
-       u8 val;
+       s8 val;
 
        val = sd->sharpness;
        if (val < 0) {                          /* auto */
index 4cff803..0ca1c06 100644 (file)
@@ -2319,7 +2319,7 @@ static void do_autogain(struct gspca_dev *gspca_dev, u16 avg_lum)
                }
        }
        if (avg_lum > MAX_AVG_LUM) {
-               if (sd->gain - 1 >= 0) {
+               if (sd->gain >= 1) {
                        sd->gain--;
                        set_gain(gspca_dev);
                }
index 487d405..96c6192 100644 (file)
@@ -228,6 +228,7 @@ static const struct stv_init stv_bridge_init[] = {
        /* This reg is written twice. Some kind of reset? */
        {NULL,  0x1620, 0x80},
        {NULL,  0x1620, 0x00},
+       {NULL,  0x1443, 0x00},
        {NULL,  0x1423, 0x04},
        {x1500, 0x1500, ARRAY_SIZE(x1500)},
        {x1536, 0x1536, ARRAY_SIZE(x1536)},
index 716df6b..306b7d7 100644 (file)
@@ -709,7 +709,7 @@ static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
                spca504B_PollingDataReady(gspca_dev);
 
                /* Init the cam width height with some values get on init ? */
-               reg_w_riv(gspca_dev, 0x31, 0, 0x04);
+               reg_w_riv(gspca_dev, 0x31, 0x0004, 0x00);
                spca504B_WaitCmdStatus(gspca_dev);
                spca504B_PollingDataReady(gspca_dev);
                break;
@@ -807,14 +807,14 @@ static void init_ctl_reg(struct gspca_dev *gspca_dev)
        default:
 /*     case BRIDGE_SPCA533: */
 /*     case BRIDGE_SPCA504B: */
-               reg_w_riv(gspca_dev, 0, 0x00, 0x21ad);  /* hue */
-               reg_w_riv(gspca_dev, 0, 0x01, 0x21ac);  /* sat/hue */
-               reg_w_riv(gspca_dev, 0, 0x00, 0x21a3);  /* gamma */
+               reg_w_riv(gspca_dev, 0, 0x21ad, 0x00);  /* hue */
+               reg_w_riv(gspca_dev, 0, 0x21ac, 0x01);  /* sat/hue */
+               reg_w_riv(gspca_dev, 0, 0x21a3, 0x00);  /* gamma */
                break;
        case BRIDGE_SPCA536:
-               reg_w_riv(gspca_dev, 0, 0x40, 0x20f5);
-               reg_w_riv(gspca_dev, 0, 0x01, 0x20f4);
-               reg_w_riv(gspca_dev, 0, 0x00, 0x2089);
+               reg_w_riv(gspca_dev, 0, 0x20f5, 0x40);
+               reg_w_riv(gspca_dev, 0, 0x20f4, 0x01);
+               reg_w_riv(gspca_dev, 0, 0x2089, 0x00);
                break;
        }
        if (pollreg)
@@ -887,11 +887,11 @@ static int sd_init(struct gspca_dev *gspca_dev)
        switch (sd->bridge) {
        case BRIDGE_SPCA504B:
                reg_w_riv(gspca_dev, 0x1d, 0x00, 0);
-               reg_w_riv(gspca_dev, 0, 0x01, 0x2306);
-               reg_w_riv(gspca_dev, 0, 0x00, 0x0d04);
-               reg_w_riv(gspca_dev, 0, 0x00, 0x2000);
-               reg_w_riv(gspca_dev, 0, 0x13, 0x2301);
-               reg_w_riv(gspca_dev, 0, 0x00, 0x2306);
+               reg_w_riv(gspca_dev, 0x00, 0x2306, 0x01);
+               reg_w_riv(gspca_dev, 0x00, 0x0d04, 0x00);
+               reg_w_riv(gspca_dev, 0x00, 0x2000, 0x00);
+               reg_w_riv(gspca_dev, 0x00, 0x2301, 0x13);
+               reg_w_riv(gspca_dev, 0x00, 0x2306, 0x00);
                /* fall thru */
        case BRIDGE_SPCA533:
                spca504B_PollingDataReady(gspca_dev);
@@ -1000,7 +1000,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
                        spca504B_WaitCmdStatus(gspca_dev);
                        break;
                default:
-                       reg_w_riv(gspca_dev, 0x31, 0, 0x04);
+                       reg_w_riv(gspca_dev, 0x31, 0x0004, 0x00);
                        spca504B_WaitCmdStatus(gspca_dev);
                        spca504B_PollingDataReady(gspca_dev);
                        break;
index c090efc..71921c8 100644 (file)
@@ -3009,6 +3009,10 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
                int l;
 
                frame = gspca_get_i_frame(gspca_dev);
+               if (frame == NULL) {
+                       gspca_dev->last_packet_type = DISCARD_PACKET;
+                       return;
+               }
                l = frame->data_end - frame->data;
                if (len > frame->v4l2_buf.length - l)
                        len = frame->v4l2_buf.length - l;
index 2ba14fb..c167cc3 100644 (file)
@@ -718,7 +718,7 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        irq = platform_get_irq(pdev, 0);
-       if (!res || !irq) {
+       if (!res || (int)irq <= 0) {
                err = -ENODEV;
                goto exit;
        }
index 7e42989..805226e 100644 (file)
@@ -563,7 +563,7 @@ static int rj54n1_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
        struct i2c_client *client = sd->priv;
        struct rj54n1 *rj54n1 = to_rj54n1(client);
        struct v4l2_rect *rect = &a->c;
-       unsigned int dummy, output_w, output_h,
+       unsigned int dummy = 0, output_w, output_h,
                input_w = rect->width, input_h = rect->height;
        int ret;
 
index 9f85e91..a7ad781 100644 (file)
@@ -420,19 +420,6 @@ int saa7134_set_dmabits(struct saa7134_dev *dev)
                ctrl |= SAA7134_MAIN_CTRL_TE5;
                irq  |= SAA7134_IRQ1_INTE_RA2_1 |
                        SAA7134_IRQ1_INTE_RA2_0;
-
-               /* dma: setup channel 5 (= TS) */
-
-               saa_writeb(SAA7134_TS_DMA0, (dev->ts.nr_packets - 1) & 0xff);
-               saa_writeb(SAA7134_TS_DMA1,
-                       ((dev->ts.nr_packets - 1) >> 8) & 0xff);
-               /* TSNOPIT=0, TSCOLAP=0 */
-               saa_writeb(SAA7134_TS_DMA2,
-                       (((dev->ts.nr_packets - 1) >> 16) & 0x3f) | 0x00);
-               saa_writel(SAA7134_RS_PITCH(5), TS_PACKET_SIZE);
-               saa_writel(SAA7134_RS_CONTROL(5), SAA7134_RS_CONTROL_BURST_16 |
-                                                 SAA7134_RS_CONTROL_ME |
-                                                 (dev->ts.pt_ts.dma >> 12));
        }
 
        /* set task conditions + field handling */
index 03488ba..b9817d7 100644 (file)
@@ -250,6 +250,19 @@ int saa7134_ts_start(struct saa7134_dev *dev)
 
        BUG_ON(dev->ts_started);
 
+       /* dma: setup channel 5 (= TS) */
+       saa_writeb(SAA7134_TS_DMA0, (dev->ts.nr_packets - 1) & 0xff);
+       saa_writeb(SAA7134_TS_DMA1,
+               ((dev->ts.nr_packets - 1) >> 8) & 0xff);
+       /* TSNOPIT=0, TSCOLAP=0 */
+       saa_writeb(SAA7134_TS_DMA2,
+               (((dev->ts.nr_packets - 1) >> 16) & 0x3f) | 0x00);
+       saa_writel(SAA7134_RS_PITCH(5), TS_PACKET_SIZE);
+       saa_writel(SAA7134_RS_CONTROL(5), SAA7134_RS_CONTROL_BURST_16 |
+                                         SAA7134_RS_CONTROL_ME |
+                                         (dev->ts.pt_ts.dma >> 12));
+
+       /* reset hardware TS buffers */
        saa_writeb(SAA7134_TS_SERIAL1, 0x00);
        saa_writeb(SAA7134_TS_SERIAL1, 0x03);
        saa_writeb(SAA7134_TS_SERIAL1, 0x00);
index d69363f..f09c714 100644 (file)
@@ -1827,7 +1827,7 @@ static int __devinit sh_mobile_ceu_probe(struct platform_device *pdev)
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        irq = platform_get_irq(pdev, 0);
-       if (!res || !irq) {
+       if (!res || (int)irq <= 0) {
                dev_err(&pdev->dev, "Not enough CEU platform resources.\n");
                err = -ENODEV;
                goto exit;
index 0469d7a..ec8ef8c 100644 (file)
@@ -1393,7 +1393,7 @@ uvc_ctrl_prune_entity(struct uvc_device *dev, struct uvc_entity *entity)
        size = entity->processing.bControlSize;
 
        for (i = 0; i < ARRAY_SIZE(blacklist); ++i) {
-               if (!usb_match_id(dev->intf, &blacklist[i].id))
+               if (!usb_match_one_id(dev->intf, &blacklist[i].id))
                        continue;
 
                if (blacklist[i].index >= 8 * size ||
index f854698..ea11839 100644 (file)
@@ -59,9 +59,9 @@
  *    returns immediately.
  *
  *    When the buffer is full, the completion handler removes it from the irq
- *    queue, marks it as ready (UVC_BUF_STATE_DONE) and wakes its wait queue.
+ *    queue, marks it as done (UVC_BUF_STATE_DONE) and wakes its wait queue.
  *    At that point, any process waiting on the buffer will be woken up. If a
- *    process tries to dequeue a buffer after it has been marked ready, the
+ *    process tries to dequeue a buffer after it has been marked done, the
  *    dequeing will succeed immediately.
  *
  * 2. Buffers are queued, user is waiting on a buffer and the device gets
@@ -201,6 +201,7 @@ static void __uvc_query_buffer(struct uvc_buffer *buf,
                break;
        case UVC_BUF_STATE_QUEUED:
        case UVC_BUF_STATE_ACTIVE:
+       case UVC_BUF_STATE_READY:
                v4l2_buf->flags |= V4L2_BUF_FLAG_QUEUED;
                break;
        case UVC_BUF_STATE_IDLE:
@@ -295,13 +296,15 @@ static int uvc_queue_waiton(struct uvc_buffer *buf, int nonblocking)
 {
        if (nonblocking) {
                return (buf->state != UVC_BUF_STATE_QUEUED &&
-                       buf->state != UVC_BUF_STATE_ACTIVE)
+                       buf->state != UVC_BUF_STATE_ACTIVE &&
+                       buf->state != UVC_BUF_STATE_READY)
                        ? 0 : -EAGAIN;
        }
 
        return wait_event_interruptible(buf->wait,
                buf->state != UVC_BUF_STATE_QUEUED &&
-               buf->state != UVC_BUF_STATE_ACTIVE);
+               buf->state != UVC_BUF_STATE_ACTIVE &&
+               buf->state != UVC_BUF_STATE_READY);
 }
 
 /*
@@ -348,6 +351,7 @@ int uvc_dequeue_buffer(struct uvc_video_queue *queue,
        case UVC_BUF_STATE_IDLE:
        case UVC_BUF_STATE_QUEUED:
        case UVC_BUF_STATE_ACTIVE:
+       case UVC_BUF_STATE_READY:
        default:
                uvc_trace(UVC_TRACE_CAPTURE, "[E] Invalid buffer state %u "
                        "(driver bug?).\n", buf->state);
@@ -489,6 +493,7 @@ struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
 
        spin_lock_irqsave(&queue->irqlock, flags);
        list_del(&buf->queue);
+       buf->state = UVC_BUF_STATE_DONE;
        if (!list_empty(&queue->irqqueue))
                nextbuf = list_first_entry(&queue->irqqueue, struct uvc_buffer,
                                           queue);
index 9a98028..7dcf534 100644 (file)
@@ -441,7 +441,7 @@ static int uvc_video_decode_start(struct uvc_streaming *stream,
        if (fid != stream->last_fid && buf->buf.bytesused != 0) {
                uvc_trace(UVC_TRACE_FRAME, "Frame complete (FID bit "
                                "toggled).\n");
-               buf->state = UVC_BUF_STATE_DONE;
+               buf->state = UVC_BUF_STATE_READY;
                return -EAGAIN;
        }
 
@@ -470,7 +470,7 @@ static void uvc_video_decode_data(struct uvc_streaming *stream,
        /* Complete the current frame if the buffer size was exceeded. */
        if (len > maxlen) {
                uvc_trace(UVC_TRACE_FRAME, "Frame complete (overflow).\n");
-               buf->state = UVC_BUF_STATE_DONE;
+               buf->state = UVC_BUF_STATE_READY;
        }
 }
 
@@ -482,7 +482,7 @@ static void uvc_video_decode_end(struct uvc_streaming *stream,
                uvc_trace(UVC_TRACE_FRAME, "Frame complete (EOF found).\n");
                if (data[0] == len)
                        uvc_trace(UVC_TRACE_FRAME, "EOF in empty payload.\n");
-               buf->state = UVC_BUF_STATE_DONE;
+               buf->state = UVC_BUF_STATE_READY;
                if (stream->dev->quirks & UVC_QUIRK_STREAM_NO_FID)
                        stream->last_fid ^= UVC_STREAM_FID;
        }
@@ -568,8 +568,7 @@ static void uvc_video_decode_isoc(struct urb *urb, struct uvc_streaming *stream,
                uvc_video_decode_end(stream, buf, mem,
                        urb->iso_frame_desc[i].actual_length);
 
-               if (buf->state == UVC_BUF_STATE_DONE ||
-                   buf->state == UVC_BUF_STATE_ERROR)
+               if (buf->state == UVC_BUF_STATE_READY)
                        buf = uvc_queue_next_buffer(&stream->queue, buf);
        }
 }
@@ -627,8 +626,7 @@ static void uvc_video_decode_bulk(struct urb *urb, struct uvc_streaming *stream,
                if (!stream->bulk.skip_payload && buf != NULL) {
                        uvc_video_decode_end(stream, buf, stream->bulk.header,
                                stream->bulk.payload_size);
-                       if (buf->state == UVC_BUF_STATE_DONE ||
-                           buf->state == UVC_BUF_STATE_ERROR)
+                       if (buf->state == UVC_BUF_STATE_READY)
                                buf = uvc_queue_next_buffer(&stream->queue,
                                                            buf);
                }
@@ -669,7 +667,7 @@ static void uvc_video_encode_bulk(struct urb *urb, struct uvc_streaming *stream,
            stream->bulk.payload_size == stream->bulk.max_payload_size) {
                if (buf->buf.bytesused == stream->queue.buf_used) {
                        stream->queue.buf_used = 0;
-                       buf->state = UVC_BUF_STATE_DONE;
+                       buf->state = UVC_BUF_STATE_READY;
                        uvc_queue_next_buffer(&stream->queue, buf);
                        stream->last_fid ^= UVC_STREAM_FID;
                }
@@ -924,10 +922,8 @@ static int uvc_init_video_bulk(struct uvc_streaming *stream,
 static int uvc_init_video(struct uvc_streaming *stream, gfp_t gfp_flags)
 {
        struct usb_interface *intf = stream->intf;
-       struct usb_host_interface *alts;
-       struct usb_host_endpoint *ep = NULL;
-       int intfnum = stream->intfnum;
-       unsigned int bandwidth, psize, i;
+       struct usb_host_endpoint *ep;
+       unsigned int i;
        int ret;
 
        stream->last_fid = -1;
@@ -936,6 +932,12 @@ static int uvc_init_video(struct uvc_streaming *stream, gfp_t gfp_flags)
        stream->bulk.payload_size = 0;
 
        if (intf->num_altsetting > 1) {
+               struct usb_host_endpoint *best_ep = NULL;
+               unsigned int best_psize = 3 * 1024;
+               unsigned int bandwidth;
+               unsigned int uninitialized_var(altsetting);
+               int intfnum = stream->intfnum;
+
                /* Isochronous endpoint, select the alternate setting. */
                bandwidth = stream->ctrl.dwMaxPayloadTransferSize;
 
@@ -949,6 +951,9 @@ static int uvc_init_video(struct uvc_streaming *stream, gfp_t gfp_flags)
                }
 
                for (i = 0; i < intf->num_altsetting; ++i) {
+                       struct usb_host_interface *alts;
+                       unsigned int psize;
+
                        alts = &intf->altsetting[i];
                        ep = uvc_find_endpoint(alts,
                                stream->header.bEndpointAddress);
@@ -958,21 +963,27 @@ static int uvc_init_video(struct uvc_streaming *stream, gfp_t gfp_flags)
                        /* Check if the bandwidth is high enough. */
                        psize = le16_to_cpu(ep->desc.wMaxPacketSize);
                        psize = (psize & 0x07ff) * (1 + ((psize >> 11) & 3));
-                       if (psize >= bandwidth)
-                               break;
+                       if (psize >= bandwidth && psize <= best_psize) {
+                               altsetting = i;
+                               best_psize = psize;
+                               best_ep = ep;
+                       }
                }
 
-               if (i >= intf->num_altsetting) {
+               if (best_ep == NULL) {
                        uvc_trace(UVC_TRACE_VIDEO, "No fast enough alt setting "
                                "for requested bandwidth.\n");
                        return -EIO;
                }
 
-               ret = usb_set_interface(stream->dev->udev, intfnum, i);
+               uvc_trace(UVC_TRACE_VIDEO, "Selecting alternate setting %u "
+                       "(%u B/frame bandwidth).\n", altsetting, best_psize);
+
+               ret = usb_set_interface(stream->dev->udev, intfnum, altsetting);
                if (ret < 0)
                        return ret;
 
-               ret = uvc_init_video_isoc(stream, ep, gfp_flags);
+               ret = uvc_init_video_isoc(stream, best_ep, gfp_flags);
        } else {
                /* Bulk endpoint, proceed to URB initialization. */
                ep = uvc_find_endpoint(&intf->altsetting[0],
index 7ec9a04..2337585 100644 (file)
@@ -365,8 +365,9 @@ enum uvc_buffer_state {
        UVC_BUF_STATE_IDLE      = 0,
        UVC_BUF_STATE_QUEUED    = 1,
        UVC_BUF_STATE_ACTIVE    = 2,
-       UVC_BUF_STATE_DONE      = 3,
-       UVC_BUF_STATE_ERROR     = 4,
+       UVC_BUF_STATE_READY     = 3,
+       UVC_BUF_STATE_DONE      = 4,
+       UVC_BUF_STATE_ERROR     = 5,
 };
 
 struct uvc_buffer {
index cebbd90..d6ee28f 100644 (file)
@@ -582,7 +582,6 @@ extern s32 e1000_read_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset,
 extern s32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data);
 extern s32 e1000_write_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset,
                                          u16 data);
-extern s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw, bool slow);
 extern s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw);
 extern s32 e1000_copper_link_setup_82577(struct e1000_hw *hw);
 extern s32 e1000_check_polarity_82577(struct e1000_hw *hw);
index ad08cf3..8b6ecd1 100644 (file)
 #define E1000_NVM_K1_CONFIG 0x1B /* NVM K1 Config Word */
 #define E1000_NVM_K1_ENABLE 0x1  /* NVM Enable K1 bit */
 
+/* KMRN Mode Control */
+#define HV_KMRN_MODE_CTRL      PHY_REG(769, 16)
+#define HV_KMRN_MDIO_SLOW      0x0400
+
 /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
 /* Offset 04h HSFSTS */
 union ich8_hws_flash_status {
@@ -219,6 +223,7 @@ static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active);
 static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw);
 static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw);
 static s32  e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link);
+static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw);
 
 static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg)
 {
@@ -270,7 +275,21 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
        phy->autoneg_mask             = AUTONEG_ADVERTISE_SPEED_DEFAULT;
 
        phy->id = e1000_phy_unknown;
-       e1000e_get_phy_id(hw);
+       ret_val = e1000e_get_phy_id(hw);
+       if (ret_val)
+               goto out;
+       if ((phy->id == 0) || (phy->id == PHY_REVISION_MASK)) {
+               /*
+                * In case the PHY needs to be in mdio slow mode (eg. 82577),
+                * set slow mode and try to get the PHY id again.
+                */
+               ret_val = e1000_set_mdio_slow_mode_hv(hw);
+               if (ret_val)
+                       goto out;
+               ret_val = e1000e_get_phy_id(hw);
+               if (ret_val)
+                       goto out;
+       }
        phy->type = e1000e_get_phy_type_from_id(phy->id);
 
        switch (phy->type) {
@@ -292,6 +311,7 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
                break;
        }
 
+out:
        return ret_val;
 }
 
@@ -1076,16 +1096,44 @@ out:
 
 
 /**
+ *  e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
+ *  @hw:   pointer to the HW structure
+ **/
+static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw)
+{
+       s32 ret_val;
+       u16 data;
+
+       ret_val = e1e_rphy(hw, HV_KMRN_MODE_CTRL, &data);
+       if (ret_val)
+               return ret_val;
+
+       data |= HV_KMRN_MDIO_SLOW;
+
+       ret_val = e1e_wphy(hw, HV_KMRN_MODE_CTRL, data);
+
+       return ret_val;
+}
+
+/**
  *  e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
  *  done after every PHY reset.
  **/
 static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
 {
        s32 ret_val = 0;
+       u16 phy_data;
 
        if (hw->mac.type != e1000_pchlan)
                return ret_val;
 
+       /* Set MDIO slow mode before any other MDIO access */
+       if (hw->phy.type == e1000_phy_82577) {
+               ret_val = e1000_set_mdio_slow_mode_hv(hw);
+               if (ret_val)
+                       goto out;
+       }
+
        if (((hw->phy.type == e1000_phy_82577) &&
             ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
            ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
@@ -1118,16 +1166,32 @@ static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
 
        hw->phy.addr = 1;
        ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
+       hw->phy.ops.release(hw);
        if (ret_val)
                goto out;
-       hw->phy.ops.release(hw);
 
        /*
         * Configure the K1 Si workaround during phy reset assuming there is
         * link so that it disables K1 if link is in 1Gbps.
         */
        ret_val = e1000_k1_gig_workaround_hv(hw, true);
+       if (ret_val)
+               goto out;
 
+       /* Workaround for link disconnects on a busy hub in half duplex */
+       ret_val = hw->phy.ops.acquire(hw);
+       if (ret_val)
+               goto out;
+       ret_val = hw->phy.ops.read_reg_locked(hw,
+                                             PHY_REG(BM_PORT_CTRL_PAGE, 17),
+                                             &phy_data);
+       if (ret_val)
+               goto release;
+       ret_val = hw->phy.ops.write_reg_locked(hw,
+                                              PHY_REG(BM_PORT_CTRL_PAGE, 17),
+                                              phy_data & 0x00FF);
+release:
+       hw->phy.ops.release(hw);
 out:
        return ret_val;
 }
@@ -1184,6 +1248,7 @@ static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
        /* Allow time for h/w to get to a quiescent state after reset */
        mdelay(10);
 
+       /* Perform any necessary post-reset workarounds */
        if (hw->mac.type == e1000_pchlan) {
                ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
                if (ret_val)
@@ -2484,6 +2549,10 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
        if (!ret_val)
                e1000_release_swflag_ich8lan(hw);
 
+       /* Perform any necessary post-reset workarounds */
+       if (hw->mac.type == e1000_pchlan)
+               ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
+
        if (ctrl & E1000_CTRL_PHY_RST)
                ret_val = hw->phy.ops.get_cfg_done(hw);
 
@@ -2528,9 +2597,6 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
        kab |= E1000_KABGTXD_BGSQLBIAS;
        ew32(KABGTXD, kab);
 
-       if (hw->mac.type == e1000_pchlan)
-               ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
-
 out:
        return ret_val;
 }
index 55a2c0a..7f3ceb9 100644 (file)
@@ -152,32 +152,9 @@ s32 e1000e_get_phy_id(struct e1000_hw *hw)
                if (phy->id != 0 && phy->id != PHY_REVISION_MASK)
                        goto out;
 
-               /*
-                * If the PHY ID is still unknown, we may have an 82577
-                * without link.  We will try again after setting Slow MDIC
-                * mode. No harm in trying again in this case since the PHY
-                * ID is unknown at this point anyway.
-                */
-               ret_val = phy->ops.acquire(hw);
-               if (ret_val)
-                       goto out;
-               ret_val = e1000_set_mdio_slow_mode_hv(hw, true);
-               if (ret_val)
-                       goto out;
-               phy->ops.release(hw);
-
                retry_count++;
        }
 out:
-       /* Revert to MDIO fast mode, if applicable */
-       if (retry_count) {
-               ret_val = phy->ops.acquire(hw);
-               if (ret_val)
-                       return ret_val;
-               ret_val = e1000_set_mdio_slow_mode_hv(hw, false);
-               phy->ops.release(hw);
-       }
-
        return ret_val;
 }
 
@@ -2791,38 +2768,6 @@ static s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
 }
 
 /**
- *  e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
- *  @hw:   pointer to the HW structure
- *  @slow: true for slow mode, false for normal mode
- *
- *  Assumes semaphore already acquired.
- **/
-s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw, bool slow)
-{
-       s32 ret_val = 0;
-       u16 data = 0;
-
-       /* Set MDIO mode - page 769, register 16: 0x2580==slow, 0x2180==fast */
-       hw->phy.addr = 1;
-       ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT,
-                                        (BM_PORT_CTRL_PAGE << IGP_PAGE_SHIFT));
-       if (ret_val)
-               goto out;
-
-       ret_val = e1000e_write_phy_reg_mdic(hw, BM_CS_CTRL1,
-                                          (0x2180 | (slow << 10)));
-       if (ret_val)
-               goto out;
-
-       /* dummy read when reverting to fast mode - throw away result */
-       if (!slow)
-               ret_val = e1000e_read_phy_reg_mdic(hw, BM_CS_CTRL1, &data);
-
-out:
-       return ret_val;
-}
-
-/**
  *  __e1000_read_phy_reg_hv -  Read HV PHY register
  *  @hw: pointer to the HW structure
  *  @offset: register offset to be read
@@ -2839,7 +2784,6 @@ static s32 __e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data,
        s32 ret_val;
        u16 page = BM_PHY_REG_PAGE(offset);
        u16 reg = BM_PHY_REG_NUM(offset);
-       bool in_slow_mode = false;
 
        if (!locked) {
                ret_val = hw->phy.ops.acquire(hw);
@@ -2847,16 +2791,6 @@ static s32 __e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data,
                        return ret_val;
        }
 
-       /* Workaround failure in MDIO access while cable is disconnected */
-       if ((hw->phy.type == e1000_phy_82577) &&
-           !(er32(STATUS) & E1000_STATUS_LU)) {
-               ret_val = e1000_set_mdio_slow_mode_hv(hw, true);
-               if (ret_val)
-                       goto out;
-
-               in_slow_mode = true;
-       }
-
        /* Page 800 works differently than the rest so it has its own func */
        if (page == BM_WUC_PAGE) {
                ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset,
@@ -2893,10 +2827,6 @@ static s32 __e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data,
        ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & reg,
                                          data);
 out:
-       /* Revert to MDIO fast mode, if applicable */
-       if ((hw->phy.type == e1000_phy_82577) && in_slow_mode)
-               ret_val |= e1000_set_mdio_slow_mode_hv(hw, false);
-
        if (!locked)
                hw->phy.ops.release(hw);
 
@@ -2948,7 +2878,6 @@ static s32 __e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data,
        s32 ret_val;
        u16 page = BM_PHY_REG_PAGE(offset);
        u16 reg = BM_PHY_REG_NUM(offset);
-       bool in_slow_mode = false;
 
        if (!locked) {
                ret_val = hw->phy.ops.acquire(hw);
@@ -2956,16 +2885,6 @@ static s32 __e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data,
                        return ret_val;
        }
 
-       /* Workaround failure in MDIO access while cable is disconnected */
-       if ((hw->phy.type == e1000_phy_82577) &&
-           !(er32(STATUS) & E1000_STATUS_LU)) {
-               ret_val = e1000_set_mdio_slow_mode_hv(hw, true);
-               if (ret_val)
-                       goto out;
-
-               in_slow_mode = true;
-       }
-
        /* Page 800 works differently than the rest so it has its own func */
        if (page == BM_WUC_PAGE) {
                ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset,
@@ -3019,10 +2938,6 @@ static s32 __e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data,
                                          data);
 
 out:
-       /* Revert to MDIO fast mode, if applicable */
-       if ((hw->phy.type == e1000_phy_82577) && in_slow_mode)
-               ret_val |= e1000_set_mdio_slow_mode_hv(hw, false);
-
        if (!locked)
                hw->phy.ops.release(hw);
 
index 21b41f4..bfef0eb 100644 (file)
@@ -1,7 +1,7 @@
 ################################################################################
 #
 # Intel 10 Gigabit PCI Express Linux driver
-# Copyright(c) 1999 - 2009 Intel Corporation.
+# Copyright(c) 1999 - 2010 Intel Corporation.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms and conditions of the GNU General Public License,
index 8da8eb5..303e7bd 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index 204177d..3103f41 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index 5383405..b49bd6b 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index 688b8ca..21f158f 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index 27f3214..dfff0ff 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index a156228..9aea4f0 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index 64a9fa1..5caafd4 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index f302638..f0e9279 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index ebbe53c..cc728fa 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index ec8a252..4f7a26a 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index 9e5e282..0f3f791 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index 3c7a79a..56f37f6 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index 0bd49d3..d77961f 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index da32a10..e9a20c8 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index de8ff53..abf4b2b 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index 2ad754c..9c9202f 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
@@ -52,7 +52,7 @@ static const char ixgbe_driver_string[] =
 
 #define DRV_VERSION "2.0.44-k2"
 const char ixgbe_driver_version[] = DRV_VERSION;
-static char ixgbe_copyright[] = "Copyright (c) 1999-2009 Intel Corporation.";
+static char ixgbe_copyright[] = "Copyright (c) 1999-2010 Intel Corporation.";
 
 static const struct ixgbe_info *ixgbe_info_tbl[] = {
        [board_82598] = &ixgbe_82598_info,
@@ -5576,6 +5576,10 @@ static void ixgbe_netpoll(struct net_device *netdev)
        struct ixgbe_adapter *adapter = netdev_priv(netdev);
        int i;
 
+       /* if interface is down do nothing */
+       if (test_bit(__IXGBE_DOWN, &adapter->state))
+               return;
+
        adapter->flags |= IXGBE_FLAG_IN_NETPOLL;
        if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) {
                int num_q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS;
index 9ecad17..1c1efd3 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index 9b700f5..9cf5f3b 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index 84650c6..9eafddf 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2009 Intel Corporation.
+  Copyright(c) 1999 - 2010 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
index 683353b..0d4eba7 100644 (file)
@@ -142,8 +142,9 @@ static int efx_mcdi_poll(struct efx_nic *efx)
                if (spins != 0) {
                        --spins;
                        udelay(1);
-               } else
-                       schedule();
+               } else {
+                       schedule_timeout_uninterruptible(1);
+               }
 
                time = get_seconds();
 
index af39335..250c882 100644 (file)
@@ -79,10 +79,14 @@ struct efx_loopback_state {
 static int efx_test_mdio(struct efx_nic *efx, struct efx_self_tests *tests)
 {
        int rc = 0;
-       int devad = __ffs(efx->mdio.mmds);
+       int devad;
        u16 physid1, physid2;
 
-       if (efx->phy_type == PHY_TYPE_NONE)
+       if (efx->mdio.mode_support & MDIO_SUPPORTS_C45)
+               devad = __ffs(efx->mdio.mmds);
+       else if (efx->mdio.mode_support & MDIO_SUPPORTS_C22)
+               devad = MDIO_DEVAD_NONE;
+       else
                return 0;
 
        mutex_lock(&efx->mac_lock);
index 3a74d21..7f82b02 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2001, 2002, 2003, 2004 David S. Miller (davem@redhat.com)
  * Copyright (C) 2001, 2002, 2003 Jeff Garzik (jgarzik@pobox.com)
  * Copyright (C) 2004 Sun Microsystems Inc.
- * Copyright (C) 2005-2009 Broadcom Corporation.
+ * Copyright (C) 2005-2010 Broadcom Corporation.
  *
  * Firmware is:
  *     Derived from proprietary unpublished source code,
@@ -68,8 +68,8 @@
 
 #define DRV_MODULE_NAME                "tg3"
 #define PFX DRV_MODULE_NAME    ": "
-#define DRV_MODULE_VERSION     "3.105"
-#define DRV_MODULE_RELDATE     "December 2, 2009"
+#define DRV_MODULE_VERSION     "3.106"
+#define DRV_MODULE_RELDATE     "January 12, 2010"
 
 #define TG3_DEF_MAC_MODE       0
 #define TG3_DEF_RX_MODE                0
@@ -1037,7 +1037,11 @@ static void tg3_mdio_start(struct tg3 *tp)
                else
                        tp->phy_addr = 1;
 
-               is_serdes = tr32(SG_DIG_STATUS) & SG_DIG_IS_SERDES;
+               if (tp->pci_chip_rev_id != CHIPREV_ID_5717_A0)
+                       is_serdes = tr32(SG_DIG_STATUS) & SG_DIG_IS_SERDES;
+               else
+                       is_serdes = tr32(TG3_CPMU_PHY_STRAP) &
+                                   TG3_CPMU_PHY_STRAP_IS_SERDES;
                if (is_serdes)
                        tp->phy_addr += 7;
        } else
@@ -4693,8 +4697,9 @@ next_pkt:
                (*post_ptr)++;
 
                if (unlikely(rx_std_posted >= tp->rx_std_max_post)) {
-                       u32 idx = *post_ptr % TG3_RX_RING_SIZE;
-                       tw32_rx_mbox(TG3_RX_STD_PROD_IDX_REG, idx);
+                       tpr->rx_std_prod_idx = std_prod_idx % TG3_RX_RING_SIZE;
+                       tw32_rx_mbox(TG3_RX_STD_PROD_IDX_REG,
+                                    tpr->rx_std_prod_idx);
                        work_mask &= ~RXD_OPAQUE_RING_STD;
                        rx_std_posted = 0;
                }
@@ -7742,7 +7747,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
             ((u64) tpr->rx_std_mapping >> 32));
        tw32(RCVDBDI_STD_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW,
             ((u64) tpr->rx_std_mapping & 0xffffffff));
-       if (!(tp->tg3_flags3 & TG3_FLG3_5755_PLUS))
+       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5717)
                tw32(RCVDBDI_STD_BD + TG3_BDINFO_NIC_ADDR,
                     NIC_SRAM_RX_BUFFER_DESC);
 
@@ -12122,7 +12127,8 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
 
                tp->phy_id = eeprom_phy_id;
                if (eeprom_phy_serdes) {
-                       if (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)
+                       if ((tp->tg3_flags2 & TG3_FLG2_5780_CLASS) ||
+                           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717)
                                tp->tg3_flags2 |= TG3_FLG2_MII_SERDES;
                        else
                                tp->tg3_flags2 |= TG3_FLG2_PHY_SERDES;
@@ -13384,6 +13390,11 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
        if (err)
                return err;
 
+       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 &&
+           (tp->pci_chip_rev_id != CHIPREV_ID_5717_A0 ||
+                (tp->tg3_flags2 & TG3_FLG2_MII_SERDES)))
+               return -ENOTSUPP;
+
        /* Initialize data/descriptor byte/word swapping. */
        val = tr32(GRC_MODE);
        val &= GRC_MODE_HOST_STACKUP;
index cd30889..8a16791 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright (C) 2001, 2002, 2003, 2004 David S. Miller (davem@redhat.com)
  * Copyright (C) 2001 Jeff Garzik (jgarzik@pobox.com)
  * Copyright (C) 2004 Sun Microsystems Inc.
+ * Copyright (C) 2007-2010 Broadcom Corporation.
  */
 
 #ifndef _T3_H
 #define  CPMU_MUTEX_REQ_DRIVER          0x00001000
 #define TG3_CPMU_MUTEX_GNT             0x00003660
 #define  CPMU_MUTEX_GNT_DRIVER          0x00001000
+#define TG3_CPMU_PHY_STRAP             0x00003664
+#define TG3_CPMU_PHY_STRAP_IS_SERDES    0x00000020
 /* 0x3664 --> 0x3800 unused */
 
 /* Mbuf cluster free registers */
index 5d1c867..6a3f4da 100644 (file)
@@ -97,7 +97,7 @@ ath5k_eeprom_init_header(struct ath5k_hw *ah)
        struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
        int ret;
        u16 val;
-       u32 cksum, offset;
+       u32 cksum, offset, eep_max = AR5K_EEPROM_INFO_MAX;
 
        /*
         * Read values from EEPROM and store them in the capability structure
@@ -116,12 +116,38 @@ ath5k_eeprom_init_header(struct ath5k_hw *ah)
         * Validate the checksum of the EEPROM date. There are some
         * devices with invalid EEPROMs.
         */
-       for (cksum = 0, offset = 0; offset < AR5K_EEPROM_INFO_MAX; offset++) {
+       AR5K_EEPROM_READ(AR5K_EEPROM_SIZE_UPPER, val);
+       if (val) {
+               eep_max = (val & AR5K_EEPROM_SIZE_UPPER_MASK) <<
+                          AR5K_EEPROM_SIZE_ENDLOC_SHIFT;
+               AR5K_EEPROM_READ(AR5K_EEPROM_SIZE_LOWER, val);
+               eep_max = (eep_max | val) - AR5K_EEPROM_INFO_BASE;
+
+               /*
+                * Fail safe check to prevent stupid loops due
+                * to busted EEPROMs. XXX: This value is likely too
+                * big still, waiting on a better value.
+                */
+               if (eep_max > (3 * AR5K_EEPROM_INFO_MAX)) {
+                       ATH5K_ERR(ah->ah_sc, "Invalid max custom EEPROM size: "
+                                 "%d (0x%04x) max expected: %d (0x%04x)\n",
+                                 eep_max, eep_max,
+                                 3 * AR5K_EEPROM_INFO_MAX,
+                                 3 * AR5K_EEPROM_INFO_MAX);
+                       return -EIO;
+               }
+       }
+
+       for (cksum = 0, offset = 0; offset < eep_max; offset++) {
                AR5K_EEPROM_READ(AR5K_EEPROM_INFO(offset), val);
                cksum ^= val;
        }
        if (cksum != AR5K_EEPROM_INFO_CKSUM) {
-               ATH5K_ERR(ah->ah_sc, "Invalid EEPROM checksum 0x%04x\n", cksum);
+               ATH5K_ERR(ah->ah_sc, "Invalid EEPROM "
+                         "checksum: 0x%04x eep_max: 0x%04x (%s)\n",
+                         cksum, eep_max,
+                         eep_max == AR5K_EEPROM_INFO_MAX ?
+                               "default size" : "custom size");
                return -EIO;
        }
 
index 0123f35..473a483 100644 (file)
 #define AR5K_EEPROM_RFKILL_POLARITY_S  1
 
 #define AR5K_EEPROM_REG_DOMAIN         0x00bf  /* EEPROM regdom */
+
+/* FLASH(EEPROM) Defines for AR531X chips */
+#define AR5K_EEPROM_SIZE_LOWER         0x1b /* size info -- lower */
+#define AR5K_EEPROM_SIZE_UPPER         0x1c /* size info -- upper */
+#define AR5K_EEPROM_SIZE_UPPER_MASK    0xfff0
+#define AR5K_EEPROM_SIZE_UPPER_SHIFT   4
+#define AR5K_EEPROM_SIZE_ENDLOC_SHIFT  12
+
 #define AR5K_EEPROM_CHECKSUM           0x00c0  /* EEPROM checksum */
 #define AR5K_EEPROM_INFO_BASE          0x00c0  /* EEPROM header */
 #define AR5K_EEPROM_INFO_MAX           (0x400 - AR5K_EEPROM_INFO_BASE)
index 03a1106..5774cea 100644 (file)
@@ -25,7 +25,7 @@ config ATH9K
 
 config ATH9K_DEBUGFS
        bool "Atheros ath9k debugging"
-       depends on ATH9K
+       depends on ATH9K && DEBUG_FS
        ---help---
          Say Y, if you need access to ath9k's statistics for
          interrupts, rate control, etc.
index e2cef2f..1597a42 100644 (file)
@@ -33,11 +33,11 @@ struct ath_node;
 
 /* Macro to expand scalars to 64-bit objects */
 
-#define        ito64(x) (sizeof(x) == 8) ?                     \
+#define        ito64(x) (sizeof(x) == 1) ?                     \
        (((unsigned long long int)(x)) & (0xff)) :      \
-       (sizeof(x) == 16) ?                             \
+       (sizeof(x) == 2) ?                              \
        (((unsigned long long int)(x)) & 0xffff) :      \
-       ((sizeof(x) == 32) ?                            \
+       ((sizeof(x) == 4) ?                             \
         (((unsigned long long int)(x)) & 0xffffffff) : \
         (unsigned long long int)(x))
 
index 484c5fd..9b4b8b5 100644 (file)
@@ -1961,7 +1961,7 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
        struct ieee80211_tx_info *info;
        struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
        u32  status = le32_to_cpu(tx_resp->u.status);
-       int tid = MAX_TID_COUNT;
+       int uninitialized_var(tid);
        int sta_id;
        int freed;
        u8 *qc = NULL;
index 574d366..5461f10 100644 (file)
@@ -2344,6 +2344,21 @@ static void iwl_ht_conf(struct iwl_priv *priv,
        IWL_DEBUG_MAC80211(priv, "leave\n");
 }
 
+static inline void iwl_set_no_assoc(struct iwl_priv *priv)
+{
+       priv->assoc_id = 0;
+       iwl_led_disassociate(priv);
+       /*
+        * inform the ucode that there is no longer an
+        * association and that no more packets should be
+        * sent
+        */
+       priv->staging_rxon.filter_flags &=
+               ~RXON_FILTER_ASSOC_MSK;
+       priv->staging_rxon.assoc_id = 0;
+       iwlcore_commit_rxon(priv);
+}
+
 #define IWL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6)
 void iwl_bss_info_changed(struct ieee80211_hw *hw,
                          struct ieee80211_vif *vif,
@@ -2475,20 +2490,8 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
                                        IWL_DELAY_NEXT_SCAN_AFTER_ASSOC;
                        if (!iwl_is_rfkill(priv))
                                priv->cfg->ops->lib->post_associate(priv);
-               } else {
-                       priv->assoc_id = 0;
-                       iwl_led_disassociate(priv);
-
-                       /*
-                        * inform the ucode that there is no longer an
-                        * association and that no more packets should be
-                        * send
-                        */
-                       priv->staging_rxon.filter_flags &=
-                               ~RXON_FILTER_ASSOC_MSK;
-                       priv->staging_rxon.assoc_id = 0;
-                       iwlcore_commit_rxon(priv);
-               }
+               } else
+                       iwl_set_no_assoc(priv);
        }
 
        if (changes && iwl_is_associated(priv) && priv->assoc_id) {
@@ -2503,12 +2506,14 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
                }
        }
 
-       if ((changes & BSS_CHANGED_BEACON_ENABLED) &&
-           vif->bss_conf.enable_beacon) {
-               memcpy(priv->staging_rxon.bssid_addr,
-                      bss_conf->bssid, ETH_ALEN);
-               memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN);
-               iwlcore_config_ap(priv);
+       if (changes & BSS_CHANGED_BEACON_ENABLED) {
+               if (vif->bss_conf.enable_beacon) {
+                       memcpy(priv->staging_rxon.bssid_addr,
+                              bss_conf->bssid, ETH_ALEN);
+                       memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN);
+                       iwlcore_config_ap(priv);
+               } else
+                       iwl_set_no_assoc(priv);
        }
 
        mutex_unlock(&priv->mutex);
index 165d1f6..3822cf5 100644 (file)
@@ -711,7 +711,7 @@ extern void iwl_txq_ctx_stop(struct iwl_priv *priv);
 extern int iwl_queue_space(const struct iwl_queue *q);
 static inline int iwl_queue_used(const struct iwl_queue *q, int i)
 {
-       return q->write_ptr > q->read_ptr ?
+       return q->write_ptr >= q->read_ptr ?
                (i >= q->read_ptr && i < q->write_ptr) :
                !(i < q->read_ptr && i >= q->write_ptr);
 }
index 59d4915..59f9210 100644 (file)
@@ -3157,8 +3157,10 @@ static void mwl8k_configure_filter(struct ieee80211_hw *hw,
        /* Clear unsupported feature flags */
        *total_flags &= FIF_ALLMULTI | FIF_BCN_PRBRESP_PROMISC;
 
-       if (mwl8k_fw_lock(hw))
+       if (mwl8k_fw_lock(hw)) {
+               kfree(cmd);
                return;
+       }
 
        if (priv->sniffer_enabled) {
                mwl8k_enable_sniffer(hw, 0);
index 27bf887..9deae41 100644 (file)
@@ -340,7 +340,7 @@ static int rt2800_blink_set(struct led_classdev *led_cdev,
        rt2x00_set_field32(&reg, LED_CFG_OFF_PERIOD, *delay_off);
        rt2x00_set_field32(&reg, LED_CFG_SLOW_BLINK_PERIOD, 3);
        rt2x00_set_field32(&reg, LED_CFG_R_LED_MODE, 3);
-       rt2x00_set_field32(&reg, LED_CFG_G_LED_MODE, 12);
+       rt2x00_set_field32(&reg, LED_CFG_G_LED_MODE, 3);
        rt2x00_set_field32(&reg, LED_CFG_Y_LED_MODE, 3);
        rt2x00_set_field32(&reg, LED_CFG_LED_POLAR, 1);
        rt2800_register_write(led->rt2x00dev, LED_CFG, reg);
index 4d841c0..dcfc8c2 100644 (file)
        (  ((unsigned long)((__skb)->data + (__header))) & 3 )
 
 /*
+ * Constants for extra TX headroom for alignment purposes.
+ */
+#define RT2X00_ALIGN_SIZE      4 /* Only whole frame needs alignment */
+#define RT2X00_L2PAD_SIZE      8 /* Both header & payload need alignment */
+
+/*
  * Standard timing and size defines.
  * These values should follow the ieee80211 specifications.
  */
index 06c43ca..265e66d 100644 (file)
@@ -686,7 +686,17 @@ static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev)
        /*
         * Initialize extra TX headroom required.
         */
-       rt2x00dev->hw->extra_tx_headroom = rt2x00dev->ops->extra_tx_headroom;
+       rt2x00dev->hw->extra_tx_headroom =
+               max_t(unsigned int, IEEE80211_TX_STATUS_HEADROOM,
+                     rt2x00dev->ops->extra_tx_headroom);
+
+       /*
+        * Take TX headroom required for alignment into account.
+        */
+       if (test_bit(DRIVER_REQUIRE_L2PAD, &rt2x00dev->flags))
+               rt2x00dev->hw->extra_tx_headroom += RT2X00_L2PAD_SIZE;
+       else if (test_bit(DRIVER_REQUIRE_DMA, &rt2x00dev->flags))
+               rt2x00dev->hw->extra_tx_headroom += RT2X00_ALIGN_SIZE;
 
        /*
         * Register HW.
index 239afc7..9915a09 100644 (file)
@@ -104,7 +104,7 @@ void rt2x00queue_map_txskb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb)
         * is also mapped to the DMA so it can be used for transfering
         * additional descriptor information to the hardware.
         */
-       skb_push(skb, rt2x00dev->hw->extra_tx_headroom);
+       skb_push(skb, rt2x00dev->ops->extra_tx_headroom);
 
        skbdesc->skb_dma =
            dma_map_single(rt2x00dev->dev, skb->data, skb->len, DMA_TO_DEVICE);
@@ -112,7 +112,7 @@ void rt2x00queue_map_txskb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb)
        /*
         * Restore data pointer to original location again.
         */
-       skb_pull(skb, rt2x00dev->hw->extra_tx_headroom);
+       skb_pull(skb, rt2x00dev->ops->extra_tx_headroom);
 
        skbdesc->flags |= SKBDESC_DMA_MAPPED_TX;
 }
@@ -134,7 +134,7 @@ void rt2x00queue_unmap_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb)
                 * by the driver, but it was actually mapped to DMA.
                 */
                dma_unmap_single(rt2x00dev->dev, skbdesc->skb_dma,
-                                skb->len + rt2x00dev->hw->extra_tx_headroom,
+                                skb->len + rt2x00dev->ops->extra_tx_headroom,
                                 DMA_TO_DEVICE);
                skbdesc->flags &= ~SKBDESC_DMA_MAPPED_TX;
        }
index 8ebf5c3..f14deb0 100644 (file)
@@ -987,12 +987,13 @@ static void zd_op_configure_filter(struct ieee80211_hw *hw,
        changed_flags &= SUPPORTED_FIF_FLAGS;
        *new_flags &= SUPPORTED_FIF_FLAGS;
 
-       /* changed_flags is always populated but this driver
-        * doesn't support all FIF flags so its possible we don't
-        * need to do anything */
-       if (!changed_flags)
-               return;
-
+       /*
+        * If multicast parameter (as returned by zd_op_prepare_multicast)
+        * has changed, no bit in changed_flags is set. To handle this
+        * situation, we do not return if changed_flags is 0. If we do so,
+        * we will have some issue with IPv6 which uses multicast for link
+        * layer address resolution.
+        */
        if (*new_flags & (FIF_PROMISC_IN_BSS | FIF_ALLMULTI))
                zd_mc_add_all(&hash);
 
index 5819dc0..1c500c4 100644 (file)
@@ -23,6 +23,7 @@
 #include <asm/debug.h>
 #include <asm/idals.h>
 #include <asm/ebcdic.h>
+#include <asm/compat.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/cio.h>
@@ -2844,13 +2845,16 @@ static int dasd_symm_io(struct dasd_device *device, void __user *argp)
        rc = -EFAULT;
        if (copy_from_user(&usrparm, argp, sizeof(usrparm)))
                goto out;
-#ifndef CONFIG_64BIT
-       /* Make sure pointers are sane even on 31 bit. */
-       if ((usrparm.psf_data >> 32) != 0 || (usrparm.rssd_result >> 32) != 0) {
+       if (is_compat_task() || sizeof(long) == 4) {
+               /* Make sure pointers are sane even on 31 bit. */
                rc = -EINVAL;
-               goto out;
+               if ((usrparm.psf_data >> 32) != 0)
+                       goto out;
+               if ((usrparm.rssd_result >> 32) != 0)
+                       goto out;
+               usrparm.psf_data &= 0x7fffffffULL;
+               usrparm.rssd_result &= 0x7fffffffULL;
        }
-#endif
        /* alloc I/O data area */
        psf_data = kzalloc(usrparm.psf_data_len, GFP_KERNEL | GFP_DMA);
        rssd_result = kzalloc(usrparm.rssd_result_len, GFP_KERNEL | GFP_DMA);
index 478bcdb..fc7b30b 100644 (file)
@@ -17,7 +17,7 @@
 #include <linux/fs.h>
 #include <linux/blkpg.h>
 #include <linux/smp_lock.h>
-
+#include <asm/compat.h>
 #include <asm/ccwdev.h>
 #include <asm/cmb.h>
 #include <asm/uaccess.h>
@@ -358,9 +358,8 @@ dasd_ioctl_set_ro(struct block_device *bdev, void __user *argp)
 }
 
 static int dasd_ioctl_readall_cmb(struct dasd_block *block, unsigned int cmd,
-               unsigned long arg)
+                                 struct cmbdata __user *argp)
 {
-       struct cmbdata __user *argp = (void __user *) arg;
        size_t size = _IOC_SIZE(cmd);
        struct cmbdata data;
        int ret;
@@ -376,7 +375,12 @@ dasd_do_ioctl(struct block_device *bdev, fmode_t mode,
              unsigned int cmd, unsigned long arg)
 {
        struct dasd_block *block = bdev->bd_disk->private_data;
-       void __user *argp = (void __user *)arg;
+       void __user *argp;
+
+       if (is_compat_task())
+               argp = compat_ptr(arg);
+       else
+               argp = (void __user *)arg;
 
        if (!block)
                 return -ENODEV;
@@ -414,7 +418,7 @@ dasd_do_ioctl(struct block_device *bdev, fmode_t mode,
        case BIODASDCMFDISABLE:
                return disable_cmf(block->base->cdev);
        case BIODASDREADALLCMB:
-               return dasd_ioctl_readall_cmb(block, cmd, arg);
+               return dasd_ioctl_readall_cmb(block, cmd, argp);
        default:
                /* if the discipline has an ioctl method try it. */
                if (block->base->discipline->ioctl) {
index 9d61683..59ec073 100644 (file)
@@ -1037,22 +1037,6 @@ static void tty3215_flush_buffer(struct tty_struct *tty)
 }
 
 /*
- * Currently we don't have any io controls for 3215 ttys
- */
-static int tty3215_ioctl(struct tty_struct *tty, struct file * file,
-                        unsigned int cmd, unsigned long arg)
-{
-       if (tty->flags & (1 << TTY_IO_ERROR))
-               return -EIO;
-
-       switch (cmd) {
-       default:
-               return -ENOIOCTLCMD;
-       }
-       return 0;
-}
-
-/*
  * Disable reading from a 3215 tty
  */
 static void tty3215_throttle(struct tty_struct * tty)
@@ -1117,7 +1101,6 @@ static const struct tty_operations tty3215_ops = {
        .write_room = tty3215_write_room,
        .chars_in_buffer = tty3215_chars_in_buffer,
        .flush_buffer = tty3215_flush_buffer,
-       .ioctl = tty3215_ioctl,
        .throttle = tty3215_throttle,
        .unthrottle = tty3215_unthrottle,
        .stop = tty3215_stop,
index 247b2b9..31c59b0 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/types.h>
 #include <linux/smp_lock.h>
 
+#include <asm/compat.h>
 #include <asm/ccwdev.h>
 #include <asm/cio.h>
 #include <asm/ebcdic.h>
@@ -322,6 +323,7 @@ fs3270_write(struct file *filp, const char __user *data, size_t count, loff_t *o
 static long
 fs3270_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
+       char __user *argp;
        struct fs3270 *fp;
        struct raw3270_iocb iocb;
        int rc;
@@ -329,6 +331,10 @@ fs3270_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        fp = filp->private_data;
        if (!fp)
                return -ENODEV;
+       if (is_compat_task())
+               argp = compat_ptr(arg);
+       else
+               argp = (char __user *)arg;
        rc = 0;
        mutex_lock(&fs3270_mutex);
        switch (cmd) {
@@ -339,10 +345,10 @@ fs3270_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
                fp->write_command = arg;
                break;
        case TUBGETI:
-               rc = put_user(fp->read_command, (char __user *) arg);
+               rc = put_user(fp->read_command, argp);
                break;
        case TUBGETO:
-               rc = put_user(fp->write_command,(char __user *) arg);
+               rc = put_user(fp->write_command, argp);
                break;
        case TUBGETMOD:
                iocb.model = fp->view.model;
@@ -351,8 +357,7 @@ fs3270_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
                iocb.pf_cnt = 24;
                iocb.re_cnt = 20;
                iocb.map = 0;
-               if (copy_to_user((char __user *) arg, &iocb,
-                                sizeof(struct raw3270_iocb)))
+               if (copy_to_user(argp, &iocb, sizeof(struct raw3270_iocb)))
                        rc = -EFAULT;
                break;
        }
@@ -511,8 +516,8 @@ static const struct file_operations fs3270_fops = {
        .write           = fs3270_write,        /* write */
        .unlocked_ioctl  = fs3270_ioctl,        /* ioctl */
        .compat_ioctl    = fs3270_ioctl,        /* ioctl */
-       .open           = fs3270_open,          /* open */
-       .release        = fs3270_close,         /* release */
+       .open            = fs3270_open,         /* open */
+       .release         = fs3270_close,        /* release */
 };
 
 /*
index 9681614..8d3d720 100644 (file)
@@ -46,8 +46,6 @@
  */
 static int tapeblock_open(struct block_device *, fmode_t);
 static int tapeblock_release(struct gendisk *, fmode_t);
-static int tapeblock_ioctl(struct block_device *, fmode_t, unsigned int,
-                               unsigned long);
 static int tapeblock_medium_changed(struct gendisk *);
 static int tapeblock_revalidate_disk(struct gendisk *);
 
@@ -55,7 +53,6 @@ static const struct block_device_operations tapeblock_fops = {
        .owner           = THIS_MODULE,
        .open            = tapeblock_open,
        .release         = tapeblock_release,
-       .ioctl           = tapeblock_ioctl,
        .media_changed   = tapeblock_medium_changed,
        .revalidate_disk = tapeblock_revalidate_disk,
 };
@@ -416,42 +413,6 @@ tapeblock_release(struct gendisk *disk, fmode_t mode)
 }
 
 /*
- * Support of some generic block device IOCTLs.
- */
-static int
-tapeblock_ioctl(
-       struct block_device *   bdev,
-       fmode_t                 mode,
-       unsigned int            command,
-       unsigned long           arg
-) {
-       int rc;
-       int minor;
-       struct gendisk *disk = bdev->bd_disk;
-       struct tape_device *device;
-
-       rc     = 0;
-       BUG_ON(!disk);
-       device = disk->private_data;
-       BUG_ON(!device);
-       minor  = MINOR(bdev->bd_dev);
-
-       DBF_LH(6, "tapeblock_ioctl(0x%0x)\n", command);
-       DBF_LH(6, "device = %d:%d\n", tapeblock_major, minor);
-
-       switch (command) {
-               /* Refuse some IOCTL calls without complaining (mount). */
-               case 0x5310:            /* CDROMMULTISESSION */
-                       rc = -EINVAL;
-                       break;
-               default:
-                       rc = -EINVAL;
-       }
-
-       return rc;
-}
-
-/*
  * Initialize block device frontend.
  */
 int
index 2125ec7..539045a 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/proc_fs.h>
 #include <linux/mtio.h>
 #include <linux/smp_lock.h>
+#include <linux/compat.h>
 
 #include <asm/uaccess.h>
 
@@ -37,8 +38,9 @@ static ssize_t tapechar_write(struct file *, const char __user *, size_t, loff_t
 static int tapechar_open(struct inode *,struct file *);
 static int tapechar_release(struct inode *,struct file *);
 static long tapechar_ioctl(struct file *, unsigned int, unsigned long);
-static long tapechar_compat_ioctl(struct file *, unsigned int,
-                         unsigned long);
+#ifdef CONFIG_COMPAT
+static long tapechar_compat_ioctl(struct file *, unsigned int, unsigned long);
+#endif
 
 static const struct file_operations tape_fops =
 {
@@ -46,7 +48,9 @@ static const struct file_operations tape_fops =
        .read = tapechar_read,
        .write = tapechar_write,
        .unlocked_ioctl = tapechar_ioctl,
+#ifdef CONFIG_COMPAT
        .compat_ioctl = tapechar_compat_ioctl,
+#endif
        .open = tapechar_open,
        .release = tapechar_release,
 };
@@ -457,15 +461,22 @@ tapechar_ioctl(struct file *filp, unsigned int no, unsigned long data)
        return rc;
 }
 
+#ifdef CONFIG_COMPAT
 static long
 tapechar_compat_ioctl(struct file *filp, unsigned int no, unsigned long data)
 {
        struct tape_device *device = filp->private_data;
        int rval = -ENOIOCTLCMD;
+       unsigned long argp;
 
+       /* The 'arg' argument of any ioctl function may only be used for
+        * pointers because of the compat pointer conversion.
+        * Consider this when adding new ioctls.
+        */
+       argp = (unsigned long) compat_ptr(data);
        if (device->discipline->ioctl_fn) {
                mutex_lock(&device->mutex);
-               rval = device->discipline->ioctl_fn(device, no, data);
+               rval = device->discipline->ioctl_fn(device, no, argp);
                mutex_unlock(&device->mutex);
                if (rval == -EINVAL)
                        rval = -ENOIOCTLCMD;
@@ -473,6 +484,7 @@ tapechar_compat_ioctl(struct file *filp, unsigned int no, unsigned long data)
 
        return rval;
 }
+#endif /* CONFIG_COMPAT */
 
 /*
  * Initialize character device frontend.
index a6087ce..921dcda 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/kernel.h>
 #include <linux/miscdevice.h>
 #include <linux/module.h>
+#include <asm/compat.h>
 #include <asm/cpcmd.h>
 #include <asm/debug.h>
 #include <asm/uaccess.h>
@@ -139,21 +140,26 @@ vmcp_write(struct file *file, const char __user *buff, size_t count,
 static long vmcp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
        struct vmcp_session *session;
+       int __user *argp;
        int temp;
 
        session = (struct vmcp_session *)file->private_data;
+       if (is_compat_task())
+               argp = compat_ptr(arg);
+       else
+               argp = (int __user *)arg;
        if (mutex_lock_interruptible(&session->mutex))
                return -ERESTARTSYS;
        switch (cmd) {
        case VMCP_GETCODE:
                temp = session->resp_code;
                mutex_unlock(&session->mutex);
-               return put_user(temp, (int __user *)arg);
+               return put_user(temp, argp);
        case VMCP_SETBUF:
                free_pages((unsigned long)session->response,
                                get_order(session->bufsize));
                session->response=NULL;
-               temp = get_user(session->bufsize, (int __user *)arg);
+               temp = get_user(session->bufsize, argp);
                if (get_order(session->bufsize) > 8) {
                        session->bufsize = PAGE_SIZE;
                        temp = -EINVAL;
@@ -163,7 +169,7 @@ static long vmcp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        case VMCP_GETSIZE:
                temp = session->resp_size;
                mutex_unlock(&session->mutex);
-               return put_user(temp, (int __user *)arg);
+               return put_user(temp, argp);
        default:
                mutex_unlock(&session->mutex);
                return -ENOIOCTLCMD;
index cc5144b..c84ac94 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/uaccess.h>
 #include <linux/miscdevice.h>
 
+#include <asm/compat.h>
 #include <asm/cio.h>
 #include <asm/chsc.h>
 #include <asm/isc.h>
@@ -770,24 +771,30 @@ out_free:
 static long chsc_ioctl(struct file *filp, unsigned int cmd,
                       unsigned long arg)
 {
+       void __user *argp;
+
        CHSC_MSG(2, "chsc_ioctl called, cmd=%x\n", cmd);
+       if (is_compat_task())
+               argp = compat_ptr(arg);
+       else
+               argp = (void __user *)arg;
        switch (cmd) {
        case CHSC_START:
-               return chsc_ioctl_start((void __user *)arg);
+               return chsc_ioctl_start(argp);
        case CHSC_INFO_CHANNEL_PATH:
-               return chsc_ioctl_info_channel_path((void __user *)arg);
+               return chsc_ioctl_info_channel_path(argp);
        case CHSC_INFO_CU:
-               return chsc_ioctl_info_cu((void __user *)arg);
+               return chsc_ioctl_info_cu(argp);
        case CHSC_INFO_SCH_CU:
-               return chsc_ioctl_info_sch_cu((void __user *)arg);
+               return chsc_ioctl_info_sch_cu(argp);
        case CHSC_INFO_CI:
-               return chsc_ioctl_conf_info((void __user *)arg);
+               return chsc_ioctl_conf_info(argp);
        case CHSC_INFO_CCL:
-               return chsc_ioctl_conf_comp_list((void __user *)arg);
+               return chsc_ioctl_conf_comp_list(argp);
        case CHSC_INFO_CPD:
-               return chsc_ioctl_chpd((void __user *)arg);
+               return chsc_ioctl_chpd(argp);
        case CHSC_INFO_DCAL:
-               return chsc_ioctl_dcal((void __user *)arg);
+               return chsc_ioctl_dcal(argp);
        default: /* unknown ioctl number */
                return -ENOIOCTLCMD;
        }
index 0d4d18b..c68be24 100644 (file)
@@ -393,10 +393,12 @@ static long zcrypt_rsa_crt(struct ica_rsa_modexpo_crt *crt)
                         * u_mult_inv > 128 bytes.
                         */
                        if (copied == 0) {
-                               int len;
+                               unsigned int len;
                                spin_unlock_bh(&zcrypt_device_lock);
                                /* len is max 256 / 2 - 120 = 8 */
                                len = crt->inputdatalength / 2 - 120;
+                               if (len > sizeof(z1))
+                                       return -EFAULT;
                                z1 = z2 = z3 = 0;
                                if (copy_from_user(&z1, crt->np_prime, len) ||
                                    copy_from_user(&z2, crt->bp_key, len) ||
index 36ede02..b5496a1 100644 (file)
@@ -354,6 +354,8 @@ static const struct pnp_device_id pnp_dev_table[] = {
        {       "FUJ02E5",              0       },
        /* Fujitsu P-series tablet PC device */
        {       "FUJ02E6",              0       },
+       /* Fujitsu Wacom 2FGT Tablet PC device */
+       {       "FUJ02E7",              0       },
        /*
         * LG C1 EXPRESS DUAL (C1-PB11A3) touch screen (actually a FUJ02E6 in
         * disguise)
index 37f0de9..42f3333 100644 (file)
@@ -1052,7 +1052,18 @@ static void __devinit sci_init_single(struct platform_device *dev,
        sci_port->port.ops      = &sci_uart_ops;
        sci_port->port.iotype   = UPIO_MEM;
        sci_port->port.line     = index;
-       sci_port->port.fifosize = 1;
+
+       switch (p->type) {
+       case PORT_SCIFA:
+               sci_port->port.fifosize = 64;
+               break;
+       case PORT_SCIF:
+               sci_port->port.fifosize = 16;
+               break;
+       default:
+               sci_port->port.fifosize = 1;
+               break;
+       }
 
        if (dev) {
                sci_port->iclk = p->clk ? clk_get(&dev->dev, p->clk) : NULL;
index e4df813..1eb079b 100644 (file)
@@ -860,10 +860,8 @@ int medusa_video_init(struct cx25821_dev *dev)
 
        ret_val = medusa_set_videostandard(dev);
 
-       if (ret_val < 0) {
-               mutex_unlock(&dev->lock);
+       if (ret_val < 0)
                return -EINVAL;
-       }
 
        return 1;
 }
index adf9632..53cb722 100644 (file)
@@ -211,21 +211,23 @@ static int s3c_fb_check_var(struct fb_var_screeninfo *var,
 
 /**
  * s3c_fb_calc_pixclk() - calculate the divider to create the pixel clock.
- * @id: window id.
  * @sfb: The hardware state.
  * @pixclock: The pixel clock wanted, in picoseconds.
  *
  * Given the specified pixel clock, work out the necessary divider to get
  * close to the output frequency.
  */
-static int s3c_fb_calc_pixclk(unsigned char id, struct s3c_fb *sfb, unsigned int pixclk)
+static int s3c_fb_calc_pixclk(struct s3c_fb *sfb, unsigned int pixclk)
 {
-       struct s3c_fb_pd_win *win = sfb->pdata->win[id];
        unsigned long clk = clk_get_rate(sfb->bus_clk);
+       unsigned long long tmp;
        unsigned int result;
 
-       pixclk *= win->win_mode.refresh;
-       result = clk / pixclk;
+       tmp = (unsigned long long)clk;
+       tmp *= pixclk;
+
+       do_div(tmp, 1000000000UL);
+       result = (unsigned int)tmp / 1000;
 
        dev_dbg(sfb->dev, "pixclk=%u, clk=%lu, div=%d (%lu)\n",
                pixclk, clk, result, clk / result);
@@ -301,7 +303,7 @@ static int s3c_fb_set_par(struct fb_info *info)
        /* use window 0 as the basis for the lcd output timings */
 
        if (win_no == 0) {
-               clkdiv = s3c_fb_calc_pixclk(win_no, sfb, var->pixclock);
+               clkdiv = s3c_fb_calc_pixclk(sfb, var->pixclock);
 
                data = sfb->pdata->vidcon0;
                data &= ~(VIDCON0_CLKVAL_F_MASK | VIDCON0_CLKDIR);
index 9d4f3a4..d5077df 100644 (file)
@@ -137,7 +137,7 @@ static int hw_bitblt_1(void __iomem *engine, u8 op, u32 width, u32 height,
                        tmp, dst_pitch);
                return -EINVAL;
        }
-       tmp = (tmp >> 3) | (dst_pitch << (16 - 3));
+       tmp = VIA_PITCH_ENABLE | (tmp >> 3) | (dst_pitch << (16 - 3));
        writel(tmp, engine + 0x38);
 
        if (op == VIA_BITBLT_FILL)
@@ -352,6 +352,9 @@ int viafb_init_engine(struct fb_info *info)
        viapar->shared->vq_vram_addr = viapar->fbmem_free;
        viapar->fbmem_used += VQ_SIZE;
 
+       /* Init 2D engine reg to reset 2D engine */
+       writel(0x0, engine + VIA_REG_KEYCONTROL);
+
        /* Init AGP and VQ regs */
        switch (chip_name) {
        case UNICHROME_K8M890:
index d8df17a..3028e7d 100644 (file)
@@ -177,16 +177,15 @@ static int viafb_set_par(struct fb_info *info)
        }
 
        if (vmode_index != VIA_RES_INVALID) {
-               viafb_setmode(vmode_index, info->var.xres, info->var.yres,
-                       info->var.bits_per_pixel, vmode_index1,
-                       viafb_second_xres, viafb_second_yres, viafb_bpp1);
-
                viafb_update_fix(info);
                viafb_bpp = info->var.bits_per_pixel;
                if (info->var.accel_flags & FB_ACCELF_TEXT)
                        info->flags &= ~FBINFO_HWACCEL_DISABLED;
                else
                        info->flags |= FBINFO_HWACCEL_DISABLED;
+               viafb_setmode(vmode_index, info->var.xres, info->var.yres,
+                       info->var.bits_per_pixel, vmode_index1,
+                       viafb_second_xres, viafb_second_yres, viafb_bpp1);
        }
 
        return 0;
@@ -872,7 +871,9 @@ static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
        if (info->flags & FBINFO_HWACCEL_DISABLED || info != viafbinfo)
                return -ENODEV;
 
-       if (chip_name == UNICHROME_CLE266 && viapar->iga_path == IGA2)
+       /* LCD ouput does not support hw cursors (at least on VN896) */
+       if ((chip_name == UNICHROME_CLE266 && viapar->iga_path == IGA2) ||
+               viafb_LCD_ON)
                return -ENODEV;
 
        viafb_show_hw_cursor(info, HW_Cursor_OFF);
index 9dd5880..505be88 100644 (file)
@@ -266,7 +266,7 @@ static void __devexit virtballoon_remove(struct virtio_device *vdev)
 
 static unsigned int features[] = { VIRTIO_BALLOON_F_MUST_TELL_HOST };
 
-static struct virtio_driver virtio_balloon = {
+static struct virtio_driver virtio_balloon_driver = {
        .feature_table = features,
        .feature_table_size = ARRAY_SIZE(features),
        .driver.name =  KBUILD_MODNAME,
@@ -279,12 +279,12 @@ static struct virtio_driver virtio_balloon = {
 
 static int __init init(void)
 {
-       return register_virtio_driver(&virtio_balloon);
+       return register_virtio_driver(&virtio_balloon_driver);
 }
 
 static void __exit fini(void)
 {
-       unregister_virtio_driver(&virtio_balloon);
+       unregister_virtio_driver(&virtio_balloon_driver);
 }
 module_init(init);
 module_exit(fini);
index c499793..5d42d55 100644 (file)
@@ -102,15 +102,15 @@ static void do_suspend(void)
                goto out_thaw;
        }
 
+       printk(KERN_DEBUG "suspending xenstore...\n");
+       xs_suspend();
+
        err = dpm_suspend_noirq(PMSG_SUSPEND);
        if (err) {
                printk(KERN_ERR "dpm_suspend_noirq failed: %d\n", err);
                goto out_resume;
        }
 
-       printk(KERN_DEBUG "suspending xenstore...\n");
-       xs_suspend();
-
        err = stop_machine(xen_suspend, &cancelled, cpumask_of(0));
 
        dpm_resume_noirq(PMSG_RESUME);
@@ -120,13 +120,13 @@ static void do_suspend(void)
                cancelled = 1;
        }
 
+out_resume:
        if (!cancelled) {
                xen_arch_resume();
                xs_resume();
        } else
                xs_suspend_cancel();
 
-out_resume:
        dpm_resume_end(PMSG_RESUME);
 
        /* Make sure timer events get retriggered on all CPUs */
index 18f74ec..9d03d1e 100644 (file)
@@ -1001,44 +1001,6 @@ done:
 }
 
 /**
- * v9fs_vfs_readlink - read a symlink's location
- * @dentry: dentry for symlink
- * @buffer: buffer to load symlink location into
- * @buflen: length of buffer
- *
- */
-
-static int v9fs_vfs_readlink(struct dentry *dentry, char __user * buffer,
-                            int buflen)
-{
-       int retval;
-       int ret;
-       char *link = __getname();
-
-       if (unlikely(!link))
-               return -ENOMEM;
-
-       if (buflen > PATH_MAX)
-               buflen = PATH_MAX;
-
-       P9_DPRINTK(P9_DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_name.name,
-                                                                       dentry);
-
-       retval = v9fs_readlink(dentry, link, buflen);
-
-       if (retval > 0) {
-               if ((ret = copy_to_user(buffer, link, retval)) != 0) {
-                       P9_DPRINTK(P9_DEBUG_ERROR,
-                                       "problem copying to user: %d\n", ret);
-                       retval = ret;
-               }
-       }
-
-       __putname(link);
-       return retval;
-}
-
-/**
  * v9fs_vfs_follow_link - follow a symlink path
  * @dentry: dentry for symlink
  * @nd: nameidata
@@ -1230,7 +1192,6 @@ static const struct inode_operations v9fs_dir_inode_operations_ext = {
        .rmdir = v9fs_vfs_rmdir,
        .mknod = v9fs_vfs_mknod,
        .rename = v9fs_vfs_rename,
-       .readlink = v9fs_vfs_readlink,
        .getattr = v9fs_vfs_getattr,
        .setattr = v9fs_vfs_setattr,
 };
@@ -1253,7 +1214,7 @@ static const struct inode_operations v9fs_file_inode_operations = {
 };
 
 static const struct inode_operations v9fs_symlink_inode_operations = {
-       .readlink = v9fs_vfs_readlink,
+       .readlink = generic_readlink,
        .follow_link = v9fs_vfs_follow_link,
        .put_link = v9fs_vfs_put_link,
        .getattr = v9fs_vfs_getattr,
index fea9e89..b44ce0a 100644 (file)
@@ -269,7 +269,7 @@ static int add_mount_helper(struct vfsmount *newmnt, struct nameidata *nd,
        int err;
 
        mntget(newmnt);
-       err = do_add_mount(newmnt, &nd->path, nd->path.mnt->mnt_flags, mntlist);
+       err = do_add_mount(newmnt, &nd->path, nd->path.mnt->mnt_flags | MNT_SHRINKABLE, mntlist);
        switch (err) {
        case 0:
                path_put(&nd->path);
@@ -371,7 +371,6 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
        if (IS_ERR(mnt))
                goto out_err;
 
-       nd->path.mnt->mnt_flags |= MNT_SHRINKABLE;
        rc = add_mount_helper(mnt, nd, &cifs_dfs_automount_list);
 
 out:
index c8afa6b..32a5f46 100644 (file)
@@ -121,8 +121,10 @@ static int get_target(const char *symname, struct path *path,
                                ret = -ENOENT;
                                path_put(path);
                        }
-               } else
+               } else {
                        ret = -EPERM;
+                       path_put(path);
+               }
        }
 
        return ret;
index 429ca0b..7f85450 100644 (file)
@@ -715,31 +715,31 @@ static void *ecryptfs_follow_link(struct dentry *dentry, struct nameidata *nd)
        /* Released in ecryptfs_put_link(); only release here on error */
        buf = kmalloc(len, GFP_KERNEL);
        if (!buf) {
-               rc = -ENOMEM;
+               buf = ERR_PTR(-ENOMEM);
                goto out;
        }
        old_fs = get_fs();
        set_fs(get_ds());
        rc = dentry->d_inode->i_op->readlink(dentry, (char __user *)buf, len);
        set_fs(old_fs);
-       if (rc < 0)
-               goto out_free;
-       else
+       if (rc < 0) {
+               kfree(buf);
+               buf = ERR_PTR(rc);
+       } else
                buf[rc] = '\0';
-       rc = 0;
-       nd_set_link(nd, buf);
-       goto out;
-out_free:
-       kfree(buf);
 out:
-       return ERR_PTR(rc);
+       nd_set_link(nd, buf);
+       return NULL;
 }
 
 static void
 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
 {
-       /* Free the char* */
-       kfree(nd_get_link(nd));
+       char *buf = nd_get_link(nd);
+       if (!IS_ERR(buf)) {
+               /* Free the char* */
+               kfree(buf);
+       }
 }
 
 /**
index 2cf93ec..97e01dc 100644 (file)
@@ -618,60 +618,90 @@ static DEFINE_RWLOCK(fasync_lock);
 static struct kmem_cache *fasync_cache __read_mostly;
 
 /*
- * fasync_helper() is used by almost all character device drivers
- * to set up the fasync queue. It returns negative on error, 0 if it did
- * no changes and positive if it added/deleted the entry.
+ * Remove a fasync entry. If successfully removed, return
+ * positive and clear the FASYNC flag. If no entry exists,
+ * do nothing and return 0.
+ *
+ * NOTE! It is very important that the FASYNC flag always
+ * match the state "is the filp on a fasync list".
+ *
+ * We always take the 'filp->f_lock', in since fasync_lock
+ * needs to be irq-safe.
  */
-int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fapp)
+static int fasync_remove_entry(struct file *filp, struct fasync_struct **fapp)
 {
        struct fasync_struct *fa, **fp;
-       struct fasync_struct *new = NULL;
        int result = 0;
 
-       if (on) {
-               new = kmem_cache_alloc(fasync_cache, GFP_KERNEL);
-               if (!new)
-                       return -ENOMEM;
+       spin_lock(&filp->f_lock);
+       write_lock_irq(&fasync_lock);
+       for (fp = fapp; (fa = *fp) != NULL; fp = &fa->fa_next) {
+               if (fa->fa_file != filp)
+                       continue;
+               *fp = fa->fa_next;
+               kmem_cache_free(fasync_cache, fa);
+               filp->f_flags &= ~FASYNC;
+               result = 1;
+               break;
        }
+       write_unlock_irq(&fasync_lock);
+       spin_unlock(&filp->f_lock);
+       return result;
+}
+
+/*
+ * Add a fasync entry. Return negative on error, positive if
+ * added, and zero if did nothing but change an existing one.
+ *
+ * NOTE! It is very important that the FASYNC flag always
+ * match the state "is the filp on a fasync list".
+ */
+static int fasync_add_entry(int fd, struct file *filp, struct fasync_struct **fapp)
+{
+       struct fasync_struct *new, *fa, **fp;
+       int result = 0;
+
+       new = kmem_cache_alloc(fasync_cache, GFP_KERNEL);
+       if (!new)
+               return -ENOMEM;
 
-       /*
-        * We need to take f_lock first since it's not an IRQ-safe
-        * lock.
-        */
        spin_lock(&filp->f_lock);
        write_lock_irq(&fasync_lock);
        for (fp = fapp; (fa = *fp) != NULL; fp = &fa->fa_next) {
-               if (fa->fa_file == filp) {
-                       if(on) {
-                               fa->fa_fd = fd;
-                               kmem_cache_free(fasync_cache, new);
-                       } else {
-                               *fp = fa->fa_next;
-                               kmem_cache_free(fasync_cache, fa);
-                               result = 1;
-                       }
-                       goto out;
-               }
+               if (fa->fa_file != filp)
+                       continue;
+               fa->fa_fd = fd;
+               kmem_cache_free(fasync_cache, new);
+               goto out;
        }
 
-       if (on) {
-               new->magic = FASYNC_MAGIC;
-               new->fa_file = filp;
-               new->fa_fd = fd;
-               new->fa_next = *fapp;
-               *fapp = new;
-               result = 1;
-       }
+       new->magic = FASYNC_MAGIC;
+       new->fa_file = filp;
+       new->fa_fd = fd;
+       new->fa_next = *fapp;
+       *fapp = new;
+       result = 1;
+       filp->f_flags |= FASYNC;
+
 out:
-       if (on)
-               filp->f_flags |= FASYNC;
-       else
-               filp->f_flags &= ~FASYNC;
        write_unlock_irq(&fasync_lock);
        spin_unlock(&filp->f_lock);
        return result;
 }
 
+/*
+ * fasync_helper() is used by almost all character device drivers
+ * to set up the fasync queue, and for regular files by the file
+ * lease code. It returns negative on error, 0 if it did no changes
+ * and positive if it added/deleted the entry.
+ */
+int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fapp)
+{
+       if (!on)
+               return fasync_remove_entry(filp, fapp);
+       return fasync_add_entry(fd, filp, fapp);
+}
+
 EXPORT_SYMBOL(fasync_helper);
 
 void __kill_fasync(struct fasync_struct *fa, int sig, int band)
index a5089a6..7239efc 100644 (file)
@@ -646,22 +646,27 @@ static const struct super_operations hppfs_sbops = {
 static int hppfs_readlink(struct dentry *dentry, char __user *buffer,
                          int buflen)
 {
-       struct dentry *proc_dentry;
-
-       proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
+       struct dentry *proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
        return proc_dentry->d_inode->i_op->readlink(proc_dentry, buffer,
                                                    buflen);
 }
 
 static void *hppfs_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
-       struct dentry *proc_dentry;
-
-       proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
+       struct dentry *proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
 
        return proc_dentry->d_inode->i_op->follow_link(proc_dentry, nd);
 }
 
+static void hppfs_put_link(struct dentry *dentry, struct nameidata *nd,
+                          void *cookie)
+{
+       struct dentry *proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
+
+       if (proc_dentry->d_inode->i_op->put_link)
+               proc_dentry->d_inode->i_op->put_link(proc_dentry, nd, cookie);
+}
+
 static const struct inode_operations hppfs_dir_iops = {
        .lookup         = hppfs_lookup,
 };
@@ -669,6 +674,7 @@ static const struct inode_operations hppfs_dir_iops = {
 static const struct inode_operations hppfs_link_iops = {
        .readlink       = hppfs_readlink,
        .follow_link    = hppfs_follow_link,
+       .put_link       = hppfs_put_link,
 };
 
 static struct inode *get_inode(struct super_block *sb, struct dentry *dentry)
index b55440b..94a5e60 100644 (file)
@@ -561,6 +561,7 @@ static __always_inline int __do_follow_link(struct path *path, struct nameidata
                dget(dentry);
        }
        mntget(path->mnt);
+       nd->last_type = LAST_BIND;
        cookie = dentry->d_inode->i_op->follow_link(dentry, nd);
        error = PTR_ERR(cookie);
        if (!IS_ERR(cookie)) {
@@ -1603,11 +1604,12 @@ struct file *do_filp_open(int dfd, const char *pathname,
        struct file *filp;
        struct nameidata nd;
        int error;
-       struct path path, save;
+       struct path path;
        struct dentry *dir;
        int count = 0;
        int will_truncate;
        int flag = open_to_namei_flags(open_flag);
+       int force_reval = 0;
 
        /*
         * O_SYNC is implemented as __O_SYNC|O_DSYNC.  As many places only
@@ -1619,7 +1621,7 @@ struct file *do_filp_open(int dfd, const char *pathname,
                open_flag |= O_DSYNC;
 
        if (!acc_mode)
-               acc_mode = MAY_OPEN | ACC_MODE(flag);
+               acc_mode = MAY_OPEN | ACC_MODE(open_flag);
 
        /* O_TRUNC implies we need access checks for write permissions */
        if (flag & O_TRUNC)
@@ -1659,9 +1661,12 @@ struct file *do_filp_open(int dfd, const char *pathname,
        /*
         * Create - we need to know the parent.
         */
+reval:
        error = path_init(dfd, pathname, LOOKUP_PARENT, &nd);
        if (error)
                return ERR_PTR(error);
+       if (force_reval)
+               nd.flags |= LOOKUP_REVAL;
        error = path_walk(pathname, &nd);
        if (error) {
                if (nd.root.mnt)
@@ -1853,17 +1858,7 @@ do_link:
        error = security_inode_follow_link(path.dentry, &nd);
        if (error)
                goto exit_dput;
-       save = nd.path;
-       path_get(&save);
        error = __do_follow_link(&path, &nd);
-       if (error == -ESTALE) {
-               /* nd.path had been dropped */
-               nd.path = save;
-               path_get(&nd.path);
-               nd.flags |= LOOKUP_REVAL;
-               error = __do_follow_link(&path, &nd);
-       }
-       path_put(&save);
        path_put(&path);
        if (error) {
                /* Does someone understand code flow here? Or it is only
@@ -1873,6 +1868,10 @@ do_link:
                release_open_intent(&nd);
                if (nd.root.mnt)
                        path_put(&nd.root);
+               if (error == -ESTALE && !force_reval) {
+                       force_reval = 1;
+                       goto reval;
+               }
                return ERR_PTR(error);
        }
        nd.flags &= ~LOOKUP_PARENT;
index 7d70d63..c768f73 100644 (file)
@@ -965,10 +965,12 @@ EXPORT_SYMBOL(may_umount_tree);
 int may_umount(struct vfsmount *mnt)
 {
        int ret = 1;
+       down_read(&namespace_sem);
        spin_lock(&vfsmount_lock);
        if (propagate_mount_busy(mnt, 2))
                ret = 0;
        spin_unlock(&vfsmount_lock);
+       up_read(&namespace_sem);
        return ret;
 }
 
@@ -1352,12 +1354,12 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt,
        if (err)
                goto out_cleanup_ids;
 
+       spin_lock(&vfsmount_lock);
+
        if (IS_MNT_SHARED(dest_mnt)) {
                for (p = source_mnt; p; p = next_mnt(p, source_mnt))
                        set_mnt_shared(p);
        }
-
-       spin_lock(&vfsmount_lock);
        if (parent_path) {
                detach_mnt(source_mnt, parent_path);
                attach_mnt(source_mnt, path);
@@ -1534,8 +1536,12 @@ static int do_remount(struct path *path, int flags, int mnt_flags,
                err = change_mount_flags(path->mnt, flags);
        else
                err = do_remount_sb(sb, flags, data, 0);
-       if (!err)
+       if (!err) {
+               spin_lock(&vfsmount_lock);
+               mnt_flags |= path->mnt->mnt_flags & MNT_PNODE_MASK;
                path->mnt->mnt_flags = mnt_flags;
+               spin_unlock(&vfsmount_lock);
+       }
        up_write(&sb->s_umount);
        if (!err) {
                security_sb_post_remount(path->mnt, flags, data);
@@ -1665,6 +1671,8 @@ int do_add_mount(struct vfsmount *newmnt, struct path *path,
 {
        int err;
 
+       mnt_flags &= ~(MNT_SHARED | MNT_WRITE_HOLD);
+
        down_write(&namespace_sem);
        /* Something was mounted here while we slept */
        while (d_mountpoint(path->dentry) &&
index c9ee67b..1afb0a1 100644 (file)
@@ -121,7 +121,7 @@ static int idr_callback(int id, void *p, void *data)
        if (warned)
                return 0;
 
-       warned = false;
+       warned = true;
        entry = p;
        ientry = container_of(entry, struct inotify_inode_mark_entry, fsn_entry);
 
index 8271cf0..a94e8bd 100644 (file)
@@ -552,7 +552,7 @@ retry:
 
        spin_lock(&group->inotify_data.idr_lock);
        ret = idr_get_new_above(&group->inotify_data.idr, &tmp_ientry->fsn_entry,
-                               group->inotify_data.last_wd,
+                               group->inotify_data.last_wd+1,
                                &tmp_ientry->wd);
        spin_unlock(&group->inotify_data.idr_lock);
        if (ret) {
@@ -632,7 +632,7 @@ static struct fsnotify_group *inotify_new_group(struct user_struct *user, unsign
 
        spin_lock_init(&group->inotify_data.idr_lock);
        idr_init(&group->inotify_data.idr);
-       group->inotify_data.last_wd = 1;
+       group->inotify_data.last_wd = 0;
        group->inotify_data.user = user;
        group->inotify_data.fa = NULL;
 
index 18d5cc6..e42bbd8 100644 (file)
@@ -1419,7 +1419,6 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
                goto out;
 
        error = PROC_I(inode)->op.proc_get_link(inode, &nd->path);
-       nd->last_type = LAST_BIND;
 out:
        return ERR_PTR(error);
 }
index 2efc571..1739a4a 100644 (file)
@@ -123,30 +123,6 @@ add_error:
 
 /*****************************************************************************/
 /*
- * check that file shrinkage doesn't leave any VMAs dangling in midair
- */
-static int ramfs_nommu_check_mappings(struct inode *inode,
-                                     size_t newsize, size_t size)
-{
-       struct vm_area_struct *vma;
-       struct prio_tree_iter iter;
-
-       /* search for VMAs that fall within the dead zone */
-       vma_prio_tree_foreach(vma, &iter, &inode->i_mapping->i_mmap,
-                             newsize >> PAGE_SHIFT,
-                             (size + PAGE_SIZE - 1) >> PAGE_SHIFT
-                             ) {
-               /* found one - only interested if it's shared out of the page
-                * cache */
-               if (vma->vm_flags & VM_SHARED)
-                       return -ETXTBSY; /* not quite true, but near enough */
-       }
-
-       return 0;
-}
-
-/*****************************************************************************/
-/*
  *
  */
 static int ramfs_nommu_resize(struct inode *inode, loff_t newsize, loff_t size)
@@ -164,7 +140,7 @@ static int ramfs_nommu_resize(struct inode *inode, loff_t newsize, loff_t size)
 
        /* check that a decrease in size doesn't cut off any shared mappings */
        if (newsize < size) {
-               ret = ramfs_nommu_check_mappings(inode, newsize, size);
+               ret = nommu_shrink_inode_mappings(inode, size, newsize);
                if (ret < 0)
                        return ret;
        }
index 9147ca8..b1bcb27 100644 (file)
@@ -2463,7 +2463,7 @@ int proc_nr_files(struct ctl_table *table, int write,
 
 int __init get_filesystem_list(char *buf);
 
-#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
+#define ACC_MODE(x) ("\004\002\006\006"[(x)&O_ACCMODE])
 #define OPEN_FMODE(flag) ((__force fmode_t)((flag + 1) & O_ACCMODE))
 
 #endif /* __KERNEL__ */
index 3fc9f5a..328bca6 100644 (file)
@@ -734,6 +734,10 @@ struct sysinfo {
 /* Force a compilation error if condition is constant and true */
 #define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)]))
 
+/* Force a compilation error if a constant expression is not a power of 2 */
+#define BUILD_BUG_ON_NOT_POWER_OF_2(n)                 \
+       BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
+
 /* Force a compilation error if condition is true, but also produce a
    result (of value 0 and type size_t), so the expression can be used
    e.g. in a structure initializer (or where-ever else comma expressions
index 7c6b32a..6f6c5f3 100644 (file)
@@ -67,7 +67,7 @@ struct kfifo {
 /**
  * DECLARE_KFIFO - macro to declare a kfifo and the associated buffer
  * @name: name of the declared kfifo datatype
- * @size: size of the fifo buffer
+ * @size: size of the fifo buffer. Must be a power of two.
  *
  * Note1: the macro can be used inside struct or union declaration
  * Note2: the macro creates two objects:
@@ -91,7 +91,7 @@ union { \
 /**
  * DEFINE_KFIFO - macro to define and initialize a kfifo
  * @name: name of the declared kfifo datatype
- * @size: size of the fifo buffer
+ * @size: size of the fifo buffer. Must be a power of two.
  *
  * Note1: the macro can be used for global and local kfifo data type variables
  * Note2: the macro creates two objects:
@@ -104,15 +104,28 @@ union { \
 
 #undef __kfifo_initializer
 
-extern void kfifo_init(struct kfifo *fifo, unsigned char *buffer,
+extern void kfifo_init(struct kfifo *fifo, void *buffer,
                        unsigned int size);
 extern __must_check int kfifo_alloc(struct kfifo *fifo, unsigned int size,
                        gfp_t gfp_mask);
 extern void kfifo_free(struct kfifo *fifo);
 extern unsigned int kfifo_in(struct kfifo *fifo,
-                               const unsigned char *from, unsigned int len);
+                               const void *from, unsigned int len);
 extern __must_check unsigned int kfifo_out(struct kfifo *fifo,
-                               unsigned char *to, unsigned int len);
+                               void *to, unsigned int len);
+extern __must_check unsigned int kfifo_out_peek(struct kfifo *fifo,
+                               void *to, unsigned int len, unsigned offset);
+
+/**
+ * kfifo_initialized - Check if kfifo is initialized.
+ * @fifo: fifo to check
+ * Return %true if FIFO is initialized, otherwise %false.
+ * Assumes the fifo was 0 before.
+ */
+static inline bool kfifo_initialized(struct kfifo *fifo)
+{
+       return fifo->buffer != 0;
+}
 
 /**
  * kfifo_reset - removes the entire FIFO contents
@@ -194,7 +207,7 @@ static inline __must_check unsigned int kfifo_avail(struct kfifo *fifo)
  * bytes copied.
  */
 static inline unsigned int kfifo_in_locked(struct kfifo *fifo,
-               const unsigned char *from, unsigned int n, spinlock_t *lock)
+               const void *from, unsigned int n, spinlock_t *lock)
 {
        unsigned long flags;
        unsigned int ret;
@@ -219,7 +232,7 @@ static inline unsigned int kfifo_in_locked(struct kfifo *fifo,
  * @to buffer and returns the number of copied bytes.
  */
 static inline __must_check unsigned int kfifo_out_locked(struct kfifo *fifo,
-       unsigned char *to, unsigned int n, spinlock_t *lock)
+       void *to, unsigned int n, spinlock_t *lock)
 {
        unsigned long flags;
        unsigned int ret;
@@ -228,13 +241,6 @@ static inline __must_check unsigned int kfifo_out_locked(struct kfifo *fifo,
 
        ret = kfifo_out(fifo, to, n);
 
-       /*
-        * optimization: if the FIFO is empty, set the indices to 0
-        * so we don't wrap the next time
-        */
-       if (kfifo_is_empty(fifo))
-               kfifo_reset(fifo);
-
        spin_unlock_irqrestore(lock, flags);
 
        return ret;
@@ -242,11 +248,11 @@ static inline __must_check unsigned int kfifo_out_locked(struct kfifo *fifo,
 
 extern void kfifo_skip(struct kfifo *fifo, unsigned int len);
 
-extern __must_check unsigned int kfifo_from_user(struct kfifo *fifo,
-       const void __user *from, unsigned int n);
+extern __must_check int kfifo_from_user(struct kfifo *fifo,
+       const void __user *from, unsigned int n, unsigned *lenout);
 
-extern __must_check unsigned int kfifo_to_user(struct kfifo *fifo,
-       void __user *to, unsigned int n);
+extern __must_check int kfifo_to_user(struct kfifo *fifo,
+       void __user *to, unsigned int n, unsigned *lenout);
 
 /*
  * __kfifo_add_out internal helper function for updating the out offset
index 2265f28..60c467b 100644 (file)
@@ -1089,6 +1089,7 @@ extern void zone_pcp_update(struct zone *zone);
 
 /* nommu.c */
 extern atomic_long_t mmap_pages_allocated;
+extern int nommu_shrink_inode_mappings(struct inode *, size_t, size_t);
 
 /* prio_tree.c */
 void vma_prio_tree_add(struct vm_area_struct *, struct vm_area_struct *old);
index 84d020b..36f9627 100644 (file)
@@ -122,7 +122,7 @@ struct vm_region {
        unsigned long   vm_pgoff;       /* the offset in vm_file corresponding to vm_start */
        struct file     *vm_file;       /* the backing file or NULL */
 
-       atomic_t        vm_usage;       /* region usage count */
+       int             vm_usage;       /* region usage count (access under nommu_region_sem) */
        bool            vm_icache_flushed : 1; /* true if the icache has been flushed for
                                                * this region */
 };
@@ -205,10 +205,12 @@ struct mm_struct {
        struct vm_area_struct * mmap;           /* list of VMAs */
        struct rb_root mm_rb;
        struct vm_area_struct * mmap_cache;     /* last find_vma result */
+#ifdef CONFIG_MMU
        unsigned long (*get_unmapped_area) (struct file *filp,
                                unsigned long addr, unsigned long len,
                                unsigned long pgoff, unsigned long flags);
        void (*unmap_area) (struct mm_struct *mm, unsigned long addr);
+#endif
        unsigned long mmap_base;                /* base of mmap area */
        unsigned long task_size;                /* size of task vm space */
        unsigned long cached_hole_size;         /* if non-zero, the largest hole below free_area_cache */
index 8d4991b..6f7bba9 100644 (file)
@@ -377,6 +377,8 @@ extern int sysctl_max_map_count;
 
 #include <linux/aio.h>
 
+#ifdef CONFIG_MMU
+extern void arch_pick_mmap_layout(struct mm_struct *mm);
 extern unsigned long
 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
                       unsigned long, unsigned long);
@@ -386,6 +388,9 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
                          unsigned long flags);
 extern void arch_unmap_area(struct mm_struct *, unsigned long);
 extern void arch_unmap_area_topdown(struct mm_struct *, unsigned long);
+#else
+static inline void arch_pick_mmap_layout(struct mm_struct *mm) {}
+#endif
 
 #if USE_SPLIT_PTLOCKS
 /*
@@ -2491,8 +2496,6 @@ static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
 
 #endif /* CONFIG_SMP */
 
-extern void arch_pick_mmap_layout(struct mm_struct *mm);
-
 #ifdef CONFIG_TRACING
 extern void
 __trace_special(void *__tr, void *__data,
index e2f3044..813d26c 100644 (file)
@@ -136,25 +136,6 @@ static inline void serio_continue_rx(struct serio *serio)
        spin_unlock_irq(&serio->lock);
 }
 
-/*
- * Use the following functions to pin serio's driver in process context
- */
-static inline int serio_pin_driver(struct serio *serio)
-{
-       return mutex_lock_interruptible(&serio->drv_mutex);
-}
-
-static inline void serio_pin_driver_uninterruptible(struct serio *serio)
-{
-       mutex_lock(&serio->drv_mutex);
-}
-
-static inline void serio_unpin_driver(struct serio *serio)
-{
-       mutex_unlock(&serio->drv_mutex);
-}
-
-
 #endif
 
 /*
index 651839a..a716ee2 100644 (file)
@@ -72,7 +72,10 @@ static inline __must_check char *strstrip(char *str)
 }
 
 #ifndef __HAVE_ARCH_STRSTR
-extern char * strstr(const char *,const char *);
+extern char * strstr(const char *, const char *);
+#endif
+#ifndef __HAVE_ARCH_STRNSTR
+extern char * strnstr(const char *, const char *, size_t);
 #endif
 #ifndef __HAVE_ARCH_STRLEN
 extern __kernel_size_t strlen(const char *);
index ef3a294..6abfcf5 100644 (file)
@@ -464,7 +464,7 @@ extern int tty_port_alloc_xmit_buf(struct tty_port *port);
 extern void tty_port_free_xmit_buf(struct tty_port *port);
 extern void tty_port_put(struct tty_port *port);
 
-extern inline struct tty_port *tty_port_get(struct tty_port *port)
+static inline struct tty_port *tty_port_get(struct tty_port *port)
 {
        if (port)
                kref_get(&port->kref);
@@ -486,7 +486,7 @@ extern void tty_port_close(struct tty_port *port,
                                struct tty_struct *tty, struct file *filp);
 extern int tty_port_open(struct tty_port *port,
                                struct tty_struct *tty, struct file *filp);
-extern inline int tty_port_users(struct tty_port *port)
+static inline int tty_port_users(struct tty_port *port)
 {
        return port->count + port->blocked_open;
 }
index d9a0e74..fb63371 100644 (file)
@@ -338,7 +338,7 @@ static inline int sk_mc_loop(struct sock *sk)
                return inet6_sk(sk)->mc_loop;
 #endif
        }
-       __WARN();
+       WARN_ON(1);
        return 1;
 }
 
index 92fe923..23256b8 100644 (file)
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -298,6 +298,9 @@ static const struct file_operations shm_file_operations = {
        .mmap           = shm_mmap,
        .fsync          = shm_fsync,
        .release        = shm_release,
+#ifndef CONFIG_MMU
+       .get_unmapped_area      = shm_get_unmapped_area,
+#endif
 };
 
 static const struct file_operations shm_file_operations_huge = {
index 8e3c3ff..d9b3a22 100644 (file)
@@ -203,8 +203,6 @@ static void drop_futex_key_refs(union futex_key *key)
  * @uaddr:     virtual address of the futex
  * @fshared:   0 for a PROCESS_PRIVATE futex, 1 for PROCESS_SHARED
  * @key:       address where result is stored.
- * @rw:                mapping needs to be read/write (values: VERIFY_READ,
- *             VERIFY_WRITE)
  *
  * Returns a negative error code or 0
  * The key words are stored in *key on success.
@@ -216,7 +214,7 @@ static void drop_futex_key_refs(union futex_key *key)
  * lock_page() might sleep, the caller should not hold a spinlock.
  */
 static int
-get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
+get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key)
 {
        unsigned long address = (unsigned long)uaddr;
        struct mm_struct *mm = current->mm;
@@ -239,7 +237,7 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
         *        but access_ok() should be faster than find_vma()
         */
        if (!fshared) {
-               if (unlikely(!access_ok(rw, uaddr, sizeof(u32))))
+               if (unlikely(!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))))
                        return -EFAULT;
                key->private.mm = mm;
                key->private.address = address;
@@ -248,7 +246,7 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
        }
 
 again:
-       err = get_user_pages_fast(address, 1, rw == VERIFY_WRITE, &page);
+       err = get_user_pages_fast(address, 1, 1, &page);
        if (err < 0)
                return err;
 
@@ -867,7 +865,7 @@ static int futex_wake(u32 __user *uaddr, int fshared, int nr_wake, u32 bitset)
        if (!bitset)
                return -EINVAL;
 
-       ret = get_futex_key(uaddr, fshared, &key, VERIFY_READ);
+       ret = get_futex_key(uaddr, fshared, &key);
        if (unlikely(ret != 0))
                goto out;
 
@@ -913,10 +911,10 @@ futex_wake_op(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,
        int ret, op_ret;
 
 retry:
-       ret = get_futex_key(uaddr1, fshared, &key1, VERIFY_READ);
+       ret = get_futex_key(uaddr1, fshared, &key1);
        if (unlikely(ret != 0))
                goto out;
-       ret = get_futex_key(uaddr2, fshared, &key2, VERIFY_WRITE);
+       ret = get_futex_key(uaddr2, fshared, &key2);
        if (unlikely(ret != 0))
                goto out_put_key1;
 
@@ -1175,11 +1173,10 @@ retry:
                pi_state = NULL;
        }
 
-       ret = get_futex_key(uaddr1, fshared, &key1, VERIFY_READ);
+       ret = get_futex_key(uaddr1, fshared, &key1);
        if (unlikely(ret != 0))
                goto out;
-       ret = get_futex_key(uaddr2, fshared, &key2,
-                           requeue_pi ? VERIFY_WRITE : VERIFY_READ);
+       ret = get_futex_key(uaddr2, fshared, &key2);
        if (unlikely(ret != 0))
                goto out_put_key1;
 
@@ -1738,7 +1735,7 @@ static int futex_wait_setup(u32 __user *uaddr, u32 val, int fshared,
         */
 retry:
        q->key = FUTEX_KEY_INIT;
-       ret = get_futex_key(uaddr, fshared, &q->key, VERIFY_READ);
+       ret = get_futex_key(uaddr, fshared, &q->key);
        if (unlikely(ret != 0))
                return ret;
 
@@ -1904,7 +1901,7 @@ static int futex_lock_pi(u32 __user *uaddr, int fshared,
        q.requeue_pi_key = NULL;
 retry:
        q.key = FUTEX_KEY_INIT;
-       ret = get_futex_key(uaddr, fshared, &q.key, VERIFY_WRITE);
+       ret = get_futex_key(uaddr, fshared, &q.key);
        if (unlikely(ret != 0))
                goto out;
 
@@ -2023,7 +2020,7 @@ retry:
        if ((uval & FUTEX_TID_MASK) != task_pid_vnr(current))
                return -EPERM;
 
-       ret = get_futex_key(uaddr, fshared, &key, VERIFY_WRITE);
+       ret = get_futex_key(uaddr, fshared, &key);
        if (unlikely(ret != 0))
                goto out;
 
@@ -2215,7 +2212,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared,
        rt_waiter.task = NULL;
 
        key2 = FUTEX_KEY_INIT;
-       ret = get_futex_key(uaddr2, fshared, &key2, VERIFY_WRITE);
+       ret = get_futex_key(uaddr2, fshared, &key2);
        if (unlikely(ret != 0))
                goto out;
 
index e92d519..32c5c15 100644 (file)
@@ -28,7 +28,7 @@
 #include <linux/log2.h>
 #include <linux/uaccess.h>
 
-static void _kfifo_init(struct kfifo *fifo, unsigned char *buffer,
+static void _kfifo_init(struct kfifo *fifo, void *buffer,
                unsigned int size)
 {
        fifo->buffer = buffer;
@@ -41,10 +41,10 @@ static void _kfifo_init(struct kfifo *fifo, unsigned char *buffer,
  * kfifo_init - initialize a FIFO using a preallocated buffer
  * @fifo: the fifo to assign the buffer
  * @buffer: the preallocated buffer to be used.
- * @size: the size of the internal buffer, this have to be a power of 2.
+ * @size: the size of the internal buffer, this has to be a power of 2.
  *
  */
-void kfifo_init(struct kfifo *fifo, unsigned char *buffer, unsigned int size)
+void kfifo_init(struct kfifo *fifo, void *buffer, unsigned int size)
 {
        /* size must be a power of 2 */
        BUG_ON(!is_power_of_2(size));
@@ -159,8 +159,9 @@ static inline void __kfifo_out_data(struct kfifo *fifo,
        memcpy(to + l, fifo->buffer, len - l);
 }
 
-static inline unsigned int __kfifo_from_user_data(struct kfifo *fifo,
-        const void __user *from, unsigned int len, unsigned int off)
+static inline int __kfifo_from_user_data(struct kfifo *fifo,
+        const void __user *from, unsigned int len, unsigned int off,
+        unsigned *lenout)
 {
        unsigned int l;
        int ret;
@@ -177,16 +178,20 @@ static inline unsigned int __kfifo_from_user_data(struct kfifo *fifo,
        /* first put the data starting from fifo->in to buffer end */
        l = min(len, fifo->size - off);
        ret = copy_from_user(fifo->buffer + off, from, l);
-
-       if (unlikely(ret))
-               return ret + len - l;
+       if (unlikely(ret)) {
+               *lenout = ret;
+               return -EFAULT;
+       }
+       *lenout = l;
 
        /* then put the rest (if any) at the beginning of the buffer */
-       return copy_from_user(fifo->buffer, from + l, len - l);
+       ret = copy_from_user(fifo->buffer, from + l, len - l);
+       *lenout += ret ? ret : len - l;
+       return ret ? -EFAULT : 0;
 }
 
-static inline unsigned int __kfifo_to_user_data(struct kfifo *fifo,
-               void __user *to, unsigned int len, unsigned int off)
+static inline int __kfifo_to_user_data(struct kfifo *fifo,
+               void __user *to, unsigned int len, unsigned int off, unsigned *lenout)
 {
        unsigned int l;
        int ret;
@@ -203,12 +208,21 @@ static inline unsigned int __kfifo_to_user_data(struct kfifo *fifo,
        /* first get the data from fifo->out until the end of the buffer */
        l = min(len, fifo->size - off);
        ret = copy_to_user(to, fifo->buffer + off, l);
-
-       if (unlikely(ret))
-               return ret + len - l;
+       *lenout = l;
+       if (unlikely(ret)) {
+               *lenout -= ret;
+               return -EFAULT;
+       }
 
        /* then get the rest (if any) from the beginning of the buffer */
-       return copy_to_user(to + l, fifo->buffer, len - l);
+       len -= l;
+       ret = copy_to_user(to + l, fifo->buffer, len);
+       if (unlikely(ret)) {
+               *lenout += len - ret;
+               return -EFAULT;
+       }
+       *lenout += len;
+       return 0;
 }
 
 unsigned int __kfifo_in_n(struct kfifo *fifo,
@@ -235,7 +249,7 @@ EXPORT_SYMBOL(__kfifo_in_n);
  * Note that with only one concurrent reader and one concurrent
  * writer, you don't need extra locking to use these functions.
  */
-unsigned int kfifo_in(struct kfifo *fifo, const unsigned char *from,
+unsigned int kfifo_in(struct kfifo *fifo, const void *from,
                                unsigned int len)
 {
        len = min(kfifo_avail(fifo), len);
@@ -277,7 +291,7 @@ EXPORT_SYMBOL(__kfifo_out_n);
  * Note that with only one concurrent reader and one concurrent
  * writer, you don't need extra locking to use these functions.
  */
-unsigned int kfifo_out(struct kfifo *fifo, unsigned char *to, unsigned int len)
+unsigned int kfifo_out(struct kfifo *fifo, void *to, unsigned int len)
 {
        len = min(kfifo_len(fifo), len);
 
@@ -288,6 +302,27 @@ unsigned int kfifo_out(struct kfifo *fifo, unsigned char *to, unsigned int len)
 }
 EXPORT_SYMBOL(kfifo_out);
 
+/**
+ * kfifo_out_peek - copy some data from the FIFO, but do not remove it
+ * @fifo: the fifo to be used.
+ * @to: where the data must be copied.
+ * @len: the size of the destination buffer.
+ * @offset: offset into the fifo
+ *
+ * This function copies at most @len bytes at @offset from the FIFO
+ * into the @to buffer and returns the number of copied bytes.
+ * The data is not removed from the FIFO.
+ */
+unsigned int kfifo_out_peek(struct kfifo *fifo, void *to, unsigned int len,
+                           unsigned offset)
+{
+       len = min(kfifo_len(fifo), len + offset);
+
+       __kfifo_out_data(fifo, to, len, offset);
+       return len;
+}
+EXPORT_SYMBOL(kfifo_out_peek);
+
 unsigned int __kfifo_out_generic(struct kfifo *fifo,
        void *to, unsigned int len, unsigned int recsize,
        unsigned int *total)
@@ -299,10 +334,13 @@ EXPORT_SYMBOL(__kfifo_out_generic);
 unsigned int __kfifo_from_user_n(struct kfifo *fifo,
        const void __user *from, unsigned int len, unsigned int recsize)
 {
+       unsigned total;
+
        if (kfifo_avail(fifo) < len + recsize)
                return len + 1;
 
-       return __kfifo_from_user_data(fifo, from, len, recsize);
+       __kfifo_from_user_data(fifo, from, len, recsize, &total);
+       return total;
 }
 EXPORT_SYMBOL(__kfifo_from_user_n);
 
@@ -313,18 +351,21 @@ EXPORT_SYMBOL(__kfifo_from_user_n);
  * @len: the length of the data to be added.
  *
  * This function copies at most @len bytes from the @from into the
- * FIFO depending and returns the number of copied bytes.
+ * FIFO depending and returns -EFAULT/0.
  *
  * Note that with only one concurrent reader and one concurrent
  * writer, you don't need extra locking to use these functions.
  */
-unsigned int kfifo_from_user(struct kfifo *fifo,
-       const void __user *from, unsigned int len)
+int kfifo_from_user(struct kfifo *fifo,
+        const void __user *from, unsigned int len, unsigned *total)
 {
+       int ret;
        len = min(kfifo_avail(fifo), len);
-       len -= __kfifo_from_user_data(fifo, from, len, 0);
+       ret = __kfifo_from_user_data(fifo, from, len, 0, total);
+       if (ret)
+               return ret;
        __kfifo_add_in(fifo, len);
-       return len;
+       return 0;
 }
 EXPORT_SYMBOL(kfifo_from_user);
 
@@ -339,17 +380,17 @@ unsigned int __kfifo_to_user_n(struct kfifo *fifo,
        void __user *to, unsigned int len, unsigned int reclen,
        unsigned int recsize)
 {
-       unsigned int ret;
+       unsigned int ret, total;
 
        if (kfifo_len(fifo) < reclen + recsize)
                return len;
 
-       ret = __kfifo_to_user_data(fifo, to, reclen, recsize);
+       ret = __kfifo_to_user_data(fifo, to, reclen, recsize, &total);
 
        if (likely(ret == 0))
                __kfifo_add_out(fifo, reclen + recsize);
 
-       return ret;
+       return total;
 }
 EXPORT_SYMBOL(__kfifo_to_user_n);
 
@@ -358,20 +399,22 @@ EXPORT_SYMBOL(__kfifo_to_user_n);
  * @fifo: the fifo to be used.
  * @to: where the data must be copied.
  * @len: the size of the destination buffer.
+ @ @lenout: pointer to output variable with copied data
  *
  * This function copies at most @len bytes from the FIFO into the
- * @to buffer and returns the number of copied bytes.
+ * @to buffer and 0 or -EFAULT.
  *
  * Note that with only one concurrent reader and one concurrent
  * writer, you don't need extra locking to use these functions.
  */
-unsigned int kfifo_to_user(struct kfifo *fifo,
-       void __user *to, unsigned int len)
+int kfifo_to_user(struct kfifo *fifo,
+       void __user *to, unsigned int len, unsigned *lenout)
 {
+       int ret;
        len = min(kfifo_len(fifo), len);
-       len -= __kfifo_to_user_data(fifo, to, len, 0);
-       __kfifo_add_out(fifo, len);
-       return len;
+       ret = __kfifo_to_user_data(fifo, to, len, 0, lenout);
+       __kfifo_add_out(fifo, *lenout);
+       return ret;
 }
 EXPORT_SYMBOL(kfifo_to_user);
 
index de735a6..f104084 100644 (file)
@@ -347,7 +347,7 @@ int smp_call_function_any(const struct cpumask *mask,
                goto call;
 
        /* Try for same node. */
-       nodemask = cpumask_of_node(cpu);
+       nodemask = cpumask_of_node(cpu_to_node(cpu));
        for (cpu = cpumask_first_and(nodemask, mask); cpu < nr_cpu_ids;
             cpu = cpumask_next_and(cpu, nodemask, mask)) {
                if (cpu_online(cpu))
index 7968762..1e6640f 100644 (file)
@@ -1690,7 +1690,7 @@ ftrace_regex_lseek(struct file *file, loff_t offset, int origin)
 static int ftrace_match(char *str, char *regex, int len, int type)
 {
        int matched = 0;
-       char *ptr;
+       int slen;
 
        switch (type) {
        case MATCH_FULL:
@@ -1706,8 +1706,8 @@ static int ftrace_match(char *str, char *regex, int len, int type)
                        matched = 1;
                break;
        case MATCH_END_ONLY:
-               ptr = strstr(str, regex);
-               if (ptr && (ptr[len] == 0))
+               slen = strlen(str);
+               if (slen >= len && memcmp(str + slen - len, regex, len) == 0)
                        matched = 1;
                break;
        }
index 2326b04..edefe3b 100644 (file)
@@ -2869,7 +2869,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
         * Splice the empty reader page into the list around the head.
         */
        reader = rb_set_head_page(cpu_buffer);
-       cpu_buffer->reader_page->list.next = reader->list.next;
+       cpu_buffer->reader_page->list.next = rb_list_head(reader->list.next);
        cpu_buffer->reader_page->list.prev = reader->list.prev;
 
        /*
@@ -2906,7 +2906,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
         *
         * Now make the new head point back to the reader page.
         */
-       reader->list.next->prev = &cpu_buffer->reader_page->list;
+       rb_list_head(reader->list.next)->prev = &cpu_buffer->reader_page->list;
        rb_inc_page(cpu_buffer, &cpu_buffer->head_page);
 
        /* Finally update the reader page to the new head */
index 50504cb..e42af9a 100644 (file)
@@ -211,8 +211,9 @@ static int filter_pred_pchar(struct filter_pred *pred, void *event,
 {
        char **addr = (char **)(event + pred->offset);
        int cmp, match;
+       int len = strlen(*addr) + 1;    /* including tailing '\0' */
 
-       cmp = pred->regex.match(*addr, &pred->regex, pred->regex.field_len);
+       cmp = pred->regex.match(*addr, &pred->regex, len);
 
        match = cmp ^ pred->not;
 
@@ -251,7 +252,18 @@ static int filter_pred_none(struct filter_pred *pred, void *event,
        return 0;
 }
 
-/* Basic regex callbacks */
+/*
+ * regex_match_foo - Basic regex callbacks
+ *
+ * @str: the string to be searched
+ * @r:   the regex structure containing the pattern string
+ * @len: the length of the string to be searched (including '\0')
+ *
+ * Note:
+ * - @str might not be NULL-terminated if it's of type DYN_STRING
+ *   or STATIC_STRING
+ */
+
 static int regex_match_full(char *str, struct regex *r, int len)
 {
        if (strncmp(str, r->pattern, len) == 0)
@@ -261,23 +273,24 @@ static int regex_match_full(char *str, struct regex *r, int len)
 
 static int regex_match_front(char *str, struct regex *r, int len)
 {
-       if (strncmp(str, r->pattern, len) == 0)
+       if (strncmp(str, r->pattern, r->len) == 0)
                return 1;
        return 0;
 }
 
 static int regex_match_middle(char *str, struct regex *r, int len)
 {
-       if (strstr(str, r->pattern))
+       if (strnstr(str, r->pattern, len))
                return 1;
        return 0;
 }
 
 static int regex_match_end(char *str, struct regex *r, int len)
 {
-       char *ptr = strstr(str, r->pattern);
+       int strlen = len - 1;
 
-       if (ptr && (ptr[r->len] == 0))
+       if (strlen >= r->len &&
+           memcmp(str + strlen - r->len, r->pattern, r->len) == 0)
                return 1;
        return 0;
 }
@@ -781,10 +794,8 @@ static int filter_add_pred(struct filter_parse_state *ps,
                        pred->regex.field_len = field->size;
                } else if (field->filter_type == FILTER_DYN_STRING)
                        fn = filter_pred_strloc;
-               else {
+               else
                        fn = filter_pred_pchar;
-                       pred->regex.field_len = strlen(pred->regex.pattern);
-               }
        } else {
                if (field->is_signed)
                        ret = strict_strtoll(pred->regex.pattern, 0, &val);
index 9f75b4e..a1cdcfc 100644 (file)
@@ -667,7 +667,7 @@ EXPORT_SYMBOL(memscan);
  */
 char *strstr(const char *s1, const char *s2)
 {
-       int l1, l2;
+       size_t l1, l2;
 
        l2 = strlen(s2);
        if (!l2)
@@ -684,6 +684,31 @@ char *strstr(const char *s1, const char *s2)
 EXPORT_SYMBOL(strstr);
 #endif
 
+#ifndef __HAVE_ARCH_STRNSTR
+/**
+ * strnstr - Find the first substring in a length-limited string
+ * @s1: The string to be searched
+ * @s2: The string to search for
+ * @len: the maximum number of characters to search
+ */
+char *strnstr(const char *s1, const char *s2, size_t len)
+{
+       size_t l1 = len, l2;
+
+       l2 = strlen(s2);
+       if (!l2)
+               return (char *)s1;
+       while (l1 >= l2) {
+               l1--;
+               if (!memcmp(s1, s2, l2))
+                       return (char *)s1;
+               s1++;
+       }
+       return NULL;
+}
+EXPORT_SYMBOL(strnstr);
+#endif
+
 #ifndef __HAVE_ARCH_MEMCHR
 /**
  * memchr - Find a character in an area of memory.
index 05e1559..215447c 100644 (file)
@@ -4,12 +4,25 @@
  */
 
 #include <linux/zutil.h>
-#include <asm/unaligned.h>
-#include <asm/byteorder.h>
 #include "inftrees.h"
 #include "inflate.h"
 #include "inffast.h"
 
+/* Only do the unaligned "Faster" variant when
+ * CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is set
+ *
+ * On powerpc, it won't be as we don't include autoconf.h
+ * automatically for the boot wrapper, which is intended as
+ * we run in an environment where we may not be able to deal
+ * with (even rare) alignment faults. In addition, we do not
+ * define __KERNEL__ for arch/powerpc/boot unlike x86
+ */
+
+#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
+#include <asm/unaligned.h>
+#include <asm/byteorder.h>
+#endif
+
 #ifndef ASMINF
 
 /* Allow machine dependent optimization for post-increment or pre-increment.
@@ -243,6 +256,7 @@ void inflate_fast(z_streamp strm, unsigned start)
                     }
                 }
                 else {
+#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
                    unsigned short *sout;
                    unsigned long loops;
 
@@ -284,6 +298,20 @@ void inflate_fast(z_streamp strm, unsigned start)
                    }
                    if (len & 1)
                        PUP(out) = PUP(from);
+#else /* CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */
+                    from = out - dist;          /* copy direct from output */
+                    do {                        /* minimum length is three */
+                        PUP(out) = PUP(from);
+                        PUP(out) = PUP(from);
+                        PUP(out) = PUP(from);
+                        len -= 3;
+                    } while (len > 2);
+                    if (len) {
+                        PUP(out) = PUP(from);
+                        if (len > 1)
+                            PUP(out) = PUP(from);
+                    }
+#endif /* !CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */
                 }
             }
             else if ((op & 64) == 0) {          /* 2nd level distance code */
index 488b644..954032b 100644 (file)
@@ -2586,7 +2586,7 @@ static int mem_cgroup_force_empty(struct mem_cgroup *mem, bool free_all)
        if (free_all)
                goto try_to_free;
 move_account:
-       while (mem->res.usage > 0) {
+       do {
                ret = -EBUSY;
                if (cgroup_task_count(cgrp) || !list_empty(&cgrp->children))
                        goto out;
@@ -2614,8 +2614,8 @@ move_account:
                if (ret == -ENOMEM)
                        goto try_to_free;
                cond_resched();
-       }
-       ret = 0;
+       /* "ret" should also be checked to ensure all lists are empty. */
+       } while (mem->res.usage > 0 || ret);
 out:
        css_put(&mem->css);
        return ret;
@@ -2648,10 +2648,7 @@ try_to_free:
        }
        lru_add_drain();
        /* try move_account...there may be some *locked* pages. */
-       if (mem->res.usage)
-               goto move_account;
-       ret = 0;
-       goto out;
+       goto move_account;
 }
 
 int mem_cgroup_force_empty_write(struct cgroup *cont, unsigned int event)
index 1777386..48a2ecf 100644 (file)
@@ -552,11 +552,11 @@ static void free_page_series(unsigned long from, unsigned long to)
 static void __put_nommu_region(struct vm_region *region)
        __releases(nommu_region_sem)
 {
-       kenter("%p{%d}", region, atomic_read(&region->vm_usage));
+       kenter("%p{%d}", region, region->vm_usage);
 
        BUG_ON(!nommu_region_tree.rb_node);
 
-       if (atomic_dec_and_test(&region->vm_usage)) {
+       if (--region->vm_usage == 0) {
                if (region->vm_top > region->vm_start)
                        delete_nommu_region(region);
                up_write(&nommu_region_sem);
@@ -1205,7 +1205,7 @@ unsigned long do_mmap_pgoff(struct file *file,
        if (!vma)
                goto error_getting_vma;
 
-       atomic_set(&region->vm_usage, 1);
+       region->vm_usage = 1;
        region->vm_flags = vm_flags;
        region->vm_pgoff = pgoff;
 
@@ -1272,7 +1272,7 @@ unsigned long do_mmap_pgoff(struct file *file,
                        }
 
                        /* we've found a region we can share */
-                       atomic_inc(&pregion->vm_usage);
+                       pregion->vm_usage++;
                        vma->vm_region = pregion;
                        start = pregion->vm_start;
                        start += (pgoff - pregion->vm_pgoff) << PAGE_SHIFT;
@@ -1289,7 +1289,7 @@ unsigned long do_mmap_pgoff(struct file *file,
                                        vma->vm_region = NULL;
                                        vma->vm_start = 0;
                                        vma->vm_end = 0;
-                                       atomic_dec(&pregion->vm_usage);
+                                       pregion->vm_usage--;
                                        pregion = NULL;
                                        goto error_just_free;
                                }
@@ -1441,10 +1441,9 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
 
        kenter("");
 
-       /* we're only permitted to split anonymous regions that have a single
-        * owner */
-       if (vma->vm_file ||
-           atomic_read(&vma->vm_region->vm_usage) != 1)
+       /* we're only permitted to split anonymous regions (these should have
+        * only a single usage on the region) */
+       if (vma->vm_file)
                return -ENOMEM;
 
        if (mm->map_count >= sysctl_max_map_count)
@@ -1518,7 +1517,7 @@ static int shrink_vma(struct mm_struct *mm,
 
        /* cut the backing region down to size */
        region = vma->vm_region;
-       BUG_ON(atomic_read(&region->vm_usage) != 1);
+       BUG_ON(region->vm_usage != 1);
 
        down_write(&nommu_region_sem);
        delete_nommu_region(region);
@@ -1762,27 +1761,6 @@ void unmap_mapping_range(struct address_space *mapping,
 EXPORT_SYMBOL(unmap_mapping_range);
 
 /*
- * ask for an unmapped area at which to create a mapping on a file
- */
-unsigned long get_unmapped_area(struct file *file, unsigned long addr,
-                               unsigned long len, unsigned long pgoff,
-                               unsigned long flags)
-{
-       unsigned long (*get_area)(struct file *, unsigned long, unsigned long,
-                                 unsigned long, unsigned long);
-
-       get_area = current->mm->get_unmapped_area;
-       if (file && file->f_op && file->f_op->get_unmapped_area)
-               get_area = file->f_op->get_unmapped_area;
-
-       if (!get_area)
-               return -ENOSYS;
-
-       return get_area(file, addr, len, pgoff, flags);
-}
-EXPORT_SYMBOL(get_unmapped_area);
-
-/*
  * Check that a process has enough memory to allocate a new virtual
  * mapping. 0 means there is enough memory for the allocation to
  * succeed and -ENOMEM implies there is not.
@@ -1936,3 +1914,65 @@ int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, in
        mmput(mm);
        return len;
 }
+
+/**
+ * nommu_shrink_inode_mappings - Shrink the shared mappings on an inode
+ * @inode: The inode to check
+ * @size: The current filesize of the inode
+ * @newsize: The proposed filesize of the inode
+ *
+ * Check the shared mappings on an inode on behalf of a shrinking truncate to
+ * make sure that that any outstanding VMAs aren't broken and then shrink the
+ * vm_regions that extend that beyond so that do_mmap_pgoff() doesn't
+ * automatically grant mappings that are too large.
+ */
+int nommu_shrink_inode_mappings(struct inode *inode, size_t size,
+                               size_t newsize)
+{
+       struct vm_area_struct *vma;
+       struct prio_tree_iter iter;
+       struct vm_region *region;
+       pgoff_t low, high;
+       size_t r_size, r_top;
+
+       low = newsize >> PAGE_SHIFT;
+       high = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
+
+       down_write(&nommu_region_sem);
+
+       /* search for VMAs that fall within the dead zone */
+       vma_prio_tree_foreach(vma, &iter, &inode->i_mapping->i_mmap,
+                             low, high) {
+               /* found one - only interested if it's shared out of the page
+                * cache */
+               if (vma->vm_flags & VM_SHARED) {
+                       up_write(&nommu_region_sem);
+                       return -ETXTBSY; /* not quite true, but near enough */
+               }
+       }
+
+       /* reduce any regions that overlap the dead zone - if in existence,
+        * these will be pointed to by VMAs that don't overlap the dead zone
+        *
+        * we don't check for any regions that start beyond the EOF as there
+        * shouldn't be any
+        */
+       vma_prio_tree_foreach(vma, &iter, &inode->i_mapping->i_mmap,
+                             0, ULONG_MAX) {
+               if (!(vma->vm_flags & VM_SHARED))
+                       continue;
+
+               region = vma->vm_region;
+               r_size = region->vm_top - region->vm_start;
+               r_top = (region->vm_pgoff << PAGE_SHIFT) + r_size;
+
+               if (r_top > newsize) {
+                       region->vm_top -= r_top - newsize;
+                       if (region->vm_end > region->vm_top)
+                               region->vm_end = region->vm_top;
+               }
+       }
+
+       up_write(&nommu_region_sem);
+       return 0;
+}
index 4e9f5cc..d2a8889 100644 (file)
@@ -1222,10 +1222,10 @@ again:
                }
                spin_lock_irqsave(&zone->lock, flags);
                page = __rmqueue(zone, order, migratetype);
-               __mod_zone_page_state(zone, NR_FREE_PAGES, -(1 << order));
                spin_unlock(&zone->lock);
                if (!page)
                        goto failed;
+               __mod_zone_page_state(zone, NR_FREE_PAGES, -(1 << order));
        }
 
        __count_zone_vm_events(PGALLOC, zone, 1 << order);
@@ -3998,7 +3998,7 @@ void __init add_active_range(unsigned int nid, unsigned long start_pfn,
                }
 
                /* Merge backward if suitable */
-               if (start_pfn < early_node_map[i].end_pfn &&
+               if (start_pfn < early_node_map[i].start_pfn &&
                                end_pfn >= early_node_map[i].start_pfn) {
                        early_node_map[i].start_pfn = start_pfn;
                        return;
index 342deee..e87e372 100644 (file)
@@ -522,22 +522,20 @@ EXPORT_SYMBOL_GPL(invalidate_inode_pages2);
  */
 void truncate_pagecache(struct inode *inode, loff_t old, loff_t new)
 {
-       if (new < old) {
-               struct address_space *mapping = inode->i_mapping;
-
-               /*
-                * unmap_mapping_range is called twice, first simply for
-                * efficiency so that truncate_inode_pages does fewer
-                * single-page unmaps.  However after this first call, and
-                * before truncate_inode_pages finishes, it is possible for
-                * private pages to be COWed, which remain after
-                * truncate_inode_pages finishes, hence the second
-                * unmap_mapping_range call must be made for correctness.
-                */
-               unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1);
-               truncate_inode_pages(mapping, new);
-               unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1);
-       }
+       struct address_space *mapping = inode->i_mapping;
+
+       /*
+        * unmap_mapping_range is called twice, first simply for
+        * efficiency so that truncate_inode_pages does fewer
+        * single-page unmaps.  However after this first call, and
+        * before truncate_inode_pages finishes, it is possible for
+        * private pages to be COWed, which remain after
+        * truncate_inode_pages finishes, hence the second
+        * unmap_mapping_range call must be made for correctness.
+        */
+       unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1);
+       truncate_inode_pages(mapping, new);
+       unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1);
 }
 EXPORT_SYMBOL(truncate_pagecache);
 
index 7c35ad9..834db7b 100644 (file)
--- a/mm/util.c
+++ b/mm/util.c
@@ -220,7 +220,7 @@ char *strndup_user(const char __user *s, long n)
 }
 EXPORT_SYMBOL(strndup_user);
 
-#ifndef HAVE_ARCH_PICK_MMAP_LAYOUT
+#if defined(CONFIG_MMU) && !defined(HAVE_ARCH_PICK_MMAP_LAYOUT)
 void arch_pick_mmap_layout(struct mm_struct *mm)
 {
        mm->mmap_base = TASK_UNMAPPED_BASE;
index 885207a..c26986c 100644 (file)
@@ -1922,6 +1922,9 @@ static int sleeping_prematurely(pg_data_t *pgdat, int order, long remaining)
                if (!populated_zone(zone))
                        continue;
 
+               if (zone_is_all_unreclaimable(zone))
+                       continue;
+
                if (!zone_watermark_ok(zone, order, high_wmark_pages(zone),
                                                                0, 0))
                        return 1;
index df159ff..4bac362 100644 (file)
@@ -559,6 +559,11 @@ static inline struct inet6_dev *ipv6_skb_idev(struct sk_buff *skb)
        return skb_dst(skb) ? ip6_dst_idev(skb_dst(skb)) : __in6_dev_get(skb->dev);
 }
 
+static inline struct net *ipv6_skb_net(struct sk_buff *skb)
+{
+       return skb_dst(skb) ? dev_net(skb_dst(skb)->dev) : dev_net(skb->dev);
+}
+
 /* Router Alert as of RFC 2711 */
 
 static int ipv6_hop_ra(struct sk_buff *skb, int optoff)
@@ -580,8 +585,8 @@ static int ipv6_hop_ra(struct sk_buff *skb, int optoff)
 static int ipv6_hop_jumbo(struct sk_buff *skb, int optoff)
 {
        const unsigned char *nh = skb_network_header(skb);
+       struct net *net = ipv6_skb_net(skb);
        u32 pkt_len;
-       struct net *net = dev_net(skb_dst(skb)->dev);
 
        if (nh[optoff + 1] != 4 || (optoff & 3) != 2) {
                LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n",
index 80c16f6..32abae3 100644 (file)
 #include <linux/netdevice.h>
 #include <linux/rtnetlink.h>
 #include <net/mac80211.h>
+#include <net/ieee80211_radiotap.h>
 #include "ieee80211_i.h"
 #include "sta_info.h"
 #include "debugfs_netdev.h"
 #include "mesh.h"
 #include "led.h"
 #include "driver-ops.h"
+#include "wme.h"
 
 /**
  * DOC: Interface list locking
@@ -314,7 +316,7 @@ static int ieee80211_open(struct net_device *dev)
        if (sdata->vif.type == NL80211_IFTYPE_STATION)
                ieee80211_queue_work(&local->hw, &sdata->u.mgd.work);
 
-       netif_start_queue(dev);
+       netif_tx_start_all_queues(dev);
 
        return 0;
  err_del_interface:
@@ -343,7 +345,7 @@ static int ieee80211_stop(struct net_device *dev)
        /*
         * Stop TX on this interface first.
         */
-       netif_stop_queue(dev);
+       netif_tx_stop_all_queues(dev);
 
        /*
         * Now delete all active aggregation sessions.
@@ -644,6 +646,12 @@ static void ieee80211_teardown_sdata(struct net_device *dev)
        WARN_ON(flushed);
 }
 
+static u16 ieee80211_netdev_select_queue(struct net_device *dev,
+                                        struct sk_buff *skb)
+{
+       return ieee80211_select_queue(IEEE80211_DEV_TO_SUB_IF(dev), skb);
+}
+
 static const struct net_device_ops ieee80211_dataif_ops = {
        .ndo_open               = ieee80211_open,
        .ndo_stop               = ieee80211_stop,
@@ -652,8 +660,38 @@ static const struct net_device_ops ieee80211_dataif_ops = {
        .ndo_set_multicast_list = ieee80211_set_multicast_list,
        .ndo_change_mtu         = ieee80211_change_mtu,
        .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_select_queue       = ieee80211_netdev_select_queue,
 };
 
+static u16 ieee80211_monitor_select_queue(struct net_device *dev,
+                                         struct sk_buff *skb)
+{
+       struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+       struct ieee80211_local *local = sdata->local;
+       struct ieee80211_hdr *hdr;
+       struct ieee80211_radiotap_header *rtap = (void *)skb->data;
+       u8 *p;
+
+       if (local->hw.queues < 4)
+               return 0;
+
+       if (skb->len < 4 ||
+           skb->len < le16_to_cpu(rtap->it_len) + 2 /* frame control */)
+               return 0; /* doesn't matter, frame will be dropped */
+
+       hdr = (void *)((u8 *)skb->data + le16_to_cpu(rtap->it_len));
+
+       if (!ieee80211_is_data_qos(hdr->frame_control)) {
+               skb->priority = 7;
+               return ieee802_1d_to_ac[skb->priority];
+       }
+
+       p = ieee80211_get_qos_ctl(hdr);
+       skb->priority = *p & IEEE80211_QOS_CTL_TAG1D_MASK;
+
+       return ieee80211_downgrade_queue(local, skb);
+}
+
 static const struct net_device_ops ieee80211_monitorif_ops = {
        .ndo_open               = ieee80211_open,
        .ndo_stop               = ieee80211_stop,
@@ -662,6 +700,7 @@ static const struct net_device_ops ieee80211_monitorif_ops = {
        .ndo_set_multicast_list = ieee80211_set_multicast_list,
        .ndo_change_mtu         = ieee80211_change_mtu,
        .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_select_queue       = ieee80211_monitor_select_queue,
 };
 
 static void ieee80211_if_setup(struct net_device *dev)
@@ -768,8 +807,8 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
 
        ASSERT_RTNL();
 
-       ndev = alloc_netdev(sizeof(*sdata) + local->hw.vif_data_size,
-                           name, ieee80211_if_setup);
+       ndev = alloc_netdev_mq(sizeof(*sdata) + local->hw.vif_data_size,
+                              name, ieee80211_if_setup, local->hw.queues);
        if (!ndev)
                return -ENOMEM;
        dev_net_set(ndev, wiphy_net(local->hw.wiphy));
index c79e59f..05a18f4 100644 (file)
@@ -942,7 +942,7 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
        ieee80211_recalc_ps(local, -1);
        mutex_unlock(&local->iflist_mtx);
 
-       netif_start_queue(sdata->dev);
+       netif_tx_start_all_queues(sdata->dev);
        netif_carrier_on(sdata->dev);
 }
 
@@ -1074,7 +1074,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
         * time -- we don't want the scan code to enable queues.
         */
 
-       netif_stop_queue(sdata->dev);
+       netif_tx_stop_all_queues(sdata->dev);
        netif_carrier_off(sdata->dev);
 
        rcu_read_lock();
@@ -1963,7 +1963,9 @@ static void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
                        rma = ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len);
                        break;
                case IEEE80211_STYPE_ACTION:
-                       /* XXX: differentiate, can only happen for CSA now! */
+                       if (mgmt->u.action.category != WLAN_CATEGORY_SPECTRUM_MGMT)
+                               break;
+
                        ieee80211_sta_process_chanswitch(sdata,
                                        &mgmt->u.action.u.chan_switch.sw_elem,
                                        ifmgd->associated);
index 9f2807a..82a30c1 100644 (file)
@@ -1746,7 +1746,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
                        memset(info, 0, sizeof(*info));
                        info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
                        info->control.vif = &rx->sdata->vif;
-                       ieee80211_select_queue(local, fwd_skb);
+                       skb_set_queue_mapping(skb,
+                               ieee80211_select_queue(rx->sdata, fwd_skb));
+                       ieee80211_set_qos_hdr(local, skb);
                        if (is_multicast_ether_addr(fwd_hdr->addr1))
                                IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.mesh,
                                                                fwded_mcast);
@@ -2013,6 +2015,10 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
                }
                break;
        default:
+               /* do not process rejected action frames */
+               if (mgmt->u.action.category & 0x80)
+                       return RX_DROP_MONITOR;
+
                return RX_CONTINUE;
        }
 
index f1a4c71..f934c96 100644 (file)
@@ -353,10 +353,10 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
                if (sdata->vif.type == NL80211_IFTYPE_STATION) {
                        if (sdata->u.mgd.associated) {
                                ieee80211_scan_ps_disable(sdata);
-                               netif_wake_queue(sdata->dev);
+                               netif_tx_wake_all_queues(sdata->dev);
                        }
                } else
-                       netif_wake_queue(sdata->dev);
+                       netif_tx_wake_all_queues(sdata->dev);
 
                /* re-enable beaconing */
                if (sdata->vif.type == NL80211_IFTYPE_AP ||
@@ -411,7 +411,7 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local)
                 * are handled in the scan state machine
                 */
                if (sdata->vif.type != NL80211_IFTYPE_STATION)
-                       netif_stop_queue(sdata->dev);
+                       netif_tx_stop_all_queues(sdata->dev);
        }
        mutex_unlock(&local->iflist_mtx);
 
@@ -575,7 +575,7 @@ static void ieee80211_scan_state_leave_oper_channel(struct ieee80211_local *loca
                        continue;
 
                if (sdata->vif.type == NL80211_IFTYPE_STATION) {
-                       netif_stop_queue(sdata->dev);
+                       netif_tx_stop_all_queues(sdata->dev);
                        if (sdata->u.mgd.associated)
                                ieee80211_scan_ps_enable(sdata);
                }
@@ -610,7 +610,7 @@ static void ieee80211_scan_state_enter_oper_channel(struct ieee80211_local *loca
                if (sdata->vif.type == NL80211_IFTYPE_STATION) {
                        if (sdata->u.mgd.associated)
                                ieee80211_scan_ps_disable(sdata);
-                       netif_wake_queue(sdata->dev);
+                       netif_tx_wake_all_queues(sdata->dev);
                }
        }
        mutex_unlock(&local->iflist_mtx);
index 27ceaef..ac210b5 100644 (file)
@@ -1512,7 +1512,7 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
                                return;
                        }
 
-       ieee80211_select_queue(local, skb);
+       ieee80211_set_qos_hdr(local, skb);
        ieee80211_tx(sdata, skb, false);
        rcu_read_unlock();
 }
@@ -2291,6 +2291,9 @@ void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
        skb_set_network_header(skb, 0);
        skb_set_transport_header(skb, 0);
 
+       /* send all internal mgmt frames on VO */
+       skb_set_queue_mapping(skb, 0);
+
        /*
         * The other path calling ieee80211_xmit is from the tasklet,
         * and while we can handle concurrent transmissions locking
index dc76267..3848140 100644 (file)
@@ -269,6 +269,7 @@ static void __ieee80211_wake_queue(struct ieee80211_hw *hw, int queue,
                                   enum queue_stop_reason reason)
 {
        struct ieee80211_local *local = hw_to_local(hw);
+       struct ieee80211_sub_if_data *sdata;
 
        if (WARN_ON(queue >= hw->queues))
                return;
@@ -281,6 +282,11 @@ static void __ieee80211_wake_queue(struct ieee80211_hw *hw, int queue,
 
        if (!skb_queue_empty(&local->pending[queue]))
                tasklet_schedule(&local->tx_pending_tasklet);
+
+       rcu_read_lock();
+       list_for_each_entry_rcu(sdata, &local->interfaces, list)
+               netif_tx_wake_queue(netdev_get_tx_queue(sdata->dev, queue));
+       rcu_read_unlock();
 }
 
 void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
@@ -305,11 +311,17 @@ static void __ieee80211_stop_queue(struct ieee80211_hw *hw, int queue,
                                   enum queue_stop_reason reason)
 {
        struct ieee80211_local *local = hw_to_local(hw);
+       struct ieee80211_sub_if_data *sdata;
 
        if (WARN_ON(queue >= hw->queues))
                return;
 
        __set_bit(reason, &local->queue_stop_reasons[queue]);
+
+       rcu_read_lock();
+       list_for_each_entry_rcu(sdata, &local->interfaces, list)
+               netif_tx_stop_queue(netdev_get_tx_queue(sdata->dev, queue));
+       rcu_read_unlock();
 }
 
 void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
index b19b769..79d887d 100644 (file)
@@ -44,22 +44,69 @@ static int wme_downgrade_ac(struct sk_buff *skb)
 }
 
 
-/* Indicate which queue to use.  */
-static u16 classify80211(struct ieee80211_local *local, struct sk_buff *skb)
+/* Indicate which queue to use. */
+u16 ieee80211_select_queue(struct ieee80211_sub_if_data *sdata,
+                          struct sk_buff *skb)
 {
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+       struct ieee80211_local *local = sdata->local;
+       struct sta_info *sta = NULL;
+       u32 sta_flags = 0;
+       const u8 *ra = NULL;
+       bool qos = false;
 
-       if (!ieee80211_is_data(hdr->frame_control)) {
-               /* management frames go on AC_VO queue, but are sent
-               * without QoS control fields */
-               return 0;
+       if (local->hw.queues < 4 || skb->len < 6) {
+               skb->priority = 0; /* required for correct WPA/11i MIC */
+               return min_t(u16, local->hw.queues - 1,
+                            ieee802_1d_to_ac[skb->priority]);
+       }
+
+       rcu_read_lock();
+       switch (sdata->vif.type) {
+       case NL80211_IFTYPE_AP_VLAN:
+               rcu_read_lock();
+               sta = rcu_dereference(sdata->u.vlan.sta);
+               if (sta)
+                       sta_flags = get_sta_flags(sta);
+               rcu_read_unlock();
+               if (sta)
+                       break;
+       case NL80211_IFTYPE_AP:
+               ra = skb->data;
+               break;
+       case NL80211_IFTYPE_WDS:
+               ra = sdata->u.wds.remote_addr;
+               break;
+#ifdef CONFIG_MAC80211_MESH
+       case NL80211_IFTYPE_MESH_POINT:
+               /*
+                * XXX: This is clearly broken ... but already was before,
+                * because ieee80211_fill_mesh_addresses() would clear A1
+                * except for multicast addresses.
+                */
+               break;
+#endif
+       case NL80211_IFTYPE_STATION:
+               ra = sdata->u.mgd.bssid;
+               break;
+       case NL80211_IFTYPE_ADHOC:
+               ra = skb->data;
+               break;
+       default:
+               break;
        }
 
-       if (0 /* injected */) {
-               /* use AC from radiotap */
+       if (!sta && ra && !is_multicast_ether_addr(ra)) {
+               sta = sta_info_get(local, ra);
+               if (sta)
+                       sta_flags = get_sta_flags(sta);
        }
 
-       if (!ieee80211_is_data_qos(hdr->frame_control)) {
+       if (sta_flags & WLAN_STA_WME)
+               qos = true;
+
+       rcu_read_unlock();
+
+       if (!qos) {
                skb->priority = 0; /* required for correct WPA/11i MIC */
                return ieee802_1d_to_ac[skb->priority];
        }
@@ -68,6 +115,12 @@ static u16 classify80211(struct ieee80211_local *local, struct sk_buff *skb)
         * data frame has */
        skb->priority = cfg80211_classify8021d(skb);
 
+       return ieee80211_downgrade_queue(local, skb);
+}
+
+u16 ieee80211_downgrade_queue(struct ieee80211_local *local,
+                             struct sk_buff *skb)
+{
        /* in case we are a client verify acm is not set for this ac */
        while (unlikely(local->wmm_acm & BIT(skb->priority))) {
                if (wme_downgrade_ac(skb)) {
@@ -85,24 +138,17 @@ static u16 classify80211(struct ieee80211_local *local, struct sk_buff *skb)
        return ieee802_1d_to_ac[skb->priority];
 }
 
-void ieee80211_select_queue(struct ieee80211_local *local, struct sk_buff *skb)
+void ieee80211_set_qos_hdr(struct ieee80211_local *local, struct sk_buff *skb)
 {
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       u16 queue;
-       u8 tid;
-
-       queue = classify80211(local, skb);
-       if (unlikely(queue >= local->hw.queues))
-               queue = local->hw.queues - 1;
-
-       /*
-        * Now we know the 1d priority, fill in the QoS header if
-        * there is one (and we haven't done this before).
-        */
+       struct ieee80211_hdr *hdr = (void *)skb->data;
+
+       /* Fill in the QoS header if there is one. */
        if (ieee80211_is_data_qos(hdr->frame_control)) {
                u8 *p = ieee80211_get_qos_ctl(hdr);
-               u8 ack_policy = 0;
+               u8 ack_policy = 0, tid;
+
                tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
+
                if (unlikely(local->wifi_wme_noack_test))
                        ack_policy |= QOS_CONTROL_ACK_POLICY_NOACK <<
                                        QOS_CONTROL_ACK_POLICY_SHIFT;
@@ -110,6 +156,4 @@ void ieee80211_select_queue(struct ieee80211_local *local, struct sk_buff *skb)
                *p++ = ack_policy | tid;
                *p = 0;
        }
-
-       skb_set_queue_mapping(skb, queue);
 }
index d4fd87c..6053b1c 100644 (file)
 
 extern const int ieee802_1d_to_ac[8];
 
-void ieee80211_select_queue(struct ieee80211_local *local,
-                           struct sk_buff *skb);
+u16 ieee80211_select_queue(struct ieee80211_sub_if_data *sdata,
+                          struct sk_buff *skb);
+void ieee80211_set_qos_hdr(struct ieee80211_local *local, struct sk_buff *skb);
+u16 ieee80211_downgrade_queue(struct ieee80211_local *local,
+                              struct sk_buff *skb);
+
 
 #endif /* _WME_H */
index c2a2c56..92b8124 100644 (file)
@@ -745,9 +745,9 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
                        mutex_unlock(&rdev->devlist_mtx);
                        dev_put(dev);
                }
-#ifdef CONFIG_CFG80211_WEXT
                cfg80211_lock_rdev(rdev);
                mutex_lock(&rdev->devlist_mtx);
+#ifdef CONFIG_CFG80211_WEXT
                wdev_lock(wdev);
                switch (wdev->iftype) {
                case NL80211_IFTYPE_ADHOC:
@@ -760,10 +760,10 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
                        break;
                }
                wdev_unlock(wdev);
+#endif
                rdev->opencount++;
                mutex_unlock(&rdev->devlist_mtx);
                cfg80211_unlock_rdev(rdev);
-#endif
                break;
        case NETDEV_UNREGISTER:
                /*
index baa898a..7a0754c 100644 (file)
@@ -1690,7 +1690,7 @@ int regulatory_hint_user(const char *alpha2)
        request->wiphy_idx = WIPHY_IDX_STALE;
        request->alpha2[0] = alpha2[0];
        request->alpha2[1] = alpha2[1];
-       request->initiator = NL80211_REGDOM_SET_BY_USER,
+       request->initiator = NL80211_REGDOM_SET_BY_USER;
 
        queue_regulatory_request(request);
 
index 0fe48cd..f9bdf26 100644 (file)
@@ -219,8 +219,13 @@ for F in $1; do                                                            \
        fsize=$$(stat -c "%s" $$F);                                     \
        dec_size=$$(expr $$dec_size + $$fsize);                         \
 done;                                                                  \
-printf "%08x" $$dec_size |                                             \
-       sed 's/\(..\)\(..\)\(..\)\(..\)/\\\\x\4\\\\x\3\\\\x\2\\\\x\1/g' \
+printf "%08x\n" $$dec_size |                                           \
+       sed 's/\(..\)/\1 /g' | {                                        \
+               read ch0 ch1 ch2 ch3;                                   \
+               for ch in $$ch3 $$ch2 $$ch1 $$ch0; do                   \
+                       printf '%s%03o' '\\' $$((0x$$ch));              \
+               done;                                                   \
+       }                                                               \
 )
 
 quiet_cmd_bzip2 = BZIP2   $@
index 5f0fcb7..ce3e40b 100644 (file)
@@ -154,7 +154,7 @@ while (<STDIN>) {
        if ($line =~ /RIP: 0010:\[\<([a-z0-9]+)\>\]/) {
                $target = $1;
        }
-       if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) {
+       if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+0x([0-9a-f]+)\/0x[a-f0-9]/) {
                $function = $1;
                $func_offset = $2;
        }
index 6f426af..220213e 100644 (file)
@@ -804,7 +804,7 @@ static inline int sym_is(const char *symbol, const char *name)
        match = strstr(symbol, name);
        if (!match)
                return 0;
-       return match[strlen(symbol)] == '\0';
+       return match[strlen(name)] == '\0';
 }
 
 static void do_table(void *symval, unsigned long size,
index 92f09fe..ea6f6e3 100755 (executable)
@@ -194,7 +194,7 @@ sub check_objcopy
     }
 }
 
-if ($arch eq "x86") {
+if ($arch =~ /(x86(_64)?)|(i386)/) {
     if ($bits == 64) {
        $arch = "x86_64";
     } else {
index 8a00ade..2aceebf 100644 (file)
@@ -80,9 +80,8 @@ static int tomoyo_bprm_check_security(struct linux_binprm *bprm)
                return tomoyo_find_next_domain(bprm);
        /*
         * Read permission is checked against interpreters using next domain.
-        * '1' is the result of open_to_namei_flags(O_RDONLY).
         */
-       return tomoyo_check_open_permission(domain, &bprm->file->f_path, 1);
+       return tomoyo_check_open_permission(domain, &bprm->file->f_path, O_RDONLY);
 }
 
 static int tomoyo_path_truncate(struct path *path, loff_t length,
@@ -184,10 +183,6 @@ static int tomoyo_file_fcntl(struct file *file, unsigned int cmd,
 static int tomoyo_dentry_open(struct file *f, const struct cred *cred)
 {
        int flags = f->f_flags;
-
-       if ((flags + 1) & O_ACCMODE)
-               flags++;
-       flags |= f->f_flags & (O_APPEND | O_TRUNC);
        /* Don't check read permission here if called from do_execve(). */
        if (current->in_execve)
                return 0;
index 652a470..2e7fa3a 100644 (file)
@@ -250,7 +250,19 @@ PTHREAD_LIBS = -lpthread
 # explicitly what architecture to check for. Fix this up for yours..
 SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
 
-ifeq ($(shell sh -c "echo 'int foo(void) {char X[2]; return 3;}' | $(CC) -x c -c -Werror -fstack-protector-all - -o /dev/null "$(QUIET_STDERR)" && echo y"), y)
+ifeq ($(V), 2)
+       QUIET_STDERR = ">/dev/null"
+else
+       QUIET_STDERR = ">/dev/null 2>&1"
+endif
+
+BITBUCKET = "/dev/null"
+
+ifneq ($(shell sh -c "(echo '\#include <stdio.h>'; echo 'int main(void) { return puts(\"hi\"); }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) "$(QUIET_STDERR)" && echo y"), y)
+       BITBUCKET = .perf.dev.null
+endif
+
+ifeq ($(shell sh -c "echo 'int foo(void) {char X[2]; return 3;}' | $(CC) -x c -c -Werror -fstack-protector-all - -o $(BITBUCKET) "$(QUIET_STDERR)" && echo y"), y)
   CFLAGS := $(CFLAGS) -fstack-protector-all
 endif
 
@@ -451,11 +463,6 @@ BUILTIN_OBJS += builtin-kmem.o
 
 PERFLIBS = $(LIB_FILE)
 
-ifeq ($(V), 2)
-       QUIET_STDERR = ">/dev/null"
-else
-       QUIET_STDERR = ">/dev/null 2>&1"
-endif
 #
 # Platform specific tweaks
 #
@@ -483,19 +490,19 @@ ifeq ($(uname_S),Darwin)
        PTHREAD_LIBS =
 endif
 
-ifeq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
-ifneq ($(shell sh -c "(echo '\#include <gnu/libc-version.h>'; echo 'int main(void) { const char * version = gnu_get_libc_version(); return (long)version; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
+ifeq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
+ifneq ($(shell sh -c "(echo '\#include <gnu/libc-version.h>'; echo 'int main(void) { const char * version = gnu_get_libc_version(); return (long)version; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
        msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
 endif
 
-       ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
+       ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
                BASIC_CFLAGS += -DLIBELF_NO_MMAP
        endif
 else
        msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]);
 endif
 
-ifneq ($(shell sh -c "(echo '\#ifndef _MIPS_SZLONG'; echo '\#define _MIPS_SZLONG 0'; echo '\#endif'; echo '\#include <dwarf.h>'; echo '\#include <libdwarf.h>'; echo 'int main(void) { Dwarf_Debug dbg; Dwarf_Error err; Dwarf_Ranges *rng; dwarf_init(0, DW_DLC_READ, 0, 0, &dbg, &err); dwarf_get_ranges(dbg, 0, &rng, 0, 0, &err); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/libdwarf -ldwarf -lelf -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
+ifneq ($(shell sh -c "(echo '\#ifndef _MIPS_SZLONG'; echo '\#define _MIPS_SZLONG 0'; echo '\#endif'; echo '\#include <dwarf.h>'; echo '\#include <libdwarf.h>'; echo 'int main(void) { Dwarf_Debug dbg; Dwarf_Error err; Dwarf_Ranges *rng; dwarf_init(0, DW_DLC_READ, 0, 0, &dbg, &err); dwarf_get_ranges(dbg, 0, &rng, 0, 0, &err); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/libdwarf -ldwarf -lelf -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
        msg := $(warning No libdwarf.h found or old libdwarf.h found, disables dwarf support. Please install libdwarf-dev/libdwarf-devel >= 20081231);
        BASIC_CFLAGS += -DNO_LIBDWARF
 else
@@ -509,7 +516,7 @@ PERL_EMBED_LDOPTS = `perl -MExtUtils::Embed -e ldopts 2>/dev/null`
 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
 endif
 
-ifneq ($(shell sh -c "(echo '\#include <EXTERN.h>'; echo '\#include <perl.h>'; echo 'int main(void) { perl_alloc(); return 0; }') | $(CC) -x c - $(PERL_EMBED_CCOPTS) -o /dev/null $(PERL_EMBED_LDOPTS) > /dev/null 2>&1 && echo y"), y)
+ifneq ($(shell sh -c "(echo '\#include <EXTERN.h>'; echo '\#include <perl.h>'; echo 'int main(void) { perl_alloc(); return 0; }') | $(CC) -x c - $(PERL_EMBED_CCOPTS) -o $(BITBUCKET) $(PERL_EMBED_LDOPTS) > /dev/null 2>&1 && echo y"), y)
        BASIC_CFLAGS += -DNO_LIBPERL
 else
        ALL_LDFLAGS += $(PERL_EMBED_LDOPTS)
@@ -519,20 +526,20 @@ endif
 ifdef NO_DEMANGLE
        BASIC_CFLAGS += -DNO_DEMANGLE
 else
-       has_bfd := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) -lbfd "$(QUIET_STDERR)" && echo y")
+       has_bfd := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd "$(QUIET_STDERR)" && echo y")
 
        ifeq ($(has_bfd),y)
                EXTLIBS += -lbfd
        else
-               has_bfd_iberty := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty "$(QUIET_STDERR)" && echo y")
+               has_bfd_iberty := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty "$(QUIET_STDERR)" && echo y")
                ifeq ($(has_bfd_iberty),y)
                        EXTLIBS += -lbfd -liberty
                else
-                       has_bfd_iberty_z := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty -lz "$(QUIET_STDERR)" && echo y")
+                       has_bfd_iberty_z := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty -lz "$(QUIET_STDERR)" && echo y")
                        ifeq ($(has_bfd_iberty_z),y)
                                EXTLIBS += -lbfd -liberty -lz
                        else
-                               has_cplus_demangle := $(shell sh -c "(echo 'extern char *cplus_demangle(const char *, int);'; echo 'int main(void) { cplus_demangle(0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) -liberty "$(QUIET_STDERR)" && echo y")
+                               has_cplus_demangle := $(shell sh -c "(echo 'extern char *cplus_demangle(const char *, int);'; echo 'int main(void) { cplus_demangle(0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -liberty "$(QUIET_STDERR)" && echo y")
                                ifeq ($(has_cplus_demangle),y)
                                        EXTLIBS += -liberty
                                        BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
@@ -780,7 +787,7 @@ export TAR INSTALL DESTDIR SHELL_PATH
 
 SHELL = $(SHELL_PATH)
 
-all:: shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) PERF-BUILD-OPTIONS
+all:: .perf.dev.null shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) PERF-BUILD-OPTIONS
 ifneq (,$X)
        $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) perf$X)), test '$p' -ef '$p$X' || $(RM) '$p';)
 endif
@@ -1107,6 +1114,11 @@ clean:
 .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS
 .PHONY: .FORCE-PERF-BUILD-OPTIONS
 
+.perf.dev.null:
+               touch .perf.dev.null
+
+.INTERMEDIATE: .perf.dev.null
+
 ### Make sure built-ins do not have dups and listed in perf.c
 #
 check-builtins::