From abacaf47436e2f92313475c79d81eab77f99819b Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Fri, 19 Jun 2009 11:45:01 -0700 Subject: recipe_sanity.bbclass: add check to handle bugs wrt var expansions in var names. Signed-off-by: Chris Larson --- classes/recipe_sanity.bbclass | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/classes/recipe_sanity.bbclass b/classes/recipe_sanity.bbclass index 4d00ddf1e5..60fcfabfb7 100644 --- a/classes/recipe_sanity.bbclass +++ b/classes/recipe_sanity.bbclass @@ -1,3 +1,14 @@ +def __note(msg, d): + import bb + bb.note("%s: recipe_sanity: %s" % (d.getVar("P", 1), msg)) + +def var_renames_overwrite(cfgdata, d): + renames = d.getVar("__recipe_sanity_renames", 0) + if renames: + for (key, newkey, oldvalue, newvalue) in renames: + if oldvalue != newvalue and oldvalue != cfgdata.get(newkey): + __note("rename of variable '%s' to '%s' overwrote existing value '%s' with '%s'." % (key, newkey, oldvalue, newvalue), d) + def incorrect_nonempty_PACKAGES(cfgdata, d): import bb.data if bb.data.inherits_class("native", d) or \ @@ -19,7 +30,7 @@ def can_use_autotools_base(cfgdata, d): for clsfile in d.getVar("__inherit_cache", 0): (base, _) = os.path.splitext(os.path.basename(clsfile)) if cfg.find("%s_do_configure" % base) != -1: - bb.note("%s: recipe_sanity: autotools_base usage needs verification, spotted %s" % (d.getVar("P", 1), "%s_do_configure" % base)) + __note("autotools_base usage needs verification, spotted %s_do_configure" % base, d) return True @@ -34,7 +45,8 @@ def can_remove_FILESPATH(cfgdata, d): filespath = [os.path.normpath(f) for f in filespath if os.path.exists(f)] for fp in filespath: if not fp in expectedpaths: - # bb.note("Path %s in FILESPATH not in the expected paths %s" % (fp, expectedpaths)) + # __note("Path %s in FILESPATH not in the expected paths %s" % + # (fp, expectedpaths), d) return False return expected != unexpanded @@ -74,7 +86,7 @@ def can_remove_others(p, cfgdata, d): if unexpanded != cfgunexpanded and \ cfgexpanded == expanded: - bb.note("%s: recipe_sanity: candidate for removal of %s" % (p, k)) + __note("candidate for removal of %s" % k, d) bb.debug(1, "%s: recipe_sanity: cfg's '%s' and d's '%s' both expand to %s" % (p, cfgunexpanded, unexpanded, expanded)) @@ -92,9 +104,10 @@ python do_recipe_sanity () { for (func, msg) in sanitychecks: if func(cfgdata, d): - bb.note("%s: recipe_sanity: %s" % (p, msg)) + __note(msg, d) can_remove_others(p, cfgdata, d) + var_renames_overwrite(cfgdata, d) } do_recipe_sanity[nostamp] = "1" #do_recipe_sanity[recrdeptask] = "do_recipe_sanity" @@ -122,5 +135,18 @@ python recipe_sanity_eh () { cfgdata[k] = d.getVar(k, 0) d.setVar("__recipe_sanity_cfgdata", cfgdata) + + # Sick, very sick.. + from bb.data_smart import DataSmart + old = DataSmart.renameVar + def myrename(self, key, newkey): + oldvalue = self.getVar(newkey, 0) + old(self, key, newkey) + newvalue = self.getVar(newkey, 0) + if oldvalue: + renames = self.getVar("__recipe_sanity_renames", 0) or set() + renames.add((key, newkey, oldvalue, newvalue)) + self.setVar("__recipe_sanity_renames", renames) + DataSmart.renameVar = myrename } addhandler recipe_sanity_eh -- cgit v1.2.3 From 4ba936611771031c0b0f33d22a59f865ec1c4787 Mon Sep 17 00:00:00 2001 From: Holger Schurig Date: Fri, 19 Jun 2009 20:59:32 +0200 Subject: glibc: fix "extract" and "munge"/"configure" for ancient glibc 2.3.5+cvs * ld.so.conf was specified, but missing * syntax error in *.bb file: missing "}" --- recipes/glibc/glibc-2.3.5+cvs/etc/ld.so.conf | 2 ++ recipes/glibc/glibc_2.3.5+cvs20050627.bb | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 recipes/glibc/glibc-2.3.5+cvs/etc/ld.so.conf diff --git a/recipes/glibc/glibc-2.3.5+cvs/etc/ld.so.conf b/recipes/glibc/glibc-2.3.5+cvs/etc/ld.so.conf new file mode 100644 index 0000000000..46e06d3f0a --- /dev/null +++ b/recipes/glibc/glibc-2.3.5+cvs/etc/ld.so.conf @@ -0,0 +1,2 @@ +/usr/local/lib + diff --git a/recipes/glibc/glibc_2.3.5+cvs20050627.bb b/recipes/glibc/glibc_2.3.5+cvs20050627.bb index 5fa4010a69..1d4dd0d393 100644 --- a/recipes/glibc/glibc_2.3.5+cvs20050627.bb +++ b/recipes/glibc/glibc_2.3.5+cvs20050627.bb @@ -51,7 +51,7 @@ SRC_URI = "http://familiar.handhelds.org/source/v0.8.3/stash_libc_sources.redhat file://zecke-sane-readelf.patch;patch=1 \ file://glibc-2.3.5-fix-weak-alias-arm.patch;patch=1 \ file://glibc-2.3.5-fix-weak-alias-arm-2.patch;patch=1 \ - file://etc/ld.so.conf \ + file://etc/ld.so.conf \ file://generate-supported.mk" # seems to fail on tls platforms @@ -74,7 +74,7 @@ EXTRA_OECONF = "--enable-kernel=${OLDEST_KERNEL} \ --without-cvs --disable-profile --disable-debug --without-gd \ --enable-clocale=gnu \ --enable-add-ons=${GLIBC_ADDONS} \ - --with-headers=${STAGING_INCDIR \ + --with-headers=${STAGING_INCDIR} \ --without-selinux \ ${GLIBC_EXTRA_OECONF}" -- cgit v1.2.3 From f090fe6b95e9a4b60341ab324b56569ea447cba0 Mon Sep 17 00:00:00 2001 From: Holger Schurig Date: Fri, 19 Jun 2009 21:07:56 +0200 Subject: glibc: move missing ld.so.conf into correct directory my previous patch was erraneous (Thou shalt not develop on one box and commit on another box ...) --- recipes/glibc/glibc-2.3.5+cvs/etc/ld.so.conf | 2 -- recipes/glibc/glibc-cvs-2.3.5/etc/ld.so.conf | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 recipes/glibc/glibc-2.3.5+cvs/etc/ld.so.conf create mode 100644 recipes/glibc/glibc-cvs-2.3.5/etc/ld.so.conf diff --git a/recipes/glibc/glibc-2.3.5+cvs/etc/ld.so.conf b/recipes/glibc/glibc-2.3.5+cvs/etc/ld.so.conf deleted file mode 100644 index 46e06d3f0a..0000000000 --- a/recipes/glibc/glibc-2.3.5+cvs/etc/ld.so.conf +++ /dev/null @@ -1,2 +0,0 @@ -/usr/local/lib - diff --git a/recipes/glibc/glibc-cvs-2.3.5/etc/ld.so.conf b/recipes/glibc/glibc-cvs-2.3.5/etc/ld.so.conf new file mode 100644 index 0000000000..46e06d3f0a --- /dev/null +++ b/recipes/glibc/glibc-cvs-2.3.5/etc/ld.so.conf @@ -0,0 +1,2 @@ +/usr/local/lib + -- cgit v1.2.3 From 01c214c0d1c1a8e8ced560e03bc74c3ea2708575 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Fri, 19 Jun 2009 12:14:04 -0700 Subject: recipe_sanity.bbclass: add checks for missing/default variables By default, for now, it just checks for LICENSE being left as default when SRC_URI is set, and an empty DESCRIPTION, which freaks out the packaging classes. Signed-off-by: Chris Larson --- classes/recipe_sanity.bbclass | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/classes/recipe_sanity.bbclass b/classes/recipe_sanity.bbclass index 60fcfabfb7..870a83f6c3 100644 --- a/classes/recipe_sanity.bbclass +++ b/classes/recipe_sanity.bbclass @@ -2,6 +2,27 @@ def __note(msg, d): import bb bb.note("%s: recipe_sanity: %s" % (d.getVar("P", 1), msg)) +__recipe_sanity_reqvars = "DESCRIPTION" +__recipe_sanity_reqdiffvars = "LICENSE" +def req_vars(cfgdata, d): + for var in d.getVar("__recipe_sanity_reqvars", 1).split(): + if not d.getVar(var, 0): + __note("%s should be set" % var, d) + + for var in d.getVar("__recipe_sanity_reqdiffvars", 1).split(): + val = d.getVar(var, 0) + cfgval = cfgdata.get(var) + + # Hardcoding is bad, but I'm lazy. We don't care about license being + # unset if the recipe has no sources! + if var == "LICENSE" and d.getVar("SRC_URI", 1) == cfgdata.get("SRC_URI"): + continue + + if not val: + __note("%s should be set" % var, d) + elif val == cfgval: + __note("%s should be defined to something other than default (%s)" % (var, cfgval), d) + def var_renames_overwrite(cfgdata, d): renames = d.getVar("__recipe_sanity_renames", 0) if renames: @@ -108,6 +129,7 @@ python do_recipe_sanity () { can_remove_others(p, cfgdata, d) var_renames_overwrite(cfgdata, d) + req_vars(cfgdata, d) } do_recipe_sanity[nostamp] = "1" #do_recipe_sanity[recrdeptask] = "do_recipe_sanity" @@ -135,6 +157,7 @@ python recipe_sanity_eh () { cfgdata[k] = d.getVar(k, 0) d.setVar("__recipe_sanity_cfgdata", cfgdata) + #d.setVar("__recipe_sanity_cfgdata", d) # Sick, very sick.. from bb.data_smart import DataSmart -- cgit v1.2.3 From 91cdbe63a724125d65d3ec7bf81d84cef16ec653 Mon Sep 17 00:00:00 2001 From: Phil Blundell Date: Fri, 19 Jun 2009 20:26:26 +0100 Subject: micro-uclibc: avoid selection of crazy iphone stuff as provider for iconv --- conf/distro/micro-uclibc.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/distro/micro-uclibc.conf b/conf/distro/micro-uclibc.conf index 1135035fe9..08d8e303cf 100644 --- a/conf/distro/micro-uclibc.conf +++ b/conf/distro/micro-uclibc.conf @@ -38,6 +38,7 @@ PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}libc-for-gcc = "uclibc" PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}binutils = "binutils-cross" PREFERRED_PROVIDER_linux-libc-headers = "linux-libc-headers" PREFERRED_PROVIDER_virtual/libintl = "proxy-libintl" +PREFERRED_PROVIDER_virtual/libiconv = "libiconv" ############################################################################# # PREFERRED VERSIONS -- cgit v1.2.3 From df7ddd8feaeab6b39ee784a581dfd723d79e9b80 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Fri, 19 Jun 2009 12:32:21 -0700 Subject: recipe_sanity.bbclass: add checks for "bad" vars like RDEPENDS/RPROVIDES. Signed-off-by: Chris Larson --- classes/recipe_sanity.bbclass | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/classes/recipe_sanity.bbclass b/classes/recipe_sanity.bbclass index 870a83f6c3..3b834c8223 100644 --- a/classes/recipe_sanity.bbclass +++ b/classes/recipe_sanity.bbclass @@ -2,6 +2,13 @@ def __note(msg, d): import bb bb.note("%s: recipe_sanity: %s" % (d.getVar("P", 1), msg)) +__recipe_sanity_badvars = "RDEPENDS RPROVIDES" +def bad_vars(cfgdata, d): + for var in d.getVar("__recipe_sanity_badvars", 1).split(): + val = d.getVar(var, 0) + if val and val != cfgdata.get(var): + __note("%s should not be set, but is set to '%s'" % (var, val), d) + __recipe_sanity_reqvars = "DESCRIPTION" __recipe_sanity_reqdiffvars = "LICENSE" def req_vars(cfgdata, d): @@ -130,6 +137,7 @@ python do_recipe_sanity () { can_remove_others(p, cfgdata, d) var_renames_overwrite(cfgdata, d) req_vars(cfgdata, d) + bad_vars(cfgdata, d) } do_recipe_sanity[nostamp] = "1" #do_recipe_sanity[recrdeptask] = "do_recipe_sanity" -- cgit v1.2.3 From 715ccad5fe7ebf50661b8787a17091a76474a5fa Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Fri, 19 Jun 2009 12:48:28 -0700 Subject: recipe_sanity.bbclass: only check RPROVIDES/RDEPENDS in target recipes. Signed-off-by: Chris Larson --- classes/recipe_sanity.bbclass | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/classes/recipe_sanity.bbclass b/classes/recipe_sanity.bbclass index 3b834c8223..29f4a8fada 100644 --- a/classes/recipe_sanity.bbclass +++ b/classes/recipe_sanity.bbclass @@ -2,9 +2,14 @@ def __note(msg, d): import bb bb.note("%s: recipe_sanity: %s" % (d.getVar("P", 1), msg)) -__recipe_sanity_badvars = "RDEPENDS RPROVIDES" -def bad_vars(cfgdata, d): - for var in d.getVar("__recipe_sanity_badvars", 1).split(): +__recipe_sanity_badtargetvars = "RDEPENDS RPROVIDES" +def bad_target_vars(cfgdata, d): + import bb.data + if bb.data.inherits_class("native", d) or \ + bb.data.inherits_class("cross", d): + return + + for var in d.getVar("__recipe_sanity_badtargetvars", 1).split(): val = d.getVar(var, 0) if val and val != cfgdata.get(var): __note("%s should not be set, but is set to '%s'" % (var, val), d) @@ -137,7 +142,7 @@ python do_recipe_sanity () { can_remove_others(p, cfgdata, d) var_renames_overwrite(cfgdata, d) req_vars(cfgdata, d) - bad_vars(cfgdata, d) + bad_target_vars(cfgdata, d) } do_recipe_sanity[nostamp] = "1" #do_recipe_sanity[recrdeptask] = "do_recipe_sanity" -- cgit v1.2.3 From 4229c7118238b54c2b221ca65522bbf4780eea53 Mon Sep 17 00:00:00 2001 From: Dieter Thimm Date: Sat, 13 Jun 2009 01:19:06 +0200 Subject: This is the Boardfile, defconfig, Kerneldiff and adapted bb file for the new tx25 ka-ro Board. --- conf/machine/tx25.conf | 29 + recipes/linux/linux-2.6.30/tx25/defconfig | 1203 ++ .../linux-2.6.30/tx25/linux-2.6.30-rc4-karo.diff | 17631 +++++++++++++++++++ recipes/linux/linux_2.6.30.bb | 3 + 4 files changed, 18866 insertions(+) create mode 100644 conf/machine/tx25.conf create mode 100644 recipes/linux/linux-2.6.30/tx25/defconfig create mode 100644 recipes/linux/linux-2.6.30/tx25/linux-2.6.30-rc4-karo.diff diff --git a/conf/machine/tx25.conf b/conf/machine/tx25.conf new file mode 100644 index 0000000000..92a8fef3df --- /dev/null +++ b/conf/machine/tx25.conf @@ -0,0 +1,29 @@ +#@TYPE: Machine +#@Name: KARO TX25 +#@DESCRIPTION: Machine configuration for Freescale i.MX25 based Karo TX25 + baseboard + +TARGET_ARCH = "arm" + +MACHINE_FEATURES = "kernel26 apm alsa ext2 pcmcia usbhost usbgadget screen camera" + +GUI_MACHINE_CLASS = "bigscreen" + +PREFERRED_PROVIDER_virtual/kernel = "linux" +PREFERRED_VERSION_linux = "2.6.30" +PREFERRED_PROVIDER_virtual/xserver = "xserver-kdrive" +XSERVER = "xserver-kdrive-fbdev" + +require conf/machine/include/tune-arm926ejs.inc + +# used by sysvinit_2 +SERIAL_CONSOLE = "115200 ttymxc0" + +ROOT_FLASH_SIZE = "128" + +IMAGE_FSTYPES ?= "jffs2" + +EXTRA_IMAGECMD_jffs2 = "--little-endian --eraseblock=0x20000 -n \ + --pad ; sumtool --eraseblock=0x20000 -n \ + --littleendian --pad \ + -i ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.jffs2 \ + -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.jffs2.summary" diff --git a/recipes/linux/linux-2.6.30/tx25/defconfig b/recipes/linux/linux-2.6.30/tx25/defconfig new file mode 100644 index 0000000000..db27e0251f --- /dev/null +++ b/recipes/linux/linux-2.6.30/tx25/defconfig @@ -0,0 +1,1203 @@ +# +# Automatically generated make config: don't edit +# Linux kernel version: 2.6.30-rc4 +# Tue Jun 2 15:46:43 2009 +# +CONFIG_ARM=y +CONFIG_SYS_SUPPORTS_APM_EMULATION=y +CONFIG_GENERIC_GPIO=y +CONFIG_GENERIC_TIME=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_MMU=y +# CONFIG_NO_IOPORT is not set +CONFIG_GENERIC_HARDIRQS=y +CONFIG_STACKTRACE_SUPPORT=y +CONFIG_HAVE_LATENCYTOP_SUPPORT=y +CONFIG_LOCKDEP_SUPPORT=y +CONFIG_TRACE_IRQFLAGS_SUPPORT=y +CONFIG_HARDIRQS_SW_RESEND=y +CONFIG_GENERIC_IRQ_PROBE=y +CONFIG_RWSEM_GENERIC_SPINLOCK=y +# CONFIG_ARCH_HAS_ILOG2_U32 is not set +# CONFIG_ARCH_HAS_ILOG2_U64 is not set +CONFIG_GENERIC_HWEIGHT=y +CONFIG_GENERIC_CALIBRATE_DELAY=y +CONFIG_ARCH_MTD_XIP=y +CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y +CONFIG_VECTORS_BASE=0xffff0000 +CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" + +# +# General setup +# +CONFIG_EXPERIMENTAL=y +CONFIG_BROKEN_ON_SMP=y +CONFIG_LOCK_KERNEL=y +CONFIG_INIT_ENV_ARG_LIMIT=32 +CONFIG_LOCALVERSION="" +CONFIG_LOCALVERSION_AUTO=y +# CONFIG_SWAP is not set +CONFIG_SYSVIPC=y +CONFIG_SYSVIPC_SYSCTL=y +CONFIG_POSIX_MQUEUE=y +CONFIG_POSIX_MQUEUE_SYSCTL=y +# CONFIG_BSD_PROCESS_ACCT is not set +# CONFIG_TASKSTATS is not set +# CONFIG_AUDIT is not set + +# +# RCU Subsystem +# +CONFIG_CLASSIC_RCU=y +# CONFIG_TREE_RCU is not set +# CONFIG_PREEMPT_RCU is not set +# CONFIG_TREE_RCU_TRACE is not set +# CONFIG_PREEMPT_RCU_TRACE is not set +# CONFIG_IKCONFIG is not set +CONFIG_LOG_BUF_SHIFT=17 +# CONFIG_GROUP_SCHED is not set +# CONFIG_CGROUPS is not set +# CONFIG_SYSFS_DEPRECATED_V2 is not set +# CONFIG_RELAY is not set +# CONFIG_NAMESPACES is not set +CONFIG_BLK_DEV_INITRD=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_RD_GZIP=y +# CONFIG_RD_BZIP2 is not set +# CONFIG_RD_LZMA is not set +# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set +CONFIG_SYSCTL=y +CONFIG_ANON_INODES=y +CONFIG_EMBEDDED=y +CONFIG_UID16=y +CONFIG_SYSCTL_SYSCALL=y +CONFIG_KALLSYMS=y +# CONFIG_KALLSYMS_ALL is not set +# CONFIG_KALLSYMS_EXTRA_PASS is not set +# CONFIG_STRIP_ASM_SYMS is not set +CONFIG_HOTPLUG=y +CONFIG_PRINTK=y +CONFIG_BUG=y +# CONFIG_ELF_CORE is not set +CONFIG_BASE_FULL=y +CONFIG_FUTEX=y +CONFIG_EPOLL=y +CONFIG_SIGNALFD=y +CONFIG_TIMERFD=y +CONFIG_EVENTFD=y +CONFIG_SHMEM=y +# CONFIG_AIO is not set +# CONFIG_VM_EVENT_COUNTERS is not set +# CONFIG_COMPAT_BRK is not set +CONFIG_SLAB=y +# CONFIG_SLUB is not set +# CONFIG_SLOB is not set +# CONFIG_PROFILING is not set +# CONFIG_MARKERS is not set +CONFIG_HAVE_OPROFILE=y +# CONFIG_KPROBES is not set +CONFIG_HAVE_KPROBES=y +CONFIG_HAVE_KRETPROBES=y +CONFIG_HAVE_CLK=y +# CONFIG_SLOW_WORK is not set +CONFIG_HAVE_GENERIC_DMA_COHERENT=y +CONFIG_SLABINFO=y +CONFIG_RT_MUTEXES=y +CONFIG_BASE_SMALL=0 +CONFIG_MODULES=y +# CONFIG_MODULE_FORCE_LOAD is not set +CONFIG_MODULE_UNLOAD=y +CONFIG_MODULE_FORCE_UNLOAD=y +CONFIG_MODVERSIONS=y +# CONFIG_MODULE_SRCVERSION_ALL is not set +CONFIG_BLOCK=y +CONFIG_LBD=y +# CONFIG_BLK_DEV_BSG is not set +# CONFIG_BLK_DEV_INTEGRITY is not set + +# +# IO Schedulers +# +CONFIG_IOSCHED_NOOP=y +CONFIG_IOSCHED_AS=y +CONFIG_IOSCHED_DEADLINE=y +CONFIG_IOSCHED_CFQ=y +CONFIG_DEFAULT_AS=y +# CONFIG_DEFAULT_DEADLINE is not set +# CONFIG_DEFAULT_CFQ is not set +# CONFIG_DEFAULT_NOOP is not set +CONFIG_DEFAULT_IOSCHED="anticipatory" +CONFIG_FREEZER=y + +# +# System Type +# +# CONFIG_ARCH_AAEC2000 is not set +# CONFIG_ARCH_INTEGRATOR is not set +# CONFIG_ARCH_REALVIEW is not set +# CONFIG_ARCH_VERSATILE is not set +# CONFIG_ARCH_AT91 is not set +# CONFIG_ARCH_CLPS711X is not set +# CONFIG_ARCH_EBSA110 is not set +# CONFIG_ARCH_EP93XX is not set +# CONFIG_ARCH_GEMINI is not set +# CONFIG_ARCH_FOOTBRIDGE is not set +# CONFIG_ARCH_NETX is not set +# CONFIG_ARCH_H720X is not set +# CONFIG_ARCH_IOP13XX is not set +# CONFIG_ARCH_IOP32X is not set +# CONFIG_ARCH_IOP33X is not set +# CONFIG_ARCH_IXP23XX is not set +# CONFIG_ARCH_IXP2000 is not set +# CONFIG_ARCH_IXP4XX is not set +# CONFIG_ARCH_L7200 is not set +# CONFIG_ARCH_KIRKWOOD is not set +# CONFIG_ARCH_KS8695 is not set +# CONFIG_ARCH_NS9XXX is not set +# CONFIG_ARCH_LOKI is not set +# CONFIG_ARCH_MV78XX0 is not set +CONFIG_ARCH_MXC=y +# CONFIG_ARCH_ORION5X is not set +# CONFIG_ARCH_PNX4008 is not set +# CONFIG_ARCH_PXA is not set +# CONFIG_ARCH_MMP is not set +# CONFIG_ARCH_RPC is not set +# CONFIG_ARCH_SA1100 is not set +# CONFIG_ARCH_S3C2410 is not set +# CONFIG_ARCH_S3C64XX is not set +# CONFIG_ARCH_SHARK is not set +# CONFIG_ARCH_LH7A40X is not set +# CONFIG_ARCH_DAVINCI is not set +# CONFIG_ARCH_OMAP is not set +# CONFIG_ARCH_MSM is not set +# CONFIG_ARCH_W90X900 is not set + +# +# Freescale MXC Implementations +# +# CONFIG_ARCH_MX1 is not set +CONFIG_ARCH_MX2=y +# CONFIG_ARCH_MX3 is not set +# CONFIG_MACH_MX21 is not set +# CONFIG_MACH_MX27 is not set +CONFIG_MACH_MX25=y + +# +# MX2 platforms: +# +CONFIG_MACH_TX25=y +# CONFIG_KARO_DEBUG is not set +CONFIG_MACH_STK5_BASEBOARD=y +# CONFIG_MXC_IRQ_PRIOR is not set +# CONFIG_MXC_PWM is not set +CONFIG_ARCH_MXC_IOMUX_V3=y + +# +# Processor Type +# +CONFIG_CPU_32=y +CONFIG_CPU_ARM926T=y +CONFIG_CPU_32v5=y +CONFIG_CPU_ABRT_EV5TJ=y +CONFIG_CPU_PABRT_NOIFAR=y +CONFIG_CPU_CACHE_VIVT=y +CONFIG_CPU_COPY_V4WB=y +CONFIG_CPU_TLB_V4WBI=y +CONFIG_CPU_CP15=y +CONFIG_CPU_CP15_MMU=y + +# +# Processor Features +# +CONFIG_ARM_THUMB=y +# CONFIG_CPU_ICACHE_DISABLE is not set +# CONFIG_CPU_DCACHE_DISABLE is not set +# CONFIG_CPU_DCACHE_WRITETHROUGH is not set +# CONFIG_CPU_CACHE_ROUND_ROBIN is not set +# CONFIG_OUTER_CACHE is not set +CONFIG_COMMON_CLKDEV=y + +# +# Bus support +# +# CONFIG_PCI_SYSCALL is not set +# CONFIG_ARCH_SUPPORTS_MSI is not set +# CONFIG_PCCARD is not set + +# +# Kernel Features +# +CONFIG_TICK_ONESHOT=y +CONFIG_NO_HZ=y +# CONFIG_HIGH_RES_TIMERS is not set +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y +CONFIG_VMSPLIT_3G=y +# CONFIG_VMSPLIT_2G is not set +# CONFIG_VMSPLIT_1G is not set +CONFIG_PAGE_OFFSET=0xC0000000 +CONFIG_PREEMPT=y +CONFIG_HZ=100 +CONFIG_AEABI=y +CONFIG_OABI_COMPAT=y +CONFIG_ARCH_FLATMEM_HAS_HOLES=y +# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set +# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set +# CONFIG_HIGHMEM is not set +CONFIG_SELECT_MEMORY_MODEL=y +CONFIG_FLATMEM_MANUAL=y +# CONFIG_DISCONTIGMEM_MANUAL is not set +# CONFIG_SPARSEMEM_MANUAL is not set +CONFIG_FLATMEM=y +CONFIG_FLAT_NODE_MEM_MAP=y +CONFIG_PAGEFLAGS_EXTENDED=y +CONFIG_SPLIT_PTLOCK_CPUS=4096 +# CONFIG_PHYS_ADDR_T_64BIT is not set +CONFIG_ZONE_DMA_FLAG=0 +CONFIG_VIRT_TO_BUS=y +CONFIG_UNEVICTABLE_LRU=y +CONFIG_HAVE_MLOCK=y +CONFIG_HAVE_MLOCKED_PAGE_BIT=y +CONFIG_ALIGNMENT_TRAP=y + +# +# Boot options +# +CONFIG_ZBOOT_ROM_TEXT=0 +CONFIG_ZBOOT_ROM_BSS=0 +CONFIG_CMDLINE="init=/linuxrc root=1f01 rootfstype=jffs2 ro console=ttymxc0,115200 panic=1" +# CONFIG_XIP_KERNEL is not set +# CONFIG_KEXEC is not set + +# +# CPU Power Management +# +CONFIG_CPU_IDLE=y +CONFIG_CPU_IDLE_GOV_LADDER=y +CONFIG_CPU_IDLE_GOV_MENU=y + +# +# Floating point emulation +# + +# +# At least one emulation must be selected +# +CONFIG_FPE_NWFPE=y +# CONFIG_FPE_NWFPE_XP is not set +# CONFIG_FPE_FASTFPE is not set +CONFIG_VFP=y + +# +# Userspace binary formats +# +CONFIG_BINFMT_ELF=y +CONFIG_HAVE_AOUT=y +# CONFIG_BINFMT_AOUT is not set +# CONFIG_BINFMT_MISC is not set + +# +# Power management options +# +CONFIG_PM=y +CONFIG_PM_DEBUG=y +CONFIG_PM_VERBOSE=y +CONFIG_CAN_PM_TRACE=y +CONFIG_PM_SLEEP=y +CONFIG_SUSPEND=y +CONFIG_SUSPEND_FREEZER=y +CONFIG_APM_EMULATION=y +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_NET=y + +# +# Networking options +# +CONFIG_PACKET=y +CONFIG_PACKET_MMAP=y +CONFIG_UNIX=y +# CONFIG_NET_KEY is not set +CONFIG_INET=y +# CONFIG_IP_MULTICAST is not set +# CONFIG_IP_ADVANCED_ROUTER is not set +CONFIG_IP_FIB_HASH=y +CONFIG_IP_PNP=y +CONFIG_IP_PNP_DHCP=y +CONFIG_IP_PNP_BOOTP=y +# CONFIG_IP_PNP_RARP is not set +# CONFIG_NET_IPIP is not set +# CONFIG_NET_IPGRE is not set +# CONFIG_ARPD is not set +CONFIG_SYN_COOKIES=y +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +# CONFIG_INET_XFRM_TUNNEL is not set +# CONFIG_INET_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set +# CONFIG_INET_XFRM_MODE_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_BEET is not set +# CONFIG_INET_LRO is not set +# CONFIG_INET_DIAG is not set +# CONFIG_TCP_CONG_ADVANCED is not set +CONFIG_TCP_CONG_CUBIC=y +CONFIG_DEFAULT_TCP_CONG="cubic" +# CONFIG_TCP_MD5SIG is not set +# CONFIG_IPV6 is not set +# CONFIG_NETWORK_SECMARK is not set +# CONFIG_NETFILTER is not set +# CONFIG_IP_DCCP is not set +# CONFIG_IP_SCTP is not set +# CONFIG_TIPC is not set +# CONFIG_ATM is not set +# CONFIG_BRIDGE is not set +# CONFIG_NET_DSA is not set +# CONFIG_VLAN_8021Q is not set +# CONFIG_DECNET is not set +# CONFIG_LLC2 is not set +# CONFIG_IPX is not set +# CONFIG_ATALK is not set +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +# CONFIG_ECONET is not set +# CONFIG_WAN_ROUTER is not set +# CONFIG_PHONET is not set +# CONFIG_NET_SCHED is not set +# CONFIG_DCB is not set + +# +# Network testing +# +# CONFIG_NET_PKTGEN is not set +# CONFIG_HAMRADIO is not set +# CONFIG_CAN is not set +# CONFIG_IRDA is not set +# CONFIG_BT is not set +# CONFIG_AF_RXRPC is not set +# CONFIG_WIRELESS is not set +# CONFIG_WIMAX is not set +# CONFIG_RFKILL is not set +# CONFIG_NET_9P is not set + +# +# Device Drivers +# + +# +# Generic Driver Options +# +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" +CONFIG_STANDALONE=y +CONFIG_PREVENT_FIRMWARE_BUILD=y +CONFIG_FW_LOADER=y +CONFIG_FIRMWARE_IN_KERNEL=y +CONFIG_EXTRA_FIRMWARE="" +# CONFIG_DEBUG_DRIVER is not set +# CONFIG_DEBUG_DEVRES is not set +# CONFIG_SYS_HYPERVISOR is not set +# CONFIG_CONNECTOR is not set +CONFIG_MTD=y +CONFIG_MTD_DEBUG=y +CONFIG_MTD_DEBUG_VERBOSE=0 +CONFIG_MTD_CONCAT=y +CONFIG_MTD_PARTITIONS=y +CONFIG_MTD_TESTS=m +CONFIG_MTD_REDBOOT_PARTS=y +CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-5 +# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set +CONFIG_MTD_REDBOOT_PARTS_READONLY=y +CONFIG_MTD_CMDLINE_PARTS=y +# CONFIG_MTD_AFS_PARTS is not set +# CONFIG_MTD_AR7_PARTS is not set + +# +# User Modules And Translation Layers +# +CONFIG_MTD_CHAR=y +CONFIG_MTD_BLKDEVS=y +CONFIG_MTD_BLOCK=y +# CONFIG_FTL is not set +# CONFIG_NFTL is not set +# CONFIG_INFTL is not set +# CONFIG_RFD_FTL is not set +# CONFIG_SSFDC is not set +# CONFIG_MTD_OOPS is not set + +# +# RAM/ROM/Flash chip drivers +# +# CONFIG_MTD_CFI is not set +# CONFIG_MTD_JEDECPROBE is not set +CONFIG_MTD_MAP_BANK_WIDTH_1=y +CONFIG_MTD_MAP_BANK_WIDTH_2=y +CONFIG_MTD_MAP_BANK_WIDTH_4=y +# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set +# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set +# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set +CONFIG_MTD_CFI_I1=y +CONFIG_MTD_CFI_I2=y +# CONFIG_MTD_CFI_I4 is not set +# CONFIG_MTD_CFI_I8 is not set +# CONFIG_MTD_RAM is not set +# CONFIG_MTD_ROM is not set +# CONFIG_MTD_ABSENT is not set + +# +# Mapping drivers for chip access +# +# CONFIG_MTD_COMPLEX_MAPPINGS is not set +# CONFIG_MTD_PLATRAM is not set + +# +# Self-contained MTD device drivers +# +# CONFIG_MTD_SLRAM is not set +# CONFIG_MTD_PHRAM is not set +# CONFIG_MTD_MTDRAM is not set +# CONFIG_MTD_BLOCK2MTD is not set + +# +# Disk-On-Chip Device Drivers +# +# CONFIG_MTD_DOC2000 is not set +# CONFIG_MTD_DOC2001 is not set +# CONFIG_MTD_DOC2001PLUS is not set +CONFIG_MTD_NAND=y +CONFIG_MTD_NAND_VERIFY_WRITE=y +# CONFIG_MTD_NAND_ECC_SMC is not set +# CONFIG_MTD_NAND_MUSEUM_IDS is not set +# CONFIG_MTD_NAND_GPIO is not set +CONFIG_MTD_NAND_IDS=y +# CONFIG_MTD_NAND_DISKONCHIP is not set +# CONFIG_MTD_NAND_NANDSIM is not set +# CONFIG_MTD_NAND_PLATFORM is not set +# CONFIG_MTD_NAND_MXC is not set +CONFIG_ARCH_MXC_HAS_NFC_V2=y +CONFIG_ARCH_MXC_HAS_NFC_V2_1=y +# CONFIG_MTD_ONENAND is not set + +# +# LPDDR flash memory drivers +# +# CONFIG_MTD_LPDDR is not set + +# +# UBI - Unsorted block images +# +# CONFIG_MTD_UBI is not set +# CONFIG_PARPORT is not set +CONFIG_BLK_DEV=y +# CONFIG_BLK_DEV_COW_COMMON is not set +CONFIG_BLK_DEV_LOOP=m +# CONFIG_BLK_DEV_CRYPTOLOOP is not set +# CONFIG_BLK_DEV_NBD is not set +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_COUNT=16 +CONFIG_BLK_DEV_RAM_SIZE=8192 +# CONFIG_BLK_DEV_XIP is not set +# CONFIG_CDROM_PKTCDVD is not set +# CONFIG_ATA_OVER_ETH is not set +CONFIG_MISC_DEVICES=y +# CONFIG_ENCLOSURE_SERVICES is not set +# CONFIG_C2PORT is not set + +# +# EEPROM support +# +# CONFIG_EEPROM_93CX6 is not set +CONFIG_HAVE_IDE=y +# CONFIG_IDE is not set + +# +# SCSI device support +# +# CONFIG_RAID_ATTRS is not set +# CONFIG_SCSI is not set +# CONFIG_SCSI_DMA is not set +# CONFIG_SCSI_NETLINK is not set +# CONFIG_ATA is not set +# CONFIG_MD is not set +CONFIG_NETDEVICES=y +CONFIG_COMPAT_NET_DEV_OPS=y +# CONFIG_DUMMY is not set +# CONFIG_BONDING is not set +# CONFIG_MACVLAN is not set +# CONFIG_EQUALIZER is not set +# CONFIG_TUN is not set +# CONFIG_VETH is not set +CONFIG_PHYLIB=y + +# +# MII PHY device drivers +# +# CONFIG_MARVELL_PHY is not set +# CONFIG_DAVICOM_PHY is not set +# CONFIG_QSEMI_PHY is not set +# CONFIG_LXT_PHY is not set +# CONFIG_CICADA_PHY is not set +# CONFIG_VITESSE_PHY is not set +CONFIG_SMSC_PHY=y +# CONFIG_BROADCOM_PHY is not set +# CONFIG_ICPLUS_PHY is not set +# CONFIG_REALTEK_PHY is not set +# CONFIG_NATIONAL_PHY is not set +# CONFIG_STE10XP is not set +# CONFIG_LSI_ET1011C_PHY is not set +# CONFIG_FIXED_PHY is not set +# CONFIG_MDIO_BITBANG is not set +CONFIG_NET_ETHERNET=y +CONFIG_MII=y +# CONFIG_AX88796 is not set +# CONFIG_SMC91X is not set +# CONFIG_DM9000 is not set +# CONFIG_ETHOC is not set +# CONFIG_SMC911X is not set +# CONFIG_SMSC911X is not set +# CONFIG_DNET is not set +# CONFIG_IBM_NEW_EMAC_ZMII is not set +# CONFIG_IBM_NEW_EMAC_RGMII is not set +# CONFIG_IBM_NEW_EMAC_TAH is not set +# CONFIG_IBM_NEW_EMAC_EMAC4 is not set +# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set +# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set +# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set +# CONFIG_B44 is not set +CONFIG_FEC=y +# CONFIG_FEC2 is not set +# CONFIG_NETDEV_1000 is not set +# CONFIG_NETDEV_10000 is not set + +# +# Wireless LAN +# +# CONFIG_WLAN_PRE80211 is not set +# CONFIG_WLAN_80211 is not set + +# +# Enable WiMAX (Networking options) to see the WiMAX drivers +# +# CONFIG_WAN is not set +# CONFIG_PPP is not set +# CONFIG_SLIP is not set +CONFIG_NETCONSOLE=y +CONFIG_NETCONSOLE_DYNAMIC=y +CONFIG_NETPOLL=y +# CONFIG_NETPOLL_TRAP is not set +CONFIG_NET_POLL_CONTROLLER=y +# CONFIG_ISDN is not set + +# +# Input device support +# +CONFIG_INPUT=y +# CONFIG_INPUT_FF_MEMLESS is not set +# CONFIG_INPUT_POLLDEV is not set + +# +# Userland interfaces +# +CONFIG_INPUT_MOUSEDEV=m +CONFIG_INPUT_MOUSEDEV_PSAUX=y +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 +# CONFIG_INPUT_JOYDEV is not set +CONFIG_INPUT_EVDEV=m +CONFIG_INPUT_EVBUG=m +# CONFIG_INPUT_APMPOWER is not set + +# +# Input Device Drivers +# +CONFIG_INPUT_KEYBOARD=y +# CONFIG_KEYBOARD_ATKBD is not set +# CONFIG_KEYBOARD_SUNKBD is not set +# CONFIG_KEYBOARD_LKKBD is not set +# CONFIG_KEYBOARD_XTKBD is not set +# CONFIG_KEYBOARD_NEWTON is not set +# CONFIG_KEYBOARD_STOWAWAY is not set +CONFIG_KEYBOARD_GPIO=m +CONFIG_INPUT_MOUSE=y +# CONFIG_MOUSE_PS2 is not set +# CONFIG_MOUSE_SERIAL is not set +# CONFIG_MOUSE_VSXXXAA is not set +# CONFIG_MOUSE_GPIO is not set +# CONFIG_INPUT_JOYSTICK is not set +# CONFIG_INPUT_TABLET is not set +# CONFIG_INPUT_TOUCHSCREEN is not set +# CONFIG_INPUT_MISC is not set + +# +# Hardware I/O ports +# +# CONFIG_SERIO is not set +# CONFIG_GAMEPORT is not set + +# +# Character devices +# +CONFIG_VT=y +CONFIG_CONSOLE_TRANSLATIONS=y +CONFIG_VT_CONSOLE=y +CONFIG_HW_CONSOLE=y +CONFIG_VT_HW_CONSOLE_BINDING=y +CONFIG_DEVKMEM=y +# CONFIG_SERIAL_NONSTANDARD is not set + +# +# Serial drivers +# +# CONFIG_SERIAL_8250 is not set + +# +# Non-8250 serial port support +# +CONFIG_SERIAL_IMX=y +CONFIG_SERIAL_IMX_CONSOLE=y +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_UNIX98_PTYS=y +# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set +CONFIG_LEGACY_PTYS=y +CONFIG_LEGACY_PTY_COUNT=16 +# CONFIG_IPMI_HANDLER is not set +# CONFIG_HW_RANDOM is not set +# CONFIG_R3964 is not set +# CONFIG_RAW_DRIVER is not set +# CONFIG_TCG_TPM is not set +# CONFIG_I2C is not set +# CONFIG_SPI is not set +CONFIG_ARCH_REQUIRE_GPIOLIB=y +CONFIG_GPIOLIB=y +CONFIG_DEBUG_GPIO=y +CONFIG_GPIO_SYSFS=y + +# +# Memory mapped GPIO expanders: +# + +# +# I2C GPIO expanders: +# + +# +# PCI GPIO expanders: +# + +# +# SPI GPIO expanders: +# +# CONFIG_W1 is not set +# CONFIG_POWER_SUPPLY is not set +# CONFIG_HWMON is not set +# CONFIG_THERMAL is not set +# CONFIG_THERMAL_HWMON is not set +# CONFIG_WATCHDOG is not set +CONFIG_SSB_POSSIBLE=y + +# +# Sonics Silicon Backplane +# +# CONFIG_SSB is not set + +# +# Multifunction device drivers +# +# CONFIG_MFD_CORE is not set +# CONFIG_MFD_SM501 is not set +# CONFIG_MFD_ASIC3 is not set +# CONFIG_HTC_EGPIO is not set +# CONFIG_HTC_PASIC3 is not set +# CONFIG_MFD_TMIO is not set +# CONFIG_MFD_T7L66XB is not set +# CONFIG_MFD_TC6387XB is not set +# CONFIG_MFD_TC6393XB is not set + +# +# Multimedia devices +# + +# +# Multimedia core support +# +# CONFIG_VIDEO_DEV is not set +# CONFIG_DVB_CORE is not set +# CONFIG_VIDEO_MEDIA is not set + +# +# Multimedia drivers +# +# CONFIG_DAB is not set + +# +# Graphics support +# +# CONFIG_VGASTATE is not set +# CONFIG_VIDEO_OUTPUT_CONTROL is not set +CONFIG_FB=y +# CONFIG_FIRMWARE_EDID is not set +# CONFIG_FB_DDC is not set +# CONFIG_FB_BOOT_VESA_SUPPORT is not set +CONFIG_FB_CFB_FILLRECT=y +CONFIG_FB_CFB_COPYAREA=y +CONFIG_FB_CFB_IMAGEBLIT=y +# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set +# CONFIG_FB_SYS_FILLRECT is not set +# CONFIG_FB_SYS_COPYAREA is not set +# CONFIG_FB_SYS_IMAGEBLIT is not set +# CONFIG_FB_FOREIGN_ENDIAN is not set +# CONFIG_FB_SYS_FOPS is not set +# CONFIG_FB_SVGALIB is not set +# CONFIG_FB_MACMODES is not set +# CONFIG_FB_BACKLIGHT is not set +CONFIG_FB_MODE_HELPERS=y +CONFIG_FB_TILEBLITTING=y + +# +# Frame buffer hardware drivers +# +CONFIG_FB_IMX=y +# CONFIG_FB_S1D13XXX is not set +# CONFIG_FB_VIRTUAL is not set +# CONFIG_FB_METRONOME is not set +# CONFIG_FB_MB862XX is not set +# CONFIG_FB_BROADSHEET is not set +# CONFIG_BACKLIGHT_LCD_SUPPORT is not set + +# +# Display device support +# +# CONFIG_DISPLAY_SUPPORT is not set + +# +# Console display driver support +# +# CONFIG_VGA_CONSOLE is not set +CONFIG_DUMMY_CONSOLE=y +CONFIG_FRAMEBUFFER_CONSOLE=y +CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y +CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y +# CONFIG_FONTS is not set +CONFIG_FONT_8x8=y +CONFIG_FONT_8x16=y +CONFIG_LOGO=y +CONFIG_LOGO_LINUX_MONO=y +CONFIG_LOGO_LINUX_VGA16=y +CONFIG_LOGO_LINUX_CLUT224=y +# CONFIG_SOUND is not set +# CONFIG_HID_SUPPORT is not set +# CONFIG_USB_SUPPORT is not set +# CONFIG_MMC is not set +# CONFIG_MEMSTICK is not set +# CONFIG_ACCESSIBILITY is not set +CONFIG_NEW_LEDS=y +CONFIG_LEDS_CLASS=y + +# +# LED drivers +# +CONFIG_LEDS_GPIO=y +CONFIG_LEDS_GPIO_PLATFORM=y + +# +# LED Triggers +# +CONFIG_LEDS_TRIGGERS=y +# CONFIG_LEDS_TRIGGER_TIMER is not set +CONFIG_LEDS_TRIGGER_HEARTBEAT=y +# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set +# CONFIG_LEDS_TRIGGER_GPIO is not set +# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set + +# +# iptables trigger is under Netfilter config (LED target) +# +CONFIG_RTC_LIB=y +# CONFIG_RTC_CLASS is not set +# CONFIG_DMADEVICES is not set +# CONFIG_AUXDISPLAY is not set +# CONFIG_REGULATOR is not set +# CONFIG_UIO is not set +# CONFIG_STAGING is not set + +# +# File systems +# +CONFIG_EXT2_FS=y +# CONFIG_EXT2_FS_XATTR is not set +# CONFIG_EXT2_FS_XIP is not set +CONFIG_EXT3_FS=m +# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set +CONFIG_EXT3_FS_XATTR=y +CONFIG_EXT3_FS_POSIX_ACL=y +# CONFIG_EXT3_FS_SECURITY is not set +# CONFIG_EXT4_FS is not set +CONFIG_JBD=m +CONFIG_FS_MBCACHE=m +# CONFIG_REISERFS_FS is not set +# CONFIG_JFS_FS is not set +CONFIG_FS_POSIX_ACL=y +CONFIG_FILE_LOCKING=y +# CONFIG_XFS_FS is not set +# CONFIG_GFS2_FS is not set +# CONFIG_OCFS2_FS is not set +# CONFIG_BTRFS_FS is not set +CONFIG_DNOTIFY=y +CONFIG_INOTIFY=y +CONFIG_INOTIFY_USER=y +# CONFIG_QUOTA is not set +# CONFIG_AUTOFS_FS is not set +# CONFIG_AUTOFS4_FS is not set +# CONFIG_FUSE_FS is not set + +# +# Caches +# +# CONFIG_FSCACHE is not set + +# +# CD-ROM/DVD Filesystems +# +CONFIG_ISO9660_FS=y +CONFIG_JOLIET=y +CONFIG_ZISOFS=y +# CONFIG_UDF_FS is not set + +# +# DOS/FAT/NT Filesystems +# +CONFIG_FAT_FS=m +CONFIG_MSDOS_FS=m +CONFIG_VFAT_FS=m +CONFIG_FAT_DEFAULT_CODEPAGE=437 +CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" +CONFIG_NTFS_FS=m +# CONFIG_NTFS_DEBUG is not set +CONFIG_NTFS_RW=y + +# +# Pseudo filesystems +# +CONFIG_PROC_FS=y +CONFIG_PROC_SYSCTL=y +CONFIG_PROC_PAGE_MONITOR=y +CONFIG_SYSFS=y +CONFIG_TMPFS=y +# CONFIG_TMPFS_POSIX_ACL is not set +# CONFIG_HUGETLB_PAGE is not set +CONFIG_CONFIGFS_FS=y +CONFIG_MISC_FILESYSTEMS=y +# CONFIG_ADFS_FS is not set +# CONFIG_AFFS_FS is not set +# CONFIG_HFS_FS is not set +# CONFIG_HFSPLUS_FS is not set +# CONFIG_BEFS_FS is not set +# CONFIG_BFS_FS is not set +# CONFIG_EFS_FS is not set +CONFIG_JFFS2_FS=y +CONFIG_JFFS2_FS_DEBUG=0 +CONFIG_JFFS2_FS_WRITEBUFFER=y +# CONFIG_JFFS2_FS_WBUF_VERIFY is not set +CONFIG_JFFS2_SUMMARY=y +# CONFIG_JFFS2_FS_XATTR is not set +# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set +CONFIG_JFFS2_ZLIB=y +# CONFIG_JFFS2_LZO is not set +CONFIG_JFFS2_RTIME=y +# CONFIG_JFFS2_RUBIN is not set +CONFIG_CRAMFS=y +# CONFIG_SQUASHFS is not set +# CONFIG_VXFS_FS is not set +# CONFIG_MINIX_FS is not set +# CONFIG_OMFS_FS is not set +# CONFIG_HPFS_FS is not set +# CONFIG_QNX4FS_FS is not set +# CONFIG_ROMFS_FS is not set +# CONFIG_SYSV_FS is not set +# CONFIG_UFS_FS is not set +# CONFIG_NILFS2_FS is not set +CONFIG_NETWORK_FILESYSTEMS=y +CONFIG_NFS_FS=y +CONFIG_NFS_V3=y +# CONFIG_NFS_V3_ACL is not set +CONFIG_NFS_V4=y +CONFIG_ROOT_NFS=y +# CONFIG_NFSD is not set +CONFIG_LOCKD=y +CONFIG_LOCKD_V4=y +CONFIG_NFS_COMMON=y +CONFIG_SUNRPC=y +CONFIG_SUNRPC_GSS=y +CONFIG_RPCSEC_GSS_KRB5=y +# CONFIG_RPCSEC_GSS_SPKM3 is not set +# CONFIG_SMB_FS is not set +# CONFIG_CIFS is not set +# CONFIG_NCP_FS is not set +# CONFIG_CODA_FS is not set +# CONFIG_AFS_FS is not set + +# +# Partition Types +# +CONFIG_PARTITION_ADVANCED=y +# CONFIG_ACORN_PARTITION is not set +# CONFIG_OSF_PARTITION is not set +# CONFIG_AMIGA_PARTITION is not set +# CONFIG_ATARI_PARTITION is not set +# CONFIG_MAC_PARTITION is not set +CONFIG_MSDOS_PARTITION=y +# CONFIG_BSD_DISKLABEL is not set +# CONFIG_MINIX_SUBPARTITION is not set +# CONFIG_SOLARIS_X86_PARTITION is not set +# CONFIG_UNIXWARE_DISKLABEL is not set +# CONFIG_LDM_PARTITION is not set +# CONFIG_SGI_PARTITION is not set +# CONFIG_ULTRIX_PARTITION is not set +# CONFIG_SUN_PARTITION is not set +# CONFIG_KARMA_PARTITION is not set +# CONFIG_EFI_PARTITION is not set +# CONFIG_SYSV68_PARTITION is not set +CONFIG_NLS=y +CONFIG_NLS_DEFAULT="cp437" +CONFIG_NLS_CODEPAGE_437=y +# CONFIG_NLS_CODEPAGE_737 is not set +# CONFIG_NLS_CODEPAGE_775 is not set +CONFIG_NLS_CODEPAGE_850=y +# CONFIG_NLS_CODEPAGE_852 is not set +# CONFIG_NLS_CODEPAGE_855 is not set +# CONFIG_NLS_CODEPAGE_857 is not set +# CONFIG_NLS_CODEPAGE_860 is not set +# CONFIG_NLS_CODEPAGE_861 is not set +# CONFIG_NLS_CODEPAGE_862 is not set +# CONFIG_NLS_CODEPAGE_863 is not set +# CONFIG_NLS_CODEPAGE_864 is not set +# CONFIG_NLS_CODEPAGE_865 is not set +# CONFIG_NLS_CODEPAGE_866 is not set +# CONFIG_NLS_CODEPAGE_869 is not set +# CONFIG_NLS_CODEPAGE_936 is not set +# CONFIG_NLS_CODEPAGE_950 is not set +# CONFIG_NLS_CODEPAGE_932 is not set +# CONFIG_NLS_CODEPAGE_949 is not set +# CONFIG_NLS_CODEPAGE_874 is not set +# CONFIG_NLS_ISO8859_8 is not set +CONFIG_NLS_CODEPAGE_1250=m +# CONFIG_NLS_CODEPAGE_1251 is not set +CONFIG_NLS_ASCII=m +CONFIG_NLS_ISO8859_1=m +# CONFIG_NLS_ISO8859_2 is not set +# CONFIG_NLS_ISO8859_3 is not set +# CONFIG_NLS_ISO8859_4 is not set +# CONFIG_NLS_ISO8859_5 is not set +# CONFIG_NLS_ISO8859_6 is not set +# CONFIG_NLS_ISO8859_7 is not set +# CONFIG_NLS_ISO8859_9 is not set +# CONFIG_NLS_ISO8859_13 is not set +# CONFIG_NLS_ISO8859_14 is not set +CONFIG_NLS_ISO8859_15=y +# CONFIG_NLS_KOI8_R is not set +# CONFIG_NLS_KOI8_U is not set +CONFIG_NLS_UTF8=y +# CONFIG_DLM is not set + +# +# Kernel hacking +# +# CONFIG_PRINTK_TIME is not set +CONFIG_ENABLE_WARN_DEPRECATED=y +CONFIG_ENABLE_MUST_CHECK=y +CONFIG_FRAME_WARN=1024 +CONFIG_MAGIC_SYSRQ=y +# CONFIG_UNUSED_SYMBOLS is not set +# CONFIG_DEBUG_FS is not set +# CONFIG_HEADERS_CHECK is not set +CONFIG_DEBUG_KERNEL=y +# CONFIG_DEBUG_SHIRQ is not set +CONFIG_DETECT_SOFTLOCKUP=y +CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC=y +CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=1 +CONFIG_DETECT_HUNG_TASK=y +CONFIG_BOOTPARAM_HUNG_TASK_PANIC=y +CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=1 +# CONFIG_SCHED_DEBUG is not set +# CONFIG_SCHEDSTATS is not set +# CONFIG_TIMER_STATS is not set +# CONFIG_DEBUG_OBJECTS is not set +CONFIG_DEBUG_SLAB=y +CONFIG_DEBUG_SLAB_LEAK=y +# CONFIG_DEBUG_PREEMPT is not set +# CONFIG_DEBUG_RT_MUTEXES is not set +# CONFIG_RT_MUTEX_TESTER is not set +# CONFIG_DEBUG_SPINLOCK is not set +# CONFIG_DEBUG_MUTEXES is not set +# CONFIG_DEBUG_LOCK_ALLOC is not set +# CONFIG_PROVE_LOCKING is not set +# CONFIG_LOCK_STAT is not set +# CONFIG_DEBUG_SPINLOCK_SLEEP is not set +# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set +# CONFIG_DEBUG_KOBJECT is not set +CONFIG_DEBUG_BUGVERBOSE=y +# CONFIG_DEBUG_INFO is not set +# CONFIG_DEBUG_VM is not set +# CONFIG_DEBUG_WRITECOUNT is not set +# CONFIG_DEBUG_MEMORY_INIT is not set +# CONFIG_DEBUG_LIST is not set +# CONFIG_DEBUG_SG is not set +# CONFIG_DEBUG_NOTIFIERS is not set +# CONFIG_BOOT_PRINTK_DELAY is not set +# CONFIG_RCU_TORTURE_TEST is not set +# CONFIG_RCU_CPU_STALL_DETECTOR is not set +# CONFIG_BACKTRACE_SELF_TEST is not set +# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set +# CONFIG_FAULT_INJECTION is not set +# CONFIG_LATENCYTOP is not set +# CONFIG_SYSCTL_SYSCALL_CHECK is not set +# CONFIG_PAGE_POISONING is not set +CONFIG_HAVE_FUNCTION_TRACER=y +CONFIG_TRACING_SUPPORT=y + +# +# Tracers +# +# CONFIG_FUNCTION_TRACER is not set +# CONFIG_IRQSOFF_TRACER is not set +# CONFIG_PREEMPT_TRACER is not set +# CONFIG_SCHED_TRACER is not set +# CONFIG_CONTEXT_SWITCH_TRACER is not set +# CONFIG_EVENT_TRACER is not set +# CONFIG_BOOT_TRACER is not set +# CONFIG_TRACE_BRANCH_PROFILING is not set +# CONFIG_STACK_TRACER is not set +# CONFIG_KMEMTRACE is not set +# CONFIG_WORKQUEUE_TRACER is not set +# CONFIG_BLK_DEV_IO_TRACE is not set +# CONFIG_SAMPLES is not set +CONFIG_HAVE_ARCH_KGDB=y +# CONFIG_KGDB is not set +CONFIG_ARM_UNWIND=y +CONFIG_DEBUG_USER=y +CONFIG_DEBUG_ERRORS=y +# CONFIG_DEBUG_STACK_USAGE is not set +# CONFIG_DEBUG_LL is not set + +# +# Security options +# +# CONFIG_KEYS is not set +# CONFIG_SECURITY is not set +# CONFIG_SECURITYFS is not set +# CONFIG_SECURITY_FILE_CAPABILITIES is not set +CONFIG_CRYPTO=y + +# +# Crypto core or helper +# +# CONFIG_CRYPTO_FIPS is not set +CONFIG_CRYPTO_ALGAPI=y +CONFIG_CRYPTO_ALGAPI2=y +CONFIG_CRYPTO_AEAD2=y +CONFIG_CRYPTO_BLKCIPHER=y +CONFIG_CRYPTO_BLKCIPHER2=y +CONFIG_CRYPTO_HASH=y +CONFIG_CRYPTO_HASH2=y +CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_PCOMP=y +CONFIG_CRYPTO_MANAGER=y +CONFIG_CRYPTO_MANAGER2=y +# CONFIG_CRYPTO_GF128MUL is not set +# CONFIG_CRYPTO_NULL is not set +CONFIG_CRYPTO_WORKQUEUE=y +# CONFIG_CRYPTO_CRYPTD is not set +# CONFIG_CRYPTO_AUTHENC is not set +# CONFIG_CRYPTO_TEST is not set + +# +# Authenticated Encryption with Associated Data +# +# CONFIG_CRYPTO_CCM is not set +# CONFIG_CRYPTO_GCM is not set +# CONFIG_CRYPTO_SEQIV is not set + +# +# Block modes +# +CONFIG_CRYPTO_CBC=y +# CONFIG_CRYPTO_CTR is not set +# CONFIG_CRYPTO_CTS is not set +CONFIG_CRYPTO_ECB=y +# CONFIG_CRYPTO_LRW is not set +# CONFIG_CRYPTO_PCBC is not set +# CONFIG_CRYPTO_XTS is not set + +# +# Hash modes +# +CONFIG_CRYPTO_HMAC=y +# CONFIG_CRYPTO_XCBC is not set + +# +# Digest +# +# CONFIG_CRYPTO_CRC32C is not set +# CONFIG_CRYPTO_MD4 is not set +CONFIG_CRYPTO_MD5=y +# CONFIG_CRYPTO_MICHAEL_MIC is not set +# CONFIG_CRYPTO_RMD128 is not set +# CONFIG_CRYPTO_RMD160 is not set +# CONFIG_CRYPTO_RMD256 is not set +# CONFIG_CRYPTO_RMD320 is not set +# CONFIG_CRYPTO_SHA1 is not set +# CONFIG_CRYPTO_SHA256 is not set +# CONFIG_CRYPTO_SHA512 is not set +# CONFIG_CRYPTO_TGR192 is not set +# CONFIG_CRYPTO_WP512 is not set + +# +# Ciphers +# +CONFIG_CRYPTO_AES=y +# CONFIG_CRYPTO_ANUBIS is not set +CONFIG_CRYPTO_ARC4=y +# CONFIG_CRYPTO_BLOWFISH is not set +# CONFIG_CRYPTO_CAMELLIA is not set +# CONFIG_CRYPTO_CAST5 is not set +# CONFIG_CRYPTO_CAST6 is not set +CONFIG_CRYPTO_DES=y +# CONFIG_CRYPTO_FCRYPT is not set +# CONFIG_CRYPTO_KHAZAD is not set +# CONFIG_CRYPTO_SALSA20 is not set +# CONFIG_CRYPTO_SEED is not set +# CONFIG_CRYPTO_SERPENT is not set +# CONFIG_CRYPTO_TEA is not set +# CONFIG_CRYPTO_TWOFISH is not set + +# +# Compression +# +# CONFIG_CRYPTO_DEFLATE is not set +# CONFIG_CRYPTO_ZLIB is not set +# CONFIG_CRYPTO_LZO is not set + +# +# Random Number Generation +# +# CONFIG_CRYPTO_ANSI_CPRNG is not set +CONFIG_CRYPTO_HW=y +# CONFIG_BINARY_PRINTF is not set + +# +# Library routines +# +CONFIG_BITREVERSE=y +CONFIG_GENERIC_FIND_LAST_BIT=y +# CONFIG_CRC_CCITT is not set +# CONFIG_CRC16 is not set +# CONFIG_CRC_T10DIF is not set +# CONFIG_CRC_ITU_T is not set +CONFIG_CRC32=y +# CONFIG_CRC7 is not set +# CONFIG_LIBCRC32C is not set +CONFIG_ZLIB_INFLATE=y +CONFIG_ZLIB_DEFLATE=y +CONFIG_DECOMPRESS_GZIP=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT=y +CONFIG_HAS_DMA=y +CONFIG_NLATTR=y diff --git a/recipes/linux/linux-2.6.30/tx25/linux-2.6.30-rc4-karo.diff b/recipes/linux/linux-2.6.30/tx25/linux-2.6.30-rc4-karo.diff new file mode 100644 index 0000000000..6926571c2e --- /dev/null +++ b/recipes/linux/linux-2.6.30/tx25/linux-2.6.30-rc4-karo.diff @@ -0,0 +1,17631 @@ +diff -urNp linux-2.6.30-rc4/.config linux-2.6.30-rc4-karo/.config +--- linux-2.6.30-rc4/.config 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/.config 2009-06-02 16:17:34.000000000 +0200 +@@ -0,0 +1,1203 @@ ++# ++# Automatically generated make config: don't edit ++# Linux kernel version: 2.6.30-rc4 ++# Tue Jun 2 15:46:43 2009 ++# ++CONFIG_ARM=y ++CONFIG_SYS_SUPPORTS_APM_EMULATION=y ++CONFIG_GENERIC_GPIO=y ++CONFIG_GENERIC_TIME=y ++CONFIG_GENERIC_CLOCKEVENTS=y ++CONFIG_MMU=y ++# CONFIG_NO_IOPORT is not set ++CONFIG_GENERIC_HARDIRQS=y ++CONFIG_STACKTRACE_SUPPORT=y ++CONFIG_HAVE_LATENCYTOP_SUPPORT=y ++CONFIG_LOCKDEP_SUPPORT=y ++CONFIG_TRACE_IRQFLAGS_SUPPORT=y ++CONFIG_HARDIRQS_SW_RESEND=y ++CONFIG_GENERIC_IRQ_PROBE=y ++CONFIG_RWSEM_GENERIC_SPINLOCK=y ++# CONFIG_ARCH_HAS_ILOG2_U32 is not set ++# CONFIG_ARCH_HAS_ILOG2_U64 is not set ++CONFIG_GENERIC_HWEIGHT=y ++CONFIG_GENERIC_CALIBRATE_DELAY=y ++CONFIG_ARCH_MTD_XIP=y ++CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y ++CONFIG_VECTORS_BASE=0xffff0000 ++CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" ++ ++# ++# General setup ++# ++CONFIG_EXPERIMENTAL=y ++CONFIG_BROKEN_ON_SMP=y ++CONFIG_LOCK_KERNEL=y ++CONFIG_INIT_ENV_ARG_LIMIT=32 ++CONFIG_LOCALVERSION="" ++CONFIG_LOCALVERSION_AUTO=y ++# CONFIG_SWAP is not set ++CONFIG_SYSVIPC=y ++CONFIG_SYSVIPC_SYSCTL=y ++CONFIG_POSIX_MQUEUE=y ++CONFIG_POSIX_MQUEUE_SYSCTL=y ++# CONFIG_BSD_PROCESS_ACCT is not set ++# CONFIG_TASKSTATS is not set ++# CONFIG_AUDIT is not set ++ ++# ++# RCU Subsystem ++# ++CONFIG_CLASSIC_RCU=y ++# CONFIG_TREE_RCU is not set ++# CONFIG_PREEMPT_RCU is not set ++# CONFIG_TREE_RCU_TRACE is not set ++# CONFIG_PREEMPT_RCU_TRACE is not set ++# CONFIG_IKCONFIG is not set ++CONFIG_LOG_BUF_SHIFT=17 ++# CONFIG_GROUP_SCHED is not set ++# CONFIG_CGROUPS is not set ++# CONFIG_SYSFS_DEPRECATED_V2 is not set ++# CONFIG_RELAY is not set ++# CONFIG_NAMESPACES is not set ++CONFIG_BLK_DEV_INITRD=y ++CONFIG_INITRAMFS_SOURCE="" ++CONFIG_RD_GZIP=y ++# CONFIG_RD_BZIP2 is not set ++# CONFIG_RD_LZMA is not set ++# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set ++CONFIG_SYSCTL=y ++CONFIG_ANON_INODES=y ++CONFIG_EMBEDDED=y ++CONFIG_UID16=y ++CONFIG_SYSCTL_SYSCALL=y ++CONFIG_KALLSYMS=y ++# CONFIG_KALLSYMS_ALL is not set ++# CONFIG_KALLSYMS_EXTRA_PASS is not set ++# CONFIG_STRIP_ASM_SYMS is not set ++CONFIG_HOTPLUG=y ++CONFIG_PRINTK=y ++CONFIG_BUG=y ++# CONFIG_ELF_CORE is not set ++CONFIG_BASE_FULL=y ++CONFIG_FUTEX=y ++CONFIG_EPOLL=y ++CONFIG_SIGNALFD=y ++CONFIG_TIMERFD=y ++CONFIG_EVENTFD=y ++CONFIG_SHMEM=y ++# CONFIG_AIO is not set ++# CONFIG_VM_EVENT_COUNTERS is not set ++# CONFIG_COMPAT_BRK is not set ++CONFIG_SLAB=y ++# CONFIG_SLUB is not set ++# CONFIG_SLOB is not set ++# CONFIG_PROFILING is not set ++# CONFIG_MARKERS is not set ++CONFIG_HAVE_OPROFILE=y ++# CONFIG_KPROBES is not set ++CONFIG_HAVE_KPROBES=y ++CONFIG_HAVE_KRETPROBES=y ++CONFIG_HAVE_CLK=y ++# CONFIG_SLOW_WORK is not set ++CONFIG_HAVE_GENERIC_DMA_COHERENT=y ++CONFIG_SLABINFO=y ++CONFIG_RT_MUTEXES=y ++CONFIG_BASE_SMALL=0 ++CONFIG_MODULES=y ++# CONFIG_MODULE_FORCE_LOAD is not set ++CONFIG_MODULE_UNLOAD=y ++CONFIG_MODULE_FORCE_UNLOAD=y ++CONFIG_MODVERSIONS=y ++# CONFIG_MODULE_SRCVERSION_ALL is not set ++CONFIG_BLOCK=y ++CONFIG_LBD=y ++# CONFIG_BLK_DEV_BSG is not set ++# CONFIG_BLK_DEV_INTEGRITY is not set ++ ++# ++# IO Schedulers ++# ++CONFIG_IOSCHED_NOOP=y ++CONFIG_IOSCHED_AS=y ++CONFIG_IOSCHED_DEADLINE=y ++CONFIG_IOSCHED_CFQ=y ++CONFIG_DEFAULT_AS=y ++# CONFIG_DEFAULT_DEADLINE is not set ++# CONFIG_DEFAULT_CFQ is not set ++# CONFIG_DEFAULT_NOOP is not set ++CONFIG_DEFAULT_IOSCHED="anticipatory" ++CONFIG_FREEZER=y ++ ++# ++# System Type ++# ++# CONFIG_ARCH_AAEC2000 is not set ++# CONFIG_ARCH_INTEGRATOR is not set ++# CONFIG_ARCH_REALVIEW is not set ++# CONFIG_ARCH_VERSATILE is not set ++# CONFIG_ARCH_AT91 is not set ++# CONFIG_ARCH_CLPS711X is not set ++# CONFIG_ARCH_EBSA110 is not set ++# CONFIG_ARCH_EP93XX is not set ++# CONFIG_ARCH_GEMINI is not set ++# CONFIG_ARCH_FOOTBRIDGE is not set ++# CONFIG_ARCH_NETX is not set ++# CONFIG_ARCH_H720X is not set ++# CONFIG_ARCH_IOP13XX is not set ++# CONFIG_ARCH_IOP32X is not set ++# CONFIG_ARCH_IOP33X is not set ++# CONFIG_ARCH_IXP23XX is not set ++# CONFIG_ARCH_IXP2000 is not set ++# CONFIG_ARCH_IXP4XX is not set ++# CONFIG_ARCH_L7200 is not set ++# CONFIG_ARCH_KIRKWOOD is not set ++# CONFIG_ARCH_KS8695 is not set ++# CONFIG_ARCH_NS9XXX is not set ++# CONFIG_ARCH_LOKI is not set ++# CONFIG_ARCH_MV78XX0 is not set ++CONFIG_ARCH_MXC=y ++# CONFIG_ARCH_ORION5X is not set ++# CONFIG_ARCH_PNX4008 is not set ++# CONFIG_ARCH_PXA is not set ++# CONFIG_ARCH_MMP is not set ++# CONFIG_ARCH_RPC is not set ++# CONFIG_ARCH_SA1100 is not set ++# CONFIG_ARCH_S3C2410 is not set ++# CONFIG_ARCH_S3C64XX is not set ++# CONFIG_ARCH_SHARK is not set ++# CONFIG_ARCH_LH7A40X is not set ++# CONFIG_ARCH_DAVINCI is not set ++# CONFIG_ARCH_OMAP is not set ++# CONFIG_ARCH_MSM is not set ++# CONFIG_ARCH_W90X900 is not set ++ ++# ++# Freescale MXC Implementations ++# ++# CONFIG_ARCH_MX1 is not set ++CONFIG_ARCH_MX2=y ++# CONFIG_ARCH_MX3 is not set ++# CONFIG_MACH_MX21 is not set ++# CONFIG_MACH_MX27 is not set ++CONFIG_MACH_MX25=y ++ ++# ++# MX2 platforms: ++# ++CONFIG_MACH_TX25=y ++# CONFIG_KARO_DEBUG is not set ++CONFIG_MACH_STK5_BASEBOARD=y ++# CONFIG_MXC_IRQ_PRIOR is not set ++# CONFIG_MXC_PWM is not set ++CONFIG_ARCH_MXC_IOMUX_V3=y ++ ++# ++# Processor Type ++# ++CONFIG_CPU_32=y ++CONFIG_CPU_ARM926T=y ++CONFIG_CPU_32v5=y ++CONFIG_CPU_ABRT_EV5TJ=y ++CONFIG_CPU_PABRT_NOIFAR=y ++CONFIG_CPU_CACHE_VIVT=y ++CONFIG_CPU_COPY_V4WB=y ++CONFIG_CPU_TLB_V4WBI=y ++CONFIG_CPU_CP15=y ++CONFIG_CPU_CP15_MMU=y ++ ++# ++# Processor Features ++# ++CONFIG_ARM_THUMB=y ++# CONFIG_CPU_ICACHE_DISABLE is not set ++# CONFIG_CPU_DCACHE_DISABLE is not set ++# CONFIG_CPU_DCACHE_WRITETHROUGH is not set ++# CONFIG_CPU_CACHE_ROUND_ROBIN is not set ++# CONFIG_OUTER_CACHE is not set ++CONFIG_COMMON_CLKDEV=y ++ ++# ++# Bus support ++# ++# CONFIG_PCI_SYSCALL is not set ++# CONFIG_ARCH_SUPPORTS_MSI is not set ++# CONFIG_PCCARD is not set ++ ++# ++# Kernel Features ++# ++CONFIG_TICK_ONESHOT=y ++CONFIG_NO_HZ=y ++# CONFIG_HIGH_RES_TIMERS is not set ++CONFIG_GENERIC_CLOCKEVENTS_BUILD=y ++CONFIG_VMSPLIT_3G=y ++# CONFIG_VMSPLIT_2G is not set ++# CONFIG_VMSPLIT_1G is not set ++CONFIG_PAGE_OFFSET=0xC0000000 ++CONFIG_PREEMPT=y ++CONFIG_HZ=100 ++CONFIG_AEABI=y ++CONFIG_OABI_COMPAT=y ++CONFIG_ARCH_FLATMEM_HAS_HOLES=y ++# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set ++# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set ++# CONFIG_HIGHMEM is not set ++CONFIG_SELECT_MEMORY_MODEL=y ++CONFIG_FLATMEM_MANUAL=y ++# CONFIG_DISCONTIGMEM_MANUAL is not set ++# CONFIG_SPARSEMEM_MANUAL is not set ++CONFIG_FLATMEM=y ++CONFIG_FLAT_NODE_MEM_MAP=y ++CONFIG_PAGEFLAGS_EXTENDED=y ++CONFIG_SPLIT_PTLOCK_CPUS=4096 ++# CONFIG_PHYS_ADDR_T_64BIT is not set ++CONFIG_ZONE_DMA_FLAG=0 ++CONFIG_VIRT_TO_BUS=y ++CONFIG_UNEVICTABLE_LRU=y ++CONFIG_HAVE_MLOCK=y ++CONFIG_HAVE_MLOCKED_PAGE_BIT=y ++CONFIG_ALIGNMENT_TRAP=y ++ ++# ++# Boot options ++# ++CONFIG_ZBOOT_ROM_TEXT=0 ++CONFIG_ZBOOT_ROM_BSS=0 ++CONFIG_CMDLINE="init=/linuxrc root=1f01 rootfstype=jffs2 ro console=ttymxc0,115200 panic=1" ++# CONFIG_XIP_KERNEL is not set ++# CONFIG_KEXEC is not set ++ ++# ++# CPU Power Management ++# ++CONFIG_CPU_IDLE=y ++CONFIG_CPU_IDLE_GOV_LADDER=y ++CONFIG_CPU_IDLE_GOV_MENU=y ++ ++# ++# Floating point emulation ++# ++ ++# ++# At least one emulation must be selected ++# ++CONFIG_FPE_NWFPE=y ++# CONFIG_FPE_NWFPE_XP is not set ++# CONFIG_FPE_FASTFPE is not set ++CONFIG_VFP=y ++ ++# ++# Userspace binary formats ++# ++CONFIG_BINFMT_ELF=y ++CONFIG_HAVE_AOUT=y ++# CONFIG_BINFMT_AOUT is not set ++# CONFIG_BINFMT_MISC is not set ++ ++# ++# Power management options ++# ++CONFIG_PM=y ++CONFIG_PM_DEBUG=y ++CONFIG_PM_VERBOSE=y ++CONFIG_CAN_PM_TRACE=y ++CONFIG_PM_SLEEP=y ++CONFIG_SUSPEND=y ++CONFIG_SUSPEND_FREEZER=y ++CONFIG_APM_EMULATION=y ++CONFIG_ARCH_SUSPEND_POSSIBLE=y ++CONFIG_NET=y ++ ++# ++# Networking options ++# ++CONFIG_PACKET=y ++CONFIG_PACKET_MMAP=y ++CONFIG_UNIX=y ++# CONFIG_NET_KEY is not set ++CONFIG_INET=y ++# CONFIG_IP_MULTICAST is not set ++# CONFIG_IP_ADVANCED_ROUTER is not set ++CONFIG_IP_FIB_HASH=y ++CONFIG_IP_PNP=y ++CONFIG_IP_PNP_DHCP=y ++CONFIG_IP_PNP_BOOTP=y ++# CONFIG_IP_PNP_RARP is not set ++# CONFIG_NET_IPIP is not set ++# CONFIG_NET_IPGRE is not set ++# CONFIG_ARPD is not set ++CONFIG_SYN_COOKIES=y ++# CONFIG_INET_AH is not set ++# CONFIG_INET_ESP is not set ++# CONFIG_INET_IPCOMP is not set ++# CONFIG_INET_XFRM_TUNNEL is not set ++# CONFIG_INET_TUNNEL is not set ++# CONFIG_INET_XFRM_MODE_TRANSPORT is not set ++# CONFIG_INET_XFRM_MODE_TUNNEL is not set ++# CONFIG_INET_XFRM_MODE_BEET is not set ++# CONFIG_INET_LRO is not set ++# CONFIG_INET_DIAG is not set ++# CONFIG_TCP_CONG_ADVANCED is not set ++CONFIG_TCP_CONG_CUBIC=y ++CONFIG_DEFAULT_TCP_CONG="cubic" ++# CONFIG_TCP_MD5SIG is not set ++# CONFIG_IPV6 is not set ++# CONFIG_NETWORK_SECMARK is not set ++# CONFIG_NETFILTER is not set ++# CONFIG_IP_DCCP is not set ++# CONFIG_IP_SCTP is not set ++# CONFIG_TIPC is not set ++# CONFIG_ATM is not set ++# CONFIG_BRIDGE is not set ++# CONFIG_NET_DSA is not set ++# CONFIG_VLAN_8021Q is not set ++# CONFIG_DECNET is not set ++# CONFIG_LLC2 is not set ++# CONFIG_IPX is not set ++# CONFIG_ATALK is not set ++# CONFIG_X25 is not set ++# CONFIG_LAPB is not set ++# CONFIG_ECONET is not set ++# CONFIG_WAN_ROUTER is not set ++# CONFIG_PHONET is not set ++# CONFIG_NET_SCHED is not set ++# CONFIG_DCB is not set ++ ++# ++# Network testing ++# ++# CONFIG_NET_PKTGEN is not set ++# CONFIG_HAMRADIO is not set ++# CONFIG_CAN is not set ++# CONFIG_IRDA is not set ++# CONFIG_BT is not set ++# CONFIG_AF_RXRPC is not set ++# CONFIG_WIRELESS is not set ++# CONFIG_WIMAX is not set ++# CONFIG_RFKILL is not set ++# CONFIG_NET_9P is not set ++ ++# ++# Device Drivers ++# ++ ++# ++# Generic Driver Options ++# ++CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" ++CONFIG_STANDALONE=y ++CONFIG_PREVENT_FIRMWARE_BUILD=y ++CONFIG_FW_LOADER=y ++CONFIG_FIRMWARE_IN_KERNEL=y ++CONFIG_EXTRA_FIRMWARE="" ++# CONFIG_DEBUG_DRIVER is not set ++# CONFIG_DEBUG_DEVRES is not set ++# CONFIG_SYS_HYPERVISOR is not set ++# CONFIG_CONNECTOR is not set ++CONFIG_MTD=y ++CONFIG_MTD_DEBUG=y ++CONFIG_MTD_DEBUG_VERBOSE=0 ++CONFIG_MTD_CONCAT=y ++CONFIG_MTD_PARTITIONS=y ++CONFIG_MTD_TESTS=m ++CONFIG_MTD_REDBOOT_PARTS=y ++CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-5 ++# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set ++CONFIG_MTD_REDBOOT_PARTS_READONLY=y ++CONFIG_MTD_CMDLINE_PARTS=y ++# CONFIG_MTD_AFS_PARTS is not set ++# CONFIG_MTD_AR7_PARTS is not set ++ ++# ++# User Modules And Translation Layers ++# ++CONFIG_MTD_CHAR=y ++CONFIG_MTD_BLKDEVS=y ++CONFIG_MTD_BLOCK=y ++# CONFIG_FTL is not set ++# CONFIG_NFTL is not set ++# CONFIG_INFTL is not set ++# CONFIG_RFD_FTL is not set ++# CONFIG_SSFDC is not set ++# CONFIG_MTD_OOPS is not set ++ ++# ++# RAM/ROM/Flash chip drivers ++# ++# CONFIG_MTD_CFI is not set ++# CONFIG_MTD_JEDECPROBE is not set ++CONFIG_MTD_MAP_BANK_WIDTH_1=y ++CONFIG_MTD_MAP_BANK_WIDTH_2=y ++CONFIG_MTD_MAP_BANK_WIDTH_4=y ++# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set ++# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set ++# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set ++CONFIG_MTD_CFI_I1=y ++CONFIG_MTD_CFI_I2=y ++# CONFIG_MTD_CFI_I4 is not set ++# CONFIG_MTD_CFI_I8 is not set ++# CONFIG_MTD_RAM is not set ++# CONFIG_MTD_ROM is not set ++# CONFIG_MTD_ABSENT is not set ++ ++# ++# Mapping drivers for chip access ++# ++# CONFIG_MTD_COMPLEX_MAPPINGS is not set ++# CONFIG_MTD_PLATRAM is not set ++ ++# ++# Self-contained MTD device drivers ++# ++# CONFIG_MTD_SLRAM is not set ++# CONFIG_MTD_PHRAM is not set ++# CONFIG_MTD_MTDRAM is not set ++# CONFIG_MTD_BLOCK2MTD is not set ++ ++# ++# Disk-On-Chip Device Drivers ++# ++# CONFIG_MTD_DOC2000 is not set ++# CONFIG_MTD_DOC2001 is not set ++# CONFIG_MTD_DOC2001PLUS is not set ++CONFIG_MTD_NAND=y ++CONFIG_MTD_NAND_VERIFY_WRITE=y ++# CONFIG_MTD_NAND_ECC_SMC is not set ++# CONFIG_MTD_NAND_MUSEUM_IDS is not set ++# CONFIG_MTD_NAND_GPIO is not set ++CONFIG_MTD_NAND_IDS=y ++# CONFIG_MTD_NAND_DISKONCHIP is not set ++# CONFIG_MTD_NAND_NANDSIM is not set ++# CONFIG_MTD_NAND_PLATFORM is not set ++# CONFIG_MTD_NAND_MXC is not set ++CONFIG_ARCH_MXC_HAS_NFC_V2=y ++CONFIG_ARCH_MXC_HAS_NFC_V2_1=y ++# CONFIG_MTD_ONENAND is not set ++ ++# ++# LPDDR flash memory drivers ++# ++# CONFIG_MTD_LPDDR is not set ++ ++# ++# UBI - Unsorted block images ++# ++# CONFIG_MTD_UBI is not set ++# CONFIG_PARPORT is not set ++CONFIG_BLK_DEV=y ++# CONFIG_BLK_DEV_COW_COMMON is not set ++CONFIG_BLK_DEV_LOOP=m ++# CONFIG_BLK_DEV_CRYPTOLOOP is not set ++# CONFIG_BLK_DEV_NBD is not set ++CONFIG_BLK_DEV_RAM=y ++CONFIG_BLK_DEV_RAM_COUNT=16 ++CONFIG_BLK_DEV_RAM_SIZE=8192 ++# CONFIG_BLK_DEV_XIP is not set ++# CONFIG_CDROM_PKTCDVD is not set ++# CONFIG_ATA_OVER_ETH is not set ++CONFIG_MISC_DEVICES=y ++# CONFIG_ENCLOSURE_SERVICES is not set ++# CONFIG_C2PORT is not set ++ ++# ++# EEPROM support ++# ++# CONFIG_EEPROM_93CX6 is not set ++CONFIG_HAVE_IDE=y ++# CONFIG_IDE is not set ++ ++# ++# SCSI device support ++# ++# CONFIG_RAID_ATTRS is not set ++# CONFIG_SCSI is not set ++# CONFIG_SCSI_DMA is not set ++# CONFIG_SCSI_NETLINK is not set ++# CONFIG_ATA is not set ++# CONFIG_MD is not set ++CONFIG_NETDEVICES=y ++CONFIG_COMPAT_NET_DEV_OPS=y ++# CONFIG_DUMMY is not set ++# CONFIG_BONDING is not set ++# CONFIG_MACVLAN is not set ++# CONFIG_EQUALIZER is not set ++# CONFIG_TUN is not set ++# CONFIG_VETH is not set ++CONFIG_PHYLIB=y ++ ++# ++# MII PHY device drivers ++# ++# CONFIG_MARVELL_PHY is not set ++# CONFIG_DAVICOM_PHY is not set ++# CONFIG_QSEMI_PHY is not set ++# CONFIG_LXT_PHY is not set ++# CONFIG_CICADA_PHY is not set ++# CONFIG_VITESSE_PHY is not set ++CONFIG_SMSC_PHY=y ++# CONFIG_BROADCOM_PHY is not set ++# CONFIG_ICPLUS_PHY is not set ++# CONFIG_REALTEK_PHY is not set ++# CONFIG_NATIONAL_PHY is not set ++# CONFIG_STE10XP is not set ++# CONFIG_LSI_ET1011C_PHY is not set ++# CONFIG_FIXED_PHY is not set ++# CONFIG_MDIO_BITBANG is not set ++CONFIG_NET_ETHERNET=y ++CONFIG_MII=y ++# CONFIG_AX88796 is not set ++# CONFIG_SMC91X is not set ++# CONFIG_DM9000 is not set ++# CONFIG_ETHOC is not set ++# CONFIG_SMC911X is not set ++# CONFIG_SMSC911X is not set ++# CONFIG_DNET is not set ++# CONFIG_IBM_NEW_EMAC_ZMII is not set ++# CONFIG_IBM_NEW_EMAC_RGMII is not set ++# CONFIG_IBM_NEW_EMAC_TAH is not set ++# CONFIG_IBM_NEW_EMAC_EMAC4 is not set ++# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set ++# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set ++# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set ++# CONFIG_B44 is not set ++CONFIG_FEC=y ++# CONFIG_FEC2 is not set ++# CONFIG_NETDEV_1000 is not set ++# CONFIG_NETDEV_10000 is not set ++ ++# ++# Wireless LAN ++# ++# CONFIG_WLAN_PRE80211 is not set ++# CONFIG_WLAN_80211 is not set ++ ++# ++# Enable WiMAX (Networking options) to see the WiMAX drivers ++# ++# CONFIG_WAN is not set ++# CONFIG_PPP is not set ++# CONFIG_SLIP is not set ++CONFIG_NETCONSOLE=y ++CONFIG_NETCONSOLE_DYNAMIC=y ++CONFIG_NETPOLL=y ++# CONFIG_NETPOLL_TRAP is not set ++CONFIG_NET_POLL_CONTROLLER=y ++# CONFIG_ISDN is not set ++ ++# ++# Input device support ++# ++CONFIG_INPUT=y ++# CONFIG_INPUT_FF_MEMLESS is not set ++# CONFIG_INPUT_POLLDEV is not set ++ ++# ++# Userland interfaces ++# ++CONFIG_INPUT_MOUSEDEV=m ++CONFIG_INPUT_MOUSEDEV_PSAUX=y ++CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 ++CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 ++# CONFIG_INPUT_JOYDEV is not set ++CONFIG_INPUT_EVDEV=m ++CONFIG_INPUT_EVBUG=m ++# CONFIG_INPUT_APMPOWER is not set ++ ++# ++# Input Device Drivers ++# ++CONFIG_INPUT_KEYBOARD=y ++# CONFIG_KEYBOARD_ATKBD is not set ++# CONFIG_KEYBOARD_SUNKBD is not set ++# CONFIG_KEYBOARD_LKKBD is not set ++# CONFIG_KEYBOARD_XTKBD is not set ++# CONFIG_KEYBOARD_NEWTON is not set ++# CONFIG_KEYBOARD_STOWAWAY is not set ++CONFIG_KEYBOARD_GPIO=m ++CONFIG_INPUT_MOUSE=y ++# CONFIG_MOUSE_PS2 is not set ++# CONFIG_MOUSE_SERIAL is not set ++# CONFIG_MOUSE_VSXXXAA is not set ++# CONFIG_MOUSE_GPIO is not set ++# CONFIG_INPUT_JOYSTICK is not set ++# CONFIG_INPUT_TABLET is not set ++# CONFIG_INPUT_TOUCHSCREEN is not set ++# CONFIG_INPUT_MISC is not set ++ ++# ++# Hardware I/O ports ++# ++# CONFIG_SERIO is not set ++# CONFIG_GAMEPORT is not set ++ ++# ++# Character devices ++# ++CONFIG_VT=y ++CONFIG_CONSOLE_TRANSLATIONS=y ++CONFIG_VT_CONSOLE=y ++CONFIG_HW_CONSOLE=y ++CONFIG_VT_HW_CONSOLE_BINDING=y ++CONFIG_DEVKMEM=y ++# CONFIG_SERIAL_NONSTANDARD is not set ++ ++# ++# Serial drivers ++# ++# CONFIG_SERIAL_8250 is not set ++ ++# ++# Non-8250 serial port support ++# ++CONFIG_SERIAL_IMX=y ++CONFIG_SERIAL_IMX_CONSOLE=y ++CONFIG_SERIAL_CORE=y ++CONFIG_SERIAL_CORE_CONSOLE=y ++CONFIG_UNIX98_PTYS=y ++# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set ++CONFIG_LEGACY_PTYS=y ++CONFIG_LEGACY_PTY_COUNT=16 ++# CONFIG_IPMI_HANDLER is not set ++# CONFIG_HW_RANDOM is not set ++# CONFIG_R3964 is not set ++# CONFIG_RAW_DRIVER is not set ++# CONFIG_TCG_TPM is not set ++# CONFIG_I2C is not set ++# CONFIG_SPI is not set ++CONFIG_ARCH_REQUIRE_GPIOLIB=y ++CONFIG_GPIOLIB=y ++CONFIG_DEBUG_GPIO=y ++CONFIG_GPIO_SYSFS=y ++ ++# ++# Memory mapped GPIO expanders: ++# ++ ++# ++# I2C GPIO expanders: ++# ++ ++# ++# PCI GPIO expanders: ++# ++ ++# ++# SPI GPIO expanders: ++# ++# CONFIG_W1 is not set ++# CONFIG_POWER_SUPPLY is not set ++# CONFIG_HWMON is not set ++# CONFIG_THERMAL is not set ++# CONFIG_THERMAL_HWMON is not set ++# CONFIG_WATCHDOG is not set ++CONFIG_SSB_POSSIBLE=y ++ ++# ++# Sonics Silicon Backplane ++# ++# CONFIG_SSB is not set ++ ++# ++# Multifunction device drivers ++# ++# CONFIG_MFD_CORE is not set ++# CONFIG_MFD_SM501 is not set ++# CONFIG_MFD_ASIC3 is not set ++# CONFIG_HTC_EGPIO is not set ++# CONFIG_HTC_PASIC3 is not set ++# CONFIG_MFD_TMIO is not set ++# CONFIG_MFD_T7L66XB is not set ++# CONFIG_MFD_TC6387XB is not set ++# CONFIG_MFD_TC6393XB is not set ++ ++# ++# Multimedia devices ++# ++ ++# ++# Multimedia core support ++# ++# CONFIG_VIDEO_DEV is not set ++# CONFIG_DVB_CORE is not set ++# CONFIG_VIDEO_MEDIA is not set ++ ++# ++# Multimedia drivers ++# ++# CONFIG_DAB is not set ++ ++# ++# Graphics support ++# ++# CONFIG_VGASTATE is not set ++# CONFIG_VIDEO_OUTPUT_CONTROL is not set ++CONFIG_FB=y ++# CONFIG_FIRMWARE_EDID is not set ++# CONFIG_FB_DDC is not set ++# CONFIG_FB_BOOT_VESA_SUPPORT is not set ++CONFIG_FB_CFB_FILLRECT=y ++CONFIG_FB_CFB_COPYAREA=y ++CONFIG_FB_CFB_IMAGEBLIT=y ++# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set ++# CONFIG_FB_SYS_FILLRECT is not set ++# CONFIG_FB_SYS_COPYAREA is not set ++# CONFIG_FB_SYS_IMAGEBLIT is not set ++# CONFIG_FB_FOREIGN_ENDIAN is not set ++# CONFIG_FB_SYS_FOPS is not set ++# CONFIG_FB_SVGALIB is not set ++# CONFIG_FB_MACMODES is not set ++# CONFIG_FB_BACKLIGHT is not set ++CONFIG_FB_MODE_HELPERS=y ++CONFIG_FB_TILEBLITTING=y ++ ++# ++# Frame buffer hardware drivers ++# ++CONFIG_FB_IMX=y ++# CONFIG_FB_S1D13XXX is not set ++# CONFIG_FB_VIRTUAL is not set ++# CONFIG_FB_METRONOME is not set ++# CONFIG_FB_MB862XX is not set ++# CONFIG_FB_BROADSHEET is not set ++# CONFIG_BACKLIGHT_LCD_SUPPORT is not set ++ ++# ++# Display device support ++# ++# CONFIG_DISPLAY_SUPPORT is not set ++ ++# ++# Console display driver support ++# ++# CONFIG_VGA_CONSOLE is not set ++CONFIG_DUMMY_CONSOLE=y ++CONFIG_FRAMEBUFFER_CONSOLE=y ++CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y ++CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y ++# CONFIG_FONTS is not set ++CONFIG_FONT_8x8=y ++CONFIG_FONT_8x16=y ++CONFIG_LOGO=y ++CONFIG_LOGO_LINUX_MONO=y ++CONFIG_LOGO_LINUX_VGA16=y ++CONFIG_LOGO_LINUX_CLUT224=y ++# CONFIG_SOUND is not set ++# CONFIG_HID_SUPPORT is not set ++# CONFIG_USB_SUPPORT is not set ++# CONFIG_MMC is not set ++# CONFIG_MEMSTICK is not set ++# CONFIG_ACCESSIBILITY is not set ++CONFIG_NEW_LEDS=y ++CONFIG_LEDS_CLASS=y ++ ++# ++# LED drivers ++# ++CONFIG_LEDS_GPIO=y ++CONFIG_LEDS_GPIO_PLATFORM=y ++ ++# ++# LED Triggers ++# ++CONFIG_LEDS_TRIGGERS=y ++# CONFIG_LEDS_TRIGGER_TIMER is not set ++CONFIG_LEDS_TRIGGER_HEARTBEAT=y ++# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set ++# CONFIG_LEDS_TRIGGER_GPIO is not set ++# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set ++ ++# ++# iptables trigger is under Netfilter config (LED target) ++# ++CONFIG_RTC_LIB=y ++# CONFIG_RTC_CLASS is not set ++# CONFIG_DMADEVICES is not set ++# CONFIG_AUXDISPLAY is not set ++# CONFIG_REGULATOR is not set ++# CONFIG_UIO is not set ++# CONFIG_STAGING is not set ++ ++# ++# File systems ++# ++CONFIG_EXT2_FS=y ++# CONFIG_EXT2_FS_XATTR is not set ++# CONFIG_EXT2_FS_XIP is not set ++CONFIG_EXT3_FS=m ++# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set ++CONFIG_EXT3_FS_XATTR=y ++CONFIG_EXT3_FS_POSIX_ACL=y ++# CONFIG_EXT3_FS_SECURITY is not set ++# CONFIG_EXT4_FS is not set ++CONFIG_JBD=m ++CONFIG_FS_MBCACHE=m ++# CONFIG_REISERFS_FS is not set ++# CONFIG_JFS_FS is not set ++CONFIG_FS_POSIX_ACL=y ++CONFIG_FILE_LOCKING=y ++# CONFIG_XFS_FS is not set ++# CONFIG_GFS2_FS is not set ++# CONFIG_OCFS2_FS is not set ++# CONFIG_BTRFS_FS is not set ++CONFIG_DNOTIFY=y ++CONFIG_INOTIFY=y ++CONFIG_INOTIFY_USER=y ++# CONFIG_QUOTA is not set ++# CONFIG_AUTOFS_FS is not set ++# CONFIG_AUTOFS4_FS is not set ++# CONFIG_FUSE_FS is not set ++ ++# ++# Caches ++# ++# CONFIG_FSCACHE is not set ++ ++# ++# CD-ROM/DVD Filesystems ++# ++CONFIG_ISO9660_FS=y ++CONFIG_JOLIET=y ++CONFIG_ZISOFS=y ++# CONFIG_UDF_FS is not set ++ ++# ++# DOS/FAT/NT Filesystems ++# ++CONFIG_FAT_FS=m ++CONFIG_MSDOS_FS=m ++CONFIG_VFAT_FS=m ++CONFIG_FAT_DEFAULT_CODEPAGE=437 ++CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" ++CONFIG_NTFS_FS=m ++# CONFIG_NTFS_DEBUG is not set ++CONFIG_NTFS_RW=y ++ ++# ++# Pseudo filesystems ++# ++CONFIG_PROC_FS=y ++CONFIG_PROC_SYSCTL=y ++CONFIG_PROC_PAGE_MONITOR=y ++CONFIG_SYSFS=y ++CONFIG_TMPFS=y ++# CONFIG_TMPFS_POSIX_ACL is not set ++# CONFIG_HUGETLB_PAGE is not set ++CONFIG_CONFIGFS_FS=y ++CONFIG_MISC_FILESYSTEMS=y ++# CONFIG_ADFS_FS is not set ++# CONFIG_AFFS_FS is not set ++# CONFIG_HFS_FS is not set ++# CONFIG_HFSPLUS_FS is not set ++# CONFIG_BEFS_FS is not set ++# CONFIG_BFS_FS is not set ++# CONFIG_EFS_FS is not set ++CONFIG_JFFS2_FS=y ++CONFIG_JFFS2_FS_DEBUG=0 ++CONFIG_JFFS2_FS_WRITEBUFFER=y ++# CONFIG_JFFS2_FS_WBUF_VERIFY is not set ++CONFIG_JFFS2_SUMMARY=y ++# CONFIG_JFFS2_FS_XATTR is not set ++# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set ++CONFIG_JFFS2_ZLIB=y ++# CONFIG_JFFS2_LZO is not set ++CONFIG_JFFS2_RTIME=y ++# CONFIG_JFFS2_RUBIN is not set ++CONFIG_CRAMFS=y ++# CONFIG_SQUASHFS is not set ++# CONFIG_VXFS_FS is not set ++# CONFIG_MINIX_FS is not set ++# CONFIG_OMFS_FS is not set ++# CONFIG_HPFS_FS is not set ++# CONFIG_QNX4FS_FS is not set ++# CONFIG_ROMFS_FS is not set ++# CONFIG_SYSV_FS is not set ++# CONFIG_UFS_FS is not set ++# CONFIG_NILFS2_FS is not set ++CONFIG_NETWORK_FILESYSTEMS=y ++CONFIG_NFS_FS=y ++CONFIG_NFS_V3=y ++# CONFIG_NFS_V3_ACL is not set ++CONFIG_NFS_V4=y ++CONFIG_ROOT_NFS=y ++# CONFIG_NFSD is not set ++CONFIG_LOCKD=y ++CONFIG_LOCKD_V4=y ++CONFIG_NFS_COMMON=y ++CONFIG_SUNRPC=y ++CONFIG_SUNRPC_GSS=y ++CONFIG_RPCSEC_GSS_KRB5=y ++# CONFIG_RPCSEC_GSS_SPKM3 is not set ++# CONFIG_SMB_FS is not set ++# CONFIG_CIFS is not set ++# CONFIG_NCP_FS is not set ++# CONFIG_CODA_FS is not set ++# CONFIG_AFS_FS is not set ++ ++# ++# Partition Types ++# ++CONFIG_PARTITION_ADVANCED=y ++# CONFIG_ACORN_PARTITION is not set ++# CONFIG_OSF_PARTITION is not set ++# CONFIG_AMIGA_PARTITION is not set ++# CONFIG_ATARI_PARTITION is not set ++# CONFIG_MAC_PARTITION is not set ++CONFIG_MSDOS_PARTITION=y ++# CONFIG_BSD_DISKLABEL is not set ++# CONFIG_MINIX_SUBPARTITION is not set ++# CONFIG_SOLARIS_X86_PARTITION is not set ++# CONFIG_UNIXWARE_DISKLABEL is not set ++# CONFIG_LDM_PARTITION is not set ++# CONFIG_SGI_PARTITION is not set ++# CONFIG_ULTRIX_PARTITION is not set ++# CONFIG_SUN_PARTITION is not set ++# CONFIG_KARMA_PARTITION is not set ++# CONFIG_EFI_PARTITION is not set ++# CONFIG_SYSV68_PARTITION is not set ++CONFIG_NLS=y ++CONFIG_NLS_DEFAULT="cp437" ++CONFIG_NLS_CODEPAGE_437=y ++# CONFIG_NLS_CODEPAGE_737 is not set ++# CONFIG_NLS_CODEPAGE_775 is not set ++CONFIG_NLS_CODEPAGE_850=y ++# CONFIG_NLS_CODEPAGE_852 is not set ++# CONFIG_NLS_CODEPAGE_855 is not set ++# CONFIG_NLS_CODEPAGE_857 is not set ++# CONFIG_NLS_CODEPAGE_860 is not set ++# CONFIG_NLS_CODEPAGE_861 is not set ++# CONFIG_NLS_CODEPAGE_862 is not set ++# CONFIG_NLS_CODEPAGE_863 is not set ++# CONFIG_NLS_CODEPAGE_864 is not set ++# CONFIG_NLS_CODEPAGE_865 is not set ++# CONFIG_NLS_CODEPAGE_866 is not set ++# CONFIG_NLS_CODEPAGE_869 is not set ++# CONFIG_NLS_CODEPAGE_936 is not set ++# CONFIG_NLS_CODEPAGE_950 is not set ++# CONFIG_NLS_CODEPAGE_932 is not set ++# CONFIG_NLS_CODEPAGE_949 is not set ++# CONFIG_NLS_CODEPAGE_874 is not set ++# CONFIG_NLS_ISO8859_8 is not set ++CONFIG_NLS_CODEPAGE_1250=m ++# CONFIG_NLS_CODEPAGE_1251 is not set ++CONFIG_NLS_ASCII=m ++CONFIG_NLS_ISO8859_1=m ++# CONFIG_NLS_ISO8859_2 is not set ++# CONFIG_NLS_ISO8859_3 is not set ++# CONFIG_NLS_ISO8859_4 is not set ++# CONFIG_NLS_ISO8859_5 is not set ++# CONFIG_NLS_ISO8859_6 is not set ++# CONFIG_NLS_ISO8859_7 is not set ++# CONFIG_NLS_ISO8859_9 is not set ++# CONFIG_NLS_ISO8859_13 is not set ++# CONFIG_NLS_ISO8859_14 is not set ++CONFIG_NLS_ISO8859_15=y ++# CONFIG_NLS_KOI8_R is not set ++# CONFIG_NLS_KOI8_U is not set ++CONFIG_NLS_UTF8=y ++# CONFIG_DLM is not set ++ ++# ++# Kernel hacking ++# ++# CONFIG_PRINTK_TIME is not set ++CONFIG_ENABLE_WARN_DEPRECATED=y ++CONFIG_ENABLE_MUST_CHECK=y ++CONFIG_FRAME_WARN=1024 ++CONFIG_MAGIC_SYSRQ=y ++# CONFIG_UNUSED_SYMBOLS is not set ++# CONFIG_DEBUG_FS is not set ++# CONFIG_HEADERS_CHECK is not set ++CONFIG_DEBUG_KERNEL=y ++# CONFIG_DEBUG_SHIRQ is not set ++CONFIG_DETECT_SOFTLOCKUP=y ++CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC=y ++CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=1 ++CONFIG_DETECT_HUNG_TASK=y ++CONFIG_BOOTPARAM_HUNG_TASK_PANIC=y ++CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=1 ++# CONFIG_SCHED_DEBUG is not set ++# CONFIG_SCHEDSTATS is not set ++# CONFIG_TIMER_STATS is not set ++# CONFIG_DEBUG_OBJECTS is not set ++CONFIG_DEBUG_SLAB=y ++CONFIG_DEBUG_SLAB_LEAK=y ++# CONFIG_DEBUG_PREEMPT is not set ++# CONFIG_DEBUG_RT_MUTEXES is not set ++# CONFIG_RT_MUTEX_TESTER is not set ++# CONFIG_DEBUG_SPINLOCK is not set ++# CONFIG_DEBUG_MUTEXES is not set ++# CONFIG_DEBUG_LOCK_ALLOC is not set ++# CONFIG_PROVE_LOCKING is not set ++# CONFIG_LOCK_STAT is not set ++# CONFIG_DEBUG_SPINLOCK_SLEEP is not set ++# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set ++# CONFIG_DEBUG_KOBJECT is not set ++CONFIG_DEBUG_BUGVERBOSE=y ++# CONFIG_DEBUG_INFO is not set ++# CONFIG_DEBUG_VM is not set ++# CONFIG_DEBUG_WRITECOUNT is not set ++# CONFIG_DEBUG_MEMORY_INIT is not set ++# CONFIG_DEBUG_LIST is not set ++# CONFIG_DEBUG_SG is not set ++# CONFIG_DEBUG_NOTIFIERS is not set ++# CONFIG_BOOT_PRINTK_DELAY is not set ++# CONFIG_RCU_TORTURE_TEST is not set ++# CONFIG_RCU_CPU_STALL_DETECTOR is not set ++# CONFIG_BACKTRACE_SELF_TEST is not set ++# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set ++# CONFIG_FAULT_INJECTION is not set ++# CONFIG_LATENCYTOP is not set ++# CONFIG_SYSCTL_SYSCALL_CHECK is not set ++# CONFIG_PAGE_POISONING is not set ++CONFIG_HAVE_FUNCTION_TRACER=y ++CONFIG_TRACING_SUPPORT=y ++ ++# ++# Tracers ++# ++# CONFIG_FUNCTION_TRACER is not set ++# CONFIG_IRQSOFF_TRACER is not set ++# CONFIG_PREEMPT_TRACER is not set ++# CONFIG_SCHED_TRACER is not set ++# CONFIG_CONTEXT_SWITCH_TRACER is not set ++# CONFIG_EVENT_TRACER is not set ++# CONFIG_BOOT_TRACER is not set ++# CONFIG_TRACE_BRANCH_PROFILING is not set ++# CONFIG_STACK_TRACER is not set ++# CONFIG_KMEMTRACE is not set ++# CONFIG_WORKQUEUE_TRACER is not set ++# CONFIG_BLK_DEV_IO_TRACE is not set ++# CONFIG_SAMPLES is not set ++CONFIG_HAVE_ARCH_KGDB=y ++# CONFIG_KGDB is not set ++CONFIG_ARM_UNWIND=y ++CONFIG_DEBUG_USER=y ++CONFIG_DEBUG_ERRORS=y ++# CONFIG_DEBUG_STACK_USAGE is not set ++# CONFIG_DEBUG_LL is not set ++ ++# ++# Security options ++# ++# CONFIG_KEYS is not set ++# CONFIG_SECURITY is not set ++# CONFIG_SECURITYFS is not set ++# CONFIG_SECURITY_FILE_CAPABILITIES is not set ++CONFIG_CRYPTO=y ++ ++# ++# Crypto core or helper ++# ++# CONFIG_CRYPTO_FIPS is not set ++CONFIG_CRYPTO_ALGAPI=y ++CONFIG_CRYPTO_ALGAPI2=y ++CONFIG_CRYPTO_AEAD2=y ++CONFIG_CRYPTO_BLKCIPHER=y ++CONFIG_CRYPTO_BLKCIPHER2=y ++CONFIG_CRYPTO_HASH=y ++CONFIG_CRYPTO_HASH2=y ++CONFIG_CRYPTO_RNG2=y ++CONFIG_CRYPTO_PCOMP=y ++CONFIG_CRYPTO_MANAGER=y ++CONFIG_CRYPTO_MANAGER2=y ++# CONFIG_CRYPTO_GF128MUL is not set ++# CONFIG_CRYPTO_NULL is not set ++CONFIG_CRYPTO_WORKQUEUE=y ++# CONFIG_CRYPTO_CRYPTD is not set ++# CONFIG_CRYPTO_AUTHENC is not set ++# CONFIG_CRYPTO_TEST is not set ++ ++# ++# Authenticated Encryption with Associated Data ++# ++# CONFIG_CRYPTO_CCM is not set ++# CONFIG_CRYPTO_GCM is not set ++# CONFIG_CRYPTO_SEQIV is not set ++ ++# ++# Block modes ++# ++CONFIG_CRYPTO_CBC=y ++# CONFIG_CRYPTO_CTR is not set ++# CONFIG_CRYPTO_CTS is not set ++CONFIG_CRYPTO_ECB=y ++# CONFIG_CRYPTO_LRW is not set ++# CONFIG_CRYPTO_PCBC is not set ++# CONFIG_CRYPTO_XTS is not set ++ ++# ++# Hash modes ++# ++CONFIG_CRYPTO_HMAC=y ++# CONFIG_CRYPTO_XCBC is not set ++ ++# ++# Digest ++# ++# CONFIG_CRYPTO_CRC32C is not set ++# CONFIG_CRYPTO_MD4 is not set ++CONFIG_CRYPTO_MD5=y ++# CONFIG_CRYPTO_MICHAEL_MIC is not set ++# CONFIG_CRYPTO_RMD128 is not set ++# CONFIG_CRYPTO_RMD160 is not set ++# CONFIG_CRYPTO_RMD256 is not set ++# CONFIG_CRYPTO_RMD320 is not set ++# CONFIG_CRYPTO_SHA1 is not set ++# CONFIG_CRYPTO_SHA256 is not set ++# CONFIG_CRYPTO_SHA512 is not set ++# CONFIG_CRYPTO_TGR192 is not set ++# CONFIG_CRYPTO_WP512 is not set ++ ++# ++# Ciphers ++# ++CONFIG_CRYPTO_AES=y ++# CONFIG_CRYPTO_ANUBIS is not set ++CONFIG_CRYPTO_ARC4=y ++# CONFIG_CRYPTO_BLOWFISH is not set ++# CONFIG_CRYPTO_CAMELLIA is not set ++# CONFIG_CRYPTO_CAST5 is not set ++# CONFIG_CRYPTO_CAST6 is not set ++CONFIG_CRYPTO_DES=y ++# CONFIG_CRYPTO_FCRYPT is not set ++# CONFIG_CRYPTO_KHAZAD is not set ++# CONFIG_CRYPTO_SALSA20 is not set ++# CONFIG_CRYPTO_SEED is not set ++# CONFIG_CRYPTO_SERPENT is not set ++# CONFIG_CRYPTO_TEA is not set ++# CONFIG_CRYPTO_TWOFISH is not set ++ ++# ++# Compression ++# ++# CONFIG_CRYPTO_DEFLATE is not set ++# CONFIG_CRYPTO_ZLIB is not set ++# CONFIG_CRYPTO_LZO is not set ++ ++# ++# Random Number Generation ++# ++# CONFIG_CRYPTO_ANSI_CPRNG is not set ++CONFIG_CRYPTO_HW=y ++# CONFIG_BINARY_PRINTF is not set ++ ++# ++# Library routines ++# ++CONFIG_BITREVERSE=y ++CONFIG_GENERIC_FIND_LAST_BIT=y ++# CONFIG_CRC_CCITT is not set ++# CONFIG_CRC16 is not set ++# CONFIG_CRC_T10DIF is not set ++# CONFIG_CRC_ITU_T is not set ++CONFIG_CRC32=y ++# CONFIG_CRC7 is not set ++# CONFIG_LIBCRC32C is not set ++CONFIG_ZLIB_INFLATE=y ++CONFIG_ZLIB_DEFLATE=y ++CONFIG_DECOMPRESS_GZIP=y ++CONFIG_HAS_IOMEM=y ++CONFIG_HAS_IOPORT=y ++CONFIG_HAS_DMA=y ++CONFIG_NLATTR=y +diff -urNp linux-2.6.30-rc4/arch/arm/configs/karo_tx25_defconfig linux-2.6.30-rc4-karo/arch/arm/configs/karo_tx25_defconfig +--- linux-2.6.30-rc4/arch/arm/configs/karo_tx25_defconfig 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/arch/arm/configs/karo_tx25_defconfig 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,1203 @@ ++# ++# Automatically generated make config: don't edit ++# Linux kernel version: 2.6.30-rc4 ++# Tue Jun 2 15:46:43 2009 ++# ++CONFIG_ARM=y ++CONFIG_SYS_SUPPORTS_APM_EMULATION=y ++CONFIG_GENERIC_GPIO=y ++CONFIG_GENERIC_TIME=y ++CONFIG_GENERIC_CLOCKEVENTS=y ++CONFIG_MMU=y ++# CONFIG_NO_IOPORT is not set ++CONFIG_GENERIC_HARDIRQS=y ++CONFIG_STACKTRACE_SUPPORT=y ++CONFIG_HAVE_LATENCYTOP_SUPPORT=y ++CONFIG_LOCKDEP_SUPPORT=y ++CONFIG_TRACE_IRQFLAGS_SUPPORT=y ++CONFIG_HARDIRQS_SW_RESEND=y ++CONFIG_GENERIC_IRQ_PROBE=y ++CONFIG_RWSEM_GENERIC_SPINLOCK=y ++# CONFIG_ARCH_HAS_ILOG2_U32 is not set ++# CONFIG_ARCH_HAS_ILOG2_U64 is not set ++CONFIG_GENERIC_HWEIGHT=y ++CONFIG_GENERIC_CALIBRATE_DELAY=y ++CONFIG_ARCH_MTD_XIP=y ++CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y ++CONFIG_VECTORS_BASE=0xffff0000 ++CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" ++ ++# ++# General setup ++# ++CONFIG_EXPERIMENTAL=y ++CONFIG_BROKEN_ON_SMP=y ++CONFIG_LOCK_KERNEL=y ++CONFIG_INIT_ENV_ARG_LIMIT=32 ++CONFIG_LOCALVERSION="" ++CONFIG_LOCALVERSION_AUTO=y ++# CONFIG_SWAP is not set ++CONFIG_SYSVIPC=y ++CONFIG_SYSVIPC_SYSCTL=y ++CONFIG_POSIX_MQUEUE=y ++CONFIG_POSIX_MQUEUE_SYSCTL=y ++# CONFIG_BSD_PROCESS_ACCT is not set ++# CONFIG_TASKSTATS is not set ++# CONFIG_AUDIT is not set ++ ++# ++# RCU Subsystem ++# ++CONFIG_CLASSIC_RCU=y ++# CONFIG_TREE_RCU is not set ++# CONFIG_PREEMPT_RCU is not set ++# CONFIG_TREE_RCU_TRACE is not set ++# CONFIG_PREEMPT_RCU_TRACE is not set ++# CONFIG_IKCONFIG is not set ++CONFIG_LOG_BUF_SHIFT=17 ++# CONFIG_GROUP_SCHED is not set ++# CONFIG_CGROUPS is not set ++# CONFIG_SYSFS_DEPRECATED_V2 is not set ++# CONFIG_RELAY is not set ++# CONFIG_NAMESPACES is not set ++CONFIG_BLK_DEV_INITRD=y ++CONFIG_INITRAMFS_SOURCE="" ++CONFIG_RD_GZIP=y ++# CONFIG_RD_BZIP2 is not set ++# CONFIG_RD_LZMA is not set ++# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set ++CONFIG_SYSCTL=y ++CONFIG_ANON_INODES=y ++CONFIG_EMBEDDED=y ++CONFIG_UID16=y ++CONFIG_SYSCTL_SYSCALL=y ++CONFIG_KALLSYMS=y ++# CONFIG_KALLSYMS_ALL is not set ++# CONFIG_KALLSYMS_EXTRA_PASS is not set ++# CONFIG_STRIP_ASM_SYMS is not set ++CONFIG_HOTPLUG=y ++CONFIG_PRINTK=y ++CONFIG_BUG=y ++# CONFIG_ELF_CORE is not set ++CONFIG_BASE_FULL=y ++CONFIG_FUTEX=y ++CONFIG_EPOLL=y ++CONFIG_SIGNALFD=y ++CONFIG_TIMERFD=y ++CONFIG_EVENTFD=y ++CONFIG_SHMEM=y ++# CONFIG_AIO is not set ++# CONFIG_VM_EVENT_COUNTERS is not set ++# CONFIG_COMPAT_BRK is not set ++CONFIG_SLAB=y ++# CONFIG_SLUB is not set ++# CONFIG_SLOB is not set ++# CONFIG_PROFILING is not set ++# CONFIG_MARKERS is not set ++CONFIG_HAVE_OPROFILE=y ++# CONFIG_KPROBES is not set ++CONFIG_HAVE_KPROBES=y ++CONFIG_HAVE_KRETPROBES=y ++CONFIG_HAVE_CLK=y ++# CONFIG_SLOW_WORK is not set ++CONFIG_HAVE_GENERIC_DMA_COHERENT=y ++CONFIG_SLABINFO=y ++CONFIG_RT_MUTEXES=y ++CONFIG_BASE_SMALL=0 ++CONFIG_MODULES=y ++# CONFIG_MODULE_FORCE_LOAD is not set ++CONFIG_MODULE_UNLOAD=y ++CONFIG_MODULE_FORCE_UNLOAD=y ++CONFIG_MODVERSIONS=y ++# CONFIG_MODULE_SRCVERSION_ALL is not set ++CONFIG_BLOCK=y ++CONFIG_LBD=y ++# CONFIG_BLK_DEV_BSG is not set ++# CONFIG_BLK_DEV_INTEGRITY is not set ++ ++# ++# IO Schedulers ++# ++CONFIG_IOSCHED_NOOP=y ++CONFIG_IOSCHED_AS=y ++CONFIG_IOSCHED_DEADLINE=y ++CONFIG_IOSCHED_CFQ=y ++CONFIG_DEFAULT_AS=y ++# CONFIG_DEFAULT_DEADLINE is not set ++# CONFIG_DEFAULT_CFQ is not set ++# CONFIG_DEFAULT_NOOP is not set ++CONFIG_DEFAULT_IOSCHED="anticipatory" ++CONFIG_FREEZER=y ++ ++# ++# System Type ++# ++# CONFIG_ARCH_AAEC2000 is not set ++# CONFIG_ARCH_INTEGRATOR is not set ++# CONFIG_ARCH_REALVIEW is not set ++# CONFIG_ARCH_VERSATILE is not set ++# CONFIG_ARCH_AT91 is not set ++# CONFIG_ARCH_CLPS711X is not set ++# CONFIG_ARCH_EBSA110 is not set ++# CONFIG_ARCH_EP93XX is not set ++# CONFIG_ARCH_GEMINI is not set ++# CONFIG_ARCH_FOOTBRIDGE is not set ++# CONFIG_ARCH_NETX is not set ++# CONFIG_ARCH_H720X is not set ++# CONFIG_ARCH_IOP13XX is not set ++# CONFIG_ARCH_IOP32X is not set ++# CONFIG_ARCH_IOP33X is not set ++# CONFIG_ARCH_IXP23XX is not set ++# CONFIG_ARCH_IXP2000 is not set ++# CONFIG_ARCH_IXP4XX is not set ++# CONFIG_ARCH_L7200 is not set ++# CONFIG_ARCH_KIRKWOOD is not set ++# CONFIG_ARCH_KS8695 is not set ++# CONFIG_ARCH_NS9XXX is not set ++# CONFIG_ARCH_LOKI is not set ++# CONFIG_ARCH_MV78XX0 is not set ++CONFIG_ARCH_MXC=y ++# CONFIG_ARCH_ORION5X is not set ++# CONFIG_ARCH_PNX4008 is not set ++# CONFIG_ARCH_PXA is not set ++# CONFIG_ARCH_MMP is not set ++# CONFIG_ARCH_RPC is not set ++# CONFIG_ARCH_SA1100 is not set ++# CONFIG_ARCH_S3C2410 is not set ++# CONFIG_ARCH_S3C64XX is not set ++# CONFIG_ARCH_SHARK is not set ++# CONFIG_ARCH_LH7A40X is not set ++# CONFIG_ARCH_DAVINCI is not set ++# CONFIG_ARCH_OMAP is not set ++# CONFIG_ARCH_MSM is not set ++# CONFIG_ARCH_W90X900 is not set ++ ++# ++# Freescale MXC Implementations ++# ++# CONFIG_ARCH_MX1 is not set ++CONFIG_ARCH_MX2=y ++# CONFIG_ARCH_MX3 is not set ++# CONFIG_MACH_MX21 is not set ++# CONFIG_MACH_MX27 is not set ++CONFIG_MACH_MX25=y ++ ++# ++# MX2 platforms: ++# ++CONFIG_MACH_TX25=y ++# CONFIG_KARO_DEBUG is not set ++CONFIG_MACH_STK5_BASEBOARD=y ++# CONFIG_MXC_IRQ_PRIOR is not set ++# CONFIG_MXC_PWM is not set ++CONFIG_ARCH_MXC_IOMUX_V3=y ++ ++# ++# Processor Type ++# ++CONFIG_CPU_32=y ++CONFIG_CPU_ARM926T=y ++CONFIG_CPU_32v5=y ++CONFIG_CPU_ABRT_EV5TJ=y ++CONFIG_CPU_PABRT_NOIFAR=y ++CONFIG_CPU_CACHE_VIVT=y ++CONFIG_CPU_COPY_V4WB=y ++CONFIG_CPU_TLB_V4WBI=y ++CONFIG_CPU_CP15=y ++CONFIG_CPU_CP15_MMU=y ++ ++# ++# Processor Features ++# ++CONFIG_ARM_THUMB=y ++# CONFIG_CPU_ICACHE_DISABLE is not set ++# CONFIG_CPU_DCACHE_DISABLE is not set ++# CONFIG_CPU_DCACHE_WRITETHROUGH is not set ++# CONFIG_CPU_CACHE_ROUND_ROBIN is not set ++# CONFIG_OUTER_CACHE is not set ++CONFIG_COMMON_CLKDEV=y ++ ++# ++# Bus support ++# ++# CONFIG_PCI_SYSCALL is not set ++# CONFIG_ARCH_SUPPORTS_MSI is not set ++# CONFIG_PCCARD is not set ++ ++# ++# Kernel Features ++# ++CONFIG_TICK_ONESHOT=y ++CONFIG_NO_HZ=y ++# CONFIG_HIGH_RES_TIMERS is not set ++CONFIG_GENERIC_CLOCKEVENTS_BUILD=y ++CONFIG_VMSPLIT_3G=y ++# CONFIG_VMSPLIT_2G is not set ++# CONFIG_VMSPLIT_1G is not set ++CONFIG_PAGE_OFFSET=0xC0000000 ++CONFIG_PREEMPT=y ++CONFIG_HZ=100 ++CONFIG_AEABI=y ++CONFIG_OABI_COMPAT=y ++CONFIG_ARCH_FLATMEM_HAS_HOLES=y ++# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set ++# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set ++# CONFIG_HIGHMEM is not set ++CONFIG_SELECT_MEMORY_MODEL=y ++CONFIG_FLATMEM_MANUAL=y ++# CONFIG_DISCONTIGMEM_MANUAL is not set ++# CONFIG_SPARSEMEM_MANUAL is not set ++CONFIG_FLATMEM=y ++CONFIG_FLAT_NODE_MEM_MAP=y ++CONFIG_PAGEFLAGS_EXTENDED=y ++CONFIG_SPLIT_PTLOCK_CPUS=4096 ++# CONFIG_PHYS_ADDR_T_64BIT is not set ++CONFIG_ZONE_DMA_FLAG=0 ++CONFIG_VIRT_TO_BUS=y ++CONFIG_UNEVICTABLE_LRU=y ++CONFIG_HAVE_MLOCK=y ++CONFIG_HAVE_MLOCKED_PAGE_BIT=y ++CONFIG_ALIGNMENT_TRAP=y ++ ++# ++# Boot options ++# ++CONFIG_ZBOOT_ROM_TEXT=0 ++CONFIG_ZBOOT_ROM_BSS=0 ++CONFIG_CMDLINE="init=/linuxrc root=1f01 rootfstype=jffs2 ro console=ttymxc0,115200 panic=1" ++# CONFIG_XIP_KERNEL is not set ++# CONFIG_KEXEC is not set ++ ++# ++# CPU Power Management ++# ++CONFIG_CPU_IDLE=y ++CONFIG_CPU_IDLE_GOV_LADDER=y ++CONFIG_CPU_IDLE_GOV_MENU=y ++ ++# ++# Floating point emulation ++# ++ ++# ++# At least one emulation must be selected ++# ++CONFIG_FPE_NWFPE=y ++# CONFIG_FPE_NWFPE_XP is not set ++# CONFIG_FPE_FASTFPE is not set ++CONFIG_VFP=y ++ ++# ++# Userspace binary formats ++# ++CONFIG_BINFMT_ELF=y ++CONFIG_HAVE_AOUT=y ++# CONFIG_BINFMT_AOUT is not set ++# CONFIG_BINFMT_MISC is not set ++ ++# ++# Power management options ++# ++CONFIG_PM=y ++CONFIG_PM_DEBUG=y ++CONFIG_PM_VERBOSE=y ++CONFIG_CAN_PM_TRACE=y ++CONFIG_PM_SLEEP=y ++CONFIG_SUSPEND=y ++CONFIG_SUSPEND_FREEZER=y ++CONFIG_APM_EMULATION=y ++CONFIG_ARCH_SUSPEND_POSSIBLE=y ++CONFIG_NET=y ++ ++# ++# Networking options ++# ++CONFIG_PACKET=y ++CONFIG_PACKET_MMAP=y ++CONFIG_UNIX=y ++# CONFIG_NET_KEY is not set ++CONFIG_INET=y ++# CONFIG_IP_MULTICAST is not set ++# CONFIG_IP_ADVANCED_ROUTER is not set ++CONFIG_IP_FIB_HASH=y ++CONFIG_IP_PNP=y ++CONFIG_IP_PNP_DHCP=y ++CONFIG_IP_PNP_BOOTP=y ++# CONFIG_IP_PNP_RARP is not set ++# CONFIG_NET_IPIP is not set ++# CONFIG_NET_IPGRE is not set ++# CONFIG_ARPD is not set ++CONFIG_SYN_COOKIES=y ++# CONFIG_INET_AH is not set ++# CONFIG_INET_ESP is not set ++# CONFIG_INET_IPCOMP is not set ++# CONFIG_INET_XFRM_TUNNEL is not set ++# CONFIG_INET_TUNNEL is not set ++# CONFIG_INET_XFRM_MODE_TRANSPORT is not set ++# CONFIG_INET_XFRM_MODE_TUNNEL is not set ++# CONFIG_INET_XFRM_MODE_BEET is not set ++# CONFIG_INET_LRO is not set ++# CONFIG_INET_DIAG is not set ++# CONFIG_TCP_CONG_ADVANCED is not set ++CONFIG_TCP_CONG_CUBIC=y ++CONFIG_DEFAULT_TCP_CONG="cubic" ++# CONFIG_TCP_MD5SIG is not set ++# CONFIG_IPV6 is not set ++# CONFIG_NETWORK_SECMARK is not set ++# CONFIG_NETFILTER is not set ++# CONFIG_IP_DCCP is not set ++# CONFIG_IP_SCTP is not set ++# CONFIG_TIPC is not set ++# CONFIG_ATM is not set ++# CONFIG_BRIDGE is not set ++# CONFIG_NET_DSA is not set ++# CONFIG_VLAN_8021Q is not set ++# CONFIG_DECNET is not set ++# CONFIG_LLC2 is not set ++# CONFIG_IPX is not set ++# CONFIG_ATALK is not set ++# CONFIG_X25 is not set ++# CONFIG_LAPB is not set ++# CONFIG_ECONET is not set ++# CONFIG_WAN_ROUTER is not set ++# CONFIG_PHONET is not set ++# CONFIG_NET_SCHED is not set ++# CONFIG_DCB is not set ++ ++# ++# Network testing ++# ++# CONFIG_NET_PKTGEN is not set ++# CONFIG_HAMRADIO is not set ++# CONFIG_CAN is not set ++# CONFIG_IRDA is not set ++# CONFIG_BT is not set ++# CONFIG_AF_RXRPC is not set ++# CONFIG_WIRELESS is not set ++# CONFIG_WIMAX is not set ++# CONFIG_RFKILL is not set ++# CONFIG_NET_9P is not set ++ ++# ++# Device Drivers ++# ++ ++# ++# Generic Driver Options ++# ++CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" ++CONFIG_STANDALONE=y ++CONFIG_PREVENT_FIRMWARE_BUILD=y ++CONFIG_FW_LOADER=y ++CONFIG_FIRMWARE_IN_KERNEL=y ++CONFIG_EXTRA_FIRMWARE="" ++# CONFIG_DEBUG_DRIVER is not set ++# CONFIG_DEBUG_DEVRES is not set ++# CONFIG_SYS_HYPERVISOR is not set ++# CONFIG_CONNECTOR is not set ++CONFIG_MTD=y ++CONFIG_MTD_DEBUG=y ++CONFIG_MTD_DEBUG_VERBOSE=0 ++CONFIG_MTD_CONCAT=y ++CONFIG_MTD_PARTITIONS=y ++CONFIG_MTD_TESTS=m ++CONFIG_MTD_REDBOOT_PARTS=y ++CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-5 ++# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set ++CONFIG_MTD_REDBOOT_PARTS_READONLY=y ++CONFIG_MTD_CMDLINE_PARTS=y ++# CONFIG_MTD_AFS_PARTS is not set ++# CONFIG_MTD_AR7_PARTS is not set ++ ++# ++# User Modules And Translation Layers ++# ++CONFIG_MTD_CHAR=y ++CONFIG_MTD_BLKDEVS=y ++CONFIG_MTD_BLOCK=y ++# CONFIG_FTL is not set ++# CONFIG_NFTL is not set ++# CONFIG_INFTL is not set ++# CONFIG_RFD_FTL is not set ++# CONFIG_SSFDC is not set ++# CONFIG_MTD_OOPS is not set ++ ++# ++# RAM/ROM/Flash chip drivers ++# ++# CONFIG_MTD_CFI is not set ++# CONFIG_MTD_JEDECPROBE is not set ++CONFIG_MTD_MAP_BANK_WIDTH_1=y ++CONFIG_MTD_MAP_BANK_WIDTH_2=y ++CONFIG_MTD_MAP_BANK_WIDTH_4=y ++# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set ++# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set ++# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set ++CONFIG_MTD_CFI_I1=y ++CONFIG_MTD_CFI_I2=y ++# CONFIG_MTD_CFI_I4 is not set ++# CONFIG_MTD_CFI_I8 is not set ++# CONFIG_MTD_RAM is not set ++# CONFIG_MTD_ROM is not set ++# CONFIG_MTD_ABSENT is not set ++ ++# ++# Mapping drivers for chip access ++# ++# CONFIG_MTD_COMPLEX_MAPPINGS is not set ++# CONFIG_MTD_PLATRAM is not set ++ ++# ++# Self-contained MTD device drivers ++# ++# CONFIG_MTD_SLRAM is not set ++# CONFIG_MTD_PHRAM is not set ++# CONFIG_MTD_MTDRAM is not set ++# CONFIG_MTD_BLOCK2MTD is not set ++ ++# ++# Disk-On-Chip Device Drivers ++# ++# CONFIG_MTD_DOC2000 is not set ++# CONFIG_MTD_DOC2001 is not set ++# CONFIG_MTD_DOC2001PLUS is not set ++CONFIG_MTD_NAND=y ++CONFIG_MTD_NAND_VERIFY_WRITE=y ++# CONFIG_MTD_NAND_ECC_SMC is not set ++# CONFIG_MTD_NAND_MUSEUM_IDS is not set ++# CONFIG_MTD_NAND_GPIO is not set ++CONFIG_MTD_NAND_IDS=y ++# CONFIG_MTD_NAND_DISKONCHIP is not set ++# CONFIG_MTD_NAND_NANDSIM is not set ++# CONFIG_MTD_NAND_PLATFORM is not set ++# CONFIG_MTD_NAND_MXC is not set ++CONFIG_ARCH_MXC_HAS_NFC_V2=y ++CONFIG_ARCH_MXC_HAS_NFC_V2_1=y ++# CONFIG_MTD_ONENAND is not set ++ ++# ++# LPDDR flash memory drivers ++# ++# CONFIG_MTD_LPDDR is not set ++ ++# ++# UBI - Unsorted block images ++# ++# CONFIG_MTD_UBI is not set ++# CONFIG_PARPORT is not set ++CONFIG_BLK_DEV=y ++# CONFIG_BLK_DEV_COW_COMMON is not set ++CONFIG_BLK_DEV_LOOP=m ++# CONFIG_BLK_DEV_CRYPTOLOOP is not set ++# CONFIG_BLK_DEV_NBD is not set ++CONFIG_BLK_DEV_RAM=y ++CONFIG_BLK_DEV_RAM_COUNT=16 ++CONFIG_BLK_DEV_RAM_SIZE=8192 ++# CONFIG_BLK_DEV_XIP is not set ++# CONFIG_CDROM_PKTCDVD is not set ++# CONFIG_ATA_OVER_ETH is not set ++CONFIG_MISC_DEVICES=y ++# CONFIG_ENCLOSURE_SERVICES is not set ++# CONFIG_C2PORT is not set ++ ++# ++# EEPROM support ++# ++# CONFIG_EEPROM_93CX6 is not set ++CONFIG_HAVE_IDE=y ++# CONFIG_IDE is not set ++ ++# ++# SCSI device support ++# ++# CONFIG_RAID_ATTRS is not set ++# CONFIG_SCSI is not set ++# CONFIG_SCSI_DMA is not set ++# CONFIG_SCSI_NETLINK is not set ++# CONFIG_ATA is not set ++# CONFIG_MD is not set ++CONFIG_NETDEVICES=y ++CONFIG_COMPAT_NET_DEV_OPS=y ++# CONFIG_DUMMY is not set ++# CONFIG_BONDING is not set ++# CONFIG_MACVLAN is not set ++# CONFIG_EQUALIZER is not set ++# CONFIG_TUN is not set ++# CONFIG_VETH is not set ++CONFIG_PHYLIB=y ++ ++# ++# MII PHY device drivers ++# ++# CONFIG_MARVELL_PHY is not set ++# CONFIG_DAVICOM_PHY is not set ++# CONFIG_QSEMI_PHY is not set ++# CONFIG_LXT_PHY is not set ++# CONFIG_CICADA_PHY is not set ++# CONFIG_VITESSE_PHY is not set ++CONFIG_SMSC_PHY=y ++# CONFIG_BROADCOM_PHY is not set ++# CONFIG_ICPLUS_PHY is not set ++# CONFIG_REALTEK_PHY is not set ++# CONFIG_NATIONAL_PHY is not set ++# CONFIG_STE10XP is not set ++# CONFIG_LSI_ET1011C_PHY is not set ++# CONFIG_FIXED_PHY is not set ++# CONFIG_MDIO_BITBANG is not set ++CONFIG_NET_ETHERNET=y ++CONFIG_MII=y ++# CONFIG_AX88796 is not set ++# CONFIG_SMC91X is not set ++# CONFIG_DM9000 is not set ++# CONFIG_ETHOC is not set ++# CONFIG_SMC911X is not set ++# CONFIG_SMSC911X is not set ++# CONFIG_DNET is not set ++# CONFIG_IBM_NEW_EMAC_ZMII is not set ++# CONFIG_IBM_NEW_EMAC_RGMII is not set ++# CONFIG_IBM_NEW_EMAC_TAH is not set ++# CONFIG_IBM_NEW_EMAC_EMAC4 is not set ++# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set ++# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set ++# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set ++# CONFIG_B44 is not set ++CONFIG_FEC=y ++# CONFIG_FEC2 is not set ++# CONFIG_NETDEV_1000 is not set ++# CONFIG_NETDEV_10000 is not set ++ ++# ++# Wireless LAN ++# ++# CONFIG_WLAN_PRE80211 is not set ++# CONFIG_WLAN_80211 is not set ++ ++# ++# Enable WiMAX (Networking options) to see the WiMAX drivers ++# ++# CONFIG_WAN is not set ++# CONFIG_PPP is not set ++# CONFIG_SLIP is not set ++CONFIG_NETCONSOLE=y ++CONFIG_NETCONSOLE_DYNAMIC=y ++CONFIG_NETPOLL=y ++# CONFIG_NETPOLL_TRAP is not set ++CONFIG_NET_POLL_CONTROLLER=y ++# CONFIG_ISDN is not set ++ ++# ++# Input device support ++# ++CONFIG_INPUT=y ++# CONFIG_INPUT_FF_MEMLESS is not set ++# CONFIG_INPUT_POLLDEV is not set ++ ++# ++# Userland interfaces ++# ++CONFIG_INPUT_MOUSEDEV=m ++CONFIG_INPUT_MOUSEDEV_PSAUX=y ++CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 ++CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 ++# CONFIG_INPUT_JOYDEV is not set ++CONFIG_INPUT_EVDEV=m ++CONFIG_INPUT_EVBUG=m ++# CONFIG_INPUT_APMPOWER is not set ++ ++# ++# Input Device Drivers ++# ++CONFIG_INPUT_KEYBOARD=y ++# CONFIG_KEYBOARD_ATKBD is not set ++# CONFIG_KEYBOARD_SUNKBD is not set ++# CONFIG_KEYBOARD_LKKBD is not set ++# CONFIG_KEYBOARD_XTKBD is not set ++# CONFIG_KEYBOARD_NEWTON is not set ++# CONFIG_KEYBOARD_STOWAWAY is not set ++CONFIG_KEYBOARD_GPIO=m ++CONFIG_INPUT_MOUSE=y ++# CONFIG_MOUSE_PS2 is not set ++# CONFIG_MOUSE_SERIAL is not set ++# CONFIG_MOUSE_VSXXXAA is not set ++# CONFIG_MOUSE_GPIO is not set ++# CONFIG_INPUT_JOYSTICK is not set ++# CONFIG_INPUT_TABLET is not set ++# CONFIG_INPUT_TOUCHSCREEN is not set ++# CONFIG_INPUT_MISC is not set ++ ++# ++# Hardware I/O ports ++# ++# CONFIG_SERIO is not set ++# CONFIG_GAMEPORT is not set ++ ++# ++# Character devices ++# ++CONFIG_VT=y ++CONFIG_CONSOLE_TRANSLATIONS=y ++CONFIG_VT_CONSOLE=y ++CONFIG_HW_CONSOLE=y ++CONFIG_VT_HW_CONSOLE_BINDING=y ++CONFIG_DEVKMEM=y ++# CONFIG_SERIAL_NONSTANDARD is not set ++ ++# ++# Serial drivers ++# ++# CONFIG_SERIAL_8250 is not set ++ ++# ++# Non-8250 serial port support ++# ++CONFIG_SERIAL_IMX=y ++CONFIG_SERIAL_IMX_CONSOLE=y ++CONFIG_SERIAL_CORE=y ++CONFIG_SERIAL_CORE_CONSOLE=y ++CONFIG_UNIX98_PTYS=y ++# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set ++CONFIG_LEGACY_PTYS=y ++CONFIG_LEGACY_PTY_COUNT=16 ++# CONFIG_IPMI_HANDLER is not set ++# CONFIG_HW_RANDOM is not set ++# CONFIG_R3964 is not set ++# CONFIG_RAW_DRIVER is not set ++# CONFIG_TCG_TPM is not set ++# CONFIG_I2C is not set ++# CONFIG_SPI is not set ++CONFIG_ARCH_REQUIRE_GPIOLIB=y ++CONFIG_GPIOLIB=y ++CONFIG_DEBUG_GPIO=y ++CONFIG_GPIO_SYSFS=y ++ ++# ++# Memory mapped GPIO expanders: ++# ++ ++# ++# I2C GPIO expanders: ++# ++ ++# ++# PCI GPIO expanders: ++# ++ ++# ++# SPI GPIO expanders: ++# ++# CONFIG_W1 is not set ++# CONFIG_POWER_SUPPLY is not set ++# CONFIG_HWMON is not set ++# CONFIG_THERMAL is not set ++# CONFIG_THERMAL_HWMON is not set ++# CONFIG_WATCHDOG is not set ++CONFIG_SSB_POSSIBLE=y ++ ++# ++# Sonics Silicon Backplane ++# ++# CONFIG_SSB is not set ++ ++# ++# Multifunction device drivers ++# ++# CONFIG_MFD_CORE is not set ++# CONFIG_MFD_SM501 is not set ++# CONFIG_MFD_ASIC3 is not set ++# CONFIG_HTC_EGPIO is not set ++# CONFIG_HTC_PASIC3 is not set ++# CONFIG_MFD_TMIO is not set ++# CONFIG_MFD_T7L66XB is not set ++# CONFIG_MFD_TC6387XB is not set ++# CONFIG_MFD_TC6393XB is not set ++ ++# ++# Multimedia devices ++# ++ ++# ++# Multimedia core support ++# ++# CONFIG_VIDEO_DEV is not set ++# CONFIG_DVB_CORE is not set ++# CONFIG_VIDEO_MEDIA is not set ++ ++# ++# Multimedia drivers ++# ++# CONFIG_DAB is not set ++ ++# ++# Graphics support ++# ++# CONFIG_VGASTATE is not set ++# CONFIG_VIDEO_OUTPUT_CONTROL is not set ++CONFIG_FB=y ++# CONFIG_FIRMWARE_EDID is not set ++# CONFIG_FB_DDC is not set ++# CONFIG_FB_BOOT_VESA_SUPPORT is not set ++CONFIG_FB_CFB_FILLRECT=y ++CONFIG_FB_CFB_COPYAREA=y ++CONFIG_FB_CFB_IMAGEBLIT=y ++# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set ++# CONFIG_FB_SYS_FILLRECT is not set ++# CONFIG_FB_SYS_COPYAREA is not set ++# CONFIG_FB_SYS_IMAGEBLIT is not set ++# CONFIG_FB_FOREIGN_ENDIAN is not set ++# CONFIG_FB_SYS_FOPS is not set ++# CONFIG_FB_SVGALIB is not set ++# CONFIG_FB_MACMODES is not set ++# CONFIG_FB_BACKLIGHT is not set ++CONFIG_FB_MODE_HELPERS=y ++CONFIG_FB_TILEBLITTING=y ++ ++# ++# Frame buffer hardware drivers ++# ++CONFIG_FB_IMX=y ++# CONFIG_FB_S1D13XXX is not set ++# CONFIG_FB_VIRTUAL is not set ++# CONFIG_FB_METRONOME is not set ++# CONFIG_FB_MB862XX is not set ++# CONFIG_FB_BROADSHEET is not set ++# CONFIG_BACKLIGHT_LCD_SUPPORT is not set ++ ++# ++# Display device support ++# ++# CONFIG_DISPLAY_SUPPORT is not set ++ ++# ++# Console display driver support ++# ++# CONFIG_VGA_CONSOLE is not set ++CONFIG_DUMMY_CONSOLE=y ++CONFIG_FRAMEBUFFER_CONSOLE=y ++CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y ++CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y ++# CONFIG_FONTS is not set ++CONFIG_FONT_8x8=y ++CONFIG_FONT_8x16=y ++CONFIG_LOGO=y ++CONFIG_LOGO_LINUX_MONO=y ++CONFIG_LOGO_LINUX_VGA16=y ++CONFIG_LOGO_LINUX_CLUT224=y ++# CONFIG_SOUND is not set ++# CONFIG_HID_SUPPORT is not set ++# CONFIG_USB_SUPPORT is not set ++# CONFIG_MMC is not set ++# CONFIG_MEMSTICK is not set ++# CONFIG_ACCESSIBILITY is not set ++CONFIG_NEW_LEDS=y ++CONFIG_LEDS_CLASS=y ++ ++# ++# LED drivers ++# ++CONFIG_LEDS_GPIO=y ++CONFIG_LEDS_GPIO_PLATFORM=y ++ ++# ++# LED Triggers ++# ++CONFIG_LEDS_TRIGGERS=y ++# CONFIG_LEDS_TRIGGER_TIMER is not set ++CONFIG_LEDS_TRIGGER_HEARTBEAT=y ++# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set ++# CONFIG_LEDS_TRIGGER_GPIO is not set ++# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set ++ ++# ++# iptables trigger is under Netfilter config (LED target) ++# ++CONFIG_RTC_LIB=y ++# CONFIG_RTC_CLASS is not set ++# CONFIG_DMADEVICES is not set ++# CONFIG_AUXDISPLAY is not set ++# CONFIG_REGULATOR is not set ++# CONFIG_UIO is not set ++# CONFIG_STAGING is not set ++ ++# ++# File systems ++# ++CONFIG_EXT2_FS=y ++# CONFIG_EXT2_FS_XATTR is not set ++# CONFIG_EXT2_FS_XIP is not set ++CONFIG_EXT3_FS=m ++# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set ++CONFIG_EXT3_FS_XATTR=y ++CONFIG_EXT3_FS_POSIX_ACL=y ++# CONFIG_EXT3_FS_SECURITY is not set ++# CONFIG_EXT4_FS is not set ++CONFIG_JBD=m ++CONFIG_FS_MBCACHE=m ++# CONFIG_REISERFS_FS is not set ++# CONFIG_JFS_FS is not set ++CONFIG_FS_POSIX_ACL=y ++CONFIG_FILE_LOCKING=y ++# CONFIG_XFS_FS is not set ++# CONFIG_GFS2_FS is not set ++# CONFIG_OCFS2_FS is not set ++# CONFIG_BTRFS_FS is not set ++CONFIG_DNOTIFY=y ++CONFIG_INOTIFY=y ++CONFIG_INOTIFY_USER=y ++# CONFIG_QUOTA is not set ++# CONFIG_AUTOFS_FS is not set ++# CONFIG_AUTOFS4_FS is not set ++# CONFIG_FUSE_FS is not set ++ ++# ++# Caches ++# ++# CONFIG_FSCACHE is not set ++ ++# ++# CD-ROM/DVD Filesystems ++# ++CONFIG_ISO9660_FS=y ++CONFIG_JOLIET=y ++CONFIG_ZISOFS=y ++# CONFIG_UDF_FS is not set ++ ++# ++# DOS/FAT/NT Filesystems ++# ++CONFIG_FAT_FS=m ++CONFIG_MSDOS_FS=m ++CONFIG_VFAT_FS=m ++CONFIG_FAT_DEFAULT_CODEPAGE=437 ++CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" ++CONFIG_NTFS_FS=m ++# CONFIG_NTFS_DEBUG is not set ++CONFIG_NTFS_RW=y ++ ++# ++# Pseudo filesystems ++# ++CONFIG_PROC_FS=y ++CONFIG_PROC_SYSCTL=y ++CONFIG_PROC_PAGE_MONITOR=y ++CONFIG_SYSFS=y ++CONFIG_TMPFS=y ++# CONFIG_TMPFS_POSIX_ACL is not set ++# CONFIG_HUGETLB_PAGE is not set ++CONFIG_CONFIGFS_FS=y ++CONFIG_MISC_FILESYSTEMS=y ++# CONFIG_ADFS_FS is not set ++# CONFIG_AFFS_FS is not set ++# CONFIG_HFS_FS is not set ++# CONFIG_HFSPLUS_FS is not set ++# CONFIG_BEFS_FS is not set ++# CONFIG_BFS_FS is not set ++# CONFIG_EFS_FS is not set ++CONFIG_JFFS2_FS=y ++CONFIG_JFFS2_FS_DEBUG=0 ++CONFIG_JFFS2_FS_WRITEBUFFER=y ++# CONFIG_JFFS2_FS_WBUF_VERIFY is not set ++CONFIG_JFFS2_SUMMARY=y ++# CONFIG_JFFS2_FS_XATTR is not set ++# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set ++CONFIG_JFFS2_ZLIB=y ++# CONFIG_JFFS2_LZO is not set ++CONFIG_JFFS2_RTIME=y ++# CONFIG_JFFS2_RUBIN is not set ++CONFIG_CRAMFS=y ++# CONFIG_SQUASHFS is not set ++# CONFIG_VXFS_FS is not set ++# CONFIG_MINIX_FS is not set ++# CONFIG_OMFS_FS is not set ++# CONFIG_HPFS_FS is not set ++# CONFIG_QNX4FS_FS is not set ++# CONFIG_ROMFS_FS is not set ++# CONFIG_SYSV_FS is not set ++# CONFIG_UFS_FS is not set ++# CONFIG_NILFS2_FS is not set ++CONFIG_NETWORK_FILESYSTEMS=y ++CONFIG_NFS_FS=y ++CONFIG_NFS_V3=y ++# CONFIG_NFS_V3_ACL is not set ++CONFIG_NFS_V4=y ++CONFIG_ROOT_NFS=y ++# CONFIG_NFSD is not set ++CONFIG_LOCKD=y ++CONFIG_LOCKD_V4=y ++CONFIG_NFS_COMMON=y ++CONFIG_SUNRPC=y ++CONFIG_SUNRPC_GSS=y ++CONFIG_RPCSEC_GSS_KRB5=y ++# CONFIG_RPCSEC_GSS_SPKM3 is not set ++# CONFIG_SMB_FS is not set ++# CONFIG_CIFS is not set ++# CONFIG_NCP_FS is not set ++# CONFIG_CODA_FS is not set ++# CONFIG_AFS_FS is not set ++ ++# ++# Partition Types ++# ++CONFIG_PARTITION_ADVANCED=y ++# CONFIG_ACORN_PARTITION is not set ++# CONFIG_OSF_PARTITION is not set ++# CONFIG_AMIGA_PARTITION is not set ++# CONFIG_ATARI_PARTITION is not set ++# CONFIG_MAC_PARTITION is not set ++CONFIG_MSDOS_PARTITION=y ++# CONFIG_BSD_DISKLABEL is not set ++# CONFIG_MINIX_SUBPARTITION is not set ++# CONFIG_SOLARIS_X86_PARTITION is not set ++# CONFIG_UNIXWARE_DISKLABEL is not set ++# CONFIG_LDM_PARTITION is not set ++# CONFIG_SGI_PARTITION is not set ++# CONFIG_ULTRIX_PARTITION is not set ++# CONFIG_SUN_PARTITION is not set ++# CONFIG_KARMA_PARTITION is not set ++# CONFIG_EFI_PARTITION is not set ++# CONFIG_SYSV68_PARTITION is not set ++CONFIG_NLS=y ++CONFIG_NLS_DEFAULT="cp437" ++CONFIG_NLS_CODEPAGE_437=y ++# CONFIG_NLS_CODEPAGE_737 is not set ++# CONFIG_NLS_CODEPAGE_775 is not set ++CONFIG_NLS_CODEPAGE_850=y ++# CONFIG_NLS_CODEPAGE_852 is not set ++# CONFIG_NLS_CODEPAGE_855 is not set ++# CONFIG_NLS_CODEPAGE_857 is not set ++# CONFIG_NLS_CODEPAGE_860 is not set ++# CONFIG_NLS_CODEPAGE_861 is not set ++# CONFIG_NLS_CODEPAGE_862 is not set ++# CONFIG_NLS_CODEPAGE_863 is not set ++# CONFIG_NLS_CODEPAGE_864 is not set ++# CONFIG_NLS_CODEPAGE_865 is not set ++# CONFIG_NLS_CODEPAGE_866 is not set ++# CONFIG_NLS_CODEPAGE_869 is not set ++# CONFIG_NLS_CODEPAGE_936 is not set ++# CONFIG_NLS_CODEPAGE_950 is not set ++# CONFIG_NLS_CODEPAGE_932 is not set ++# CONFIG_NLS_CODEPAGE_949 is not set ++# CONFIG_NLS_CODEPAGE_874 is not set ++# CONFIG_NLS_ISO8859_8 is not set ++CONFIG_NLS_CODEPAGE_1250=m ++# CONFIG_NLS_CODEPAGE_1251 is not set ++CONFIG_NLS_ASCII=m ++CONFIG_NLS_ISO8859_1=m ++# CONFIG_NLS_ISO8859_2 is not set ++# CONFIG_NLS_ISO8859_3 is not set ++# CONFIG_NLS_ISO8859_4 is not set ++# CONFIG_NLS_ISO8859_5 is not set ++# CONFIG_NLS_ISO8859_6 is not set ++# CONFIG_NLS_ISO8859_7 is not set ++# CONFIG_NLS_ISO8859_9 is not set ++# CONFIG_NLS_ISO8859_13 is not set ++# CONFIG_NLS_ISO8859_14 is not set ++CONFIG_NLS_ISO8859_15=y ++# CONFIG_NLS_KOI8_R is not set ++# CONFIG_NLS_KOI8_U is not set ++CONFIG_NLS_UTF8=y ++# CONFIG_DLM is not set ++ ++# ++# Kernel hacking ++# ++# CONFIG_PRINTK_TIME is not set ++CONFIG_ENABLE_WARN_DEPRECATED=y ++CONFIG_ENABLE_MUST_CHECK=y ++CONFIG_FRAME_WARN=1024 ++CONFIG_MAGIC_SYSRQ=y ++# CONFIG_UNUSED_SYMBOLS is not set ++# CONFIG_DEBUG_FS is not set ++# CONFIG_HEADERS_CHECK is not set ++CONFIG_DEBUG_KERNEL=y ++# CONFIG_DEBUG_SHIRQ is not set ++CONFIG_DETECT_SOFTLOCKUP=y ++CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC=y ++CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=1 ++CONFIG_DETECT_HUNG_TASK=y ++CONFIG_BOOTPARAM_HUNG_TASK_PANIC=y ++CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=1 ++# CONFIG_SCHED_DEBUG is not set ++# CONFIG_SCHEDSTATS is not set ++# CONFIG_TIMER_STATS is not set ++# CONFIG_DEBUG_OBJECTS is not set ++CONFIG_DEBUG_SLAB=y ++CONFIG_DEBUG_SLAB_LEAK=y ++# CONFIG_DEBUG_PREEMPT is not set ++# CONFIG_DEBUG_RT_MUTEXES is not set ++# CONFIG_RT_MUTEX_TESTER is not set ++# CONFIG_DEBUG_SPINLOCK is not set ++# CONFIG_DEBUG_MUTEXES is not set ++# CONFIG_DEBUG_LOCK_ALLOC is not set ++# CONFIG_PROVE_LOCKING is not set ++# CONFIG_LOCK_STAT is not set ++# CONFIG_DEBUG_SPINLOCK_SLEEP is not set ++# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set ++# CONFIG_DEBUG_KOBJECT is not set ++CONFIG_DEBUG_BUGVERBOSE=y ++# CONFIG_DEBUG_INFO is not set ++# CONFIG_DEBUG_VM is not set ++# CONFIG_DEBUG_WRITECOUNT is not set ++# CONFIG_DEBUG_MEMORY_INIT is not set ++# CONFIG_DEBUG_LIST is not set ++# CONFIG_DEBUG_SG is not set ++# CONFIG_DEBUG_NOTIFIERS is not set ++# CONFIG_BOOT_PRINTK_DELAY is not set ++# CONFIG_RCU_TORTURE_TEST is not set ++# CONFIG_RCU_CPU_STALL_DETECTOR is not set ++# CONFIG_BACKTRACE_SELF_TEST is not set ++# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set ++# CONFIG_FAULT_INJECTION is not set ++# CONFIG_LATENCYTOP is not set ++# CONFIG_SYSCTL_SYSCALL_CHECK is not set ++# CONFIG_PAGE_POISONING is not set ++CONFIG_HAVE_FUNCTION_TRACER=y ++CONFIG_TRACING_SUPPORT=y ++ ++# ++# Tracers ++# ++# CONFIG_FUNCTION_TRACER is not set ++# CONFIG_IRQSOFF_TRACER is not set ++# CONFIG_PREEMPT_TRACER is not set ++# CONFIG_SCHED_TRACER is not set ++# CONFIG_CONTEXT_SWITCH_TRACER is not set ++# CONFIG_EVENT_TRACER is not set ++# CONFIG_BOOT_TRACER is not set ++# CONFIG_TRACE_BRANCH_PROFILING is not set ++# CONFIG_STACK_TRACER is not set ++# CONFIG_KMEMTRACE is not set ++# CONFIG_WORKQUEUE_TRACER is not set ++# CONFIG_BLK_DEV_IO_TRACE is not set ++# CONFIG_SAMPLES is not set ++CONFIG_HAVE_ARCH_KGDB=y ++# CONFIG_KGDB is not set ++CONFIG_ARM_UNWIND=y ++CONFIG_DEBUG_USER=y ++CONFIG_DEBUG_ERRORS=y ++# CONFIG_DEBUG_STACK_USAGE is not set ++# CONFIG_DEBUG_LL is not set ++ ++# ++# Security options ++# ++# CONFIG_KEYS is not set ++# CONFIG_SECURITY is not set ++# CONFIG_SECURITYFS is not set ++# CONFIG_SECURITY_FILE_CAPABILITIES is not set ++CONFIG_CRYPTO=y ++ ++# ++# Crypto core or helper ++# ++# CONFIG_CRYPTO_FIPS is not set ++CONFIG_CRYPTO_ALGAPI=y ++CONFIG_CRYPTO_ALGAPI2=y ++CONFIG_CRYPTO_AEAD2=y ++CONFIG_CRYPTO_BLKCIPHER=y ++CONFIG_CRYPTO_BLKCIPHER2=y ++CONFIG_CRYPTO_HASH=y ++CONFIG_CRYPTO_HASH2=y ++CONFIG_CRYPTO_RNG2=y ++CONFIG_CRYPTO_PCOMP=y ++CONFIG_CRYPTO_MANAGER=y ++CONFIG_CRYPTO_MANAGER2=y ++# CONFIG_CRYPTO_GF128MUL is not set ++# CONFIG_CRYPTO_NULL is not set ++CONFIG_CRYPTO_WORKQUEUE=y ++# CONFIG_CRYPTO_CRYPTD is not set ++# CONFIG_CRYPTO_AUTHENC is not set ++# CONFIG_CRYPTO_TEST is not set ++ ++# ++# Authenticated Encryption with Associated Data ++# ++# CONFIG_CRYPTO_CCM is not set ++# CONFIG_CRYPTO_GCM is not set ++# CONFIG_CRYPTO_SEQIV is not set ++ ++# ++# Block modes ++# ++CONFIG_CRYPTO_CBC=y ++# CONFIG_CRYPTO_CTR is not set ++# CONFIG_CRYPTO_CTS is not set ++CONFIG_CRYPTO_ECB=y ++# CONFIG_CRYPTO_LRW is not set ++# CONFIG_CRYPTO_PCBC is not set ++# CONFIG_CRYPTO_XTS is not set ++ ++# ++# Hash modes ++# ++CONFIG_CRYPTO_HMAC=y ++# CONFIG_CRYPTO_XCBC is not set ++ ++# ++# Digest ++# ++# CONFIG_CRYPTO_CRC32C is not set ++# CONFIG_CRYPTO_MD4 is not set ++CONFIG_CRYPTO_MD5=y ++# CONFIG_CRYPTO_MICHAEL_MIC is not set ++# CONFIG_CRYPTO_RMD128 is not set ++# CONFIG_CRYPTO_RMD160 is not set ++# CONFIG_CRYPTO_RMD256 is not set ++# CONFIG_CRYPTO_RMD320 is not set ++# CONFIG_CRYPTO_SHA1 is not set ++# CONFIG_CRYPTO_SHA256 is not set ++# CONFIG_CRYPTO_SHA512 is not set ++# CONFIG_CRYPTO_TGR192 is not set ++# CONFIG_CRYPTO_WP512 is not set ++ ++# ++# Ciphers ++# ++CONFIG_CRYPTO_AES=y ++# CONFIG_CRYPTO_ANUBIS is not set ++CONFIG_CRYPTO_ARC4=y ++# CONFIG_CRYPTO_BLOWFISH is not set ++# CONFIG_CRYPTO_CAMELLIA is not set ++# CONFIG_CRYPTO_CAST5 is not set ++# CONFIG_CRYPTO_CAST6 is not set ++CONFIG_CRYPTO_DES=y ++# CONFIG_CRYPTO_FCRYPT is not set ++# CONFIG_CRYPTO_KHAZAD is not set ++# CONFIG_CRYPTO_SALSA20 is not set ++# CONFIG_CRYPTO_SEED is not set ++# CONFIG_CRYPTO_SERPENT is not set ++# CONFIG_CRYPTO_TEA is not set ++# CONFIG_CRYPTO_TWOFISH is not set ++ ++# ++# Compression ++# ++# CONFIG_CRYPTO_DEFLATE is not set ++# CONFIG_CRYPTO_ZLIB is not set ++# CONFIG_CRYPTO_LZO is not set ++ ++# ++# Random Number Generation ++# ++# CONFIG_CRYPTO_ANSI_CPRNG is not set ++CONFIG_CRYPTO_HW=y ++# CONFIG_BINARY_PRINTF is not set ++ ++# ++# Library routines ++# ++CONFIG_BITREVERSE=y ++CONFIG_GENERIC_FIND_LAST_BIT=y ++# CONFIG_CRC_CCITT is not set ++# CONFIG_CRC16 is not set ++# CONFIG_CRC_T10DIF is not set ++# CONFIG_CRC_ITU_T is not set ++CONFIG_CRC32=y ++# CONFIG_CRC7 is not set ++# CONFIG_LIBCRC32C is not set ++CONFIG_ZLIB_INFLATE=y ++CONFIG_ZLIB_DEFLATE=y ++CONFIG_DECOMPRESS_GZIP=y ++CONFIG_HAS_IOMEM=y ++CONFIG_HAS_IOPORT=y ++CONFIG_HAS_DMA=y ++CONFIG_NLATTR=y +diff -urNp linux-2.6.30-rc4/arch/arm/mach-mx2/Kconfig linux-2.6.30-rc4-karo/arch/arm/mach-mx2/Kconfig +--- linux-2.6.30-rc4/arch/arm/mach-mx2/Kconfig 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/mach-mx2/Kconfig 2009-06-02 17:05:27.000000000 +0200 +@@ -6,14 +6,26 @@ choice + + config MACH_MX21 + bool "i.MX21 support" ++ select ARCH_MXC_IOMUX_V2 ++ select ARCH_MXC_HAS_NFC_V1 + help + This enables support for Freescale's MX2 based i.MX21 processor. + + config MACH_MX27 + bool "i.MX27 support" ++ select ARCH_MXC_IOMUX_V2 ++ select ARCH_MXC_HAS_NFC_V1 + help + This enables support for Freescale's MX2 based i.MX27 processor. + ++config MACH_MX25 ++ bool "i.MX25 support" ++ select ARCH_MXC_IOMUX_V3 ++ select ARCH_MXC_HAS_NFC_V2_1 ++ select PHYLIB if FEC ++ help ++ This enables support for Freescale's MX2 based i.MX25 processor. ++ + endchoice + + comment "MX2 platforms:" +@@ -39,6 +51,26 @@ config MACH_PCM038 + Include support for phyCORE-i.MX27 (aka pcm038) platform. This + includes specific configurations for the module and its peripherals. + ++config MACH_TX25 ++ bool "Support Ka-Ro electronics TX25 module" ++ depends on MACH_MX25 ++ help ++ Include support for Ka-Ro TX25 processor module ++ ++config KARO_DEBUG ++ bool "Enable Ka-Ro specific debug messages" ++ depends on MACH_TX25 || MACH_TX27 ++ help ++ Compile the architecture specific files with -DDEBUG to enable ++ additional debug messages ++ ++config MACH_STK5_BASEBOARD ++ bool "Ka-Ro Starterkit-5 (STK5) development board" ++ depends on MACH_TX27 || MACH_TX25 ++ help ++ This adds board specific devices that can be found on Ka-Ro's ++ STK5 evaluation board. ++ + choice + prompt "Baseboard" + depends on MACH_PCM038 +@@ -60,3 +92,4 @@ config MACH_MX27_3DS + Include support for MX27PDK platform. This includes specific + configurations for the board and its peripherals. + endif ++ +diff -urNp linux-2.6.30-rc4/arch/arm/mach-mx2/Makefile linux-2.6.30-rc4-karo/arch/arm/mach-mx2/Makefile +--- linux-2.6.30-rc4/arch/arm/mach-mx2/Makefile 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/mach-mx2/Makefile 2009-06-02 17:05:27.000000000 +0200 +@@ -2,17 +2,31 @@ + # Makefile for the linux kernel. + # + ++ifeq ($(CONFIG_KARO_DEBUG),y) ++ EXTRA_CFLAGS += -DDEBUG ++endif ++ + # Object file lists. + +-obj-y := generic.o devices.o serial.o ++obj-y := generic.o serial.o ++obj-$(CONFIG_MACH_MX25) += devices_mx25.o ++ifeq ($(CONFIG_MACH_MX25),) ++obj-y += devices.o ++endif ++ ++obj-$(CONFIG_MACH_MX21) += clock_imx21.o + +-obj-$(CONFIG_MACH_MX21) += clock_imx21.o ++obj-$(CONFIG_MACH_MX25) += clock_imx25.o ++obj-$(CONFIG_MACH_MX25) += cpu_imx25.o + +-obj-$(CONFIG_MACH_MX27) += cpu_imx27.o +-obj-$(CONFIG_MACH_MX27) += clock_imx27.o ++obj-$(CONFIG_MACH_MX27) += cpu_imx27.o ++obj-$(CONFIG_MACH_MX27) += clock_imx27.o + +-obj-$(CONFIG_MACH_MX21ADS) += mx21ads.o +-obj-$(CONFIG_MACH_MX27ADS) += mx27ads.o +-obj-$(CONFIG_MACH_PCM038) += pcm038.o +-obj-$(CONFIG_MACH_PCM970_BASEBOARD) += pcm970-baseboard.o +-obj-$(CONFIG_MACH_MX27_3DS) += mx27pdk.o ++obj-$(CONFIG_MACH_MX21ADS) += mx21ads.o ++obj-$(CONFIG_MACH_MX27ADS) += mx27ads.o ++obj-$(CONFIG_MACH_PCM038) += pcm038.o ++obj-$(CONFIG_MACH_PCM970_BASEBOARD) += pcm970-baseboard.o ++obj-$(CONFIG_MACH_MX27_3DS) += mx27pdk.o ++obj-$(CONFIG_MACH_TX27) += karo-tx27.o tx27_gpio.o ++obj-$(CONFIG_MACH_TX25) += karo-tx25.o ++obj-$(CONFIG_MACH_STK5_BASEBOARD) += stk5-baseboard.o +diff -urNp linux-2.6.30-rc4/arch/arm/mach-mx2/Makefile.boot linux-2.6.30-rc4-karo/arch/arm/mach-mx2/Makefile.boot +--- linux-2.6.30-rc4/arch/arm/mach-mx2/Makefile.boot 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/mach-mx2/Makefile.boot 2009-06-02 17:05:27.000000000 +0200 +@@ -5,3 +5,7 @@ initrd_phys-$(CONFIG_MACH_MX21) := 0xC08 + zreladdr-$(CONFIG_MACH_MX27) := 0xA0008000 + params_phys-$(CONFIG_MACH_MX27) := 0xA0000100 + initrd_phys-$(CONFIG_MACH_MX27) := 0xA0800000 ++ ++zreladdr-$(CONFIG_MACH_MX25) := 0x80008000 ++params_phys-$(CONFIG_MACH_MX25) := 0x80000100 ++initrd_phys-$(CONFIG_MACH_MX25) := 0x80800000 +diff -urNp linux-2.6.30-rc4/arch/arm/mach-mx2/clock_imx21.c linux-2.6.30-rc4-karo/arch/arm/mach-mx2/clock_imx21.c +--- linux-2.6.30-rc4/arch/arm/mach-mx2/clock_imx21.c 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/mach-mx2/clock_imx21.c 2009-06-02 17:05:26.000000000 +0200 +@@ -890,7 +890,7 @@ static struct clk clko_clk = { + .con_id = n, \ + .clk = &c, \ + }, +-static struct clk_lookup lookups[] __initdata = { ++static struct clk_lookup lookups[] = { + /* It's unlikely that any driver wants one of them directly: + _REGISTER_CLOCK(NULL, "ckih", ckih_clk) + _REGISTER_CLOCK(NULL, "ckil", ckil_clk) +diff -urNp linux-2.6.30-rc4/arch/arm/mach-mx2/clock_imx25.c linux-2.6.30-rc4-karo/arch/arm/mach-mx2/clock_imx25.c +--- linux-2.6.30-rc4/arch/arm/mach-mx2/clock_imx25.c 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/arch/arm/mach-mx2/clock_imx25.c 2009-06-02 17:05:26.000000000 +0200 +@@ -0,0 +1,1967 @@ ++/* ++ * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved. ++ */ ++ ++/* ++ * The code contained herein is licensed under the GNU General Public ++ * License. You may obtain a copy of the GNU General Public License ++ * Version 2 or later at the following locations: ++ * ++ * http://www.opensource.org/licenses/gpl-license.html ++ * http://www.gnu.org/copyleft/gpl.html ++ */ ++ ++/* based on mach-mx27/clock.c */ ++ ++#include ++#include ++#include ++//#include ++ ++#include ++//#include ++ ++#include ++#include ++#include ++ ++/* Register offsets */ ++#define MXC_CCM_MPCTL (IO_ADDRESS(CCM_BASE_ADDR) + 0x00) ++#define MXC_CCM_UPCTL (IO_ADDRESS(CCM_BASE_ADDR) + 0x04) ++#define MXC_CCM_CCTL (IO_ADDRESS(CCM_BASE_ADDR) + 0x08) ++#define MXC_CCM_CGCR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x0C) ++#define MXC_CCM_CGCR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x10) ++#define MXC_CCM_CGCR2 (IO_ADDRESS(CCM_BASE_ADDR) + 0x14) ++#define MXC_CCM_PCDR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x18) ++#define MXC_CCM_PCDR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x1C) ++#define MXC_CCM_PCDR2 (IO_ADDRESS(CCM_BASE_ADDR) + 0x20) ++#define MXC_CCM_PCDR3 (IO_ADDRESS(CCM_BASE_ADDR) + 0x24) ++#define MXC_CCM_RCSR (IO_ADDRESS(CCM_BASE_ADDR) + 0x28) ++#define MXC_CCM_CRDR (IO_ADDRESS(CCM_BASE_ADDR) + 0x2C) ++#define MXC_CCM_DCVR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x30) ++#define MXC_CCM_DCVR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x34) ++#define MXC_CCM_DCVR2 (IO_ADDRESS(CCM_BASE_ADDR) + 0x38) ++#define MXC_CCM_DCVR3 (IO_ADDRESS(CCM_BASE_ADDR) + 0x3C) ++#define MXC_CCM_LTR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x40) ++#define MXC_CCM_LTR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x44) ++#define MXC_CCM_LTR2 (IO_ADDRESS(CCM_BASE_ADDR) + 0x48) ++#define MXC_CCM_LTR3 (IO_ADDRESS(CCM_BASE_ADDR) + 0x4C) ++#define MXC_CCM_LTBR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x50) ++#define MXC_CCM_LTBR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x54) ++#define MXC_CCM_PMCR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x58) ++#define MXC_CCM_PMCR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x5C) ++#define MXC_CCM_PMCR2 (IO_ADDRESS(CCM_BASE_ADDR) + 0x60) ++#define MXC_CCM_MCR (IO_ADDRESS(CCM_BASE_ADDR) + 0x64) ++ ++#define MXC_CCM_MPCTL_BRMO (1 << 31) ++#define MXC_CCM_MPCTL_PD_OFFSET 26 ++#define MXC_CCM_MPCTL_PD_MASK (0xf << 26) ++#define MXC_CCM_MPCTL_MFD_OFFSET 16 ++#define MXC_CCM_MPCTL_MFD_MASK (0x3ff << 16) ++#define MXC_CCM_MPCTL_MFI_OFFSET 10 ++#define MXC_CCM_MPCTL_MFI_MASK (0xf << 10) ++#define MXC_CCM_MPCTL_MFN_OFFSET 0 ++#define MXC_CCM_MPCTL_MFN_MASK 0x3ff ++#define MXC_CCM_MPCTL_LF (1 << 15) ++ ++#define MXC_CCM_UPCTL_BRMO (1 << 31) ++#define MXC_CCM_UPCTL_PD_OFFSET 26 ++#define MXC_CCM_UPCTL_PD_MASK (0xf << 26) ++#define MXC_CCM_UPCTL_MFD_OFFSET 16 ++#define MXC_CCM_UPCTL_MFD_MASK (0x3ff << 16) ++#define MXC_CCM_UPCTL_MFI_OFFSET 10 ++#define MXC_CCM_UPCTL_MFI_MASK (0xf << 10) ++#define MXC_CCM_UPCTL_MFN_OFFSET 0 ++#define MXC_CCM_UPCTL_MFN_MASK 0x3ff ++#define MXC_CCM_UPCTL_LF (1 << 15) ++ ++#define MXC_CCM_CCTL_ARM_OFFSET 30 ++#define MXC_CCM_CCTL_ARM_MASK (0x3 << 30) ++#define MXC_CCM_CCTL_AHB_OFFSET 28 ++#define MXC_CCM_CCTL_AHB_MASK (0x3 << 28) ++#define MXC_CCM_CCTL_MPLL_RST (1 << 27) ++#define MXC_CCM_CCTL_UPLL_RST (1 << 26) ++#define MXC_CCM_CCTL_LP_CTL_OFFSET 24 ++#define MXC_CCM_CCTL_LP_CTL_MASK (0x3 << 24) ++#define MXC_CCM_CCTL_LP_MODE_RUN (0x0 << 24) ++#define MXC_CCM_CCTL_LP_MODE_WAIT (0x1 << 24) ++#define MXC_CCM_CCTL_LP_MODE_DOZE (0x2 << 24) ++#define MXC_CCM_CCTL_LP_MODE_STOP (0x3 << 24) ++#define MXC_CCM_CCTL_UPLL_DISABLE (1 << 23) ++#define MXC_CCM_CCTL_MPLL_BYPASS (1 << 22) ++#define MXC_CCM_CCTL_USB_DIV_OFFSET 16 ++#define MXC_CCM_CCTL_USB_DIV_MASK (0x3 << 16) ++#define MXC_CCM_CCTL_CG_CTRL (1 << 15) ++#define MXC_CCM_CCTL_ARM_SRC (1 << 14) ++ ++#define MXC_CCM_CGCR0_HCLK_ATA_OFFSET (16 + 0) ++#define MXC_CCM_CGCR0_HCLK_BROM_OFFSET (16 + 1) ++#define MXC_CCM_CGCR0_HCLK_CSI_OFFSET (16 + 2) ++#define MXC_CCM_CGCR0_HCLK_EMI_OFFSET (16 + 3) ++#define MXC_CCM_CGCR0_HCLK_ESAI_OFFSET (16 + 4) ++#define MXC_CCM_CGCR0_HCLK_ESDHC1_OFFSET (16 + 5) ++#define MXC_CCM_CGCR0_HCLK_ESDHC2_OFFSET (16 + 6) ++#define MXC_CCM_CGCR0_HCLK_FEC_OFFSET (16 + 7) ++#define MXC_CCM_CGCR0_HCLK_LCDC_OFFSET (16 + 8) ++#define MXC_CCM_CGCR0_HCLK_RTIC_OFFSET (16 + 9) ++#define MXC_CCM_CGCR0_HCLK_SDMA_OFFSET (16 + 10) ++#define MXC_CCM_CGCR0_HCLK_SLCDC_OFFSET (16 + 11) ++#define MXC_CCM_CGCR0_HCLK_USBOTG_OFFSET (16 + 12) ++ ++#define MXC_CCM_CGCR0_PER_CSI_OFFSET 0 ++#define MXC_CCM_CGCR0_PER_EPIT_OFFSET 1 ++#define MXC_CCM_CGCR0_PER_ESAI_OFFSET 2 ++#define MXC_CCM_CGCR0_PER_ESDHC1_OFFSET 3 ++#define MXC_CCM_CGCR0_PER_ESDHC2_OFFSET 4 ++#define MXC_CCM_CGCR0_PER_GPT_OFFSET 5 ++#define MXC_CCM_CGCR0_PER_I2C_OFFSET 6 ++#define MXC_CCM_CGCR0_PER_LCDC_OFFSET 7 ++#define MXC_CCM_CGCR0_PER_NFC_OFFSET 8 ++#define MXC_CCM_CGCR0_PER_OWIRE_OFFSET 9 ++#define MXC_CCM_CGCR0_PER_PWM_OFFSET 10 ++#define MXC_CCM_CGCR0_PER_SIM1_OFFSET 11 ++#define MXC_CCM_CGCR0_PER_SIM2_OFFSET 12 ++#define MXC_CCM_CGCR0_PER_SSI1_OFFSET 13 ++#define MXC_CCM_CGCR0_PER_SSI2_OFFSET 14 ++#define MXC_CCM_CGCR0_PER_UART_OFFSET 15 ++ ++#define MXC_CCM_CGCR1_AUDMUX_OFFSET 0 ++#define MXC_CCM_CGCR1_ATA_OFFSET 1 ++#define MXC_CCM_CGCR1_CAN1_OFFSET 2 ++#define MXC_CCM_CGCR1_CAN2_OFFSET 3 ++#define MXC_CCM_CGCR1_CSI_OFFSET 4 ++#define MXC_CCM_CGCR1_CSPI1_OFFSET 5 ++#define MXC_CCM_CGCR1_CSPI2_OFFSET 6 ++#define MXC_CCM_CGCR1_CSPI3_OFFSET 7 ++#define MXC_CCM_CGCR1_DRYICE_OFFSET 8 ++#define MXC_CCM_CGCR1_ECT_OFFSET 9 ++#define MXC_CCM_CGCR1_EPIT1_OFFSET 10 ++#define MXC_CCM_CGCR1_EPIT2_OFFSET 11 ++#define MXC_CCM_CGCR1_ESAI_OFFSET 12 ++#define MXC_CCM_CGCR1_ESDHC1_OFFSET 13 ++#define MXC_CCM_CGCR1_ESDHC2_OFFSET 14 ++#define MXC_CCM_CGCR1_FEC_OFFSET 15 ++#define MXC_CCM_CGCR1_GPIO1_OFFSET 16 ++#define MXC_CCM_CGCR1_GPIO2_OFFSET 17 ++#define MXC_CCM_CGCR1_GPIO3_OFFSET 18 ++#define MXC_CCM_CGCR1_GPT1_OFFSET 19 ++#define MXC_CCM_CGCR1_GPT2_OFFSET 20 ++#define MXC_CCM_CGCR1_GPT3_OFFSET 21 ++#define MXC_CCM_CGCR1_GPT4_OFFSET 22 ++#define MXC_CCM_CGCR1_I2C1_OFFSET 23 ++#define MXC_CCM_CGCR1_I2C2_OFFSET 24 ++#define MXC_CCM_CGCR1_I2C3_OFFSET 25 ++#define MXC_CCM_CGCR1_IIM_OFFSET 26 ++#define MXC_CCM_CGCR1_IOMUXC_OFFSET 27 ++#define MXC_CCM_CGCR1_KPP_OFFSET 28 ++#define MXC_CCM_CGCR1_LCDC_OFFSET 29 ++#define MXC_CCM_CGCR1_OWIRE_OFFSET 30 ++#define MXC_CCM_CGCR1_PWM1_OFFSET 31 ++ ++#define MXC_CCM_CGCR2_PWM2_OFFSET (32 - 32) ++#define MXC_CCM_CGCR2_PWM3_OFFSET (33 - 32) ++#define MXC_CCM_CGCR2_PWM4_OFFSET (34 - 32) ++#define MXC_CCM_CGCR2_RNGB_OFFSET (35 - 32) ++#define MXC_CCM_CGCR2_RTIC_OFFSET (36 - 32) ++#define MXC_CCM_CGCR2_SCC_OFFSET (37 - 32) ++#define MXC_CCM_CGCR2_SDMA_OFFSET (38 - 32) ++#define MXC_CCM_CGCR2_SIM1_OFFSET (39 - 32) ++#define MXC_CCM_CGCR2_SIM2_OFFSET (40 - 32) ++#define MXC_CCM_CGCR2_SLCDC_OFFSET (41 - 32) ++#define MXC_CCM_CGCR2_SPBA_OFFSET (42 - 32) ++#define MXC_CCM_CGCR2_SSI1_OFFSET (43 - 32) ++#define MXC_CCM_CGCR2_SSI2_OFFSET (44 - 32) ++#define MXC_CCM_CGCR2_TCHSCRN_OFFSET (45 - 32) ++#define MXC_CCM_CGCR2_UART1_OFFSET (46 - 32) ++#define MXC_CCM_CGCR2_UART2_OFFSET (47 - 32) ++#define MXC_CCM_CGCR2_UART3_OFFSET (48 - 32) ++#define MXC_CCM_CGCR2_UART4_OFFSET (49 - 32) ++#define MXC_CCM_CGCR2_UART5_OFFSET (50 - 32) ++#define MXC_CCM_CGCR2_WDOG_OFFSET (51 - 32) ++ ++#define MXC_CCM_PCDR1_PERDIV1_MASK 0x3f ++ ++#define MXC_CCM_MCR_USB_XTAL_MUX_OFFSET 31 ++#define MXC_CCM_MCR_CLKO_EN_OFFSET 30 ++#define MXC_CCM_MCR_CLKO_DIV_OFFSET 24 ++#define MXC_CCM_MCR_CLKO_DIV_MASK (0x3F << 24) ++#define MXC_CCM_MCR_CLKO_SEL_OFFSET 20 ++#define MXC_CCM_MCR_CLKO_SEL_MASK (0xF << 20) ++#define MXC_CCM_MCR_ESAI_CLK_MUX_OFFSET 19 ++#define MXC_CCM_MCR_SSI2_CLK_MUX_OFFSET 18 ++#define MXC_CCM_MCR_SSI1_CLK_MUX_OFFSET 17 ++#define MXC_CCM_MCR_USB_CLK_MUX_OFFSET 16 ++ ++#define MXC_CCM_MCR_PER_CLK_MUX_MASK (0xFFFF << 0) ++ ++#define OSC24M_CLK_FREQ 24000000 /* 24MHz reference clk */ ++#define OSC32K_CLK_FREQ 32768 /* 32.768kHz oscillator in */ ++ ++static struct clk mpll_clk; ++static struct clk upll_clk; ++static struct clk ahb_clk; ++static struct clk upll_24610k_clk; ++ ++static int _clk_enable(struct clk *clk) ++{ ++ unsigned long reg; ++ ++ if (!clk->enable_reg) ++ return 0; ++ ++ reg = __raw_readl(clk->enable_reg); ++ reg |= 1 << clk->enable_shift; ++ __raw_writel(reg, clk->enable_reg); ++ ++ return 0; ++} ++ ++static void _clk_disable(struct clk *clk) ++{ ++ unsigned long reg; ++ ++ if (!clk->enable_reg) ++ return; ++ ++ reg = __raw_readl(clk->enable_reg); ++ reg &= ~(1 << clk->enable_shift); ++ __raw_writel(reg, clk->enable_reg); ++} ++ ++static int _clk_upll_enable(struct clk *clk) ++{ ++ unsigned long reg; ++ ++ reg = __raw_readl(MXC_CCM_CCTL); ++ reg &= ~MXC_CCM_CCTL_UPLL_DISABLE; ++ __raw_writel(reg, MXC_CCM_CCTL); ++ ++ while (!(__raw_readl(MXC_CCM_UPCTL) & MXC_CCM_UPCTL_LF)) ++ cpu_relax(); ++ ++ return 0; ++} ++ ++static void _clk_upll_disable(struct clk *clk) ++{ ++ unsigned long reg; ++ ++ reg = __raw_readl(MXC_CCM_CCTL); ++ reg |= MXC_CCM_CCTL_UPLL_DISABLE; ++ __raw_writel(reg, MXC_CCM_CCTL); ++} ++ ++static int _perclk_enable(struct clk *clk) ++{ ++ unsigned long reg; ++ ++ reg = __raw_readl(MXC_CCM_CGCR0); ++ reg |= 1 << clk->id; ++ __raw_writel(reg, MXC_CCM_CGCR0); ++ ++ return 0; ++} ++ ++static void _perclk_disable(struct clk *clk) ++{ ++ unsigned long reg; ++ ++ reg = __raw_readl(MXC_CCM_CGCR0); ++ reg &= ~(1 << clk->id); ++ __raw_writel(reg, MXC_CCM_CGCR0); ++} ++ ++static int _clk_pll_set_rate(struct clk *clk, unsigned long rate) ++{ ++ unsigned long reg; ++ signed long pd = 1; /* Pre-divider */ ++ signed long mfi; /* Multiplication Factor (Integer part) */ ++ signed long mfn; /* Multiplication Factor (Integer part) */ ++ signed long mfd; /* Multiplication Factor (Denominator Part) */ ++ signed long tmp; ++ unsigned long ref_freq = clk_get_rate(clk->parent); ++ ++ while (((ref_freq / pd) * 10) > rate) ++ pd++; ++ ++ /* the ref_freq/2 in the following is to round up */ ++ mfi = (((rate / 2) * pd) + (ref_freq / 2)) / ref_freq; ++ if (mfi < 5 || mfi > 15) ++ return -EINVAL; ++ ++ /* pick a mfd value that will work ++ * then solve for mfn */ ++ mfd = ref_freq / 50000; ++ ++ /* ++ * pll_freq * pd * mfd ++ * mfn = -------------------- - (mfi * mfd) ++ * 2 * ref_freq ++ */ ++ /* the tmp/2 is for rounding */ ++ tmp = ref_freq / 10000; ++ mfn = ((((((rate / 2) + (tmp / 2)) / tmp) * pd) * mfd) / 10000) - ++ (mfi * mfd); ++ ++ printk(KERN_DEBUG "pll freq: %lu PD=%ld MFI=%ld MFD=%ld MFN=%ld (0x%03lx)\n", ++ rate, pd, mfi, mfd, mfn, (mfn + ((mfn < 0) ? 1024 : 0)) & 0x3ff); ++ ++ mfn = (mfn + ((mfn < 0) ? 1024 : 0)) & 0x3ff; ++ pd--; ++ mfd--; ++ ++ /* Change the Pll value */ ++ reg = (mfi << MXC_CCM_MPCTL_MFI_OFFSET) | ++ (mfn << MXC_CCM_MPCTL_MFN_OFFSET) | ++ (mfd << MXC_CCM_MPCTL_MFD_OFFSET) | ++ (pd << MXC_CCM_MPCTL_PD_OFFSET); ++ ++ if (clk == &mpll_clk) { ++ printk(KERN_DEBUG "Changing MPCTL from %08x to %08lx\n", ++ __raw_readl(MXC_CCM_MPCTL), reg); ++ } else if (clk == &upll_clk) { ++ printk(KERN_DEBUG "Changing UPCTL from %08x to %08lx\n", ++ __raw_readl(MXC_CCM_UPCTL), reg); ++ } ++ if (clk == &mpll_clk) ++ __raw_writel(reg, MXC_CCM_MPCTL); ++ else if (clk == &upll_clk) ++ __raw_writel(reg, MXC_CCM_UPCTL); ++ return 0; ++} ++ ++static unsigned long _clk_pll_getrate(struct clk *clk) ++{ ++ unsigned long rate; ++ signed long mfi, mfn, mfd, pdf; ++ unsigned long ref_clk; ++ unsigned long reg; ++ ++ ref_clk = clk_get_rate(clk->parent); ++ ++ if (clk == &mpll_clk) { ++ reg = __raw_readl(MXC_CCM_MPCTL); ++ pdf = (reg & MXC_CCM_MPCTL_PD_MASK) >> MXC_CCM_MPCTL_PD_OFFSET; ++ mfd = (reg & MXC_CCM_MPCTL_MFD_MASK) >> MXC_CCM_MPCTL_MFD_OFFSET; ++ mfi = (reg & MXC_CCM_MPCTL_MFI_MASK) >> MXC_CCM_MPCTL_MFI_OFFSET; ++ mfn = (reg & MXC_CCM_MPCTL_MFN_MASK) >> MXC_CCM_MPCTL_MFN_OFFSET; ++ } else if (clk == &upll_clk) { ++ reg = __raw_readl(MXC_CCM_UPCTL); ++ pdf = (reg & MXC_CCM_UPCTL_PD_MASK) >> MXC_CCM_UPCTL_PD_OFFSET; ++ mfd = (reg & MXC_CCM_UPCTL_MFD_MASK) >> MXC_CCM_UPCTL_MFD_OFFSET; ++ mfi = (reg & MXC_CCM_UPCTL_MFI_MASK) >> MXC_CCM_UPCTL_MFI_OFFSET; ++ mfn = (reg & MXC_CCM_UPCTL_MFN_MASK) >> MXC_CCM_UPCTL_MFN_OFFSET; ++ } else { ++ BUG(); /* oops */ ++ } ++ ++ mfi = (mfi < 5) ? 5 : mfi; ++ rate = 2LL * ref_clk * mfn; ++ do_div(rate, mfd + 1); ++ rate = 2LL * ref_clk * mfi + rate; ++ do_div(rate, pdf + 1); ++ ++ return rate; ++} ++ ++static unsigned long _clk_cpu_round_rate(struct clk *clk, unsigned long rate) ++{ ++ int div = clk_get_rate(clk->parent) / rate; ++ ++ if (clk_get_rate(clk->parent) % rate) ++ div++; ++ ++ if (div > 4) ++ div = 4; ++ ++ return clk_get_rate(clk->parent) / div; ++} ++ ++static int _clk_cpu_set_rate(struct clk *clk, unsigned long rate) ++{ ++ int div, reg; ++ unsigned long cctl = __raw_readl(MXC_CCM_CCTL); ++ ++ div = clk_get_rate(clk->parent) / rate; ++ ++ if (div > 4 || div < 1 || ((clk_get_rate(clk->parent) / div) != rate)) ++ return -EINVAL; ++ div--; ++ ++ reg = (cctl & ~MXC_CCM_CCTL_ARM_MASK) | ++ (div << MXC_CCM_CCTL_ARM_OFFSET); ++ __raw_writel(reg, MXC_CCM_CCTL); ++ ++ return 0; ++} ++ ++static unsigned long _clk_cpu_getrate(struct clk *clk) ++{ ++ unsigned long div; ++ unsigned long cctl = __raw_readl(MXC_CCM_CCTL); ++ unsigned long rate; ++ ++ div = (cctl & MXC_CCM_CCTL_ARM_MASK) >> MXC_CCM_CCTL_ARM_OFFSET; ++ ++ rate = clk_get_rate(clk->parent) / (div + 1); ++ ++ if (cctl & MXC_CCM_CCTL_ARM_SRC) { ++ rate *= 3; ++ rate /= 4; ++ } ++ return rate; ++} ++ ++static unsigned long _clk_ahb_getrate(struct clk *clk) ++{ ++ unsigned long div; ++ unsigned long cctl = __raw_readl(MXC_CCM_CCTL); ++ ++ div = (cctl & MXC_CCM_CCTL_AHB_MASK) >> MXC_CCM_CCTL_AHB_OFFSET; ++ ++ return clk_get_rate(clk->parent) / (div + 1); ++} ++ ++static void __iomem *pcdr_a[4] = { ++ MXC_CCM_PCDR0, MXC_CCM_PCDR1, MXC_CCM_PCDR2, MXC_CCM_PCDR3 ++}; ++ ++static unsigned long _clk_perclkx_getrate(struct clk *clk) ++{ ++ unsigned long perclk_pdf; ++ unsigned long pcdr; ++ ++ if (clk->id < 0 || clk->id > 15) ++ return 0; ++ ++ pcdr = __raw_readl(pcdr_a[clk->id >> 2]); ++ ++ perclk_pdf = ++ (pcdr >> ((clk->id & 3) << 3)) & MXC_CCM_PCDR1_PERDIV1_MASK; ++ ++ return clk_get_rate(clk->parent) / (perclk_pdf + 1); ++} ++ ++static unsigned long _clk_perclkx_round_rate(struct clk *clk, ++ unsigned long rate) ++{ ++ unsigned long div; ++ ++ div = clk_get_rate(clk->parent) / rate; ++ if (clk_get_rate(clk->parent) % rate) ++ div++; ++ ++ if (div > 64) ++ div = 64; ++ ++ return clk_get_rate(clk->parent) / div; ++} ++ ++static int _clk_perclkx_set_rate(struct clk *clk, unsigned long rate) ++{ ++ unsigned long reg; ++ unsigned long div; ++ ++ if (clk->id < 0 || clk->id > 15) ++ return -EINVAL; ++ ++ div = clk_get_rate(clk->parent) / rate; ++ printk(KERN_DEBUG "%s: perclk[%d] parent_rate=%lu rate=%lu div=%lu\n", ++ __FUNCTION__, clk->id, clk_get_rate(clk->parent), rate, div); ++ if (div > 64 || div < 1 || ((clk_get_rate(clk->parent) / div) != rate)) ++ return -EINVAL; ++ div--; ++ ++ reg = ++ __raw_readl(pcdr_a[clk->id >> 2]) & ~(MXC_CCM_PCDR1_PERDIV1_MASK << ++ ((clk->id & 3) << 3)); ++ reg |= div << ((clk->id & 3) << 3); ++ __raw_writel(reg, pcdr_a[clk->id >> 2]); ++ ++ return 0; ++} ++ ++static int _clk_perclkx_set_parent(struct clk *clk, struct clk *parent) ++{ ++ unsigned long mcr; ++ ++ if (clk->parent == parent) ++ return 0; ++ if (parent != &upll_clk && parent != &ahb_clk) ++ return -EINVAL; ++ ++ clk->parent = parent; ++ mcr = __raw_readl(MXC_CCM_MCR); ++ if (parent == &upll_clk) ++ mcr |= (1 << clk->id); ++ else ++ mcr &= ~(1 << clk->id); ++ ++ __raw_writel(mcr, MXC_CCM_MCR); ++ ++ return 0; ++} ++ ++static int _clk_perclkx_set_parent3(struct clk *clk, struct clk *parent) ++{ ++ unsigned long mcr = __raw_readl(MXC_CCM_MCR); ++ int bit; ++ ++ if (clk->parent == parent) ++ return 0; ++ if (parent != &upll_clk && parent != &ahb_clk && ++ parent != &upll_24610k_clk) ++ return -EINVAL; ++ ++ switch (clk->id) { ++ case 2: ++ bit = MXC_CCM_MCR_ESAI_CLK_MUX_OFFSET; ++ break; ++ case 13: ++ bit = MXC_CCM_MCR_SSI1_CLK_MUX_OFFSET; ++ break; ++ case 14: ++ bit = MXC_CCM_MCR_SSI2_CLK_MUX_OFFSET; ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ if (parent == &upll_24610k_clk) { ++ mcr |= bit; ++ __raw_writel(mcr, MXC_CCM_MCR); ++ clk->parent = parent; ++ } else { ++ mcr &= ~bit; ++ __raw_writel(mcr, MXC_CCM_MCR); ++ return _clk_perclkx_set_parent(clk, parent); ++ } ++ ++ return 0; ++} ++ ++static unsigned long _clk_ipg_getrate(struct clk *clk) ++{ ++ return clk_get_rate(clk->parent) / 2; /* Always AHB / 2 */ ++} ++ ++/* Top-level clocks */ ++static unsigned long ckih_rate = OSC24M_CLK_FREQ; ++ ++static unsigned long clk_ckih_get_rate(struct clk *clk) ++{ ++ return ckih_rate; ++} ++ ++static unsigned long clk_ckil_get_rate(struct clk *clk) ++{ ++ return OSC32K_CLK_FREQ; ++} ++ ++static struct clk osc24m_clk = { ++ .get_rate = clk_ckih_get_rate, ++}; ++ ++static struct clk osc32k_clk = { ++ .get_rate = clk_ckil_get_rate, ++}; ++ ++static struct clk mpll_clk = { ++ .parent = &osc24m_clk, ++ .get_rate = _clk_pll_getrate, ++ .set_rate = _clk_pll_set_rate, ++}; ++ ++static struct clk upll_clk = { ++ .parent = &osc24m_clk, ++ .get_rate = _clk_pll_getrate, ++ .set_rate = _clk_pll_set_rate, ++ .enable = _clk_upll_enable, ++ .disable = _clk_upll_disable, ++}; ++ ++static unsigned long _clk_24610k_getrate(struct clk *clk) ++{ ++ long long rate = clk_get_rate(clk->parent) * 2461LL; ++ ++ do_div(rate, 24000); ++ ++ return rate; /* Always (UPLL * 24.61 / 240) */ ++} ++ ++static struct clk upll_24610k_clk = { ++ .parent = &upll_clk, ++ .get_rate = _clk_24610k_getrate, ++}; ++ ++/* Mid-level clocks */ ++ ++static struct clk cpu_clk = { /* ARM clock */ ++ .parent = &mpll_clk, ++ .set_rate = _clk_cpu_set_rate, ++ .get_rate = _clk_cpu_getrate, ++ .round_rate = _clk_cpu_round_rate, ++}; ++ ++static struct clk ahb_clk = { /* a.k.a. HCLK */ ++ .parent = &cpu_clk, ++ .get_rate = _clk_ahb_getrate, ++}; ++ ++static struct clk ipg_clk = { ++ .parent = &ahb_clk, ++ .get_rate = _clk_ipg_getrate, ++}; ++ ++/* Bottom-level clocks */ ++ ++struct clk usbotg_clk = { ++ .id = 0, ++ .parent = &ahb_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR0, ++ .enable_shift = MXC_CCM_CGCR0_HCLK_USBOTG_OFFSET, ++ .disable = _clk_disable, ++}; ++ ++struct clk rtic_clk = { ++ .id = 0, ++ .parent = &ahb_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR0, ++ .enable_shift = MXC_CCM_CGCR0_HCLK_RTIC_OFFSET, ++ .disable = _clk_disable, ++}; ++ ++struct clk emi_clk = { ++ .id = 0, ++ .parent = &ahb_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR0, ++ .enable_shift = MXC_CCM_CGCR0_HCLK_EMI_OFFSET, ++ .disable = _clk_disable, ++}; ++ ++struct clk brom_clk = { ++ .id = 0, ++ .parent = &ahb_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR0, ++ .enable_shift = MXC_CCM_CGCR0_HCLK_BROM_OFFSET, ++ .disable = _clk_disable, ++}; ++ ++static struct clk per_clk[] = { ++ { ++ .id = 0, ++ .parent = &ahb_clk, /* can be AHB or UPLL */ ++ .round_rate = _clk_perclkx_round_rate, ++ .set_rate = _clk_perclkx_set_rate, ++ .set_parent = _clk_perclkx_set_parent, ++ .get_rate = _clk_perclkx_getrate, ++ .enable = _perclk_enable, ++ .disable = _perclk_disable, ++ }, ++ { ++ .id = 1, ++ .parent = &ahb_clk, /* can be AHB or UPLL */ ++ .round_rate = _clk_perclkx_round_rate, ++ .set_rate = _clk_perclkx_set_rate, ++ .set_parent = _clk_perclkx_set_parent, ++ .get_rate = _clk_perclkx_getrate, ++ .enable = _perclk_enable, ++ .disable = _perclk_disable, ++ }, ++ { ++ .id = 2, ++ .parent = &ahb_clk, /* can be AHB or UPLL or 24.61MHz */ ++ .round_rate = _clk_perclkx_round_rate, ++ .set_rate = _clk_perclkx_set_rate, ++ .set_parent = _clk_perclkx_set_parent3, ++ .get_rate = _clk_perclkx_getrate, ++ .enable = _perclk_enable, ++ .disable = _perclk_disable, ++ }, ++ { ++ .id = 3, ++ .parent = &ahb_clk, /* can be AHB or UPLL */ ++ .round_rate = _clk_perclkx_round_rate, ++ .set_rate = _clk_perclkx_set_rate, ++ .set_parent = _clk_perclkx_set_parent, ++ .get_rate = _clk_perclkx_getrate, ++ .enable = _perclk_enable, ++ }, ++ { ++ .id = 4, ++ .parent = &ahb_clk, /* can be AHB or UPLL */ ++ .round_rate = _clk_perclkx_round_rate, ++ .set_rate = _clk_perclkx_set_rate, ++ .set_parent = _clk_perclkx_set_parent, ++ .get_rate = _clk_perclkx_getrate, ++ .enable = _perclk_enable, ++ .disable = _perclk_disable, ++ }, ++ { ++ .id = 5, ++ .parent = &upll_clk, /* can be AHB or UPLL */ ++ .round_rate = _clk_perclkx_round_rate, ++ .set_rate = _clk_perclkx_set_rate, ++ .set_parent = _clk_perclkx_set_parent, ++ .get_rate = _clk_perclkx_getrate, ++ .enable = _perclk_enable, ++ .disable = _perclk_disable, ++ }, ++ { ++ .id = 6, ++ .parent = &ahb_clk, /* can be AHB or UPLL */ ++ .round_rate = _clk_perclkx_round_rate, ++ .set_rate = _clk_perclkx_set_rate, ++ .set_parent = _clk_perclkx_set_parent, ++ .get_rate = _clk_perclkx_getrate, ++ .enable = _perclk_enable, ++ .disable = _perclk_disable, ++ }, ++ { ++ .id = 7, ++ .parent = &ahb_clk, /* can be AHB or UPLL */ ++ .round_rate = _clk_perclkx_round_rate, ++ .set_rate = _clk_perclkx_set_rate, ++ .set_parent = _clk_perclkx_set_parent, ++ .get_rate = _clk_perclkx_getrate, ++ .enable = _perclk_enable, ++ .disable = _perclk_disable, ++ }, ++ { ++ .id = 8, ++ .parent = &ahb_clk, /* can be AHB or UPLL */ ++ .round_rate = _clk_perclkx_round_rate, ++ .set_rate = _clk_perclkx_set_rate, ++ .set_parent = _clk_perclkx_set_parent, ++ .get_rate = _clk_perclkx_getrate, ++ .enable = _perclk_enable, ++ .disable = _perclk_disable, ++ }, ++ { ++ .id = 9, ++ .parent = &ahb_clk, /* can be AHB or UPLL */ ++ .round_rate = _clk_perclkx_round_rate, ++ .set_rate = _clk_perclkx_set_rate, ++ .set_parent = _clk_perclkx_set_parent, ++ .get_rate = _clk_perclkx_getrate, ++ .enable = _perclk_enable, ++ .disable = _perclk_disable, ++ }, ++ { ++ .id = 10, ++ .parent = &ahb_clk, /* can be AHB or UPLL */ ++ .round_rate = _clk_perclkx_round_rate, ++ .set_rate = _clk_perclkx_set_rate, ++ .set_parent = _clk_perclkx_set_parent, ++ .get_rate = _clk_perclkx_getrate, ++ .enable = _perclk_enable, ++ .disable = _perclk_disable, ++ }, ++ { ++ .id = 11, ++ .parent = &ahb_clk, /* can be AHB or UPLL */ ++ .round_rate = _clk_perclkx_round_rate, ++ .set_rate = _clk_perclkx_set_rate, ++ .set_parent = _clk_perclkx_set_parent, ++ .get_rate = _clk_perclkx_getrate, ++ .enable = _perclk_enable, ++ .disable = _perclk_disable, ++ }, ++ { ++ .id = 12, ++ .parent = &ahb_clk, /* can be AHB or UPLL */ ++ .round_rate = _clk_perclkx_round_rate, ++ .set_rate = _clk_perclkx_set_rate, ++ .set_parent = _clk_perclkx_set_parent, ++ .get_rate = _clk_perclkx_getrate, ++ .enable = _perclk_enable, ++ .disable = _perclk_disable, ++ }, ++ { ++ .id = 13, ++ .parent = &ahb_clk, /* can be AHB or UPLL or 24.61MHz */ ++ .round_rate = _clk_perclkx_round_rate, ++ .set_rate = _clk_perclkx_set_rate, ++ .set_parent = _clk_perclkx_set_parent3, ++ .get_rate = _clk_perclkx_getrate, ++ .enable = _perclk_enable, ++ .disable = _perclk_disable, ++ }, ++ { ++ .id = 14, ++ .parent = &ahb_clk, /* can be AHB or UPLL or 24.61MHz */ ++ .round_rate = _clk_perclkx_round_rate, ++ .set_rate = _clk_perclkx_set_rate, ++ .set_parent = _clk_perclkx_set_parent3, ++ .get_rate = _clk_perclkx_getrate, ++ .enable = _perclk_enable, ++ .disable = _perclk_disable, ++ }, ++ { ++ .id = 15, ++ .parent = &ahb_clk, /* can be AHB or UPLL */ ++ .round_rate = _clk_perclkx_round_rate, ++ .set_rate = _clk_perclkx_set_rate, ++ .set_parent = _clk_perclkx_set_parent, ++ .get_rate = _clk_perclkx_getrate, ++ .enable = _perclk_enable, ++ .disable = _perclk_disable, ++ }, ++}; ++ ++struct clk nfc_clk = { ++ .id = 0, ++ .parent = &per_clk[8], ++}; ++ ++struct clk audmux_clk = { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_AUDMUX_OFFSET, ++ .disable = _clk_disable, ++}; ++ ++struct clk ata_clk[] = { ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_ATA_OFFSET, ++ .disable = _clk_disable, ++ .secondary = &ata_clk[1], ++ }, ++ { ++ .id = 0, ++ .parent = &ahb_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR0, ++ .enable_shift = MXC_CCM_CGCR0_HCLK_ATA_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk can_clk[] = { ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_CAN1_OFFSET, ++ .disable = _clk_disable, ++ }, ++ { ++ .id = 1, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_CAN2_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk csi_clk[] = { ++ { ++ .id = 0, ++ .parent = &per_clk[0], ++ .secondary = &csi_clk[1], ++ }, ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_CSI_OFFSET, ++ .disable = _clk_disable, ++ .secondary = &csi_clk[2], ++ }, ++ { ++ .id = 0, ++ .parent = &ahb_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR0, ++ .enable_shift = MXC_CCM_CGCR0_HCLK_CSI_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk cspi_clk[] = { ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_CSPI1_OFFSET, ++ .disable = _clk_disable, ++ }, ++ { ++ .id = 1, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_CSPI2_OFFSET, ++ .disable = _clk_disable, ++ }, ++ { ++ .id = 2, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_CSPI3_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk dryice_clk = { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_DRYICE_OFFSET, ++ .disable = _clk_disable, ++}; ++ ++struct clk ect_clk = { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_ECT_OFFSET, ++ .disable = _clk_disable, ++}; ++ ++struct clk epit1_clk[] = { ++ { ++ .id = 0, ++ .parent = &per_clk[1], ++ .secondary = &epit1_clk[1], ++ }, ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_EPIT1_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk epit2_clk[] = { ++ { ++ .id = 1, ++ .parent = &per_clk[1], ++ .secondary = &epit2_clk[1], ++ }, ++ { ++ .id = 1, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_EPIT2_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk esai_clk[] = { ++ { ++ .id = 0, ++ .parent = &per_clk[2], ++ .secondary = &esai_clk[1], ++ }, ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_ESAI_OFFSET, ++ .disable = _clk_disable, ++ .secondary = &esai_clk[2], ++ }, ++ { ++ .id = 0, ++ .parent = &ahb_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR0, ++ .enable_shift = MXC_CCM_CGCR0_HCLK_ESAI_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk esdhc1_clk[] = { ++ { ++ .id = 0, ++ .parent = &per_clk[3], ++ .secondary = &esdhc1_clk[1], ++ }, ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_ESDHC1_OFFSET, ++ .disable = _clk_disable, ++ .secondary = &esdhc1_clk[2], ++ }, ++ { ++ .id = 0, ++ .parent = &ahb_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR0, ++ .enable_shift = MXC_CCM_CGCR0_HCLK_ESDHC1_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk esdhc2_clk[] = { ++ { ++ .id = 1, ++ .parent = &per_clk[4], ++ .secondary = &esdhc2_clk[1], ++ }, ++ { ++ .id = 1, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_ESDHC2_OFFSET, ++ .disable = _clk_disable, ++ .secondary = &esdhc2_clk[2], ++ }, ++ { ++ .id = 1, ++ .parent = &ahb_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR0, ++ .enable_shift = MXC_CCM_CGCR0_HCLK_ESDHC2_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk fec_clk[] = { ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_FEC_OFFSET, ++ .disable = _clk_disable, ++ .secondary = &fec_clk[1], ++ }, ++ { ++ .id = 0, ++ .parent = &ahb_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR0, ++ .enable_shift = MXC_CCM_CGCR0_HCLK_FEC_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk gpio_clk[] = { ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_GPIO1_OFFSET, ++ .disable = _clk_disable, ++ }, ++ { ++ .id = 1, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_GPIO2_OFFSET, ++ .disable = _clk_disable, ++ }, ++ { ++ .id = 2, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_GPIO3_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++static struct clk gpt1_clk[] = { ++ { ++ .id = 0, ++ .parent = &per_clk[5], ++ .secondary = &gpt1_clk[1], ++ }, ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_GPT1_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++static struct clk gpt2_clk[] = { ++ { ++ .id = 1, ++ .parent = &per_clk[5], ++ .secondary = &gpt1_clk[1], ++ }, ++ { ++ .id = 1, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_GPT2_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++static struct clk gpt3_clk[] = { ++ { ++ .id = 2, ++ .parent = &per_clk[5], ++ .secondary = &gpt1_clk[1], ++ }, ++ { ++ .id = 2, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_GPT3_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++static struct clk gpt4_clk[] = { ++ { ++ .id = 3, ++ .parent = &per_clk[5], ++ .secondary = &gpt1_clk[1], ++ }, ++ { ++ .id = 3, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_GPT4_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk i2c_clk[] = { ++ { ++ .id = 0, ++ .parent = &per_clk[6], ++ }, ++ { ++ .id = 1, ++ .parent = &per_clk[6], ++ }, ++ { ++ .id = 2, ++ .parent = &per_clk[6], ++ }, ++}; ++ ++struct clk iim_clk = { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_IIM_OFFSET, ++ .disable = _clk_disable, ++}; ++ ++struct clk iomuxc_clk = { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_IOMUXC_OFFSET, ++ .disable = _clk_disable, ++}; ++ ++struct clk kpp_clk = { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_KPP_OFFSET, ++ .disable = _clk_disable, ++}; ++ ++struct clk lcdc_clk[] = { ++ { ++ .id = 0, ++ .parent = &per_clk[7], ++ .secondary = &lcdc_clk[1], ++ }, ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_LCDC_OFFSET, ++ .disable = _clk_disable, ++ .secondary = &lcdc_clk[2], ++ }, ++ { ++ .id = 0, ++ .parent = &ahb_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR0, ++ .enable_shift = MXC_CCM_CGCR0_HCLK_LCDC_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk owire_clk[] = { ++ { ++ .id = 0, ++ .parent = &per_clk[9], ++ .secondary = &owire_clk[1], ++ }, ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_OWIRE_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk pwm1_clk[] = { ++ { ++ .id = 0, ++ .parent = &per_clk[10], ++ .secondary = &pwm1_clk[1], ++ }, ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR1, ++ .enable_shift = MXC_CCM_CGCR1_PWM1_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk pwm2_clk[] = { ++ { ++ .id = 1, ++ .parent = &per_clk[10], ++ .secondary = &pwm2_clk[1], ++ }, ++ { ++ .id = 1, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_PWM2_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk pwm3_clk[] = { ++ { ++ .id = 2, ++ .parent = &per_clk[10], ++ .secondary = &pwm3_clk[1], ++ }, ++ { ++ .id = 2, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_PWM3_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk pwm4_clk[] = { ++ { ++ .id = 3, ++ .parent = &per_clk[10], ++ .secondary = &pwm4_clk[1], ++ }, ++ { ++ .id = 3, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_PWM3_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk rngb_clk = { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_RNGB_OFFSET, ++ .disable = _clk_disable, ++}; ++ ++struct clk scc_clk = { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_SCC_OFFSET, ++ .disable = _clk_disable, ++}; ++ ++struct clk sdma_clk[] = { ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_SDMA_OFFSET, ++ .disable = _clk_disable, ++ .secondary = &sdma_clk[1], ++ }, ++ { ++ .id = 0, ++ .parent = &ahb_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR0, ++ .enable_shift = MXC_CCM_CGCR0_HCLK_SDMA_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk sim1_clk[] = { ++ { ++ .id = 0, ++ .parent = &per_clk[11], ++ .secondary = &sim1_clk[1], ++ }, ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_SIM1_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk sim2_clk[] = { ++ { ++ .id = 1, ++ .parent = &per_clk[12], ++ .secondary = &sim2_clk[1], ++ }, ++ { ++ .id = 1, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_SIM2_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk slcdc_clk[] = { ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_SLCDC_OFFSET, ++ .disable = _clk_disable, ++ .secondary = &slcdc_clk[1], ++ }, ++ { ++ .id = 0, ++ .parent = &ahb_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR0, ++ .enable_shift = MXC_CCM_CGCR0_HCLK_SLCDC_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk spba_clk = { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_SPBA_OFFSET, ++ .disable = _clk_disable, ++}; ++ ++struct clk ssi1_clk[] = { ++ { ++ .id = 0, ++ .parent = &per_clk[13], ++ .secondary = &ssi1_clk[1], ++ }, ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_SSI1_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk ssi2_clk[] = { ++ { ++ .id = 1, ++ .parent = &per_clk[14], ++ .secondary = &ssi2_clk[1], ++ }, ++ { ++ .id = 1, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_SSI2_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk tchscrn_clk = { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_TCHSCRN_OFFSET, ++ .disable = _clk_disable, ++}; ++ ++struct clk uart1_clk[] = { ++ { ++ .id = 0, ++ .parent = &per_clk[15], ++ .secondary = &uart1_clk[1], ++ }, ++ { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_UART1_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk uart2_clk[] = { ++ { ++ .id = 1, ++ .parent = &per_clk[15], ++ .secondary = &uart2_clk[1], ++ }, ++ { ++ .id = 1, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_UART2_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk uart3_clk[] = { ++ { ++ .id = 2, ++ .parent = &per_clk[15], ++ .secondary = &uart3_clk[1], ++ }, ++ { ++ .id = 2, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_UART3_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk uart4_clk[] = { ++ { ++ .id = 3, ++ .parent = &per_clk[15], ++ .secondary = &uart4_clk[1], ++ }, ++ { ++ .id = 3, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_UART4_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk uart5_clk[] = { ++ { ++ .id = 4, ++ .parent = &per_clk[15], ++ .secondary = &uart5_clk[1], ++ }, ++ { ++ .id = 4, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_UART5_OFFSET, ++ .disable = _clk_disable, ++ }, ++}; ++ ++struct clk wdog_clk = { ++ .id = 0, ++ .parent = &ipg_clk, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_CGCR2, ++ .enable_shift = MXC_CCM_CGCR2_WDOG_OFFSET, ++ .disable = _clk_disable, ++}; ++ ++static unsigned long _clk_usb_round_rate(struct clk *clk, unsigned long rate) ++{ ++ unsigned long div; ++ ++ div = clk_get_rate(clk->parent) / rate; ++ if (clk_get_rate(clk->parent) % rate) ++ div++; ++ ++ if (div > 64) ++ return -EINVAL; ++ ++ return clk_get_rate(clk->parent) / div; ++} ++ ++static int _clk_usb_set_rate(struct clk *clk, unsigned long rate) ++{ ++ unsigned long reg; ++ unsigned long div; ++ ++ div = clk_get_rate(clk->parent) / rate; ++ ++ if (clk_get_rate(clk->parent) / div != rate) ++ return -EINVAL; ++ if (div > 64) ++ return -EINVAL; ++ ++ reg = __raw_readl(MXC_CCM_CCTL) & ~MXC_CCM_CCTL_USB_DIV_MASK; ++ reg |= (div - 1) << MXC_CCM_CCTL_USB_DIV_OFFSET; ++ __raw_writel(reg, MXC_CCM_MCR); ++ ++ return 0; ++} ++ ++static unsigned long _clk_usb_getrate(struct clk *clk) ++{ ++ unsigned long div = ++ __raw_readl(MXC_CCM_MCR) & MXC_CCM_CCTL_USB_DIV_MASK; ++ ++ div >>= MXC_CCM_CCTL_USB_DIV_OFFSET; ++ ++ return clk_get_rate(clk->parent) / (div + 1); ++} ++ ++static int _clk_usb_set_parent(struct clk *clk, struct clk *parent) ++{ ++ unsigned long mcr; ++ ++ if (clk->parent == parent) ++ return 0; ++ if (parent != &upll_clk && parent != &ahb_clk) ++ return -EINVAL; ++ ++ clk->parent = parent; ++ mcr = __raw_readl(MXC_CCM_MCR); ++ if (parent == &ahb_clk) ++ mcr |= (1 << MXC_CCM_MCR_USB_CLK_MUX_OFFSET); ++ else ++ mcr &= ~(1 << MXC_CCM_MCR_USB_CLK_MUX_OFFSET); ++ ++ __raw_writel(mcr, MXC_CCM_MCR); ++ ++ return 0; ++} ++ ++static struct clk usb_clk = { ++ .parent = &upll_clk, ++ .get_rate = _clk_usb_getrate, ++ .set_rate = _clk_usb_set_rate, ++ .round_rate = _clk_usb_round_rate, ++ .set_parent = _clk_usb_set_parent, ++}; ++ ++/* CLKO */ ++ ++static unsigned long _clk_clko_round_rate(struct clk *clk, unsigned long rate) ++{ ++ unsigned long div; ++ ++ div = clk_get_rate(clk->parent) / rate; ++ if (clk_get_rate(clk->parent) % rate) ++ div++; ++ ++ if (div > 64) ++ return -EINVAL; ++ ++ return clk_get_rate(clk->parent) / div; ++} ++ ++static int _clk_clko_set_rate(struct clk *clk, unsigned long rate) ++{ ++ unsigned long reg; ++ unsigned long div; ++ ++ div = clk_get_rate(clk->parent) / rate; ++ ++ if ((clk_get_rate(clk->parent) / div) != rate) ++ return -EINVAL; ++ if (div > 64) ++ return -EINVAL; ++ ++ reg = __raw_readl(MXC_CCM_MCR) & ~MXC_CCM_MCR_CLKO_DIV_MASK; ++ reg |= (div - 1) << MXC_CCM_MCR_CLKO_DIV_OFFSET; ++ __raw_writel(reg, MXC_CCM_MCR); ++ ++ return 0; ++} ++ ++static unsigned long _clk_clko_getrate(struct clk *clk) ++{ ++ unsigned long div = __raw_readl(MXC_CCM_MCR); ++ ++ div &= MXC_CCM_MCR_CLKO_DIV_MASK; ++ div >>= MXC_CCM_MCR_CLKO_DIV_OFFSET; ++ ++ return clk_get_rate(clk->parent) / (div + 1); ++} ++ ++static struct clk *clko_sources[] = { ++ &osc32k_clk, /* 0x0 */ ++ &osc24m_clk, /* 0x1 */ ++ &cpu_clk, /* 0x2 */ ++ &ahb_clk, /* 0x3 */ ++ &ipg_clk, /* 0x4 */ ++ NULL, /* 0x5 */ ++ NULL, /* 0x6 */ ++ NULL, /* 0x7 */ ++ NULL, /* 0x8 */ ++ NULL, /* 0x9 */ ++ &per_clk[0], /* 0xA */ ++ &per_clk[2], /* 0xB */ ++ &per_clk[13], /* 0xC */ ++ &per_clk[14], /* 0xD */ ++ &usb_clk, /* 0xE */ ++ NULL, /* 0xF */ ++}; ++ ++#define NR_CLKO_SOURCES (sizeof(clko_sources) / sizeof(struct clk *)) ++ ++static int _clk_clko_set_parent(struct clk *clk, struct clk *parent) ++{ ++ unsigned long reg; ++ struct clk **src; ++ int i; ++ ++ if (clk->parent == parent) ++ return 0; ++ for (i = 0, src = clko_sources; i < NR_CLKO_SOURCES; i++, src++) ++ if (*src == parent) ++ break; ++ ++ if (i == NR_CLKO_SOURCES) ++ return -EINVAL; ++ ++ clk->parent = parent; ++ ++ reg = __raw_readl(MXC_CCM_MCR) & ~MXC_CCM_MCR_CLKO_SEL_MASK; ++ reg |= i << MXC_CCM_MCR_CLKO_SEL_OFFSET; ++ __raw_writel(reg, MXC_CCM_MCR); ++ ++ return 0; ++} ++ ++static struct clk clko_clk = { ++ .set_rate = _clk_clko_set_rate, ++ .round_rate = _clk_clko_round_rate, ++ .set_parent = _clk_clko_set_parent, ++ .get_rate = _clk_clko_getrate, ++ .enable = _clk_enable, ++ .enable_reg = MXC_CCM_MCR, ++ .enable_shift = MXC_CCM_MCR_CLKO_EN_OFFSET, ++ .disable = _clk_disable, ++}; ++ ++#ifdef CONFIG_COMMON_CLKDEV ++#define _REGISTER_CLOCK(d, n, c) \ ++ { \ ++ .dev_id = d, \ ++ .con_id = n, \ ++ .clk = &c, \ ++ }, ++ ++static struct clk_lookup lookups[] = { ++ _REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk) ++ _REGISTER_CLOCK(NULL, "audmux", audmux_clk) ++ _REGISTER_CLOCK(NULL, "ata", ata_clk[0]) ++ _REGISTER_CLOCK(NULL, "can", can_clk[0]) ++ _REGISTER_CLOCK(NULL, "csi", csi_clk[0]) ++ _REGISTER_CLOCK(NULL, "cspi.0", cspi_clk[0]) ++ _REGISTER_CLOCK(NULL, "cspi.1", cspi_clk[1]) ++ _REGISTER_CLOCK(NULL, "cspi.2", cspi_clk[2]) ++ _REGISTER_CLOCK(NULL, "dryice", dryice_clk) ++ _REGISTER_CLOCK(NULL, "ect", ect_clk) ++ _REGISTER_CLOCK(NULL, "epit1", epit1_clk[0]) ++ _REGISTER_CLOCK(NULL, "epit2", epit2_clk[0]) ++ _REGISTER_CLOCK(NULL, "esai", esai_clk[0]) ++ _REGISTER_CLOCK("mxc-mmc.0", NULL, esdhc1_clk[0]) ++ _REGISTER_CLOCK("mxc-mmc.1", NULL, esdhc2_clk[0]) ++ _REGISTER_CLOCK("fec.0", NULL, fec_clk[0]) ++ _REGISTER_CLOCK(NULL, "gpio0", gpio_clk[0]) ++ _REGISTER_CLOCK(NULL, "gpio1", gpio_clk[1]) ++ _REGISTER_CLOCK(NULL, "gpio2", gpio_clk[2]) ++ _REGISTER_CLOCK(NULL, "gpt1", gpt1_clk[0]) ++ _REGISTER_CLOCK(NULL, "gpt2", gpt2_clk[0]) ++ _REGISTER_CLOCK(NULL, "gpt3", gpt3_clk[0]) ++ _REGISTER_CLOCK(NULL, "gpt4", gpt4_clk[0]) ++ _REGISTER_CLOCK("imx-i2c.0", NULL, i2c_clk[0]) ++ _REGISTER_CLOCK("imx-i2c.1", NULL, i2c_clk[1]) ++ _REGISTER_CLOCK("imx-i2c.2", NULL, i2c_clk[2]) ++ _REGISTER_CLOCK(NULL, "iim", iim_clk) ++ _REGISTER_CLOCK(NULL, "iomuxc", iomuxc_clk) ++ _REGISTER_CLOCK(NULL, "kpp", kpp_clk) ++ _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk[0]) ++ _REGISTER_CLOCK(NULL, "owire", owire_clk[0]) ++ _REGISTER_CLOCK("mxc_pwm.0", NULL, pwm1_clk[0]) ++ _REGISTER_CLOCK("mxc_pwm.1", NULL, pwm2_clk[0]) ++ _REGISTER_CLOCK("mxc_pwm.2", NULL, pwm3_clk[0]) ++ _REGISTER_CLOCK("mxc_pwm.3", NULL, pwm4_clk[0]) ++ _REGISTER_CLOCK(NULL, "rngb", rngb_clk) ++ _REGISTER_CLOCK(NULL, "scc", scc_clk) ++ _REGISTER_CLOCK(NULL, "sdma", sdma_clk[0]) ++ _REGISTER_CLOCK(NULL, "sim1", sim1_clk[0]) ++ _REGISTER_CLOCK(NULL, "sim2", sim2_clk[0]) ++ _REGISTER_CLOCK(NULL, "slcdc", slcdc_clk[0]) ++ _REGISTER_CLOCK(NULL, "spba", spba_clk) ++ _REGISTER_CLOCK(NULL, "ssi1", ssi1_clk[0]) ++ _REGISTER_CLOCK(NULL, "ssi2", ssi2_clk[0]) ++ _REGISTER_CLOCK(NULL, "tchscrn", tchscrn_clk) ++ _REGISTER_CLOCK("imx-uart.0", NULL, uart1_clk[0]) ++ _REGISTER_CLOCK("imx-uart.1", NULL, uart2_clk[0]) ++ _REGISTER_CLOCK("imx-uart.2", NULL, uart3_clk[0]) ++ _REGISTER_CLOCK("imx-uart.3", NULL, uart4_clk[0]) ++ _REGISTER_CLOCK("imx-uart.4", NULL, uart5_clk[0]) ++ _REGISTER_CLOCK(NULL, "wdog", wdog_clk) ++ _REGISTER_CLOCK(NULL, "usb", usb_clk) ++ _REGISTER_CLOCK(NULL, "clko", clko_clk) ++ _REGISTER_CLOCK(NULL, "brom", brom_clk) ++}; ++#else ++static struct clk *mxc_clks[] = { ++ &osc24m_clk, ++ &osc32k_clk, ++ &mpll_clk, ++ &upll_clk, ++ &cpu_clk, ++ &ahb_clk, ++ &ipg_clk, ++ &per_clk[0], ++ &per_clk[1], ++ &per_clk[2], ++ &per_clk[3], ++ &per_clk[4], ++ &per_clk[5], ++ &per_clk[6], ++ &per_clk[7], ++ &per_clk[8], ++ &per_clk[9], ++ &per_clk[10], ++ &per_clk[11], ++ &per_clk[12], ++ &per_clk[13], ++ &per_clk[14], ++ &per_clk[15], ++ &nfc_clk, ++ &audmux_clk, ++ &ata_clk[0], ++ &ata_clk[1], ++ &can_clk[0], ++ &can_clk[1], ++ &csi_clk[0], ++ &csi_clk[1], ++ &csi_clk[2], ++ &cspi_clk[0], ++ &cspi_clk[1], ++ &cspi_clk[2], ++ &dryice_clk, ++ &ect_clk, ++ &epit1_clk[0], ++ &epit1_clk[1], ++ &epit2_clk[0], ++ &epit2_clk[1], ++ &esai_clk[0], ++ &esai_clk[1], ++ &esai_clk[2], ++ &esdhc1_clk[0], ++ &esdhc1_clk[1], ++ &esdhc1_clk[2], ++ &esdhc2_clk[0], ++ &esdhc2_clk[1], ++ &esdhc2_clk[2], ++ &fec_clk[0], ++ &fec_clk[1], ++ &gpio_clk[0], ++ &gpio_clk[1], ++ &gpio_clk[2], ++ &gpt1_clk[0], ++ &gpt1_clk[1], ++ &gpt2_clk[0], ++ &gpt2_clk[1], ++ &gpt3_clk[0], ++ &gpt3_clk[1], ++ &gpt4_clk[0], ++ &gpt4_clk[1], ++ &i2c_clk[0], ++ &i2c_clk[1], ++ &i2c_clk[2], ++ &iim_clk, ++ &iomuxc_clk, ++ &kpp_clk, ++ &lcdc_clk[0], ++ &lcdc_clk[1], ++ &lcdc_clk[2], ++ &owire_clk[0], ++ &owire_clk[1], ++ &pwm1_clk[0], ++ &pwm1_clk[1], ++ &pwm2_clk[0], ++ &pwm2_clk[1], ++ &pwm3_clk[0], ++ &pwm3_clk[1], ++ &pwm4_clk[0], ++ &pwm4_clk[1], ++ &rngb_clk, ++ &scc_clk, ++ &sdma_clk[0], ++ &sdma_clk[1], ++ &sim1_clk[0], ++ &sim1_clk[1], ++ &sim2_clk[0], ++ &sim2_clk[1], ++ &slcdc_clk[0], ++ &slcdc_clk[1], ++ &spba_clk, ++ &ssi1_clk[0], ++ &ssi1_clk[1], ++ &ssi2_clk[0], ++ &ssi2_clk[1], ++ &tchscrn_clk, ++ &uart1_clk[0], ++ &uart1_clk[1], ++ &uart2_clk[0], ++ &uart2_clk[1], ++ &uart3_clk[0], ++ &uart3_clk[1], ++ &uart4_clk[0], ++ &uart4_clk[1], ++ &uart5_clk[0], ++ &uart5_clk[1], ++ &wdog_clk, ++ &usb_clk, ++ &clko_clk, ++}; ++#endif ++ ++int __init mx25_clocks_init(unsigned long fref) ++{ ++ int i; ++ ++#ifdef CONFIG_COMMON_CLKDEV ++ for (i = 0; i < ARRAY_SIZE(lookups); i++) { ++ printk(KERN_DEBUG "Registering clock '%s' '%s'\n", ++ lookups[i].dev_id ? lookups[i].dev_id : "", ++ lookups[i].con_id ? lookups[i].con_id : ""); ++ clkdev_add(&lookups[i]); ++ } ++#else ++ struct clk **clkp; ++ for (clkp = mxc_clks; clkp < mxc_clks + ARRAY_SIZE(mxc_clks); clkp++) ++ clk_register(*clkp); ++#endif ++ ckih_rate = fref; ++#ifndef CONFIG_DEBUG_LL ++ /* Turn off all possible clocks */ ++ __raw_writel((1 << MXC_CCM_CGCR0_HCLK_EMI_OFFSET), MXC_CCM_CGCR0); ++ ++ __raw_writel((1 << MXC_CCM_CGCR1_GPT1_OFFSET) | ++ (1 << MXC_CCM_CGCR1_IIM_OFFSET), MXC_CCM_CGCR1); ++ __raw_writel(1 << MXC_CCM_CGCR2_SCC_OFFSET, MXC_CCM_CGCR2); ++#endif ++#if 1 ++ /* Set all perclk sources to upll */ ++ for (i = 0; i < ARRAY_SIZE(per_clk); i++) { ++ int ret; ++ unsigned long rate = per_clk[i].get_rate(&per_clk[i]); ++ ++#ifdef CONFIG_DEBUG_LL ++ if (i == 15) { ++ printk(KERN_DEBUG "skipping per_clk[%d] rate=%lu\n", i, rate); ++ continue; ++ } ++#endif ++ { ++ unsigned long new_rate; ++ ++ per_clk[i].set_parent(&per_clk[i], &upll_clk); ++ new_rate = per_clk[i].round_rate(&per_clk[i], rate); ++ if ((ret = per_clk[i].set_rate(&per_clk[i], new_rate)) < 0) { ++ printk(KERN_ERR "Error %d setting clk[%d] rate to %lu\n", ++ ret, i, new_rate); ++ } ++ } ++ } ++#endif ++ /* the NFC clock must be derived from AHB clock */ ++ clk_set_parent(&per_clk[8], &ahb_clk); ++ clk_set_rate(&per_clk[8], clk_get_rate(&ahb_clk) / 6); ++ ++ /* This will propagate to all children and init all the clock rates */ ++#if 1 ++ clk_enable(&uart1_clk[0]); ++#endif ++ clk_enable(&emi_clk); ++ clk_enable(&gpio_clk[0]); ++ clk_enable(&gpio_clk[1]); ++ clk_enable(&gpio_clk[2]); ++ clk_enable(&iim_clk); ++ clk_enable(&gpt1_clk[0]); ++ clk_enable(&iomuxc_clk); ++ clk_enable(&scc_clk); ++ ++ pr_info("Clock input source is %ld\n", clk_get_rate(&osc24m_clk)); ++ ++ pr_info("CPU: %lu.%03luMHz\n", ++ clk_get_rate(&cpu_clk) / 1000000, clk_get_rate(&cpu_clk) / 1000 % 1000); ++ pr_info("AHB: %lu.%03luMHz\n", ++ clk_get_rate(&ahb_clk) / 1000000, clk_get_rate(&ahb_clk) / 1000 % 1000); ++ pr_info("MPLL: %lu.%03luMHz\n", ++ clk_get_rate(&mpll_clk) / 1000000, clk_get_rate(&mpll_clk) / 1000 % 1000); ++ pr_info("UPLL: %lu.%03luMHz\n", ++ clk_get_rate(&upll_clk) / 1000000, clk_get_rate(&upll_clk) / 1000 % 1000); ++ clk_set_rate(&mpll_clk, clk_get_rate(&mpll_clk)); ++ clk_set_rate(&upll_clk, clk_get_rate(&upll_clk)); ++ ++ mxc_timer_init(&gpt1_clk[0]); ++ return 0; ++} +diff -urNp linux-2.6.30-rc4/arch/arm/mach-mx2/clock_imx27.c linux-2.6.30-rc4-karo/arch/arm/mach-mx2/clock_imx27.c +--- linux-2.6.30-rc4/arch/arm/mach-mx2/clock_imx27.c 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/mach-mx2/clock_imx27.c 2009-06-02 17:05:26.000000000 +0200 +@@ -621,7 +621,7 @@ DEFINE_CLOCK1(csi_clk, 0, 0, 0, + .clk = &c, \ + }, + +-static struct clk_lookup lookups[] __initdata = { ++static struct clk_lookup lookups[] = { + _REGISTER_CLOCK("imx-uart.0", NULL, uart1_clk) + _REGISTER_CLOCK("imx-uart.1", NULL, uart2_clk) + _REGISTER_CLOCK("imx-uart.2", NULL, uart3_clk) +diff -urNp linux-2.6.30-rc4/arch/arm/mach-mx2/cpu_imx25.c linux-2.6.30-rc4-karo/arch/arm/mach-mx2/cpu_imx25.c +--- linux-2.6.30-rc4/arch/arm/mach-mx2/cpu_imx25.c 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/arch/arm/mach-mx2/cpu_imx25.c 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,65 @@ ++/* ++ * arch/arm/mach-mx2/cpu_mx25.c ++ * ++ * Copyright 2009 Lothar Wassmann ++ * derived from: cpu_mx27.c ++ * Copyright 2007 Freescale Semiconductor, Inc. All Rights Reserved. ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2 ++ * of the License, or (at your option) any later version. ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, ++ * MA 02110-1301, USA. ++ */ ++ ++/* ++ * i.MX25 specific CPU detection code ++ */ ++ ++#include ++#include ++ ++#include ++ ++static int cpu_silicon_rev = -1; ++static int cpu_partnumber; ++ ++#define IIM_PREV_REG IO_ADDRESS(IIM_BASE_ADDR + 0x20) ++#define IIM_SREV_REG IO_ADDRESS(IIM_BASE_ADDR + 0x24) ++ ++static void query_silicon_parameter(void) ++{ ++ cpu_partnumber = __raw_readl(IIM_PREV_REG) >> 3; ++ cpu_silicon_rev = __raw_readl(IIM_SREV_REG); ++ ++ printk(KERN_DEBUG "CPU rev: 0x%02x chip_rev: 0x%02x\n", ++ cpu_partnumber, cpu_silicon_rev); ++ if (WARN_ON(cpu_partnumber != 0x1f)) { ++ printk(KERN_WARNING "Unsupported CPU rev: 0x%02x\n", cpu_partnumber); ++ } ++} ++ ++/* ++ * Returns: ++ * the silicon revision of the cpu ++ * -EINVAL - not a mx25 ++ */ ++int mx25_revision(void) ++{ ++ if (cpu_silicon_rev == -1) ++ query_silicon_parameter(); ++ ++ if (cpu_partnumber != 0x1f) ++ return -EINVAL; ++ ++ return cpu_silicon_rev; ++} ++EXPORT_SYMBOL(mx25_revision); +diff -urNp linux-2.6.30-rc4/arch/arm/mach-mx2/crm_regs_mx25.h linux-2.6.30-rc4-karo/arch/arm/mach-mx2/crm_regs_mx25.h +--- linux-2.6.30-rc4/arch/arm/mach-mx2/crm_regs_mx25.h 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/arch/arm/mach-mx2/crm_regs_mx25.h 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,190 @@ ++/* ++ * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved. ++ */ ++ ++/* ++ * The code contained herein is licensed under the GNU General Public ++ * License. You may obtain a copy of the GNU General Public License ++ * Version 2 or later at the following locations: ++ * ++ * http://www.opensource.org/licenses/gpl-license.html ++ * http://www.gnu.org/copyleft/gpl.html ++ */ ++ ++#ifndef __ARCH_ARM_MACH_MX25_CRM_REGS_H__ ++#define __ARCH_ARM_MACH_MX25_CRM_REGS_H__ ++ ++#include ++ ++/* Register offsets */ ++#define MXC_CCM_MPCTL (IO_ADDRESS(CCM_BASE_ADDR) + 0x00) ++#define MXC_CCM_UPCTL (IO_ADDRESS(CCM_BASE_ADDR) + 0x04) ++#define MXC_CCM_CCTL (IO_ADDRESS(CCM_BASE_ADDR) + 0x08) ++#define MXC_CCM_CGCR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x0C) ++#define MXC_CCM_CGCR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x10) ++#define MXC_CCM_CGCR2 (IO_ADDRESS(CCM_BASE_ADDR) + 0x14) ++#define MXC_CCM_PCDR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x18) ++#define MXC_CCM_PCDR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x1C) ++#define MXC_CCM_PCDR2 (IO_ADDRESS(CCM_BASE_ADDR) + 0x20) ++#define MXC_CCM_PCDR3 (IO_ADDRESS(CCM_BASE_ADDR) + 0x24) ++#define MXC_CCM_RCSR (IO_ADDRESS(CCM_BASE_ADDR) + 0x28) ++#define MXC_CCM_CRDR (IO_ADDRESS(CCM_BASE_ADDR) + 0x2C) ++#define MXC_CCM_DCVR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x30) ++#define MXC_CCM_DCVR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x34) ++#define MXC_CCM_DCVR2 (IO_ADDRESS(CCM_BASE_ADDR) + 0x38) ++#define MXC_CCM_DCVR3 (IO_ADDRESS(CCM_BASE_ADDR) + 0x3C) ++#define MXC_CCM_LTR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x40) ++#define MXC_CCM_LTR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x44) ++#define MXC_CCM_LTR2 (IO_ADDRESS(CCM_BASE_ADDR) + 0x48) ++#define MXC_CCM_LTR3 (IO_ADDRESS(CCM_BASE_ADDR) + 0x4C) ++#define MXC_CCM_LTBR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x50) ++#define MXC_CCM_LTBR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x54) ++#define MXC_CCM_PMCR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x58) ++#define MXC_CCM_PMCR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x5C) ++#define MXC_CCM_PMCR2 (IO_ADDRESS(CCM_BASE_ADDR) + 0x60) ++#define MXC_CCM_MCR (IO_ADDRESS(CCM_BASE_ADDR) + 0x64) ++ ++#define MXC_CCM_MPCTL_BRMO (1 << 31) ++#define MXC_CCM_MPCTL_PD_OFFSET 26 ++#define MXC_CCM_MPCTL_PD_MASK (0xf << 26) ++#define MXC_CCM_MPCTL_MFD_OFFSET 16 ++#define MXC_CCM_MPCTL_MFD_MASK (0x3ff << 16) ++#define MXC_CCM_MPCTL_MFI_OFFSET 10 ++#define MXC_CCM_MPCTL_MFI_MASK (0xf << 10) ++#define MXC_CCM_MPCTL_MFN_OFFSET 0 ++#define MXC_CCM_MPCTL_MFN_MASK 0x3ff ++#define MXC_CCM_MPCTL_LF (1 << 15) ++ ++#define MXC_CCM_UPCTL_BRMO (1 << 31) ++#define MXC_CCM_UPCTL_PD_OFFSET 26 ++#define MXC_CCM_UPCTL_PD_MASK (0xf << 26) ++#define MXC_CCM_UPCTL_MFD_OFFSET 16 ++#define MXC_CCM_UPCTL_MFD_MASK (0x3ff << 16) ++#define MXC_CCM_UPCTL_MFI_OFFSET 10 ++#define MXC_CCM_UPCTL_MFI_MASK (0xf << 10) ++#define MXC_CCM_UPCTL_MFN_OFFSET 0 ++#define MXC_CCM_UPCTL_MFN_MASK 0x3ff ++#define MXC_CCM_UPCTL_LF (1 << 15) ++ ++#define MXC_CCM_CCTL_ARM_OFFSET 30 ++#define MXC_CCM_CCTL_ARM_MASK (0x3 << 30) ++#define MXC_CCM_CCTL_AHB_OFFSET 28 ++#define MXC_CCM_CCTL_AHB_MASK (0x3 << 28) ++#define MXC_CCM_CCTL_MPLL_RST (1 << 27) ++#define MXC_CCM_CCTL_UPLL_RST (1 << 26) ++#define MXC_CCM_CCTL_LP_CTL_OFFSET 24 ++#define MXC_CCM_CCTL_LP_CTL_MASK (0x3 << 24) ++#define MXC_CCM_CCTL_LP_MODE_RUN (0x0 << 24) ++#define MXC_CCM_CCTL_LP_MODE_WAIT (0x1 << 24) ++#define MXC_CCM_CCTL_LP_MODE_DOZE (0x2 << 24) ++#define MXC_CCM_CCTL_LP_MODE_STOP (0x3 << 24) ++#define MXC_CCM_CCTL_UPLL_DISABLE (1 << 23) ++#define MXC_CCM_CCTL_MPLL_BYPASS (1 << 22) ++#define MXC_CCM_CCTL_USB_DIV_OFFSET 16 ++#define MXC_CCM_CCTL_USB_DIV_MASK (0x3 << 16) ++#define MXC_CCM_CCTL_CG_CTRL (1 << 15) ++#define MXC_CCM_CCTL_ARM_SRC (1 << 14) ++ ++#define MXC_CCM_CGCR0_HCLK_ATA_OFFSET 16 ++#define MXC_CCM_CGCR0_HCLK_BROM_OFFSET 17 ++#define MXC_CCM_CGCR0_HCLK_CSI_OFFSET 18 ++#define MXC_CCM_CGCR0_HCLK_EMI_OFFSET 19 ++#define MXC_CCM_CGCR0_HCLK_ESAI_OFFSET 20 ++#define MXC_CCM_CGCR0_HCLK_ESDHC1_OFFSET 21 ++#define MXC_CCM_CGCR0_HCLK_ESDHC2_OFFSET 22 ++#define MXC_CCM_CGCR0_HCLK_FEC_OFFSET 23 ++#define MXC_CCM_CGCR0_HCLK_LCDC_OFFSET 24 ++#define MXC_CCM_CGCR0_HCLK_RTIC_OFFSET 25 ++#define MXC_CCM_CGCR0_HCLK_SDMA_OFFSET 26 ++#define MXC_CCM_CGCR0_HCLK_SLCDC_OFFSET 27 ++#define MXC_CCM_CGCR0_HCLK_USBOTG_OFFSET 28 ++ ++#define MXC_CCM_CGCR0_PER_CSI_OFFSET 0 ++#define MXC_CCM_CGCR0_PER_EPIT_OFFSET 1 ++#define MXC_CCM_CGCR0_PER_ESAI_OFFSET 2 ++#define MXC_CCM_CGCR0_PER_ESDHC1_OFFSET 3 ++#define MXC_CCM_CGCR0_PER_ESDHC2_OFFSET 4 ++#define MXC_CCM_CGCR0_PER_GPT_OFFSET 5 ++#define MXC_CCM_CGCR0_PER_I2C_OFFSET 6 ++#define MXC_CCM_CGCR0_PER_LCDC_OFFSET 7 ++#define MXC_CCM_CGCR0_PER_NFC_OFFSET 8 ++#define MXC_CCM_CGCR0_PER_OWIRE_OFFSET 9 ++#define MXC_CCM_CGCR0_PER_PWM_OFFSET 10 ++#define MXC_CCM_CGCR0_PER_SIM1_OFFSET 11 ++#define MXC_CCM_CGCR0_PER_SIM2_OFFSET 12 ++#define MXC_CCM_CGCR0_PER_SSI1_OFFSET 13 ++#define MXC_CCM_CGCR0_PER_SSI2_OFFSET 14 ++#define MXC_CCM_CGCR0_PER_UART_OFFSET 15 ++ ++#define MXC_CCM_CGCR1_AUDMUX_OFFSET 0 ++#define MXC_CCM_CGCR1_ATA_OFFSET 1 ++#define MXC_CCM_CGCR1_CAN1_OFFSET 2 ++#define MXC_CCM_CGCR1_CAN2_OFFSET 3 ++#define MXC_CCM_CGCR1_CSI_OFFSET 4 ++#define MXC_CCM_CGCR1_CSPI1_OFFSET 5 ++#define MXC_CCM_CGCR1_CSPI2_OFFSET 6 ++#define MXC_CCM_CGCR1_CSPI3_OFFSET 7 ++#define MXC_CCM_CGCR1_DRYICE_OFFSET 8 ++#define MXC_CCM_CGCR1_ECT_OFFSET 9 ++#define MXC_CCM_CGCR1_EPIT1_OFFSET 10 ++#define MXC_CCM_CGCR1_EPIT2_OFFSET 11 ++#define MXC_CCM_CGCR1_ESAI_OFFSET 12 ++#define MXC_CCM_CGCR1_ESDHC1_OFFSET 13 ++#define MXC_CCM_CGCR1_ESDHC2_OFFSET 14 ++#define MXC_CCM_CGCR1_FEC_OFFSET 15 ++#define MXC_CCM_CGCR1_GPIO1_OFFSET 16 ++#define MXC_CCM_CGCR1_GPIO2_OFFSET 17 ++#define MXC_CCM_CGCR1_GPIO3_OFFSET 18 ++#define MXC_CCM_CGCR1_GPT1_OFFSET 19 ++#define MXC_CCM_CGCR1_GPT2_OFFSET 20 ++#define MXC_CCM_CGCR1_GPT3_OFFSET 21 ++#define MXC_CCM_CGCR1_GPT4_OFFSET 22 ++#define MXC_CCM_CGCR1_I2C1_OFFSET 23 ++#define MXC_CCM_CGCR1_I2C2_OFFSET 24 ++#define MXC_CCM_CGCR1_I2C3_OFFSET 25 ++#define MXC_CCM_CGCR1_IIM_OFFSET 26 ++#define MXC_CCM_CGCR1_IOMUXC_OFFSET 27 ++#define MXC_CCM_CGCR1_KPP_OFFSET 28 ++#define MXC_CCM_CGCR1_LCDC_OFFSET 29 ++#define MXC_CCM_CGCR1_OWIRE_OFFSET 30 ++#define MXC_CCM_CGCR1_PWM1_OFFSET 31 ++ ++#define MXC_CCM_CGCR2_PWM2_OFFSET (32-32) ++#define MXC_CCM_CGCR2_PWM3_OFFSET (33-32) ++#define MXC_CCM_CGCR2_PWM4_OFFSET (34-32) ++#define MXC_CCM_CGCR2_RNGB_OFFSET (35-32) ++#define MXC_CCM_CGCR2_RTIC_OFFSET (36-32) ++#define MXC_CCM_CGCR2_SCC_OFFSET (37-32) ++#define MXC_CCM_CGCR2_SDMA_OFFSET (38-32) ++#define MXC_CCM_CGCR2_SIM1_OFFSET (39-32) ++#define MXC_CCM_CGCR2_SIM2_OFFSET (40-32) ++#define MXC_CCM_CGCR2_SLCDC_OFFSET (41-32) ++#define MXC_CCM_CGCR2_SPBA_OFFSET (42-32) ++#define MXC_CCM_CGCR2_SSI1_OFFSET (43-32) ++#define MXC_CCM_CGCR2_SSI2_OFFSET (44-32) ++#define MXC_CCM_CGCR2_TCHSCRN_OFFSET (45-32) ++#define MXC_CCM_CGCR2_UART1_OFFSET (46-32) ++#define MXC_CCM_CGCR2_UART2_OFFSET (47-32) ++#define MXC_CCM_CGCR2_UART3_OFFSET (48-32) ++#define MXC_CCM_CGCR2_UART4_OFFSET (49-32) ++#define MXC_CCM_CGCR2_UART5_OFFSET (50-32) ++#define MXC_CCM_CGCR2_WDOG_OFFSET (51-32) ++ ++#define MXC_CCM_PCDR1_PERDIV1_MASK 0x3f ++ ++#define MXC_CCM_RCSR_NF16B (1 << 14) ++ ++#define MXC_CCM_MCR_USB_XTAL_MUX_OFFSET 31 ++#define MXC_CCM_MCR_CLKO_EN_OFFSET 30 ++#define MXC_CCM_MCR_CLKO_DIV_OFFSET 24 ++#define MXC_CCM_MCR_CLKO_DIV_MASK (0x3F << 24) ++#define MXC_CCM_MCR_CLKO_SEL_OFFSET 20 ++#define MXC_CCM_MCR_CLKO_SEL_MASK (0xF << 20) ++#define MXC_CCM_MCR_ESAI_CLK_MUX_OFFSET 19 ++#define MXC_CCM_MCR_SSI2_CLK_MUX_OFFSET 18 ++#define MXC_CCM_MCR_SSI1_CLK_MUX_OFFSET 17 ++#define MXC_CCM_MCR_USB_CLK_MUX_OFFSET 16 ++ ++#define MXC_CCM_MCR_PER_CLK_MUX_MASK (0xFFFF << 0) ++ ++#endif /* __ARCH_ARM_MACH_MX25_CRM_REGS_H__ */ +diff -urNp linux-2.6.30-rc4/arch/arm/mach-mx2/devices.h linux-2.6.30-rc4-karo/arch/arm/mach-mx2/devices.h +--- linux-2.6.30-rc4/arch/arm/mach-mx2/devices.h 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/mach-mx2/devices.h 2009-06-02 17:05:27.000000000 +0200 +@@ -20,3 +20,9 @@ extern struct platform_device mxc_i2c_de + extern struct platform_device mxc_i2c_device1; + extern struct platform_device mxc_sdhc_device0; + extern struct platform_device mxc_sdhc_device1; ++#ifdef CONFIG_MACH_MX25 ++extern struct platform_device mx25_i2c_device0; ++extern struct platform_device mx25_i2c_device1; ++extern struct platform_device mx25_i2c_device2; ++extern struct platform_device mxc_sdhc_device2; ++#endif +diff -urNp linux-2.6.30-rc4/arch/arm/mach-mx2/devices_mx25.c linux-2.6.30-rc4-karo/arch/arm/mach-mx2/devices_mx25.c +--- linux-2.6.30-rc4/arch/arm/mach-mx2/devices_mx25.c 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/arch/arm/mach-mx2/devices_mx25.c 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,402 @@ ++/* ++ * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved. ++ */ ++ ++/* ++ * The code contained herein is licensed under the GNU General Public ++ * License. You may obtain a copy of the GNU General Public License ++ * Version 2 or later at the following locations: ++ * ++ * http://www.opensource.org/licenses/gpl-license.html ++ * http://www.gnu.org/copyleft/gpl.html ++ */ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include "sdma_script_code.h" ++ ++#include "karo.h" ++ ++void mx25_sdma_get_script_info(sdma_script_start_addrs * sdma_script_addr) ++{ ++ sdma_script_addr->mxc_sdma_ap_2_ap_addr = ap_2_ap_ADDR; ++ sdma_script_addr->mxc_sdma_ap_2_bp_addr = -1; ++ sdma_script_addr->mxc_sdma_bp_2_ap_addr = -1; ++ sdma_script_addr->mxc_sdma_loopback_on_dsp_side_addr = -1; ++ sdma_script_addr->mxc_sdma_mcu_interrupt_only_addr = -1; ++ ++ sdma_script_addr->mxc_sdma_firi_2_per_addr = -1; ++ sdma_script_addr->mxc_sdma_firi_2_mcu_addr = -1; ++ sdma_script_addr->mxc_sdma_per_2_firi_addr = -1; ++ sdma_script_addr->mxc_sdma_mcu_2_firi_addr = -1; ++ ++ sdma_script_addr->mxc_sdma_uart_2_per_addr = uart_2_per_ADDR; ++ sdma_script_addr->mxc_sdma_uart_2_mcu_addr = uart_2_mcu_ADDR; ++ sdma_script_addr->mxc_sdma_per_2_app_addr = per_2_app_ADDR; ++ sdma_script_addr->mxc_sdma_mcu_2_app_addr = mcu_2_app_ADDR; ++ ++ sdma_script_addr->mxc_sdma_per_2_per_addr = -1; ++ ++ sdma_script_addr->mxc_sdma_uartsh_2_per_addr = uartsh_2_per_ADDR; ++ sdma_script_addr->mxc_sdma_uartsh_2_mcu_addr = uartsh_2_mcu_ADDR; ++ sdma_script_addr->mxc_sdma_per_2_shp_addr = per_2_shp_ADDR; ++ sdma_script_addr->mxc_sdma_mcu_2_shp_addr = mcu_2_shp_ADDR; ++ ++ sdma_script_addr->mxc_sdma_ata_2_mcu_addr = ata_2_mcu_ADDR; ++ sdma_script_addr->mxc_sdma_mcu_2_ata_addr = mcu_2_ata_ADDR; ++ ++ sdma_script_addr->mxc_sdma_app_2_per_addr = app_2_per_ADDR; ++ sdma_script_addr->mxc_sdma_app_2_mcu_addr = app_2_mcu_ADDR; ++ sdma_script_addr->mxc_sdma_shp_2_per_addr = shp_2_per_ADDR; ++ sdma_script_addr->mxc_sdma_shp_2_mcu_addr = shp_2_mcu_ADDR; ++ ++ sdma_script_addr->mxc_sdma_mshc_2_mcu_addr = -1; ++ sdma_script_addr->mxc_sdma_mcu_2_mshc_addr = -1; ++ ++ sdma_script_addr->mxc_sdma_spdif_2_mcu_addr = -1; ++ sdma_script_addr->mxc_sdma_mcu_2_spdif_addr = -1; ++ ++ sdma_script_addr->mxc_sdma_asrc_2_mcu_addr = -1; ++ ++ sdma_script_addr->mxc_sdma_dptc_dvfs_addr = -1; ++ sdma_script_addr->mxc_sdma_ext_mem_2_ipu_addr = ext_mem__ipu_ram_ADDR; ++ sdma_script_addr->mxc_sdma_descrambler_addr = -1; ++ ++ sdma_script_addr->mxc_sdma_start_addr = (unsigned short *)sdma_code; ++ sdma_script_addr->mxc_sdma_ram_code_size = RAM_CODE_SIZE; ++ sdma_script_addr->mxc_sdma_ram_code_start_addr = RAM_CODE_START_ADDR; ++} ++ ++#if defined(CONFIG_MXC_WATCHDOG) || defined(CONFIG_MXC_WATCHDOG_MODULE) ++static struct resource wdt_resources[] = { ++ { ++ .start = WDOG_BASE_ADDR, ++ .end = WDOG_BASE_ADDR + 0x2f, ++ .flags = IORESOURCE_MEM, ++ }, ++}; ++ ++static struct platform_device mx25_wdt_device = { ++ .name = "mxc_wdt", ++ .id = 0, ++ .num_resources = ARRAY_SIZE(wdt_resources), ++ .resource = wdt_resources, ++}; ++ ++static void mx25_init_wdt(void) ++{ ++ (void)platform_device_register(&mx25_wdt_device); ++} ++#else ++static inline void mx25_init_wdt(void) ++{ ++} ++#endif ++ ++/* ++ * lcdc: ++ * - i.MX1: the basic controller ++ * - i.MX21: to be checked ++ * - i.MX27: like i.MX1, with slightly variations ++ */ ++static struct resource mxc_fb[] = { ++ { ++ .start = LCDC_BASE_ADDR, ++ .end = LCDC_BASE_ADDR + 0xFFF, ++ .flags = IORESOURCE_MEM, ++ }, ++ { ++ .start = MXC_INT_LCDC, ++ .end = MXC_INT_LCDC, ++ .flags = IORESOURCE_IRQ, ++ } ++}; ++ ++/* mxc lcd driver */ ++struct platform_device mxc_fb_device = { ++ .name = "imx-fb", ++ .id = 0, ++ .num_resources = ARRAY_SIZE(mxc_fb), ++ .resource = mxc_fb, ++ .dev = { ++ .coherent_dma_mask = 0xFFFFFFFF, ++ }, ++}; ++ ++/* SPI controller and device data */ ++#if defined(CONFIG_SPI_MXC) || defined(CONFIG_SPI_MXC_MODULE) ++ ++#ifdef CONFIG_SPI_MXC_SELECT1 ++/*! ++ * Resource definition for the CSPI1 ++ */ ++static struct resource mx25_spi1_resources[] = { ++ [0] = { ++ .start = CSPI1_BASE_ADDR, ++ .end = CSPI1_BASE_ADDR + SZ_4K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = MXC_INT_CSPI1, ++ .end = MXC_INT_CSPI1, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++/*! Platform Data for MXC CSPI1 */ ++static struct mxc_spi_master mx25_spi1_data = { ++ .maxchipselect = 4, ++ .spi_version = 7, ++}; ++ ++/*! Device Definition for MXC CSPI1 */ ++static struct platform_device mx25_spi1_device = { ++ .name = "mxc_spi", ++ .id = 0, ++ .dev = { ++ .platform_data = &mx25_spi1_data, ++ }, ++ .num_resources = ARRAY_SIZE(mx25_spi1_resources), ++ .resource = mx25_spi1_resources, ++}; ++ ++#endif /* CONFIG_SPI_MXC_SELECT1 */ ++ ++#ifdef CONFIG_SPI_MXC_SELECT2 ++/*! ++ * Resource definition for the CSPI2 ++ */ ++static struct resource mx25_spi2_resources[] = { ++ [0] = { ++ .start = CSPI2_BASE_ADDR, ++ .end = CSPI2_BASE_ADDR + SZ_4K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = MXC_INT_CSPI2, ++ .end = MXC_INT_CSPI2, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++/*! Platform Data for MXC CSPI2 */ ++static struct mxc_spi_master mx25_spi2_data = { ++ .maxchipselect = 4, ++ .spi_version = 7, ++}; ++ ++/*! Device Definition for MXC CSPI2 */ ++static struct platform_device mx25_spi2_device = { ++ .name = "mxc_spi", ++ .id = 1, ++ .dev = { ++ .platform_data = &mx25_spi2_data, ++ }, ++ .num_resources = ARRAY_SIZE(mx25_spi2_resources), ++ .resource = mx25_spi2_resources, ++}; ++#endif /* CONFIG_SPI_MXC_SELECT2 */ ++ ++#ifdef CONFIG_SPI_MXC_SELECT3 ++/*! ++ * Resource definition for the CSPI3 ++ */ ++static struct resource mx25_spi3_resources[] = { ++ [0] = { ++ .start = CSPI3_BASE_ADDR, ++ .end = CSPI3_BASE_ADDR + SZ_4K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = MXC_INT_CSPI3, ++ .end = MXC_INT_CSPI3, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++/*! Platform Data for MXC CSPI3 */ ++static struct mxc_spi_master mx25_spi3_data = { ++ .maxchipselect = 4, ++ .spi_version = 7, ++}; ++ ++/*! Device Definition for MXC CSPI3 */ ++static struct platform_device mx25_spi3_device = { ++ .name = "mxc_spi", ++ .id = 2, ++ .dev = { ++ .platform_data = &mx25_spi3_data, ++ }, ++ .num_resources = ARRAY_SIZE(mx25_spi3_resources), ++ .resource = mx25_spi3_resources, ++}; ++#endif /* CONFIG_SPI_MXC_SELECT3 */ ++ ++static inline void mx25_init_spi(void) ++{ ++ spba_take_ownership(SPBA_CSPI2, SPBA_MASTER_A); ++ spba_take_ownership(SPBA_CSPI3, SPBA_MASTER_A); ++ ++#ifdef CONFIG_SPI_MXC_SELECT1 ++ if (platform_device_register(&mx25_spi1_device) < 0) ++ printk(KERN_ERR "Error: Registering the SPI Controller_1\n"); ++#endif /* CONFIG_SPI_MXC_SELECT1 */ ++#ifdef CONFIG_SPI_MXC_SELECT2 ++ if (platform_device_register(&mx25_spi2_device) < 0) ++ printk(KERN_ERR "Error: Registering the SPI Controller_2\n"); ++#endif /* CONFIG_SPI_MXC_SELECT2 */ ++#ifdef CONFIG_SPI_MXC_SELECT3 ++ if (platform_device_register(&mx25_spi3_device) < 0) ++ printk(KERN_ERR "Error: Registering the SPI Controller_3\n"); ++#endif /* CONFIG_SPI_MXC_SELECT3 */ ++} ++#else ++static inline void mx25_init_spi(void) ++{ ++} ++#endif ++ ++/* I2C controller and device data */ ++#if defined(CONFIG_I2C_IMX) || defined(CONFIG_I2C_IMX_MODULE) ++ ++/*! ++ * Resource definition for the I2C1 ++ */ ++static struct resource mx25_i2c1_resources[] = { ++ [0] = { ++ .start = I2C_BASE_ADDR, ++ .end = I2C_BASE_ADDR + SZ_4K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = MXC_INT_I2C, ++ .end = MXC_INT_I2C, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++/*! ++ * Resource definition for the I2C2 ++ */ ++static struct resource mx25_i2c2_resources[] = { ++ [0] = { ++ .start = I2C2_BASE_ADDR, ++ .end = I2C2_BASE_ADDR + SZ_4K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = MXC_INT_I2C2, ++ .end = MXC_INT_I2C2, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++/*! ++ * Resource definition for the I2C3 ++ */ ++static struct resource mx25_i2c3_resources[] = { ++ [0] = { ++ .start = I2C3_BASE_ADDR, ++ .end = I2C3_BASE_ADDR + SZ_4K - 1, ++ .flags = IORESOURCE_MEM, ++ }, ++ [1] = { ++ .start = MXC_INT_I2C3, ++ .end = MXC_INT_I2C3, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++/*! Device Definition for MXC I2C1 */ ++struct platform_device mx25_i2c_device0 = { ++ .name = "imx-i2c", ++ .id = 0, ++ .num_resources = ARRAY_SIZE(mx25_i2c1_resources), ++ .resource = mx25_i2c1_resources, ++}; ++ ++struct platform_device mx25_i2c_device1 = { ++ .name = "imx-i2c", ++ .id = 1, ++ .num_resources = ARRAY_SIZE(mx25_i2c2_resources), ++ .resource = mx25_i2c2_resources, ++}; ++ ++struct platform_device mx25_i2c_device2 = { ++ .name = "imx-i2c", ++ .id = 2, ++ .num_resources = ARRAY_SIZE(mx25_i2c3_resources), ++ .resource = mx25_i2c3_resources, ++}; ++#endif ++ ++static struct mxc_gpio_port mx25_gpio_ports[] = { ++ { ++ .chip.label = "gpio-1", ++ .base = IO_ADDRESS(GPIO1_BASE_ADDR), ++ .irq = MXC_INT_GPIO1, ++ .virtual_irq_start = MXC_GPIO_IRQ_START, ++ }, ++ { ++ .chip.label = "gpio-2", ++ .base = IO_ADDRESS(GPIO2_BASE_ADDR), ++ .irq = MXC_INT_GPIO2, ++ .virtual_irq_start = MXC_GPIO_IRQ_START + 1 * 32, ++ }, ++ { ++ .chip.label = "gpio-3", ++ .base = IO_ADDRESS(GPIO3_BASE_ADDR), ++ .irq = MXC_INT_GPIO3, ++ .virtual_irq_start = MXC_GPIO_IRQ_START + 2 * 32, ++ }, ++ { ++ .chip.label = "gpio-4", ++ .base = IO_ADDRESS(GPIO4_BASE_ADDR), ++ .irq = MXC_INT_GPIO4, ++ .virtual_irq_start = MXC_GPIO_IRQ_START + 3 * 32, ++ }, ++}; ++ ++static inline void mx25_init_ssi(void) ++{ ++ /* SPBA configuration for SSI - SDMA and MCU are set */ ++ spba_take_ownership(SPBA_SSI1, SPBA_MASTER_A | SPBA_MASTER_C); ++ spba_take_ownership(SPBA_SSI2, SPBA_MASTER_A | SPBA_MASTER_C); ++} ++ ++static struct platform_device mx25_dma_device = { ++ .name = "mxc_dma", ++ .id = 0, ++}; ++ ++static inline void mx25_init_dma(void) ++{ ++ (void)platform_device_register(&mx25_dma_device); ++} ++ ++static int __init mx25_init_devices(void) ++{ ++ mx25_init_wdt(); ++ mx25_init_spi(); ++ mx25_init_dma(); ++ mx25_init_ssi(); ++ ++ return 0; ++} ++arch_initcall(mx25_init_devices); ++ ++int __init mxc_register_gpios(void) ++{ ++ return mxc_gpio_init(mx25_gpio_ports, ARRAY_SIZE(mx25_gpio_ports)); ++} +diff -urNp linux-2.6.30-rc4/arch/arm/mach-mx2/generic.c linux-2.6.30-rc4-karo/arch/arm/mach-mx2/generic.c +--- linux-2.6.30-rc4/arch/arm/mach-mx2/generic.c 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/mach-mx2/generic.c 2009-06-02 17:05:27.000000000 +0200 +@@ -26,6 +26,7 @@ + #include + + /* MX27 memory map definition */ ++#if defined(CONFIG_MACH_MX27) || defined(CONFIG_MACH_MX21) + static struct map_desc mxc_io_desc[] __initdata = { + /* + * this fixed mapping covers: +@@ -61,7 +62,7 @@ static struct map_desc mxc_io_desc[] __i + .pfn = __phys_to_pfn(X_MEMC_BASE_ADDR), + .length = X_MEMC_SIZE, + .type = MT_DEVICE +- } ++ }, + }; + + /* +@@ -82,4 +83,46 @@ void __init mx27_map_io(void) + + iotable_init(mxc_io_desc, ARRAY_SIZE(mxc_io_desc)); + } ++#endif ++ ++#ifdef CONFIG_MACH_MX25 ++static struct map_desc mx25_io_desc[] __initdata = { ++ { ++ .virtual = (unsigned long)X_MEMC_BASE_ADDR_VIRT, ++ .pfn = __phys_to_pfn(X_MEMC_BASE_ADDR), ++ .length = X_MEMC_SIZE, ++ .type = MT_DEVICE ++ }, ++ { ++ .virtual = (unsigned long)ASIC_BASE_ADDR_VIRT, ++ .pfn = __phys_to_pfn(ASIC_BASE_ADDR), ++ .length = ASIC_SIZE, ++ .type = MT_DEVICE_NONSHARED ++ }, ++ { ++ .virtual = (unsigned long)AIPS1_BASE_ADDR_VIRT, ++ .pfn = __phys_to_pfn(AIPS1_BASE_ADDR), ++ .length = AIPS1_SIZE, ++ .type = MT_DEVICE_NONSHARED ++ }, ++ { ++ .virtual = (unsigned long)AIPS2_BASE_ADDR_VIRT, ++ .pfn = __phys_to_pfn(AIPS2_BASE_ADDR), ++ .length = AIPS2_SIZE, ++ .type = MT_DEVICE_NONSHARED ++ }, ++ { ++ .virtual = (unsigned long)SPBA0_BASE_ADDR_VIRT, ++ .pfn = __phys_to_pfn(SPBA0_BASE_ADDR), ++ .length = SPBA0_SIZE, ++ .type = MT_DEVICE_NONSHARED ++ }, ++}; ++ ++void __init mx25_map_io(void) ++{ ++ mxc_set_cpu_type(MXC_CPU_MX25); + ++ iotable_init(mx25_io_desc, ARRAY_SIZE(mx25_io_desc)); ++} ++#endif +diff -urNp linux-2.6.30-rc4/arch/arm/mach-mx2/karo-tx25.c linux-2.6.30-rc4-karo/arch/arm/mach-mx2/karo-tx25.c +--- linux-2.6.30-rc4/arch/arm/mach-mx2/karo-tx25.c 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/arch/arm/mach-mx2/karo-tx25.c 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,1115 @@ ++/* ++ * arch/arm/mach-mx2/karo-tx25.c ++ * ++ * Copyright (C) 2008 Lothar Wassmann ++ * ++ * based on: arch/arm/mach-mx27ads.c (C) Freescale Semiconductor, Inc. ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * version 2 as published by the Free Software Foundation ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the: ++ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 ++ * ++ * This file adds support for the Ka-Ro electronics TX25 processor modules ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++//#include ++//#include ++#include ++#include ++#include ++#if defined(CONFIG_MTD) || defined(CONFIG_MTD_MODULE) ++#include ++#include ++#include ++#include ++#endif ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++//#include ++//#include ++#include ++#include ++#include ++//#include ++//#include ++//#include ++ ++#include "crm_regs.h" ++#include "devices.h" ++#include "karo.h" ++ ++#ifdef DEBUG ++int tx25_debug = 1; ++module_param(tx25_debug, int, S_IRUGO | S_IWUSR); ++#else ++static int tx25_debug; ++module_param(tx25_debug, int, 0); ++#endif ++ ++//#include "karo.h" ++ ++int karo_board_type = 0; ++int karo_mod_type = -1; ++ ++ ++#ifdef CONFIG_USB_EHCI_MXC ++ ++#define SMSC_VENDOR_ID 0x0424 ++#define USB3317_PROD_ID 0x0006 ++#define ULPI_FCTL 7 ++ ++static inline const char *ulpi_name(void __iomem *view) ++{ ++ if ((unsigned long)view & 0x400) { ++ return "USBH2"; ++ } else { ++ return "USBOTG"; ++ } ++} ++ ++static int usb3317_init(void __iomem *view) ++{ ++ int vid, pid, ret; ++#if 1 ++ /* This is a kludge until we know why we sometimes read a wrong ++ * vendor or product ID! ++ */ ++ int retries = 3; ++ ++ retry: ++#endif ++ ret = ulpi_read(ISP1504_VID_HIGH, view); ++ if (ret < 0) { ++ goto err; ++ } ++ vid = ret << 8; ++ ++ ret = ulpi_read(ISP1504_VID_LOW, view); ++ if (ret < 0) { ++ goto err; ++ } ++ vid |= ret; ++ ++ ret = ulpi_read(ISP1504_PID_HIGH, view); ++ if (ret < 0) { ++ goto err; ++ } ++ pid = ret << 8; ++ ++ ret = ulpi_read(ISP1504_PID_LOW, view); ++ if (ret < 0) { ++ goto err; ++ } ++ pid |= ret; ++ ++ pr_info("ULPI on %s port Vendor ID 0x%x Product ID 0x%x\n", ++ ulpi_name(view), vid, pid); ++ if (vid != SMSC_VENDOR_ID || pid != USB3317_PROD_ID) { ++ if (retries-- < 0) { ++ pr_err("No USB3317 found\n"); ++ return -ENODEV; ++ } ++ goto retry; ++ } ++ err: ++ if (ret < 0) { ++ printk(KERN_ERR "ULPI read on %s port failed with error %d\n", ++ ulpi_name(view), ret); ++ return ret; ++ } ++ return 0; ++} ++ ++static int usb3317_set_vbus_power(void __iomem *view, int on) ++{ ++ int ret; ++ ++ DBG(0, "%s: Switching %s port VBUS power %s\n", __FUNCTION__, ++ ulpi_name(view), on ? "on" : "off"); ++ ++ if (on) { ++ ret = ulpi_set(DRV_VBUS_EXT | /* enable external Vbus */ ++ DRV_VBUS | /* enable internal Vbus */ ++ CHRG_VBUS, /* charge Vbus */ ++ ISP1504_OTGCTL, view); ++ } else { ++ ret = ulpi_clear(DRV_VBUS_EXT | /* disable external Vbus */ ++ DRV_VBUS, /* disable internal Vbus */ ++ ISP1504_OTGCTL, view); ++ if (ret == 0) { ++ ret = ulpi_set(DISCHRG_VBUS, /* discharge Vbus */ ++ ISP1504_OTGCTL, view); ++ } ++ } ++ if (ret < 0) { ++ printk(KERN_ERR "ULPI read on %s port failed with error %d\n", ++ ulpi_name(view), ret); ++ return ret; ++ } ++ return 0; ++} ++ ++static int tx25_usbh2_init(struct platform_device *pdev) ++{ ++ int ret; ++ u32 temp; ++ unsigned long flags; ++ void __iomem *view = IO_ADDRESS(OTG_BASE_ADDR + 0x570); ++ ++ local_irq_save(flags); ++ temp = readl(IO_ADDRESS(OTG_BASE_ADDR) + 0x600); ++ temp &= ~((3 << 21) | (1 << 0)); ++ temp |= (1 << 5) | (1 << 16) | (1 << 19) | (1 << 20); ++ writel(temp, IO_ADDRESS(OTG_BASE_ADDR) + 0x600); ++ local_irq_restore(flags); ++ ++ /* select ULPI transceiver */ ++ /* this must be done _before_ setting up the GPIOs! */ ++ temp = readl(view + 0x14); ++ DBG(0, "%s: Changing USBH2_PORTSC1 from %08x to %08x\n", __FUNCTION__, ++ temp, (temp & ~(3 << 30)) | (2 << 30)); ++ temp &= ~(3 << 30); ++ temp |= 2 << 30; ++ writel(temp, view + 0x14); ++ ++ /* Set to Host mode */ ++ temp = readl(view + 0x38); ++ DBG(0, "%s: Changing USBH2_USBMODE from %08x to %08x\n", __FUNCTION__, ++ temp, temp | 3); ++ writel(temp | 0x3, view + 0x38); ++ ++ ret = gpio_usbh2_active(); ++ if (ret != 0) { ++ return ret; ++ } ++ ++ ret = usb3317_init(view); ++ if (ret != 0) { ++ goto err; ++ } ++ ret = usb3317_set_vbus_power(view, 1); ++ if (ret != 0) { ++ goto err; ++ } ++ return 0; ++ ++ err: ++ gpio_usbh2_inactive(); ++ return ret; ++} ++ ++static int tx25_usbh2_exit(struct platform_device *pdev) ++{ ++ gpio_usbh2_inactive(); ++ return 0; ++} ++ ++static struct mxc_usbh_platform_data tx25_usbh2_data = { ++ .init = tx25_usbh2_init, ++ .exit = tx25_usbh2_exit, ++}; ++ ++int tx25_usbh2_register(void) ++{ ++ int ret; ++ ++ ret = mxc_register_device(&mxc_ehci2, &tx25_usbh2_data); ++ return ret; ++} ++device_initcall(tx25_usbh2_register); ++#endif // CONFIG_USB_EHCI_MXC ++ ++//#define FEC_MII_IRQ IRQ_GPIOD(8) ++ ++#if defined(CONFIG_FEC) || defined(CONFIG_FEC_MODULE) ++static struct resource fec_resources[] = { ++ { ++ .start = FEC_BASE_ADDR, ++ .end = FEC_BASE_ADDR + 0x18f, ++ .flags = IORESOURCE_MEM, ++ }, { ++ .start = FEC_BASE_ADDR + 0x200, ++ .end = FEC_BASE_ADDR + 0x30b, ++ .flags = IORESOURCE_MEM, ++ }, { ++ .start = MXC_INT_FEC, ++ .end = MXC_INT_FEC, ++ .flags = IORESOURCE_IRQ, ++#ifdef FEC_MII_IRQ ++ }, { ++ .start = FEC_MII_IRQ, ++ .end = FEC_MII_IRQ, ++ .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, ++#endif ++ }, ++}; ++ ++/* ++ * Setup GPIO for FEC device to be active ++ * ++ */ ++static struct pad_desc karo_tx25_fec_gpios_off[] = { ++ MX25_PAD_FEC_MDC__GPIO_3_5, ++ MX25_PAD_FEC_MDIO__GPIO_3_6, ++ MX25_PAD_FEC_TDATA0__GPIO_3_7, ++ MX25_PAD_FEC_TDATA1__GPIO_3_8, ++ MX25_PAD_FEC_TX_EN__GPIO_3_9, ++ MX25_PAD_FEC_RDATA0__GPIO_3_10, ++ MX25_PAD_FEC_RDATA1__GPIO_3_11, ++ MX25_PAD_FEC_RX_DV__GPIO_3_12, ++ MX25_PAD_FEC_TX_CLK__GPIO_3_13, ++ MX25_PAD_D12__GPIO_4_8, ++ MX25_PAD_D10__GPIO_4_10, ++}; ++ ++static struct pad_desc karo_tx25_fec_pwr_gpios[] = { ++ MX25_PAD_D11__GPIO_4_9, /* FEC PHY power on pin */ ++ MX25_PAD_D13__GPIO_4_7, /* FEC reset */ ++}; ++ ++static struct pad_desc karo_tx25_fec_gpios_on[] = { ++ MX25_PAD_FEC_MDC__FEC_MDC, ++ MX25_PAD_FEC_MDIO__FEC_MDIO, ++ MX25_PAD_FEC_TDATA0__FEC_TDATA0, ++ MX25_PAD_FEC_TDATA1__FEC_TDATA1, ++ MX25_PAD_FEC_TX_EN__FEC_TX_EN, ++ MX25_PAD_FEC_RDATA0__FEC_RDATA0, ++ MX25_PAD_FEC_RDATA1__FEC_RDATA1, ++ MX25_PAD_FEC_RX_DV__FEC_RX_DV, ++ MX25_PAD_FEC_TX_CLK__FEC_TX_CLK, ++ MX25_PAD_D12__GPIO_4_8, ++ MX25_PAD_D10__GPIO_4_10, ++}; ++ ++static struct gpio_desc { ++ unsigned int gpio:7; ++ unsigned int dir:1; ++ unsigned int level:1; ++} karo_tx25_fec_strap_gpios[] = { ++ /* configure the PHY strap pins to the correct values */ ++ { GPIO_PORTC | 5, 1, 0, }, ++ { GPIO_PORTC | 6, 1, 0, }, ++ { GPIO_PORTC | 7, 1, 0, }, ++ { GPIO_PORTC | 8, 1, 0, }, ++ { GPIO_PORTC | 9, 1, 0, }, ++ { GPIO_PORTC | 10, 1, 1, }, ++ { GPIO_PORTC | 11, 1, 1, }, ++ { GPIO_PORTC | 12, 0, 1, }, ++ { GPIO_PORTC | 13, 1, 0, }, ++ ++ { GPIO_PORTD | 8, 0, 0, }, ++ { GPIO_PORTD | 10, 0, 0, }, ++ { GPIO_PORTD | 9, 1, 1, }, ++ { GPIO_PORTD | 7, 1, 0, }, ++}; ++ ++#define TX25_FEC_PWR_GPIO (GPIO_PORTD | 9) ++#define TX25_FEC_RST_GPIO (GPIO_PORTD | 7) ++ ++static int gpio_fec_active(void) ++{ ++ int ret; ++ int i; ++ ++#ifdef FEC_MII_IRQ ++ DBG(0, "%s: Using IRQ %d (GPIO %d) for MII\n", __FUNCTION__, ++ FEC_MII_IRQ, irq_to_gpio(FEC_MII_IRQ)); ++ ++ set_irq_type(FEC_MII_IRQ, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING); ++#endif ++ ret = mxc_iomux_v3_setup_multiple_pads(karo_tx25_fec_pwr_gpios, ++ ARRAY_SIZE(karo_tx25_fec_pwr_gpios)); ++ if (ret) { ++ return ret; ++ } ++ /* ++ * If the PHY is already powered on, assume it has been ++ * correctly configured (by the boot loader) ++ */ ++ if (0 && gpio_get_value(TX25_FEC_PWR_GPIO) && ++ gpio_get_value(TX25_FEC_RST_GPIO)) { ++ ret = mxc_iomux_v3_setup_multiple_pads(karo_tx25_fec_gpios_on, ++ ARRAY_SIZE(karo_tx25_fec_gpios_on)); ++ if (ret) { ++ mxc_iomux_v3_release_multiple_pads(karo_tx25_fec_pwr_gpios, ++ ARRAY_SIZE(karo_tx25_fec_pwr_gpios)); ++ return ret; ++ } ++ } else { ++ /* switch PHY strap pins into required state */ ++ ret = mxc_iomux_v3_setup_multiple_pads(karo_tx25_fec_gpios_off, ++ ARRAY_SIZE(karo_tx25_fec_gpios_off)); ++ if (ret) { ++ mxc_iomux_v3_release_multiple_pads(karo_tx25_fec_pwr_gpios, ++ ARRAY_SIZE(karo_tx25_fec_pwr_gpios)); ++ return ret; ++ } ++ DBG(0, "%s: Switching FEC PHY power on\n", __FUNCTION__); ++ //gpio_set_value(TX25_FEC_PWR_GPIO, 1); ++#if 0 ++ while (1) { ++ gpio_set_value(TX25_FEC_PWR_GPIO, 1); ++ mdelay(1000); ++ gpio_set_value(TX25_FEC_PWR_GPIO, 0); ++ mdelay(1000); ++ } ++#endif ++ DBG(0, "%s: Asserting FEC PHY reset\n", __FUNCTION__); ++// gpio_set_value(TX25_FEC_RST_GPIO, 0); ++ for (i = 0; i < ARRAY_SIZE(karo_tx25_fec_strap_gpios); i++) { ++ struct gpio_desc *pd = &karo_tx25_fec_strap_gpios[i]; ++ ++ ret = gpio_request(pd->gpio, "FEC"); ++ if (ret < 0) { ++ DBG(0, "%s: Failed to request GPIO%d_%d: %d\n", ++ __FUNCTION__, pd->gpio / 32 + 1, pd->gpio % 32, ret); ++ goto rel_mux; ++ } ++ if (pd->dir) { ++ gpio_direction_output(pd->gpio, ++ pd->level); ++ } else { ++ gpio_direction_input(pd->gpio); ++ } ++ } ++#ifdef DEBUG ++ for (i = 0; i < ARRAY_SIZE(karo_tx25_fec_strap_gpios); i++) { ++ struct gpio_desc *pd = &karo_tx25_fec_strap_gpios[i]; ++ int grp = pd->gpio / 32 + 1; ++ int ofs = pd->gpio % 32; ++ ++ if (pd->dir && pd->level != gpio_get_value(pd->gpio)) { ++ DBG(0, "%s: GPIO%d_%d is %d instead of %d\n", __FUNCTION__, ++ grp, ofs, gpio_get_value(pd->gpio), ++ pd->level); ++ } ++ } ++#endif ++ DBG(0, "%s: Delaying for 22ms\n", __FUNCTION__); ++ mdelay(22); ++ DBG(0, "%s: Deasserting FEC PHY reset\n", __FUNCTION__); ++ gpio_set_value(TX25_FEC_RST_GPIO, 1); ++#ifdef DEBUG ++ for (i = 0; i < ARRAY_SIZE(karo_tx25_fec_strap_gpios); i++) { ++ struct gpio_desc *pd = &karo_tx25_fec_strap_gpios[i]; ++ int grp = pd->gpio / 32 + 1; ++ int ofs = pd->gpio % 32; ++ ++ DBG(0, "%s: GPIO%d_%d is %d\n", __FUNCTION__, ++ grp, ofs, gpio_get_value(pd->gpio)); ++ } ++#endif ++ mxc_iomux_v3_release_multiple_pads(karo_tx25_fec_gpios_off, ++ ARRAY_SIZE(karo_tx25_fec_gpios_off)); ++ ret = mxc_iomux_v3_setup_multiple_pads(karo_tx25_fec_gpios_on, ++ ARRAY_SIZE(karo_tx25_fec_gpios_on)); ++ if (ret) { ++ goto rel_gpio; ++ } ++#ifdef DEBUG ++ for (i = 0; i < ARRAY_SIZE(karo_tx25_fec_strap_gpios); i++) { ++ struct gpio_desc *pd = &karo_tx25_fec_strap_gpios[i]; ++ int grp = pd->gpio / 32 + 1; ++ int ofs = pd->gpio % 32; ++ ++ DBG(0, "%s: GPIO%d_%d is %d\n", __FUNCTION__, ++ grp, ofs, gpio_get_value(pd->gpio)); ++ } ++#endif ++ } ++ return ret; ++ ++ rel_mux: ++ mxc_iomux_v3_release_multiple_pads(karo_tx25_fec_gpios_off, ++ ARRAY_SIZE(karo_tx25_fec_gpios_off)); ++ rel_gpio: ++ while (--i >= 0) { ++ struct gpio_desc *pd = &karo_tx25_fec_strap_gpios[i]; ++#ifdef DEBUG ++ int grp = pd->gpio / 32 + 1; ++ int ofs = pd->gpio % 32; ++ ++ DBG(0, "%s: Freeing GPIO%d_%d\n", __FUNCTION__, ++ grp, ofs); ++#endif ++ gpio_free(pd->gpio); ++ } ++ mxc_iomux_v3_release_multiple_pads(karo_tx25_fec_pwr_gpios, ++ ARRAY_SIZE(karo_tx25_fec_pwr_gpios)); ++ return ret; ++} ++ ++/* ++ * Setup GPIO for FEC device to be inactive ++ * ++ */ ++static void gpio_fec_inactive(void) ++{ ++ int i; ++ ++ mxc_iomux_v3_release_multiple_pads(karo_tx25_fec_gpios_on, ++ ARRAY_SIZE(karo_tx25_fec_gpios_on)); ++ mxc_iomux_v3_setup_multiple_pads(karo_tx25_fec_gpios_off, ++ ARRAY_SIZE(karo_tx25_fec_gpios_off)); ++ DBG(0, "%s: Asserting FEC PHY reset\n", __FUNCTION__); ++ gpio_set_value(TX25_FEC_RST_GPIO, 0); ++ DBG(0, "%s: Switching FEC PHY power off\n", __FUNCTION__); ++ gpio_set_value(TX25_FEC_PWR_GPIO, 0); ++ ++ mxc_iomux_v3_release_multiple_pads(karo_tx25_fec_gpios_off, ++ ARRAY_SIZE(karo_tx25_fec_gpios_off)); ++ mxc_iomux_v3_release_multiple_pads(karo_tx25_fec_pwr_gpios, ++ ARRAY_SIZE(karo_tx25_fec_pwr_gpios)); ++ for (i = 0; i < ARRAY_SIZE(karo_tx25_fec_strap_gpios); i++) { ++ struct gpio_desc *pd = &karo_tx25_fec_strap_gpios[i]; ++#ifdef DEBUG ++ int grp = pd->gpio / 32 + 1; ++ int ofs = pd->gpio % 32; ++ ++ DBG(0, "%s: Freeing GPIO%d_%d\n", __FUNCTION__, ++ grp, ofs); ++#endif ++ gpio_free(pd->gpio); ++ } ++} ++ ++static struct clk *tx25_fec_clk; ++ ++static int tx25_fec_suspend(struct platform_device *pdev) ++{ ++ BUG_ON(tx25_fec_clk == NULL); ++ DBG(1, "%s: Switching FEC PHY off\n", __FUNCTION__); ++ gpio_fec_inactive(); ++ clk_disable(tx25_fec_clk); ++ return 0; ++} ++ ++static int tx25_fec_resume(struct platform_device *pdev) ++{ ++ BUG_ON(tx25_fec_clk == NULL); ++ DBG(1, "%s: Switching FEC PHY on\n", __FUNCTION__); ++ clk_enable(tx25_fec_clk); ++ gpio_fec_active(); ++ return 0; ++} ++ ++#if 0 ++/* ++ * i.MX25 allows RMII mode to be configured via a gasket ++ */ ++#define FEC_MIIGSK_CFGR_FRCONT (1 << 6) ++#define FEC_MIIGSK_CFGR_LBMODE (1 << 4) ++#define FEC_MIIGSK_CFGR_EMODE (1 << 3) ++#define FEC_MIIGSK_CFGR_IF_MODE_MASK (3 << 0) ++#define FEC_MIIGSK_CFGR_IF_MODE_MII (0 << 0) ++#define FEC_MIIGSK_CFGR_IF_MODE_RMII (1 << 0) ++ ++#define FEC_MIIGSK_ENR_READY (1 << 2) ++#define FEC_MIIGSK_ENR_EN (1 << 1) ++ ++#include "../arch/arm/mach-mx25/crm_regs.h" ++static void __inline__ fec_localhw_setup(struct net_device *dev) ++{ ++ struct fec_enet_private *fep = netdev_priv(dev); ++ ++ /* ++ * Set up the MII gasket for RMII mode ++ */ ++ printk("%s: enable RMII gasket\n", dev->name); ++ ++ /* disable the gasket and wait */ ++ fec_reg_write16(fep, FEC_MIIGSK_ENR, 0); ++ while (fec_reg_read16(fep, FEC_MIIGSK_ENR) & FEC_MIIGSK_ENR_READY) ++ udelay(1); ++ ++ /* configure the gasket for RMII, 50 MHz, no loopback, no echo */ ++ fec_reg_write16(fep, FEC_MIIGSK_CFGR, FEC_MIIGSK_CFGR_IF_MODE_RMII); ++ ++ /* re-enable the gasket */ ++ fec_reg_write16(fep, FEC_MIIGSK_ENR, FEC_MIIGSK_ENR_EN); ++ fec_reg_read16(fep, FEC_MIIGSK_CFGR); ++ fec_reg_read16(fep, FEC_MIIGSK_ENR); ++} ++#endif ++ ++static int fec_arch_init(struct platform_device *pdev) ++{ ++ int ret; ++ ++ DBG(0, "%s: Activating FEC GPIOs\n", __FUNCTION__); ++ dump_regs(); ++ ++ ret = gpio_fec_active(); ++ if (ret) { ++ printk(KERN_ERR "%s: could not enable FEC gpios: %d\n", __FUNCTION__, ret); ++ return ret; ++ } ++ ++ BUG_ON(tx25_fec_clk != NULL); ++ tx25_fec_clk = clk_get(&pdev->dev, NULL); ++ if (unlikely(IS_ERR(tx25_fec_clk))) { ++ printk(KERN_ERR "Failed to get fec_clk\n"); ++ return PTR_ERR(tx25_fec_clk); ++ } ++ DBG(0, "%s: Enabling FEC clock\n", __FUNCTION__); ++ clk_enable(tx25_fec_clk); ++ dump_regs(); ++ return 0; ++} ++ ++static void fec_arch_exit(struct platform_device *pdev) ++{ ++ BUG_ON(tx25_fec_clk == NULL); ++ if (unlikely(IS_ERR(tx25_fec_clk))) { ++ printk(KERN_ERR "Failed to get fec_clk\n"); ++ return; ++ } ++ DBG(0, "%s: Disabling FEC clock\n", __FUNCTION__); ++ clk_disable(tx25_fec_clk); ++ clk_put(tx25_fec_clk); ++ tx25_fec_clk = NULL; ++ DBG(0, "%s: Deactivating FEC GPIOs\n", __FUNCTION__); ++ gpio_fec_inactive(); ++} ++ ++static struct fec_enet_platform_data fec_data = { ++ .arch_init = fec_arch_init, ++ .arch_exit = fec_arch_exit, ++ .suspend = tx25_fec_suspend, ++ .resume = tx25_fec_resume, ++}; ++ ++static struct platform_device fec_device = { ++ .name = "fec", ++ .id = 0, ++ .num_resources = ARRAY_SIZE(fec_resources), ++ .resource = fec_resources, ++ .dev = { ++ .platform_data = &fec_data, ++ .coherent_dma_mask = 0xFFFFFFFF, ++ }, ++}; ++#endif ++ ++/* MTD NAND flash */ ++#if defined(CONFIG_MTD_NAND_MXC) || defined(CONFIG_MTD_NAND_MXC_MODULE) ++#ifdef CONFIG_ARCH_MXC_HAS_NFC_V2 ++static struct mtd_partition tx25_nand_partitions[] = { ++ { ++ .name = "RedBoot", ++ .offset = 0, ++ .size = 0x00040000, ++ }, { ++ .name = "kernel", ++ .offset = MTDPART_OFS_APPEND, ++ .size = 0x001A0000, ++ }, { ++ .name = "rootfs", ++ .offset = MTDPART_OFS_APPEND, ++ .size = 0x07E000000, ++ }, { ++ .name = "FIS directory", ++ .offset = MTDPART_OFS_APPEND, ++ .size = 0x00003000, ++ .mask_flags = MTD_WRITEABLE, ++ }, { ++ .name = "RedBoot config", ++ .offset = MTDPART_OFS_APPEND, ++ .size = 0x00001000, ++ .mask_flags = MTD_WRITEABLE, ++ }, ++}; ++ ++static struct pad_desc karo_tx25_nand_pads[] = { ++ MX25_PAD_NF_CE0__NF_CE0, ++ MX25_PAD_NFWE_B__NFWE_B, ++ MX25_PAD_NFRE_B__NFRE_B, ++ MX25_PAD_NFALE__NFALE, ++ MX25_PAD_NFCLE__NFCLE, ++ MX25_PAD_NFWP_B__NFWP_B, ++ MX25_PAD_NFRB__NFRB, ++ MX25_PAD_D7__D7, ++ MX25_PAD_D6__D6, ++ MX25_PAD_D5__D5, ++ MX25_PAD_D4__D4, ++ MX25_PAD_D3__D3, ++ MX25_PAD_D2__D2, ++ MX25_PAD_D1__D1, ++ MX25_PAD_D0__D0, ++}; ++ ++static int tx25_nand_init(void) ++{ ++ int ret; ++ ++ DBG(0, "%s: Configuring NAND pins\n", __FUNCTION__); ++ ret = mxc_iomux_v3_setup_multiple_pads(karo_tx25_nand_pads, ++ ARRAY_SIZE(karo_tx25_nand_pads)); ++ if (ret) { ++ return ret; ++ } ++ return 0; ++} ++ ++static void tx25_nand_exit(void) ++{ ++ mxc_iomux_v3_release_multiple_pads(karo_tx25_nand_pads, ++ ARRAY_SIZE(karo_tx25_nand_pads)); ++} ++ ++static struct flash_platform_data tx25_nand_data = { ++ .map_name = "nand_probe", ++ .name = "tx25-nand", ++ .parts = tx25_nand_partitions, ++ .nr_parts = ARRAY_SIZE(tx25_nand_partitions), ++ .width = 1, ++ .init = tx25_nand_init, ++ .exit = tx25_nand_exit, ++}; ++#else ++static struct mxc_nand_platform_data tx25_nand_data = { ++ .hw_ecc = 1, ++ .width = 1, ++}; ++#endif ++ ++static struct resource tx25_nand_resources[] = { ++#ifdef CONFIG_ARCH_MXC_HAS_NFC_V1_1 ++ { ++ .start = NFC_BASE_ADDR + 0x1e00, ++ .end = NFC_BASE_ADDR + 0x1e2f, ++ .flags = IORESOURCE_MEM, ++ }, { ++ .start = NFC_BASE_ADDR, ++ .end = NFC_BASE_ADDR + 0x11ff, ++ .flags = IORESOURCE_MEM, ++#else ++ { ++ .start = NFC_BASE_ADDR, ++ .end = NFC_BASE_ADDR + 0x1e2f, ++ .flags = IORESOURCE_MEM, ++#endif ++ }, { ++ .start = MXC_INT_NANDFC, ++ .end = MXC_INT_NANDFC, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++static struct platform_device tx25_nand_mtd_device = { ++ .name = "mxc_nand", ++ .id = 0, ++ .num_resources = ARRAY_SIZE(tx25_nand_resources), ++ .resource = tx25_nand_resources, ++ .dev = { ++ .platform_data = &tx25_nand_data, ++ }, ++}; ++#endif ++ ++#if defined(CONFIG_VIDEO_MXC_EMMA_OUTPUT) || defined(CONFIG_VIDEO_MXC_EMMA_OUTPUT_MODULE) ++static u64 mxc_emma_dmamask = 0xffffffffUL; ++ ++static struct platform_device tx25_v4l2out_device = { ++ .name = "MXC Video Output", ++ .id = 0, ++ .dev = { ++ .dma_mask = &mxc_emma_dmamask, ++ .coherent_dma_mask = ~0UL, ++ }, ++}; ++#endif ++ ++#if 0 ++#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) ++static struct pad_desc mxc_i2c0_pins[] = { ++ /* ++ * it seems the data line misses a pullup, so we must enable ++ * the internal pullup as a local workaround ++ */ ++ MX25_PAD_I2C1_CLK__I2C1_CLK, ++ MX25_PAD_I2C1_DAT__I2C1_DAT, ++}; ++ ++static int karo_tx25_i2c_0_init(struct device *dev) ++{ ++ DBG(-1, "%s: \n", __FUNCTION__); ++ return mxc_iomux_v3_setup_multiple_pads(mxc_i2c0_pins, ++ ARRAY_SIZE(mxc_i2c0_pins)); ++} ++ ++static void karo_tx25_i2c_0_exit(struct device *dev) ++{ ++ DBG(-1, "%s: \n", __FUNCTION__); ++ mxc_iomux_v3_release_multiple_pads(mxc_i2c0_pins, ++ ARRAY_SIZE(mxc_i2c0_pins)); ++} ++ ++static struct imxi2c_platform_data karo_tx25_i2c_0_data = { ++ .bitrate = 100000, ++ .init = karo_tx25_i2c_0_init, ++ .exit = karo_tx25_i2c_0_exit, ++}; ++ ++static struct at24_platform_data karo_tx25_eeprom = { ++ .byte_len = 2048, ++ .page_size = 32, ++ .flags = AT24_FLAG_ADDR16 | AT24_FLAG_TAKE8ADDR, ++}; ++ ++static struct i2c_board_info karo_i2c_0_boardinfo[] __initdata = { ++ { ++ I2C_BOARD_INFO("24c16", 0x50), ++ .platform_data = &karo_tx25_eeprom, ++ .type = "24c16", ++ }, ++}; ++ ++int __init karo_i2c_init(void) ++{ ++ int ret; ++ ++ DBG(0, "%s: Registering I2C bus 0\n", __FUNCTION__); ++ ret = mxc_register_device(&mx25_i2c_device0, &karo_tx25_i2c_0_data); ++ if (ret != 0) { ++ printk(KERN_ERR "Failed to register I2C device: %d\n", ret); ++ return ret; ++ } ++ ret = i2c_register_board_info(0, karo_i2c_0_boardinfo, ++ ARRAY_SIZE(karo_i2c_0_boardinfo)); ++ if (ret != 0) { ++ printk(KERN_ERR "Failed to register I2C board info: %d\n", ret); ++ } ++ return ret; ++} ++device_initcall(karo_i2c_init); ++#endif ++#endif ++ ++struct platform_dev_list { ++ struct platform_device *pdev; ++ int flag; ++} tx25_devices[] __initdata = { ++#if defined(CONFIG_RTC_MXC) || defined(CONFIG_RTC_MXC_MODULE) ++ { .pdev = &mxc_rtc_device, .flag = -1, }, ++#endif ++#if defined(CONFIG_MTD_NAND_MXC) || defined(CONFIG_MTD_NAND_MXC_MODULE) ++ { .pdev = &tx25_nand_mtd_device, .flag = 1, }, ++#endif ++#if defined(CONFIG_FEC) || defined(CONFIG_FEC_MODULE) ++ { .pdev = &fec_device, .flag = 1, }, ++#endif ++#if defined(CONFIG_SPI_MXC) || defined(CONFIG_SPI_MXC_MODULE) ++ { .pdev = &mxcspi1_device, .flag = 1, }, ++#endif ++#if defined(CONFIG_VIDEO_MXC_EMMA_OUTPUT) || defined(CONFIG_VIDEO_MXC_EMMA_OUTPUT_MODULE) ++ { .pdev = &tx25_v4l2out_device, .flag = 1, }, ++#endif ++#if defined(CONFIG_MXC_VPU) || defined(CONFIG_MXC_VPU_MODULE) ++ { .pdev = &mxc_vpu_device, .flag = 1, }, ++#endif ++}; ++#define TX25_NUM_DEVICES ARRAY_SIZE(tx25_devices) ++ ++static __init void karo_tx25_board_init(void) ++{ ++ int i; ++ ++ DBG(0, "%s: \n", __FUNCTION__); ++ ++ dump_regs(); ++ ++ for (i = 0; i < TX25_NUM_DEVICES; i++) { ++ int ret; ++ ++ if (tx25_devices[i].pdev == NULL) continue; ++ if (!tx25_devices[i].flag) { ++ DBG(0, "%s: Skipping platform device[%d] @ %p dev %p: %s\n", ++ __FUNCTION__, i, tx25_devices[i].pdev, &tx25_devices[i].pdev->dev, ++ tx25_devices[i].pdev->name); ++ continue; ++ } ++ DBG(0, "%s: Registering platform device[%d] @ %p dev %p: %s\n", ++ __FUNCTION__, i, tx25_devices[i].pdev, &tx25_devices[i].pdev->dev, ++ tx25_devices[i].pdev->name); ++ ret = platform_device_register(tx25_devices[i].pdev); ++ if (ret) { ++ printk(KERN_WARNING "%s: Failed to register platform_device[%d]: %s: %d\n", ++ __FUNCTION__, i, tx25_devices[i].pdev->name, ret); ++ } ++ } ++ DBG(0, "%s: Done\n", __FUNCTION__); ++} ++ ++static struct pad_desc karo_tx25_gpios[] __initdata = { ++ MX25_PAD_GPIO_A__GPIO_A, ++ MX25_PAD_GPIO_B__GPIO_B, ++ MX25_PAD_GPIO_C__GPIO_C, ++ MX25_PAD_GPIO_D__GPIO_D, ++ MX25_PAD_GPIO_E__GPIO_E, ++ MX25_PAD_GPIO_F__GPIO_F, ++ MX25_PAD_CSI_D7__GPIO_1_6, ++ MX25_PAD_CSI_D8__GPIO_1_7, ++ MX25_PAD_CSI_MCLK__GPIO_1_8, ++ MX25_PAD_CSI_VSYNC__GPIO_1_9, ++ MX25_PAD_CSI_HSYNC__GPIO_1_10, ++ MX25_PAD_CSI_PIXCLK__GPIO_1_11, ++ MX25_PAD_I2C1_CLK__GPIO_1_12, ++ MX25_PAD_I2C1_DAT__GPIO_1_13, ++ MX25_PAD_CSPI1_MOSI__GPIO_1_14, ++ MX25_PAD_CSPI1_MISO__GPIO_1_15, ++ MX25_PAD_CSPI1_SS0__GPIO_1_16, ++ MX25_PAD_CSPI1_SS1__GPIO_1_17, ++ MX25_PAD_CSPI1_SCLK__GPIO_1_18, ++ MX25_PAD_LD5__GPIO_1_19, ++ MX25_PAD_LD6__GPIO_1_20, ++ MX25_PAD_LD7__GPIO_1_21, ++ MX25_PAD_HSYNC__GPIO_1_22, ++ MX25_PAD_VSYNC__GPIO_1_23, ++ MX25_PAD_LSCLK__GPIO_1_24, ++ MX25_PAD_OE_ACD__GPIO_1_25, ++ MX25_PAD_PWM__GPIO_1_26, ++ MX25_PAD_CSI_D2__GPIO_1_27, ++ MX25_PAD_CSI_D3__GPIO_1_28, ++ MX25_PAD_CSI_D4__GPIO_1_29, ++ MX25_PAD_CSI_D5__GPIO_1_30, ++ MX25_PAD_CSI_D6__GPIO_1_31, ++ ++ MX25_PAD_A14__GPIO_2_0, ++ MX25_PAD_A15__GPIO_2_1, ++ MX25_PAD_A16__GPIO_2_2, ++ MX25_PAD_A17__GPIO_2_3, ++ MX25_PAD_A18__GPIO_2_4, ++ MX25_PAD_A19__GPIO_2_5, ++ MX25_PAD_A20__GPIO_2_6, ++ MX25_PAD_A21__GPIO_2_7, ++ MX25_PAD_A22__GPIO_2_8, ++ MX25_PAD_A23__GPIO_2_9, ++ MX25_PAD_A24__GPIO_2_10, ++ MX25_PAD_A25__GPIO_2_11, ++ MX25_PAD_EB0__GPIO_2_12, ++ MX25_PAD_EB1__GPIO_2_13, ++ MX25_PAD_OE__GPIO_2_14, ++ MX25_PAD_LD0__GPIO_2_15, ++ MX25_PAD_LD1__GPIO_2_16, ++ MX25_PAD_LD2__GPIO_2_17, ++ MX25_PAD_LD3__GPIO_2_18, ++ MX25_PAD_LD4__GPIO_2_19, ++ MX25_PAD_DE_B__GPIO_2_20, ++ MX25_PAD_CLKO__GPIO_2_21, ++ MX25_PAD_CSPI1_RDY__GPIO_2_22, ++ MX25_PAD_SD1_CMD__GPIO_2_23, ++ MX25_PAD_SD1_CLK__GPIO_2_24, ++ MX25_PAD_SD1_DATA0__GPIO_2_25, ++ MX25_PAD_SD1_DATA1__GPIO_2_26, ++ MX25_PAD_SD1_DATA2__GPIO_2_27, ++ MX25_PAD_SD1_DATA3__GPIO_2_28, ++ MX25_PAD_KPP_ROW0__GPIO_2_29, ++ MX25_PAD_KPP_ROW1__GPIO_2_30, ++ MX25_PAD_KPP_ROW2__GPIO_2_31, ++ ++ MX25_PAD_KPP_ROW3__GPIO_3_0, ++ MX25_PAD_KPP_COL0__GPIO_3_1, ++ MX25_PAD_KPP_COL1__GPIO_3_2, ++ MX25_PAD_KPP_COL2__GPIO_3_3, ++ MX25_PAD_KPP_COL3__GPIO_3_4, ++ MX25_PAD_FEC_MDC__GPIO_3_5, ++ MX25_PAD_FEC_MDIO__GPIO_3_6, ++ MX25_PAD_FEC_TDATA0__GPIO_3_7, ++ MX25_PAD_FEC_TDATA1__GPIO_3_8, ++ MX25_PAD_FEC_TX_EN__GPIO_3_9, ++ MX25_PAD_FEC_RDATA0__GPIO_3_10, ++ MX25_PAD_FEC_RDATA1__GPIO_3_11, ++ MX25_PAD_FEC_RX_DV__GPIO_3_12, ++ MX25_PAD_FEC_TX_CLK__GPIO_3_13, ++ MX25_PAD_RTCK__GPIO_3_14, ++ MX25_PAD_EXT_ARMCLK__GPIO_3_15, ++ MX25_PAD_UPLL_BYPCLK__GPIO_3_16, ++ MX25_PAD_VSTBY_REQ__GPIO_3_17, ++ MX25_PAD_VSTBY_ACK__GPIO_3_18, ++ MX25_PAD_POWER_FAIL__GPIO_3_19, ++ MX25_PAD_CS4__GPIO_3_20, ++ MX25_PAD_CS5__GPIO_3_21, ++ MX25_PAD_NF_CE0__GPIO_3_22, ++ MX25_PAD_ECB__GPIO_3_23, ++ MX25_PAD_LBA__GPIO_3_24, ++ MX25_PAD_RW__GPIO_3_25, ++ MX25_PAD_NFWE_B__GPIO_3_26, ++ MX25_PAD_NFRE_B__GPIO_3_27, ++ MX25_PAD_NFALE__GPIO_3_28, ++ MX25_PAD_NFCLE__GPIO_3_29, ++ MX25_PAD_NFWP_B__GPIO_3_30, ++ MX25_PAD_NFRB__GPIO_3_31, ++ ++ MX25_PAD_A10__GPIO_4_0, ++ MX25_PAD_A13__GPIO_4_1, ++ MX25_PAD_CS0__GPIO_4_2, ++ MX25_PAD_CS1__GPIO_4_3, ++ MX25_PAD_BCLK__GPIO_4_4, ++ MX25_PAD_D15__GPIO_4_5, ++ MX25_PAD_D14__GPIO_4_6, ++ MX25_PAD_D13__GPIO_4_7, ++ MX25_PAD_D12__GPIO_4_8, ++ MX25_PAD_D11__GPIO_4_9, ++ MX25_PAD_D10__GPIO_4_10, ++ MX25_PAD_D9__GPIO_4_11, ++ MX25_PAD_D8__GPIO_4_12, ++ MX25_PAD_D7__GPIO_4_13, ++ MX25_PAD_D6__GPIO_4_14, ++ MX25_PAD_D5__GPIO_4_15, ++ MX25_PAD_D4__GPIO_4_16, ++ MX25_PAD_D3__GPIO_4_17, ++ MX25_PAD_D2__GPIO_4_18, ++ MX25_PAD_D1__GPIO_4_19, ++ MX25_PAD_D0__GPIO_4_20, ++ MX25_PAD_CSI_D9__GPIO_4_21, ++ MX25_PAD_UART1_RXD__GPIO_4_22, ++ MX25_PAD_UART1_TXD__GPIO_4_23, ++ MX25_PAD_UART1_RTS__GPIO_4_24, ++ MX25_PAD_UART1_CTS__GPIO_4_25, ++ MX25_PAD_UART2_RXD__GPIO_4_26, ++ MX25_PAD_UART2_TXD__GPIO_4_27, ++ MX25_PAD_UART2_RTS__GPIO_4_28, ++ MX25_PAD_UART2_CTS__GPIO_4_29, ++ MX25_PAD_BOOT_MODE0__GPIO_4_30, ++ MX25_PAD_BOOT_MODE1__GPIO_4_31, ++}; ++ ++static int __init karo_tx25_setup_gpios(void) ++{ ++ int i; ++ int ret; ++ int count = 0; ++ ++ for (i = 0; i < ARRAY_SIZE(karo_tx25_gpios); i++) { ++ struct pad_desc *pd = &karo_tx25_gpios[i]; ++#if 0 ++ if (i - 64 >= 16 && i - 64 < 32) { ++ continue; ++ } ++#endif ++ ret = mxc_iomux_v3_setup_pad(pd); ++ if (ret == 0) { ++#ifdef IOMUX_DEBUG ++ DBG(0, "%s: PAD[%d] %s set up as GPIO\n", __FUNCTION__, i, pd->name); ++#else ++ DBG(0, "%s: PAD[%d] set up as GPIO\n", __FUNCTION__, i); ++#endif ++ count++; ++ mxc_iomux_v3_release_pad(pd); ++ } else { ++#ifdef IOMUX_DEBUG ++ DBG(0, "%s: PAD[%d] %s skipped\n", __FUNCTION__, i, pd->name); ++#else ++ DBG(0, "%s: PAD[%d] skipped\n", __FUNCTION__, i); ++#endif ++ } ++ } ++ DBG(0, "%s: %d out of %d pins set up as GPIO\n", __FUNCTION__, count, i); ++#if 0 ++ if (gpio_request(42, "TEST") == 0) { ++ gpio_direction_output(42, 1); ++ while (1) { ++ gpio_set_value(42, 0); ++ if (gpio_get_value(42)) { ++ DBG(0, "%s: GPIO 42 is HIGH instead of LOW\n", __FUNCTION__); ++ } ++ msleep(1000); ++ gpio_set_value(42, 1); ++ if (!gpio_get_value(42)) { ++ DBG(0, "%s: GPIO 42 is LOW instead of HIGH\n", __FUNCTION__); ++ } ++ msleep(1000); ++ } ++ } ++ gpio_free(42); ++#endif ++ return 0; ++} ++late_initcall(karo_tx25_setup_gpios); ++ ++static void __init karo_tx25_map_io(void) ++{ ++ mx25_map_io(); ++} ++ ++static void __init karo_tx25_fixup(struct machine_desc *desc, struct tag *tags, ++ char **cmdline, struct meminfo *mi) ++{ ++} ++ ++static void __init karo_tx25_timer_init(void) ++{ ++ DBG(0, "%s: \n", __FUNCTION__); ++ mx25_clocks_init(24000000); ++ DBG(0, "%s: Done\n", __FUNCTION__); ++} ++ ++struct sys_timer karo_tx25_timer = { ++ .init = karo_tx25_timer_init, ++}; ++ ++static int __init karo_mod_type_setup(char *line) ++{ ++ get_option(&line, &karo_mod_type); ++ DBG(0, "%s: Module type set to 0x%02x by kernel cmd line\n", __FUNCTION__, karo_mod_type); ++ ++ return 1; ++} ++__setup("module_type=", karo_mod_type_setup); ++ ++static int __init karo_board_type_setup(char *line) ++{ ++ get_option(&line, &karo_board_type); ++ DBG(0, "%s: Board type set to 0x%02x by kernel cmd line\n", __FUNCTION__, karo_board_type); ++ ++ return 1; ++} ++__setup("board_type=", karo_board_type_setup); ++ ++MACHINE_START(TX25, "Ka-Ro electronics TX25 module (Freescale i.MX25)") ++ /* Maintainer: */ ++ .phys_io = AIPS1_BASE_ADDR, ++ .io_pg_offst = ((unsigned long)AIPS1_BASE_ADDR_VIRT >> 18) & 0xfffc, ++ .fixup = karo_tx25_fixup, ++ .map_io = karo_tx25_map_io, ++ .init_irq = mxc_init_irq, ++ .init_machine = karo_tx25_board_init, ++ .timer = &karo_tx25_timer, ++MACHINE_END +diff -urNp linux-2.6.30-rc4/arch/arm/mach-mx2/karo.h linux-2.6.30-rc4-karo/arch/arm/mach-mx2/karo.h +--- linux-2.6.30-rc4/arch/arm/mach-mx2/karo.h 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/arch/arm/mach-mx2/karo.h 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,99 @@ ++/* ++ * arch/arm/mach-mx2/karo.h ++ * ++ * Copyright (C) 2009 Lothar Wassmann ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * version 2 as published by the Free Software Foundation ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the: ++ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 ++ * ++ * This file provides platform specific definitions for the ++ * Ka-Ro electronics TX25 processor modules ++ */ ++ ++#include ++#include "crm_regs_mx25.h" ++ ++enum { ++ BOARD_KARO_STK5, ++}; ++ ++extern int karo_board_type; ++extern int karo_mod_type; ++ ++#ifdef DEBUG ++extern int tx25_debug; ++#define dbg_lvl(n) ((n) < tx25_debug) ++#define DBG(lvl, fmt...) do { if (dbg_lvl(lvl)) printk(KERN_DEBUG fmt); } while (0) ++#else ++#define dbg_lvl(n) 0 ++#define DBG(lvl, fmt...) do { } while (0) ++#endif ++ ++static inline int karo_get_board_type(void) ++{ ++ return karo_board_type; ++} ++ ++static inline int karo_get_module_type(void) ++{ ++ return karo_mod_type; ++} ++ ++#define SHOW_REG(reg) DBG(0, "%s[%08lx]=%08x\n", #reg, MXC_PHYS_ADDRESS(reg), __raw_readl(reg)) ++ ++#define SHOW_GPIO_REG(port, reg) \ ++ DBG(0, "GPIO%d_%s[%08lx]=%08x\n", port, #reg, \ ++ GPIO_BASE_ADDR(port) + GPIO_##reg, \ ++ __raw_readl(IO_ADDRESS(GPIO_BASE_ADDR(port) + GPIO_##reg))) ++ ++static inline void dump_regs(void) ++{ ++ int i; ++ ++ SHOW_REG(MXC_CCM_MPCTL); ++ SHOW_REG(MXC_CCM_UPCTL); ++ SHOW_REG(MXC_CCM_CCTL); ++ SHOW_REG(MXC_CCM_RCSR); ++ SHOW_REG(MXC_CCM_CRDR); ++ SHOW_REG(MXC_CCM_PCDR0); ++ SHOW_REG(MXC_CCM_PCDR1); ++ SHOW_REG(MXC_CCM_PCDR2); ++ SHOW_REG(MXC_CCM_PCDR3); ++ SHOW_REG(MXC_CCM_CGCR0); ++ SHOW_REG(MXC_CCM_CGCR1); ++ SHOW_REG(MXC_CCM_CGCR2); ++ SHOW_REG(MXC_CCM_MCR); ++ SHOW_REG(MXC_CCM_PMCR0); ++ SHOW_REG(MXC_CCM_PMCR1); ++ SHOW_REG(MXC_CCM_PMCR2); ++ SHOW_REG(MXC_CCM_LTBR0); ++ SHOW_REG(MXC_CCM_LTBR1); ++ SHOW_REG(MXC_CCM_LTR0); ++ SHOW_REG(MXC_CCM_LTR1); ++ SHOW_REG(MXC_CCM_LTR2); ++ SHOW_REG(MXC_CCM_LTR3); ++ SHOW_REG(MXC_CCM_DCVR0); ++ SHOW_REG(MXC_CCM_DCVR1); ++ SHOW_REG(MXC_CCM_DCVR2); ++ SHOW_REG(MXC_CCM_DCVR3); ++ ++ for (i = 1; i <= 4; i++) { ++ SHOW_GPIO_REG(i, DR); ++ SHOW_GPIO_REG(i, GDIR); ++ SHOW_GPIO_REG(i, PSR); ++ SHOW_GPIO_REG(i, ICR1); ++ SHOW_GPIO_REG(i, ICR2); ++ SHOW_GPIO_REG(i, IMR); ++ SHOW_GPIO_REG(i, ISR); ++ } ++} +diff -urNp linux-2.6.30-rc4/arch/arm/mach-mx2/sdma_script_code.h linux-2.6.30-rc4-karo/arch/arm/mach-mx2/sdma_script_code.h +--- linux-2.6.30-rc4/arch/arm/mach-mx2/sdma_script_code.h 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/arch/arm/mach-mx2/sdma_script_code.h 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,159 @@ ++ ++/* ++ * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved. ++ */ ++ ++/* ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ */ ++ ++/*! ++ * @file sdma_script_code.h ++ * @brief This file contains functions of SDMA scripts code initialization ++ * ++ * The file was generated automatically. Based on sdma scripts library. ++ * ++ * @ingroup SDMA ++ */ ++/************************************************************************ ++ ++ SDMA RELEASE LABEL: "SS15_SENNA" ++ ++************************************************************************/ ++ ++#ifndef SDMA_SCRIPT_CODE_H ++#define SDMA_SCRIPT_CODE_H ++ ++/*! ++ * SDMA ROM scripts start addresses and sizes ++ */ ++#define start_ADDR 0 ++#define start_SIZE 22 ++ ++#define core_ADDR 80 ++#define core_SIZE 233 ++ ++#define common_ADDR 313 ++#define common_SIZE 416 ++ ++#define ap_2_ap_ADDR 729 ++#define ap_2_ap_SIZE 41 ++ ++#define app_2_mcu_ADDR 770 ++#define app_2_mcu_SIZE 64 ++ ++#define mcu_2_app_ADDR 834 ++#define mcu_2_app_SIZE 70 ++ ++#define uart_2_mcu_ADDR 904 ++#define uart_2_mcu_SIZE 75 ++ ++#define shp_2_mcu_ADDR 979 ++#define shp_2_mcu_SIZE 69 ++ ++#define mcu_2_shp_ADDR 1048 ++#define mcu_2_shp_SIZE 72 ++ ++#define uartsh_2_mcu_ADDR 1120 ++#define uartsh_2_mcu_SIZE 69 ++ ++#define app_2_per_ADDR 1189 ++#define app_2_per_SIZE 66 ++ ++#define per_2_app_ADDR 1255 ++#define per_2_app_SIZE 74 ++ ++#define per_2_shp_ADDR 1329 ++#define per_2_shp_SIZE 78 ++ ++#define shp_2_per_ADDR 1407 ++#define shp_2_per_SIZE 72 ++ ++#define mcu_2_ata_ADDR 1479 ++#define mcu_2_ata_SIZE 81 ++ ++#define ata_2_mcu_ADDR 1560 ++#define ata_2_mcu_SIZE 96 ++ ++#define loop_DMAs_routines_ADDR 1656 ++#define loop_DMAs_routines_SIZE 227 ++ ++#define test_ADDR 1883 ++#define test_SIZE 63 ++ ++#define signature_ADDR 1022 ++#define signature_SIZE 1 ++ ++/*! ++ * SDMA RAM scripts start addresses and sizes ++ */ ++#define ext_mem__ipu_ram_ADDR 6144 ++#define ext_mem__ipu_ram_SIZE 123 ++ ++#define uart_2_per_ADDR 6267 ++#define uart_2_per_SIZE 73 ++ ++#define uartsh_2_per_ADDR 6340 ++#define uartsh_2_per_SIZE 67 ++ ++/*! ++ * SDMA RAM image start address and size ++ */ ++#define RAM_CODE_START_ADDR 6144 ++#define RAM_CODE_SIZE 263 ++ ++/*! ++ * Buffer that holds the SDMA RAM image ++ */ ++__attribute__ ((__aligned__(4))) ++#ifndef CONFIG_XIP_KERNEL ++const ++#endif ++static const short sdma_code[] = { ++ 0x0e70, 0x0611, 0x5616, 0xc18a, 0x7d2a, 0x5ade, 0x008e, 0xc19c, ++ 0x7c26, 0x5be0, 0x5ef0, 0x5ce8, 0x0688, 0x08ff, 0x0011, 0x28ff, ++ 0x00bc, 0x53f6, 0x05df, 0x7d0b, 0x6dc5, 0x03df, 0x7d03, 0x6bd5, ++ 0xd84f, 0x982b, 0x6b05, 0xc6d8, 0x7e27, 0x7f29, 0x982b, 0x6d01, ++ 0x03df, 0x7d05, 0x6bd5, 0xc702, 0x7e18, 0x7f1a, 0x982b, 0x6b05, ++ 0xc678, 0x7e07, 0x7f06, 0x52de, 0x53e6, 0xc1a8, 0x7dd7, 0x0200, ++ 0x9803, 0x0007, 0x6004, 0x680c, 0x53f6, 0x028e, 0x00a3, 0xc2ad, ++ 0x048b, 0x0498, 0x0454, 0x068a, 0x982b, 0x0207, 0x680c, 0x6ddf, ++ 0x0107, 0x68ff, 0x60d0, 0x9834, 0x0207, 0x68ff, 0x6d28, 0x0107, ++ 0x6004, 0x680c, 0x9834, 0x0007, 0x68ff, 0x60d0, 0x9834, 0x0288, ++ 0x03a5, 0x3b03, 0x3d03, 0x4d00, 0x7d0a, 0x0804, 0x00a5, 0x00da, ++ 0x7d1a, 0x02a0, 0x7b01, 0x65d8, 0x7eee, 0x65ff, 0x7eec, 0x0804, ++ 0x02d0, 0x7d11, 0x4b00, 0x7c0f, 0x008a, 0x3003, 0x6dcf, 0x6bdf, ++ 0x0015, 0x0015, 0x7b02, 0x65d8, 0x0000, 0x7edd, 0x63ff, 0x7edb, ++ 0x3a03, 0x6dcd, 0x6bdd, 0x008a, 0x7b02, 0x65d8, 0x0000, 0x7ed3, ++ 0x65ff, 0x7ed1, 0x0006, 0xc23a, 0x57db, 0x52f3, 0x6ad5, 0x56fb, ++ 0x028e, 0x1a94, 0x6ac3, 0x62c8, 0x0269, 0x7d1e, 0x1e94, 0x6ee3, ++ 0x62d0, 0x5aeb, 0x62c8, 0x0248, 0x6ed3, 0x6ac8, 0x2694, 0x52eb, ++ 0x6ad5, 0x6ee3, 0x62c8, 0x026e, 0x7d27, 0x6ac8, 0x7f23, 0x2501, ++ 0x4d00, 0x7d26, 0x028e, 0x1a98, 0x6ac3, 0x62c8, 0x6ec3, 0x0260, ++ 0x7df1, 0x62d0, 0xc2d1, 0x98c0, 0x6ee3, 0x008f, 0x2001, 0x00d5, ++ 0x7d01, 0x008d, 0x05a0, 0x62c8, 0x026e, 0x7d0e, 0x6ac8, 0x7f0a, ++ 0x2001, 0x7cf9, 0x6add, 0x7f06, 0x0000, 0x4d00, 0x7d09, 0xc251, ++ 0x57db, 0x987f, 0x0007, 0x6aff, 0x62d0, 0xc2d1, 0x0458, 0x0454, ++ 0x6add, 0x7ff8, 0xc261, 0x987c, 0xc230, 0xc23a, 0x57db, 0x52f3, ++ 0x6ad5, 0x56fb, 0x028e, 0x1a94, 0x5202, 0x0269, 0x7d17, 0x1e94, ++ 0x5206, 0x0248, 0x5a06, 0x2694, 0x5206, 0x026e, 0x7d26, 0x6ac8, ++ 0x7f22, 0x2501, 0x4d00, 0x7d27, 0x028e, 0x1a98, 0x5202, 0x0260, ++ 0x7df3, 0x6add, 0x7f18, 0x62d0, 0xc2d1, 0x9903, 0x008f, 0x2001, ++ 0x00d5, 0x7d01, 0x008d, 0x05a0, 0x5206, 0x026e, 0x7d0e, 0x6ac8, ++ 0x7f0a, 0x2001, 0x7cf9, 0x6add, 0x7f06, 0x0000, 0x4d00, 0x7d0b, ++ 0xc251, 0x57db, 0x98c9, 0x0007, 0x6aff, 0x6add, 0x7ffc, 0x62d0, ++ 0xc2d1, 0x0458, 0x0454, 0x6add, 0x7ff6, 0xc261, 0x98c6 ++}; ++#endif +diff -urNp linux-2.6.30-rc4/arch/arm/mach-mx2/stk5-baseboard.c linux-2.6.30-rc4-karo/arch/arm/mach-mx2/stk5-baseboard.c +--- linux-2.6.30-rc4/arch/arm/mach-mx2/stk5-baseboard.c 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/arch/arm/mach-mx2/stk5-baseboard.c 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,1003 @@ ++/* ++ * arch/arm/mach-mx2/stk5-baseboard.c ++ * ++ * Copyright (C) 2009 Lothar Wassmann ++ * ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * version 2 as published by the Free Software Foundation ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the: ++ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 ++ * ++ * This file adds support for devices found on Ka-Ro electronics ++ * Starterkit-5 (STK5) baseboard ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++//#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++//#include ++#include ++#include ++#include ++//#include ++//#include ++#include ++ ++#include "crm_regs.h" ++#include "devices.h" ++#include "karo.h" ++ ++#if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE) ++static struct pad_desc stk5_uart_pads[][4] = { ++ { ++ MX25_PAD_UART1_TXD__UART1_TXD, ++ MX25_PAD_UART1_RXD__UART1_RXD, ++ MX25_PAD_UART1_CTS__UART1_CTS, ++ MX25_PAD_UART1_RTS__UART1_RTS, ++ }, { ++ MX25_PAD_UART2_TXD__UART2_TXD, ++ MX25_PAD_UART2_RXD__UART2_RXD, ++ MX25_PAD_UART2_CTS__UART2_CTS, ++ MX25_PAD_UART2_RTS__UART2_RTS, ++ }, { ++ MX25_PAD_ECB__UART5_TXD_MUX, ++ MX25_PAD_LBA__UART5_RXD_MUX, ++ MX25_PAD_CS4__UART5_CTS, ++ MX25_PAD_CS5__UART5_RTS, ++#if 0 ++ }, { ++ MX25_PAD_UART4_TXD__UART4_TXD, ++ MX25_PAD_UART4_RXD__UART4_RXD, ++ MX25_PAD_UART4_CTS__UART4_CTS, ++ MX25_PAD_UART4_RTS__UART4_RTS, ++ }, { ++ MX25_PAD_UART5_TXD__UART5_TXD, ++ MX25_PAD_UART5_RXD__UART5_RXD, ++ MX25_PAD_UART5_CTS__UART5_CTS, ++ MX25_PAD_UART5_RTS__UART5_RTS, ++#endif ++ }, ++}; ++ ++static int stk5_uart_init(struct platform_device *pdev) ++{ ++ DBG(0, "%s: \n", __FUNCTION__); ++ return mxc_iomux_v3_setup_multiple_pads(stk5_uart_pads[pdev->id], ++ ARRAY_SIZE(stk5_uart_pads[pdev->id])); ++} ++ ++static void stk5_uart_exit(struct platform_device *pdev) ++{ ++ DBG(0, "%s: \n", __FUNCTION__); ++ mxc_iomux_v3_release_multiple_pads(stk5_uart_pads[pdev->id], ++ ARRAY_SIZE(stk5_uart_pads[pdev->id])); ++} ++ ++static struct imxuart_platform_data stk5_uart_ports[] = { ++ { ++ .init = stk5_uart_init, ++ .exit = stk5_uart_exit, ++ .flags = IMXUART_HAVE_RTSCTS, ++ }, { ++ .init = stk5_uart_init, ++ .exit = stk5_uart_exit, ++ .flags = IMXUART_HAVE_RTSCTS, ++ }, { ++ .init = stk5_uart_init, ++ .exit = stk5_uart_exit, ++ .flags = IMXUART_HAVE_RTSCTS, ++ }, { ++ .init = stk5_uart_init, ++ .exit = stk5_uart_exit, ++ .flags = IMXUART_HAVE_RTSCTS, ++ }, { ++ .init = stk5_uart_init, ++ .exit = stk5_uart_exit, ++ .flags = IMXUART_HAVE_RTSCTS, ++ }, { ++ .init = stk5_uart_init, ++ .exit = stk5_uart_exit, ++ .flags = IMXUART_HAVE_RTSCTS, ++ }, ++}; ++ ++static struct platform_device *stk5_uart_devices[] = { ++#if UART1_ENABLED ++ &mxc_uart_device0, ++#endif ++#if UART2_ENABLED ++ &mxc_uart_device1, ++#endif ++#if UART3_ENABLED ++ &mxc_uart_device2, ++#endif ++#if UART4_ENABLED ++ &mxc_uart_device3, ++#endif ++#if UART5_ENABLED ++ &mxc_uart_device4, ++#endif ++}; ++ ++static void __init karo_stk5_serial_init(void) ++{ ++ int i; ++ ++ for (i = 0; i < ARRAY_SIZE(stk5_uart_devices); i++) { ++ int ret; ++ int port = stk5_uart_devices[i]->id; ++ ++ DBG(0, "%s: Registering platform device[%d] @ %p dev %p: %s\n", ++ __FUNCTION__, i, stk5_uart_devices[i], ++ &stk5_uart_devices[i]->dev, stk5_uart_devices[i]->name); ++ ret = mxc_register_device(stk5_uart_devices[i], ++ &stk5_uart_ports[port]); ++ if (ret != 0) { ++ printk(KERN_WARNING "%s: Failed to register platform_device[%d]: %s: %d\n", ++ __FUNCTION__, i, stk5_uart_devices[i]->name, ret); ++ } ++ } ++} ++#else ++static void __init karo_stk5_serial_init(void) ++{ ++} ++#endif ++ ++#ifdef CONFIG_USB_EHCI_MXC ++ ++#define SMSC_VENDOR_ID 0x0424 ++#define USB3317_PROD_ID 0x0006 ++#define ULPI_FCTL 7 ++ ++static inline const char *ulpi_name(void __iomem *view) ++{ ++ if ((unsigned long)view & 0x400) { ++ return "USBH2"; ++ } else { ++ return "USBOTG"; ++ } ++} ++ ++static int usb3317_init(void __iomem *view) ++{ ++ int vid, pid, ret; ++ ++ ret = ulpi_read(ISP1504_VID_HIGH, view); ++ if (ret < 0) { ++ goto err; ++ } ++ vid = ret << 8; ++ ++ ret = ulpi_read(ISP1504_VID_LOW, view); ++ if (ret < 0) { ++ goto err; ++ } ++ vid |= ret; ++ ++ ret = ulpi_read(ISP1504_PID_HIGH, view); ++ if (ret < 0) { ++ goto err; ++ } ++ pid = ret << 8; ++ ++ ret = ulpi_read(ISP1504_PID_LOW, view); ++ if (ret < 0) { ++ goto err; ++ } ++ pid |= ret; ++ ++ pr_info("ULPI on %s port Vendor ID 0x%x Product ID 0x%x\n", ++ ulpi_name(view), vid, pid); ++ if (vid != SMSC_VENDOR_ID || pid != USB3317_PROD_ID) { ++ pr_err("No USB3317 found\n"); ++ return -ENODEV; ++ } ++ err: ++ if (ret < 0) { ++ printk(KERN_ERR "ULPI read on %s port failed with error %d\n", ++ ulpi_name(view), ret); ++ return ret; ++ } ++ return 0; ++} ++ ++static int usb3317_set_vbus_power(void __iomem *view, int on) ++{ ++ int ret; ++ ++ DBG(0, "%s: Switching %s port VBUS power %s\n", __FUNCTION__, ++ ulpi_name(view), on ? "on" : "off"); ++ ++ if (on) { ++ ret = ulpi_set(DRV_VBUS_EXT | /* enable external Vbus */ ++ DRV_VBUS | /* enable internal Vbus */ ++ CHRG_VBUS, /* charge Vbus */ ++ ISP1504_OTGCTL, view); ++ } else { ++ ret = ulpi_clear(DRV_VBUS_EXT | /* disable external Vbus */ ++ DRV_VBUS, /* disable internal Vbus */ ++ ISP1504_OTGCTL, view); ++ if (ret == 0) { ++ ret = ulpi_set(DISCHRG_VBUS, /* discharge Vbus */ ++ ISP1504_OTGCTL, view); ++ } ++ } ++ if (ret < 0) { ++ printk(KERN_ERR "ULPI read on %s port failed with error %d\n", ++ ulpi_name(view), ret); ++ return ret; ++ } ++ return 0; ++} ++ ++static int stk5_usbh2_init(struct platform_device *pdev) ++{ ++ int ret; ++ u32 temp; ++ unsigned long flags; ++ void __iomem *view = IO_ADDRESS(OTG_BASE_ADDR + 0x570); ++ ++ local_irq_save(flags); ++ temp = readl(IO_ADDRESS(OTG_BASE_ADDR) + 0x600); ++ temp &= ~((3 << 21) | (1 << 0)); ++ temp |= (1 << 5) | (1 << 16) | (1 << 19) | (1 << 20); ++ writel(temp, IO_ADDRESS(OTG_BASE_ADDR) + 0x600); ++ local_irq_restore(flags); ++ ++ /* select ULPI transceiver */ ++ /* this must be done _before_ setting up the GPIOs! */ ++ temp = readl(view + 0x14); ++ DBG(0, "%s: Changing USBH2_PORTSC1 from %08x to %08x\n", __FUNCTION__, ++ temp, (temp & ~(3 << 30)) | (2 << 30)); ++ temp &= ~(3 << 30); ++ temp |= 2 << 30; ++ writel(temp, view + 0x14); ++ ++ /* Set to Host mode */ ++ temp = readl(view + 0x38); ++ DBG(0, "%s: Changing USBH2_USBMODE from %08x to %08x\n", __FUNCTION__, ++ temp, temp | 3); ++ writel(temp | 0x3, view + 0x38); ++ ++ ret = gpio_usbh2_active(); ++ if (ret != 0) { ++ return ret; ++ } ++ ++ ret = usb3317_init(view); ++ if (ret != 0) { ++ goto err; ++ } ++ ret = usb3317_set_vbus_power(view, 1); ++ if (ret != 0) { ++ goto err; ++ } ++ return 0; ++ ++ err: ++ gpio_usbh2_inactive(); ++ return ret; ++} ++ ++static int stk5_usbh2_exit(struct platform_device *pdev) ++{ ++ gpio_usbh2_inactive(); ++ return 0; ++} ++ ++static struct mxc_usbh_platform_data stk5_usbh2_data = { ++ .init = stk5_usbh2_init, ++ .exit = stk5_usbh2_exit, ++}; ++ ++static int __init karo_stk5_usbh2_register(void) ++{ ++ int ret; ++ ++ ret = mxc_register_device(&mxc_ehci2, &stk5_usbh2_data); ++ return ret; ++} ++#else ++static inline int karo_stk5_usbh2_register(void) ++{ ++ return 0; ++} ++#endif // CONFIG_USB_EHCI_MXC ++ ++#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) ++static struct gpio_led stk5_leds[] = { ++ { ++ .name = "GPIO-LED", ++ .default_trigger = "heartbeat", ++ .gpio = GPIO_PORTB | 7, ++ }, ++}; ++ ++static struct gpio_led_platform_data stk5_led_data = { ++ .leds = stk5_leds, ++ .num_leds = ARRAY_SIZE(stk5_leds), ++}; ++ ++static struct platform_device stk5_led_device = { ++ .name = "leds-gpio", ++ .id = -1, ++ .dev = { ++ .platform_data = &stk5_led_data, ++ }, ++}; ++#endif ++ ++#if defined(CONFIG_KEYBOARD_MXC) || defined(CONFIG_KEYBOARD_MXC_MODULE) ++/*! ++ * This array is used for mapping mx25 ADS keypad scancodes to input keyboard ++ * keycodes. ++ */ ++static u16 stk5_kpd_keycodes[] = { ++ KEY_POWER, ++}; ++ ++static struct keypad_data stk5_keypad = { ++ .rowmax = 1, ++ .colmax = 1, ++ .irq = MXC_INT_KPP, ++ .learning = 0, ++ //.delay = 2, /* unused in the driver! */ ++ .matrix = stk5_kpd_keycodes, ++}; ++ ++static struct resource stk5_kpp_resources[] = { ++ { ++ .start = MXC_INT_KPP, ++ .end = MXC_INT_KPP, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++/* stk5 keypad driver */ ++static struct platform_device stk5_keypad_device = { ++ .name = "mxc_keypad", ++ .id = 0, ++ .num_resources = ARRAY_SIZE(stk5_kpp_resources), ++ .resource = stk5_kpp_resources, ++ .dev = { ++ .platform_data = &stk5_keypad, ++ }, ++}; ++#endif ++ ++#if defined(CONFIG_FB_IMX) || defined(CONFIG_FB_IMX_MODULE) ++/* ++ * Setup GPIO for LCDC device to be active ++ * ++ */ ++static struct pad_desc mx25_lcdc_gpios[] = { ++#if 0 ++ MXC_PIN(A, 30, GPIO, GPIO_OUT | GPIO_DFLT_LOW), /* PA30 */ ++ MXC_PIN(A, 25, GPIO, GPIO_OUT | GPIO_DFLT_LOW), /* PA25 */ ++ MXC_PIN(A, 26, GPIO, GPIO_OUT | GPIO_DFLT_LOW), /* PA26 */ ++ MXC_PIN(A, 24, GPIO, GPIO_OUT | GPIO_DFLT_LOW), /* PA24 */ ++ MXC_PIN(A, 27, GPIO, GPIO_OUT | GPIO_DFLT_LOW), /* PA27 */ ++#endif ++ MX25_PAD_LSCLK__LSCLK, ++ MX25_PAD_LD0__LD0, ++ MX25_PAD_LD1__LD1, ++ MX25_PAD_LD2__LD2, ++ MX25_PAD_LD3__LD3, ++ MX25_PAD_LD4__LD4, ++ MX25_PAD_LD5__LD5, ++ MX25_PAD_LD6__LD6, ++ MX25_PAD_LD7__LD7, ++ MX25_PAD_LD8__LD8, ++ MX25_PAD_LD9__LD9, ++ MX25_PAD_LD10__LD10, ++ MX25_PAD_LD11__LD11, ++ MX25_PAD_LD12__LD12, ++ MX25_PAD_LD13__LD13, ++ MX25_PAD_LD14__LD14, ++ MX25_PAD_LD15__LD15, ++ MX25_PAD_D15__LD16, ++ MX25_PAD_D14__LD17, ++ MX25_PAD_HSYNC__HSYNC, ++ MX25_PAD_VSYNC__VSYNC, ++ MX25_PAD_OE_ACD__OE_ACD, ++}; ++ ++static int stk5_gpio_lcdc_active(struct platform_device *dev) ++{ ++ int ret; ++ ++ DBG(0, "%s: Setting up GPIO pins for LCD\n", __FUNCTION__); ++ ret = mxc_iomux_v3_setup_multiple_pads(mx25_lcdc_gpios, ++ ARRAY_SIZE(mx25_lcdc_gpios)); ++ if (ret) { ++ DBG(0, "%s: Failed to setup GPIO pins for LCD: %d\n", ++ __FUNCTION__, ret); ++ return ret; ++ } ++ return 0; ++} ++ ++/* ++ * Setup GPIO for LCDC device to be inactive ++ * ++ */ ++static void stk5_gpio_lcdc_inactive(struct platform_device *dev) ++{ ++ mxc_iomux_v3_release_multiple_pads(mx25_lcdc_gpios, ++ ARRAY_SIZE(mx25_lcdc_gpios)); ++} ++ ++static struct imx_fb_platform_data stk5_fb_data[] __initdata = { ++ { ++ //.fb_mode = "Xenarc_700_Y-18", ++ .init = stk5_gpio_lcdc_active, ++ .exit = stk5_gpio_lcdc_inactive, ++ .lcd_power = NULL, ++ .backlight_power = NULL, ++ ++ .pixclock = 34576, ++ .xres = 640, ++ .yres = 480, ++ ++ .bpp = 32, ++ ++ .hsync_len = 64, ++ .right_margin = 60 + 1, ++ .left_margin = 80 + 3, ++ ++ .vsync_len = 2, ++ .upper_margin = 54, ++ .lower_margin = 54, ++#if 0 ++ /* currently not used by driver! */ ++ .sync = ((0*FB_SYNC_HOR_HIGH_ACT) | ++ (0*FB_SYNC_VERT_HIGH_ACT) | ++ (1*FB_SYNC_OE_ACT_HIGH)), ++#else ++ .pcr = PCR_TFT | PCR_COLOR | PCR_PBSIZ_8 | ++ PCR_BPIX_18 | PCR_END_SEL | PCR_FLMPOL | PCR_LPPOL | PCR_SCLK_SEL, ++ .dmacr = 0x800a0078, ++#endif ++ .cmap_greyscale = 0, ++ .cmap_inverse = 0, ++ .cmap_static = 0, ++ ++ .fixed_screen_cpu = NULL, ++ }, { ++ //.fb_mode = "Xenarc_700_Y-16", ++ .init = stk5_gpio_lcdc_active, ++ .exit = stk5_gpio_lcdc_inactive, ++ .lcd_power = NULL, ++ .backlight_power = NULL, ++ ++ .pixclock = 34576, ++ .xres = 640, ++ .yres = 480, ++ ++ .bpp = 16, ++ ++ .hsync_len = 64, ++ .right_margin = 138 + 1, ++ .left_margin = 118 + 3, ++ ++ .vsync_len = 7, ++ .upper_margin = 44, ++ .lower_margin = 44, ++#if 0 ++ /* currently not used by driver! */ ++ .sync = ((0*FB_SYNC_HOR_HIGH_ACT) | ++ (0*FB_SYNC_VERT_HIGH_ACT) | ++ (1*FB_SYNC_OE_ACT_HIGH)), ++#else ++ .pcr = PCR_TFT | PCR_COLOR | PCR_PBSIZ_8 | ++ PCR_BPIX_16 | PCR_FLMPOL | PCR_LPPOL | PCR_SCLK_SEL, ++ .dmacr = 0x80040060, ++#endif ++ .cmap_greyscale = 0, ++ .cmap_inverse = 0, ++ .cmap_static = 0, ++ ++ .fixed_screen_cpu = NULL, ++ }, { ++ //.fb_mode = "SHARP LQ10D42-16", ++ .init = stk5_gpio_lcdc_active, ++ .exit = stk5_gpio_lcdc_inactive, ++ .lcd_power = NULL, ++ .backlight_power = NULL, ++ ++ .pixclock = 34576, ++ .xres = 640, ++ .yres = 480, ++ ++#ifdef USE_18BPP ++ .bpp = 32, ++#else ++ .bpp = 16, ++#endif ++ .hsync_len = 64, ++ .right_margin = 138 + 1, ++ .left_margin = 118 + 3, ++ ++ .vsync_len = 7, ++ .upper_margin = 28, ++ .lower_margin = 60, ++#if 0 ++ /* currently not used by driver! */ ++ .sync = ((0*FB_SYNC_HOR_HIGH_ACT) | ++ (0*FB_SYNC_VERT_HIGH_ACT) | ++ (1*FB_SYNC_OE_ACT_HIGH)), ++#else ++ .pcr = PCR_TFT | PCR_COLOR | PCR_PBSIZ_8 | ++#ifdef USE_18BPP ++ PCR_BPIX_18 | PCR_END_SEL | PCR_FLMPOL | PCR_LPPOL | PCR_SCLK_SEL, ++#else ++ PCR_BPIX_16 | PCR_FLMPOL | PCR_LPPOL | PCR_SCLK_SEL, ++#endif ++ .dmacr = 0x80040060, ++#endif ++ .cmap_greyscale = 0, ++ .cmap_inverse = 0, ++ .cmap_static = 0, ++ ++ .fixed_screen_cpu = NULL, ++ }, { ++ //.fb_mode = "SHARP LQ104V1DG61-16", ++ .init = stk5_gpio_lcdc_active, ++ .exit = stk5_gpio_lcdc_inactive, ++ .lcd_power = NULL, ++ .backlight_power = NULL, ++ ++ .pixclock = 40000, ++ .xres = 640, ++ .yres = 480, ++ ++#ifdef USE_18BPP ++ .bpp = 32, ++#else ++ .bpp = 16, ++#endif ++ .hsync_len = 32, ++ .right_margin = 32 + 1, ++ .left_margin = 0 + 3, ++ ++ .vsync_len = 35, ++ .upper_margin = 0, ++ .lower_margin = 0, ++#if 0 ++ /* currently not used by driver! */ ++ .sync = ((0*FB_SYNC_HOR_HIGH_ACT) | ++ (0*FB_SYNC_VERT_HIGH_ACT) | ++ (1*FB_SYNC_OE_ACT_HIGH)), ++#else ++ .pcr = PCR_TFT | PCR_COLOR | PCR_PBSIZ_8 | ++#ifdef USE_18BPP ++ PCR_BPIX_18 | PCR_END_SEL | PCR_FLMPOL | PCR_LPPOL | PCR_SCLK_SEL, ++#else ++ PCR_BPIX_16 | PCR_FLMPOL | PCR_LPPOL | PCR_CLKPOL | PCR_SCLK_SEL, ++#endif ++ .dmacr = 0x80040060, ++#endif ++ .cmap_greyscale = 0, ++ .cmap_inverse = 0, ++ .cmap_static = 0, ++ ++ .fixed_screen_cpu = NULL, ++ }, ++}; ++ ++static int __init karo_stk5_fb_register(void) ++{ ++ int ret; ++ ++ ret = mxc_register_device(&mxc_fb_device, &stk5_fb_data[0]); ++ if (ret != 0) { ++ DBG(0, "%s: Failed to register FB device: %d\n", __FUNCTION__, ret); ++ } ++ return ret; ++} ++#else ++static inline int karo_stk5_fb_register(void) ++{ ++ return 0; ++} ++#endif ++ ++#if defined(CONFIG_MMC_MXC) || defined(CONFIG_MMC_MXC_MODULE) ++/*! ++ * Resource definition for the SDHC1 ++ */ ++static struct resource stk5_sdhc1_resources[] = { ++ { ++ .start = MMC_SDHC1_BASE_ADDR, ++ .end = MMC_SDHC1_BASE_ADDR + SZ_4K - 1, ++ .flags = IORESOURCE_MEM, ++ }, { ++ .start = MXC_INT_SDHC1, ++ .end = MXC_INT_SDHC1, ++ .flags = IORESOURCE_IRQ, ++ }, { ++ .start = gpio_to_irq(4 * 32 + 4), ++ .end = gpio_to_irq(4 * 32 + 4), ++ .flags = IORESOURCE_IRQ, ++#if 0 ++ }, { ++ .name = "sdhc1", ++ .start = DMA_REQ_SDHC1, ++ .end = DMA_REQ_SDHC1, ++ .flags = IORESOURCE_DMA ++#endif ++ }, ++}; ++ ++static inline int stk5_mmc_get_irq(int id) ++{ ++ int irq; ++ ++ switch (id) { ++ case 0: ++ irq = stk5_sdhc1_resources[2].start; ++ break; ++ default: ++ BUG(); ++ } ++ return irq; ++} ++ ++static const char *stk5_mmc_irqdesc[] = { ++ "MMC card 0 detect", ++}; ++ ++static struct pad_desc stk5_sdhc_pads[] = { ++}; ++ ++static int stk5_mmc_init(struct device *dev, irqreturn_t (*mmc_detect_irq)(int, void *), ++ void *data) ++{ ++ int err; ++ int id = to_platform_device(dev)->id; ++ struct mmc_host *host = data; ++ int irq = stk5_mmc_get_irq(id); ++ ++ err = mxc_iomux_v3_setup_multiple_pads(stk5_sdhc_pads, ++ ARRAY_SIZE(stk5_sdhc_pads)); ++ if (err) { ++ return err; ++ } ++ ++ host->caps |= MMC_CAP_4_BIT_DATA; ++ ++ err = request_irq(irq, mmc_detect_irq, ++ IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, ++ stk5_mmc_irqdesc[id], data); ++ if (err) { ++ printk(KERN_ERR "%s: MMC/SD: can't request MMC card detect IRQ %d\n", ++ __FUNCTION__, irq); ++ return err; ++ } ++ device_set_wakeup_capable(dev, 1); ++ ++ return 0; ++} ++ ++static void stk5_mmc_exit(struct device *dev, void *data) ++{ ++ int id = to_platform_device(dev)->id; ++ int irq = stk5_mmc_get_irq(id); ++ ++ free_irq(irq, data); ++ mxc_iomux_v3_release_multiple_pads(stk5_sdhc_pads, ++ ARRAY_SIZE(stk5_sdhc_pads)); ++} ++ ++#if 0 ++static int stk5_mmc_suspend(struct device *dev, pm_message_t state) ++{ ++ int id = to_platform_device(dev)->id; ++ int irq = stk5_mmc_get_irq(id); ++ ++ if (device_may_wakeup(dev)) { ++ DBG(0, "%s: Enabling IRQ %d wakeup\n", __FUNCTION__, irq); ++ return enable_irq_wake(irq); ++ } ++ return 0; ++} ++ ++static int stk5_mmc_resume(struct device *dev) ++{ ++ int id = to_platform_device(dev)->id; ++ int irq = stk5_mmc_get_irq(id); ++ ++ if (device_may_wakeup(dev)) { ++ DBG(0, "%s: Disabling IRQ %d wakeup\n", __FUNCTION__, irq); ++ return disable_irq_wake(irq); ++ } ++ return 0; ++} ++#endif ++ ++static struct imxmmc_platform_data stk5_sdhc1_data = { ++ //.ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, ++ //.min_clk = 150000, ++ //.max_clk = 25000000, ++ //.detect_delay = 20, ++ .init = stk5_mmc_init, ++ .exit = stk5_mmc_exit, ++// .suspend = stk5_mmc_suspend, ++// .resume = stk5_mmc_resume, ++}; ++ ++static struct platform_device stk5_sdhc1_device = { ++ .name = "imx-mmc", ++ .id = 0, ++ .dev = { ++ .platform_data = &stk5_sdhc1_data, ++ }, ++ .num_resources = ARRAY_SIZE(stk5_sdhc1_resources), ++ .resource = stk5_sdhc1_resources, ++}; ++#endif ++ ++#if defined(CONFIG_SPI_MXC) || defined(CONFIG_SPI_MXC_MODULE) ++static struct resource mxcspi1_resources[] = { ++ { ++ .start = CSPI1_BASE_ADDR, ++ .end = CSPI1_BASE_ADDR + SZ_4K - 1, ++ .flags = IORESOURCE_MEM, ++ }, { ++ .start = MXC_INT_CSPI1, ++ .end = MXC_INT_CSPI1, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++static struct mxc_spi_master mxcspi1_data = { ++ .maxchipselect = 2, ++ .spi_version = 0, ++}; ++ ++static struct platform_device mxcspi1_device = { ++ .name = "mxc_spi", ++ .id = 0, ++ .dev = { ++ .platform_data = &mxcspi1_data, ++ }, ++ .num_resources = ARRAY_SIZE(mxcspi1_resources), ++ .resource = mxcspi1_resources, ++}; ++#endif // defined(CONFIG_SPI_MXC) || defined(CONFIG_SPI_MXC_MODULE) ++ ++#if defined(CONFIG_AC97_BUS) || defined(CONFIG_AC97_BUS_MODULE) ++static u64 stk5_dma_mask = ~0UL; ++ ++static struct pad_desc stk5_ac97_pads_on[] = { ++ MX25_PAD_VSTBY_ACK__GPIO_3_18, /* UCB1400 Reset */ ++ MX25_PAD_RW__AUD4_TXFS, ++ MX25_PAD_EB0__AUD4_TXD, ++ MX25_PAD_EB1__AUD4_RXD, ++ MX25_PAD_OE__AUD4_TXC, ++}; ++ ++static struct pad_desc stk5_ac97_pads_off[] = { ++ MX25_PAD_VSTBY_ACK__GPIO_3_18, /* UCB1400 Reset */ ++ MX25_PAD_RW__GPIO_3_25, ++ MX25_PAD_EB0__GPIO_2_12, ++ MX25_PAD_EB1__AUD4_RXD, ++ MX25_PAD_OE__AUD4_TXC, ++}; ++ ++static struct gpio_desc { ++ unsigned int gpio:7; ++ unsigned int dir:1; ++ unsigned int level:1; ++} stk5_ac97_gpios[] = { ++ /* configure the PHY strap pins to the correct values */ ++ { GPIO_PORTC | 18, 1, 0, }, ++ { GPIO_PORTC | 25, 1, 0, }, ++ { GPIO_PORTB | 12, 1, 0, }, ++}; ++ ++static int stk5_ac97_init(struct platform_device *dev) ++{ ++ int ret; ++ int i; ++ ++ DBG(0, "%s: \n", __FUNCTION__); ++ ++ ret = mxc_iomux_v3_setup_multiple_pads(stk5_ac97_pads_off, ++ ARRAY_SIZE(stk5_ac97_pads_off)); ++ if (ret == 0) { ++ for (i = 0; i < ARRAY_SIZE(stk5_ac97_gpios); i++) { ++ struct gpio_desc *pd = &stk5_ac97_gpios[i]; ++ ++ ret = gpio_request(pd->gpio, "AC97"); ++ if (ret < 0) { ++ DBG(0, "%s: Failed to request GPIO%d_%d: %d\n", ++ __FUNCTION__, pd->gpio / 32 + 1, pd->gpio % 32, ret); ++ goto rel_mux; ++ } ++ if (pd->dir) { ++ gpio_direction_output(pd->gpio, ++ pd->level); ++ } else { ++ gpio_direction_input(pd->gpio); ++ } ++ } ++ ++ ret = mxc_iomux_v3_setup_multiple_pads(stk5_ac97_pads_on, ++ ARRAY_SIZE(stk5_ac97_pads_on)); ++ if (ret != 0) { ++ goto rel_gpio; ++ } ++ udelay(1); ++ gpio_set_value(stk5_ac97_gpios[0].gpio, !stk5_ac97_gpios[0].level); ++ } ++ return ret; ++ ++ rel_mux: ++ mxc_iomux_v3_release_multiple_pads(stk5_ac97_gpios_off, ++ ARRAY_SIZE(stk5_ac97_gpios_off)); ++ rel_gpio: ++ while (--i >= 0) { ++ struct gpio_desc *pd = &stk5_ac97_gpios[i]; ++ int grp = pd->gpio / 32 + 1; ++ int ofs = pd->gpio % 32; ++ ++ DBG(0, "%s: Freeing GPIO%d_%d\n", __FUNCTION__, ++ grp, ofs); ++ gpio_free(pd->gpio); ++ } ++ return ret; ++} ++ ++static void stk5_ac97_exit(struct platform_device *dev) ++{ ++ int i; ++ ++ DBG(0, "%s: Releasing AC97 GPIO pins\n", __FUNCTION__); ++ ++ mxc_iomux_v3_release_multiple_pads(stk5_ac97_pads_on, ++ ARRAY_SIZE(stk5_ac97_pads_on)); ++ for (i = 0; i < ARRAY_SIZE(stk5_ac97_gpios); i++) { ++ struct gpio_desc *pd = &stk5_ac97_gpios[i]; ++ int grp = pd->gpio / 32 + 1; ++ int ofs = pd->gpio % 32; ++ ++ DBG(0, "%s: Freeing GPIO%d_%d\n", __FUNCTION__, ++ grp, ofs); ++ gpio_free(pd->gpio); ++ } ++} ++ ++static struct mxc_ac97_audio_ops stk5_ac97_ops = { ++ .init = stk5_ac97_init, ++ .exit = stk5_ac97_exit, ++ .startup = NULL, ++ .shutdown = NULL, ++ .suspend = NULL, ++ .resume = NULL, ++ .priv = NULL, ++}; ++ ++static struct platform_device ac97_device = { ++ .name = "mx25-ac97", ++ .id = -1, ++ .dev = { ++ .dma_mask = &stk5_dma_mask, ++ .coherent_dma_mask = ~0UL, ++ .platform_data = &stk5_ac97_ops, ++ }, ++}; ++#endif ++ ++static struct platform_dev_list { ++ struct platform_device *pdev; ++ int flag; ++} stk5_devices[] __initdata = { ++#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) ++ { .pdev = &stk5_led_device, .flag = -1, }, ++#endif ++#if defined(CONFIG_KEYBOARD_MXC) || defined(CONFIG_KEYBOARD_MXC_MODULE) ++ { .pdev = &stk5_keypad_device, .flag = 1, }, ++#endif ++#if defined(CONFIG_SPI_MXC) || defined(CONFIG_SPI_MXC_MODULE) ++ { .pdev = &mxcspi1_device, .flag = 1, }, ++#endif ++#if defined(CONFIG_AC97_BUS) || defined(CONFIG_AC97_BUS_MODULE) ++ { .pdev = &ac97_device, .flag = 1, }, ++#endif ++#if defined(CONFIG_MMC_MXC) || defined(CONFIG_MMC_MXC_MODULE) ++ { .pdev = &stk5_sdhc1_device, .flag = 1, }, ++#endif ++}; ++#define STK5_NUM_DEVICES ARRAY_SIZE(stk5_devices) ++ ++static __init int karo_stk5_board_init(void) ++{ ++ int ret; ++ int i; ++ ++ if (karo_get_board_type() != BOARD_KARO_STK5) { ++ return -ENODEV; ++ } ++ DBG(0, "%s: \n", __FUNCTION__); ++ ++ karo_stk5_serial_init(); ++ ++ dump_regs(); ++ ++ /* enable SSI1_INT (GPIO_3_15) for IRQ probing */ ++ set_irq_flags(gpio_to_irq(GPIO_PORTC | 15), IRQF_VALID | IRQF_PROBE); ++ ++ ret = karo_stk5_fb_register(); ++ if (ret) { ++ printk(KERN_WARNING "%s: karo_stk5_fb_register() failed: %d\n", ++ __FUNCTION__, ret); ++ } ++ ret = karo_stk5_usbh2_register(); ++ if (ret) { ++ printk(KERN_WARNING "%s: karo_stk5_usbh2_register() failed: %d\n", ++ __FUNCTION__, ret); ++ } ++ ++ for (i = 0; i < STK5_NUM_DEVICES; i++) { ++ if (stk5_devices[i].pdev == NULL) continue; ++ if (!stk5_devices[i].flag) { ++ DBG(0, "%s: Skipping platform device[%d] @ %p dev %p: %s\n", ++ __FUNCTION__, i, stk5_devices[i].pdev, &stk5_devices[i].pdev->dev, ++ stk5_devices[i].pdev->name); ++ continue; ++ } ++ DBG(0, "%s: Registering platform device[%d] @ %p dev %p: %s\n", ++ __FUNCTION__, i, stk5_devices[i].pdev, &stk5_devices[i].pdev->dev, ++ stk5_devices[i].pdev->name); ++ ret = platform_device_register(stk5_devices[i].pdev); ++ if (ret) { ++ printk(KERN_WARNING "%s: Failed to register platform_device[%d]: %s: %d\n", ++ __FUNCTION__, i, stk5_devices[i].pdev->name, ret); ++ } ++ } ++ DBG(0, "%s: Done\n", __FUNCTION__); ++ return 0; ++} ++subsys_initcall(karo_stk5_board_init); +diff -urNp linux-2.6.30-rc4/arch/arm/mach-mx3/clock-imx35.c linux-2.6.30-rc4-karo/arch/arm/mach-mx3/clock-imx35.c +--- linux-2.6.30-rc4/arch/arm/mach-mx3/clock-imx35.c 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/mach-mx3/clock-imx35.c 2009-06-02 17:05:26.000000000 +0200 +@@ -381,7 +381,7 @@ DEFINE_CLOCK(gpu2d_clk, 0, CCM_CGR3, 4 + .clk = &c, \ + }, + +-static struct clk_lookup lookups[] __initdata = { ++static struct clk_lookup lookups[] = { + _REGISTER_CLOCK(NULL, "asrc", asrc_clk) + _REGISTER_CLOCK(NULL, "ata", ata_clk) + _REGISTER_CLOCK(NULL, "audmux", audmux_clk) +diff -urNp linux-2.6.30-rc4/arch/arm/mach-mx3/clock.c linux-2.6.30-rc4-karo/arch/arm/mach-mx3/clock.c +--- linux-2.6.30-rc4/arch/arm/mach-mx3/clock.c 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/mach-mx3/clock.c 2009-06-02 17:05:26.000000000 +0200 +@@ -516,7 +516,7 @@ DEFINE_CLOCK(ipg_clk, 0, NULL, + .clk = &c, \ + }, + +-static struct clk_lookup lookups[] __initdata = { ++static struct clk_lookup lookups[] = { + _REGISTER_CLOCK(NULL, "emi", emi_clk) + _REGISTER_CLOCK(NULL, "cspi", cspi1_clk) + _REGISTER_CLOCK(NULL, "cspi", cspi2_clk) +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/Kconfig linux-2.6.30-rc4-karo/arch/arm/plat-mxc/Kconfig +--- linux-2.6.30-rc4/arch/arm/plat-mxc/Kconfig 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/Kconfig 2009-06-02 17:05:27.000000000 +0200 +@@ -56,6 +56,9 @@ config ARCH_HAS_RNGA + bool + depends on ARCH_MXC + ++config ARCH_MXC_IOMUX_V2 ++ bool ++ + config ARCH_MXC_IOMUX_V3 + bool + endif +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/Makefile linux-2.6.30-rc4-karo/arch/arm/plat-mxc/Makefile +--- linux-2.6.30-rc4/arch/arm/plat-mxc/Makefile 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/Makefile 2009-06-02 17:05:27.000000000 +0200 +@@ -5,7 +5,7 @@ + # Common support + obj-y := irq.o clock.o gpio.o time.o devices.o cpu.o system.o + +-obj-$(CONFIG_ARCH_MX1) += iomux-mx1-mx2.o dma-mx1-mx2.o +-obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o dma-mx1-mx2.o +-obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o +-obj-$(CONFIG_MXC_PWM) += pwm.o ++obj-$(CONFIG_ARCH_MXC_IOMUX_V2) += iomux-mx1-mx2.o dma-mx1-mx2.o ++obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o ++obj-$(CONFIG_MXC_PWM) += pwm.o ++obj-$(CONFIG_MACH_MX25) += spba.o +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/board-stk5.h linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/board-stk5.h +--- linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/board-stk5.h 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/board-stk5.h 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,17 @@ ++/* ++ * Copyright 2009 ++ * ++ * The code contained herein is licensed under the GNU General Public ++ * License. You may obtain a copy of the GNU General Public License ++ * Version 2 or later at the following locations: ++ * ++ * http://www.opensource.org/licenses/gpl-license.html ++ * http://www.gnu.org/copyleft/gpl.html ++ */ ++ ++#define UART1_ENABLED 1 ++#define UART2_ENABLED 1 ++#define UART3_ENABLED 1 ++/* Not available on TX25 */ ++#define UART4_ENABLED 0 ++#define UART5_ENABLED 0 +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/board-tx25.h linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/board-tx25.h +--- linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/board-tx25.h 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/board-tx25.h 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,13 @@ ++/* ++ * Copyright 2009 ++ * ++ * The code contained herein is licensed under the GNU General Public ++ * License. You may obtain a copy of the GNU General Public License ++ * Version 2 or later at the following locations: ++ * ++ * http://www.opensource.org/licenses/gpl-license.html ++ * http://www.gnu.org/copyleft/gpl.html ++ */ ++ ++#define MXC_LL_UART_PADDR UART1_BASE_ADDR ++#define MXC_LL_UART_VADDR AIPS1_IO_ADDRESS(UART1_BASE_ADDR) +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/common.h linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/common.h +--- linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/common.h 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/common.h 2009-06-02 17:05:27.000000000 +0200 +@@ -17,6 +17,7 @@ struct clk; + extern void mx1_map_io(void); + extern void mx21_map_io(void); + extern void mx27_map_io(void); ++extern void mx25_map_io(void); + extern void mx31_map_io(void); + extern void mx35_map_io(void); + extern void mxc_init_irq(void); +@@ -24,6 +25,7 @@ extern void mxc_timer_init(struct clk *t + extern int mx1_clocks_init(unsigned long fref); + extern int mx21_clocks_init(unsigned long lref, unsigned long fref); + extern int mx27_clocks_init(unsigned long fref); ++extern int mx25_clocks_init(unsigned long fref); + extern int mx31_clocks_init(unsigned long fref); + extern int mx35_clocks_init(void); + extern int mxc_register_gpios(void); +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/dma.h linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/dma.h +--- linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/dma.h 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/dma.h 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,259 @@ ++/* ++ * Copyright 2004-2008 Freescale Semiconductor, Inc. All Rights Reserved. ++ */ ++ ++/* ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License version 2 as ++ * published by the Free Software Foundation. ++ */ ++ ++#ifndef __ASM_ARCH_MXC_DMA_H__ ++#define __ASM_ARCH_MXC_DMA_H__ ++ ++#include ++ ++#define MXC_DMA_DYNAMIC_CHANNEL 255 ++ ++#define MXC_DMA_DONE 0x0 ++#define MXC_DMA_REQUEST_TIMEOUT 0x1 ++#define MXC_DMA_TRANSFER_ERROR 0x2 ++ ++/*! This defines the list of device ID's for DMA */ ++typedef enum mxc_dma_device { ++ MXC_DMA_UART1_RX, ++ MXC_DMA_UART1_TX, ++ MXC_DMA_UART2_RX, ++ MXC_DMA_UART2_TX, ++ MXC_DMA_UART3_RX, ++ MXC_DMA_UART3_TX, ++ MXC_DMA_UART4_RX, ++ MXC_DMA_UART4_TX, ++ MXC_DMA_UART5_RX, ++ MXC_DMA_UART5_TX, ++ MXC_DMA_UART6_RX, ++ MXC_DMA_UART6_TX, ++ MXC_DMA_MMC1_WIDTH_1, ++ MXC_DMA_MMC1_WIDTH_4, ++ MXC_DMA_MMC2_WIDTH_1, ++ MXC_DMA_MMC2_WIDTH_4, ++ MXC_DMA_SSI1_8BIT_RX0, ++ MXC_DMA_SSI1_8BIT_TX0, ++ MXC_DMA_SSI1_16BIT_RX0, ++ MXC_DMA_SSI1_16BIT_TX0, ++ MXC_DMA_SSI1_24BIT_RX0, ++ MXC_DMA_SSI1_24BIT_TX0, ++ MXC_DMA_SSI1_8BIT_RX1, ++ MXC_DMA_SSI1_8BIT_TX1, ++ MXC_DMA_SSI1_16BIT_RX1, ++ MXC_DMA_SSI1_16BIT_TX1, ++ MXC_DMA_SSI1_24BIT_RX1, ++ MXC_DMA_SSI1_24BIT_TX1, ++ MXC_DMA_SSI2_8BIT_RX0, ++ MXC_DMA_SSI2_8BIT_TX0, ++ MXC_DMA_SSI2_16BIT_RX0, ++ MXC_DMA_SSI2_16BIT_TX0, ++ MXC_DMA_SSI2_24BIT_RX0, ++ MXC_DMA_SSI2_24BIT_TX0, ++ MXC_DMA_SSI2_8BIT_RX1, ++ MXC_DMA_SSI2_8BIT_TX1, ++ MXC_DMA_SSI2_16BIT_RX1, ++ MXC_DMA_SSI2_16BIT_TX1, ++ MXC_DMA_SSI2_24BIT_RX1, ++ MXC_DMA_SSI2_24BIT_TX1, ++ MXC_DMA_FIR_RX, ++ MXC_DMA_FIR_TX, ++ MXC_DMA_CSPI1_RX, ++ MXC_DMA_CSPI1_TX, ++ MXC_DMA_CSPI2_RX, ++ MXC_DMA_CSPI2_TX, ++ MXC_DMA_CSPI3_RX, ++ MXC_DMA_CSPI3_TX, ++ MXC_DMA_ATA_RX, ++ MXC_DMA_ATA_TX, ++ MXC_DMA_MEMORY, ++ MXC_DMA_FIFO_MEMORY, ++ MXC_DMA_DSP_PACKET_DATA0_RD, ++ MXC_DMA_DSP_PACKET_DATA0_WR, ++ MXC_DMA_DSP_PACKET_DATA1_RD, ++ MXC_DMA_DSP_PACKET_DATA1_WR, ++ MXC_DMA_DSP_LOG0_CHNL, ++ MXC_DMA_DSP_LOG1_CHNL, ++ MXC_DMA_DSP_LOG2_CHNL, ++ MXC_DMA_DSP_LOG3_CHNL, ++ MXC_DMA_CSI_RX, ++ MXC_DMA_SPDIF_16BIT_TX, ++ MXC_DMA_SPDIF_16BIT_RX, ++ MXC_DMA_SPDIF_32BIT_TX, ++ MXC_DMA_SPDIF_32BIT_RX, ++ MXC_DMA_ASRC_A_RX, ++ MXC_DMA_ASRC_A_TX, ++ MXC_DMA_ASRC_B_RX, ++ MXC_DMA_ASRC_B_TX, ++ MXC_DMA_ASRC_C_RX, ++ MXC_DMA_ASRC_C_TX, ++ MXC_DMA_ESAI_16BIT_RX, ++ MXC_DMA_ESAI_16BIT_TX, ++ MXC_DMA_ESAI_24BIT_RX, ++ MXC_DMA_ESAI_24BIT_TX, ++ MXC_DMA_TEST_RAM2D2RAM, ++ MXC_DMA_TEST_RAM2RAM2D, ++ MXC_DMA_TEST_RAM2D2RAM2D, ++ MXC_DMA_TEST_RAM2RAM, ++ MXC_DMA_TEST_HW_CHAINING, ++ MXC_DMA_TEST_SW_CHAINING ++} mxc_dma_device_t; ++ ++/*! This defines the prototype of callback funtion registered by the drivers */ ++typedef void (*mxc_dma_callback_t) (void *arg, int error_status, ++ unsigned int count); ++ ++/*! This defines the type of DMA transfer requested */ ++typedef enum mxc_dma_mode { ++ MXC_DMA_MODE_READ, ++ MXC_DMA_MODE_WRITE, ++} mxc_dma_mode_t; ++ ++/*! This defines the DMA channel parameters */ ++typedef struct mxc_dma_channel { ++ unsigned int active:1; /*!< When there has a active tranfer, it is set to 1 */ ++ unsigned int lock; /*!< Defines the channel is allocated or not */ ++ int curr_buf; /*!< Current buffer */ ++ mxc_dma_mode_t mode; /*!< Read or Write */ ++ unsigned int channel; /*!< Channel info */ ++ unsigned int dynamic:1; /*!< Channel not statically allocated when 1 */ ++ char *dev_name; /*!< Device name */ ++ void *private; /*!< Private structure for platform */ ++ mxc_dma_callback_t cb_fn; /*!< The callback function */ ++ void *cb_args; /*!< The argument of callback function */ ++} mxc_dma_channel_t; ++ ++/*! This structure contains the information about a dma transfer */ ++typedef struct mxc_dma_requestbuf { ++ dma_addr_t src_addr; /*!< source address */ ++ dma_addr_t dst_addr; /*!< destination address */ ++ int num_of_bytes; /*!< the length of this transfer : bytes */ ++} mxc_dma_requestbuf_t; ++ ++/*! ++ * This function is generally called by the driver at open time. ++ * The DMA driver would do any initialization steps that is required ++ * to get the channel ready for data transfer. ++ * ++ * @param channel_id a pre-defined id. The peripheral driver would specify ++ * the id associated with its peripheral. This would be ++ * used by the DMA driver to identify the peripheral ++ * requesting DMA and do the necessary setup on the ++ * channel associated with the particular peripheral. ++ * The DMA driver could use static or dynamic DMA channel ++ * allocation. ++ * @param dev_name module name or device name ++ * @return returns a negative number on error if request for a DMA channel did not ++ * succeed, returns the channel number to be used on success. ++ */ ++extern int mxc_dma_request(mxc_dma_device_t channel_id, char *dev_name); ++ ++/*! ++ * This function is generally called by the driver at close time. The DMA ++ * driver would do any cleanup associated with this channel. ++ * ++ * @param channel_num the channel number returned at request time. This ++ * would be used by the DMA driver to identify the calling ++ * driver and do the necessary cleanup on the channel ++ * associated with the particular peripheral ++ * @return returns a negative number on error or 0 on success ++ */ ++extern int mxc_dma_free(int channel_num); ++ ++/*! ++ * This function would just configure the buffers specified by the user into ++ * dma channel. The caller must call mxc_dma_enable to start this transfer. ++ * ++ * @param channel_num the channel number returned at request time. This ++ * would be used by the DMA driver to identify the calling ++ * driver and do the necessary cleanup on the channel ++ * associated with the particular peripheral ++ * @param dma_buf an array of physical addresses to the user defined ++ * buffers. The caller must guarantee the dma_buf is ++ * available until the transfer is completed. ++ * @param num_buf number of buffers in the array ++ * @param mode specifies whether this is READ or WRITE operation ++ * @return This function returns a negative number on error if buffer could not be ++ * added with DMA for transfer. On Success, it returns 0 ++ */ ++extern int mxc_dma_config(int channel_num, mxc_dma_requestbuf_t * dma_buf, ++ int num_buf, mxc_dma_mode_t mode); ++ ++/*! ++ * This function would just configure the scatterlist specified by the ++ * user into dma channel. This is a slight variation of mxc_dma_config(), ++ * it is provided for the convenience of drivers that have a scatterlist ++ * passed into them. It is the calling driver's responsibility to have the ++ * correct physical address filled in the "dma_address" field of the ++ * scatterlist. ++ * ++ * @param channel_num the channel number returned at request time. This ++ * would be used by the DMA driver to identify the calling ++ * driver and do the necessary cleanup on the channel ++ * associated with the particular peripheral ++ * @param sg a scatterlist of buffers. The caller must guarantee ++ * the dma_buf is available until the transfer is ++ * completed. ++ * @param num_buf number of buffers in the array ++ * @param num_of_bytes total number of bytes to transfer. If set to 0, this ++ * would imply to use the length field of the scatterlist ++ * for each DMA transfer. Else it would calculate the size ++ * for each DMA transfer. ++ * @param mode specifies whether this is READ or WRITE operation ++ * @return This function returns a negative number on error if buffer could not ++ * be added with DMA for transfer. On Success, it returns 0 ++ */ ++extern int mxc_dma_sg_config(int channel_num, struct scatterlist *sg, ++ int num_buf, int num_of_bytes, ++ mxc_dma_mode_t mode); ++ ++/*! ++ * This function is provided if the driver would like to set/change its ++ * callback function. ++ * ++ * @param channel_num the channel number returned at request time. This ++ * would be used by the DMA driver to identify the calling ++ * driver and do the necessary cleanup on the channel ++ * associated with the particular peripheral ++ * @param callback a callback function to provide notification on transfer ++ * completion, user could specify NULL if he does not wish ++ * to be notified ++ * @param arg an argument that gets passed in to the callback ++ * function, used by the user to do any driver specific ++ * operations. ++ * @return this function returns a negative number on error if the callback ++ * could not be set for the channel or 0 on success ++ */ ++extern int mxc_dma_callback_set(int channel_num, mxc_dma_callback_t callback, ++ void *arg); ++ ++/*! ++ * This stops the DMA channel and any ongoing transfers. Subsequent use of ++ * mxc_dma_enable() will restart the channel and restart the transfer. ++ * ++ * @param channel_num the channel number returned at request time. This ++ * would be used by the DMA driver to identify the calling ++ * driver and do the necessary cleanup on the channel ++ * associated with the particular peripheral ++ * @return returns a negative number on error or 0 on success ++ */ ++extern int mxc_dma_disable(int channel_num); ++ ++/*! ++ * This starts DMA transfer. Or it restarts DMA on a stopped channel ++ * previously stopped with mxc_dma_disable(). ++ * ++ * @param channel_num the channel number returned at request time. This ++ * would be used by the DMA driver to identify the calling ++ * driver and do the necessary cleanup on the channel ++ * associated with the particular peripheral ++ * @return returns a negative number on error or 0 on success ++ */ ++extern int mxc_dma_enable(int channel_num); ++ ++#endif +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/hardware.h linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/hardware.h +--- linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/hardware.h 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/hardware.h 2009-06-02 17:05:27.000000000 +0200 +@@ -29,13 +29,18 @@ + #endif + + #ifdef CONFIG_ARCH_MX2 ++#ifndef CONFIG_MACH_MX25 + # include ++#endif + # ifdef CONFIG_MACH_MX21 + # include + # endif + # ifdef CONFIG_MACH_MX27 + # include + # endif ++# ifdef CONFIG_MACH_MX25 ++# include ++# endif + #endif + + #ifdef CONFIG_ARCH_MX1 +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/imxfb.h linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/imxfb.h +--- linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/imxfb.h 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/imxfb.h 2009-06-02 17:05:26.000000000 +0200 +@@ -13,7 +13,8 @@ + #define PCR_BPIX_4 (2 << 25) + #define PCR_BPIX_8 (3 << 25) + #define PCR_BPIX_12 (4 << 25) +-#define PCR_BPIX_16 (4 << 25) ++#define PCR_BPIX_16 (5 << 25) ++#define PCR_BPIX_18 (6 << 25) + #define PCR_PIXPOL (1 << 24) + #define PCR_FLMPOL (1 << 23) + #define PCR_LPPOL (1 << 22) +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/iomux-mx25.h linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/iomux-mx25.h +--- linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/iomux-mx25.h 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/iomux-mx25.h 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,905 @@ ++/* ++ * arch/arm/plat-mxc/include/mach/iomux-mx25.h ++ * ++ * Copyright (C) 2009 by Lothar Wassmann ++ * ++ * based on arch/arm/mach-mx25/mx25_pins.h ++ * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved. ++ * and ++ * arch/arm/plat-mxc/include/mach/iomux-mx35.h ++ * Copyright (C, NO_PAD_CTRL) 2009 by Jan Weitzel Phytec Messtechnik GmbH ++ * ++ * The code contained herein is licensed under the GNU General Public ++ * License. You may obtain a copy of the GNU General Public License ++ * Version 2 or later at the following locations: ++ * ++ * http://www.opensource.org/licenses/gpl-license.html ++ * http://www.gnu.org/copyleft/gpl.html ++ */ ++#ifndef __IOMUX_MX25_H__ ++#define __IOMUX_MX25_H__ ++ ++#include ++ ++/* ++ * ++ * @brief MX25 I/O Pin List ++ * ++ * @ingroup GPIO_MX25 ++ */ ++ ++#ifndef __ASSEMBLY__ ++ ++/* ++ * IOMUX/PAD Bit field definitions ++ */ ++ ++#define MX25_PAD_A10__A10 IOMUX_PAD(A10, A10, 0x000, 0x008, 0x00, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_A10__GPIO_4_0 IOMUX_PAD(A10, GPIO_4_0, 0x000, 0x008, 0x05, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_A13__A13 IOMUX_PAD(A13, A13, 0x22C, 0x00c, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A13__GPIO_4_1 IOMUX_PAD(A13, GPIO_4_1, 0x22C, 0x00c, 0x05, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A14__A14 IOMUX_PAD(A14, A14, 0x230, 0x010, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A14__GPIO_2_0 IOMUX_PAD(A14, GPIO_2_0, 0x230, 0x010, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A15__A15 IOMUX_PAD(A15, A15, 0x234, 0x014, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A15__GPIO_2_1 IOMUX_PAD(A15, GPIO_2_1, 0x234, 0x014, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A16__A16 IOMUX_PAD(A16, A16, 0x000, 0x018, 0x10, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_A16__GPIO_2_2 IOMUX_PAD(A16, GPIO_2_2, 0x000, 0x018, 0x15, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_A17__A17 IOMUX_PAD(A17, A17, 0x238, 0x01c, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A17__GPIO_2_3 IOMUX_PAD(A17, GPIO_2_3, 0x238, 0x01c, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A18__A18 IOMUX_PAD(A18, A18, 0x23c, 0x020, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A18__GPIO_2_4 IOMUX_PAD(A18, GPIO_2_4, 0x23c, 0x020, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A18__FEC_COL IOMUX_PAD(A18, FEC_COL, 0x23c, 0x020, 0x17, 0x504, 0, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_A19__A19 IOMUX_PAD(A19, A19, 0x240, 0x024, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A19__FEC_RX_ER IOMUX_PAD(A19, FEC_RX_ER, 0x240, 0x024, 0x17, 0x518, 0, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_A19__GPIO_2_5 IOMUX_PAD(A19, GPIO_2_5, 0x240, 0x024, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A20__A20 IOMUX_PAD(A20, A20, 0x244, 0x028, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A20__GPIO_2_6 IOMUX_PAD(A20, GPIO_2_6, 0x244, 0x028, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A20__FEC_RDATA2 IOMUX_PAD(A20, FEC_RDATA2, 0x244, 0x028, 0x17, 0x50c, 0, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_A21__A21 IOMUX_PAD(A21, A21, 0x248, 0x02c, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A21__GPIO_2_7 IOMUX_PAD(A21, GPIO_2_7, 0x248, 0x02c, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A21__FEC_RDATA3 IOMUX_PAD(A21, FEC_RDATA3, 0x248, 0x02c, 0x17, 0x510, 0, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_A22__A22 IOMUX_PAD(A22, A22, 0x000, 0x030, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A22__GPIO_2_8 IOMUX_PAD(A22, GPIO_2_8, 0x000, 0x030, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A23__A23 IOMUX_PAD(A23, A23, 0x24c, 0x034, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A23__GPIO_2_9 IOMUX_PAD(A23, GPIO_2_9, 0x24c, 0x034, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A24__A24 IOMUX_PAD(A24, A24, 0x250, 0x038, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A24__GPIO_2_10 IOMUX_PAD(A24, GPIO_2_10, 0x250, 0x038, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A24__FEC_RX_CLK IOMUX_PAD(A24, FEC_RX_CLK, 0x250, 0x038, 0x17, 0x514, 0, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_A25__A25 IOMUX_PAD(A25, A25, 0x254, 0x03c, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A25__GPIO_2_11 IOMUX_PAD(A25, GPIO_2_11, 0x254, 0x03c, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_A25__FEC_CRS IOMUX_PAD(A25, FEC_CRS, 0x254, 0x03c, 0x17, 0x508, 0, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_EB0__EB0 IOMUX_PAD(EB0, EB0, 0x258, 0x040, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_EB0__AUD4_TXD IOMUX_PAD(EB0, AUD4_TXD, 0x258, 0x040, 0x14, 0x464, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_EB0__GPIO_2_12 IOMUX_PAD(EB0, GPIO_2_12, 0x258, 0x040, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_EB1__EB1 IOMUX_PAD(EB1, EB1, 0x25c, 0x044, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_EB1__AUD4_RXD IOMUX_PAD(EB1, AUD4_RXD, 0x25c, 0x044, 0x14, 0x460, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_EB1__GPIO_2_13 IOMUX_PAD(EB1, GPIO_2_13, 0x25c, 0x044, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_OE__OE IOMUX_PAD(OE, OE, 0x260, 0x048, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_OE__AUD4_TXC IOMUX_PAD(OE, AUD4_TXC, 0x260, 0x048, 0x14, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_OE__GPIO_2_14 IOMUX_PAD(OE, GPIO_2_14, 0x260, 0x048, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CS0__CS0 IOMUX_PAD(CS0, CS0, 0x000, 0x04c, 0x00, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CS0__GPIO_4_2 IOMUX_PAD(CS0, GPIO_4_2, 0x000, 0x04c, 0x05, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CS1__CS1 IOMUX_PAD(CS1, CS1, 0x000, 0x050, 0x00, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CS1__GPIO_4_3 IOMUX_PAD(CS1, GPIO_4_3, 0x000, 0x050, 0x05, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CS4__CS4 IOMUX_PAD(CS4, CS4, 0x264, 0x054, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CS4__UART5_CTS IOMUX_PAD(CS4, UART5_CTS, 0x264, 0x054, 0x13, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CS4__GPIO_3_20 IOMUX_PAD(CS4, GPIO_3_20, 0x264, 0x054, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CS5__CS5 IOMUX_PAD(CS5, CS5, 0x268, 0x058, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CS5__UART5_RTS IOMUX_PAD(CS5, UART5_RTS, 0x268, 0x058, 0x13, 0x574, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CS5__GPIO_3_21 IOMUX_PAD(CS5, GPIO_3_21, 0x268, 0x058, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_NF_CE0__NF_CE0 IOMUX_PAD(NF_CE0, NF_CE0, 0x26c, 0x05c, 0x10, 0, 0, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_NF_CE0__GPIO_3_22 IOMUX_PAD(NF_CE0, GPIO_3_22, 0x26c, 0x05c, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_ECB__ECB IOMUX_PAD(ECB, ECB, 0x270, 0x060, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_ECB__UART5_TXD_MUX IOMUX_PAD(ECB, UART5_TXD_MUX, 0x270, 0x060, 0x13, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_ECB__GPIO_3_23 IOMUX_PAD(ECB, GPIO_3_23, 0x270, 0x060, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LBA__LBA IOMUX_PAD(LBA, LBA, 0x274, 0x064, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LBA__UART5_RXD_MUX IOMUX_PAD(LBA, UART5_RXD_MUX, 0x274, 0x064, 0x13, 0x578, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LBA__GPIO_3_24 IOMUX_PAD(LBA, GPIO_3_24, 0x274, 0x064, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_BCLK__BCLK IOMUX_PAD(BCLK, BCLK, 0x000, 0x068, 0x00, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_BCLK__GPIO_4_4 IOMUX_PAD(BCLK, GPIO_4_4, 0x000, 0x068, 0x05, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_RW__RW IOMUX_PAD(RW, RW, 0x278, 0x06c, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_RW__AUD4_TXFS IOMUX_PAD(RW, AUD4_TXFS, 0x278, 0x06c, 0x14, 0x474, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_RW__GPIO_3_25 IOMUX_PAD(RW, GPIO_3_25, 0x278, 0x06c, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_NFWE_B__NFWE_B IOMUX_PAD(NFWE_B, NFWE_B, 0x000, 0x070, 0x10, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_NFWE_B__GPIO_3_26 IOMUX_PAD(NFWE_B, GPIO_3_26, 0x000, 0x070, 0x15, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_NFRE_B__NFRE_B IOMUX_PAD(NFRE_B, NFRE_B, 0x000, 0x074, 0x10, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_NFRE_B__GPIO_3_27 IOMUX_PAD(NFRE_B, GPIO_3_27, 0x000, 0x074, 0x15, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_NFALE__NFALE IOMUX_PAD(NFALE, NFALE, 0x000, 0x078, 0x10, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_NFALE__GPIO_3_28 IOMUX_PAD(NFALE, GPIO_3_28, 0x000, 0x078, 0x15, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_NFCLE__NFCLE IOMUX_PAD(NFCLE, NFCLE, 0x000, 0x07c, 0x10, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_NFCLE__GPIO_3_29 IOMUX_PAD(NFCLE, GPIO_3_29, 0x000, 0x07c, 0x15, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_NFWP_B__NFWP_B IOMUX_PAD(NFWP_B, NFWP_B, 0x000, 0x080, 0x10, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_NFWP_B__GPIO_3_30 IOMUX_PAD(NFWP_B, GPIO_3_30, 0x000, 0x080, 0x15, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_NFRB__NFRB IOMUX_PAD(NFRB, NFRB, 0x27c, 0x084, 0x10, 0, 0, PAD_CTL_PULL_KEEPER) ++#define MX25_PAD_NFRB__GPIO_3_31 IOMUX_PAD(NFRB, GPIO_3_31, 0x27c, 0x084, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D15__D15 IOMUX_PAD(D15, D15, 0x280, 0x088, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D15__LD16 IOMUX_PAD(D15, LD16, 0x280, 0x088, 0x01, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D15__GPIO_4_5 IOMUX_PAD(D15, GPIO_4_5, 0x280, 0x088, 0x05, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D14__D14 IOMUX_PAD(D14, D14, 0x284, 0x08c, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D14__LD17 IOMUX_PAD(D14, LD17, 0x284, 0x08c, 0x01, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D14__GPIO_4_6 IOMUX_PAD(D14, GPIO_4_6, 0x284, 0x08c, 0x05, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D13__D13 IOMUX_PAD(D13, D13, 0x288, 0x090, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D13__LD18 IOMUX_PAD(D13, LD18, 0x288, 0x090, 0x01, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D13__GPIO_4_7 IOMUX_PAD(D13, GPIO_4_7, 0x288, 0x090, 0x05, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D12__D12 IOMUX_PAD(D12, D12, 0x28c, 0x094, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D12__GPIO_4_8 IOMUX_PAD(D12, GPIO_4_8, 0x28c, 0x094, 0x05, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D11__D11 IOMUX_PAD(D11, D11, 0x290, 0x098, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D11__GPIO_4_9 IOMUX_PAD(D11, GPIO_4_9, 0x290, 0x098, 0x05, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D10__D10 IOMUX_PAD(D10, D10, 0x294, 0x09c, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D10__GPIO_4_10 IOMUX_PAD(D10, GPIO_4_10, 0x294, 0x09c, 0x05, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D10__USBOTG_OC IOMUX_PAD(D10, USBOTG_OC, 0x294, 0x09c, 0x06, 0x57c, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D9__D9 IOMUX_PAD(D9, D9, 0x298, 0x0a0, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D9__GPIO_4_11 IOMUX_PAD(D9, GPIO_4_11, 0x298, 0x0a0, 0x05, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D9__USBH2_PWR IOMUX_PAD(D9, USBH2_PWR, 0x298, 0x0a0, 0x06, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D8__D8 IOMUX_PAD(D8, D8, 0x29c, 0x0a4, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D8__GPIO_4_12 IOMUX_PAD(D8, GPIO_4_12, 0x29c, 0x0a4, 0x05, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D8__USBH2_OC IOMUX_PAD(D8, USBH2_OC, 0x29c, 0x0a4, 0x06, 0x580, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D7__D7 IOMUX_PAD(D7, D7, 0x2a0, 0x0a8, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D7__GPIO_4_13 IOMUX_PAD(D7, GPIO_4_13, 0x2a0, 0x0a8, 0x05, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D6__D6 IOMUX_PAD(D6, D6, 0x2a4, 0x0ac, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D6__GPIO_4_14 IOMUX_PAD(D6, GPIO_4_14, 0x2a4, 0x0ac, 0x05, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D5__D5 IOMUX_PAD(D5, D5, 0x2a8, 0x0b0, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D5__GPIO_4_15 IOMUX_PAD(D5, GPIO_4_15, 0x2a8, 0x0b0, 0x05, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D4__D4 IOMUX_PAD(D4, D4, 0x2ac, 0x0b4, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D4__GPIO_4_16 IOMUX_PAD(D4, GPIO_4_16, 0x2ac, 0x0b4, 0x05, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D3__D3 IOMUX_PAD(D3, D3, 0x2b0, 0x0b8, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D3__GPIO_4_17 IOMUX_PAD(D3, GPIO_4_17, 0x2b0, 0x0b8, 0x05, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D2__D2 IOMUX_PAD(D2, D2, 0x2b4, 0x0bc, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D2__GPIO_4_18 IOMUX_PAD(D2, GPIO_4_18, 0x2b4, 0x0bc, 0x05, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D1__D1 IOMUX_PAD(D1, D1, 0x2b8, 0x0c0, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D1__GPIO_4_19 IOMUX_PAD(D1, GPIO_4_19, 0x2b8, 0x0c0, 0x05, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D0__D0 IOMUX_PAD(D0, D0, 0x2bc, 0x0c4, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_D0__GPIO_4_20 IOMUX_PAD(D0, GPIO_4_20, 0x2bc, 0x0c4, 0x05, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD0__LD0 IOMUX_PAD(LD0, LD0, 0x2c0, 0x0c8, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD0__CSI_D0 IOMUX_PAD(LD0, CSI_D0, 0x2c0, 0x0c8, 0x12, 0x488, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD0__GPIO_2_15 IOMUX_PAD(LD0, GPIO_2_15, 0x2c0, 0x0c8, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD1__LD1 IOMUX_PAD(LD1, LD1, 0x2c4, 0x0cc, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD1__CSI_D1 IOMUX_PAD(LD1, CSI_D1, 0x2c4, 0x0cc, 0x12, 0x48c, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD1__GPIO_2_16 IOMUX_PAD(LD1, GPIO_2_16, 0x2c4, 0x0cc, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD2__LD2 IOMUX_PAD(LD2, LD2, 0x2c8, 0x0d0, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD2__GPIO_2_17 IOMUX_PAD(LD2, GPIO_2_17, 0x2c8, 0x0d0, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD3__LD3 IOMUX_PAD(LD3, LD3, 0x2cc, 0x0d4, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD3__GPIO_2_18 IOMUX_PAD(LD3, GPIO_2_18, 0x2cc, 0x0d4, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD4__LD4 IOMUX_PAD(LD4, LD4, 0x2d0, 0x0d8, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD4__GPIO_2_19 IOMUX_PAD(LD4, GPIO_2_19, 0x2d0, 0x0d8, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD5__LD5 IOMUX_PAD(LD5, LD5, 0x2d4, 0x0dc, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD5__GPIO_1_19 IOMUX_PAD(LD5, GPIO_1_19, 0x2d4, 0x0dc, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD6__LD6 IOMUX_PAD(LD6, LD6, 0x2d8, 0x0e0, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD6__GPIO_1_20 IOMUX_PAD(LD6, GPIO_1_20, 0x2d8, 0x0e0, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD7__LD7 IOMUX_PAD(LD7, LD7, 0x2dc, 0x0e4, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD7__GPIO_1_21 IOMUX_PAD(LD7, GPIO_1_21, 0x2dc, 0x0e4, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD8__LD8 IOMUX_PAD(LD8, LD8, 0x2e0, 0x0e8, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD8__FEC_TX_ERR IOMUX_PAD(LD8, FEC_TX_ERR, 0x2e0, 0x0e8, 0x15, 0, 0, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_LD9__LD9 IOMUX_PAD(LD9, LD9, 0x2e4, 0x0ec, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD9__FEC_COL IOMUX_PAD(LD9, FEC_COL, 0x2e4, 0x0ec, 0x15, 0x504, 1, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_LD10__LD10 IOMUX_PAD(LD10, LD10, 0x2e8, 0x0f0, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD10__FEC_RX_ER IOMUX_PAD(LD10, FEC_RX_ER, 0x2e8, 0x0f0, 0x15, 0x518, 1, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_LD11__LD11 IOMUX_PAD(LD11, LD11, 0x2ec, 0x0f4, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD11__FEC_RDATA2 IOMUX_PAD(LD11, FEC_RDATA2, 0x2ec, 0x0f4, 0x15, 0x50c, 1, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_LD12__LD12 IOMUX_PAD(LD12, LD12, 0x2f0, 0x0f8, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD12__FEC_RDATA3 IOMUX_PAD(LD12, FEC_RDATA3, 0x2f0, 0x0f8, 0x15, 0x510, 1, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_LD13__LD13 IOMUX_PAD(LD13, LD13, 0x2f4, 0x0fc, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD13__FEC_TDATA2 IOMUX_PAD(LD13, FEC_TDATA2, 0x2f4, 0x0fc, 0x15, 0, 0, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_LD14__LD14 IOMUX_PAD(LD14, LD14, 0x2f8, 0x100, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD14__FEC_TDATA3 IOMUX_PAD(LD14, FEC_TDATA3, 0x2f8, 0x100, 0x15, 0, 0, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_LD15__LD15 IOMUX_PAD(LD15, LD15, 0x2fc, 0x104, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LD15__FEC_RX_CLK IOMUX_PAD(LD15, FEC_RX_CLK, 0x2fc, 0x104, 0x15, 0x514, 1, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_HSYNC__HSYNC IOMUX_PAD(HSYNC, HSYNC, 0x300, 0x108, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_HSYNC__GPIO_1_22 IOMUX_PAD(HSYNC, GPIO_1_22, 0x300, 0x108, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_VSYNC__VSYNC IOMUX_PAD(VSYNC, VSYNC, 0x304, 0x10c, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_VSYNC__GPIO_1_23 IOMUX_PAD(VSYNC, GPIO_1_23, 0x304, 0x10c, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LSCLK__LSCLK IOMUX_PAD(LSCLK, LSCLK, 0x308, 0x110, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_LSCLK__GPIO_1_24 IOMUX_PAD(LSCLK, GPIO_1_24, 0x308, 0x110, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_OE_ACD__OE_ACD IOMUX_PAD(OE_ACD, OE_ACD, 0x30c, 0x114, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_OE_ACD__GPIO_1_25 IOMUX_PAD(OE_ACD, GPIO_1_25, 0x30c, 0x114, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CONTRAST__CONTRAST IOMUX_PAD(CONTRAST, CONTRAST, 0x310, 0x118, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CONTRAST__FEC_CRS IOMUX_PAD(CONTRAST, FEC_CRS, 0x310, 0x118, 0x15, 0x508, 1, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_PWM__PWM IOMUX_PAD(PWM, PWM, 0x314, 0x11c, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_PWM__GPIO_1_26 IOMUX_PAD(PWM, GPIO_1_26, 0x314, 0x11c, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_PWM__USBH2_OC IOMUX_PAD(PWM, USBH2_OC, 0x314, 0x11c, 0x16, 0x580, 1, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D2__CSI_D2 IOMUX_PAD(CSI_D2, CSI_D2, 0x318, 0x120, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D2__UART5_RXD_MUX IOMUX_PAD(CSI_D2, UART5_RXD_MUX, 0x318, 0x120, 0x11, 0x578, 1, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D2__GPIO_1_27 IOMUX_PAD(CSI_D2, GPIO_1_27, 0x318, 0x120, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D3__CSI_D3 IOMUX_PAD(CSI_D3, CSI_D3, 0x31c, 0x124, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D3__GPIO_1_28 IOMUX_PAD(CSI_D3, GPIO_1_28, 0x31c, 0x124, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D4__CSI_D4 IOMUX_PAD(CSI_D4, CSI_D4, 0x320, 0x128, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D4__UART5_RTS IOMUX_PAD(CSI_D4, UART5_RTS, 0x320, 0x128, 0x11, 0x574, 1, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D4__GPIO_1_29 IOMUX_PAD(CSI_D4, GPIO_1_29, 0x320, 0x128, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D5__CSI_D5 IOMUX_PAD(CSI_D5, CSI_D5, 0x324, 0x12c, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D5__GPIO_1_30 IOMUX_PAD(CSI_D5, GPIO_1_30, 0x324, 0x12c, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D6__CSI_D6 IOMUX_PAD(CSI_D6, CSI_D6, 0x328, 0x130, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D6__GPIO_1_31 IOMUX_PAD(CSI_D6, GPIO_1_31, 0x328, 0x130, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D7__CSI_D7 IOMUX_PAD(CSI_D7, CSI_D7, 0x32c, 0x134, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D7__GPIO_1_6 IOMUX_PAD(CSI_D7, GPIO_1_6, 0x32c, 0x134, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D8__CSI_D8 IOMUX_PAD(CSI_D8, CSI_D8, 0x330, 0x138, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D8__GPIO_1_7 IOMUX_PAD(CSI_D8, GPIO_1_7, 0x330, 0x138, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D9__CSI_D9 IOMUX_PAD(CSI_D9, CSI_D9, 0x334, 0x13c, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_D9__GPIO_4_21 IOMUX_PAD(CSI_D9, GPIO_4_21, 0x334, 0x13c, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_MCLK__CSI_MCLK IOMUX_PAD(CSI_MCLK, CSI_MCLK, 0x338, 0x140, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_MCLK__GPIO_1_8 IOMUX_PAD(CSI_MCLK, GPIO_1_8, 0x338, 0x140, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_VSYNC__CSI_VSYNC IOMUX_PAD(CSI_VSYNC, CSI_VSYNC, 0x33c, 0x144, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_VSYNC__GPIO_1_9 IOMUX_PAD(CSI_VSYNC, GPIO_1_9, 0x33c, 0x144, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_HSYNC__CSI_HSYNC IOMUX_PAD(CSI_HSYNC, CSI_HSYNC, 0x340, 0x148, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_HSYNC__GPIO_1_10 IOMUX_PAD(CSI_HSYNC, GPIO_1_10, 0x340, 0x148, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_PIXCLK__CSI_PIXCLK IOMUX_PAD(CSI_PIXCLK, CSI_PIXCLK, 0x344, 0x14c, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSI_PIXCLK__GPIO_1_11 IOMUX_PAD(CSI_PIXCLK, GPIO_1_11, 0x344, 0x14c, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_I2C1_CLK__I2C1_CLK IOMUX_PAD(I2C1_CLK, I2C1_CLK, 0x348, 0x150, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_I2C1_CLK__GPIO_1_12 IOMUX_PAD(I2C1_CLK, GPIO_1_12, 0x348, 0x150, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_I2C1_DAT__I2C1_DAT IOMUX_PAD(I2C1_DAT, I2C1_DAT, 0x34c, 0x154, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_I2C1_DAT__GPIO_1_13 IOMUX_PAD(I2C1_DAT, GPIO_1_13, 0x34c, 0x154, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSPI1_MOSI__CSPI1_MOSI IOMUX_PAD(CSPI1_MOSI, CSPI1_MOSI, 0x350, 0x158, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSPI1_MOSI__GPIO_1_14 IOMUX_PAD(CSPI1_MOSI, GPIO_1_14, 0x350, 0x158, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSPI1_MISO__CSPI1_MISO IOMUX_PAD(CSPI1_MISO, CSPI1_MISO, 0x354, 0x15c, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSPI1_MISO__GPIO_1_15 IOMUX_PAD(CSPI1_MISO, GPIO_1_15, 0x354, 0x15c, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSPI1_SS0__CSPI1_SS0 IOMUX_PAD(CSPI1_SS0, CSPI1_SS0, 0x358, 0x160, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSPI1_SS0__GPIO_1_16 IOMUX_PAD(CSPI1_SS0, GPIO_1_16, 0x358, 0x160, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSPI1_SS1__CSPI1_SS1 IOMUX_PAD(CSPI1_SS1, CSPI1_SS1, 0x35c, 0x164, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSPI1_SS1__GPIO_1_17 IOMUX_PAD(CSPI1_SS1, GPIO_1_17, 0x35c, 0x164, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSPI1_SCLK__CSPI1_SCLK IOMUX_PAD(CSPI1_SCLK, CSPI1_SCLK, 0x360, 0x168, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSPI1_SCLK__GPIO_1_18 IOMUX_PAD(CSPI1_SCLK, GPIO_1_18, 0x360, 0x168, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CSPI1_RDY__CSPI1_RDY IOMUX_PAD(CSPI1_RDY, CSPI1_RDY, 0x364, 0x16c, 0x10, 0, 0, PAD_CTL_PULL_KEEPER) ++#define MX25_PAD_CSPI1_RDY__GPIO_2_22 IOMUX_PAD(CSPI1_RDY, GPIO_2_22, 0x364, 0x16c, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_UART1_RXD__UART1_RXD IOMUX_PAD(UART1_RXD, UART1_RXD, 0x368, 0x170, 0x10, 0, 0, PAD_CTL_PULL_DOWN_100K) ++#define MX25_PAD_UART1_RXD__GPIO_4_22 IOMUX_PAD(UART1_RXD, GPIO_4_22, 0x368, 0x170, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_UART1_TXD__UART1_TXD IOMUX_PAD(UART1_TXD, UART1_TXD, 0x36c, 0x174, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_UART1_TXD__GPIO_4_23 IOMUX_PAD(UART1_TXD, GPIO_4_23, 0x36c, 0x174, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_UART1_RTS__UART1_RTS IOMUX_PAD(UART1_RTS, UART1_RTS, 0x370, 0x178, 0x10, 0, 0, PAD_CTL_PULL_UP_100K) ++#define MX25_PAD_UART1_RTS__CSI_D0 IOMUX_PAD(UART1_RTS, CSI_D0, 0x370, 0x178, 0x11, 0x488, 1, 0 | NO_PAD_CTRL) ++#define MX25_PAD_UART1_RTS__GPIO_4_24 IOMUX_PAD(UART1_RTS, GPIO_4_24, 0x370, 0x178, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_UART1_CTS__UART1_CTS IOMUX_PAD(UART1_CTS, UART1_CTS, 0x374, 0x17c, 0x10, 0, 0, PAD_CTL_PULL_UP_100K) ++#define MX25_PAD_UART1_CTS__CSI_D1 IOMUX_PAD(UART1_CTS, CSI_D1, 0x374, 0x17c, 0x11, 0x48c, 1, 0 | NO_PAD_CTRL) ++#define MX25_PAD_UART1_CTS__GPIO_4_25 IOMUX_PAD(UART1_CTS, GPIO_4_25, 0x374, 0x17c, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_UART2_RXD__UART2_RXD IOMUX_PAD(UART2_RXD, UART2_RXD, 0x378, 0x180, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_UART2_RXD__GPIO_4_26 IOMUX_PAD(UART2_RXD, GPIO_4_26, 0x378, 0x180, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_UART2_TXD__UART2_TXD IOMUX_PAD(UART2_TXD, UART2_TXD, 0x37c, 0x184, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_UART2_TXD__GPIO_4_27 IOMUX_PAD(UART2_TXD, GPIO_4_27, 0x37c, 0x184, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_UART2_RTS__UART2_RTS IOMUX_PAD(UART2_RTS, UART2_RTS, 0x380, 0x188, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_UART2_RTS__FEC_COL IOMUX_PAD(UART2_RTS, FEC_COL, 0x380, 0x188, 0x12, 0x504, 2, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_UART2_RTS__GPIO_4_28 IOMUX_PAD(UART2_RTS, GPIO_4_28, 0x380, 0x188, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_UART2_CTS__FEC_RX_ER IOMUX_PAD(UART2_CTS, FEC_RX_ER, 0x384, 0x18c, 0x12, 0x518, 2, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_UART2_CTS__UART2_CTS IOMUX_PAD(UART2_CTS, UART2_CTS, 0x384, 0x18c, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_UART2_CTS__GPIO_4_29 IOMUX_PAD(UART2_CTS, GPIO_4_29, 0x384, 0x18c, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_SD1_CMD__SD1_CMD IOMUX_PAD(SD1_CMD, SD1_CMD, 0x388, 0x190, 0x10, 0, 0, PAD_CTL_PULL_UP_47K | PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_SD1_CMD__FEC_RDATA2 IOMUX_PAD(SD1_CMD, FEC_RDATA2, 0x388, 0x190, 0x12, 0x50c, 2, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_SD1_CMD__GPIO_2_23 IOMUX_PAD(SD1_CMD, GPIO_2_23, 0x388, 0x190, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_SD1_CLK__SD1_CLK IOMUX_PAD(SD1_CLK, SD1_CLK, 0x38c, 0x194, 0x10, 0, 0, PAD_CTL_PULL_UP_47K | PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_SD1_CLK__FEC_RDATA3 IOMUX_PAD(SD1_CLK, FEC_RDATA3, 0x38c, 0x194, 0x12, 0x510, 2, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_SD1_CLK__GPIO_2_24 IOMUX_PAD(SD1_CLK, GPIO_2_24, 0x38c, 0x194, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_SD1_DATA0__SD1_DATA0 IOMUX_PAD(SD1_DATA0, SD1_DATA0, 0x390, 0x198, 0x10, 0, 0, PAD_CTL_PULL_UP_47K | PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_SD1_DATA0__GPIO_2_25 IOMUX_PAD(SD1_DATA0, GPIO_2_25, 0x390, 0x198, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_SD1_DATA1__SD1_DATA1 IOMUX_PAD(SD1_DATA1, SD1_DATA1, 0x394, 0x19c, 0x10, 0, 0, PAD_CTL_PULL_UP_47K | PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_SD1_DATA1__AUD7_RXD IOMUX_PAD(SD1_DATA1, AUD7_RXD, 0x394, 0x19c, 0x13, 0x478, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_SD1_DATA1__GPIO_2_26 IOMUX_PAD(SD1_DATA1, GPIO_2_26, 0x394, 0x19c, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_SD1_DATA2__SD1_DATA2 IOMUX_PAD(SD1_DATA2, SD1_DATA2, 0x398, 0x1a0, 0x10, 0, 0, PAD_CTL_PULL_UP_47K | PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_SD1_DATA2__FEC_RX_CLK IOMUX_PAD(SD1_DATA2, FEC_RX_CLK, 0x398, 0x1a0, 0x15, 0x514, 2, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_SD1_DATA2__GPIO_2_27 IOMUX_PAD(SD1_DATA2, GPIO_2_27, 0x398, 0x1a0, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_SD1_DATA3__SD1_DATA3 IOMUX_PAD(SD1_DATA3, SD1_DATA3, 0x39c, 0x1a4, 0x10, 0, 0, PAD_CTL_PULL_UP_47K | PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_SD1_DATA3__FEC_CRS IOMUX_PAD(SD1_DATA3, FEC_CRS, 0x39c, 0x1a4, 0x10, 0x508, 2, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_SD1_DATA3__GPIO_2_28 IOMUX_PAD(SD1_DATA3, GPIO_2_28, 0x39c, 0x1a4, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_KPP_ROW0__KPP_ROW0 IOMUX_PAD(KPP_ROW0, KPP_ROW0, 0x3a0, 0x1a8, 0x10, 0, 0, PAD_CTL_PULL_KEEPER) ++#define MX25_PAD_KPP_ROW0__GPIO_2_29 IOMUX_PAD(KPP_ROW0, GPIO_2_29, 0x3a0, 0x1a8, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_KPP_ROW1__KPP_ROW1 IOMUX_PAD(KPP_ROW1, KPP_ROW1, 0x3a4, 0x1ac, 0x10, 0, 0, PAD_CTL_PULL_KEEPER) ++#define MX25_PAD_KPP_ROW1__GPIO_2_30 IOMUX_PAD(KPP_ROW1, GPIO_2_30, 0x3a4, 0x1ac, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_KPP_ROW2__KPP_ROW2 IOMUX_PAD(KPP_ROW2, KPP_ROW2, 0x3a8, 0x1b0, 0x10, 0, 0, PAD_CTL_PULL_KEEPER) ++#define MX25_PAD_KPP_ROW2__CSI_D0 IOMUX_PAD(KPP_ROW2, CSI_D0, 0x3a8, 0x1b0, 0x13, 0x488, 2, 0 | NO_PAD_CTRL) ++#define MX25_PAD_KPP_ROW2__GPIO_2_31 IOMUX_PAD(KPP_ROW2, GPIO_2_31, 0x3a8, 0x1b0, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_KPP_ROW3__KPP_ROW3 IOMUX_PAD(KPP_ROW3, KPP_ROW3, 0x3ac, 0x1b4, 0x10, 0, 0, PAD_CTL_PULL_KEEPER) ++#define MX25_PAD_KPP_ROW3__CSI_LD1 IOMUX_PAD(KPP_ROW3, CSI_LD1, 0x3ac, 0x1b4, 0x13, 0x48c, 2, 0 | NO_PAD_CTRL) ++#define MX25_PAD_KPP_ROW3__GPIO_3_0 IOMUX_PAD(KPP_ROW3, GPIO_3_0, 0x3ac, 0x1b4, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_KPP_COL0__KPP_COL0 IOMUX_PAD(KPP_COL0, KPP_COL0, 0x3b0, 0x1b8, 0x10, 0, 0, PAD_CTL_PULL_KEEPER | PAD_CTL_OUTPUT_OPEN_DRAIN) ++#define MX25_PAD_KPP_COL0__GPIO_3_1 IOMUX_PAD(KPP_COL0, GPIO_3_1, 0x3b0, 0x1b8, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_KPP_COL1__KPP_COL1 IOMUX_PAD(KPP_COL1, KPP_COL1, 0x3b4, 0x1bc, 0x10, 0, 0, PAD_CTL_PULL_KEEPER | PAD_CTL_OUTPUT_OPEN_DRAIN) ++#define MX25_PAD_KPP_COL1__GPIO_3_2 IOMUX_PAD(KPP_COL1, GPIO_3_2, 0x3b4, 0x1bc, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_KPP_COL2__KPP_COL2 IOMUX_PAD(KPP_COL2, KPP_COL2, 0x3b8, 0x1c0, 0x10, 0, 0, PAD_CTL_PULL_KEEPER | PAD_CTL_OUTPUT_OPEN_DRAIN) ++#define MX25_PAD_KPP_COL2__GPIO_3_3 IOMUX_PAD(KPP_COL2, GPIO_3_3, 0x3b8, 0x1c0, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_KPP_COL3__KPP_COL3 IOMUX_PAD(KPP_COL3, KPP_COL3, 0x3bc, 0x1c4, 0x10, 0, 0, PAD_CTL_PULL_KEEPER | PAD_CTL_OUTPUT_OPEN_DRAIN) ++#define MX25_PAD_KPP_COL3__GPIO_3_4 IOMUX_PAD(KPP_COL3, GPIO_3_4, 0x3bc, 0x1c4, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_FEC_MDC__FEC_MDC IOMUX_PAD(FEC_MDC, FEC_MDC, 0x3c0, 0x1c8, 0x10, 0, 0, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_FEC_MDC__AUD4_TXD IOMUX_PAD(FEC_MDC, AUD4_TXD, 0x3c0, 0x1c8, 0x12, 0x464, 1, 0 | NO_PAD_CTRL) ++#define MX25_PAD_FEC_MDC__GPIO_3_5 IOMUX_PAD(FEC_MDC, GPIO_3_5, 0x3c0, 0x1c8, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_FEC_MDIO__FEC_MDIO IOMUX_PAD(FEC_MDIO, FEC_MDIO, 0x3c4, 0x1cc, 0x10, 0, 0, PAD_CTL_HYSTERESIS | PAD_CTL_PULL_UP_22K | PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_FEC_MDIO__AUD4_RXD IOMUX_PAD(FEC_MDIO, AUD4_RXD, 0x3c4, 0x1cc, 0x12, 0x460, 1, 0 | NO_PAD_CTRL) ++#define MX25_PAD_FEC_MDIO__GPIO_3_6 IOMUX_PAD(FEC_MDIO, GPIO_3_6, 0x3c4, 0x1cc, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_FEC_TDATA0__FEC_TDATA0 IOMUX_PAD(FEC_TDATA0, FEC_TDATA0, 0x3c8, 0x1d0, 0x10, 0, 0, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_FEC_TDATA0__GPIO_3_7 IOMUX_PAD(FEC_TDATA0, GPIO_3_7, 0x3c8, 0x1d0, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_FEC_TDATA1__FEC_TDATA1 IOMUX_PAD(FEC_TDATA1, FEC_TDATA1, 0x3cc, 0x1d4, 0x10, 0, 0, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_FEC_TDATA1__AUD4_TXFS IOMUX_PAD(FEC_TDATA1, AUD4_TXFS, 0x3cc, 0x1d4, 0x12, 0x474, 1, 0 | NO_PAD_CTRL) ++#define MX25_PAD_FEC_TDATA1__GPIO_3_8 IOMUX_PAD(FEC_TDATA1, GPIO_3_8, 0x3cc, 0x1d4, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_FEC_TX_EN__FEC_TX_EN IOMUX_PAD(FEC_TX_EN, FEC_TX_EN, 0x3d0, 0x1d8, 0x10, 0, 0, PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_FEC_TX_EN__GPIO_3_9 IOMUX_PAD(FEC_TX_EN, GPIO_3_9 , 0x3d0, 0x1d8, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_FEC_RDATA0__FEC_RDATA0 IOMUX_PAD(FEC_RDATA0, FEC_RDATA0, 0x3d4, 0x1dc, 0x10, 0, 0, PAD_CTL_PULL_DOWN_100K | PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_FEC_RDATA0__GPIO_3_10 IOMUX_PAD(FEC_RDATA0, GPIO_3_10, 0x3d4, 0x1dc, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_FEC_RDATA1__FEC_RDATA1 IOMUX_PAD(FEC_RDATA1, FEC_RDATA1, 0x3d8, 0x1e0, 0x10, 0, 0, PAD_CTL_PULL_DOWN_100K | PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_FEC_RDATA1__GPIO_3_11 IOMUX_PAD(FEC_RDATA1, GPIO_3_11, 0x3d8, 0x1e0, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_FEC_RX_DV__FEC_RX_DV IOMUX_PAD(FEC_RX_DV, FEC_RX_DV, 0x3dc, 0x1e4, 0x10, 0, 0, PAD_CTL_PULL_DOWN_100K | PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_FEC_RX_DV__CAN2_RX IOMUX_PAD(FEC_RX_DV, CAN2_RX, 0x3dc, 0x1e4, 0x14, 0x484, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_FEC_RX_DV__GPIO_3_12 IOMUX_PAD(FEC_RX_DV, GPIO_3_12, 0x3dc, 0x1e4, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_FEC_TX_CLK__FEC_TX_CLK IOMUX_PAD(FEC_TX_CLK, FEC_TX_CLK, 0x3e0, 0x1e8, 0x10, 0, 0, PAD_CTL_HYSTERESIS | PAD_CTL_PULL_DOWN_100K | PAD_CTL_SLEW_RATE_FAST) ++#define MX25_PAD_FEC_TX_CLK__GPIO_3_13 IOMUX_PAD(FEC_TX_CLK, GPIO_3_13, 0x3e0, 0x1e8, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_RTCK__RTCK IOMUX_PAD(RTCK, RTCK, 0x3e4, 0x1ec, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_RTCK__OWIRE IOMUX_PAD(RTCK, OWIRE, 0x3e4, 0x1ec, 0x11, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_RTCK__GPIO_3_14 IOMUX_PAD(RTCK, GPIO_3_14, 0x3e4, 0x1ec, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_DE_B__DE_B IOMUX_PAD(DE_B, DE_B, 0x3ec, 0x1f0, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_DE_B__GPIO_2_20 IOMUX_PAD(DE_B, GPIO_2_20, 0x3ec, 0x1f0, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_TDO__TDO IOMUX_PAD(TDO, TDO, 0x3e8, 0x000, 0x00, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_GPIO_A__GPIO_A IOMUX_PAD(GPIO_A, GPIO_A, 0x3f0, 0x1f4, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_GPIO_A__USBOTG_PWR IOMUX_PAD(GPIO_A, USBOTG_PWR, 0x3f0, 0x1f4, 0x12, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_GPIO_B__GPIO_B IOMUX_PAD(GPIO_B, GPIO_B, 0x3f4, 0x1f8, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_GPIO_B__USBOTG_OC IOMUX_PAD(GPIO_B, USBOTG_OC, 0x3f4, 0x1f8, 0x12, 0x57c, 1, 0 | NO_PAD_CTRL) ++#define MX25_PAD_GPIO_C__GPIO_C IOMUX_PAD(GPIO_C, GPIO_C, 0x3f8, 0x1fc, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_GPIO_C__CAN2_TX IOMUX_PAD(GPIO_C, CAN2_TX, 0x3f8, 0x1fc, 0x16, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_GPIO_D__GPIO_D IOMUX_PAD(GPIO_D, GPIO_D, 0x3fc, 0x200, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_GPIO_D__CAN2_RX IOMUX_PAD(GPIO_D, CAN2_RX, 0x3fc, 0x200, 0x16, 0x484, 1, 0 | NO_PAD_CTRL) ++#define MX25_PAD_GPIO_E__GPIO_E IOMUX_PAD(GPIO_E, GPIO_E, 0x400, 0x204, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_GPIO_E__AUD7_TXD IOMUX_PAD(GPIO_E, AUD7_TXD, 0x400, 0x204, 0x14, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_GPIO_F__GPIO_F IOMUX_PAD(GPIO_F, GPIO_F, 0x404, 0x208, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_GPIO_F__AUD7_TXC IOMUX_PAD(GPIO_F, AUD7_TXC, 0x404, 0x208, 0x14, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_EXT_ARMCLK__EXT_ARMCLK IOMUX_PAD(EXT_ARMCLK, EXT_ARMCLK, 0x000, 0x20c, 0x10, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_EXT_ARMCLK__GPIO_3_15 IOMUX_PAD(EXT_ARMCLK, GPIO_3_15, 0x000, 0x20c, 0x15, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_UPLL_BYPCLK__UPLL_BYPCLK IOMUX_PAD(UPLL_BYPCLK, UPLL_BYPCLK, 0x000, 0x210, 0x10, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_UPLL_BYPCLK__GPIO_3_16 IOMUX_PAD(UPLL_BYPCLK, GPIO_3_16, 0x000, 0x210, 0x15, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_VSTBY_REQ__VSTBY_REQ IOMUX_PAD(VSTBY_REQ, VSTBY_REQ, 0x408, 0x214, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_VSTBY_REQ__AUD7_TXFS IOMUX_PAD(VSTBY_REQ, AUD7_TXFS, 0x408, 0x214, 0x14, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_VSTBY_REQ__GPIO_3_17 IOMUX_PAD(VSTBY_REQ, GPIO_3_17, 0x408, 0x214, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_VSTBY_ACK__VSTBY_ACK IOMUX_PAD(VSTBY_ACK, VSTBY_ACK, 0x40c, 0x218, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_VSTBY_ACK__GPIO_3_18 IOMUX_PAD(VSTBY_ACK, GPIO_3_18, 0x40c, 0x218, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_POWER_FAIL__POWER_FAIL IOMUX_PAD(POWER_FAIL, POWER_FAIL, 0x410, 0x21c, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_POWER_FAIL__AUD7_RXD IOMUX_PAD(POWER_FAIL, AUD7_RXD, 0x410, 0x21c, 0x14, 0x478, 1, 0 | NO_PAD_CTRL) ++#define MX25_PAD_POWER_FAIL__GPIO_3_19 IOMUX_PAD(POWER_FAIL, GPIO_3_19, 0x410, 0x21c, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CLKO__CLKO IOMUX_PAD(CLKO, CLKO, 0x414, 0x220, 0x10, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_CLKO__GPIO_2_21 IOMUX_PAD(CLKO, GPIO_2_21, 0x414, 0x220, 0x15, 0, 0, 0 | NO_PAD_CTRL) ++#define MX25_PAD_BOOT_MODE0__BOOT_MODE0 IOMUX_PAD(BOOT_MODE0, BOOT_MODE0, 0x000, 0x224, 0x00, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_BOOT_MODE0__GPIO_4_30 IOMUX_PAD(BOOT_MODE0, GPIO_4_30, 0x000, 0x224, 0x05, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_BOOT_MODE1__BOOT_MODE1 IOMUX_PAD(BOOT_MODE1, BOOT_MODE1, 0x000, 0x228, 0x00, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_BOOT_MODE1__GPIO_4_31 IOMUX_PAD(BOOT_MODE1, GPIO_4_31, 0x000, 0x228, 0x05, 0, 0, NO_PAD_CTRL) ++ ++#define MX25_PAD_CTL_GRP_DVS_MISC IOMUX_PAD(0x418, 0x000, 0, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CTL_GRP_DSE_FEC IOMUX_PAD(0x41c, 0x000, 0, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CTL_GRP_DVS_JTAG IOMUX_PAD(0x420, 0x000, 0, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CTL_GRP_DSE_NFC IOMUX_PAD(0x424, 0x000, 0, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CTL_GRP_DSE_CSI IOMUX_PAD(0x428, 0x000, 0, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CTL_GRP_DSE_WEIM IOMUX_PAD(0x42c, 0x000, 0, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CTL_GRP_DSE_DDR IOMUX_PAD(0x430, 0x000, 0, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CTL_GRP_DVS_CRM IOMUX_PAD(0x434, 0x000, 0, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CTL_GRP_DSE_KPP IOMUX_PAD(0x438, 0x000, 0, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CTL_GRP_DSE_SDHC1 IOMUX_PAD(0x43c, 0x000, 0, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CTL_GRP_DSE_LCD IOMUX_PAD(0x440, 0x000, 0, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CTL_GRP_DSE_UART IOMUX_PAD(0x444, 0x000, 0, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CTL_GRP_DVS_NFC IOMUX_PAD(0x448, 0x000, 0, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CTL_GRP_DVS_CSI IOMUX_PAD(0x44c, 0x000, 0, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CTL_GRP_DSE_CSPI1 IOMUX_PAD(0x450, 0x000, 0, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CTL_GRP_DDRTYPE IOMUX_PAD(0x454, 0x000, 0, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CTL_GRP_DVS_SDHC1 IOMUX_PAD(0x458, 0x000, 0, 0, 0, NO_PAD_CTRL) ++#define MX25_PAD_CTL_GRP_DVS_LCD IOMUX_PAD(0x45c, 0x000, 0, 0, 0, NO_PAD_CTRL) ++ ++#if 0 ++enum { ++ GPIO_A, ++ GPIO_B, ++ GPIO_C, ++ GPIO_D, ++ GPIO_E, ++ GPIO_F, ++ GPIO_1_6, ++ GPIO_1_7, ++ GPIO_1_8, ++ GPIO_1_9, ++ GPIO_1_10, ++ GPIO_1_11, ++ GPIO_1_12, ++ GPIO_1_13, ++ GPIO_1_14, ++ GPIO_1_15, ++ GPIO_1_16, ++ GPIO_1_17, ++ GPIO_1_18, ++ GPIO_1_19, ++ GPIO_1_20, ++ GPIO_1_21, ++ GPIO_1_22, ++ GPIO_1_23, ++ GPIO_1_24, ++ GPIO_1_25, ++ GPIO_1_26, ++ GPIO_1_27, ++ GPIO_1_28, ++ GPIO_1_29, ++ GPIO_1_30, ++ GPIO_1_31, ++ GPIO_2_0, ++ GPIO_2_1, ++ GPIO_2_2, ++ GPIO_2_3, ++ GPIO_2_4, ++ GPIO_2_5, ++ GPIO_2_6, ++ GPIO_2_7, ++ GPIO_2_8, ++ GPIO_2_9, ++ GPIO_2_10, ++ GPIO_2_11, ++ GPIO_2_12, ++ GPIO_2_13, ++ GPIO_2_14, ++ GPIO_2_15, ++ GPIO_2_16, ++ GPIO_2_17, ++ GPIO_2_18, ++ GPIO_2_19, ++ GPIO_2_20, ++ GPIO_2_21, ++ GPIO_2_22, ++ GPIO_2_23, ++ GPIO_2_24, ++ GPIO_2_25, ++ GPIO_2_26, ++ GPIO_2_27, ++ GPIO_2_28, ++ GPIO_2_29, ++ GPIO_2_30, ++ GPIO_2_31, ++ GPIO_3_0, ++ GPIO_3_1, ++ GPIO_3_2, ++ GPIO_3_3, ++ GPIO_3_4, ++ GPIO_3_5, ++ GPIO_3_6, ++ GPIO_3_7, ++ GPIO_3_8, ++ GPIO_3_9, ++ GPIO_3_10, ++ GPIO_3_11, ++ GPIO_3_12, ++ GPIO_3_13, ++ GPIO_3_14, ++ GPIO_3_15, ++ GPIO_3_16, ++ GPIO_3_17, ++ GPIO_3_18, ++ GPIO_3_19, ++ GPIO_3_20, ++ GPIO_3_21, ++ GPIO_3_22, ++ GPIO_3_23, ++ GPIO_3_24, ++ GPIO_3_25, ++ GPIO_3_26, ++ GPIO_3_27, ++ GPIO_3_28, ++ GPIO_3_29, ++ GPIO_3_30, ++ GPIO_3_31, ++ GPIO_4_0, ++ GPIO_4_1, ++ GPIO_4_2, ++ GPIO_4_3, ++ GPIO_4_4, ++ GPIO_4_5, ++ GPIO_4_6, ++ GPIO_4_7, ++ GPIO_4_8, ++ GPIO_4_9, ++ GPIO_4_10, ++ GPIO_4_11, ++ GPIO_4_12, ++ GPIO_4_13, ++ GPIO_4_14, ++ GPIO_4_15, ++ GPIO_4_16, ++ GPIO_4_17, ++ GPIO_4_18, ++ GPIO_4_19, ++ GPIO_4_20, ++ GPIO_4_21, ++ GPIO_4_22, ++ GPIO_4_23, ++ GPIO_4_24, ++ GPIO_4_25, ++ GPIO_4_26, ++ GPIO_4_27, ++ GPIO_4_28, ++ GPIO_4_29, ++ GPIO_4_30, ++ GPIO_4_31, ++}; ++ ++#define IOMUX_TO_GPIO(__pad_desc) ({ \ ++ int __gpio = -1; \ ++ struct pad_desc *__pd = __pad_desc; \ ++ \ ++ switch (__pd->mux_ctrl_ofs) { \ ++ case MX25_PAD_GPIO_A__GPIO_A: \ ++ __gpio = GPIO_A; \ ++ break; \ ++ case MX25_PAD_GPIO_B__GPIO_B: \ ++ __gpio = GPIO_B; \ ++ break; \ ++ case MX25_PAD_GPIO_C__GPIO_C: \ ++ __gpio = GPIO_C; \ ++ break; \ ++ case MX25_PAD_GPIO_D__GPIO_D: \ ++ __gpio = GPIO_D; \ ++ break; \ ++ case MX25_PAD_GPIO_E__GPIO_E: \ ++ __gpio = GPIO_E; \ ++ break; \ ++ case MX25_PAD_GPIO_F__GPIO_F: \ ++ __gpio = GPIO_F; \ ++ break; \ ++ case MX25_PAD_CSI_D7__GPIO_1_6: \ ++ __gpio = GPIO_1_6; \ ++ break; \ ++ case MX25_PAD_CSI_D8__GPIO_1_7: \ ++ __gpio = GPIO_1_7; \ ++ break; \ ++ case MX25_PAD_CSI_MCLK__GPIO_1_8: \ ++ __gpio = GPIO_1_8; \ ++ break; \ ++ case MX25_PAD_CSI_VSYNC__GPIO_1_9: \ ++ __gpio = GPIO_1_9; \ ++ break; \ ++ case MX25_PAD_CSI_HSYNC__GPIO_1_10: \ ++ __gpio = GPIO_1_10; \ ++ break; \ ++ case MX25_PAD_CSI_PIXCLK__GPIO_1_11: \ ++ __gpio = GPIO_1_11; \ ++ break; \ ++ case MX25_PAD_I2C1_CLK__GPIO_1_12: \ ++ __gpio = GPIO_1_12; \ ++ break; \ ++ case MX25_PAD_I2C1_DAT__GPIO_1_13: \ ++ __gpio = GPIO_1_13; \ ++ break; \ ++ case MX25_PAD_CSPI1_MOSI__GPIO_1_14: \ ++ __gpio = GPIO_1_14; \ ++ break; \ ++ case MX25_PAD_CSPI1_MISO__GPIO_1_15: \ ++ __gpio = GPIO_1_15; \ ++ break; \ ++ case MX25_PAD_CSPI1_SS0__GPIO_1_16: \ ++ __gpio = GPIO_1_16; \ ++ break; \ ++ case MX25_PAD_CSPI1_SS1__GPIO_1_17: \ ++ __gpio = GPIO_1_17; \ ++ break; \ ++ case MX25_PAD_CSPI1_SCLK__GPIO_1_18: \ ++ __gpio = GPIO_1_18; \ ++ break; \ ++ case MX25_PAD_LD5__GPIO_1_19: \ ++ __gpio = GPIO_1_19; \ ++ break; \ ++ case MX25_PAD_LD6__GPIO_1_20: \ ++ __gpio = GPIO_1_20; \ ++ break; \ ++ case MX25_PAD_LD7__GPIO_1_21: \ ++ __gpio = GPIO_1_21; \ ++ break; \ ++ case MX25_PAD_HSYNC__GPIO_1_22: \ ++ __gpio = GPIO_1_22; \ ++ break; \ ++ case MX25_PAD_VSYNC__GPIO_1_23: \ ++ __gpio = GPIO_1_23; \ ++ break; \ ++ case MX25_PAD_LSCLK__GPIO_1_24: \ ++ __gpio = GPIO_1_24; \ ++ break; \ ++ case MX25_PAD_OE_ACD__GPIO_1_25: \ ++ __gpio = GPIO_1_25; \ ++ break; \ ++ case MX25_PAD_PWM__GPIO_1_26: \ ++ __gpio = GPIO_1_26; \ ++ break; \ ++ case MX25_PAD_CSI_D2__GPIO_1_27: \ ++ __gpio = GPIO_1_27; \ ++ break; \ ++ case MX25_PAD_CSI_D3__GPIO_1_28: \ ++ __gpio = GPIO_1_28; \ ++ break; \ ++ case MX25_PAD_CSI_D4__GPIO_1_29: \ ++ __gpio = GPIO_1_29; \ ++ break; \ ++ case MX25_PAD_CSI_D5__GPIO_1_30: \ ++ __gpio = GPIO_1_30; \ ++ break; \ ++ case MX25_PAD_CSI_D6__GPIO_1_31: \ ++ __gpio = GPIO_1_31; \ ++ break; \ ++ \ ++ case MX25_PAD_A14__GPIO_2_0: \ ++ __gpio = GPIO_2_0; \ ++ break; \ ++ case MX25_PAD_A15__GPIO_2_1: \ ++ __gpio = GPIO_2_1; \ ++ break; \ ++ case MX25_PAD_A16__GPIO_2_2: \ ++ __gpio = GPIO_2_2; \ ++ break; \ ++ case MX25_PAD_A17__GPIO_2_3: \ ++ __gpio = GPIO_2_3; \ ++ break; \ ++ case MX25_PAD_A18__GPIO_2_4: \ ++ __gpio = GPIO_2_4; \ ++ break; \ ++ case MX25_PAD_A19__GPIO_2_5: \ ++ __gpio = GPIO_2_5; \ ++ break; \ ++ case MX25_PAD_A20__GPIO_2_6: \ ++ __gpio = GPIO_2_6; \ ++ break; \ ++ case MX25_PAD_A21__GPIO_2_7: \ ++ __gpio = GPIO_2_7; \ ++ break; \ ++ case MX25_PAD_A22__GPIO_2_8: \ ++ __gpio = GPIO_2_8; \ ++ break; \ ++ case MX25_PAD_A23__GPIO_2_9: \ ++ __gpio = GPIO_2_9; \ ++ break; \ ++ case MX25_PAD_A24__GPIO_2_10: \ ++ __gpio = GPIO_2_10; \ ++ break; \ ++ case MX25_PAD_A25__GPIO_2_11: \ ++ __gpio = GPIO_2_11; \ ++ break; \ ++ case MX25_PAD_EB0__GPIO_2_12: \ ++ __gpio = GPIO_2_12; \ ++ break; \ ++ case MX25_PAD_EB1__GPIO_2_13: \ ++ __gpio = GPIO_2_13; \ ++ break; \ ++ case MX25_PAD_OE__GPIO_2_14: \ ++ __gpio = GPIO_2_14; \ ++ break; \ ++ case MX25_PAD_LD0__GPIO_2_15: \ ++ __gpio = GPIO_2_15; \ ++ break; \ ++ case MX25_PAD_LD1__GPIO_2_16: \ ++ __gpio = GPIO_2_16; \ ++ break; \ ++ case MX25_PAD_LD2__GPIO_2_17: \ ++ __gpio = GPIO_2_17; \ ++ break; \ ++ case MX25_PAD_LD3__GPIO_2_18: \ ++ __gpio = GPIO_2_18; \ ++ break; \ ++ case MX25_PAD_LD4__GPIO_2_19: \ ++ __gpio = GPIO_2_19; \ ++ break; \ ++ case MX25_PAD_DE_B__GPIO_2_20: \ ++ __gpio = GPIO_2_20; \ ++ break; \ ++ case MX25_PAD_CLKO__GPIO_2_21: \ ++ __gpio = GPIO_2_21; \ ++ break; \ ++ case MX25_PAD_CSPI1_RDY__GPIO_2_22: \ ++ __gpio = GPIO_2_22; \ ++ break; \ ++ case MX25_PAD_SD1_CMD__GPIO_2_23: \ ++ __gpio = GPIO_2_23; \ ++ break; \ ++ case MX25_PAD_SD1_CLK__GPIO_2_24: \ ++ __gpio = GPIO_2_24; \ ++ break; \ ++ case MX25_PAD_SD1_DATA0__GPIO_2_25: \ ++ __gpio = GPIO_2_25; \ ++ break; \ ++ case MX25_PAD_SD1_DATA1__GPIO_2_26: \ ++ __gpio = GPIO_2_26; \ ++ break; \ ++ case MX25_PAD_SD1_DATA2__GPIO_2_27: \ ++ __gpio = GPIO_2_27; \ ++ break; \ ++ case MX25_PAD_SD1_DATA3__GPIO_2_28: \ ++ __gpio = GPIO_2_28; \ ++ break; \ ++ case MX25_PAD_KPP_ROW0__GPIO_2_29: \ ++ __gpio = GPIO_2_29; \ ++ break; \ ++ case MX25_PAD_KPP_ROW1__GPIO_2_30: \ ++ __gpio = GPIO_2_30; \ ++ break; \ ++ case MX25_PAD_KPP_ROW2__GPIO_2_31: \ ++ __gpio = GPIO_2_31; \ ++ break; \ ++ \ ++ case MX25_PAD_KPP_ROW3__GPIO_3_0: \ ++ __gpio = GPIO_3_0; \ ++ break; \ ++ case MX25_PAD_KPP_COL0__GPIO_3_1: \ ++ __gpio = GPIO_3_1; \ ++ break; \ ++ case MX25_PAD_KPP_COL1__GPIO_3_2: \ ++ __gpio = GPIO_3_2; \ ++ break; \ ++ case MX25_PAD_KPP_COL2__GPIO_3_3: \ ++ __gpio = GPIO_3_3; \ ++ break; \ ++ case MX25_PAD_KPP_COL3__GPIO_3_4: \ ++ __gpio = GPIO_3_4; \ ++ break; \ ++ case MX25_PAD_FEC_MDC__GPIO_3_5: \ ++ __gpio = GPIO_3_5; \ ++ break; \ ++ case MX25_PAD_FEC_MDIO__GPIO_3_6: \ ++ __gpio = GPIO_3_6; \ ++ break; \ ++ case MX25_PAD_FEC_TDATA0__GPIO_3_7: \ ++ __gpio = GPIO_3_7; \ ++ break; \ ++ case MX25_PAD_FEC_TDATA1__GPIO_3_8: \ ++ __gpio = GPIO_3_8; \ ++ break; \ ++ case MX25_PAD_FEC_TX_EN__GPIO_3_9: \ ++ __gpio = GPIO_3_9; \ ++ break; \ ++ case MX25_PAD_FEC_RDATA0__GPIO_3_10: \ ++ __gpio = GPIO_3_10; \ ++ break; \ ++ case MX25_PAD_FEC_RDATA1__GPIO_3_11: \ ++ __gpio = GPIO_3_11; \ ++ break; \ ++ case MX25_PAD_FEC_RX_DV__GPIO_3_12: \ ++ __gpio = GPIO_3_12; \ ++ break; \ ++ case MX25_PAD_FEC_TX_CLK__GPIO_3_13: \ ++ __gpio = GPIO_3_13; \ ++ break; \ ++ case MX25_PAD_RTCK__GPIO_3_14: \ ++ __gpio = GPIO_3_14; \ ++ break; \ ++ case MX25_PAD_EXT_ARMCLK__GPIO_3_15: \ ++ __gpio = GPIO_3_15; \ ++ break; \ ++ case MX25_PAD_UPLL_BYPCLK__GPIO_3_16: \ ++ __gpio = GPIO_3_16; \ ++ break; \ ++ case MX25_PAD_VSTBY_REQ__GPIO_3_17: \ ++ __gpio = GPIO_3_17; \ ++ break; \ ++ case MX25_PAD_VSTBY_ACK__GPIO_3_18: \ ++ __gpio = GPIO_3_18; \ ++ break; \ ++ case MX25_PAD_POWER_FAIL__GPIO_3_19: \ ++ __gpio = GPIO_3_19; \ ++ break; \ ++ case MX25_PAD_CS4__GPIO_3_20: \ ++ __gpio = GPIO_3_20; \ ++ break; \ ++ case MX25_PAD_CS5__GPIO_3_21: \ ++ __gpio = GPIO_3_21; \ ++ break; \ ++ case MX25_PAD_NF_CE0__GPIO_3_22: \ ++ __gpio = GPIO_3_22; \ ++ break; \ ++ case MX25_PAD_ECB__GPIO_3_23: \ ++ __gpio = GPIO_3_23; \ ++ break; \ ++ case MX25_PAD_LBA__GPIO_3_24: \ ++ __gpio = GPIO_3_24; \ ++ break; \ ++ case MX25_PAD_RW__GPIO_3_25: \ ++ __gpio = GPIO_3_25; \ ++ break; \ ++ case MX25_PAD_NFWE_B__GPIO_3_26: \ ++ __gpio = GPIO_3_26; \ ++ break; \ ++ case MX25_PAD_NFRE_B__GPIO_3_27: \ ++ __gpio = GPIO_3_27; \ ++ break; \ ++ case MX25_PAD_NFALE__GPIO_3_28: \ ++ __gpio = GPIO_3_28; \ ++ break; \ ++ case MX25_PAD_NFCLE__GPIO_3_29: \ ++ __gpio = GPIO_3_29; \ ++ break; \ ++ case MX25_PAD_NFWP_B__GPIO_3_30: \ ++ __gpio = GPIO_3_30; \ ++ break; \ ++ case MX25_PAD_NFRB__GPIO_3_31: \ ++ __gpio = GPIO_3_31; \ ++ break; \ ++ \ ++ case MX25_PAD_A10__GPIO_4_0: \ ++ __gpio = GPIO_4_0; \ ++ break; \ ++ case MX25_PAD_A13__GPIO_4_1: \ ++ __gpio = GPIO_4_1; \ ++ break; \ ++ case MX25_PAD_CS0__GPIO_4_2: \ ++ __gpio = GPIO_4_2; \ ++ break; \ ++ case MX25_PAD_CS1__GPIO_4_3: \ ++ __gpio = GPIO_4_3; \ ++ break; \ ++ case MX25_PAD_BCLK__GPIO_4_4: \ ++ __gpio = GPIO_4_4; \ ++ break; \ ++ case MX25_PAD_D15__GPIO_4_5: \ ++ __gpio = GPIO_4_5; \ ++ break; \ ++ case MX25_PAD_D14__GPIO_4_6: \ ++ __gpio = GPIO_4_6; \ ++ break; \ ++ case MX25_PAD_D13__GPIO_4_7: \ ++ __gpio = GPIO_4_7; \ ++ break; \ ++ case MX25_PAD_D12__GPIO_4_8: \ ++ __gpio = GPIO_4_8; \ ++ break; \ ++ case MX25_PAD_D11__GPIO_4_9: \ ++ __gpio = GPIO_4_9; \ ++ break; \ ++ case MX25_PAD_D10__GPIO_4_10: \ ++ __gpio = GPIO_4_10; \ ++ break; \ ++ case MX25_PAD_D9__GPIO_4_11: \ ++ __gpio = GPIO_4_11; \ ++ break; \ ++ case MX25_PAD_D8__GPIO_4_12: \ ++ __gpio = GPIO_4_12; \ ++ break; \ ++ case MX25_PAD_D7__GPIO_4_13: \ ++ __gpio = GPIO_4_13; \ ++ break; \ ++ case MX25_PAD_D6__GPIO_4_14: \ ++ __gpio = GPIO_4_14; \ ++ break; \ ++ case MX25_PAD_D5__GPIO_4_15: \ ++ __gpio = GPIO_4_15; \ ++ break; \ ++ case MX25_PAD_D4__GPIO_4_16: \ ++ __gpio = GPIO_4_16; \ ++ break; \ ++ case MX25_PAD_D3__GPIO_4_17: \ ++ __gpio = GPIO_4_17; \ ++ break; \ ++ case MX25_PAD_D2__GPIO_4_18: \ ++ __gpio = GPIO_4_18; \ ++ break; \ ++ case MX25_PAD_D1__GPIO_4_19: \ ++ __gpio = GPIO_4_19; \ ++ break; \ ++ case MX25_PAD_D0__GPIO_4_20: \ ++ __gpio = GPIO_4_20; \ ++ break; \ ++ case MX25_PAD_CSI_D9__GPIO_4_21: \ ++ __gpio = GPIO_4_21; \ ++ break; \ ++ case MX25_PAD_UART1_RXD__GPIO_4_22: \ ++ __gpio = GPIO_4_22; \ ++ break; \ ++ case MX25_PAD_UART1_TXD__GPIO_4_23: \ ++ __gpio = GPIO_4_23; \ ++ break; \ ++ case MX25_PAD_UART1_RTS__GPIO_4_24: \ ++ __gpio = GPIO_4_24; \ ++ break; \ ++ case MX25_PAD_UART1_CTS__GPIO_4_25: \ ++ __gpio = GPIO_4_25; \ ++ break; \ ++ case MX25_PAD_UART2_RXD__GPIO_4_26: \ ++ __gpio = GPIO_4_26; \ ++ break; \ ++ case MX25_PAD_UART2_TXD__GPIO_4_27: \ ++ __gpio = GPIO_4_27; \ ++ break; \ ++ case MX25_PAD_UART2_RTS__GPIO_4_28: \ ++ __gpio = GPIO_4_28; \ ++ break; \ ++ case MX25_PAD_UART2_CTS__GPIO_4_29: \ ++ __gpio = GPIO_4_29; \ ++ break; \ ++ case MX25_PAD_BOOT_MODE0__GPIO_4_30: \ ++ __gpio = GPIO_4_30; \ ++ break; \ ++ case MX25_PAD_BOOT_MODE1__GPIO_4_31: \ ++ __gpio = GPIO_4_31; \ ++ break; \ ++ } \ ++ __gpio; \ ++}) ++#endif ++ ++#endif // __ASSEMBLY__ ++#endif // __IOMUX_MX25_H__ +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/iomux-v3.h linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/iomux-v3.h +--- linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/iomux-v3.h 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/iomux-v3.h 2009-06-02 17:05:27.000000000 +0200 +@@ -54,7 +54,7 @@ struct pad_desc { + unsigned select_input:3; + }; + +-#define IOMUX_PAD(_pad_ctrl_ofs, _mux_ctrl_ofs, _mux_mode, _select_input_ofs, \ ++#define IOMUX_PAD(_pad, _func, _pad_ctrl_ofs, _mux_ctrl_ofs, _mux_mode, _select_input_ofs, \ + _select_input, _pad_ctrl) \ + { \ + .mux_ctrl_ofs = _mux_ctrl_ofs, \ +@@ -68,28 +68,28 @@ struct pad_desc { + /* + * Use to set PAD control + */ +-#define PAD_CTL_DRIVE_VOLTAGE_3_3_V 0 +-#define PAD_CTL_DRIVE_VOLTAGE_1_8_V 1 ++#define PAD_CTL_DRIVE_VOLTAGE_3_3_V (0 << 13) ++#define PAD_CTL_DRIVE_VOLTAGE_1_8_V (1 << 13) + +-#define PAD_CTL_NO_HYSTERESIS 0 +-#define PAD_CTL_HYSTERESIS 1 ++#define PAD_CTL_NO_HYSTERESIS (0 << 8) ++#define PAD_CTL_HYSTERESIS (1 << 8) + +-#define PAD_CTL_PULL_DISABLED 0x0 +-#define PAD_CTL_PULL_KEEPER 0xa +-#define PAD_CTL_PULL_DOWN_100K 0xc +-#define PAD_CTL_PULL_UP_47K 0xd +-#define PAD_CTL_PULL_UP_100K 0xe +-#define PAD_CTL_PULL_UP_22K 0xf +- +-#define PAD_CTL_OUTPUT_CMOS 0 +-#define PAD_CTL_OUTPUT_OPEN_DRAIN 1 +- +-#define PAD_CTL_DRIVE_STRENGTH_NORM 0 +-#define PAD_CTL_DRIVE_STRENGTH_HIGH 1 +-#define PAD_CTL_DRIVE_STRENGTH_MAX 2 ++#define PAD_CTL_PULL_DISABLED (0x0 << 4) ++#define PAD_CTL_PULL_KEEPER (0x8 << 4) ++#define PAD_CTL_PULL_DOWN_100K (0xc << 4) ++#define PAD_CTL_PULL_UP_47K (0xd << 4) ++#define PAD_CTL_PULL_UP_100K (0xe << 4) ++#define PAD_CTL_PULL_UP_22K (0xf << 4) ++ ++#define PAD_CTL_OUTPUT_CMOS (0 << 3) ++#define PAD_CTL_OUTPUT_OPEN_DRAIN (1 << 3) ++ ++#define PAD_CTL_DRIVE_STRENGTH_NORM (0 << 1) ++#define PAD_CTL_DRIVE_STRENGTH_HIGH (1 << 1) ++#define PAD_CTL_DRIVE_STRENGTH_MAX (2 << 1) + +-#define PAD_CTL_SLEW_RATE_SLOW 0 +-#define PAD_CTL_SLEW_RATE_FAST 1 ++#define PAD_CTL_SLEW_RATE_SLOW (0 << 0) ++#define PAD_CTL_SLEW_RATE_FAST (1 << 0) + + /* + * setups a single pad: +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/iomux.h linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/iomux.h +--- linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/iomux.h 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/iomux.h 2009-06-02 17:05:27.000000000 +0200 +@@ -24,10 +24,14 @@ + * GPIO Module and I/O Multiplexer + * x = 0..3 for reg_A, reg_B, reg_C, reg_D + */ ++#ifndef CONFIG_MACH_MX25 + #define VA_GPIO_BASE IO_ADDRESS(GPIO_BASE_ADDR) ++#endif + #define MXC_DDIR(x) (0x00 + ((x) << 8)) ++#ifndef CONFIG_MACH_MX25 + #define MXC_OCR1(x) (0x04 + ((x) << 8)) + #define MXC_OCR2(x) (0x08 + ((x) << 8)) ++#endif + #define MXC_ICONFA1(x) (0x0c + ((x) << 8)) + #define MXC_ICONFA2(x) (0x10 + ((x) << 8)) + #define MXC_ICONFB1(x) (0x14 + ((x) << 8)) +@@ -96,16 +100,20 @@ + + + #ifdef CONFIG_ARCH_MX1 +-#include ++# include + #endif + #ifdef CONFIG_ARCH_MX2 +-#include +-#ifdef CONFIG_MACH_MX21 +-#include +-#endif +-#ifdef CONFIG_MACH_MX27 +-#include +-#endif ++# ifndef CONFIG_MACH_MX25 ++# include ++# ifdef CONFIG_MACH_MX21 ++# include ++# endif ++# endif ++# ifdef CONFIG_MACH_MX27 ++# include ++# else ++# include ++# endif + #endif + + +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/irqs.h linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/irqs.h +--- linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/irqs.h 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/irqs.h 2009-06-02 17:05:27.000000000 +0200 +@@ -21,7 +21,11 @@ + #if defined CONFIG_ARCH_MX1 + #define MXC_GPIO_IRQS (32 * 4) + #elif defined CONFIG_ARCH_MX2 ++#ifndef CONFIG_MACH_MX25 + #define MXC_GPIO_IRQS (32 * 6) ++#else ++#define MXC_GPIO_IRQS (32 * 4) ++#endif + #elif defined CONFIG_ARCH_MX3 + #define MXC_GPIO_IRQS (32 * 3) + #endif +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/memory.h linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/memory.h +--- linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/memory.h 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/memory.h 2009-06-02 17:05:27.000000000 +0200 +@@ -14,12 +14,13 @@ + #if defined CONFIG_ARCH_MX1 + #define PHYS_OFFSET UL(0x08000000) + #elif defined CONFIG_ARCH_MX2 +-#ifdef CONFIG_MACH_MX21 ++# if defined(CONFIG_MACH_MX21) + #define PHYS_OFFSET UL(0xC0000000) +-#endif +-#ifdef CONFIG_MACH_MX27 ++# elif defined(CONFIG_MACH_MX27) + #define PHYS_OFFSET UL(0xA0000000) +-#endif ++# elif defined(CONFIG_MACH_MX25) ++#define PHYS_OFFSET UL(0x80000000) ++# endif + #elif defined CONFIG_ARCH_MX3 + #define PHYS_OFFSET UL(0x80000000) + #endif +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/mx25.h linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/mx25.h +--- linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/mx25.h 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/mx25.h 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,482 @@ ++/* ++ * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved. ++ */ ++ ++/* ++ * The code contained herein is licensed under the GNU General Public ++ * License. You may obtain a copy of the GNU General Public License ++ * Version 2 or later at the following locations: ++ * ++ * http://www.opensource.org/licenses/gpl-license.html ++ * http://www.gnu.org/copyleft/gpl.html ++ */ ++ ++/*! ++ * @file arch-mxc/mx25.h ++ * @brief This file contains register definitions. ++ * ++ * @ingroup MSL_MX25 ++ */ ++ ++#ifndef __ASM_ARCH_MXC_MX25_H__ ++#define __ASM_ARCH_MXC_MX25_H__ ++ ++#ifndef __ASM_ARCH_MXC_HARDWARE_H__ ++#error "Do not include directly." ++#endif ++ ++#ifdef CONFIG_DEBUG_LL ++#ifdef CONFIG_MACH_TX25 ++#include ++#endif ++#endif // CONFIG_DEBUG_LL ++ ++/* ++ * MX25 memory map: ++ * ++ * Virt Phys Size What ++ * --------------------------------------------------------------------------- ++ * FC000000 43F00000 1M AIPS 1 ++ * FC100000 50000000 1M SPBA ++ * FC200000 53F00000 1M AIPS 2 ++ * FC300000 60000000 1M ROMPATCH (128M) ++ * FC400000 68000000 1M ASIC (128M) ++ * FC500000 78000000 128K FBC RAM (IRAM) ++ * 80000000 256M SDRAM0 ++ * 90000000 256M SDRAM1 ++ * A0000000 128M CS0 Flash ++ * A8000000 128M CS1 Flash ++ * B0000000 32M CS2 SRAM ++ * B2000000 32M CS3 ++ * B4000000 32M CS4 ++ * B6000000 32M CS5 ++ * FC520000 B8000000 64K SDRAM, WEIM, M3IF, EMI controllers ++ * FC530000 BB000000 8K NFC ++ */ ++ ++#include ++#define VA(x) _AT(void __force __iomem *,x) ++ ++/* ++ * IRAM ++ */ ++#define IRAM_BASE_ADDR UL(0x78000000) /* internal ram */ ++#define IRAM_BASE_ADDR_VIRT VA(0xFC500000) ++#define IRAM_SIZE SZ_128K ++ ++/* ++ * AIPS 1 ++ */ ++#define AIPS1_BASE_ADDR UL(0x43F00000) ++#define AIPS1_BASE_ADDR_VIRT VA(0xFC000000) ++#define AIPS1_SIZE SZ_1M ++ ++#define MAX_BASE_ADDR (AIPS1_BASE_ADDR + 0x00004000) ++#define CLKCTL_BASE_ADDR (AIPS1_BASE_ADDR + 0x00008000) ++#define ETB_SLOT4_BASE_ADDR (AIPS1_BASE_ADDR + 0x0000C000) ++#define ETB_SLOT5_BASE_ADDR (AIPS1_BASE_ADDR + 0x00010000) ++#define AAPE_BASE_ADDR (AIPS1_BASE_ADDR + 0x00014000) ++#define I2C_BASE_ADDR (AIPS1_BASE_ADDR + 0x00080000) ++#define I2C3_BASE_ADDR (AIPS1_BASE_ADDR + 0x00084000) ++#define CAN1_BASE_ADDR (AIPS1_BASE_ADDR + 0x00088000) ++#define CAN3_BASE_ADDR (AIPS1_BASE_ADDR + 0x0008C000) ++#define UART1_BASE_ADDR (AIPS1_BASE_ADDR + 0x00090000) ++#define UART2_BASE_ADDR (AIPS1_BASE_ADDR + 0x00094000) ++#define I2C2_BASE_ADDR (AIPS1_BASE_ADDR + 0x00098000) ++#define OWIRE_BASE_ADDR (AIPS1_BASE_ADDR + 0x0009C000) ++#define ATA_BASE_ADDR (AIPS1_BASE_ADDR + 0x000A0000) ++#define CSPI1_BASE_ADDR (AIPS1_BASE_ADDR + 0x000A4000) ++#define KPP_BASE_ADDR (AIPS1_BASE_ADDR + 0x000A8000) ++#define IOMUXC_BASE_ADDR (AIPS1_BASE_ADDR + 0x000AC000) ++#define AUDMUX_BASE_ADDR (AIPS1_BASE_ADDR + 0x000B0000) ++#define ECT_A_BASE_ADDR (AIPS1_BASE_ADDR + 0x000B8000) ++#define ECT_B_BASE_ADDR (AIPS1_BASE_ADDR + 0x000BC000) ++ ++/* ++ * SPBA global module enabled #0 ++ */ ++#define SPBA0_BASE_ADDR UL(0x50000000) ++#define SPBA0_BASE_ADDR_VIRT VA(0xFC100000) ++#define SPBA0_SIZE SZ_1M ++ ++#define CSPI3_BASE_ADDR (SPBA0_BASE_ADDR + 0x00004000) ++#define UART4_BASE_ADDR (SPBA0_BASE_ADDR + 0x00008000) ++#define UART3_BASE_ADDR (SPBA0_BASE_ADDR + 0x0000C000) ++#define CSPI2_BASE_ADDR (SPBA0_BASE_ADDR + 0x00010000) ++#define SSI2_BASE_ADDR (SPBA0_BASE_ADDR + 0x00014000) ++#define ESAI_BASE_ADDR (SPBA0_BASE_ADDR + 0x00018000) ++#define ATA_DMA_BASE_ADDR (SPBA0_BASE_ADDR + 0x00020000) ++#define SIM1_BASE_ADDR (SPBA0_BASE_ADDR + 0x00024000) ++#define SIM2_BASE_ADDR (SPBA0_BASE_ADDR + 0x00028000) ++#define UART5_BASE_ADDR (SPBA0_BASE_ADDR + 0x0002C000) ++#define TSC_BASE_ADDR (SPBA0_BASE_ADDR + 0x00030000) ++#define SSI1_BASE_ADDR (SPBA0_BASE_ADDR + 0x00034000) ++#define FEC_BASE_ADDR (SPBA0_BASE_ADDR + 0x00038000) ++#define SPBA_CTRL_BASE_ADDR (SPBA0_BASE_ADDR + 0x0003C000) ++ ++/*! ++ * defines for SPBA modules ++ */ ++#define SPBA_CSPI3 (0x1 << 2) ++#define SPBA_UART4 (0x2 << 2) ++#define SPBA_UART3 (0x3 << 2) ++#define SPBA_CSPI2 (0x4 << 2) ++#define SPBA_SSI2 (0x5 << 2) ++#define SPBA_ESAI (0x6 << 2) ++#define SPBA_ATA (0x8 << 2) ++#define SPBA_SIM1 (0x9 << 2) ++#define SPBA_SIM2 (0xA << 2) ++#define SPBA_UART5 (0xB << 2) ++#define SPBA_ANALOG (0xC << 2) ++#define SPBA_SSI1 (0xD << 2) ++#define SPBA_FEC (0xE << 2) ++ ++/*! ++ * Defines for modules using static and dynamic DMA channels ++ */ ++#define MXC_DMA_CHANNEL_IRAM 30 ++#define MXC_DMA_CHANNEL_UART1_RX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_UART1_TX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_UART2_RX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_UART2_TX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_UART3_RX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_UART3_TX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_UART4_RX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_UART4_TX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_UART5_RX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_UART5_TX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_MMC1 MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_SSI1_RX MXC_DMA_DYNAMIC_CHANNEL ++#ifdef CONFIG_SDMA_IRAM ++#define MXC_DMA_CHANNEL_SSI1_TX (MXC_DMA_CHANNEL_IRAM + 1) ++#else ++#define MXC_DMA_CHANNEL_SSI1_TX MXC_DMA_DYNAMIC_CHANNEL ++#endif ++#define MXC_DMA_CHANNEL_SSI2_RX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_SSI2_TX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_CSPI1_RX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_CSPI1_TX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_CSPI2_RX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_CSPI2_TX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_CSPI3_RX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_CSPI3_TX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_ATA_RX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_ATA_TX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_MEMORY MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_ESAI_RX MXC_DMA_DYNAMIC_CHANNEL ++#define MXC_DMA_CHANNEL_ESAI_TX MXC_DMA_DYNAMIC_CHANNEL ++ ++/* ++ * AIPS 2 ++ */ ++#define AIPS2_BASE_ADDR UL(0x53F00000) ++#define AIPS2_BASE_ADDR_VIRT VA(0xFC200000) ++#define AIPS2_SIZE SZ_1M ++ ++#define CCM_BASE_ADDR (AIPS2_BASE_ADDR + 0x00080000) ++#define GPT4_BASE_ADDR (AIPS2_BASE_ADDR + 0x00084000) ++#define GPT3_BASE_ADDR (AIPS2_BASE_ADDR + 0x00088000) ++#define GPT2_BASE_ADDR (AIPS2_BASE_ADDR + 0x0008C000) ++#define GPT1_BASE_ADDR (AIPS2_BASE_ADDR + 0x00090000) ++#define EPIT1_BASE_ADDR (AIPS2_BASE_ADDR + 0x00094000) ++#define EPIT2_BASE_ADDR (AIPS2_BASE_ADDR + 0x00098000) ++#define GPIO4_BASE_ADDR (AIPS2_BASE_ADDR + 0x0009C000) ++#define PWM2_BASE_ADDR (AIPS2_BASE_ADDR + 0x000A0000) ++#define GPIO3_BASE_ADDR (AIPS2_BASE_ADDR + 0x000A4000) ++#define PWM3_BASE_ADDR (AIPS2_BASE_ADDR + 0x000A8000) ++#define SCC_BASE_ADDR (AIPS2_BASE_ADDR + 0x000AC000) ++#define RNGD_BASE_ADDR (AIPS2_BASE_ADDR + 0x000B0000) ++#define MMC_SDHC1_BASE_ADDR (AIPS2_BASE_ADDR + 0x000B4000) ++#define MMC_SDHC2_BASE_ADDR (AIPS2_BASE_ADDR + 0x000B8000) ++#define LCDC_BASE_ADDR (AIPS2_BASE_ADDR + 0x000BC000) ++#define SLCDC_BASE_ADDR (AIPS2_BASE_ADDR + 0x000C0000) ++#define PWM4_BASE_ADDR (AIPS2_BASE_ADDR + 0x000C8000) ++#define GPIO1_BASE_ADDR (AIPS2_BASE_ADDR + 0x000CC000) ++#define GPIO2_BASE_ADDR (AIPS2_BASE_ADDR + 0x000D0000) ++#define SDMA_BASE_ADDR (AIPS2_BASE_ADDR + 0x000D4000) ++#define WDOG_BASE_ADDR (AIPS2_BASE_ADDR + 0x000DC000) ++#define PWM1_BASE_ADDR (AIPS2_BASE_ADDR + 0x000E0000) ++#define RTIC_BASE_ADDR (AIPS2_BASE_ADDR + 0x000EC000) ++#define IIM_BASE_ADDR (AIPS2_BASE_ADDR + 0x000F0000) ++#define USBOTG_BASE_ADDR (AIPS2_BASE_ADDR + 0x000F4000) ++#define OTG_BASE_ADDR USBOTG_BASE_ADDR ++#define CSI_BASE_ADDR (AIPS2_BASE_ADDR + 0x000F8000) ++#define DRYICE_BASE_ADDR (AIPS2_BASE_ADDR + 0x000FC000) ++ ++/* ++ * ROMP and ASIC ++ */ ++#define ROMP_BASE_ADDR UL(0x60000000) ++#define ROMP_BASE_ADDR_VIRT VA(0xFC300000) ++#define ROMP_SIZE SZ_1M ++ ++#define ASIC_BASE_ADDR UL(0x68000000) ++#define ASIC_BASE_ADDR_VIRT VA(0xFC400000) ++#define ASIC_SIZE SZ_1M ++#define AVIC_BASE_ADDR ASIC_BASE_ADDR ++#define AVIC_BASE_ADDR_VIRT ASIC_BASE_ADDR_VIRT ++#define AVIC_SIZE ASIC_SIZE ++ ++/* ++ * SDRAM, WEIM, M3IF, EMI controllers ++ */ ++#define X_MEMC_BASE_ADDR UL(0xB8000000) ++#define X_MEMC_BASE_ADDR_VIRT VA(0xFC520000) ++#define X_MEMC_SIZE SZ_64K ++ ++#define SDRAMC_BASE_ADDR (X_MEMC_BASE_ADDR + 0x1000) ++#define WEIM_BASE_ADDR (X_MEMC_BASE_ADDR + 0x2000) ++#define M3IF_BASE_ADDR (X_MEMC_BASE_ADDR + 0x3000) ++#define EMI_CTL_BASE_ADDR (X_MEMC_BASE_ADDR + 0x4000) ++ ++/* ++ * NFC controller ++ */ ++#define NFC_BASE_ADDR UL(0xBB000000) ++#define NFC_BASE_ADDR_VIRT VA(0xFC530000) ++#define NFC_SIZE SZ_8K ++ ++/* ++ * Memory regions and CS ++ */ ++#define CSD0_BASE_ADDR UL(0x80000000) ++#define CSD1_BASE_ADDR UL(0x90000000) ++ ++#define SDRAM_BASE_ADDR CSD0_BASE_ADDR ++ ++#define CS0_BASE_ADDR UL(0xA0000000) ++#define CS1_BASE_ADDR UL(0xA8000000) ++#define CS2_BASE_ADDR UL(0xB0000000) ++#define CS3_BASE_ADDR UL(0xB2000000) ++#define CS4_BASE_ADDR UL(0xB4000000) ++#define CS4_SIZE SZ_32M ++#define CS5_BASE_ADDR UL(0xB6000000) ++#define CS5_SIZE SZ_32M ++ ++/*! ++ * This macro defines the physical to virtual address mapping for all the ++ * peripheral modules. It is used by passing in the physical address as x ++ * and returning the virtual address. If the physical address is not mapped, ++ * it returns 0 ++ */ ++#define IO_ADDRESS(x) \ ++ VA((((x) >= AIPS1_BASE_ADDR) && ((x) < (AIPS1_BASE_ADDR + AIPS1_SIZE))) ? AIPS1_IO_ADDRESS(x): \ ++ (((x) >= SPBA0_BASE_ADDR) && ((x) < (SPBA0_BASE_ADDR + SPBA0_SIZE))) ? SPBA0_IO_ADDRESS(x): \ ++ (((x) >= AIPS2_BASE_ADDR) && ((x) < (AIPS2_BASE_ADDR + AIPS2_SIZE))) ? AIPS2_IO_ADDRESS(x): \ ++ (((x) >= ROMP_BASE_ADDR) && ((x) < (ROMP_BASE_ADDR + ROMP_SIZE))) ? ROMP_IO_ADDRESS(x): \ ++ (((x) >= ASIC_BASE_ADDR) && ((x) < (ASIC_BASE_ADDR + AVIC_SIZE))) ? ASIC_IO_ADDRESS(x): \ ++ (((x) >= IRAM_BASE_ADDR) && ((x) < (IRAM_BASE_ADDR + IRAM_SIZE))) ? IRAM_IO_ADDRESS(x): \ ++ (((x) >= X_MEMC_BASE_ADDR) && ((x) < (X_MEMC_BASE_ADDR + X_MEMC_SIZE))) ? X_MEMC_IO_ADDRESS(x): \ ++ (((x) >= NFC_BASE_ADDR) && ((x) < (NFC_BASE_ADDR + NFC_SIZE))) ? NFC_IO_ADDRESS(x): \ ++ 0) ++ ++#define MXC_VADDR_RANGE(v,n) \ ++ (((v)) >= n##_BASE_ADDR_VIRT) && \ ++ (((v)) < n##_BASE_ADDR_VIRT + n##_SIZE) ? \ ++ ((v)-n##_BASE_ADDR_VIRT + n##_BASE_ADDR) : ++ ++#define MXC_PHYS_ADDRESS(v) \ ++ UL(MXC_VADDR_RANGE(v,AIPS1) \ ++ MXC_VADDR_RANGE(v,AIPS2) \ ++ MXC_VADDR_RANGE(v,SPBA0) \ ++ MXC_VADDR_RANGE(v,ROMP) \ ++ MXC_VADDR_RANGE(v,ASIC) \ ++ MXC_VADDR_RANGE(v,IRAM) \ ++ MXC_VADDR_RANGE(v,X_MEMC) \ ++ MXC_VADDR_RANGE(v,NFC) \ ++ 0) ++ ++#define GPIO_BASE_ADDR(port) \ ++ ((port == 1 ? GPIO1_BASE_ADDR : \ ++ (port == 2 ? GPIO2_BASE_ADDR : \ ++ (port == 3 ? GPIO3_BASE_ADDR : \ ++ (port == 4 ? GPIO4_BASE_ADDR : 0))))) ++ ++/* ++ * define the address mapping macros: in physical address order ++ */ ++ ++#define AIPS1_IO_ADDRESS(x) \ ++ (((x) - AIPS1_BASE_ADDR) + AIPS1_BASE_ADDR_VIRT) ++ ++#define SPBA0_IO_ADDRESS(x) \ ++ (((x) - SPBA0_BASE_ADDR) + SPBA0_BASE_ADDR_VIRT) ++ ++#define AIPS2_IO_ADDRESS(x) \ ++ (((x) - AIPS2_BASE_ADDR) + AIPS2_BASE_ADDR_VIRT) ++ ++#define ROMP_IO_ADDRESS(x) \ ++ (((x) - ROMP_BASE_ADDR) + ROMP_BASE_ADDR_VIRT) ++ ++#define ASIC_IO_ADDRESS(x) \ ++ (((x) - ASIC_BASE_ADDR) + ASIC_BASE_ADDR_VIRT) ++ ++/* for entry-macro.S */ ++#define AVIC_IO_ADDRESS(x) ASIC_IO_ADDRESS(x) ++ ++#define IRAM_IO_ADDRESS(x) \ ++ (((x) - IRAM_BASE_ADDR) + IRAM_BASE_ADDR_VIRT) ++ ++#define X_MEMC_IO_ADDRESS(x) \ ++ (((x) - X_MEMC_BASE_ADDR) + X_MEMC_BASE_ADDR_VIRT) ++ ++#define NFC_IO_ADDRESS(x) \ ++ (((x) - NFC_BASE_ADDR) + NFC_BASE_ADDR_VIRT) ++ ++/* ++ * DMA request assignments ++ */ ++#define DMA_REQ_EXTREQ0 0 ++#define DMA_REQ_CCM 1 ++#define DMA_REQ_ATA_TX_END 2 ++#define DMA_REQ_ATA_TX 3 ++#define DMA_REQ_ATA_RX 4 ++#define DMA_REQ_CSPI2_RX 6 ++#define DMA_REQ_CSPI2_TX 7 ++#define DMA_REQ_CSPI1_RX 8 ++#define DMA_REQ_CSPI1_TX 9 ++#define DMA_REQ_UART3_RX 10 ++#define DMA_REQ_UART3_TX 11 ++#define DMA_REQ_UART4_RX 12 ++#define DMA_REQ_UART4_TX 13 ++#define DMA_REQ_EXTREQ1 14 ++#define DMA_REQ_EXTREQ2 15 ++#define DMA_REQ_UART2_RX 16 ++#define DMA_REQ_UART2_TX 17 ++#define DMA_REQ_UART1_RX 18 ++#define DMA_REQ_UART1_TX 19 ++#define DMA_REQ_SSI2_RX1 22 ++#define DMA_REQ_SSI2_TX1 23 ++#define DMA_REQ_SSI2_RX0 24 ++#define DMA_REQ_SSI2_TX0 25 ++#define DMA_REQ_SSI1_RX1 26 ++#define DMA_REQ_SSI1_TX1 27 ++#define DMA_REQ_SSI1_RX0 28 ++#define DMA_REQ_SSI1_TX0 29 ++#define DMA_REQ_NFC 30 ++#define DMA_REQ_ECT 31 ++#define DMA_REQ_ESAI_RX 32 ++#define DMA_REQ_ESAI_TX 33 ++#define DMA_REQ_CSPI3_RX 34 ++#define DMA_REQ_CSPI3_TX 35 ++#define DMA_REQ_SIM2_RX 36 ++#define DMA_REQ_SIM2_TX 37 ++#define DMA_REQ_SIM1_RX 38 ++#define DMA_REQ_SIM1_TX 39 ++#define DMA_REQ_TSC_GCQ 44 ++#define DMA_REQ_TSC_TCQ 45 ++#define DMA_REQ_UART5_RX 46 ++#define DMA_REQ_UART5_TX 47 ++ ++/* ++ * Interrupt numbers ++ */ ++#define MXC_INT_CSPI3 0 ++#define MXC_INT_GPT4 1 ++#define MXC_INT_OWIRE 2 ++#define MXC_INT_I2C 3 ++#define MXC_INT_I2C2 4 ++#define MXC_INT_UART4 5 ++#define MXC_INT_RTIC 6 ++#define MXC_INT_ESAI 7 ++#define MXC_INT_SDHC2 8 ++#define MXC_INT_SDHC1 9 ++#define MXC_INT_I2C3 10 ++#define MXC_INT_SSI2 11 ++#define MXC_INT_SSI1 12 ++#define MXC_INT_CSPI2 13 ++#define MXC_INT_CSPI1 14 ++#define MXC_INT_ATA 15 ++#define MXC_INT_GPIO3 16 ++#define MXC_INT_CSI 17 ++#define MXC_INT_UART3 18 ++#define MXC_INT_IIM 19 ++#define MXC_INT_SIM1 20 ++#define MXC_INT_SIM2 21 ++#define MXC_INT_RNGD 22 ++#define MXC_INT_GPIO4 23 ++#define MXC_INT_KPP 24 ++#define MXC_INT_DRYICE_RTC 25 ++#define MXC_INT_PWM 26 ++#define MXC_INT_EPIT2 27 ++#define MXC_INT_EPIT1 28 ++#define MXC_INT_GPT3 29 ++#define MXC_INT_POWER_FAIL 30 ++#define MXC_INT_CRM 31 ++#define MXC_INT_UART2 32 ++#define MXC_INT_NANDFC 33 ++#define MXC_INT_SDMA 34 ++#define MXC_INT_USB_HTG 35 ++#define MXC_INT_PWM2 36 ++#define MXC_INT_USB_OTG 37 ++#define MXC_INT_SLCDC 38 ++#define MXC_INT_LCDC 39 ++#define MXC_INT_UART5 40 ++#define MXC_INT_PWM3 41 ++#define MXC_INT_PWM4 42 ++#define MXC_INT_CAN1 43 ++#define MXC_INT_CAN2 44 ++#define MXC_INT_UART1 45 ++#define MXC_INT_TSC 46 ++#define MXC_INT_ECT 48 ++#define MXC_INT_SCC_SCM 49 ++#define MXC_INT_SCC_SMN 50 ++#define MXC_INT_GPIO2 51 ++#define MXC_INT_GPIO1 52 ++#define MXC_INT_GPT2 53 ++#define MXC_INT_GPT1 54 ++#define MXC_INT_WDOG 55 ++#define MXC_INT_DRYICE 56 ++#define MXC_INT_FEC 57 ++#define MXC_INT_EXT_INT5 58 ++#define MXC_INT_EXT_INT4 59 ++#define MXC_INT_EXT_INT3 60 ++#define MXC_INT_EXT_INT2 61 ++#define MXC_INT_EXT_INT1 62 ++#define MXC_INT_EXT_INT0 63 ++ ++#define MXC_INT_GPT MXC_INT_GPT1 ++ ++/* silicon revisions specific to i.MX25 */ ++#define CHIP_REV_1_0 0x00 ++#define CHIP_REV_1_1 0x01 ++ ++/* gpio and gpio based interrupt handling */ ++#define GPIO_DR 0x00 ++#define GPIO_GDIR 0x04 ++#define GPIO_PSR 0x08 ++#define GPIO_ICR1 0x0C ++#define GPIO_ICR2 0x10 ++#define GPIO_IMR 0x14 ++#define GPIO_ISR 0x18 ++#define GPIO_INT_LOW_LEV 0x0 ++#define GPIO_INT_HIGH_LEV 0x1 ++#define GPIO_INT_RISE_EDGE 0x2 ++#define GPIO_INT_FALL_EDGE 0x3 ++#define GPIO_INT_NONE 0x4 ++ ++/* Mandatory defines used globally */ ++ ++/* this CPU supports up to 96 GPIOs */ ++#define ARCH_NR_GPIOS 128 ++ ++#define MXC_TIMER_GPT1 1 ++#define MXC_TIMER_GPT2 2 ++#define MXC_TIMER_GPT3 3 ++#define MXC_TIMER_GPT4 4 ++ ++/*! ++ * NFMS bit in RCSR register for pagesize of nandflash ++ */ ++#define NFMS_REG IO_ADDRESS(CCM_BASE_ADDR + 0x28) ++#define NFMS_NF_DWIDTH 14 ++#define NFMS_NF_PG_SZ 8 ++ ++#if !defined(__ASSEMBLY__) && !defined(__MXC_BOOT_UNCOMPRESS) ++#include ++ ++extern int mx25_revision(void); ++ ++#endif ++ ++#endif /* __ASM_ARCH_MXC_MX25_H__ */ +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/mx2x.h linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/mx2x.h +--- linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/mx2x.h 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/mx2x.h 2009-06-02 17:05:27.000000000 +0200 +@@ -79,7 +79,7 @@ + * This macro defines the physical to virtual address mapping for all the + * peripheral modules. It is used by passing in the physical address as x + * and returning the virtual address. If the physical address is not mapped, +- * it returns 0xDEADBEEF ++ * it returns 0 + */ + #define IO_ADDRESS(x) \ + (void __force __iomem *) \ +@@ -88,7 +88,7 @@ + ((x >= SAHB1_BASE_ADDR) && (x < (SAHB1_BASE_ADDR + SAHB1_SIZE))) ? \ + SAHB1_IO_ADDRESS(x) : \ + ((x >= X_MEMC_BASE_ADDR) && (x < (X_MEMC_BASE_ADDR + X_MEMC_SIZE))) ? \ +- X_MEMC_IO_ADDRESS(x) : 0xDEADBEEF) ++ X_MEMC_IO_ADDRESS(x) : 0) + + /* define the address mapping macros: in physical address order */ + #define AIPI_IO_ADDRESS(x) \ +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/mxc.h linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/mxc.h +--- linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/mxc.h 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/mxc.h 2009-06-02 17:05:27.000000000 +0200 +@@ -27,6 +27,7 @@ + #define MXC_CPU_MX1 1 + #define MXC_CPU_MX21 21 + #define MXC_CPU_MX27 27 ++#define MXC_CPU_MX25 25 + #define MXC_CPU_MX31 31 + #define MXC_CPU_MX35 35 + +@@ -70,6 +71,18 @@ extern unsigned int __mxc_cpu_type; + # define cpu_is_mx27() (0) + #endif + ++#ifdef CONFIG_MACH_MX25 ++# ifdef mxc_cpu_type ++# undef mxc_cpu_type ++# define mxc_cpu_type __mxc_cpu_type ++# else ++# define mxc_cpu_type MXC_CPU_MX25 ++# endif ++# define cpu_is_mx25() (mxc_cpu_type == MXC_CPU_MX25) ++#else ++# define cpu_is_mx25() (0) ++#endif ++ + #ifdef CONFIG_ARCH_MX31 + # ifdef mxc_cpu_type + # undef mxc_cpu_type +@@ -101,6 +114,6 @@ extern unsigned int __mxc_cpu_type; + #endif + + #define cpu_is_mx3() (cpu_is_mx31() || cpu_is_mx35()) +-#define cpu_is_mx2() (cpu_is_mx21() || cpu_is_mx27()) ++#define cpu_is_mx2() (cpu_is_mx21() || cpu_is_mx25() || cpu_is_mx27()) + + #endif /* __ASM_ARCH_MXC_H__ */ +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/sdma.h linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/sdma.h +--- linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/sdma.h 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/sdma.h 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,504 @@ ++ ++/* ++ * Copyright 2004-2008 Freescale Semiconductor, Inc. All Rights Reserved. ++ */ ++ ++/* ++ * The code contained herein is licensed under the GNU General Public ++ * License. You may obtain a copy of the GNU General Public License ++ * Version 2 or later at the following locations: ++ * ++ * http://www.opensource.org/licenses/gpl-license.html ++ * http://www.gnu.org/copyleft/gpl.html ++ */ ++ ++#ifndef __ASM_ARCH_MXC_SDMA_H__ ++#define __ASM_ARCH_MXC_SDMA_H__ ++ ++/*! ++ * @defgroup SDMA Smart Direct Memory Access (SDMA) Driver ++ */ ++ ++/*! ++ * @file arch-mxc/sdma.h ++ * ++ * @brief This file contains the SDMA API declarations. ++ * ++ * SDMA is responsible on moving data between peripherals and memories (MCU, EMI and DSP). ++ * ++ * @ingroup SDMA ++ */ ++ ++#include ++#include ++#include ++#include ++ ++/*! ++ * This defines maximum DMA address ++ */ ++#define MAX_DMA_ADDRESS 0xffffffff ++ ++/*! ++ * This defines maximum number of DMA channels ++ */ ++#ifdef CONFIG_MXC_SDMA_API ++#define MAX_DMA_CHANNELS 32 ++#define MAX_BD_NUMBER 16 ++#define MXC_SDMA_DEFAULT_PRIORITY 1 ++#define MXC_SDMA_MIN_PRIORITY 1 ++#define MXC_SDMA_MAX_PRIORITY 7 ++#else ++#define MAX_DMA_CHANNELS 0 ++#endif ++ ++#define MXC_FIFO_MEM_DEST_FIXED 0x1 ++#define MXC_FIFO_MEM_SRC_FIXED 0x2 ++/*! ++ * This enumerates transfer types ++ */ ++typedef enum { ++ emi_2_per = 0, /*!< EMI memory to peripheral */ ++ emi_2_int, /*!< EMI memory to internal RAM */ ++ emi_2_emi, /*!< EMI memory to EMI memory */ ++ emi_2_dsp, /*!< EMI memory to DSP memory */ ++ per_2_int, /*!< Peripheral to internal RAM */ ++ per_2_emi, /*!< Peripheral to internal EMI memory */ ++ per_2_dsp, /*!< Peripheral to DSP memory */ ++ per_2_per, /*!< Peripheral to Peripheral */ ++ int_2_per, /*!< Internal RAM to peripheral */ ++ int_2_int, /*!< Internal RAM to Internal RAM */ ++ int_2_emi, /*!< Internal RAM to EMI memory */ ++ int_2_dsp, /*!< Internal RAM to DSP memory */ ++ dsp_2_per, /*!< DSP memory to peripheral */ ++ dsp_2_int, /*!< DSP memory to internal RAM */ ++ dsp_2_emi, /*!< DSP memory to EMI memory */ ++ dsp_2_dsp, /*!< DSP memory to DSP memory */ ++ emi_2_dsp_loop, /*!< EMI memory to DSP memory loopback */ ++ dsp_2_emi_loop, /*!< DSP memory to EMI memory loopback */ ++ dvfs_pll, /*!< DVFS script with PLL change */ ++ dvfs_pdr /*!< DVFS script without PLL change */ ++} sdma_transferT; ++ ++/*! ++ * This enumerates peripheral types ++ */ ++typedef enum { ++ SSI, /*!< MCU domain SSI */ ++ SSI_SP, /*!< Shared SSI */ ++ MMC, /*!< MMC */ ++ SDHC, /*!< SDHC */ ++ UART, /*!< MCU domain UART */ ++ UART_SP, /*!< Shared UART */ ++ FIRI, /*!< FIRI */ ++ CSPI, /*!< MCU domain CSPI */ ++ CSPI_SP, /*!< Shared CSPI */ ++ SIM, /*!< SIM */ ++ ATA, /*!< ATA */ ++ CCM, /*!< CCM */ ++ EXT, /*!< External peripheral */ ++ MSHC, /*!< Memory Stick Host Controller */ ++ MSHC_SP, /*!< Shared Memory Stick Host Controller */ ++ DSP, /*!< DSP */ ++ MEMORY, /*!< Memory */ ++ FIFO_MEMORY, /*!< FIFO type Memory */ ++ SPDIF, /*!< SPDIF */ ++ IPU_MEMORY, /*!< IPU Memory */ ++ ASRC, /*!< ASRC */ ++ ESAI, /*!< ESAI */ ++} sdma_periphT; ++ ++#ifndef TRANSFER_32BIT ++/*! ++ * This defines SDMA access data size ++ */ ++#define TRANSFER_32BIT 0x00 ++#define TRANSFER_8BIT 0x01 ++#define TRANSFER_16BIT 0x02 ++#define TRANSFER_24BIT 0x03 ++ ++#endif ++ ++/*! ++ * This defines maximum device name length passed during mxc_request_dma(). ++ */ ++#define MAX_DEVNAME_LENGTH 32 ++ ++/*! ++ * This defines SDMA interrupt callback function prototype. ++ */ ++typedef void (*dma_callback_t) (void *arg); ++ ++/*! ++ * Structure containing sdma channel parameters. ++ */ ++typedef struct { ++ __u32 watermark_level; /*!< Lower/upper threshold that ++ * triggers SDMA event ++ */ ++ __u32 per_address; /*!< Peripheral source/destination ++ * physical address ++ */ ++ sdma_periphT peripheral_type; /*!< Peripheral type */ ++ sdma_transferT transfer_type; /*!< Transfer type */ ++ int event_id; /*!< Event number, ++ * needed by all channels ++ * that started by peripherals dma ++ * request (per_2_*,*_2_per) ++ * Not used for memory and DSP ++ * transfers. ++ */ ++ int event_id2; /*!< Second event number, ++ * used in ATA scripts only. ++ */ ++ int bd_number; /*!< Buffer descriptors number. ++ * If not set, single buffer ++ * descriptor will be used. ++ */ ++ dma_callback_t callback; /*! callback function */ ++ void *arg; /*! callback argument */ ++ unsigned long word_size:8; /*!< SDMA data access word size */ ++} dma_channel_params; ++ ++/*! ++ * Structure containing sdma request parameters. ++ */ ++typedef struct { ++ /*! physical source memory address */ ++ __u8 *sourceAddr; ++ /*! physical destination memory address */ ++ __u8 *destAddr; ++ /*! amount of data to transfer, ++ * updated during mxc_dma_get_config ++ */ ++ __u16 count; ++ /*!< DONE bit of the buffer descriptor, ++ * updated during mxc_dma_get_config ++ * 0 - means the BD is done and closed by SDMA ++ * 1 - means the BD is still being processed by SDMA ++ */ ++ int bd_done; ++ /*!< CONT bit of the buffer descriptor, ++ * set it if full multi-buffer descriptor mechanism ++ * required. ++ */ ++ int bd_cont; ++ /*!< ERROR bit of the buffer descriptor, ++ * updated during mxc_dma_get_config. ++ * If it is set - there was an error during BD processing. ++ */ ++ int bd_error; ++} dma_request_t; ++ ++/*! ++ * Structure containing sdma request parameters. ++ */ ++typedef struct { ++ /*! address of ap_2_ap script */ ++ int mxc_sdma_ap_2_ap_addr; ++ /*! address of ap_2_bp script */ ++ int mxc_sdma_ap_2_bp_addr; ++ /*! address of ap_2_ap_fixed script */ ++ int mxc_sdma_ap_2_ap_fixed_addr; ++ /*! address of bp_2_ap script */ ++ int mxc_sdma_bp_2_ap_addr; ++ /*! address of loopback_on_dsp_side script */ ++ int mxc_sdma_loopback_on_dsp_side_addr; ++ /*! address of mcu_interrupt_only script */ ++ int mxc_sdma_mcu_interrupt_only_addr; ++ ++ /*! address of firi_2_per script */ ++ int mxc_sdma_firi_2_per_addr; ++ /*! address of firi_2_mcu script */ ++ int mxc_sdma_firi_2_mcu_addr; ++ /*! address of per_2_firi script */ ++ int mxc_sdma_per_2_firi_addr; ++ /*! address of mcu_2_firi script */ ++ int mxc_sdma_mcu_2_firi_addr; ++ ++ /*! address of uart_2_per script */ ++ int mxc_sdma_uart_2_per_addr; ++ /*! address of uart_2_mcu script */ ++ int mxc_sdma_uart_2_mcu_addr; ++ /*! address of per_2_app script */ ++ int mxc_sdma_per_2_app_addr; ++ /*! address of mcu_2_app script */ ++ int mxc_sdma_mcu_2_app_addr; ++ /*! address of per_2_per script */ ++ int mxc_sdma_per_2_per_addr; ++ ++ /*! address of uartsh_2_per script */ ++ int mxc_sdma_uartsh_2_per_addr; ++ /*! address of uartsh_2_mcu script */ ++ int mxc_sdma_uartsh_2_mcu_addr; ++ /*! address of per_2_shp script */ ++ int mxc_sdma_per_2_shp_addr; ++ /*! address of mcu_2_shp script */ ++ int mxc_sdma_mcu_2_shp_addr; ++ ++ /*! address of ata_2_mcu script */ ++ int mxc_sdma_ata_2_mcu_addr; ++ /*! address of mcu_2_ata script */ ++ int mxc_sdma_mcu_2_ata_addr; ++ ++ /*! address of app_2_per script */ ++ int mxc_sdma_app_2_per_addr; ++ /*! address of app_2_mcu script */ ++ int mxc_sdma_app_2_mcu_addr; ++ /*! address of shp_2_per script */ ++ int mxc_sdma_shp_2_per_addr; ++ /*! address of shp_2_mcu script */ ++ int mxc_sdma_shp_2_mcu_addr; ++ ++ /*! address of mshc_2_mcu script */ ++ int mxc_sdma_mshc_2_mcu_addr; ++ /*! address of mcu_2_mshc script */ ++ int mxc_sdma_mcu_2_mshc_addr; ++ ++ /*! address of spdif_2_mcu script */ ++ int mxc_sdma_spdif_2_mcu_addr; ++ /*! address of mcu_2_spdif script */ ++ int mxc_sdma_mcu_2_spdif_addr; ++ ++ /*! address of asrc_2_mcu script */ ++ int mxc_sdma_asrc_2_mcu_addr; ++ ++ /*! address of ext_mem_2_ipu script */ ++ int mxc_sdma_ext_mem_2_ipu_addr; ++ ++ /*! address of descrambler script */ ++ int mxc_sdma_descrambler_addr; ++ ++ /*! address of dptc_dvfs script */ ++ int mxc_sdma_dptc_dvfs_addr; ++ ++ int mxc_sdma_utra_addr; ++ ++ /*! address where ram code starts */ ++ int mxc_sdma_ram_code_start_addr; ++ /*! size of the ram code */ ++ int mxc_sdma_ram_code_size; ++ /*! RAM image address */ ++ unsigned short *mxc_sdma_start_addr; ++} sdma_script_start_addrs; ++ ++/*! Structure to store the initialized dma_channel parameters */ ++typedef struct mxc_sdma_channel_params { ++ /*! Channel params */ ++ dma_channel_params chnl_params; ++ /*! Channel type (static channel number or dynamic channel) */ ++ unsigned int channel_num; ++ /*! Channel priority [0x1(lowest) - 0x7(highest)] */ ++ unsigned int chnl_priority; ++} mxc_sdma_channel_params_t; ++ ++/*! Private SDMA data structure */ ++typedef struct mxc_dma_channel_private { ++ /*! ID of the buffer that was processed */ ++ unsigned int buf_tail; ++ /*! Tasklet for the channel */ ++ struct tasklet_struct chnl_tasklet; ++ /*! Flag indicates if interrupt is required after every BD transfer */ ++ int intr_after_every_bd; ++} mxc_dma_channel_private_t; ++ ++/*! ++ * Setup channel according to parameters. ++ * Must be called once after mxc_request_dma() ++ * ++ * @param channel channel number ++ * @param p channel parameters pointer ++ * @return 0 on success, error code on fail ++ */ ++int mxc_dma_setup_channel(int channel, dma_channel_params * p); ++ ++/*! ++ * Setup the channel priority. This can be used to change the default priority ++ * for the channel. ++ * ++ * @param channel channel number ++ * @param priority priority to be set for the channel ++ * ++ * @return 0 on success, error code on failure ++ */ ++int mxc_dma_set_channel_priority(unsigned int channel, unsigned int priority); ++ ++/*! ++ * Allocates dma channel. ++ * If channel's value is 0, then the function allocates a free channel ++ * dynamically and sets its value to channel. ++ * Else allocates requested channel if it is free. ++ * If the channel is busy or no free channels (in dynamic allocation) -EBUSY returned. ++ * ++ * @param channel pointer to channel number ++ * @param devicename device name ++ * @return 0 on success, error code on fail ++ */ ++int mxc_request_dma(int *channel, const char *devicename); ++ ++/*! ++ * Configures request parameters. Can be called multiple times after ++ * mxc_request_dma() and mxc_dma_setup_channel(). ++ * ++ * ++ * @param channel channel number ++ * @param p request parameters pointer ++ * @param bd_index index of buffer descriptor to set ++ * @return 0 on success, error code on fail ++ */ ++/* int mxc_dma_set_config(int channel, dma_request_t *p, int bd_index); */ ++int mxc_dma_set_config(int channel, dma_request_t * p, int bd_index); ++ ++/*! ++ * Returns request parameters. ++ * ++ * @param channel channel number ++ * @param p request parameters pointer ++ * @param bd_index index of buffer descriptor to get ++ * @return 0 on success, error code on fail ++ */ ++/* int mxc_dma_get_config(int channel, dma_request_t *p, int bd_index); */ ++int mxc_dma_get_config(int channel, dma_request_t * p, int bd_index); ++ ++/*! ++ * This function is used by MXC IPC's write_ex2. It passes the a pointer to the ++ * data control structure to iapi_write_ipcv2() ++ * ++ * @param channel SDMA channel number ++ * @param ctrl_ptr Data Control structure pointer ++ */ ++int mxc_sdma_write_ipcv2(int channel, void *ctrl_ptr); ++ ++/*! ++ * This function is used by MXC IPC's read_ex2. It passes the a pointer to the ++ * data control structure to iapi_read_ipcv2() ++ * ++ * @param channel SDMA channel number ++ * @param ctrl_ptr Data Control structure pointer ++ */ ++int mxc_sdma_read_ipcv2(int channel, void *ctrl_ptr); ++ ++/*! ++ * Starts dma channel. ++ * ++ * @param channel channel number ++ */ ++int mxc_dma_start(int channel); ++ ++/*! ++ * Stops dma channel. ++ * ++ * @param channel channel number ++ */ ++int mxc_dma_stop(int channel); ++ ++/*! ++ * Frees dma channel. ++ * ++ * @param channel channel number ++ */ ++void mxc_free_dma(int channel); ++ ++/*! ++ * Sets callback function. Used with standard dma api ++ * for supporting interrupts ++ * ++ * @param channel channel number ++ * @param callback callback function pointer ++ * @param arg argument for callback function ++ */ ++void mxc_dma_set_callback(int channel, dma_callback_t callback, void *arg); ++ ++/*! ++ * Allocates uncachable buffer. Uses hash table. ++ * ++ * @param size size of allocated buffer ++ * @return pointer to buffer ++ */ ++void *sdma_malloc(size_t size); ++ ++#ifdef CONFIG_SDMA_IRAM ++/*! ++ * Allocates uncachable buffer from IRAM.. ++ * ++ * @param size size of allocated buffer ++ * @return pointer to buffer ++ */ ++void *sdma_iram_malloc(size_t size); ++#endif /*CONFIG_SDMA_IRAM */ ++ ++/*! ++ * Frees uncachable buffer. Uses hash table. ++ */ ++void sdma_free(void *buf); ++ ++/*! ++ * Converts virtual to physical address. Uses hash table. ++ * ++ * @param buf virtual address pointer ++ * @return physical address value ++ */ ++unsigned long sdma_virt_to_phys(void *buf); ++ ++/*! ++ * Converts physical to virtual address. Uses hash table. ++ * ++ * @param buf physical address value ++ * @return virtual address pointer ++ */ ++void *sdma_phys_to_virt(unsigned long buf); ++ ++/*! ++ * Configures the BD_INTR bit on a buffer descriptor parameters. ++ * ++ * ++ * @param channel channel number ++ * @param bd_index index of buffer descriptor to set ++ * @param bd_intr flag to set or clear the BD_INTR bit ++ */ ++void mxc_dma_set_bd_intr(int channel, int bd_index, int bd_intr); ++ ++/*! ++ * Gets the BD_INTR bit on a buffer descriptor. ++ * ++ * ++ * @param channel channel number ++ * @param bd_index index of buffer descriptor to set ++ * ++ * @return returns the BD_INTR bit status ++ */ ++int mxc_dma_get_bd_intr(int channel, int bd_index); ++ ++/*! ++ * Stop the current transfer ++ * ++ * @param channel channel number ++ * @param buffer_number number of buffers (beginning with 0), ++ * whose done bits should be reset to 0 ++ */ ++int mxc_dma_reset(int channel, int buffer_number); ++ ++/*! ++ * This functions Returns the SDMA paramaters associated for a module ++ * ++ * @param channel_id the ID of the module requesting DMA ++ * @return returns the sdma parameters structure for the device ++ */ ++mxc_sdma_channel_params_t *mxc_sdma_get_channel_params(mxc_dma_device_t ++ channel_id); ++ ++/*! ++ * This functions marks the SDMA channels that are statically allocated ++ * ++ * @param chnl the channel array used to store channel information ++ */ ++void mxc_get_static_channels(mxc_dma_channel_t * chnl); ++ ++/*! ++ * Initializes SDMA driver ++ */ ++int __init sdma_init(void); ++ ++#define DEFAULT_ERR 1 ++ ++#endif +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/spba.h linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/spba.h +--- linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/spba.h 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/spba.h 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,66 @@ ++ ++/* ++ * Copyright 2004-2008 Freescale Semiconductor, Inc. All Rights Reserved. ++ */ ++ ++/* ++ * The code contained herein is licensed under the GNU General Public ++ * License. You may obtain a copy of the GNU General Public License ++ * Version 2 or later at the following locations: ++ * ++ * http://www.opensource.org/licenses/gpl-license.html ++ * http://www.gnu.org/copyleft/gpl.html ++ */ ++ ++/*! ++ * @defgroup SPBA Shared Peripheral Bus Arbiter (SPBA) ++ * @ingroup MSL_MX31 MSL_MX35 MSL_MX37 MSL_MX51 MSL_MXC91321 ++ */ ++ ++/*! ++ * @file arch-mxc/spba.h ++ * @brief This file contains the Shared Peripheral Bus Arbiter (spba) API. ++ * ++ * @ingroup SPBA ++ */ ++ ++#ifndef __ASM_ARCH_MXC_SPBA_H__ ++#define __ASM_ARCH_MXC_SPBA_H__ ++ ++#ifdef __KERNEL__ ++ ++#define MXC_SPBA_RAR_MASK 0x7 ++ ++/*! ++ * Defines three SPBA masters: A - ARM, C - SDMA (no master B for MX31) ++ */ ++enum spba_masters { ++ SPBA_MASTER_A = 1, ++ SPBA_MASTER_B = 2, ++ SPBA_MASTER_C = 4, ++}; ++ ++/*! ++ * This function allows the three masters (A, B, C) to take ownership of a ++ * shared peripheral. ++ * ++ * @param mod specified module as defined in \b enum \b #spba_module ++ * @param master one of more (or-ed together) masters as defined in \b enum \b #spba_masters ++ * ++ * @return 0 if successful; -1 otherwise. ++ */ ++int spba_take_ownership(int mod, int master); ++ ++/*! ++ * This function releases the ownership for a shared peripheral. ++ * ++ * @param mod specified module as defined in \b enum \b #spba_module ++ * @param master one of more (or-ed together) masters as defined in \b enum \b #spba_masters ++ * ++ * @return 0 if successful; -1 otherwise. ++ */ ++int spba_rel_ownership(int mod, int master); ++ ++#endif /* __KERNEL__ */ ++ ++#endif /* __ASM_ARCH_MXC_SPBA_H__ */ +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/timex.h linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/timex.h +--- linux-2.6.30-rc4/arch/arm/plat-mxc/include/mach/timex.h 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/include/mach/timex.h 2009-06-02 17:05:27.000000000 +0200 +@@ -23,7 +23,11 @@ + #if defined CONFIG_ARCH_MX1 + #define CLOCK_TICK_RATE 16000000 + #elif defined CONFIG_ARCH_MX2 ++#ifndef CONFIG_MACH_MX25 + #define CLOCK_TICK_RATE 13300000 ++#else ++#define CLOCK_TICK_RATE 12000000 ++#endif + #elif defined CONFIG_ARCH_MX3 + #define CLOCK_TICK_RATE 16625000 + #endif +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/iomux-mx1-mx2.c linux-2.6.30-rc4-karo/arch/arm/plat-mxc/iomux-mx1-mx2.c +--- linux-2.6.30-rc4/arch/arm/plat-mxc/iomux-mx1-mx2.c 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/iomux-mx1-mx2.c 2009-06-02 17:05:27.000000000 +0200 +@@ -74,11 +74,12 @@ void mxc_gpio_mode(int gpio_mode) + __raw_writel(tmp, VA_GPIO_BASE + MXC_GIUS(port)); + + if (pin < 16) { ++#ifndef CONFIG_MACH_MX25 + tmp = __raw_readl(VA_GPIO_BASE + MXC_OCR1(port)); + tmp &= ~(3 << (pin * 2)); + tmp |= (ocr << (pin * 2)); + __raw_writel(tmp, VA_GPIO_BASE + MXC_OCR1(port)); +- ++#endif + tmp = __raw_readl(VA_GPIO_BASE + MXC_ICONFA1(port)); + tmp &= ~(3 << (pin * 2)); + tmp |= ((gpio_mode >> GPIO_AOUT_SHIFT) & 3) << (pin * 2); +@@ -90,12 +91,12 @@ void mxc_gpio_mode(int gpio_mode) + __raw_writel(tmp, VA_GPIO_BASE + MXC_ICONFB1(port)); + } else { + pin -= 16; +- ++#ifndef CONFIG_MACH_MX25 + tmp = __raw_readl(VA_GPIO_BASE + MXC_OCR2(port)); + tmp &= ~(3 << (pin * 2)); + tmp |= (ocr << (pin * 2)); + __raw_writel(tmp, VA_GPIO_BASE + MXC_OCR2(port)); +- ++#endif + tmp = __raw_readl(VA_GPIO_BASE + MXC_ICONFA2(port)); + tmp &= ~(3 << (pin * 2)); + tmp |= ((gpio_mode >> GPIO_AOUT_SHIFT) & 3) << (pin * 2); +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/iomux-v3.c linux-2.6.30-rc4-karo/arch/arm/plat-mxc/iomux-v3.c +--- linux-2.6.30-rc4/arch/arm/plat-mxc/iomux-v3.c 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/iomux-v3.c 2009-06-02 17:05:27.000000000 +0200 +@@ -31,7 +31,24 @@ + + #define IOMUX_BASE IO_ADDRESS(IOMUXC_BASE_ADDR) + +-static unsigned long iomux_v3_pad_alloc_map[0x200 / BITS_PER_LONG]; ++#ifdef CONFIG_MACH_MX25 ++#define NUM_PADS 0x228 ++#else ++#define NUM_PADS 0x200 ++#endif ++ ++static unsigned long iomux_v3_pad_alloc_map[NUM_PADS / BITS_PER_LONG]; ++ ++static inline int mxc_iomux_v3_pad_offset(struct pad_desc *pad) ++{ ++ int pad_ofs; ++ if (cpu_is_mx25()) ++ pad_ofs = pad->mux_ctrl_ofs; ++ else ++ pad_ofs = pad->pad_ctrl_ofs; ++ BUG_ON((pad_ofs >> 7) >= ARRAY_SIZE(iomux_v3_pad_alloc_map)); ++ return pad_ofs; ++} + + /* + * setups a single pin: +@@ -40,7 +57,7 @@ static unsigned long iomux_v3_pad_alloc_ + */ + int mxc_iomux_v3_setup_pad(struct pad_desc *pad) + { +- unsigned int pad_ofs = pad->pad_ctrl_ofs; ++ unsigned int pad_ofs = mxc_iomux_v3_pad_offset(pad); + + if (test_and_set_bit(pad_ofs >> 2, iomux_v3_pad_alloc_map)) + return -EBUSY; +@@ -65,8 +82,10 @@ int mxc_iomux_v3_setup_multiple_pads(str + + for (i = 0; i < count; i++) { + ret = mxc_iomux_v3_setup_pad(p); +- if (ret) ++ if (ret) { ++ printk(KERN_ERR "Failed to setup PAD[%d]: %d\n", i, ret); + goto setup_error; ++ } + p++; + } + return 0; +@@ -79,7 +98,7 @@ EXPORT_SYMBOL(mxc_iomux_v3_setup_multipl + + void mxc_iomux_v3_release_pad(struct pad_desc *pad) + { +- unsigned int pad_ofs = pad->pad_ctrl_ofs; ++ unsigned int pad_ofs = mxc_iomux_v3_pad_offset(pad); + + clear_bit(pad_ofs >> 2, iomux_v3_pad_alloc_map); + } +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/pwm.c linux-2.6.30-rc4-karo/arch/arm/plat-mxc/pwm.c +--- linux-2.6.30-rc4/arch/arm/plat-mxc/pwm.c 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/pwm.c 2009-06-02 17:05:27.000000000 +0200 +@@ -55,7 +55,7 @@ int pwm_config(struct pwm_device *pwm, i + if (pwm == NULL || period_ns == 0 || duty_ns > period_ns) + return -EINVAL; + +- if (cpu_is_mx27() || cpu_is_mx3()) { ++ if (cpu_is_mx27() || cpu_is_mx3() || cpu_is_mx25()) { + unsigned long long c; + unsigned long period_cycles, duty_cycles, prescale; + c = clk_get_rate(pwm->clk); +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/spba.c linux-2.6.30-rc4-karo/arch/arm/plat-mxc/spba.c +--- linux-2.6.30-rc4/arch/arm/plat-mxc/spba.c 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/spba.c 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,143 @@ ++/* ++ * Copyright 2004-2008 Freescale Semiconductor, Inc. All Rights Reserved. ++ */ ++ ++/* ++ * The code contained herein is licensed under the GNU General Public ++ * License. You may obtain a copy of the GNU General Public License ++ * Version 2 or later at the following locations: ++ * ++ * http://www.opensource.org/licenses/gpl-license.html ++ * http://www.gnu.org/copyleft/gpl.html ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/*! ++ * @file plat-mxc/spba.c ++ * ++ * @brief This file contains the SPBA API implementation details. ++ * ++ * @ingroup SPBA ++ */ ++ ++static DEFINE_SPINLOCK(spba_lock); ++ ++#define SPBA_MASTER_MIN 1 ++#define SPBA_MASTER_MAX 7 ++ ++/*! ++ * the base addresses for the SPBA modules ++ */ ++static unsigned long spba_base = (unsigned long)IO_ADDRESS(SPBA_CTRL_BASE_ADDR); ++ ++/*! ++ * SPBA clock ++ */ ++static struct clk *spba_clk; ++/*! ++ * This function allows the three masters (A, B, C) to take ownership of a ++ * shared peripheral. ++ * ++ * @param mod specified module as defined in \b enum \b #spba_module ++ * @param master one of more (or-ed together) masters as defined in \b enum \b #spba_masters ++ * ++ * @return 0 if successful; a negative errno value otherwise. ++ */ ++int spba_take_ownership(int mod, int master) ++{ ++ unsigned long spba_flags; ++ int rtn_val = -EIO; ++ ++ if (master < SPBA_MASTER_MIN || master > SPBA_MASTER_MAX) { ++ printk("%s() invalid master %d\n", __FUNCTION__, master); ++ return -EINVAL; ++ } ++ ++ if (spba_clk == NULL) { ++ spba_clk = clk_get(NULL, "spba"); ++ if (IS_ERR(spba_clk)) { ++ int ret = PTR_ERR(spba_clk); ++ ++ spba_clk = NULL; ++ return ret; ++ } ++ } ++ clk_enable(spba_clk); ++ ++ spin_lock_irqsave(&spba_lock, spba_flags); ++ __raw_writel(master, spba_base + mod); ++ ++ if ((__raw_readl(spba_base + mod) & MXC_SPBA_RAR_MASK) == master) { ++ rtn_val = 0; ++ } ++ ++ spin_unlock_irqrestore(&spba_lock, spba_flags); ++ ++ clk_disable(spba_clk); ++ return rtn_val; ++} ++ ++/*! ++ * This function releases the ownership for a shared peripheral. ++ * ++ * @param mod specified module as defined in \b enum \b #spba_module ++ * @param master one of more (or-ed together) masters as defined in \b enum \b #spba_masters ++ * ++ * @return 0 if successful; a negativ errno value otherwise. ++ */ ++int spba_rel_ownership(int mod, int master) ++{ ++ unsigned long spba_flags; ++ volatile unsigned long rar; ++ ++ if (master < SPBA_MASTER_MIN || master > SPBA_MASTER_MAX) { ++ printk("%s() invalid master %d\n", __FUNCTION__, master); ++ return -EINVAL; ++ } ++ ++ if (spba_clk == NULL) { ++ spba_clk = clk_get(NULL, "spba"); ++ if (IS_ERR(spba_clk)) { ++ int ret = PTR_ERR(spba_clk); ++ spba_clk = NULL; ++ return ret; ++ } ++ } ++ clk_enable(spba_clk); ++ ++ if ((__raw_readl(spba_base + mod) & master) == 0) { ++ clk_disable(spba_clk); ++ return -EBUSY; /* does not own it */ ++ } ++ ++ spin_lock_irqsave(&spba_lock, spba_flags); ++ ++ /* Since only the last 3 bits are writeable, doesn't need to mask off ++ bits 31-3 */ ++ rar = __raw_readl(spba_base + mod) & (~master); ++ __raw_writel(rar, spba_base + mod); ++ ++ if ((__raw_readl(spba_base + mod) & master) != 0) { ++ spin_unlock_irqrestore(&spba_lock, spba_flags); ++ clk_disable(spba_clk); ++ return -EIO; ++ } ++ spin_unlock_irqrestore(&spba_lock, spba_flags); ++ ++ clk_disable(spba_clk); ++ return 0; ++} ++ ++EXPORT_SYMBOL(spba_take_ownership); ++EXPORT_SYMBOL(spba_rel_ownership); ++ ++MODULE_AUTHOR("Freescale Semiconductor, Inc."); ++MODULE_DESCRIPTION("SPBA"); ++MODULE_LICENSE("GPL"); +diff -urNp linux-2.6.30-rc4/arch/arm/plat-mxc/time.c linux-2.6.30-rc4-karo/arch/arm/plat-mxc/time.c +--- linux-2.6.30-rc4/arch/arm/plat-mxc/time.c 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/plat-mxc/time.c 2009-06-02 17:05:27.000000000 +0200 +@@ -66,7 +66,7 @@ static inline void gpt_irq_disable(void) + { + unsigned int tmp; + +- if (cpu_is_mx3()) ++ if (cpu_is_mx3() || cpu_is_mx25()) + __raw_writel(0, timer_base + MX3_IR); + else { + tmp = __raw_readl(timer_base + MXC_TCTL); +@@ -76,7 +76,7 @@ static inline void gpt_irq_disable(void) + + static inline void gpt_irq_enable(void) + { +- if (cpu_is_mx3()) ++ if (cpu_is_mx3() || cpu_is_mx25()) + __raw_writel(1<<0, timer_base + MX3_IR); + else { + __raw_writel(__raw_readl(timer_base + MXC_TCTL) | MX1_2_TCTL_IRQEN, +@@ -88,9 +88,9 @@ static void gpt_irq_acknowledge(void) + { + if (cpu_is_mx1()) + __raw_writel(0, timer_base + MX1_2_TSTAT); +- if (cpu_is_mx2()) ++ if (cpu_is_mx2() && !cpu_is_mx25()) + __raw_writel(MX2_TSTAT_CAPT | MX2_TSTAT_COMP, timer_base + MX1_2_TSTAT); +- if (cpu_is_mx3()) ++ if (cpu_is_mx3() || cpu_is_mx25()) + __raw_writel(MX3_TSTAT_OF1, timer_base + MX3_TSTAT); + } + +@@ -117,7 +117,7 @@ static int __init mxc_clocksource_init(s + { + unsigned int c = clk_get_rate(timer_clk); + +- if (cpu_is_mx3()) ++ if (cpu_is_mx3() || cpu_is_mx25()) + clocksource_mxc.read = mx3_get_cycles; + + clocksource_mxc.mult = clocksource_hz2mult(c, +@@ -180,7 +180,7 @@ static void mxc_set_mode(enum clock_even + + if (mode != clockevent_mode) { + /* Set event time into far-far future */ +- if (cpu_is_mx3()) ++ if (cpu_is_mx3() || cpu_is_mx25()) + __raw_writel(__raw_readl(timer_base + MX3_TCN) - 3, + timer_base + MX3_TCMP); + else +@@ -233,7 +233,7 @@ static irqreturn_t mxc_timer_interrupt(i + struct clock_event_device *evt = &clockevent_mxc; + uint32_t tstat; + +- if (cpu_is_mx3()) ++ if (cpu_is_mx3() || cpu_is_mx25()) + tstat = __raw_readl(timer_base + MX3_TSTAT); + else + tstat = __raw_readl(timer_base + MX1_2_TSTAT); +@@ -264,7 +264,7 @@ static int __init mxc_clockevent_init(st + { + unsigned int c = clk_get_rate(timer_clk); + +- if (cpu_is_mx3()) ++ if (cpu_is_mx3() || cpu_is_mx25()) + clockevent_mxc.set_next_event = mx3_set_next_event; + + clockevent_mxc.mult = div_sc(c, NSEC_PER_SEC, +@@ -287,6 +287,7 @@ void __init mxc_timer_init(struct clk *t + int irq; + + clk_enable(timer_clk); ++printk(KERN_DEBUG "%s: \n", __FUNCTION__); + + if (cpu_is_mx1()) { + #ifdef CONFIG_ARCH_MX1 +@@ -306,6 +307,7 @@ void __init mxc_timer_init(struct clk *t + } else + BUG(); + ++printk(KERN_DEBUG "%s: timer_base=%p IRQ=%d\n", __FUNCTION__, timer_base, irq); + /* + * Initialise to a known state (all timers off, and timing reset) + */ +@@ -313,7 +315,7 @@ void __init mxc_timer_init(struct clk *t + __raw_writel(0, timer_base + MXC_TCTL); + __raw_writel(0, timer_base + MXC_TPRER); /* see datasheet note */ + +- if (cpu_is_mx3()) ++ if (cpu_is_mx3() || cpu_is_mx25()) + tctl_val = MX3_TCTL_CLK_IPG | MX3_TCTL_FRR | MX3_TCTL_WAITEN | MXC_TCTL_TEN; + else + tctl_val = MX1_2_TCTL_FRR | MX1_2_TCTL_CLK_PCLK1 | MXC_TCTL_TEN; +diff -urNp linux-2.6.30-rc4/arch/arm/tools/mach-types linux-2.6.30-rc4-karo/arch/arm/tools/mach-types +--- linux-2.6.30-rc4/arch/arm/tools/mach-types 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/arch/arm/tools/mach-types 2009-06-02 17:05:27.000000000 +0200 +@@ -12,7 +12,7 @@ + # + # http://www.arm.linux.org.uk/developer/machines/?action=new + # +-# Last update: Mon Mar 23 20:09:01 2009 ++# Last update: Mon Apr 20 10:31:38 2009 + # + # machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number + # +@@ -1721,7 +1721,7 @@ sapphire MACH_SAPPHIRE SAPPHIRE 1729 + csb637xo MACH_CSB637XO CSB637XO 1730 + evisiong MACH_EVISIONG EVISIONG 1731 + stmp37xx MACH_STMP37XX STMP37XX 1732 +-stmp378x MACH_STMP38XX STMP38XX 1733 ++stmp378x MACH_STMP378X STMP378X 1733 + tnt MACH_TNT TNT 1734 + tbxt MACH_TBXT TBXT 1735 + playmate MACH_PLAYMATE PLAYMATE 1736 +@@ -2132,3 +2132,41 @@ apollo MACH_APOLLO APOLLO 2141 + at91cap9stk MACH_AT91CAP9STK AT91CAP9STK 2142 + spc300 MACH_SPC300 SPC300 2143 + eko MACH_EKO EKO 2144 ++ccw9m2443 MACH_CCW9M2443 CCW9M2443 2145 ++ccw9m2443js MACH_CCW9M2443JS CCW9M2443JS 2146 ++m2m_router_device MACH_M2M_ROUTER_DEVICE M2M_ROUTER_DEVICE 2147 ++str9104nas MACH_STAR9104NAS STAR9104NAS 2148 ++pca100 MACH_PCA100 PCA100 2149 ++z3_dm365_mod_01 MACH_Z3_DM365_MOD_01 Z3_DM365_MOD_01 2150 ++hipox MACH_HIPOX HIPOX 2151 ++omap3_piteds MACH_OMAP3_PITEDS OMAP3_PITEDS 2152 ++bm150r MACH_BM150R BM150R 2153 ++tbone MACH_TBONE TBONE 2154 ++merlin MACH_MERLIN MERLIN 2155 ++falcon MACH_FALCON FALCON 2156 ++davinci_da850_evm MACH_DAVINCI_DA850_EVM DAVINCI_DA850_EVM 2157 ++s5p6440 MACH_S5P6440 S5P6440 2158 ++at91sam9g10ek MACH_AT91SAM9G10EK AT91SAM9G10EK 2159 ++omap_4430sdp MACH_OMAP_4430SDP OMAP_4430SDP 2160 ++lpc313x MACH_LPC313X LPC313X 2161 ++magx_zn5 MACH_MAGX_ZN5 MAGX_ZN5 2162 ++magx_em30 MACH_MAGX_EM30 MAGX_EM30 2163 ++magx_ve66 MACH_MAGX_VE66 MAGX_VE66 2164 ++meesc MACH_MEESC MEESC 2165 ++otc570 MACH_OTC570 OTC570 2166 ++bcu2412 MACH_BCU2412 BCU2412 2167 ++beacon MACH_BEACON BEACON 2168 ++actia_tgw MACH_ACTIA_TGW ACTIA_TGW 2169 ++e4430 MACH_E4430 E4430 2170 ++ql300 MACH_QL300 QL300 2171 ++btmavb101 MACH_BTMAVB101 BTMAVB101 2172 ++btmawb101 MACH_BTMAWB101 BTMAWB101 2173 ++sq201 MACH_SQ201 SQ201 2174 ++quatro45xx MACH_QUATRO45XX QUATRO45XX 2175 ++openpad MACH_OPENPAD OPENPAD 2176 ++tx25 MACH_TX25 TX25 2177 ++omap3_torpedo MACH_OMAP3_TORPEDO OMAP3_TORPEDO 2178 ++htcraphael_k MACH_HTCRAPHAEL_K HTCRAPHAEL_K 2179 ++pxa255 MACH_PXA255 PXA255 2180 ++lal43 MACH_LAL43 LAL43 2181 ++htcraphael_cdma500 MACH_HTCRAPHAEL_CDMA500 HTCRAPHAEL_CDMA500 2182 +diff -urNp linux-2.6.30-rc4/drivers/leds/leds-gpio.c linux-2.6.30-rc4-karo/drivers/leds/leds-gpio.c +--- linux-2.6.30-rc4/drivers/leds/leds-gpio.c 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/drivers/leds/leds-gpio.c 2009-06-02 17:05:27.000000000 +0200 +@@ -82,7 +82,7 @@ static int __devinit create_gpio_led(con + if (!gpio_is_valid(template->gpio)) { + printk(KERN_INFO "Skipping unavilable LED gpio %d (%s)\n", + template->gpio, template->name); +- return 0; ++ return -EINVAL; + } + + ret = gpio_request(template->gpio, template->name); +diff -urNp linux-2.6.30-rc4/drivers/mtd/nand/Kconfig linux-2.6.30-rc4-karo/drivers/mtd/nand/Kconfig +--- linux-2.6.30-rc4/drivers/mtd/nand/Kconfig 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/drivers/mtd/nand/Kconfig 2009-06-02 17:05:27.000000000 +0200 +@@ -420,6 +420,27 @@ config MTD_NAND_MXC + This enables the driver for the NAND flash controller on the + MXC processors. + ++config MTD_NAND_MXC_FLASH_BBT ++ bool "Support a flash based bad block table" ++ depends on MTD_NAND_MXC ++ ++config ARCH_MXC_HAS_NFC_V1 ++ bool ++ ++config ARCH_MXC_HAS_NFC_V1_1 ++ select ARCH_MXC_HAS_NFC_V1 ++ bool ++ ++config ARCH_MXC_HAS_NFC_V2 ++ bool ++ ++config ARCH_MXC_HAS_NFC_V2_1 ++ bool ++ select ARCH_MXC_HAS_NFC_V2 ++ ++config ARCH_MXC_HAS_NFC_V3 ++ bool ++ + config MTD_NAND_SH_FLCTL + tristate "Support for NAND on Renesas SuperH FLCTL" + depends on MTD_NAND && SUPERH && CPU_SUBTYPE_SH7723 +diff -urNp linux-2.6.30-rc4/drivers/mtd/nand/Makefile linux-2.6.30-rc4-karo/drivers/mtd/nand/Makefile +--- linux-2.6.30-rc4/drivers/mtd/nand/Makefile 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/drivers/mtd/nand/Makefile 2009-06-02 17:05:27.000000000 +0200 +@@ -36,7 +36,13 @@ obj-$(CONFIG_MTD_NAND_ORION) += orion_n + obj-$(CONFIG_MTD_NAND_FSL_ELBC) += fsl_elbc_nand.o + obj-$(CONFIG_MTD_NAND_FSL_UPM) += fsl_upm.o + obj-$(CONFIG_MTD_NAND_SH_FLCTL) += sh_flctl.o ++ifneq ($(CONFIG_ARCH_MXC_HAS_NFC_V1),) + obj-$(CONFIG_MTD_NAND_MXC) += mxc_nand.o ++else ++ifneq ($(CONFIG_ARCH_MXC_HAS_NFC_V2),) ++obj-$(CONFIG_MTD_NAND_MXC) += mxc_nd2.o ++endif ++endif + obj-$(CONFIG_MTD_NAND_SOCRATES) += socrates_nand.o + obj-$(CONFIG_MTD_NAND_TXX9NDFMC) += txx9ndfmc.o + +diff -urNp linux-2.6.30-rc4/drivers/mtd/nand/mxc_nand.c linux-2.6.30-rc4-karo/drivers/mtd/nand/mxc_nand.c +--- linux-2.6.30-rc4/drivers/mtd/nand/mxc_nand.c 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/drivers/mtd/nand/mxc_nand.c 2009-06-02 17:05:27.000000000 +0200 +@@ -34,23 +34,52 @@ + #include + #include + ++#ifdef CONFIG_MTD_DEBUG ++static int debug = 3; ++module_param(debug, int, S_IRUGO | S_IWUSR); ++ ++#define dbg_lvl(n) ((n) < debug) ++#define DBG(lvl, fmt...) do { if (dbg_lvl(lvl)) printk(KERN_DEBUG fmt); } while (0) ++#undef DEBUG ++#define DEBUG(l, fmt...) DBG(l, fmt) ++#else ++static int debug; ++module_param(debug, int, 0); ++ ++#define dbg_lvl(n) 0 ++#define DBG(lvl, fmt...) do { } while (0) ++#endif ++ ++ + #define DRIVER_NAME "mxc_nand" + + /* Addresses for NFC registers */ +-#define NFC_BUF_SIZE 0xE00 +-#define NFC_BUF_ADDR 0xE04 +-#define NFC_FLASH_ADDR 0xE06 +-#define NFC_FLASH_CMD 0xE08 +-#define NFC_CONFIG 0xE0A +-#define NFC_ECC_STATUS_RESULT 0xE0C +-#define NFC_RSLTMAIN_AREA 0xE0E +-#define NFC_RSLTSPARE_AREA 0xE10 +-#define NFC_WRPROT 0xE12 +-#define NFC_UNLOCKSTART_BLKADDR 0xE14 +-#define NFC_UNLOCKEND_BLKADDR 0xE16 +-#define NFC_NF_WRPRST 0xE18 +-#define NFC_CONFIG1 0xE1A +-#define NFC_CONFIG2 0xE1C ++#define NFC_BUF_SIZE 0x000 ++#define NFC_BUF_ADDR 0x004 ++#define NFC_FLASH_ADDR 0x006 ++#define NFC_FLASH_CMD 0x008 ++#define NFC_CONFIG 0x00A ++#define NFC_ECC_STATUS_RESULT 0x00C ++#define NFC_RSLTMAIN_AREA 0x00E ++#define NFC_RSLTSPARE_AREA 0x010 ++#define NFC_WRPROT 0x012 ++#ifndef CONFIG_ARCH_MXC_HAS_NFC_V1_1 ++#define NFC_UNLOCKSTART_BLKADDR 0x014 ++#define NFC_UNLOCKEND_BLKADDR 0x016 ++#endif ++#define NFC_NF_WRPRST 0x018 ++#define NFC_CONFIG1 0x01A ++#define NFC_CONFIG2 0x01C ++#ifdef CONFIG_ARCH_MXC_HAS_NFC_V1_1 ++#define NFC_UNLOCKSTART_BLKADDR 0x020 ++#define NFC_UNLOCKEND_BLKADDR 0x022 ++#define NFC_UNLOCKSTART_BLKADDR1 0x024 ++#define NFC_UNLOCKEND_BLKADDR1 0x026 ++#define NFC_UNLOCKSTART_BLKADDR2 0x028 ++#define NFC_UNLOCKEND_BLKADDR2 0x02a ++#define NFC_UNLOCKSTART_BLKADDR3 0x02c ++#define NFC_UNLOCKEND_BLKADDR3 0x02e ++#endif + + /* Addresses for NFC RAM BUFFER Main area 0 */ + #define MAIN_AREA0 0x000 +@@ -59,10 +88,27 @@ + #define MAIN_AREA3 0x600 + + /* Addresses for NFC SPARE BUFFER Spare area 0 */ ++#ifndef CONFIG_ARCH_MXC_HAS_NFC_V1_1 ++#define SPARE_AREA_SIZE 16 + #define SPARE_AREA0 0x800 + #define SPARE_AREA1 0x810 + #define SPARE_AREA2 0x820 + #define SPARE_AREA3 0x830 ++#else ++#define SPARE_AREA_SIZE 64 ++#define MAIN_AREA4 0x800 ++#define MAIN_AREA5 0xa00 ++#define MAIN_AREA6 0xc00 ++#define MAIN_AREA7 0xe00 ++#define SPARE_AREA0 0x1000 ++#define SPARE_AREA1 0x1040 ++#define SPARE_AREA2 0x1080 ++#define SPARE_AREA3 0x10c0 ++#define SPARE_AREA4 0x1100 ++#define SPARE_AREA5 0x1140 ++#define SPARE_AREA6 0x1180 ++#define SPARE_AREA7 0x11c0 ++#endif + + /* Set INT to 0, FCMD to 1, rest to 0 in NFC_CONFIG2 Register + * for Command operation */ +@@ -107,6 +153,7 @@ struct mxc_nand_host { + struct device *dev; + + void __iomem *regs; ++ void __iomem *nfc_buf; + int spare_only; + int status_request; + int pagesize_2k; +@@ -128,32 +175,149 @@ struct mxc_nand_host { + #define MAIN_SINGLEBIT_ERROR 0x4 + #define SPARE_SINGLEBIT_ERROR 0x1 + ++#ifndef CONFIG_ARCH_MXC_HAS_NFC_V1_1 + /* OOB placement block for use with hardware ecc generation */ ++static struct nand_ecclayout nand_hw_eccoob2k_8 = { ++ .eccbytes = 5, ++ .eccpos = {6, 7, 8, 9, 10}, ++ .oobfree = {{0, 5}, {11, 11}, {27, 11}, {43, 5}} ++}; ++ + static struct nand_ecclayout nand_hw_eccoob_8 = { + .eccbytes = 5, + .eccpos = {6, 7, 8, 9, 10}, +- .oobfree = {{0, 5}, {11, 5}, } ++ .oobfree = {{0, 5}, {11, 5}} ++}; ++ ++static struct nand_ecclayout nand_hw_eccoob2k_16 = { ++ .eccbytes = 5, ++ .eccpos = {6, 7, 8, 9, 10}, ++ .oobfree = {{0, 6}, {12, 10}, {28, 10}, {44, 4}} + }; + + static struct nand_ecclayout nand_hw_eccoob_16 = { + .eccbytes = 5, + .eccpos = {6, 7, 8, 9, 10}, +- .oobfree = {{0, 6}, {12, 4}, } ++ .oobfree = {{0, 6}, {12, 4}} ++}; ++ ++#ifdef CONFIG_MTD_NAND_MXC_FLASH_BBT ++static u8 bbt_pattern[] = {'B', 'b', 't', '0' }; ++static u8 mirror_pattern[] = {'1', 't', 'b', 'B' }; ++ ++static struct nand_bbt_descr bbt_main_descr = { ++ .options = (NAND_BBT_LASTBLOCK | NAND_BBT_WRITE | ++ NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP), ++ .offs = 12, ++ .len = 4, ++ .veroffs = 11, ++ .maxblocks = 4, ++ .pattern = bbt_pattern, ++}; ++ ++static struct nand_bbt_descr bbt_mirror_descr = { ++ .options = (NAND_BBT_LASTBLOCK | NAND_BBT_WRITE | ++ NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP), ++ .offs = 12, ++ .len = 4, ++ .veroffs = 11, ++ .maxblocks = 4, ++ .pattern = mirror_pattern, ++}; ++#endif ++#else ++/* ++ * OOB placement block for use with hardware ecc generation ++ */ ++static struct nand_ecclayout nand_hw_eccoob2k_8 = { ++ .eccbytes = 9, ++ .eccpos = {7, 8, 9, 10, 11, 12, 13, 14, 15}, ++ .oobfree = {{0, 7}, {16, 7}, {32, 7}, {48, 7}}, ++}; ++ ++static struct nand_ecclayout nand_hw_eccoob_8 = { ++ .eccbytes = 9, ++ .eccpos = {7, 8, 9, 10, 11, 12, 13, 14, 15}, ++ .oobfree = {{0, 4}}, ++}; ++ ++static struct nand_ecclayout nand_hw_eccoob2k_16 = { ++ .eccbytes = 9, ++ .eccpos = {6, 7, 8, 9, 10, 11, 12, 13, 14}, ++ .oobfree = {{0, 6}, {17, 6}, {33, 6}, {47, 6}}, + }; + ++static struct nand_ecclayout nand_hw_eccoob_16 = { ++ .eccbytes = 9, ++ .eccpos = {6, 7, 8, 9, 10, 11, 12, 13, 14}, ++ .oobfree = {{0, 3}} ++}; ++ ++#ifdef CONFIG_MTD_NAND_MXC_FLASH_BBT ++/* Generic flash bbt decriptors ++*/ ++static u8 bbt_pattern[] = { 'B', 'b', 't', '0' }; ++static u8 mirror_pattern[] = { '1', 't', 'b', 'B' }; ++ ++static struct nand_bbt_descr bbt_main_descr = { ++ .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE | ++ NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP, ++ .offs = 0, ++ .len = 4, ++ .veroffs = 4, ++ .maxblocks = 4, ++ .pattern = bbt_pattern ++}; ++ ++static struct nand_bbt_descr bbt_mirror_descr = { ++ .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE | ++ NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP, ++ .offs = 0, ++ .len = 4, ++ .veroffs = 4, ++ .maxblocks = 4, ++ .pattern = mirror_pattern ++}; ++#endif ++#endif ++ + #ifdef CONFIG_MTD_PARTITIONS + static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL }; + #endif + ++#ifdef CONFIG_MTD_DEBUG ++#define nfc_read_reg(b, r) __nfc_read_reg(b, r, #r, __FUNCTION__) ++static inline u16 __nfc_read_reg(void __iomem *base, unsigned int reg, ++ const char *name, const char *fn) ++{ ++ u16 val = readw(base + reg); ++ DBG(3, "%s: Read %04x from %s[%02x]\n", fn, val, name, reg); ++ return val; ++} ++ ++#define nfc_write_reg(v, b, r) __nfc_write_reg(v, b, r, #r, __FUNCTION__) ++static inline void __nfc_write_reg(u16 val, void __iomem *base, unsigned int reg, ++ const char *name, const char *fn) ++{ ++ DBG(3, "%s: Writing %04x to %s[%02x]\n", fn, val, name, reg); ++ writew(val, base + reg); ++} ++#else ++#define nfc_read_reg(b, r) readw(b + r) ++#define nfc_write_reg(v, b, r) writew(v, b + r) ++#endif ++ + static irqreturn_t mxc_nfc_irq(int irq, void *dev_id) + { + struct mxc_nand_host *host = dev_id; + + uint16_t tmp; + +- tmp = readw(host->regs + NFC_CONFIG1); ++ DEBUG(MTD_DEBUG_LEVEL0, "%s(%d)\n", __FUNCTION__, irq); ++ ++ tmp = nfc_read_reg(host->regs, NFC_CONFIG1); + tmp |= NFC_INT_MSK; /* Disable interrupt */ +- writew(tmp, host->regs + NFC_CONFIG1); ++ nfc_write_reg(tmp, host->regs, NFC_CONFIG1); + + wake_up(&host->irq_waitq); + +@@ -166,36 +330,31 @@ static irqreturn_t mxc_nfc_irq(int irq, + static void wait_op_done(struct mxc_nand_host *host, int max_retries, + uint16_t param, int useirq) + { +- uint32_t tmp; ++ uint32_t nfc_stat; + ++ nfc_stat = nfc_read_reg(host->regs, NFC_CONFIG2); + if (useirq) { +- if ((readw(host->regs + NFC_CONFIG2) & NFC_INT) == 0) { +- +- tmp = readw(host->regs + NFC_CONFIG1); +- tmp &= ~NFC_INT_MSK; /* Enable interrupt */ +- writew(tmp, host->regs + NFC_CONFIG1); +- +- wait_event(host->irq_waitq, +- readw(host->regs + NFC_CONFIG2) & NFC_INT); +- +- tmp = readw(host->regs + NFC_CONFIG2); +- tmp &= ~NFC_INT; +- writew(tmp, host->regs + NFC_CONFIG2); ++ if (!(nfc_stat & NFC_INT)) { ++ uint32_t cfg1; ++ const unsigned long timeout = 10; ++ ++ cfg1 = nfc_read_reg(host->regs, NFC_CONFIG1); ++ cfg1 &= ~NFC_INT_MSK; /* Enable interrupt */ ++ nfc_write_reg(cfg1, host->regs, NFC_CONFIG1); ++ ++ max_retries = wait_event_timeout(host->irq_waitq, ++ (nfc_stat = nfc_read_reg(host->regs, ++ NFC_CONFIG2)) & NFC_INT, ++ timeout); + } + } else { +- while (max_retries-- > 0) { +- if (readw(host->regs + NFC_CONFIG2) & NFC_INT) { +- tmp = readw(host->regs + NFC_CONFIG2); +- tmp &= ~NFC_INT; +- writew(tmp, host->regs + NFC_CONFIG2); +- break; +- } ++ while (!(nfc_stat & NFC_INT) && max_retries-- > 0) { ++ nfc_stat = nfc_read_reg(host->regs, NFC_CONFIG2); + udelay(1); + } +- if (max_retries <= 0) +- DEBUG(MTD_DEBUG_LEVEL0, "%s(%d): INT not set\n", +- __func__, param); + } ++ nfc_write_reg(nfc_stat & ~NFC_INT, host->regs, NFC_CONFIG2); ++ WARN_ONCE(max_retries <= 0, "%s(%d): INT not set\n", __func__, param); + } + + /* This function issues the specified command to the NAND device and +@@ -204,8 +363,8 @@ static void send_cmd(struct mxc_nand_hos + { + DEBUG(MTD_DEBUG_LEVEL3, "send_cmd(host, 0x%x, %d)\n", cmd, useirq); + +- writew(cmd, host->regs + NFC_FLASH_CMD); +- writew(NFC_CMD, host->regs + NFC_CONFIG2); ++ nfc_write_reg(cmd, host->regs, NFC_FLASH_CMD); ++ nfc_write_reg(NFC_CMD, host->regs, NFC_CONFIG2); + + /* Wait for operation to complete */ + wait_op_done(host, TROP_US_DELAY, cmd, useirq); +@@ -218,8 +377,8 @@ static void send_addr(struct mxc_nand_ho + { + DEBUG(MTD_DEBUG_LEVEL3, "send_addr(host, 0x%x %d)\n", addr, islast); + +- writew(addr, host->regs + NFC_FLASH_ADDR); +- writew(NFC_ADDR, host->regs + NFC_CONFIG2); ++ nfc_write_reg(addr, host->regs, NFC_FLASH_ADDR); ++ nfc_write_reg(NFC_ADDR, host->regs, NFC_CONFIG2); + + /* Wait for operation to complete */ + wait_op_done(host, TROP_US_DELAY, addr, islast); +@@ -233,19 +392,19 @@ static void send_prog_page(struct mxc_na + DEBUG(MTD_DEBUG_LEVEL3, "send_prog_page (%d)\n", spare_only); + + /* NANDFC buffer 0 is used for page read/write */ +- writew(buf_id, host->regs + NFC_BUF_ADDR); ++ nfc_write_reg(buf_id, host->regs, NFC_BUF_ADDR); + + /* Configure spare or page+spare access */ + if (!host->pagesize_2k) { +- uint16_t config1 = readw(host->regs + NFC_CONFIG1); ++ uint16_t config1 = nfc_read_reg(host->regs, NFC_CONFIG1); + if (spare_only) + config1 |= NFC_SP_EN; + else + config1 &= ~(NFC_SP_EN); +- writew(config1, host->regs + NFC_CONFIG1); ++ nfc_write_reg(config1, host->regs, NFC_CONFIG1); + } + +- writew(NFC_INPUT, host->regs + NFC_CONFIG2); ++ nfc_write_reg(NFC_INPUT, host->regs, NFC_CONFIG2); + + /* Wait for operation to complete */ + wait_op_done(host, TROP_US_DELAY, spare_only, true); +@@ -259,19 +418,19 @@ static void send_read_page(struct mxc_na + DEBUG(MTD_DEBUG_LEVEL3, "send_read_page (%d)\n", spare_only); + + /* NANDFC buffer 0 is used for page read/write */ +- writew(buf_id, host->regs + NFC_BUF_ADDR); ++ nfc_write_reg(buf_id, host->regs, NFC_BUF_ADDR); + + /* Configure spare or page+spare access */ + if (!host->pagesize_2k) { +- uint32_t config1 = readw(host->regs + NFC_CONFIG1); ++ uint32_t config1 = nfc_read_reg(host->regs, NFC_CONFIG1); + if (spare_only) + config1 |= NFC_SP_EN; + else + config1 &= ~NFC_SP_EN; +- writew(config1, host->regs + NFC_CONFIG1); ++ nfc_write_reg(config1, host->regs, NFC_CONFIG1); + } + +- writew(NFC_OUTPUT, host->regs + NFC_CONFIG2); ++ nfc_write_reg(NFC_OUTPUT, host->regs, NFC_CONFIG2); + + /* Wait for operation to complete */ + wait_op_done(host, TROP_US_DELAY, spare_only, true); +@@ -284,20 +443,20 @@ static void send_read_id(struct mxc_nand + uint16_t tmp; + + /* NANDFC buffer 0 is used for device ID output */ +- writew(0x0, host->regs + NFC_BUF_ADDR); ++ nfc_write_reg(0x0, host->regs, NFC_BUF_ADDR); + + /* Read ID into main buffer */ +- tmp = readw(host->regs + NFC_CONFIG1); ++ tmp = nfc_read_reg(host->regs, NFC_CONFIG1); + tmp &= ~NFC_SP_EN; +- writew(tmp, host->regs + NFC_CONFIG1); ++ nfc_write_reg(tmp, host->regs, NFC_CONFIG1); + +- writew(NFC_ID, host->regs + NFC_CONFIG2); ++ nfc_write_reg(NFC_ID, host->regs, NFC_CONFIG2); + + /* Wait for operation to complete */ + wait_op_done(host, TROP_US_DELAY, 0, true); + + if (this->options & NAND_BUSWIDTH_16) { +- void __iomem *main_buf = host->regs + MAIN_AREA0; ++ void __iomem *main_buf = host->nfc_buf + MAIN_AREA0; + /* compress the ID info */ + writeb(readb(main_buf + 2), main_buf + 1); + writeb(readb(main_buf + 4), main_buf + 2); +@@ -311,29 +470,29 @@ static void send_read_id(struct mxc_nand + * NAND device status and returns the current status. */ + static uint16_t get_dev_status(struct mxc_nand_host *host) + { +- void __iomem *main_buf = host->regs + MAIN_AREA1; ++ void __iomem *main_buf = host->nfc_buf + MAIN_AREA0; + uint32_t store; + uint16_t ret, tmp; + /* Issue status request to NAND device */ + +- /* store the main area1 first word, later do recovery */ ++ /* store the main area first word, later do recovery */ + store = readl(main_buf); +- /* NANDFC buffer 1 is used for device status to prevent ++ /* NANDFC buffer 0 is used for device status to prevent + * corruption of read/write buffer on status requests. */ +- writew(1, host->regs + NFC_BUF_ADDR); ++ nfc_write_reg(0, host->regs, NFC_BUF_ADDR); + + /* Read status into main buffer */ +- tmp = readw(host->regs + NFC_CONFIG1); ++ tmp = nfc_read_reg(host->regs, NFC_CONFIG1); + tmp &= ~NFC_SP_EN; +- writew(tmp, host->regs + NFC_CONFIG1); ++ nfc_write_reg(tmp, host->regs, NFC_CONFIG1); + +- writew(NFC_STATUS, host->regs + NFC_CONFIG2); ++ nfc_write_reg(NFC_STATUS, host->regs, NFC_CONFIG2); + + /* Wait for operation to complete */ + wait_op_done(host, TROP_US_DELAY, 0, true); + + /* Status is placed in first word of main buffer */ +- /* get status, then recovery area 1 data */ ++ /* get status, then recover area 0 data */ + ret = readw(main_buf); + writel(store, main_buf); + +@@ -369,7 +528,7 @@ static int mxc_nand_correct_data(struct + * additional correction. 2-Bit errors cannot be corrected by + * HW ECC, so we need to return failure + */ +- uint16_t ecc_status = readw(host->regs + NFC_ECC_STATUS_RESULT); ++ uint16_t ecc_status = nfc_read_reg(host->regs, NFC_ECC_STATUS_RESULT); + + if (((ecc_status & 0x3) == 2) || ((ecc_status >> 2) == 2)) { + DEBUG(MTD_DEBUG_LEVEL0, +@@ -392,8 +551,8 @@ static u_char mxc_nand_read_byte(struct + struct mxc_nand_host *host = nand_chip->priv; + uint8_t ret = 0; + uint16_t col, rd_word; +- uint16_t __iomem *main_buf = host->regs + MAIN_AREA0; +- uint16_t __iomem *spare_buf = host->regs + SPARE_AREA0; ++ uint16_t __iomem *main_buf = host->nfc_buf + MAIN_AREA0; ++ uint16_t __iomem *spare_buf = host->nfc_buf + SPARE_AREA0; + + /* Check for status request */ + if (host->status_request) +@@ -436,9 +595,9 @@ static uint16_t mxc_nand_read_word(struc + col += mtd->writesize; + + if (col < mtd->writesize) +- p = (host->regs + MAIN_AREA0) + (col >> 1); ++ p = (host->nfc_buf + MAIN_AREA0) + (col >> 1); + else +- p = (host->regs + SPARE_AREA0) + ((col - mtd->writesize) >> 1); ++ p = (host->nfc_buf + SPARE_AREA0) + ((col - mtd->writesize) >> 1); + + if (col & 1) { + rd_word = readw(p); +@@ -464,6 +623,7 @@ static void mxc_nand_write_buf(struct mt + struct nand_chip *nand_chip = mtd->priv; + struct mxc_nand_host *host = nand_chip->priv; + int n, col, i = 0; ++ int ss = mtd->oobsize / (mtd->writesize >> 9); + + DEBUG(MTD_DEBUG_LEVEL3, + "mxc_nand_write_buf(col = %d, len = %d)\n", host->col_addr, +@@ -474,21 +634,27 @@ static void mxc_nand_write_buf(struct mt + /* Adjust saved column address */ + if (col < mtd->writesize && host->spare_only) + col += mtd->writesize; +- ++#if 0 + n = mtd->writesize + mtd->oobsize - col; + n = min(len, n); ++#else ++ BUG_ON(len > mtd->writesize + mtd->oobsize - col); ++ n = len; ++#endif + + DEBUG(MTD_DEBUG_LEVEL3, + "%s:%d: col = %d, n = %d\n", __func__, __LINE__, col, n); + + while (n) { + void __iomem *p; ++ int si = (col - mtd->writesize) / 16; + + if (col < mtd->writesize) +- p = host->regs + MAIN_AREA0 + (col & ~3); ++ p = host->nfc_buf + MAIN_AREA0 + (col & ~3); + else +- p = host->regs + SPARE_AREA0 - +- mtd->writesize + (col & ~3); ++ p = host->nfc_buf + SPARE_AREA0 + ++ si * SPARE_AREA_SIZE + ++ (col - mtd->writesize) % ss; + + DEBUG(MTD_DEBUG_LEVEL3, "%s:%d: p = %p\n", __func__, + __LINE__, p); +@@ -542,6 +708,7 @@ static void mxc_nand_write_buf(struct mt + DEBUG(MTD_DEBUG_LEVEL3, + "%s:%d: n = %d, m = %d, i = %d, col = %d\n", + __func__, __LINE__, n, m, i, col); ++ BUG_ON(m == 0); + + memcpy(p, &buf[i], m); + col += m; +@@ -562,27 +729,50 @@ static void mxc_nand_read_buf(struct mtd + struct nand_chip *nand_chip = mtd->priv; + struct mxc_nand_host *host = nand_chip->priv; + int n, col, i = 0; ++ int ss = mtd->oobsize / (mtd->writesize >> 9); + + DEBUG(MTD_DEBUG_LEVEL3, + "mxc_nand_read_buf(col = %d, len = %d)\n", host->col_addr, len); + + col = host->col_addr; ++ if (dbg_lvl(2)) { ++ int si = col / 512; ++ print_hex_dump(KERN_DEBUG, "main: ", DUMP_PREFIX_ADDRESS, ++ 16, 2, host->nfc_buf + MAIN_AREA0, 64, 0); ++ print_hex_dump(KERN_DEBUG, "spare: ", DUMP_PREFIX_ADDRESS, ++ 16, 2, host->nfc_buf + SPARE_AREA0 + ++ si * SPARE_AREA_SIZE, 16, 0); ++ } + + /* Adjust saved column address */ + if (col < mtd->writesize && host->spare_only) + col += mtd->writesize; +- ++#if 0 + n = mtd->writesize + mtd->oobsize - col; + n = min(len, n); +- ++#else ++ /* If more data is requested to be read than is available in ++ * the flash buffer this is clearly a BUG! */ ++ BUG_ON(len > mtd->writesize + mtd->oobsize - col); ++ n = len; ++#endif + while (n) { + void __iomem *p; ++ int si = (col - mtd->writesize) / ss; + + if (col < mtd->writesize) +- p = host->regs + MAIN_AREA0 + (col & ~3); ++ p = host->nfc_buf + MAIN_AREA0 + (col & ~3); + else +- p = host->regs + SPARE_AREA0 - +- mtd->writesize + (col & ~3); ++ p = host->nfc_buf + SPARE_AREA0 + ++ si * SPARE_AREA_SIZE + ++ (col - mtd->writesize) % ss; ++ ++ DBG(1, "p=%p col=%03x ss=%d si=%d\n", p, col, ss, si); ++ ++ if (dbg_lvl(3)) { ++ print_hex_dump(KERN_DEBUG, "spare: ", DUMP_PREFIX_ADDRESS, ++ 16, 2, p, 64, 0); ++ } + + if (((col | (int)&buf[i]) & 3) || n < 16) { + uint32_t data; +@@ -618,18 +808,23 @@ static void mxc_nand_read_buf(struct mtd + int m = mtd->writesize - col; + + if (col >= mtd->writesize) +- m += mtd->oobsize; ++ m = ss; + + m = min(n, m) & ~3; ++ DBG(1, "Copying %u byte from offset %03x[%p]\n", ++ m + (col & 3), col, p); ++ BUG_ON(m == 0); + memcpy(&buf[i], p, m); + col += m; + i += m; + n -= m; + } + } ++ if (dbg_lvl(1)) { ++ print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, len); ++ } + /* Update saved column address */ + host->col_addr = col; +- + } + + /* Used by the upper layer to verify the data in NAND Flash +@@ -655,13 +850,15 @@ static void mxc_nand_select_chip(struct + } + + if (chip == -1) { +- writew(readw(host->regs + NFC_CONFIG1) & ~NFC_CE, +- host->regs + NFC_CONFIG1); ++ nfc_write_reg(host->regs, ++ nfc_read_reg(host->regs, NFC_CONFIG1) & ~NFC_CE, ++ NFC_CONFIG1); + return; + } + +- writew(readw(host->regs + NFC_CONFIG1) | NFC_CE, +- host->regs + NFC_CONFIG1); ++ nfc_write_reg(host->regs, ++ nfc_read_reg(host->regs, NFC_CONFIG1) | NFC_CE, ++ NFC_CONFIG1); + #endif + + switch (chip) { +@@ -831,6 +1028,7 @@ static void mxc_nand_command(struct mtd_ + break; + + case NAND_CMD_READID: ++ host->col_addr = 0; + send_read_id(host); + break; + +@@ -851,9 +1049,12 @@ static int __init mxcnd_probe(struct pla + struct mtd_info *mtd; + struct mxc_nand_platform_data *pdata = pdev->dev.platform_data; + struct mxc_nand_host *host; +- struct resource *res; ++ struct resource *res1, *res2; + uint16_t tmp; +- int err = 0, nr_parts = 0; ++ int err, nr_parts; ++ ++ DBG(0, "%s: pdata=%p hw_ecc=%d width=%d\n", __FUNCTION__, ++ pdata, pdata->hw_ecc, pdata->width); + + /* Allocate memory for MTD device structure and private data */ + host = kzalloc(sizeof(struct mxc_nand_host), GFP_KERNEL); +@@ -868,9 +1069,6 @@ static int __init mxcnd_probe(struct pla + mtd->owner = THIS_MODULE; + mtd->dev.parent = &pdev->dev; + +- /* 50 us command delay time */ +- this->chip_delay = 5; +- + this->priv = host; + this->dev_ready = mxc_nand_dev_ready; + this->cmdfunc = mxc_nand_command; +@@ -880,29 +1078,61 @@ static int __init mxcnd_probe(struct pla + this->write_buf = mxc_nand_write_buf; + this->read_buf = mxc_nand_read_buf; + this->verify_buf = mxc_nand_verify_buf; ++#ifdef CONFIG_MTD_NAND_MXC_FLASH_BBT ++ this->bbt_td = &bbt_main_descr; ++ this->bbt_md = &bbt_mirror_descr; ++ this->options |= NAND_USE_FLASH_BBT; ++#endif + +- host->clk = clk_get(&pdev->dev, "nfc"); +- if (IS_ERR(host->clk)) ++ host->clk = clk_get(&pdev->dev, "nfc_clk"); ++ if (IS_ERR(host->clk)) { ++ err = PTR_ERR(host->clk); + goto eclk; ++ } ++ printk(KERN_DEBUG "NFC clk rate: %lu\n", clk_get_rate(host->clk)); ++ clk_set_rate(host->clk, 11000000); ++ printk(KERN_DEBUG "NFC clk rate: %lu\n", clk_get_rate(host->clk)); + + clk_enable(host->clk); + host->clk_act = 1; + +- res = platform_get_resource(pdev, IORESOURCE_MEM, 0); +- if (!res) { ++ res1 = platform_get_resource(pdev, IORESOURCE_MEM, 0); ++ if (!res1) { + err = -ENODEV; + goto eres; + } ++ if (!request_mem_region(res1->start, resource_size(res1), "mxc_nand")) { ++ err = -EBUSY; ++ goto ereq1; ++ } + +- host->regs = ioremap(res->start, res->end - res->start + 1); ++ res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1); ++ if (res2) { ++ if (!request_mem_region(res2->start, resource_size(res2), "mxc_nand")) { ++ err = -EBUSY; ++ goto ereq2; ++ } ++ } ++ ++ host->regs = ioremap(res1->start, resource_size(res1)); + if (!host->regs) { +- err = -EIO; +- goto eres; ++ err = -ENOMEM; ++ goto eunmap1; + } + +- tmp = readw(host->regs + NFC_CONFIG1); ++ if (!res2) { ++ host->nfc_buf = host->regs; ++ host->regs += 0xe00; ++ } else { ++ host->nfc_buf = ioremap(res2->start, resource_size(res2)); ++ if (!host->regs) { ++ err = -ENOMEM; ++ goto eunmap2; ++ } ++ } ++ tmp = nfc_read_reg(host->regs, NFC_CONFIG1); + tmp |= NFC_INT_MSK; +- writew(tmp, host->regs + NFC_CONFIG1); ++ nfc_write_reg(tmp, host->regs, NFC_CONFIG1); + + init_waitqueue_head(&host->irq_waitq); + +@@ -911,7 +1141,7 @@ static int __init mxcnd_probe(struct pla + err = request_irq(host->irq, mxc_nfc_irq, 0, "mxc_nd", host); + if (err) + goto eirq; +- ++#if 0 + if (pdata->hw_ecc) { + this->ecc.calculate = mxc_nand_calculate_ecc; + this->ecc.hwctl = mxc_nand_enable_hwecc; +@@ -919,50 +1149,90 @@ static int __init mxcnd_probe(struct pla + this->ecc.mode = NAND_ECC_HW; + this->ecc.size = 512; + this->ecc.bytes = 3; ++ if ( + this->ecc.layout = &nand_hw_eccoob_8; +- tmp = readw(host->regs + NFC_CONFIG1); ++ tmp = nfc_read_reg(host->regs, NFC_CONFIG1); + tmp |= NFC_ECC_EN; +- writew(tmp, host->regs + NFC_CONFIG1); ++ nfc_write_reg(tmp, host->regs, NFC_CONFIG1); + } else { + this->ecc.size = 512; + this->ecc.bytes = 3; + this->ecc.layout = &nand_hw_eccoob_8; + this->ecc.mode = NAND_ECC_SOFT; +- tmp = readw(host->regs + NFC_CONFIG1); ++ tmp = nfc_read_reg(host->regs, NFC_CONFIG1); + tmp &= ~NFC_ECC_EN; +- writew(tmp, host->regs + NFC_CONFIG1); ++ nfc_write_reg(tmp, host->regs, NFC_CONFIG1); + } +- ++#endif + /* Reset NAND */ + this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); + + /* preset operation */ + /* Unlock the internal RAM Buffer */ +- writew(0x2, host->regs + NFC_CONFIG); ++ nfc_write_reg(0x2, host->regs, NFC_CONFIG); + + /* Blocks to be unlocked */ +- writew(0x0, host->regs + NFC_UNLOCKSTART_BLKADDR); +- writew(0x4000, host->regs + NFC_UNLOCKEND_BLKADDR); ++ nfc_write_reg(0x0, host->regs, NFC_UNLOCKSTART_BLKADDR); ++ nfc_write_reg(0x4000, host->regs, NFC_UNLOCKEND_BLKADDR); + + /* Unlock Block Command for given address range */ +- writew(0x4, host->regs + NFC_WRPROT); ++ nfc_write_reg(0x4, host->regs, NFC_WRPROT); + + /* NAND bus width determines access funtions used by upper layer */ + if (pdata->width == 2) { + this->options |= NAND_BUSWIDTH_16; +- this->ecc.layout = &nand_hw_eccoob_16; + } + +- host->pagesize_2k = 0; +- + /* Scan to find existence of the device */ +- if (nand_scan(mtd, 1)) { ++ err = nand_scan_ident(mtd, 1); ++ if (err) { + DEBUG(MTD_DEBUG_LEVEL0, + "MXC_ND: Unable to find any NAND device.\n"); +- err = -ENXIO; ++ goto escan; ++ } ++ /* this is required before completing the scan */ ++ host->pagesize_2k = (mtd->writesize == 2048); ++ ++ if (pdata->width == 2) { ++ if (host->pagesize_2k) { ++ this->ecc.layout = &nand_hw_eccoob2k_16; ++ } else { ++ this->ecc.layout = &nand_hw_eccoob_16; ++ } ++ } else { ++ if (host->pagesize_2k) { ++ this->ecc.layout = &nand_hw_eccoob2k_8; ++ } else { ++ this->ecc.layout = &nand_hw_eccoob_8; ++ } ++ } ++ if (pdata->hw_ecc) { ++ this->ecc.calculate = mxc_nand_calculate_ecc; ++ this->ecc.hwctl = mxc_nand_enable_hwecc; ++ this->ecc.correct = mxc_nand_correct_data; ++ this->ecc.mode = NAND_ECC_HW; ++ this->ecc.size = 512; ++ this->ecc.bytes = 3; ++ tmp = nfc_read_reg(host->regs, NFC_CONFIG1); ++ tmp |= NFC_ECC_EN; ++ nfc_write_reg(tmp, host->regs, NFC_CONFIG1); ++ } else { ++ this->ecc.size = 512; ++ this->ecc.bytes = 3; ++ this->ecc.mode = NAND_ECC_SOFT; ++ tmp = nfc_read_reg(host->regs, NFC_CONFIG1); ++ tmp &= ~NFC_ECC_EN; ++ nfc_write_reg(tmp, host->regs, NFC_CONFIG1); ++ } ++ ++ err = nand_scan_tail(mtd); ++ if (err) { + goto escan; + } + ++ pr_info("MXC MTD nand Driver IRQ %d bus width: %u bit %s ECC IO: %08lx\n", ++ host->irq, pdata->width * 8, pdata->hw_ecc ? "HW" : "SW", ++ (unsigned long)res1->start); + /* Register the partitions */ + #ifdef CONFIG_MTD_PARTITIONS + nr_parts = +@@ -981,10 +1251,19 @@ static int __init mxcnd_probe(struct pla + return 0; + + escan: +- free_irq(host->irq, NULL); ++ free_irq(host->irq, host); + eirq: ++ if (host->regs != host->nfc_buf) ++ iounmap(host->nfc_buf); ++eunmap2: + iounmap(host->regs); ++eunmap1: ++ release_mem_region(res2->start, resource_size(res2)); ++ereq2: ++ release_mem_region(res1->start, resource_size(res1)); ++ereq1: + eres: ++ clk_disable(host->clk); + clk_put(host->clk); + eclk: + kfree(host); +@@ -995,46 +1274,63 @@ eclk: + static int __devexit mxcnd_remove(struct platform_device *pdev) + { + struct mxc_nand_host *host = platform_get_drvdata(pdev); ++ struct resource *res; + ++ if (host->clk_act) ++ clk_disable(host->clk); + clk_put(host->clk); + +- platform_set_drvdata(pdev, NULL); +- + nand_release(&host->mtd); +- free_irq(host->irq, NULL); ++ free_irq(host->irq, host); + iounmap(host->regs); + kfree(host); + ++ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ++ if (res) { ++ release_mem_region(res->start, resource_size(res)); ++ } ++ res = platform_get_resource(pdev, IORESOURCE_MEM, 1); ++ if (res) { ++ release_mem_region(res->start, resource_size(res)); ++ } + return 0; + } + + #ifdef CONFIG_PM + static int mxcnd_suspend(struct platform_device *pdev, pm_message_t state) + { +- struct mtd_info *info = platform_get_drvdata(pdev); ++ struct mtd_info *mtd = platform_get_drvdata(pdev); ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_nand_host *host = nand_chip->priv; + int ret = 0; + + DEBUG(MTD_DEBUG_LEVEL0, "MXC_ND : NAND suspend\n"); +- if (info) +- ret = info->suspend(info); ++ if (mtd) ++ ret = mtd->suspend(mtd); + ++ if (host->clk_act) { + /* Disable the NFC clock */ +- clk_disable(nfc_clk); /* FIXME */ ++ clk_disable(host->clk); ++ } + + return ret; + } + + static int mxcnd_resume(struct platform_device *pdev) + { +- struct mtd_info *info = platform_get_drvdata(pdev); ++ struct mtd_info *mtd = platform_get_drvdata(pdev); ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_nand_host *host = nand_chip->priv; + int ret = 0; + + DEBUG(MTD_DEBUG_LEVEL0, "MXC_ND : NAND resume\n"); +- /* Enable the NFC clock */ +- clk_enable(nfc_clk); /* FIXME */ + +- if (info) +- info->resume(info); ++ if (host->clk_act) { ++ /* Enable the NFC clock */ ++ clk_enable(host->clk); ++ } ++ if (mtd) ++ mtd->resume(mtd); + + return ret; + } +@@ -1047,7 +1343,7 @@ static int mxcnd_resume(struct platform_ + static struct platform_driver mxcnd_driver = { + .driver = { + .name = DRIVER_NAME, +- }, ++ }, + .remove = __exit_p(mxcnd_remove), + .suspend = mxcnd_suspend, + .resume = mxcnd_resume, +@@ -1055,13 +1351,14 @@ static struct platform_driver mxcnd_driv + + static int __init mxc_nd_init(void) + { ++ int ret; ++ + /* Register the device driver structure. */ +- pr_info("MXC MTD nand Driver\n"); +- if (platform_driver_probe(&mxcnd_driver, mxcnd_probe) != 0) { ++ ret = platform_driver_probe(&mxcnd_driver, mxcnd_probe); ++ if (ret != 0) { + printk(KERN_ERR "Driver register failed for mxcnd_driver\n"); +- return -ENODEV; + } +- return 0; ++ return ret; + } + + static void __exit mxc_nd_cleanup(void) +diff -urNp linux-2.6.30-rc4/drivers/mtd/nand/mxc_nd2.c linux-2.6.30-rc4-karo/drivers/mtd/nand/mxc_nd2.c +--- linux-2.6.30-rc4/drivers/mtd/nand/mxc_nd2.c 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/drivers/mtd/nand/mxc_nd2.c 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,1651 @@ ++/* ++ * Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved. ++ */ ++ ++/* ++ * The code contained herein is licensed under the GNU General Public ++ * License. You may obtain a copy of the GNU General Public License ++ * Version 2 or later at the following locations: ++ * ++ * http://www.opensource.org/licenses/gpl-license.html ++ * http://www.gnu.org/copyleft/gpl.html ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#ifdef CONFIG_MTD_DEBUG ++static int debug = 0; ++module_param(debug, int, S_IRUGO | S_IWUSR); ++ ++#define dbg_lvl(n) ((n) < debug) ++#define DBG(lvl, fmt...) do { if (dbg_lvl(lvl)) printk(KERN_DEBUG fmt); } while (0) ++#undef DEBUG ++#define DEBUG DBG ++#else ++static int debug; ++module_param(debug, int, 0); ++ ++#define dbg_lvl(n) 0 ++#define DBG(lvl, fmt...) do { } while (0) ++#endif ++ ++#include "mxc_nd2.h" ++ ++#define DRV_NAME "mxc_nand" ++ ++ ++/* Global address Variables */ ++/* ++static void __iomem *nfc_axi_base; ++static void __iomem *nfc_ip_base; ++*/ ++ ++struct mxc_mtd_s { ++ struct mtd_info mtd; ++ struct nand_chip nand; ++ struct mtd_partition *parts; ++ struct device *dev; ++ wait_queue_head_t irq_waitq; ++ int irq; ++ ++ u8 *data_buf; ++ u8 *oob_buf; ++ struct clk *clk; ++ int clk_act; ++ ++ struct resource *res_ip; ++ struct resource *res_axi; ++ void __iomem *reg_base; ++ void __iomem *axi_base; ++ u16 __iomem *main_buf; ++ u16 __iomem *spare_buf; ++ ++ bool status_req; ++ u16 col_addr; ++}; ++ ++/* ++ * Define delays in microsec for NAND device operations ++ */ ++#define TROP_US_DELAY 2000 ++ ++#ifdef CONFIG_MTD_NAND_MXC_SWECC ++static int hardware_ecc = 0; ++#else ++static int hardware_ecc = 1; ++#endif ++ ++static u8 num_of_interleave = 1; ++ ++/* ++ * OOB placement block for use with hardware ecc generation ++ */ ++static struct nand_ecclayout nand_hw_eccoob_512 = { ++ .eccbytes = 9, ++ .eccpos = {7, 8, 9, 10, 11, 12, 13, 14, 15}, ++ .oobfree = {{0, 4}}, ++}; ++ ++static struct nand_ecclayout nand_hw_eccoob_2k = { ++ .eccbytes = 9, ++ .eccpos = {7, 8, 9, 10, 11, 12, 13, 14, 15}, ++ .oobfree = {{2, 5}, {16, 7}, {32, 7}, {48,7}}, ++}; ++ ++static struct nand_ecclayout nand_hw_eccoob_4k = { ++ .eccbytes = 9, ++ .eccpos = {7, 8, 9, 10, 11, 12, 13, 14, 15}, ++ .oobfree = {{2, 5}, {16, 218 - 16}}, ++}; ++ ++/*! ++ * @defgroup NAND_MTD NAND Flash MTD Driver for MXC processors ++ */ ++ ++/*! ++ * @file mxc_nd2.c ++ * ++ * @brief This file contains the hardware specific layer for NAND Flash on ++ * MXC processor ++ * ++ * @ingroup NAND_MTD ++ */ ++ ++#ifdef CONFIG_MTD_PARTITIONS ++static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL }; ++#endif ++ ++static irqreturn_t mxc_nfc_irq(int irq, void *dev_id) ++{ ++ struct mxc_mtd_s *mxc_nand_data = dev_id; ++ ++ /* Disable Interrupt */ ++ nfc_write_reg(mxc_nand_data, ++ nfc_read_reg(mxc_nand_data, REG_NFC_INTERRUPT) | ++ NFC_INT_MSK, REG_NFC_INTERRUPT); ++ wake_up(&mxc_nand_data->irq_waitq); ++ ++ return IRQ_HANDLED; ++} ++ ++/* ++ * Functions to transfer data to/from spare erea. ++ */ ++static void ++copy_spare(struct mtd_info *mtd, void *pbuf, void *pspare, int len, bool bfrom) ++{ ++ u16 i, j; ++ u16 m = mtd->oobsize; ++ u16 n = mtd->writesize >> 9; ++ u8 *d = (u8 *) pbuf; ++ u8 *s = (u8 *) pspare; ++ u16 t = SPARE_LEN; ++ ++ m /= num_of_interleave; ++ n /= num_of_interleave; ++ ++ j = (m / n >> 1) << 1; ++ ++ if (bfrom) { ++ for (i = 0; i < n - 1; i++) ++ memcpy(&d[i * j], &s[i * t], j); ++ ++ /* the last section */ ++ memcpy(&d[i * j], &s[i * t], len - i * j); ++ } else { ++ for (i = 0; i < n - 1; i++) ++ memcpy(&s[i * t], &d[i * j], j); ++ ++ /* the last section */ ++ memcpy(&s[i * t], &d[i * j], len - i * j); ++ } ++} ++ ++/*! ++ * This function polls the NFC to wait for the basic operation to complete by ++ * checking the INT bit of config2 register. ++ * ++ * @param retries number of retry attempts (separated by 1 us) ++ * @param useirq True if IRQ should be used rather than polling ++ */ ++static void wait_op_done(struct mxc_mtd_s *mxc_nand_data, int retries, bool useirq) ++{ ++ u32 nfc_stat; ++ static unsigned long max_wait[2]; ++ unsigned long timeout = msecs_to_jiffies(retries); ++ int op; ++ ++ nfc_stat = nfc_read_reg(mxc_nand_data, REG_NFC_OPS_STAT); ++ op = nfc_stat & 0xff; ++ DBG(2, "%s: cmd: 0x%02x op: 0x%02x irq: %d\n", __FUNCTION__, ++ __raw_readw(mxc_nand_data->reg_base + REG_NFC_FLASH_CMD), ++ op, useirq); ++ if (useirq) { ++ if (!(nfc_stat & NFC_OPS_STAT)) { ++ /* Enable Interrupt */ ++ nfc_write_reg(mxc_nand_data, ++ nfc_read_reg(mxc_nand_data, ++ REG_NFC_INTERRUPT) & ~NFC_INT_MSK, ++ REG_NFC_INTERRUPT); ++ retries = wait_event_timeout(mxc_nand_data->irq_waitq, ++ (nfc_stat = nfc_read_reg(mxc_nand_data, ++ REG_NFC_OPS_STAT)) & NFC_OPS_STAT, ++ timeout); ++ } ++ } else { ++ while (!(nfc_stat & NFC_OPS_STAT) && retries-- > 0) { ++ udelay(1); ++ nfc_stat = nfc_read_reg(mxc_nand_data, REG_NFC_OPS_STAT); ++ } ++ } ++ if (!(nfc_stat & NFC_OPS_STAT) && retries <= 0) { ++ printk(KERN_ERR "%s: timeout waiting for NFC INT for cmd: 0x%02x op 0x%02x: %d\n", ++ __FUNCTION__, __raw_readw(mxc_nand_data->reg_base + ++ REG_NFC_FLASH_CMD), op, useirq); ++ BUG(); ++ } else { ++ unsigned long wait = (useirq ? timeout : TROP_US_DELAY) - retries; ++ if (wait > max_wait[useirq]) { ++ max_wait[useirq] = wait; ++ DBG(2, "%s: ready(%d) after %lu ticks\n", __FUNCTION__, ++ useirq, max_wait[useirq]); ++ } ++ } ++ WRITE_NFC_IP_REG(nfc_stat & ~NFC_OPS_STAT, REG_NFC_OPS_STAT); ++ if (nfc_stat & NFC_OPS_STAT) { ++ DBG(2, "%s: Done: irq: %d ticks: %d\n", __FUNCTION__, useirq, retries); ++ } else { ++ DBG(0, "%s: Failed: irq: %d\n", __FUNCTION__, useirq); ++ } ++} ++ ++static inline void send_atomic_cmd(struct mxc_mtd_s *mxc_nand_data, u16 cmd, bool useirq) ++{ ++ /* fill command */ ++ nfc_write_reg(mxc_nand_data, cmd, REG_NFC_FLASH_CMD); ++ ++ /* clear status */ ++ ACK_OPS; ++ ++ /* send out command */ ++ nfc_write_reg(mxc_nand_data, NFC_CMD, REG_NFC_OPS); ++ ++ /* Wait for operation to complete */ ++ wait_op_done(mxc_nand_data, TROP_US_DELAY, useirq); ++} ++ ++static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr); ++static int mxc_check_ecc_status(struct mtd_info *mtd); ++ ++#ifdef NFC_AUTO_MODE_ENABLE ++/*! ++ * This function handle the interleave related work ++ * @param mtd mtd info ++ * @param cmd command ++ */ ++static void auto_cmd_interleave(struct mtd_info *mtd, u16 cmd) ++{ ++ u32 i; ++ u32 j = num_of_interleave; ++ struct nand_chip *this = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ u32 addr_low = nfc_read_reg(mxc_nand_data, NFC_FLASH_ADDR0); ++ u32 addr_high = nfc_read_reg(mxc_nand_data, NFC_FLASH_ADDR8); ++ u32 page_addr = addr_low >> 16 | addr_high << 16; ++ u8 *dbuf = mxc_nand_data->data_buf; ++ u8 *obuf = mxc_nand_data->oob_buf; ++ u32 dlen = mtd->writesize / j; ++ u32 olen = mtd->oobsize / j; ++ ++ /* adjust the addr value ++ * since ADD_OP mode is 01 ++ */ ++ if (j > 1) ++ page_addr *= j; ++ else ++ page_addr *= this->numchips; ++ ++ switch (cmd) { ++ case NAND_CMD_PAGEPROG: ++ for (i = 0; i < j; i++) { ++ /* reset addr cycle */ ++ if (j > 1) ++ mxc_do_addr_cycle(mtd, 0, page_addr++); ++ ++ /* data transfer */ ++ memcpy(mxc_nand_data->main_buf, dbuf, dlen); ++ copy_spare(mtd, obuf, mxc_nand_data->spare_buf, olen, false); ++ ++ /* update the value */ ++ dbuf += dlen; ++ obuf += olen; ++ ++ NFC_SET_RBA(0); ++ ACK_OPS; ++ nfc_write_reg(mxc_nand_data, NFC_AUTO_PROG, REG_NFC_OPS); ++ ++ /* wait auto_prog_done bit set */ ++ while (!(raw_read(REG_NFC_OPS_STAT) & NFC_OP_DONE)) ; ++ } ++ ++ wait_op_done(TROP_US_DELAY, false); ++ while (!(raw_read(REG_NFC_OPS_STAT) & NFC_RB)) ; ++ ++ break; ++ case NAND_CMD_READSTART: ++ for (i = 0; i < j; i++) { ++ /* reset addr cycle */ ++ if (j > 1) ++ mxc_do_addr_cycle(mtd, 0, page_addr++); ++ ++ NFC_SET_RBA(0); ++ ACK_OPS; ++ nfc_write_reg(mxc_nand_data, NFC_AUTO_READ, REG_NFC_OPS); ++ wait_op_done(mxc_nand_data, TROP_US_DELAY, true); ++ ++ /* check ecc error */ ++ mxc_check_ecc_status(mtd); ++ ++ /* data transfer */ ++ memcpy(dbuf, mxc_nand_data->main_buf, dlen); ++ copy_spare(mtd, obuf, mxc_nand_data->spare_buf, olen, true); ++ ++ /* update the value */ ++ dbuf += dlen; ++ obuf += olen; ++ } ++ break; ++ case NAND_CMD_ERASE2: ++ for (i = 0; i < j; i++) { ++ if (!i) { ++ page_addr = addr_low; ++ page_addr *= (j > 1 ? j : this->numchips); ++ } ++ mxc_do_addr_cycle(mtd, -1, page_addr++); ++ ACK_OPS; ++ nfc_write_reg(NFC_AUTO_ERASE, REG_NFC_OPS); ++ wait_op_done(TROP_US_DELAY, true); ++ } ++ break; ++ case NAND_CMD_RESET: ++ for (i = 0; i < j; i++) { ++ if (j > 1) ++ NFC_SET_NFC_ACTIVE_CS(i); ++ send_atomic_cmd(cmd, false); ++ } ++ break; ++ } ++} ++#endif ++ ++static void send_addr(struct mxc_mtd_s *mxc_nand_data, u16 addr, bool useirq); ++ ++/*! ++ * This function issues the specified command to the NAND device and ++ * waits for completion. ++ * ++ * @param cmd command for NAND Flash ++ * @param useirq True if IRQ should be used rather than polling ++ */ ++static void send_cmd(struct mtd_info *mtd, u16 cmd, bool useirq) ++{ ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ ++ DEBUG(MTD_DEBUG_LEVEL3, "send_cmd(0x%x, %d)\n", cmd, useirq); ++ ++#ifdef NFC_AUTO_MODE_ENABLE ++ switch (cmd) { ++ case NAND_CMD_READ0: ++ case NAND_CMD_READOOB: ++ nfc_write_reg(mxc_nand_data, NAND_CMD_READ0, REG_NFC_FLASH_CMD); ++ break; ++ case NAND_CMD_SEQIN: ++ case NAND_CMD_ERASE1: ++ nfc_write_reg(mxc_nand_data, cmd, REG_NFC_FLASH_CMD); ++ break; ++ case NAND_CMD_PAGEPROG: ++ case NAND_CMD_ERASE2: ++ case NAND_CMD_READSTART: ++ nfc_write_reg(mxc_nand_data, ++ nfc_read_reg(mxc_nand_data, REG_NFC_FLASH_CMD) | ++ cmd << NFC_CMD_1_SHIFT, ++ REG_NFC_FLASH_CMD); ++ auto_cmd_interleave(mtd, cmd); ++ break; ++ case NAND_CMD_READID: ++ send_atomic_cmd(mxc_nand_data, cmd, useirq); ++ send_addr(mxc_nand_data, 0, false); ++ break; ++ case NAND_CMD_RESET: ++ auto_cmd_interleave(mtd, cmd); ++ case NAND_CMD_STATUS: ++ break; ++ } ++#else ++ send_atomic_cmd(mxc_nand_data, cmd, useirq); ++#endif ++} ++ ++/*! ++ * This function sends an address (or partial address) to the ++ * NAND device. The address is used to select the source/destination for ++ * a NAND command. ++ * ++ * @param addr address to be written to NFC. ++ * @param useirq True if IRQ should be used rather than polling ++ */ ++static void send_addr(struct mxc_mtd_s *mxc_nand_data, u16 addr, bool useirq) ++{ ++ DEBUG(MTD_DEBUG_LEVEL3, "send_addr(0x%x %d)\n", addr, useirq); ++ ++ /* fill address */ ++ nfc_write_reg(mxc_nand_data, (addr << NFC_FLASH_ADDR_SHIFT), ++ REG_NFC_FLASH_ADDR); ++ ++ /* clear status */ ++ ACK_OPS; ++ ++ /* send out address */ ++ nfc_write_reg(mxc_nand_data, NFC_ADDR, REG_NFC_OPS); ++ ++ /* Wait for operation to complete */ ++ wait_op_done(mxc_nand_data, TROP_US_DELAY, useirq); ++} ++ ++/*! ++ * This function requests the NFC to initate the transfer ++ * of data currently in the NFC RAM buffer to the NAND device. ++ * ++ * @param buf_id Specify Internal RAM Buffer number ++ */ ++static void send_prog_page(struct mxc_mtd_s *mxc_nand_data, u8 buf_id) ++{ ++#ifndef NFC_AUTO_MODE_ENABLE ++ DEBUG(MTD_DEBUG_LEVEL0, "%s\n", __FUNCTION__); ++ ++ /* set ram buffer id */ ++ NFC_SET_RBA(buf_id); ++ ++ /* clear status */ ++ ACK_OPS; ++ ++ /* transfer data from NFC ram to nand */ ++ nfc_write_reg(mxc_nand_data, NFC_INPUT, REG_NFC_OPS); ++ ++ /* Wait for operation to complete */ ++ wait_op_done(mxc_nand_data, TROP_US_DELAY, true); ++#endif ++} ++ ++/*! ++ * This function requests the NFC to initated the transfer ++ * of data from the NAND device into in the NFC ram buffer. ++ * ++ * @param buf_id Specify Internal RAM Buffer number ++ */ ++static void send_read_page(struct mxc_mtd_s *mxc_nand_data, u8 buf_id) ++{ ++#ifndef NFC_AUTO_MODE_ENABLE ++ DEBUG(MTD_DEBUG_LEVEL2, "%s(%d)\n", __FUNCTION__, buf_id); ++ ++ /* set ram buffer id */ ++ NFC_SET_RBA(buf_id); ++ ++ /* clear status */ ++ ACK_OPS; ++ ++ /* transfer data from nand to NFC ram */ ++ nfc_write_reg(mxc_nand_data, NFC_OUTPUT, REG_NFC_OPS); ++ ++ /* Wait for operation to complete */ ++ wait_op_done(mxc_nand_data, TROP_US_DELAY, true); ++#endif ++} ++ ++/*! ++ * This function requests the NFC to perform a read of the ++ * NAND device ID. ++ */ ++static void send_read_id(struct mxc_mtd_s *mxc_nand_data) ++{ ++ DBG(2, "%s: \n", __FUNCTION__); ++ ++ /* Set RBA bits for BUFFER0 */ ++ NFC_SET_RBA(0); ++ ++ /* clear status */ ++ ACK_OPS; ++ ++ /* Read ID into main buffer */ ++ nfc_write_reg(mxc_nand_data, NFC_ID, REG_NFC_OPS); ++ ++ /* Wait for operation to complete */ ++ wait_op_done(mxc_nand_data, TROP_US_DELAY, true); ++} ++ ++#ifdef NFC_AUTO_MODE_ENABLE ++static inline void read_dev_status(u16 *status) ++{ ++ u32 mask = 0xFF << 16; ++ ++ /* clear status */ ++ ACK_OPS; ++ ++ do { ++ /* send auto read status command */ ++ nfc_write_reg(NFC_AUTO_STATE, REG_NFC_OPS); ++ if (cpu_is_mx51_rev(CHIP_REV_2_0) == 1) ++ wait_op_done(TROP_US_DELAY, false); ++ *status = (raw_read(NFC_CONFIG1) & mask) >> 16; ++ } while ((*status & NAND_STATUS_READY) == 0); ++} ++#endif ++ ++/*! ++ * This function requests the NFC to perform a read of the ++ * NAND device status and returns the current status. ++ * ++ * @return device status ++ */ ++static u16 get_dev_status(struct mxc_mtd_s *mxc_nand_data) ++{ ++#ifdef NFC_AUTO_MODE_ENABLE ++ int i; ++ u16 status = 0; ++ for (i = 0; i < num_of_interleave; i++) { ++ ++ /* set ative cs */ ++ NFC_SET_NFC_ACTIVE_CS(i); ++ ++ /* FIXME, NFC Auto erase may have ++ * problem, have to poll it until ++ * the nand get idle, otherwise ++ * it may get error ++ */ ++ read_dev_status(&status); ++ if (status & NAND_STATUS_FAIL) ++ break; ++ } ++ ++ return status; ++#else ++ u8 val = 1; ++ u16 *main_buf = mxc_nand_data->main_buf + val * (0x200 >> 1); ++ u16 ret; ++ u16 save = *main_buf; ++ ++ /* Set ram buffer id */ ++ NFC_SET_RBA(val); ++ ++ /* clear status */ ++ ACK_OPS; ++ ++ if (dbg_lvl(3)) { ++ for (val = 0; val < 8; val++) { ++ u16 *main_buf = mxc_nand_data->main_buf + val * (0x200 >> 1); ++ print_hex_dump(KERN_DEBUG, "mainbuf0: ", ++ DUMP_PREFIX_ADDRESS, ++ 16, 2, main_buf, 16, 0); ++ } ++ } ++ ++ /* Read status into main buffer */ ++ nfc_write_reg(mxc_nand_data, NFC_STATUS, REG_NFC_OPS); ++ ++ /* Wait for operation to complete */ ++ wait_op_done(mxc_nand_data, TROP_US_DELAY, true); ++ ++ if (dbg_lvl(3)) { ++ for (val = 0; val < 8; val++) { ++ u16 *main_buf = mxc_nand_data->main_buf + val * (0x200 >> 1); ++ print_hex_dump(KERN_DEBUG, "mainbuf1: ", ++ DUMP_PREFIX_ADDRESS, ++ 16, 2, main_buf, 16, 0); ++ } ++ } ++ ++ /* Status is placed in first word of main buffer */ ++ /* get status, then recover area 1 data */ ++ ret = *main_buf; ++ *main_buf = save; ++ ++ return ret; ++#endif ++} ++ ++static void mxc_nand_enable_hwecc(struct mtd_info *mtd, int mode) ++{ ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ ++ nfc_write_reg(mxc_nand_data, ++ (nfc_read_reg(mxc_nand_data, REG_NFC_ECC_EN) | NFC_ECC_EN), ++ REG_NFC_ECC_EN); ++ return; ++} ++ ++/* ++ * Function to record the ECC corrected/uncorrected errors resulted ++ * after a page read. This NFC detects and corrects upto to 4 symbols ++ * of 9-bits each. ++ */ ++static int mxc_check_ecc_status(struct mtd_info *mtd) ++{ ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ int no_subpages = (mtd->writesize >> 9) / num_of_interleave; ++ int ret = 0; ++ u8 ecc_bit_mask = (IS_4BIT_ECC ? 0x7 : 0xf); ++ u8 err_limit = (IS_4BIT_ECC ? 0x4 : 0x8); ++ u32 ecc_stat; ++ ++ ecc_stat = GET_NFC_ECC_STATUS(); ++ do { ++ u32 err = ecc_stat & ecc_bit_mask; ++ if (err > err_limit) { ++ mtd->ecc_stats.failed++; ++ printk(KERN_WARNING "UnCorrectable RS-ECC Error\n"); ++ return -EILSEQ; ++ } else { ++ ret += err; ++ } ++ ecc_stat >>= 4; ++ } while (--no_subpages); ++ ++ mtd->ecc_stats.corrected += ret; ++ pr_debug("%d Symbol Correctable RS-ECC Error\n", ret); ++ ++ return ret; ++} ++ ++/* ++ * Function to correct the detected errors. This NFC corrects all the errors ++ * detected. So this function just return 0. ++ */ ++static int mxc_nand_correct_data(struct mtd_info *mtd, u_char *dat, ++ u_char *read_ecc, u_char *calc_ecc) ++{ ++ return 0; ++} ++ ++/* ++ * Function to calculate the ECC for the data to be stored in the Nand device. ++ * This NFC has a hardware RS(511,503) ECC engine together with the RS ECC ++ * CONTROL blocks are responsible for detection and correction of up to ++ * 8 symbols of 9 bits each in 528 byte page. ++ * So this function is just return 0. ++ */ ++ ++static int mxc_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, ++ u_char *ecc_code) ++{ ++ return 0; ++} ++ ++/*! ++ * This function id is used to read the data buffer from the NAND Flash. To ++ * read the data from NAND Flash first the data output cycle is initiated by ++ * the NFC, which copies the data to RAMbuffer. This data of length \b len is ++ * then copied to buffer \b buf. ++ * ++ * @param mtd MTD structure for the NAND Flash ++ * @param buf data to be read from NAND Flash ++ * @param len number of bytes to be read ++ */ ++static void mxc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) ++{ ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ u16 col = mxc_nand_data->col_addr; ++ ++ if (mtd->writesize) { ++ int j = mtd->writesize - col; ++ int n = min((int)mtd->oobsize + j, len); ++ ++ if (j > 0) { ++ if (WARN_ON(n > j)) { ++ memcpy(buf, &mxc_nand_data->data_buf[col], j); ++ memcpy(buf + j, &mxc_nand_data->oob_buf[0], n - j); ++ } else { ++ memcpy(buf, &mxc_nand_data->data_buf[col], n); ++ } ++ } else { ++ col -= mtd->writesize; ++ memcpy(buf, &mxc_nand_data->oob_buf[col], len); ++ } ++ ++ /* update */ ++ mxc_nand_data->col_addr += n; ++ } else { ++ /* At flash identify phase, ++ * mtd->writesize has not been ++ * set correctly, it should ++ * be zero. And len will less 2 ++ */ ++ memcpy(buf, &mxc_nand_data->data_buf[col], len); ++ ++ /* update */ ++ mxc_nand_data->col_addr += len; ++ } ++} ++ ++/*! ++ * This function reads byte from the NAND Flash ++ * ++ * @param mtd MTD structure for the NAND Flash ++ * ++ * @return data read from the NAND Flash ++ */ ++static u8 mxc_nand_read_byte(struct mtd_info *mtd) ++{ ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ u8 ret; ++ ++ /* Check for status request */ ++ if (mxc_nand_data->status_req) { ++ ret = get_dev_status(mxc_nand_data) & 0xFF; ++ DBG(1, "%s: NAND status=%02x\n", __FUNCTION__, ret); ++ return ret; ++ } ++ ++ mxc_nand_read_buf(mtd, &ret, 1); ++ return ret; ++} ++ ++/*! ++ * This function reads word from the NAND Flash ++ * ++ * @param mtd MTD structure for the NAND Flash ++ * ++ * @return data read from the NAND Flash ++ */ ++static u16 mxc_nand_read_word(struct mtd_info *mtd) ++{ ++ u16 ret; ++ ++ mxc_nand_read_buf(mtd, (u8 *)&ret, sizeof(u16)); ++ return ret; ++} ++ ++/*! ++ * This function reads byte from the NAND Flash ++ * ++ * @param mtd MTD structure for the NAND Flash ++ * ++ * @return data read from the NAND Flash ++ */ ++static u_char mxc_nand_read_byte16(struct mtd_info *mtd) ++{ ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ ++ /* Check for status request */ ++ if (mxc_nand_data->status_req) { ++ return get_dev_status(mxc_nand_data) & 0xFF; ++ } ++ ++ return mxc_nand_read_word(mtd) & 0xFF; ++} ++ ++/*! ++ * This function writes data of length \b len from buffer \b buf to the NAND ++ * internal RAM buffer's MAIN area 0. ++ * ++ * @param mtd MTD structure for the NAND Flash ++ * @param buf data to be written to NAND Flash ++ * @param len number of bytes to be written ++ */ ++static void mxc_nand_write_buf(struct mtd_info *mtd, ++ const u_char *buf, int len) ++{ ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ u16 col = mxc_nand_data->col_addr; ++ int j = mtd->writesize - col; ++ int n = mtd->oobsize + j; ++ ++ n = min(n, len); ++ ++ if (j > 0) { ++ if (n > j) { ++ memcpy(&mxc_nand_data->data_buf[col], buf, j); ++ memcpy(&mxc_nand_data->oob_buf[0], buf + j, n - j); ++ } else { ++ memcpy(&mxc_nand_data->data_buf[col], buf, n); ++ } ++ } else { ++ col -= mtd->writesize; ++ memcpy(&mxc_nand_data->oob_buf[col], buf, len); ++ } ++ ++ /* update */ ++ mxc_nand_data->col_addr += n; ++} ++ ++/*! ++ * This function is used by the upper layer to verify the data in NAND Flash ++ * with the data in the \b buf. ++ * ++ * @param mtd MTD structure for the NAND Flash ++ * @param buf data to be verified ++ * @param len length of the data to be verified ++ * ++ * @return -EFAULT if error else 0 ++ * ++ */ ++static int mxc_nand_verify_buf(struct mtd_info *mtd, const u_char *buf, ++ int len) ++{ ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ u_char *s = mxc_nand_data->data_buf; ++ const u_char *p = buf; ++ ++ for (; len > 0; len--) { ++ if (*p++ != *s++) ++ return -EFAULT; ++ } ++ ++ return 0; ++} ++ ++/*! ++ * This function is used by upper layer for select and deselect of the NAND ++ * chip ++ * ++ * @param mtd MTD structure for the NAND Flash ++ * @param chip val indicating select or deselect ++ */ ++static void mxc_nand_select_chip(struct mtd_info *mtd, int chip) ++{ ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ ++ switch (chip) { ++ case -1: ++ if (mxc_nand_data->clk_act) { ++ /* Disable the NFC clock */ ++ clk_disable(mxc_nand_data->clk); ++ mxc_nand_data->clk_act = 0; ++ } ++ break; ++ case 0 ... 7: ++ /* Enable the NFC clock */ ++ if (!mxc_nand_data->clk_act) { ++ clk_enable(mxc_nand_data->clk); ++ mxc_nand_data->clk_act = 1; ++ } ++ NFC_SET_NFC_ACTIVE_CS(chip); ++ break; ++ default: ++ BUG(); ++ } ++} ++ ++/* ++ * Function to perform the address cycles. ++ */ ++static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr) ++{ ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++#ifdef NFC_AUTO_MODE_ENABLE ++ if (page_addr != -1 && column != -1) { ++ u32 mask = 0xFFFF; ++ /* the column address */ ++ nfc_write_reg(mxc_nand_data, column & mask, NFC_FLASH_ADDR0); ++ nfc_write_reg(mxc_nand_data, ++ (nfc_read_reg(mxc_nand_data, NFC_FLASH_ADDR0) | ++ ((page_addr & mask) << 16)), NFC_FLASH_ADDR0); ++ /* the row address */ ++ nfc_write_reg(mxc_nand_data, ++ ((nfc_read_reg(mxc_nand_data, NFC_FLASH_ADDR8) & ++ (mask << 16)) | ++ ((page_addr & (mask << 16)) >> 16)), ++ NFC_FLASH_ADDR8); ++ } else if (page_addr != -1) { ++ nfc_write_reg(mxc_nand_data, page_addr, NFC_FLASH_ADDR0); ++ } ++ ++ DEBUG(MTD_DEBUG_LEVEL3, ++ "AutoMode:the ADDR REGS value is (0x%x, 0x%x)\n", ++ nfc_read_reg(mxc_nand_data, NFC_FLASH_ADDR0), ++ nfc_read_reg(mxc_nand_data, NFC_FLASH_ADDR8)); ++#else ++ ++ u32 page_mask = nand_chip->pagemask; ++ ++ if (column != -1) { ++ send_addr(mxc_nand_data, column & 0xFF, false); ++ if (IS_2K_PAGE_NAND) { ++ /* another col addr cycle for 2k page */ ++ send_addr(mxc_nand_data, (column >> 8) & 0xF, false); ++ } else if (IS_4K_PAGE_NAND) { ++ /* another col addr cycle for 4k page */ ++ send_addr(mxc_nand_data, (column >> 8) & 0x1F, false); ++ } ++ } ++ if (page_addr != -1) { ++ do { ++ send_addr(mxc_nand_data, (page_addr & 0xff), false); ++ page_mask >>= 8; ++ page_addr >>= 8; ++ } while (page_mask != 0); ++ } ++#endif ++} ++ ++/*! ++ * This function is used by the upper layer to write command to NAND Flash for ++ * different operations to be carried out on NAND Flash ++ * ++ * @param mtd MTD structure for the NAND Flash ++ * @param command command for NAND Flash ++ * @param column column offset for the page read ++ * @param page_addr page to be read from NAND Flash ++ */ ++static void mxc_nand_command(struct mtd_info *mtd, unsigned command, ++ int column, int page_addr) ++{ ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ bool useirq = false; ++ ++ DEBUG(MTD_DEBUG_LEVEL2, ++ "mxc_nand_command (cmd = 0x%x, col = 0x%x, page = 0x%x)\n", ++ command, column, page_addr); ++ /* ++ * Reset command state information ++ */ ++ mxc_nand_data->status_req = false; ++ ++ /* ++ * Command pre-processing step ++ */ ++ switch (command) { ++ case NAND_CMD_STATUS: ++ mxc_nand_data->col_addr = 0; ++ mxc_nand_data->status_req = true; ++ break; ++ ++ case NAND_CMD_READ0: ++ mxc_nand_data->col_addr = column; ++ break; ++ ++ case NAND_CMD_READOOB: ++ mxc_nand_data->col_addr = column; ++ command = NAND_CMD_READ0; ++ break; ++ ++ case NAND_CMD_SEQIN: ++ if (column != 0) { ++ /* Before sending SEQIN command for partial ++ * write, we need to read one page out. ++ * FSL NFC does not support partial write ++ * for large page devices. It alway sends out ++ * 512+ecc+512+ecc.... ++ * For small page nand flash, it would support ++ * SPARE ONLY operation. But to simplify the driver, ++ * we take the same approach for small page and ++ * large page devices: ++ * read out the whole page and update. ++ * As for MLC nand NOP(num of operation) = 1. ++ * Partial writing to one programmed page is ++ * not allowed! We can't limit it in the driver, ++ * the upper layer application needs to take care of it. ++ */ ++ mxc_nand_command(mtd, NAND_CMD_READ0, 0, page_addr); ++ } ++ ++ mxc_nand_data->col_addr = column; ++ break; ++ ++ case NAND_CMD_PAGEPROG: ++#ifndef NFC_AUTO_MODE_ENABLE ++ /* The NFC internal buffer access ++ * has some limitation, it does not ++ * allow byte access. To make the code ++ * simple and easy to use, do not check ++ * the address alignment each time. ++ * Use the temp buffer to accomodate ++ * the data alignment. ++ * We know data_buf will be at least 4 ++ * byte aligned, so we can use ++ * memcpy safely. ++ */ ++ memcpy(mxc_nand_data->main_buf, mxc_nand_data->data_buf, mtd->writesize); ++ copy_spare(mtd, mxc_nand_data->oob_buf, mxc_nand_data->spare_buf, ++ mtd->oobsize, false); ++#endif ++ ++ if (IS_LARGE_PAGE_NAND) ++ PROG_PAGE(mxc_nand_data); ++ else ++ send_prog_page(mxc_nand_data, 0); ++ useirq = true; ++ break; ++ ++ case NAND_CMD_ERASE1: ++ break; ++ case NAND_CMD_ERASE2: ++ useirq = true; ++ ++ break; ++ } ++ ++ /* ++ * Write out the command to the device. ++ */ ++ send_cmd(mtd, command, useirq); ++ ++ mxc_do_addr_cycle(mtd, column, page_addr); ++ ++ /* ++ * Command post-processing step ++ */ ++ switch (command) { ++ ++ case NAND_CMD_READOOB: ++ case NAND_CMD_READ0: ++ if (IS_LARGE_PAGE_NAND) { ++ /* send read confirm command */ ++ send_cmd(mtd, NAND_CMD_READSTART, true); ++ /* read for each AREA */ ++ READ_PAGE(mxc_nand_data); ++ } else { ++ send_read_page(mxc_nand_data, 0); ++ } ++ ++#ifndef NFC_AUTO_MODE_ENABLE ++ /* FIXME, the NFC interal buffer ++ * access has some limitation, it ++ * does not allow byte access. To ++ * make the code simple and ease use ++ * do not check the address alignment ++ * on each access. Use the temp buffer ++ * to accomodate the data. Since we ++ * know data_buf will be at least 4 ++ * byte alignment, so we can use ++ * memcpy safely ++ */ ++ memcpy(mxc_nand_data->data_buf, mxc_nand_data->main_buf, mtd->writesize); ++ copy_spare(mtd, mxc_nand_data->oob_buf, ++ mxc_nand_data->spare_buf, mtd->oobsize, true); ++#endif ++ ++ break; ++ ++ case NAND_CMD_READID: ++ send_read_id(mxc_nand_data); ++ mxc_nand_data->col_addr = column; ++ memcpy(mxc_nand_data->data_buf, mxc_nand_data->main_buf, 2048); ++ break; ++ } ++} ++ ++static int mxc_nand_read_oob(struct mtd_info *mtd, ++ struct nand_chip *chip, int page, int sndcmd) ++{ ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ ++ if (sndcmd) { ++ chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page); ++ sndcmd = 0; ++ } ++ ++ memcpy(chip->oob_poi, mxc_nand_data->oob_buf, mtd->oobsize); ++ ++ return sndcmd; ++} ++ ++static int mxc_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip, ++ u8 *buf) ++{ ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ ++#ifndef NFC_AUTO_MODE_ENABLE ++ if (mxc_check_ecc_status(mtd) < 0) { ++ //printk(KERN_ERR "ECC error in block %u page %u\n",); ++ } ++#endif ++ ++ memcpy(buf, mxc_nand_data->data_buf, mtd->writesize); ++ memcpy(chip->oob_poi, mxc_nand_data->oob_buf, mtd->oobsize); ++ ++ return 0; ++} ++ ++static void mxc_nand_write_page(struct mtd_info *mtd, struct nand_chip *chip, ++ const u8 *buf) ++{ ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ ++ memcpy(mxc_nand_data->data_buf, buf, mtd->writesize); ++ memcpy(mxc_nand_data->oob_buf, chip->oob_poi, mtd->oobsize); ++} ++ ++/* Define some generic bad / good block scan pattern which are used ++ * while scanning a device for factory marked good / bad blocks. */ ++static u8 scan_ff_pattern[] = { 0xff, 0xff }; ++ ++static struct nand_bbt_descr smallpage_memorybased = { ++ .options = NAND_BBT_SCAN2NDPAGE, ++ .offs = 5, ++ .len = 1, ++ .pattern = scan_ff_pattern ++}; ++ ++static struct nand_bbt_descr largepage_memorybased = { ++ .options = 0, ++ .offs = 0, ++ .len = 2, ++ .pattern = scan_ff_pattern ++}; ++ ++/* Generic flash bbt decriptors ++*/ ++static u8 bbt_pattern[] = { 'B', 'b', 't', '0' }; ++static u8 mirror_pattern[] = { '1', 't', 'b', 'B' }; ++ ++static struct nand_bbt_descr bbt_main_descr = { ++ .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE | ++ NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP, ++ .offs = 0, ++ .len = 4, ++ .veroffs = 4, ++ .maxblocks = 4, ++ .pattern = bbt_pattern ++}; ++ ++static struct nand_bbt_descr bbt_mirror_descr = { ++ .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE | ++ NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP, ++ .offs = 0, ++ .len = 4, ++ .veroffs = 4, ++ .maxblocks = 4, ++ .pattern = mirror_pattern ++}; ++ ++static int mxc_nand_scan_bbt(struct mtd_info *mtd) ++{ ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ ++ if (IS_2K_PAGE_NAND) { ++ NFC_SET_NFMS(1 << NFMS_NF_PG_SZ); ++ } else if (IS_4K_PAGE_NAND) { ++ NFC_SET_NFMS(1 << NFMS_NF_PG_SZ); ++ } else { ++ } ++ ++ /* reconfig for interleave mode */ ++#ifdef NFC_AUTO_MODE_ENABLE ++ if (nand_chip->numchips > 1) { ++ num_of_interleave = nand_chip->numchips; ++ nand_chip->numchips = 1; ++ ++ /* FIXEME:need remove it ++ * when kernel support ++ * 4G larger space ++ */ ++ mtd->size = nand_chip->chipsize; ++ mtd->erasesize *= num_of_interleave; ++ mtd->writesize *= num_of_interleave; ++ mtd->oobsize *= num_of_interleave; ++ nand_chip->page_shift = ffs(mtd->writesize) - 1; ++ nand_chip->bbt_erase_shift = ++ nand_chip->phys_erase_shift = ffs(mtd->erasesize) - 1; ++ nand_chip->chip_shift = ffs(nand_chip->chipsize) - 1; ++ nand_chip->oob_poi = nand_chip->buffers->databuf + mtd->writesize; ++ } ++#endif ++ /* jffs2 not write oob */ ++ //mtd->flags |= MTD_OOB_READONLY; ++ ++ /* use flash based bbt */ ++ nand_chip->bbt_td = &bbt_main_descr; ++ nand_chip->bbt_md = &bbt_mirror_descr; ++ ++ /* update flash based bbt */ ++ nand_chip->options |= NAND_USE_FLASH_BBT; ++ ++ if (!nand_chip->badblock_pattern) { ++ nand_chip->badblock_pattern = (mtd->writesize > 512) ? ++ &largepage_memorybased : &smallpage_memorybased; ++ } ++ ++ /* Build bad block table */ ++ return nand_scan_bbt(mtd, nand_chip->badblock_pattern); ++} ++ ++static void mxc_nfc_init(struct mxc_mtd_s *mxc_nand_data) ++{ ++ /* Disable interrupt */ ++ nfc_write_reg(mxc_nand_data, ++ nfc_read_reg(mxc_nand_data, REG_NFC_INTERRUPT) | ++ NFC_INT_MSK, REG_NFC_INTERRUPT); ++ ++ /* disable spare enable */ ++ nfc_write_reg(mxc_nand_data, ++ nfc_read_reg(mxc_nand_data, REG_NFC_SP_EN) & ++ ~NFC_SP_EN, REG_NFC_SP_EN); ++ ++ /* Unlock the internal RAM Buffer */ ++ nfc_write_reg(mxc_nand_data, NFC_SET_BLS(NFC_BLS_UNLOCKED), ++ REG_NFC_BLS); ++ ++ /* Blocks to be unlocked */ ++ UNLOCK_ADDR(0x0, 0xFFFF); ++ ++ /* Unlock Block Command for given address range */ ++ nfc_write_reg(mxc_nand_data, NFC_SET_WPC(NFC_WPC_UNLOCK), REG_NFC_WPC); ++ ++ /* Enable symmetric mode by default except mx37TO1.0 */ ++ if (!cpu_is_mx25()) { ++ nfc_write_reg(mxc_nand_data, ++ nfc_read_reg(mxc_nand_data, REG_NFC_ONE_CYCLE) | ++ NFC_ONE_CYCLE, REG_NFC_ONE_CYCLE); ++ } else { ++ nfc_write_reg(mxc_nand_data, ++ nfc_read_reg(mxc_nand_data, REG_NFC_ONE_CYCLE) & ++ ~NFC_ONE_CYCLE, REG_NFC_ONE_CYCLE); ++ } ++} ++ ++static int mxc_alloc_buf(struct mxc_mtd_s *mxc_nand_data) ++{ ++ u8 *buf; ++ ++ buf = kzalloc(NAND_MAX_PAGESIZE + NAND_MAX_OOBSIZE, GFP_KERNEL); ++ if (!buf) { ++ printk(KERN_ERR "%s: failed to allocate data_buf\n", __func__); ++ return -ENOMEM; ++ } ++ mxc_nand_data->data_buf = buf; ++ mxc_nand_data->oob_buf = &buf[NAND_MAX_PAGESIZE]; ++ return 0; ++} ++ ++static void mxc_free_buf(struct mxc_mtd_s *mxc_nand_data) ++{ ++ kfree(mxc_nand_data->data_buf); ++} ++ ++/*! ++ * This function is called during the driver binding process. ++ * ++ * @param pdev the device structure used to store device specific ++ * information that is used by the suspend, resume and ++ * remove functions ++ * ++ * @return The function always returns 0. ++ */ ++#define SPLIT_SCAN ++ ++static int __init mxcnd_probe(struct platform_device *pdev) ++{ ++ int err; ++ struct nand_chip *this; ++ struct mtd_info *mtd; ++ struct flash_platform_data *pdata = pdev->dev.platform_data; ++ int nr_parts; ++ struct resource *res; ++ struct mxc_mtd_s *mxc_nand_data; ++ struct clk *clk; ++ void __iomem *nfc_axi_base; ++ void __iomem *nfc_ip_base; ++ ++ if (!pdata) { ++ dev_err(&pdev->dev, "No platform_data\n"); ++ return -ENODEV; ++ } ++ ++ /* Allocate memory for MTD device structure and private data */ ++ mxc_nand_data = kzalloc(sizeof(struct mxc_mtd_s), GFP_KERNEL); ++ if (!mxc_nand_data) { ++ printk(KERN_ERR "%s: failed to allocate mtd_info\n", ++ __FUNCTION__); ++ return -ENOMEM; ++ } ++ ++ /* allocate data buffer */ ++ if (mxc_alloc_buf(mxc_nand_data)) { ++ err = -ENOMEM; ++ goto out; ++ } ++ ++ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ++ if (!res) { ++ dev_err(&pdev->dev, "no memory resource\n"); ++ err = -ENODEV; ++ goto out1; ++ } ++ if (!request_mem_region(res->start, resource_size(res), DRV_NAME)) { ++ err = -EBUSY; ++ goto out1; ++ } ++ mxc_nand_data->res_ip = res; ++ ++ nfc_ip_base = ioremap(res->start, resource_size(res)); ++ if (nfc_ip_base == NULL) { ++ dev_err(&pdev->dev, "Failed to ioremap %08lx..%08lx\n", ++ (unsigned long)res->start, (unsigned long)res->end); ++ err = -ENOMEM; ++ goto out2; ++ } ++ DBG(0, "%s: %08lx..%08lx remapped to %p\n", __FUNCTION__, ++ (unsigned long)res->start, (unsigned long)res->end, ++ nfc_ip_base); ++ ++ mxc_nand_data->reg_base = nfc_ip_base; ++ mxc_nand_data->main_buf = mxc_nand_data->reg_base + MAIN_AREA0; ++ mxc_nand_data->spare_buf = mxc_nand_data->reg_base + SPARE_AREA0; ++ ++ DBG(1, "%s: reg_base=%p\n", __FUNCTION__, mxc_nand_data->reg_base); ++ DBG(1, "%s: main_buf=%p\n", __FUNCTION__, mxc_nand_data->main_buf); ++ DBG(1, "%s: spare_buf=%p\n", __FUNCTION__, mxc_nand_data->spare_buf); ++ ++ res = platform_get_resource(pdev, IORESOURCE_MEM, 1); ++ if (res) { ++ if (!request_mem_region(res->start, resource_size(res), DRV_NAME)) { ++ err = -EBUSY; ++ goto out3; ++ } ++ nfc_axi_base = ioremap(res->start, resource_size(res)); ++ if (nfc_axi_base == NULL) { ++ dev_err(&pdev->dev, "Failed to ioremap %08lx..%08lx\n", ++ (unsigned long)res->start, (unsigned long)res->end); ++ err = -ENOMEM; ++ goto out4; ++ } ++ mxc_nand_data->res_axi = res; ++ DBG(0, "%s: %08lx..%08lx remapped to %p\n", __FUNCTION__, ++ (unsigned long)res->start, (unsigned long)res->end, ++ nfc_axi_base); ++ mxc_nand_data->axi_base = nfc_axi_base; ++ } ++ ++ err = platform_get_irq(pdev, 0); ++ if (err < 0) { ++ dev_err(&pdev->dev, "Failed to get IRQ\n"); ++ goto out5; ++ } ++ mxc_nand_data->irq = err; ++ DBG(0, "%s: IRQ=%d\n", __FUNCTION__, mxc_nand_data->irq); ++ ++ /* init the nfc */ ++ mxc_nfc_init(mxc_nand_data); ++ ++ mxc_nand_data->dev = &pdev->dev; ++ /* structures must be linked */ ++ this = &mxc_nand_data->nand; ++ mtd = &mxc_nand_data->mtd; ++ mtd->priv = this; ++ mtd->owner = THIS_MODULE; ++ ++ this->priv = mxc_nand_data; ++ this->cmdfunc = mxc_nand_command; ++ this->select_chip = mxc_nand_select_chip; ++ this->read_byte = mxc_nand_read_byte; ++ this->read_word = mxc_nand_read_word; ++ this->write_buf = mxc_nand_write_buf; ++ this->read_buf = mxc_nand_read_buf; ++ this->verify_buf = mxc_nand_verify_buf; ++ this->scan_bbt = mxc_nand_scan_bbt; ++ ++ /* NAND bus width determines access funtions used by upper layer */ ++ if (pdata->width == 2) { ++ this->read_byte = mxc_nand_read_byte16; ++ this->options |= NAND_BUSWIDTH_16; ++ NFC_SET_NFMS(1 << NFMS_NF_DWIDTH); ++ } else { ++ NFC_SET_NFMS(0); ++ } ++ ++ clk = clk_get(&pdev->dev, "nfc_clk"); ++ if (IS_ERR(clk)) { ++ dev_err(&pdev->dev, "Failed to get nfc_clk: %ld\n", ++ PTR_ERR(clk)); ++ err = PTR_ERR(clk); ++ goto out6; ++ } ++ mxc_nand_data->clk = clk; ++ clk_enable(clk); ++ mxc_nand_data->clk_act = 1; ++ ++ init_waitqueue_head(&mxc_nand_data->irq_waitq); ++ err = request_irq(mxc_nand_data->irq, mxc_nfc_irq, 0, "mxc_nd", ++ mxc_nand_data); ++ if (err) { ++ goto out7; ++ } ++ ++ DBG(0, "%s: Init GPIOs\n", __FUNCTION__); ++ /* config the gpio */ ++ if (pdata->init) { ++ err = pdata->init(); ++ if (err) { ++ printk(KERN_ERR "%s: Failed to init GPIOs: %d\n", ++ __FUNCTION__, err); ++ goto out8; ++ } ++ } ++ ++ DBG(0, "%s: Resetting NAND chip\n", __FUNCTION__); ++ /* Reset NAND */ ++ this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); ++ ++ /* Scan to find existence of the device */ ++ err = nand_scan_ident(mtd, 1); ++ if (err) { ++ DEBUG(MTD_DEBUG_LEVEL0, ++ "MXC_ND: Unable to find any NAND device.\n"); ++ goto out9; ++ } ++ ++ if (IS_2K_PAGE_NAND) { ++ DBG(0, "%s: Using 2k ecc layout\n", __FUNCTION__); ++ this->ecc.layout = &nand_hw_eccoob_2k; ++ } else if (IS_4K_PAGE_NAND) { ++ DBG(0, "%s: Using 4k ecc layout\n", __FUNCTION__); ++ this->ecc.layout = &nand_hw_eccoob_4k; ++ } else { ++ DBG(0, "%s: Using 512b ecc layout\n", __FUNCTION__); ++ this->ecc.layout = &nand_hw_eccoob_512; ++ } ++ if (hardware_ecc) { ++ this->ecc.read_page = mxc_nand_read_page; ++ this->ecc.write_page = mxc_nand_write_page; ++ this->ecc.read_oob = mxc_nand_read_oob; ++ this->ecc.calculate = mxc_nand_calculate_ecc; ++ this->ecc.hwctl = mxc_nand_enable_hwecc; ++ this->ecc.correct = mxc_nand_correct_data; ++ this->ecc.mode = NAND_ECC_HW; ++ this->ecc.size = 512; ++ this->ecc.bytes = 9; ++ nfc_write_reg(mxc_nand_data, ++ (nfc_read_reg(mxc_nand_data, REG_NFC_ECC_EN) | NFC_ECC_EN), ++ REG_NFC_ECC_EN); ++ } else { ++ this->ecc.mode = NAND_ECC_SOFT; ++ nfc_write_reg(mxc_nand_data, ++ (nfc_read_reg(mxc_nand_data, REG_NFC_ECC_EN) & ~NFC_ECC_EN), ++ REG_NFC_ECC_EN); ++ } ++ ++ DBG(0, "%s: Scanning for NAND devices\n", __FUNCTION__); ++ err = nand_scan_tail(mtd); ++ if (err) { ++ goto out9; ++ } ++ ++ printk(KERN_INFO "MXC NAND V2 driver %d bit bus width %s ECC with %u/%u byte\n", ++ pdata->width * 8, hardware_ecc ? "HW" : "SW", ++ this->ecc.bytes, this->ecc.size); ++ ++ /* Register the partitions */ ++#ifdef CONFIG_MTD_PARTITIONS ++ nr_parts = ++ parse_mtd_partitions(mtd, part_probes, &mxc_nand_data->parts, 0); ++ if (nr_parts > 0) ++ add_mtd_partitions(mtd, mxc_nand_data->parts, nr_parts); ++ else if (pdata->parts) ++ add_mtd_partitions(mtd, pdata->parts, pdata->nr_parts); ++ else ++#endif ++ { ++ pr_info("Registering %s as whole device\n", mtd->name); ++ add_mtd_device(mtd); ++ } ++ ++ platform_set_drvdata(pdev, mtd); ++ return 0; ++ ++ out9: ++ if (pdata->exit) ++ pdata->exit(); ++ out8: ++ free_irq(mxc_nand_data->irq, mxc_nand_data); ++ out7: ++ clk_disable(clk); ++ clk_put(clk); ++ out6: ++ mxc_free_buf(mxc_nand_data); ++ out5: ++ if (mxc_nand_data->axi_base) ++ iounmap(mxc_nand_data->axi_base); ++ out4: ++ if (mxc_nand_data->res_axi) ++ release_mem_region(mxc_nand_data->res_axi->start, ++ resource_size(mxc_nand_data->res_axi)); ++ out3: ++ iounmap(mxc_nand_data->reg_base); ++ out2: ++ release_mem_region(mxc_nand_data->res_ip->start, ++ resource_size(mxc_nand_data->res_ip)); ++ out1: ++ mxc_free_buf(mxc_nand_data); ++ out: ++ kfree(mxc_nand_data); ++ return err; ++} ++ ++ /*! ++ * Dissociates the driver from the device. ++ * ++ * @param pdev the device structure used to give information on which ++ * ++ * @return The function always returns 0. ++ */ ++ ++static int __exit mxcnd_remove(struct platform_device *pdev) ++{ ++ struct mtd_info *mtd = platform_get_drvdata(pdev); ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ struct flash_platform_data *pdata = pdev->dev.platform_data; ++ ++ if (pdata->exit) ++ pdata->exit(); ++ ++ nand_release(mtd); ++ ++ free_irq(mxc_nand_data->irq, mxc_nand_data); ++ clk_disable(mxc_nand_data->clk); ++ clk_put(mxc_nand_data->clk); ++ ++ iounmap(mxc_nand_data->reg_base); ++ release_mem_region(mxc_nand_data->res_ip->start, ++ resource_size(mxc_nand_data->res_ip)); ++ if (mxc_nand_data->res_axi) { ++ iounmap(mxc_nand_data->axi_base); ++ release_mem_region(mxc_nand_data->res_axi->start, ++ resource_size(mxc_nand_data->res_axi)); ++ } ++ mxc_free_buf(mxc_nand_data); ++ kfree(mxc_nand_data); ++ return 0; ++} ++ ++#ifdef CONFIG_PM ++/*! ++ * This function is called to put the NAND in a low power state. Refer to the ++ * document driver-model/driver.txt in the kernel source tree for more ++ * information. ++ * ++ * @param pdev the device information structure ++ * ++ * @param state the power state the device is entering ++ * ++ * @return The function returns 0 on success and a negative errno value on failure ++ */ ++ ++static int mxcnd_suspend(struct platform_device *pdev, pm_message_t state) ++{ ++ int ret; ++ struct mtd_info *mtd = platform_get_drvdata(pdev); ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ ++ DEBUG(MTD_DEBUG_LEVEL0, "MXC_ND2 : NAND suspend\n"); ++ ret = mtd->suspend(mtd); ++ if (ret == 0) { ++ /* Disable the NFC clock */ ++ clk_disable(mxc_nand_data->clk); ++ } ++ return ret; ++} ++ ++/*! ++ * This function is called to bring the NAND back from a low power state. Refer ++ * to the document driver-model/driver.txt in the kernel source tree for more ++ * information. ++ * ++ * @param pdev the device information structure ++ * ++ * @return The function returns 0 on success and a negative errno value on failure ++ */ ++static int mxcnd_resume(struct platform_device *pdev) ++{ ++ struct mtd_info *mtd = platform_get_drvdata(pdev); ++ struct nand_chip *nand_chip = mtd->priv; ++ struct mxc_mtd_s *mxc_nand_data = nand_chip->priv; ++ int ret = 0; ++ ++ DEBUG(MTD_DEBUG_LEVEL0, "MXC_ND2 : NAND resume\n"); ++ /* Enable the NFC clock */ ++ clk_enable(mxc_nand_data->clk); ++ ++ mtd->resume(mtd); ++ ++ return ret; ++} ++ ++#else ++#define mxcnd_suspend NULL ++#define mxcnd_resume NULL ++#endif /* CONFIG_PM */ ++ ++/*! ++ * This structure contains pointers to the power management callback functions. ++ */ ++static struct platform_driver mxcnd_driver = { ++ .driver = { ++ .name = DRV_NAME, ++ }, ++ .probe = mxcnd_probe, ++ .remove = __exit_p(mxcnd_remove), ++ .suspend = mxcnd_suspend, ++ .resume = mxcnd_resume, ++}; ++ ++/*! ++ * Main initialization routine ++ * @return 0 if successful; non-zero otherwise ++ */ ++static int __init mxc_nd_init(void) ++{ ++ int ret; ++ ++ /* Register the device driver structure. */ ++ ret = platform_driver_register(&mxcnd_driver); ++ if (ret != 0) { ++ printk(KERN_ERR "Driver register failed for mxcnd_driver\n"); ++ } ++ return ret; ++} ++ ++/*! ++ * Clean up routine ++ */ ++static void __exit mxc_nd_cleanup(void) ++{ ++ /* Unregister the device structure */ ++ platform_driver_unregister(&mxcnd_driver); ++} ++ ++module_init(mxc_nd_init); ++module_exit(mxc_nd_cleanup); ++ ++MODULE_AUTHOR("Freescale Semiconductor, Inc."); ++MODULE_DESCRIPTION("MXC NAND MTD driver Version 2-5"); ++MODULE_LICENSE("GPL"); +diff -urNp linux-2.6.30-rc4/drivers/mtd/nand/mxc_nd2.h linux-2.6.30-rc4-karo/drivers/mtd/nand/mxc_nd2.h +--- linux-2.6.30-rc4/drivers/mtd/nand/mxc_nd2.h 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/drivers/mtd/nand/mxc_nd2.h 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,699 @@ ++/* ++ * Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved. ++ */ ++ ++/* ++ * The code contained herein is licensed under the GNU General Public ++ * License. You may obtain a copy of the GNU General Public License ++ * Version 2 or later at the following locations: ++ * ++ * http://www.opensource.org/licenses/gpl-license.html ++ * http://www.gnu.org/copyleft/gpl.html ++ */ ++ ++/*! ++ * @file mxc_nd2.h ++ * ++ * @brief This file contains the NAND Flash Controller register information. ++ * ++ * ++ * @ingroup NAND_MTD ++ */ ++ ++#ifndef __MXC_ND2_H__ ++#define __MXC_ND2_H__ ++ ++#include ++ ++#define IS_2K_PAGE_NAND ((mtd->writesize / num_of_interleave) \ ++ == NAND_PAGESIZE_2KB) ++#define IS_4K_PAGE_NAND ((mtd->writesize / num_of_interleave) \ ++ == NAND_PAGESIZE_4KB) ++#define IS_LARGE_PAGE_NAND ((mtd->writesize / num_of_interleave) > 512) ++ ++#define GET_NAND_OOB_SIZE (mtd->oobsize / num_of_interleave) ++ ++#define NAND_PAGESIZE_2KB 2048 ++#define NAND_PAGESIZE_4KB 4096 ++ ++#ifdef CONFIG_ARCH_MXC_HAS_NFC_V3 ++/* ++ * For V3 NFC registers Definition ++ */ ++/* AXI Bus Mapped */ ++#define NFC_AXI_BASE_ADDR NFC_BASE_ADDR_AXI ++ ++#if defined(CONFIG_ARCH_MXC_HAS_NFC_V3_1) /* mx37 */ ++#define MXC_INT_NANDFC MXC_INT_EMI ++#define NFC_FLASH_ADDR_CMD (nfc_axi_base + 0x1E00) ++#define NFC_CONFIG1 (nfc_axi_base + 0x1E04) ++#define NFC_ECC_STATUS_RESULT (nfc_axi_base + 0x1E08) ++#define LAUNCH_NFC (nfc_axi_base + 0x1E0c) ++#define NFC_WRPROT 0x00 ++#define NFC_WRPROT_UNLOCK_BLK_ADD0 0x04 ++#define NFC_CONFIG2 0x14 ++#define NFC_IPC 0x18 ++#elif defined(CONFIG_ARCH_MXC_HAS_NFC_V3_2) /* mx51 */ ++#define MXC_INT_NANDFC MXC_INT_NFC ++#define NFC_AUTO_MODE_ENABLE ++#define NFC_FLASH_CMD (nfc_axi_base + 0x1E00) ++#define NFC_FLASH_ADDR0 (nfc_axi_base + 0x1E04) ++#define NFC_FLASH_ADDR8 (nfc_axi_base + 0x1E24) ++#define NFC_CONFIG1 (nfc_axi_base + 0x1E34) ++#define NFC_ECC_STATUS_RESULT (nfc_axi_base + 0x1E38) ++#define NFC_ECC_STATUS_SUM (nfc_axi_base + 0x1E3C) ++#define LAUNCH_NFC (nfc_axi_base + 0x1E40) ++#define NFC_WRPROT 0x00 ++#define NFC_WRPROT_UNLOCK_BLK_ADD0 0x04 ++#define NFC_CONFIG2 0x24 ++#define NFC_CONFIG3 0x28 ++#define NFC_IPC 0x2C ++#else /* skye */ ++#define NFC_FLASH_ADDR_CMD (nfc_axi_base + 0xE00) ++#define NFC_CONFIG1 (nfc_axi_base + 0xE04) ++#define NFC_ECC_STATUS_RESULT (nfc_axi_base + 0xE08) ++#define LAUNCH_NFC (nfc_axi_base + 0xE0C) ++#define NFC_WRPROT 0x00 ++#define NFC_WRPROT_UNLOCK_BLK_ADD0 0x04 ++#define NFC_CONFIG2 0x14 ++#define NFC_IPC 0x18 ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V3_1 */ ++/*! ++ * Addresses for NFC RAM BUFFER Main area 0 ++ */ ++#define MAIN_AREA0 ((u16 *)(nfc_axi_base + 0x000)) ++#define MAIN_AREA1 ((u16 *)(nfc_axi_base + 0x200)) ++ ++/*! ++ * Addresses for NFC SPARE BUFFER Spare area 0 ++ */ ++#if defined(CONFIG_ARCH_MXC_HAS_NFC_V3_1) || \ ++ defined(CONFIG_ARCH_MXC_HAS_NFC_V3_2) ++#define SPARE_AREA0 ((u16 *)(nfc_axi_base + 0x1000)) ++#define SPARE_LEN 64 ++#define SPARE_COUNT 8 ++#define SPARE_SIZE (SPARE_LEN * SPARE_COUNT) ++#else ++#define SPARE_AREA0 ((u16 *)(nfc_axi_base + 0x800)) ++#define SPARE_LEN 16 ++#define SPARE_COUNT 4 ++#define SPARE_SIZE (SPARE_LEN * SPARE_COUNT) ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V3_1 */ ++ ++#if defined(CONFIG_ARCH_MXC_HAS_NFC_V3_1) || \ ++ defined(CONFIG_ARCH_MXC_HAS_NFC_V3_2) ++#define NFC_SPAS_WIDTH 8 ++#define NFC_SPAS_SHIFT 16 ++ ++#define IS_4BIT_ECC \ ++( \ ++ cpu_is_mx51_rev(CHIP_REV_2_0) == 1 ? \ ++ !((raw_read(NFC_CONFIG2) & NFC_ECC_MODE_4) >> 6) : \ ++ ((raw_read(NFC_CONFIG2) & NFC_ECC_MODE_4) >> 6) \ ++) ++ ++#define NFC_SET_SPAS(v) \ ++ raw_write((((raw_read(NFC_CONFIG2) & \ ++ NFC_FIELD_RESET(NFC_SPAS_WIDTH, NFC_SPAS_SHIFT)) | ((v) << 16))), \ ++ NFC_CONFIG2) ++ ++#define NFC_SET_ECC_MODE(v) \ ++do { \ ++ if (cpu_is_mx51_rev(CHIP_REV_2_0) == 1) { \ ++ if ((v) == NFC_SPAS_218 || (v) == NFC_SPAS_112) \ ++ raw_write(((raw_read(NFC_CONFIG2) & \ ++ NFC_ECC_MODE_MASK) | \ ++ NFC_ECC_MODE_4), NFC_CONFIG2); \ ++ else \ ++ raw_write(((raw_read(NFC_CONFIG2) & \ ++ NFC_ECC_MODE_MASK) & \ ++ ~NFC_ECC_MODE_4), NFC_CONFIG2); \ ++ } else { \ ++ if ((v) == NFC_SPAS_218 || (v) == NFC_SPAS_112) \ ++ raw_write(((raw_read(NFC_CONFIG2) & \ ++ NFC_ECC_MODE_MASK) & \ ++ ~NFC_ECC_MODE_4), NFC_CONFIG2); \ ++ else \ ++ raw_write(((raw_read(NFC_CONFIG2) & \ ++ NFC_ECC_MODE_MASK) | \ ++ NFC_ECC_MODE_4), NFC_CONFIG2); \ ++ } \ ++} while (0) ++ ++#define WRITE_NFC_IP_REG(val,reg) \ ++ do { \ ++ nfc_write_reg(mxc_nand_data, NFC_IPC_CREQ, NFC_IPC); \ ++ while (!(nfc_read_reg(mxc_nand_data, NFC_IPC) & NFC_IPC_ACK)); \ ++ nfc_write_reg(mxc_nand_data, val, reg); \ ++ nfc_write_reg(mxc_nand_data, 0, NFC_IPC); \ ++ } while(0) ++#else ++#define IS_4BIT_ECC 1 ++#define NFC_SET_SPAS(v) ++#define NFC_SET_ECC_MODE(v) ++#define NFC_SET_NFMS(v) (NFMS |= (v)) ++ ++#define WRITE_NFC_IP_REG(val,reg) \ ++ nfc_write_reg(mxc_nand_data, val, REG_NFC_OPS_STAT) ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V3_1 */ ++ ++#define GET_NFC_ECC_STATUS() nfc_read_reg(mxc_nand_data, REG_NFC_ECC_STATUS_RESULT); ++ ++/*! ++ * Set 1 to specific operation bit, rest to 0 in LAUNCH_NFC Register for ++ * Specific operation ++ */ ++#define NFC_CMD 0x1 ++#define NFC_ADDR 0x2 ++#define NFC_INPUT 0x4 ++#define NFC_OUTPUT 0x8 ++#define NFC_ID 0x10 ++#define NFC_STATUS 0x20 ++ ++#ifdef CONFIG_ARCH_MXC_HAS_NFC_V3_2 /* mx51 */ ++#define NFC_AUTO_PROG 0x40 ++#define NFC_AUTO_READ 0x80 ++#define NFC_AUTO_ERASE 0x200 ++#define NFC_COPY_BACK_0 0x400 ++#define NFC_COPY_BACK_1 0x800 ++#define NFC_AUTO_STATE 0x1000 ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V3_2 */ ++ ++/* Bit Definitions for NFC_IPC*/ ++#define NFC_OPS_STAT (1 << 31) ++ ++#ifdef CONFIG_ARCH_MXC_HAS_NFC_V3_2 /* mx51 */ ++#define NFC_OP_DONE (1 << 30) ++#define NFC_RB (1 << 28) ++#define NFC_PS_WIDTH 2 ++#define NFC_PS_SHIFT 0 ++#define NFC_PS_512 0 ++#define NFC_PS_2K 1 ++#define NFC_PS_4K 2 ++#else ++#define NFC_RB (1 << 29) ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V3_2 */ ++ ++#define NFC_ONE_CYCLE (1 << 2) ++ ++#ifdef CONFIG_ARCH_MXC_HAS_NFC_V3_2 /* mx51 */ ++#define NFC_INT_MSK (1 << 15) ++#define NFC_AUTO_PROG_DONE_MSK (1 << 14) ++#define NFC_NUM_ADDR_PHASE1_WIDTH 2 ++#define NFC_NUM_ADDR_PHASE1_SHIFT 12 ++ ++#define NFC_NUM_ADDR_PHASE0_WIDTH 1 ++#define NFC_NUM_ADDR_PHASE0_SHIFT 5 ++ ++#define NFC_ONE_LESS_PHASE1 0 ++#define NFC_TWO_LESS_PHASE1 1 ++ ++#define NFC_FLASH_ADDR_SHIFT 0 ++#else ++#define NFC_INT_MSK (1 << 4) ++#define NFC_BIG (1 << 5) ++#define NFC_FLASH_ADDR_SHIFT 16 ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V3_2 */ ++ ++#define NFC_UNLOCK_END_ADDR_SHIFT 16 ++ ++/* Bit definition for NFC_CONFIGRATION_1 */ ++#define NFC_SP_EN (1 << 0) ++#define NFC_CE (1 << 1) ++#define NFC_RST (1 << 2) ++#define NFC_ECC_EN (1 << 3) ++ ++#define NFC_FIELD_RESET(width, shift) ~(((1 << (width)) - 1) << (shift)) ++ ++#define NFC_RBA_SHIFT 4 ++ ++#if defined(CONFIG_ARCH_MXC_HAS_NFC_V3_1) || \ ++ defined(CONFIG_ARCH_MXC_HAS_NFC_V3_2) /* mx51 */ ++#define NFC_RBA_WIDTH 3 ++#else ++#define NFC_RBA_WIDTH 2 ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V3_1 */ ++ ++#if defined(CONFIG_ARCH_MXC_HAS_NFC_V3_2) /* mx51 */ ++#define NFC_ITERATION_SHIFT 8 ++#define NFC_ITERATION_WIDTH 4 ++#define NFC_ACTIVE_CS_SHIFT 12 ++#define NFC_ACTIVE_CS_WIDTH 3 ++/* bit definition for CONFIGRATION3 */ ++#define NFC_NO_SDMA (1 << 20) ++#define NFC_FMP_SHIFT 16 ++#define NFC_FMP_WIDTH 4 ++#define NFC_RBB_MODE (1 << 15) ++#define NFC_NUM_OF_DEVICES_SHIFT 12 ++#define NFC_NUM_OF_DEVICES_WIDTH 4 ++#define NFC_DMA_MODE_SHIFT 11 ++#define NFC_DMA_MODE_WIDTH 1 ++#define NFC_SBB_SHIFT 8 ++#define NFC_SBB_WIDTH 3 ++#define NFC_BIG (1 << 7) ++#define NFC_SB2R_SHIFT 4 ++#define NFC_SB2R_WIDTH 3 ++#define NFC_FW_SHIFT 3 ++#define NFC_FW_WIDTH 1 ++#define NFC_TOO (1 << 2) ++#define NFC_ADD_OP_SHIFT 0 ++#define NFC_ADD_OP_WIDTH 2 ++#define NFC_FW_8 1 ++#define NFC_FW_16 0 ++#define NFC_ST_CMD_SHITF 24 ++#define NFC_ST_CMD_WIDTH 8 ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V3_2 */ ++ ++#define NFC_PPB_32 (0 << 7) ++#define NFC_PPB_64 (1 << 7) ++#define NFC_PPB_128 (2 << 7) ++#define NFC_PPB_256 (3 << 7) ++#define NFC_PPB_RESET ~(3 << 7) ++ ++#define NFC_BLS_LOCKED (0 << 16) ++#define NFC_BLS_LOCKED_DEFAULT (1 << 16) ++#define NFC_BLS_UNLOCKED (2 << 16) ++#define NFC_BLS_RESET ~(3 << 16) ++#define NFC_WPC_LOCK_TIGHT 1 ++#define NFC_WPC_LOCK (1 << 1) ++#define NFC_WPC_UNLOCK (1 << 2) ++#define NFC_WPC_RESET ~7 ++#if defined(CONFIG_ARCH_MXC_HAS_NFC_V3_1) || \ ++ defined(CONFIG_ARCH_MXC_HAS_NFC_V3_2) ++#define NFC_ECC_MODE_4 (1 << 6) ++#define NFC_ECC_MODE_MASK ~(1 << 6) ++#define NFC_SPAS_16 8 ++#define NFC_SPAS_64 32 ++#define NFC_SPAS_128 64 ++#define NFC_SPAS_112 56 ++#define NFC_SPAS_218 109 ++#define NFC_IPC_CREQ (1 << 0) ++#define NFC_IPC_ACK (1 << 1) ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V3_1 */ ++ ++#define REG_NFC_OPS_STAT NFC_IPC ++#define REG_NFC_INTERRUPT NFC_CONFIG2 ++#ifdef CONFIG_ARCH_MXC_HAS_NFC_V3_2 ++#define REG_NFC_FLASH_ADDR NFC_FLASH_ADDR0 ++#define REG_NFC_FLASH_CMD NFC_FLASH_CMD ++#else ++#define REG_NFC_FLASH_ADDR NFC_FLASH_ADDR_CMD ++#define REG_NFC_FLASH_CMD NFC_FLASH_ADDR_CMD ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V3_2 */ ++#define REG_NFC_OPS LAUNCH_NFC ++#define REG_NFC_SET_RBA NFC_CONFIG1 ++#define REG_NFC_RB NFC_IPC ++#define REG_NFC_ECC_EN NFC_CONFIG2 ++#define REG_NFC_ECC_STATUS_RESULT NFC_ECC_STATUS_RESULT ++#define REG_NFC_CE NFC_CONFIG1 ++#define REG_NFC_RST NFC_CONFIG1 ++#define REG_NFC_PPB NFC_CONFIG2 ++#define REG_NFC_SP_EN NFC_CONFIG1 ++#define REG_NFC_BLS NFC_WRPROT ++#define REG_UNLOCK_BLK_ADD0 NFC_WRPROT_UNLOCK_BLK_ADD0 ++#define REG_UNLOCK_BLK_ADD1 NFC_WRPROT_UNLOCK_BLK_ADD1 ++#define REG_UNLOCK_BLK_ADD2 NFC_WRPROT_UNLOCK_BLK_ADD2 ++#define REG_UNLOCK_BLK_ADD3 NFC_WRPROT_UNLOCK_BLK_ADD3 ++#define REG_NFC_WPC NFC_WRPROT ++#define REG_NFC_ONE_CYCLE NFC_CONFIG2 ++ ++/* NFC V3 Specific MACRO function definitions */ ++#define raw_write(v,a) __raw_writel(v,a) ++#define raw_read(a) __raw_readl(a) ++ ++/* Explicitly ack ops status (if any), before issuing any command */ ++#define ACK_OPS \ ++ nfc_write_reg(mxc_nand_data, \ ++ (nfc_read_reg(mxc_nand_data, REG_NFC_OPS_STAT) & ~NFC_OPS_STAT), \ ++ REG_NFC_OPS_STAT) ++ ++/* Set RBA buffer id*/ ++#define NFC_SET_RBA(val) \ ++ nfc_write_reg(mxc_nand_data, \ ++ (nfc_read_reg(mxc_nand_data, REG_NFC_SET_RBA) & \ ++ (NFC_FIELD_RESET(NFC_RBA_WIDTH, NFC_RBA_SHIFT))) | \ ++ ((val) << NFC_RBA_SHIFT), REG_NFC_SET_RBA) ++ ++#define NFC_SET_PS(val) \ ++ nfc_write_reg(mxc_nand_data, \ ++ (nfc_read_reg(mxc_nand_data, NFC_CONFIG2) & \ ++ (NFC_FIELD_RESET(NFC_PS_WIDTH, NFC_PS_SHIFT))) | \ ++ ((val) << NFC_PS_SHIFT), NFC_CONFIG2) ++ ++#ifdef CONFIG_ARCH_MXC_HAS_NFC_V3_2 ++#define UNLOCK_ADDR(start_addr,end_addr) \ ++{ \ ++ int i = 0; \ ++ for (; i < NAND_MAX_CHIPS; i++) \ ++ nfc_write_reg(mxc_nand_data, start_addr | \ ++ (end_addr << NFC_UNLOCK_END_ADDR_SHIFT), \ ++ REG_UNLOCK_BLK_ADD0 + (i << 2)); \ ++} ++ ++#define NFC_SET_NFC_ACTIVE_CS(val) \ ++ nfc_write_reg(mxc_nand_data, (nfc_read_reg(mxc_nand_data, NFC_CONFIG1) & \ ++ (NFC_FIELD_RESET(NFC_ACTIVE_CS_WIDTH, NFC_ACTIVE_CS_SHIFT))) | \ ++ ((val) << NFC_ACTIVE_CS_SHIFT), NFC_CONFIG1) ++ ++#define NFC_GET_MAXCHIP_SP() 8 ++ ++#else ++#define UNLOCK_ADDR(start_addr,end_addr) \ ++ nfc_write_reg(mxc_nand_data, start_addr | \ ++ (end_addr << NFC_UNLOCK_END_ADDR_SHIFT), REG_UNLOCK_BLK_ADD0) ++ ++#define NFC_SET_NFC_ACTIVE_CS(val) ++#define NFC_GET_MAXCHIP_SP() 1 ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V3_2 */ ++ ++#define NFC_SET_BLS(val) ((nfc_read_reg(mxc_nand_data, REG_NFC_BLS) & NFC_BLS_RESET) | val) ++#define NFC_SET_WPC(val) ((nfc_read_reg(mxc_nand_data, REG_NFC_WPC) & NFC_WPC_RESET) | val) ++#define CHECK_NFC_RB nfc_read_reg(mxc_nand_data, REG_NFC_RB) & NFC_RB ++ ++#if defined(CONFIG_ARCH_MXC_HAS_NFC_V3_2) ++#define NFC_SET_NFC_NUM_ADDR_PHASE1(val) \ ++ nfc_write_reg(mxc_nand_data, (nfc_read_reg(mxc_nand_data, NFC_CONFIG2) & \ ++ (NFC_FIELD_RESET(NFC_NUM_ADDR_PHASE1_WIDTH, \ ++ NFC_NUM_ADDR_PHASE1_SHIFT))) | \ ++ ((val) << NFC_NUM_ADDR_PHASE1_SHIFT), NFC_CONFIG2); ++ ++#define NFC_SET_NFC_NUM_ADDR_PHASE0(val) \ ++ nfc_write_reg(mxc_nand_data, (nfc_read_reg(mxc_nand_data, NFC_CONFIG2) & \ ++ (NFC_FIELD_RESET(NFC_NUM_ADDR_PHASE0_WIDTH, \ ++ NFC_NUM_ADDR_PHASE0_SHIFT))) | \ ++ ((val) << NFC_NUM_ADDR_PHASE0_SHIFT), NFC_CONFIG2); ++ ++#define NFC_SET_NFC_ITERATION(val) \ ++ nfc_write_reg(mxc_nand_data, (nfc_read_reg(mxc_nand_data, NFC_CONFIG1) & \ ++ (NFC_FIELD_RESET(NFC_ITERATION_WIDTH, NFC_ITERATION_SHIFT))) | \ ++ ((val) << NFC_ITERATION_SHIFT), NFC_CONFIG1); ++ ++#define NFC_SET_FW(val) \ ++ nfc_write_reg(mxc_nand_data, (nfc_read_reg(mxc_nand_data, NFC_CONFIG3) & \ ++ (NFC_FIELD_RESET(NFC_FW_WIDTH, NFC_FW_SHIFT))) | \ ++ ((val) << NFC_FW_SHIFT), NFC_CONFIG3); ++ ++#define NFC_SET_NUM_OF_DEVICE(val) \ ++ nfc_write_reg(mxc_nand_data, (nfc_read_reg(mxc_nand_data, NFC_CONFIG3) & \ ++ (NFC_FIELD_RESET(NFC_NUM_OF_DEVICES_WIDTH, \ ++ NFC_NUM_OF_DEVICES_SHIFT))) | \ ++ ((val) << NFC_NUM_OF_DEVICES_SHIFT), NFC_CONFIG3); ++ ++#define NFC_SET_ADD_OP_MODE(val) \ ++ nfc_write_reg(mxc_nand_data, (nfc_read_reg(mxc_nand_data, NFC_CONFIG3) & \ ++ (NFC_FIELD_RESET(NFC_ADD_OP_WIDTH, NFC_ADD_OP_SHIFT))) | \ ++ ((val) << NFC_ADD_OP_SHIFT), NFC_CONFIG3); ++ ++#define NFC_SET_ADD_CS_MODE(val) \ ++{ \ ++ NFC_SET_ADD_OP_MODE(val); \ ++ NFC_SET_NUM_OF_DEVICE(this->numchips - 1); \ ++} ++ ++#define NFC_SET_ST_CMD(val) \ ++ nfc_write_reg((raw_read(NFC_CONFIG2) & \ ++ (NFC_FIELD_RESET(NFC_ST_CMD_WIDTH, \ ++ NFC_ST_CMD_SHITF))) | \ ++ ((val) << NFC_ST_CMD_SHITF), NFC_CONFIG2); ++ ++#define NFMS_NF_DWIDTH 0 ++#define NFMS_NF_PG_SZ 1 ++#define NFC_CMD_1_SHIFT 8 ++ ++#define NUM_OF_ADDR_CYCLE (fls(g_page_mask) >> 3) ++ ++/*should set the fw,ps,spas,ppb*/ ++#define NFC_SET_NFMS(v) \ ++do { \ ++ NFC_SET_FW(NFC_FW_8); \ ++ if (((v) & (1 << NFMS_NF_DWIDTH))) \ ++ NFC_SET_FW(NFC_FW_16); \ ++ if (((v) & (1 << NFMS_NF_PG_SZ))) { \ ++ if (IS_2K_PAGE_NAND) { \ ++ NFC_SET_PS(NFC_PS_2K); \ ++ NFC_SET_NFC_NUM_ADDR_PHASE1(NUM_OF_ADDR_CYCLE); \ ++ NFC_SET_NFC_NUM_ADDR_PHASE0(NFC_TWO_LESS_PHASE1); \ ++ } else if (IS_4K_PAGE_NAND) { \ ++ NFC_SET_PS(NFC_PS_4K); \ ++ NFC_SET_NFC_NUM_ADDR_PHASE1(NUM_OF_ADDR_CYCLE); \ ++ NFC_SET_NFC_NUM_ADDR_PHASE0(NFC_TWO_LESS_PHASE1); \ ++ } else { \ ++ NFC_SET_PS(NFC_PS_512); \ ++ NFC_SET_NFC_NUM_ADDR_PHASE1(NUM_OF_ADDR_CYCLE - 1); \ ++ NFC_SET_NFC_NUM_ADDR_PHASE0(NFC_ONE_LESS_PHASE1); \ ++ } \ ++ NFC_SET_ADD_CS_MODE(1); \ ++ NFC_SET_SPAS(GET_NAND_OOB_SIZE >> 1); \ ++ NFC_SET_ECC_MODE(GET_NAND_OOB_SIZE >> 1); \ ++ NFC_SET_ST_CMD(0x70); \ ++ nfc_write_reg(raw_read(NFC_CONFIG3) | 1 << 20, NFC_CONFIG3); \ ++ } \ ++} while (0) ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V3_2 */ ++ ++#ifdef CONFIG_ARCH_MXC_HAS_NFC_V3_1 ++#define NFC_SET_NFMS(v) ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V3_1 */ ++ ++#define READ_PAGE(c) send_read_page(c,0) ++#define PROG_PAGE(c) send_prog_page(c,0) ++ ++#elif CONFIG_ARCH_MXC_HAS_NFC_V2 ++ ++/* ++ * For V1/V2 NFC registers Definition ++ */ ++ ++#define NFC_AXI_BASE_ADDR 0x00 ++/* ++ * Addresses for NFC registers ++ */ ++#ifdef CONFIG_ARCH_MXC_HAS_NFC_V2_1 ++#define NFC_REG_BASE 0x1000 ++#else ++#define NFC_REG_BASE 0x0000 ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V2_1 */ ++#define NFC_BUF_SIZE (NFC_REG_BASE + 0xE00) ++#define NFC_BUF_ADDR (NFC_REG_BASE + 0xE04) ++#define NFC_FLASH_ADDR (NFC_REG_BASE + 0xE06) ++#define NFC_FLASH_CMD (NFC_REG_BASE + 0xE08) ++#define NFC_CONFIG (NFC_REG_BASE + 0xE0A) ++#ifdef CONFIG_ARCH_MXC_HAS_NFC_V2_1 ++#define NFC_ECC_STATUS_RESULT (NFC_REG_BASE + 0xE0C) ++#define NFC_ECC_STATUS_RESULT_1 (NFC_REG_BASE + 0xE0C) ++#define NFC_ECC_STATUS_RESULT_2 (NFC_REG_BASE + 0xE0E) ++#define NFC_SPAS (NFC_REG_BASE + 0xE10) ++#else ++#define NFC_ECC_STATUS_RESULT (NFC_REG_BASE + 0xE0C) ++#define NFC_RSLTMAIN_AREA (NFC_REG_BASE + 0xE0E) ++#define NFC_RSLTSPARE_AREA (NFC_REG_BASE + 0xE10) ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V2_1 */ ++#define NFC_WRPROT (NFC_REG_BASE + 0xE12) ++#ifdef CONFIG_ARCH_MXC_HAS_NFC_V2_1 ++#define NFC_UNLOCKSTART_BLKADDR (NFC_REG_BASE + 0xE20) ++#define NFC_UNLOCKEND_BLKADDR (NFC_REG_BASE + 0xE22) ++#define NFC_UNLOCKSTART_BLKADDR1 (NFC_REG_BASE + 0xE24) ++#define NFC_UNLOCKEND_BLKADDR1 (NFC_REG_BASE + 0xE26) ++#define NFC_UNLOCKSTART_BLKADDR2 (NFC_REG_BASE + 0xE28) ++#define NFC_UNLOCKEND_BLKADDR2 (NFC_REG_BASE + 0xE2A) ++#define NFC_UNLOCKSTART_BLKADDR3 (NFC_REG_BASE + 0xE2C) ++#define NFC_UNLOCKEND_BLKADDR3 (NFC_REG_BASE + 0xE2E) ++#else ++#define NFC_UNLOCKSTART_BLKADDR (NFC_REG_BASE + 0xE14) ++#define NFC_UNLOCKEND_BLKADDR (NFC_REG_BASE + 0xE16) ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V2_1 */ ++#define NFC_NF_WRPRST (NFC_REG_BASE + 0xE18) ++#define NFC_CONFIG1 (NFC_REG_BASE + 0xE1A) ++#define NFC_CONFIG2 (NFC_REG_BASE + 0xE1C) ++ ++/*! ++ * Addresses for NFC RAM BUFFER Main area 0 ++ */ ++#define MAIN_AREA0 0x000 ++#define MAIN_AREA1 0x200 ++ ++/*! ++ * Addresses for NFC SPARE BUFFER Spare area 0 ++ */ ++#ifdef CONFIG_ARCH_MXC_HAS_NFC_V2_1 ++#define SPARE_AREA0 0x1000 ++#define SPARE_LEN 64 ++#define SPARE_COUNT 8 ++#else ++#define SPARE_AREA0 0x800 ++#define SPARE_LEN 16 ++#define SPARE_COUNT 4 ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V2_1 */ ++#define SPARE_SIZE (SPARE_LEN * SPARE_COUNT) ++ ++#ifdef CONFIG_ARCH_MXC_HAS_NFC_V2_1 ++#define REG_NFC_ECC_MODE NFC_CONFIG1 ++#define SPAS_SHIFT 0 ++#define REG_NFC_SPAS NFC_SPAS ++#define SPAS_MASK 0xFF00 ++#define IS_4BIT_ECC \ ++ (!!(nfc_read_reg(mxc_nand_data, REG_NFC_ECC_MODE) & NFC_ECC_MODE_4)) ++ ++#define NFC_SET_SPAS(v) \ ++ nfc_write_reg(mxc_nand_data, \ ++ ((nfc_read_reg(mxc_nand_data, REG_NFC_SPAS) & SPAS_MASK) | \ ++ (((v) << SPAS_SHIFT))), \ ++ REG_NFC_SPAS) ++ ++#define NFC_SET_ECC_MODE(v) \ ++do { \ ++ if ((v) == NFC_SPAS_218) { \ ++ nfc_write_reg(mxc_nand_data, \ ++ (nfc_read_reg(mxc_nand_data, REG_NFC_ECC_MODE) & ~NFC_ECC_MODE_4),\ ++ REG_NFC_ECC_MODE); \ ++ } else { \ ++ nfc_write_reg(mxc_nand_data, \ ++ (nfc_read_reg(mxc_nand_data, REG_NFC_ECC_MODE) | NFC_ECC_MODE_4), \ ++ REG_NFC_ECC_MODE); \ ++ } \ ++} while (0) ++ ++#define NFC_SET_NFMS(v) \ ++do { \ ++ DBG(0, "Setting NFMS[%p:%08lx] to %08x | %08x\n", NFMS_REG, \ ++ MXC_PHYS_ADDRESS(NFMS_REG), __raw_readl(NFMS_REG), v); \ ++ __raw_writel(__raw_readl(NFMS_REG) | (v), NFMS_REG); \ ++ if (((v) & (1 << NFMS_NF_PG_SZ))) { \ ++ NFC_SET_SPAS(GET_NAND_OOB_SIZE >> 1); \ ++ NFC_SET_ECC_MODE(GET_NAND_OOB_SIZE >> 1); \ ++ } \ ++} while (0) ++#else ++#define IS_4BIT_ECC 1 ++#define NFC_SET_SPAS(v) ++#define NFC_SET_ECC_MODE(v) ++#define NFC_SET_NFMS(v) (NFMS |= (v)) ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V2_1 */ ++ ++#define WRITE_NFC_IP_REG(val,reg) \ ++ nfc_write_reg(mxc_nand_data, val, REG_NFC_OPS_STAT) ++ ++#define GET_NFC_ECC_STATUS() nfc_read_reg(mxc_nand_data, REG_NFC_ECC_STATUS_RESULT) ++ ++/*! ++ * Set INT to 0, Set 1 to specific operation bit, rest to 0 in NFC_CONFIG2 Register for ++ * Specific operation ++ */ ++#define NFC_CMD 0x1 ++#define NFC_ADDR 0x2 ++#define NFC_INPUT 0x4 ++#define NFC_OUTPUT 0x8 ++#define NFC_ID 0x10 ++#define NFC_STATUS 0x20 ++ ++/* Bit Definitions */ ++#define NFC_OPS_STAT (1 << 15) ++#define NFC_SP_EN (1 << 2) ++#define NFC_ECC_EN (1 << 3) ++#define NFC_INT_MSK (1 << 4) ++#define NFC_BIG (1 << 5) ++#define NFC_RST (1 << 6) ++#define NFC_CE (1 << 7) ++#define NFC_ONE_CYCLE (1 << 8) ++#define NFC_BLS_LOCKED 0 ++#define NFC_BLS_LOCKED_DEFAULT 1 ++#define NFC_BLS_UNLOCKED 2 ++#define NFC_WPC_LOCK_TIGHT (1 << 0) ++#define NFC_WPC_LOCK (1 << 1) ++#define NFC_WPC_UNLOCK (1 << 2) ++#define NFC_FLASH_ADDR_SHIFT 0 ++#define NFC_UNLOCK_END_ADDR_SHIFT 0 ++ ++#ifdef CONFIG_ARCH_MXC_HAS_NFC_V2_1 ++#define NFC_ECC_MODE_4 (1 << 0) ++#define NFC_SPAS_16 8 ++#define NFC_SPAS_64 32 ++#define NFC_SPAS_112 56 ++#define NFC_SPAS_128 64 ++#define NFC_SPAS_218 109 ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V2_1 */ ++/* NFC Register Mapping */ ++#define REG_NFC_OPS_STAT NFC_CONFIG2 ++#define REG_NFC_INTERRUPT NFC_CONFIG1 ++#define REG_NFC_FLASH_ADDR NFC_FLASH_ADDR ++#define REG_NFC_FLASH_CMD NFC_FLASH_CMD ++#define REG_NFC_OPS NFC_CONFIG2 ++#define REG_NFC_SET_RBA NFC_BUF_ADDR ++#define REG_NFC_ECC_EN NFC_CONFIG1 ++#define REG_NFC_ECC_STATUS_RESULT NFC_ECC_STATUS_RESULT ++#define REG_NFC_CE NFC_CONFIG1 ++#define REG_NFC_SP_EN NFC_CONFIG1 ++#define REG_NFC_BLS NFC_CONFIG ++#define REG_NFC_WPC NFC_WRPROT ++#define REG_START_BLKADDR NFC_UNLOCKSTART_BLKADDR ++#define REG_END_BLKADDR NFC_UNLOCKEND_BLKADDR ++#define REG_NFC_RST NFC_CONFIG1 ++#define REG_NFC_ONE_CYCLE NFC_CONFIG1 ++ ++/* NFC V1/V2 Specific MACRO functions definitions */ ++ ++#if defined(CONFIG_MTD_DEBUG) ++#define nfc_write_reg(c, v, r) __nfc_reg_write(v, (c)->reg_base + r, #r, __FUNCTION__) ++static inline void __nfc_reg_write(u16 val, void __iomem *addr, ++ const char *reg, const char *fn) ++{ ++ DBG(3, "%s: Writing %04x to %s[%04lx]\n", fn, val, reg, ++ (unsigned long)addr & 0x1fff); ++ __raw_writew(val, addr); ++} ++ ++#define nfc_read_reg(c, r) __nfc_reg_read((c)->reg_base + r, #r, __FUNCTION__) ++static inline u16 __nfc_reg_read(void __iomem *addr, ++ const char *reg, const char *fn) ++{ ++ u16 val; ++ val = __raw_readw(addr); ++ DBG(3, "%s: Read %04x from %s[%04lx]\n", fn, val, reg, ++ (unsigned long)addr & 0x1fff); ++ return val; ++} ++#else ++#define nfc_read_reg(c, r) __raw_readw((c)->reg_base + r) ++#define nfc_write_reg(c, v, r) __raw_writew(v, (c)->reg_base + r) ++#endif /* CONFIG_MTD_DEBUG */ ++ ++#define NFC_SET_BLS(val) (val) ++ ++#define UNLOCK_ADDR(start_addr,end_addr) \ ++{ \ ++ nfc_write_reg(mxc_nand_data, start_addr,REG_START_BLKADDR); \ ++ nfc_write_reg(mxc_nand_data, end_addr,REG_END_BLKADDR); \ ++} ++ ++#define NFC_SET_NFC_ACTIVE_CS(val) ++#define NFC_GET_MAXCHIP_SP() 1 ++#define NFC_SET_WPC(val) (val) ++ ++#define ACK_OPS ++#define NFC_SET_RBA(val) nfc_write_reg(mxc_nand_data, val, REG_NFC_SET_RBA); ++ ++#ifdef CONFIG_ARCH_MXC_HAS_NFC_V2_1 ++#define READ_PAGE(c) send_read_page(c,0) ++#define PROG_PAGE(c) send_prog_page(c,0) ++#else ++#define READ_PAGE(c) \ ++do { \ ++ send_read_page(c,0); \ ++ send_read_page(c,1); \ ++ send_read_page(c,2); \ ++ send_read_page(c,3); \ ++} while (0) ++ ++#define PROG_PAGE(c) \ ++do { \ ++ send_prog_page(c,0); \ ++ send_prog_page(c,1); \ ++ send_prog_page(c,2); \ ++ send_prog_page(c,3); \ ++} while (0) ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V2_1 */ ++#define CHECK_NFC_RB 1 ++ ++#endif /* CONFIG_ARCH_MXC_HAS_NFC_V3 */ ++ ++#endif /* __MXC_ND2_H__ */ +diff -urNp linux-2.6.30-rc4/drivers/net/Kconfig linux-2.6.30-rc4-karo/drivers/net/Kconfig +--- linux-2.6.30-rc4/drivers/net/Kconfig 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/drivers/net/Kconfig 2009-06-02 17:05:27.000000000 +0200 +@@ -1859,7 +1859,7 @@ config 68360_ENET + + config FEC + bool "FEC ethernet controller (of ColdFire CPUs)" +- depends on M523x || M527x || M5272 || M528x || M520x || M532x || MACH_MX27 ++ depends on M523x || M527x || M5272 || M528x || M520x || M532x || MACH_MX27 || MACH_TX25 + help + Say Y here if you want to use the built-in 10/100 Fast ethernet + controller on some Motorola ColdFire and Freescale i.MX processors. +diff -urNp linux-2.6.30-rc4/drivers/net/fec.c linux-2.6.30-rc4-karo/drivers/net/fec.c +--- linux-2.6.30-rc4/drivers/net/fec.c 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/drivers/net/fec.c 2009-06-02 17:05:27.000000000 +0200 +@@ -2,6 +2,12 @@ + * Fast Ethernet Controller (FEC) driver for Motorola MPC8xx. + * Copyright (c) 1997 Dan Malek (dmalek@jlc.net) + * ++ * This version of the driver is specific to the FADS implementation, ++ * since the board contains control registers external to the processor ++ * for the control of the LevelOne LXT970 transceiver. The MPC860T manual ++ * describes connections using the internal parallel port I/O, which ++ * is basically all of Port D. ++ * + * Right now, I am very wasteful with the buffers. I allocate memory + * pages and then divide them into 2K frame buffers. This way I know I + * have buffers large enough to hold one frame within one buffer descriptor. +@@ -18,77 +24,123 @@ + * Bug fixes and cleanup by Philippe De Muyter (phdm@macqel.be) + * Copyright (c) 2004-2006 Macq Electronique SA. + */ ++/* ++ * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved. ++ */ + + #include + #include +-#include +-#include ++#include + #include + #include + #include + #include +-#include +-#include ++#include + #include ++#include + #include + #include + #include + #include +-#include +-#include +-#include +-#include ++#include + #include +-#include ++#include ++#include + +-#include ++#include ++#include + +-#ifndef CONFIG_ARCH_MXC +-#include +-#include ++#define DRV_NAME "fec" ++#define DEBUG ++ ++#ifdef DEBUG ++static int debug = 0; ++#define dbg_lvl(n) ((n) < debug) ++module_param(debug, int, S_IRUGO | S_IWUSR); ++ ++#define DBG(lvl, fmt...) do { if (dbg_lvl(lvl)) printk(KERN_DEBUG fmt); } while (0) ++#else ++static int debug; ++#define dbg_lvl(n) 0 ++module_param(debug, int, 0); ++ ++#define DBG(lvl, fmt...) do { } while (0) + #endif + ++#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || \ ++ defined(CONFIG_M5272) || defined(CONFIG_M528x) || \ ++ defined(CONFIG_M520x) || defined(CONFIG_M532x) ++#include ++#include + #include "fec.h" +- +-#ifdef CONFIG_ARCH_MXC ++#define FEC_ALIGNMENT (0x03) /*FEC needs 4bytes alignment*/ ++#elif defined(CONFIG_ARCH_MXC) + #include +-#define FEC_ALIGNMENT 0xf ++#include ++#include "fec.h" ++#define FEC_ALIGNMENT (0x0F) /*FEC needs 128bits(16bytes) alignment*/ + #else +-#define FEC_ALIGNMENT 0x3 ++#include ++#include ++#include "commproc.h" ++#define FEC_ALIGNMENT (0x03) /*FEC needs 4bytes alignment */ + #endif + ++#define FEC_ADDR_ALIGNMENT(x) ((unsigned char *)(((unsigned long)(x) + (FEC_ALIGNMENT)) & (~FEC_ALIGNMENT))) ++ ++#if 0 + /* + * Define the fixed address of the FEC hardware. + */ ++/* USE resources provided by platform_device! */ ++static unsigned int fec_hw[] = { + #if defined(CONFIG_M5272) +-#define HAVE_mii_link_interrupt +- +-static unsigned char fec_mac_default[] = { +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ (MCF_MBAR + 0x840), ++#elif defined(CONFIG_M527x) ++ (MCF_MBAR + 0x1000), ++ (MCF_MBAR + 0x1800), ++#elif defined(CONFIG_M523x) || defined(CONFIG_M528x) ++ (MCF_MBAR + 0x1000), ++#elif defined(CONFIG_M520x) ++ (MCF_MBAR+0x30000), ++#elif defined(CONFIG_M532x) ++ (MCF_MBAR+0xfc030000), ++#elif defined(CONFIG_ARCH_MXC) ++ (IO_ADDRESS(FEC_BASE_ADDR)), ++#else ++ &(((immap_t *)IMAP_ADDR)->im_cpm.cp_fec), ++#endif + }; ++#endif + ++#if 0 + /* + * Some hardware gets it MAC address out of local flash memory. + * if this is non-zero then assume it is the address to get MAC from. + */ ++/* implemented using platform_data! */ + #if defined(CONFIG_NETtel) + #define FEC_FLASHMAC 0xf0006006 + #elif defined(CONFIG_GILBARCONAP) || defined(CONFIG_SCALES) + #define FEC_FLASHMAC 0xf0006000 ++#elif defined (CONFIG_MTD_KeyTechnology) ++#define FEC_FLASHMAC 0xffe04000 + #elif defined(CONFIG_CANCam) + #define FEC_FLASHMAC 0xf0020000 + #elif defined (CONFIG_M5272C3) + #define FEC_FLASHMAC (0xffe04000 + 4) + #elif defined(CONFIG_MOD5272) +-#define FEC_FLASHMAC 0xffc0406b ++#define FEC_FLASHMAC 0xffc0406b + #else + #define FEC_FLASHMAC 0 + #endif +-#endif /* CONFIG_M5272 */ ++#endif ++ ++#define platform_func(p, args...) ((p) ? (p)(args) : 0) + + /* Forward declarations of some structures to support different PHYs + */ +- ++#ifndef CONFIG_PHYLIB + typedef struct { + uint mii_data; + void (*funct)(uint mii_reg, struct net_device *dev); +@@ -103,6 +155,7 @@ typedef struct { + const phy_cmd_t *ack_int; + const phy_cmd_t *shutdown; + } phy_info_t; ++#endif + + /* The number of Tx and Rx buffers. These are allocated from the page + * pool. The code may assume these are power of two, so it it best +@@ -116,12 +169,13 @@ typedef struct { + #define RX_RING_SIZE (FEC_ENET_RX_FRPPG * FEC_ENET_RX_PAGES) + #define FEC_ENET_TX_FRSIZE 2048 + #define FEC_ENET_TX_FRPPG (PAGE_SIZE / FEC_ENET_TX_FRSIZE) +-#define TX_RING_SIZE 16 /* Must be power of two */ +-#define TX_RING_MOD_MASK 15 /* for this to work */ ++#define TX_RING_SIZE 16 /* Must be power of two */ ++#define TX_RING_MOD_MASK (TX_RING_SIZE - 1) /* for this to work */ + + #if (((RX_RING_SIZE + TX_RING_SIZE) * 8) > PAGE_SIZE) + #error "FEC: descriptor ring size constants too large" + #endif ++#define CBD_BUF_SIZE ((RX_RING_SIZE + TX_RING_SIZE) * sizeof(cbd_t)) + + /* Interrupt events/masks. + */ +@@ -136,6 +190,17 @@ typedef struct { + #define FEC_ENET_MII ((uint)0x00800000) /* MII interrupt */ + #define FEC_ENET_EBERR ((uint)0x00400000) /* SDMA bus error */ + ++/* MXC arch interrupt bits */ ++#define FEC_ENET_LC ((uint)0x00200000) /* Late collision */ ++#define FEC_ENET_RL ((uint)0x00100000) /* Collision retry limit exceeded */ ++#define FEC_ENET_UN ((uint)0x00080000) /* TX Fifo underrun */ ++ ++#ifndef CONFIG_ARCH_MXC ++#define FEC_ENET_MASK ((uint)0xffc00000) ++#else ++#define FEC_ENET_MASK ((uint)0xfff80000) ++#endif ++ + /* The FEC stores dest/src/type, data, and checksum for receive packets. + */ + #define PKT_MAXBUF_SIZE 1518 +@@ -150,7 +215,7 @@ typedef struct { + */ + #if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \ + defined(CONFIG_M520x) || defined(CONFIG_M532x) || defined(CONFIG_ARCH_MXC) +-#define OPT_FRAME_SIZE (PKT_MAXBUF_SIZE << 16) ++#define OPT_FRAME_SIZE (RCR_MAX_FL_set(PKT_MAXBUF_SIZE)) + #else + #define OPT_FRAME_SIZE 0 + #endif +@@ -165,31 +230,45 @@ typedef struct { + */ + struct fec_enet_private { + /* Hardware registers of the FEC device */ +- volatile fec_t *hwp; +- +- struct net_device *netdev; +- +- struct clk *clk; ++ void __iomem *reg_base; ++ void __iomem *mib_base; ++ struct resource *res_mem1; ++ struct resource *res_mem2; ++ int etn_irq; ++ int mii_irq; ++#ifndef CONFIG_PHYLIB ++ struct timer_list *phy_timer; ++#else ++ struct mii_bus *mii; ++ int mii_complete; ++#endif ++ u32 msg_enable; + + /* The saved address of a sent-in-place packet/buffer, for skfree(). */ +- unsigned char *tx_bounce[TX_RING_SIZE]; ++ void *tx_bounce[TX_RING_SIZE]; + struct sk_buff* tx_skbuff[TX_RING_SIZE]; ++ struct sk_buff* rx_skbuff[RX_RING_SIZE]; + ushort skb_cur; + ushort skb_dirty; + + /* CPM dual port RAM relative addresses. + */ +- dma_addr_t bd_dma; ++ struct device *dma_dev; /* pointer to (platform_)device for dma_sync*() functions */ ++ void *cbd_mem_base; /* save the virtual base address of rx&tx buffer descriptor */ ++ dma_addr_t cbd_phys_base; /* physical address of buffer descriptor memory for access by FEC HW */ ++ + cbd_t *rx_bd_base; /* Address of Rx and Tx buffers. */ + cbd_t *tx_bd_base; +- cbd_t *cur_rx, *cur_tx; /* The next free ring entry */ +- cbd_t *dirty_tx; /* The ring entries to be free()ed. */ ++ cbd_t *cur_rx, *cur_tx; /* The next free ring entry */ ++ cbd_t *dirty_tx; /* The ring entries to be free()ed. */ ++ struct net_device_stats stats; + uint tx_full; +- /* hold while accessing the HW like ringbuffer for tx/rx but not MAC */ +- spinlock_t hw_lock; +- /* hold while accessing the mii_list_t() elements */ +- spinlock_t mii_lock; ++ spinlock_t lock; + ++#ifdef CONFIG_PHYLIB ++ struct phy_device *phy; ++ uint phy_speed; ++#else + uint phy_id; + uint phy_id_done; + uint phy_status; +@@ -199,28 +278,41 @@ struct fec_enet_private { + + uint sequence_done; + uint mii_phy_task_queued; +- ++#endif + uint phy_addr; + +- int index; +- int opened; +- int link; +- int old_link; +- int full_duplex; ++ unsigned int opened:1; ++ unsigned int phy_int_enabled:1; ++ unsigned int linkstatus:1; ++#ifndef CONFIG_PHYLIB ++ unsigned int old_linkstatus:1; ++#endif ++ unsigned int full_duplex:1; ++ ++ struct clk *clk; + }; + +-static int fec_enet_open(struct net_device *dev); +-static int fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev); +-static void fec_enet_mii(struct net_device *dev); +-static irqreturn_t fec_enet_interrupt(int irq, void * dev_id); ++#ifdef CONFIG_PHYLIB ++static int fec_connect_phy(struct net_device *dev, struct fec_enet_private *fep); ++#else ++static irqreturn_t mii_link_interrupt(int irq, void *dev_id); ++#endif ++static void fec_restart(struct net_device *dev, int duplex); + static void fec_enet_tx(struct net_device *dev); + static void fec_enet_rx(struct net_device *dev); +-static int fec_enet_close(struct net_device *dev); +-static void set_multicast_list(struct net_device *dev); +-static void fec_restart(struct net_device *dev, int duplex); ++static void fec_enet_mii(struct net_device *dev); + static void fec_stop(struct net_device *dev); +-static void fec_set_mac_address(struct net_device *dev); ++static void _fec_set_mac_address(struct net_device *dev); + ++/* ++ * fec_copy_threshold controls the copy when receiving ethernet frame. ++ * If ethernet header is aligned on a 4byte boundary, the ip header and ++ * higher level header will not be aligned. ++ * The reason is, that an ethernet header is 14bytes long. ++ * And the max size of tcp & ip header is 128bytes. Normally it is 40bytes. ++ * So I set the default value between 128 to 256. ++ */ ++static int fec_copy_threshold = 192; + + /* MII processing. We keep this as simple as possible. Requests are + * placed on the list (if there is room). When the request is finished +@@ -232,14 +324,16 @@ typedef struct mii_list { + struct mii_list *mii_next; + } mii_list_t; + ++#ifndef CONFIG_PHYLIB + #define NMII 20 + static mii_list_t mii_cmds[NMII]; + static mii_list_t *mii_free; + static mii_list_t *mii_head; + static mii_list_t *mii_tail; + +-static int mii_queue(struct net_device *dev, int request, +- void (*func)(uint, struct net_device *)); ++static int mii_queue(struct net_device *dev, int request, ++ void (*func)(uint, struct net_device *)); ++#endif + + /* Make MII read/write commands for the FEC. + */ +@@ -284,87 +378,233 @@ static int mii_queue(struct net_device * + #define PHY_STAT_100HDX 0x4000 /* 100 Mbit half duplex selected */ + #define PHY_STAT_100FDX 0x8000 /* 100 Mbit full duplex selected */ + ++#ifndef DEBUG ++static inline unsigned long fec_reg_read(struct fec_enet_private *fep, unsigned int reg) ++{ ++ return readl(fep->reg_base + reg); ++} ++ ++static inline void fec_reg_write(struct fec_enet_private *fep, unsigned int reg, unsigned long val) ++{ ++ writel(val, fep->reg_base + reg); ++} ++#else ++#define fec_reg_read(fep, reg) __fec_reg_read(fep, reg, __FUNCTION__, #reg) ++#define fec_reg_write(fep, reg, val) __fec_reg_write(fep, reg, val, __FUNCTION__, #reg) ++ ++static inline unsigned long __fec_reg_read(struct fec_enet_private *fep, unsigned int reg, ++ const char *func, const char *reg_name) ++{ ++ unsigned long val = readl(fep->reg_base + reg); ++ DBG(3, "%s: Read %08lx from %s(%03x)\n", func, val, reg_name, reg); ++ return val; ++} ++ ++static inline void __fec_reg_write(struct fec_enet_private *fep, unsigned int reg, ++ unsigned long val, const char *func, const char *reg_name) ++{ ++ DBG(3, "%s: Writing %08lx to %s(%03x)\n", func, val, reg_name, reg); ++ writel(val, fep->reg_base + reg); ++} ++#endif ++ ++static inline void fec_enet_cbd_get(struct fec_enet_private *fep) ++{ ++ DBG(2, "%s: Requesting cbd area: %08lx\n", __FUNCTION__, ++ (unsigned long)fep->cbd_phys_base); ++ dma_sync_single_for_cpu(fep->dma_dev, fep->cbd_phys_base, ++ CBD_BUF_SIZE, DMA_BIDIRECTIONAL); ++} ++ ++static inline void fec_enet_cbd_put(struct fec_enet_private *fep) ++{ ++ DBG(2, "%s: Flushing changes to cbd area\n", __FUNCTION__); ++ dma_sync_single_for_device(fep->dma_dev, fep->cbd_phys_base, ++ CBD_BUF_SIZE, DMA_BIDIRECTIONAL); ++} ++ ++static inline void fec_enet_rxbuf_get(struct fec_enet_private *fep, cbd_t *bdp, ushort len) ++{ ++ DBG(2, "%s: Requesting RX buffer %08lx(%u)\n", __FUNCTION__, ++ (unsigned long)bdp->cbd_bufaddr, len); ++ dma_sync_single_for_cpu(fep->dma_dev, bdp->cbd_bufaddr, ++ len, DMA_FROM_DEVICE); ++} ++ ++static inline void fec_enet_rxbuf_put(struct fec_enet_private *fep, cbd_t *bdp, ushort len) ++{ ++ DBG(2, "%s: Releasing RX buffer %08lx(%u)\n", __FUNCTION__, (ulong)bdp->cbd_bufaddr, len); ++ dma_sync_single_for_device(fep->dma_dev, bdp->cbd_bufaddr, len, DMA_FROM_DEVICE); ++} ++ ++static inline void fec_enet_rxbuf_map(struct fec_enet_private *fep, cbd_t *bdp, ++ void *buf, ushort len) ++{ ++ BUG_ON(!dma_mapping_error(fep->dma_dev, bdp->cbd_bufaddr)); ++ bdp->cbd_bufaddr = dma_map_single(fep->dma_dev, buf, ++ len, DMA_FROM_DEVICE); ++ DBG(2, "%s: RX buffer %p(%u) mapped to %08lx\n", __FUNCTION__, ++ buf, len, (unsigned long)bdp->cbd_bufaddr); ++} ++ ++static inline void fec_enet_rxbuf_unmap(struct fec_enet_private *fep, cbd_t *bdp, ushort len) ++{ ++ DBG(2, "%s: Unmapping RX buffer %08lx(%u)\n", __FUNCTION__, ++ (unsigned long)bdp->cbd_bufaddr, len); ++ BUG_ON(dma_mapping_error(fep->dma_dev, bdp->cbd_bufaddr)); ++ dma_unmap_single(fep->dma_dev, bdp->cbd_bufaddr, ++ len, DMA_FROM_DEVICE); ++ bdp->cbd_bufaddr = ~0; ++} ++ ++static inline void fec_enet_txbuf_map(struct fec_enet_private *fep, cbd_t *bdp, ++ void *buf, ushort len) ++{ ++ BUG_ON(!dma_mapping_error(fep->dma_dev, bdp->cbd_bufaddr)); ++ bdp->cbd_bufaddr = dma_map_single(fep->dma_dev, buf, ++ len, DMA_TO_DEVICE); ++ DBG(2, "%s: TX buffer %p(%u) mapped to %08lx\n", __FUNCTION__, ++ buf, len, (unsigned long)bdp->cbd_bufaddr); ++} ++ ++static inline void fec_enet_txbuf_unmap(struct fec_enet_private *fep, cbd_t *bdp, ushort len) ++{ ++ DBG(2, "%s: Unmapping TX buffer %08lx(%u)\n", __FUNCTION__, ++ (unsigned long)bdp->cbd_bufaddr, len); ++ BUG_ON(dma_mapping_error(fep->dma_dev, bdp->cbd_bufaddr)); ++ dma_unmap_single(fep->dma_dev, bdp->cbd_bufaddr, ++ len, DMA_TO_DEVICE); ++ bdp->cbd_bufaddr = ~0; ++} ++ ++static inline void fec_enet_txbuf_get(struct fec_enet_private *fep, cbd_t *bdp, ushort len) ++{ ++ DBG(2, "%s: Requesting TX buffer %08lx(%u)\n", __FUNCTION__, ++ (unsigned long)bdp->cbd_bufaddr, len); ++ dma_sync_single_for_cpu(fep->dma_dev, bdp->cbd_bufaddr, ++ len, DMA_TO_DEVICE); ++} ++ ++static inline void fec_enet_txbuf_put(struct fec_enet_private *fep, cbd_t *bdp, ushort len) ++{ ++ DBG(2, "%s: Releasing TX buffer %08lx(%u)\n", __FUNCTION__, ++ (unsigned long)bdp->cbd_bufaddr, len); ++ dma_sync_single_for_device(fep->dma_dev, bdp->cbd_bufaddr, ++ len, DMA_TO_DEVICE); ++} ++ ++static void dump_packet(const char *prefix, const unsigned char *data, int len) ++{ ++ if (dbg_lvl(3)) { ++ print_hex_dump_bytes(prefix, DUMP_PREFIX_OFFSET, data, len); ++ } ++} ++ ++static void dump_tx_buffers(struct fec_enet_private *fep) ++{ ++ cbd_t *bdp = fep->tx_bd_base; ++ int i; ++ ++ printk(KERN_DEBUG "tx buffers: %u buffers\n", TX_RING_SIZE); ++ for (i = 0; i < TX_RING_SIZE; i++, bdp++) { ++ printk(KERN_DEBUG " %p: %04x %04x %08x\n", ++ bdp, ++ bdp->cbd_sc, ++ bdp->cbd_datlen, ++ bdp->cbd_bufaddr); ++ print_hex_dump_bytes("tx buffers:", DUMP_PREFIX_ADDRESS, bdp, sizeof(cbd_t)); ++ } ++} ++ ++static void dump_rx_buffers(struct fec_enet_private *fep) ++{ ++ cbd_t *bdp = fep->rx_bd_base; ++ int i; ++ ++ printk(KERN_DEBUG "rx buffers: %lu buffers\n", RX_RING_SIZE); ++ for (i = 0; i < RX_RING_SIZE; i++, bdp++) { ++ printk(KERN_DEBUG " %p: %04x %04x %08x\n", ++ bdp, ++ bdp->cbd_sc, ++ bdp->cbd_datlen, ++ bdp->cbd_bufaddr); ++ print_hex_dump_bytes("rx buffers:", DUMP_PREFIX_ADDRESS, bdp, sizeof(cbd_t)); ++ } ++} + + static int + fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) + { +- struct fec_enet_private *fep; +- volatile fec_t *fecp; +- volatile cbd_t *bdp; +- unsigned short status; ++ struct fec_enet_private *fep = netdev_priv(dev); ++ cbd_t *bdp; ++ unsigned short status; + unsigned long flags; + +- fep = netdev_priv(dev); +- fecp = (volatile fec_t*)dev->base_addr; +- +- if (!fep->link) { ++ if (!fep->linkstatus) { ++ DBG(0, "%s: Cannot send packet; link is down\n", __FUNCTION__); + /* Link is down or autonegotiation is in progress. */ + return 1; + } + +- spin_lock_irqsave(&fep->hw_lock, flags); ++ spin_lock_irqsave(&fep->lock, flags); ++ ++ //WARN_ON(fec_reg_read(fep, FEC_TDAR) & TDAR_BUSY); ++ fec_enet_cbd_get(fep); ++ + /* Fill in a Tx ring entry */ + bdp = fep->cur_tx; + + status = bdp->cbd_sc; +-#ifndef final_version ++#ifdef DEBUG + if (status & BD_ENET_TX_READY) { + /* Ooops. All transmit buffers are full. Bail out. + * This should not happen, since dev->tbusy should be set. + */ + printk("%s: tx queue full!.\n", dev->name); +- spin_unlock_irqrestore(&fep->hw_lock, flags); ++ fec_enet_cbd_put(fep); ++ spin_unlock_irqrestore(&fep->lock, flags); + return 1; + } + #endif +- + /* Clear all of the status flags. + */ + status &= ~BD_ENET_TX_STATS; + + /* Set buffer length and buffer pointer. + */ +- bdp->cbd_bufaddr = __pa(skb->data); + bdp->cbd_datlen = skb->len; + ++ dump_packet("sending packet:", skb->data, skb->len); + /* + * On some FEC implementations data must be aligned on + * 4-byte boundaries. Use bounce buffers to copy data + * and get it aligned. Ugh. + */ +- if (bdp->cbd_bufaddr & FEC_ALIGNMENT) { ++ if (unlikely((bdp->cbd_bufaddr) & FEC_ALIGNMENT)) { + unsigned int index; + index = bdp - fep->tx_bd_base; +- memcpy(fep->tx_bounce[index], (void *)skb->data, skb->len); +- bdp->cbd_bufaddr = __pa(fep->tx_bounce[index]); ++ memcpy(fep->tx_bounce[index], skb->data, skb->len); ++ fec_enet_txbuf_map(fep, bdp, fep->tx_bounce[index], skb->len); ++ } else { ++ fec_enet_txbuf_map(fep, bdp, skb->data, skb->len); + } + + /* Save skb pointer. + */ + fep->tx_skbuff[fep->skb_cur] = skb; + +- dev->stats.tx_bytes += skb->len; +- fep->skb_cur = (fep->skb_cur+1) & TX_RING_MOD_MASK; +- +- /* Push the data cache so the CPM does not get stale memory +- * data. +- */ +- dma_sync_single(NULL, bdp->cbd_bufaddr, +- bdp->cbd_datlen, DMA_TO_DEVICE); ++ fep->stats.tx_bytes += skb->len; ++ fep->skb_cur = (fep->skb_cur + 1) & TX_RING_MOD_MASK; + + /* Send it on its way. Tell FEC it's ready, interrupt when done, + * it's the last BD of the frame, and to put the CRC on the end. + */ +- + status |= (BD_ENET_TX_READY | BD_ENET_TX_INTR + | BD_ENET_TX_LAST | BD_ENET_TX_TC); + bdp->cbd_sc = status; + + dev->trans_start = jiffies; + +- /* Trigger transmission start */ +- fecp->fec_x_des_active = 0; +- + /* If this was the last BD in the ring, start at the beginning again. + */ + if (status & BD_ENET_TX_WRAP) { +@@ -375,12 +615,22 @@ fec_enet_start_xmit(struct sk_buff *skb, + + if (bdp == fep->dirty_tx) { + fep->tx_full = 1; ++ DBG(0, "TX ring full, stopping netif queue\n"); + netif_stop_queue(dev); + } + +- fep->cur_tx = (cbd_t *)bdp; ++ fep->cur_tx = bdp; ++ fec_enet_cbd_put(fep); ++#if 0 ++ if (dbg_lvl(3)) { ++ dump_tx_buffers(fep); ++ dump_rx_buffers(fep); ++ } ++#endif ++ /* Trigger transmission start */ ++ fec_reg_write(fep, FEC_TDAR, DONT_CARE); + +- spin_unlock_irqrestore(&fep->hw_lock, flags); ++ spin_unlock_irqrestore(&fep->lock, flags); + + return 0; + } +@@ -390,101 +640,126 @@ fec_timeout(struct net_device *dev) + { + struct fec_enet_private *fep = netdev_priv(dev); + +- printk("%s: transmit timed out.\n", dev->name); +- dev->stats.tx_errors++; +-#ifndef final_version ++ printk(KERN_WARNING "%s: transmit timed out.\n", dev->name); ++ fep->stats.tx_errors++; ++#ifdef DEBUG + { +- int i; +- cbd_t *bdp; ++ int i; ++ cbd_t *bdp; + +- printk("Ring data dump: cur_tx %lx%s, dirty_tx %lx cur_rx: %lx\n", +- (unsigned long)fep->cur_tx, fep->tx_full ? " (full)" : "", +- (unsigned long)fep->dirty_tx, +- (unsigned long)fep->cur_rx); ++ fec_enet_cbd_get(fep); + +- bdp = fep->tx_bd_base; +- printk(" tx: %u buffers\n", TX_RING_SIZE); +- for (i = 0 ; i < TX_RING_SIZE; i++) { +- printk(" %08x: %04x %04x %08x\n", +- (uint) bdp, +- bdp->cbd_sc, +- bdp->cbd_datlen, +- (int) bdp->cbd_bufaddr); +- bdp++; +- } ++ printk(KERN_DEBUG "%s: Ring data dump: cur_tx %p%s, dirty_tx %p cur_rx: %p\n", ++ __FUNCTION__, ++ fep->cur_tx, fep->tx_full ? " (full)" : "", ++ fep->dirty_tx, ++ fep->cur_rx); + +- bdp = fep->rx_bd_base; +- printk(" rx: %lu buffers\n", (unsigned long) RX_RING_SIZE); +- for (i = 0 ; i < RX_RING_SIZE; i++) { +- printk(" %08x: %04x %04x %08x\n", +- (uint) bdp, +- bdp->cbd_sc, +- bdp->cbd_datlen, +- (int) bdp->cbd_bufaddr); +- bdp++; +- } ++ bdp = fep->tx_bd_base; ++ printk(" tx: %u buffers\n", TX_RING_SIZE); ++ for (i = 0; i < TX_RING_SIZE; i++) { ++ printk(" %p: %04x %04x %08x\n", ++ bdp, ++ bdp->cbd_sc, ++ bdp->cbd_datlen, ++ bdp->cbd_bufaddr); ++ bdp++; ++ } ++ ++ bdp = fep->rx_bd_base; ++ printk(" rx: %lu buffers\n", RX_RING_SIZE); ++ for (i = 0; i < RX_RING_SIZE; i++) { ++ printk(" %p: %04x %04x %08x\n", ++ bdp, ++ bdp->cbd_sc, ++ bdp->cbd_datlen, ++ bdp->cbd_bufaddr); ++ bdp++; ++ } ++ fec_enet_cbd_put(fep); + } + #endif + fec_restart(dev, fep->full_duplex); +- netif_wake_queue(dev); ++ DBG(0, "%s: Scheduling netif queue\n", __FUNCTION__); ++ //netif_schedule(dev); + } + + /* The interrupt handler. + * This is called from the MPC core interrupt. + */ + static irqreturn_t +-fec_enet_interrupt(int irq, void * dev_id) ++fec_enet_interrupt(int irq, void *dev_id) + { +- struct net_device *dev = dev_id; +- volatile fec_t *fecp; +- uint int_events; +- irqreturn_t ret = IRQ_NONE; +- +- fecp = (volatile fec_t*)dev->base_addr; ++ struct net_device *dev = dev_id; ++ struct fec_enet_private *fep = netdev_priv(dev); ++ uint int_events; ++ int handled = 0; ++ unsigned int eimr = fec_reg_read(fep, FEC_EIMR); + ++ DBG(2, "%s: %08lx:%08lx\n", __FUNCTION__, ++ fec_reg_read(fep, FEC_EIR), fec_reg_read(fep, FEC_EIMR)); + /* Get the interrupt events that caused us to be here. + */ +- do { +- int_events = fecp->fec_ievent; +- fecp->fec_ievent = int_events; ++ while ((int_events = fec_reg_read(fep, FEC_EIR) & FEC_ENET_MASK) != 0) { ++ if (int_events & ~eimr) { ++ printk(KERN_WARNING "%s: masked interrupt condition: %08x\n", ++ __FUNCTION__, int_events & ~eimr); ++ } ++ ++ fec_reg_write(fep, FEC_EIR, int_events); + + /* Handle receive event in its own function. + */ +- if (int_events & FEC_ENET_RXF) { +- ret = IRQ_HANDLED; ++ if (int_events & (FEC_ENET_RXF | FEC_ENET_RXB)) { ++ DBG(2, "%s: Handling RX Interrupt\n", __FUNCTION__); ++ handled = 1; + fec_enet_rx(dev); + } + ++ if (int_events & FEC_ENET_UN) { ++ printk(KERN_WARNING "TX fifo underrun"); ++ } + /* Transmit OK, or non-fatal error. Update the buffer + descriptors. FEC handles all errors, we just discover + them as part of the transmit process. + */ +- if (int_events & FEC_ENET_TXF) { +- ret = IRQ_HANDLED; ++ if (int_events & (FEC_ENET_TXF | FEC_ENET_TXB)) { ++ DBG(2, "%s: Handling TX Interrupt\n", __FUNCTION__); ++ handled = 1; + fec_enet_tx(dev); + } + +- if (int_events & FEC_ENET_MII) { +- ret = IRQ_HANDLED; ++ if (int_events & (FEC_ENET_MII | FEC_ENET_HBERR)) { ++ DBG(2, "%s: Handling MII Interrupt\n", __FUNCTION__); ++ handled = 1; + fec_enet_mii(dev); + } +- +- } while (int_events); +- +- return ret; ++ } ++ return IRQ_RETVAL(handled); + } + ++static void fec_free_skb(struct fec_enet_private *fep, cbd_t *bdp, struct sk_buff **pskb) ++{ ++ struct sk_buff *skb = *pskb; ++ if (!dma_mapping_error(fep->dma_dev, bdp->cbd_bufaddr)) { ++ fec_enet_txbuf_unmap(fep, bdp, skb->len); ++ } ++ dev_kfree_skb_any(skb); ++ *pskb = NULL; ++} + + static void + fec_enet_tx(struct net_device *dev) + { +- struct fec_enet_private *fep; +- volatile cbd_t *bdp; ++ struct fec_enet_private *fep = netdev_priv(dev); ++ cbd_t *bdp; + unsigned short status; +- struct sk_buff *skb; ++ struct sk_buff *skb; + +- fep = netdev_priv(dev); +- spin_lock_irq(&fep->hw_lock); ++ spin_lock(&fep->lock); ++ ++ //WARN_ON(fec_reg_read(fep, FEC_TDAR) & TDAR_BUSY); ++ fec_enet_cbd_get(fep); + bdp = fep->dirty_tx; + + while (((status = bdp->cbd_sc) & BD_ENET_TX_READY) == 0) { +@@ -495,22 +770,22 @@ fec_enet_tx(struct net_device *dev) + if (status & (BD_ENET_TX_HB | BD_ENET_TX_LC | + BD_ENET_TX_RL | BD_ENET_TX_UN | + BD_ENET_TX_CSL)) { +- dev->stats.tx_errors++; ++ fep->stats.tx_errors++; + if (status & BD_ENET_TX_HB) /* No heartbeat */ +- dev->stats.tx_heartbeat_errors++; ++ fep->stats.tx_heartbeat_errors++; + if (status & BD_ENET_TX_LC) /* Late collision */ +- dev->stats.tx_window_errors++; ++ fep->stats.tx_window_errors++; + if (status & BD_ENET_TX_RL) /* Retrans limit */ +- dev->stats.tx_aborted_errors++; ++ fep->stats.tx_aborted_errors++; + if (status & BD_ENET_TX_UN) /* Underrun */ +- dev->stats.tx_fifo_errors++; ++ fep->stats.tx_fifo_errors++; + if (status & BD_ENET_TX_CSL) /* Carrier lost */ +- dev->stats.tx_carrier_errors++; ++ fep->stats.tx_carrier_errors++; + } else { +- dev->stats.tx_packets++; ++ fep->stats.tx_packets++; + } + +-#ifndef final_version ++#ifdef DEBUG + if (status & BD_ENET_TX_READY) + printk("HEY! Enet xmit interrupt and TX_READY.\n"); + #endif +@@ -518,12 +793,13 @@ fec_enet_tx(struct net_device *dev) + * but we eventually sent the packet OK. + */ + if (status & BD_ENET_TX_DEF) +- dev->stats.collisions++; ++ fep->stats.collisions++; + ++ dump_packet("sent packet:", fep->tx_skbuff[fep->skb_dirty]->data, ++ fep->tx_skbuff[fep->skb_dirty]->len); + /* Free the sk buffer associated with this last transmit. + */ +- dev_kfree_skb_any(skb); +- fep->tx_skbuff[fep->skb_dirty] = NULL; ++ fec_free_skb(fep, bdp, &fep->tx_skbuff[fep->skb_dirty]); + fep->skb_dirty = (fep->skb_dirty + 1) & TX_RING_MOD_MASK; + + /* Update pointer to next buffer descriptor to be transmitted. +@@ -538,12 +814,15 @@ fec_enet_tx(struct net_device *dev) + */ + if (fep->tx_full) { + fep->tx_full = 0; +- if (netif_queue_stopped(dev)) ++ if (netif_queue_stopped(dev)) { ++ DBG(0, "%s: Waking up netif queue\n", __FUNCTION__); + netif_wake_queue(dev); ++ } + } + } +- fep->dirty_tx = (cbd_t *)bdp; +- spin_unlock_irq(&fep->hw_lock); ++ fec_enet_cbd_put(fep); ++ fep->dirty_tx = bdp; ++ spin_unlock(&fep->lock); + } + + +@@ -555,22 +834,22 @@ fec_enet_tx(struct net_device *dev) + static void + fec_enet_rx(struct net_device *dev) + { +- struct fec_enet_private *fep; +- volatile fec_t *fecp; +- volatile cbd_t *bdp; ++ struct fec_enet_private *fep = netdev_priv(dev); ++ cbd_t *bdp; + unsigned short status; +- struct sk_buff *skb; +- ushort pkt_len; +- __u8 *data; ++ struct sk_buff *skb; ++ ushort pkt_len; ++ int rx_index; + + #ifdef CONFIG_M532x ++ /* This is probably nonsense ++ Proper use of dma-mapping functions should make this obsolete ++ */ + flush_cache_all(); + #endif +- +- fep = netdev_priv(dev); +- fecp = (volatile fec_t*)dev->base_addr; +- +- spin_lock_irq(&fep->hw_lock); ++ /* reserve the dual port memory area for our use */ ++ //WARN_ON(fec_reg_read(fep, FEC_RDAR) & RDAR_BUSY); ++ fec_enet_cbd_get(fep); + + /* First, grab all of the stats for the incoming packet. + * These get messed up if we get called due to a busy condition. +@@ -578,32 +857,34 @@ fec_enet_rx(struct net_device *dev) + bdp = fep->cur_rx; + + while (!((status = bdp->cbd_sc) & BD_ENET_RX_EMPTY)) { +- +-#ifndef final_version ++ rx_index = bdp - fep->rx_bd_base; ++#ifdef DEBUG + /* Since we have allocated space to hold a complete frame, + * the last indicator should be set. + */ +- if ((status & BD_ENET_RX_LAST) == 0) +- printk("FEC ENET: rcv is not +last\n"); ++ WARN_ON(!(status & BD_ENET_RX_LAST)); + #endif + +- if (!fep->opened) ++ if (WARN_ON(!fep->opened)) { ++ DBG(0, "%s: Driver not opened; ignoring packet\n", __FUNCTION__); ++#if 0 + goto rx_processing_done; +- ++#endif ++ } + /* Check for errors. */ + if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_NO | + BD_ENET_RX_CR | BD_ENET_RX_OV)) { +- dev->stats.rx_errors++; ++ fep->stats.rx_errors++; + if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH)) { + /* Frame too long or too short. */ +- dev->stats.rx_length_errors++; ++ fep->stats.rx_length_errors++; + } + if (status & BD_ENET_RX_NO) /* Frame alignment */ +- dev->stats.rx_frame_errors++; ++ fep->stats.rx_frame_errors++; + if (status & BD_ENET_RX_CR) /* CRC Error */ +- dev->stats.rx_crc_errors++; ++ fep->stats.rx_crc_errors++; + if (status & BD_ENET_RX_OV) /* FIFO overrun */ +- dev->stats.rx_fifo_errors++; ++ fep->stats.rx_fifo_errors++; + } + + /* Report late collisions as a frame error. +@@ -611,39 +892,91 @@ while (!((status = bdp->cbd_sc) & BD_ENE + * have in the buffer. So, just drop this frame on the floor. + */ + if (status & BD_ENET_RX_CL) { +- dev->stats.rx_errors++; +- dev->stats.rx_frame_errors++; ++ fep->stats.rx_errors++; ++ fep->stats.rx_frame_errors++; ++ DBG(0, "%s: Collision detected; dropping packet\n", __FUNCTION__); ++ if (bdp->cbd_datlen > PKT_MAXBUF_SIZE) { ++ printk(KERN_ERR "invalid packet size %u; max %u\n", bdp->cbd_datlen, ++ PKT_MAXBUF_SIZE); ++ } else { ++ fec_enet_rxbuf_get(fep, bdp, bdp->cbd_datlen); ++ dump_packet("received packet:", ++ fep->rx_skbuff[rx_index]->data, bdp->cbd_datlen); ++ fec_enet_rxbuf_put(fep, bdp, bdp->cbd_datlen); ++ } + goto rx_processing_done; + } +- ++#if 1 ++ if (!fep->opened) { ++ DBG(0, "%s: Driver not opened; ignoring packet\n", __FUNCTION__); ++ if (bdp->cbd_datlen > PKT_MAXBUF_SIZE) { ++ printk(KERN_ERR "invalid packet size %u; max %u\n", bdp->cbd_datlen, ++ PKT_MAXBUF_SIZE); ++ } else { ++ fec_enet_rxbuf_get(fep, bdp, bdp->cbd_datlen); ++ dump_packet("received packet:", ++ fep->rx_skbuff[rx_index]->data, bdp->cbd_datlen); ++ fec_enet_rxbuf_put(fep, bdp, bdp->cbd_datlen); ++ } ++ goto rx_processing_done; ++ } ++#endif + /* Process the incoming frame. + */ +- dev->stats.rx_packets++; ++ fep->stats.rx_packets++; + pkt_len = bdp->cbd_datlen; +- dev->stats.rx_bytes += pkt_len; +- data = (__u8*)__va(bdp->cbd_bufaddr); +- +- dma_sync_single(NULL, (unsigned long)__pa(data), +- pkt_len - 4, DMA_FROM_DEVICE); ++ fep->stats.rx_bytes += pkt_len; + + /* This does 16 byte alignment, exactly what we need. + * The packet length includes FCS, but we don't want to + * include that when passing upstream as it messes up + * bridging applications. + */ +- skb = dev_alloc_skb(pkt_len-4); ++ if ((pkt_len - 4) < fec_copy_threshold) { ++ skb = dev_alloc_skb(pkt_len); ++ } else { ++ skb = dev_alloc_skb(FEC_ENET_RX_FRSIZE); ++ } + + if (skb == NULL) { + printk("%s: Memory squeeze, dropping packet.\n", dev->name); +- dev->stats.rx_dropped++; ++ fep->stats.rx_dropped++; + } else { +- skb_put(skb,pkt_len-4); /* Make room */ +- skb_copy_to_linear_data(skb, data, pkt_len-4); +- skb->protocol=eth_type_trans(skb,dev); ++ if ((pkt_len - 4) < fec_copy_threshold) { ++ /* skip 2 bytes, so IP header is on a 4 bytes boundary */ ++ skb_reserve(skb, 2); ++ skb_put(skb, pkt_len - 4); /* Make room */ ++ fec_enet_rxbuf_get(fep, bdp, pkt_len - 4); ++ skb_copy_to_linear_data(skb, ++ fep->rx_skbuff[rx_index]->data, ++ pkt_len - 4); ++ fec_enet_rxbuf_put(fep, bdp, pkt_len - 4); ++ } else { ++ struct sk_buff *pskb = fep->rx_skbuff[rx_index]; ++ ++ /* unmap the skb we are going to hand down to the network layer */ ++ fec_enet_rxbuf_unmap(fep, bdp, FEC_ENET_RX_FRSIZE); ++ ++ /* init the newly allocated skb */ ++ fep->rx_skbuff[rx_index] = skb; ++ skb->data = FEC_ADDR_ALIGNMENT(skb->data); ++ /* map the newly allocated skb's data buffer for DMA */ ++ fec_enet_rxbuf_map(fep, bdp, skb->data, FEC_ENET_RX_FRSIZE); ++ ++ skb_put(pskb, pkt_len - 4); /* Make room */ ++ skb = pskb; ++ } ++ skb->dev = dev; ++ skb->protocol = eth_type_trans(skb, dev); + netif_rx(skb); + } + rx_processing_done: +- ++#if 0 ++ if (dbg_lvl(3)) { ++ dump_rx_buffers(fep); ++ dump_tx_buffers(fep); ++ } ++#endif + /* Clear the status flags for this buffer. + */ + status &= ~BD_ENET_RX_STATS; +@@ -653,6 +986,9 @@ while (!((status = bdp->cbd_sc) & BD_ENE + status |= BD_ENET_RX_EMPTY; + bdp->cbd_sc = status; + ++ /* release the dual port memory area for use by the FEC hardware */ ++ fec_enet_cbd_put(fep); ++ + /* Update BD pointer to next entry. + */ + if (status & BD_ENET_RX_WRAP) +@@ -665,10 +1001,10 @@ while (!((status = bdp->cbd_sc) & BD_ENE + * incoming frames. On a heavily loaded network, we should be + * able to keep up at the expense of system resources. + */ +- fecp->fec_r_des_active = 0; ++ fec_reg_write(fep, FEC_RDAR, DONT_CARE); + #endif + } /* while (!((status = bdp->cbd_sc) & BD_ENET_RX_EMPTY)) */ +- fep->cur_rx = (cbd_t *)bdp; ++ fep->cur_rx = bdp; + + #if 0 + /* Doing this here will allow us to process all frames in the +@@ -678,27 +1014,28 @@ while (!((status = bdp->cbd_sc) & BD_ENE + * our way back to the interrupt return only to come right back + * here. + */ +- fecp->fec_r_des_active = 0; ++ fec_reg_write(fep, FEC_RDAR, DONT_CARE); + #endif +- +- spin_unlock_irq(&fep->hw_lock); + } + +- ++#ifdef CONFIG_PHYLIB + /* called from interrupt context */ ++static void fec_enet_mii(struct net_device *dev) ++{ ++ struct fec_enet_private *fep = netdev_priv(dev); ++ fep->mii_complete = 1; ++} ++#else + static void + fec_enet_mii(struct net_device *dev) + { +- struct fec_enet_private *fep; +- volatile fec_t *ep; ++ struct fec_enet_private *fep = netdev_priv(dev); + mii_list_t *mip; + uint mii_reg; + +- fep = netdev_priv(dev); +- spin_lock_irq(&fep->mii_lock); ++ mii_reg = fec_reg_read(fep, FEC_MMFR); + +- ep = fep->hwp; +- mii_reg = ep->fec_mii_data; ++ spin_lock(&fep->lock); + + if ((mip = mii_head) == NULL) { + printk("MII and no head!\n"); +@@ -713,27 +1050,27 @@ fec_enet_mii(struct net_device *dev) + mii_free = mip; + + if ((mip = mii_head) != NULL) +- ep->fec_mii_data = mip->mii_regval; ++ fec_reg_write(fep, FEC_MMFR, mip->mii_regval); + + unlock: +- spin_unlock_irq(&fep->mii_lock); ++ spin_unlock(&fep->lock); + } + + static int + mii_queue(struct net_device *dev, int regval, void (*func)(uint, struct net_device *)) + { +- struct fec_enet_private *fep; ++ struct fec_enet_private *fep = netdev_priv(dev); + unsigned long flags; + mii_list_t *mip; + int retval; + ++ retval = 0; ++ ++ spin_lock_irqsave(&fep->lock,flags); ++ + /* Add PHY address to register command. + */ +- fep = netdev_priv(dev); +- spin_lock_irqsave(&fep->mii_lock, flags); +- + regval |= fep->phy_addr << 23; +- retval = 0; + + if ((mip = mii_free) != NULL) { + mii_free = mip->mii_next; +@@ -745,32 +1082,32 @@ mii_queue(struct net_device *dev, int re + mii_tail = mip; + } else { + mii_head = mii_tail = mip; +- fep->hwp->fec_mii_data = regval; ++ fec_reg_write(fep, FEC_MMFR, regval); + } + } else { + retval = 1; + } + +- spin_unlock_irqrestore(&fep->mii_lock, flags); +- return retval; ++ spin_unlock_irqrestore(&fep->lock,flags); ++ ++ return(retval); + } + + static void mii_do_cmd(struct net_device *dev, const phy_cmd_t *c) + { +- if(!c) +- return; ++ int k; + +- for (; c->mii_data != mk_mii_end; c++) +- mii_queue(dev, c->mii_data, c->funct); ++ for (k = 0; c != NULL && c[k].mii_data != mk_mii_end; k++) { ++ mii_queue(dev, c[k].mii_data, c[k].funct); ++ } + } + + static void mii_parse_sr(uint mii_reg, struct net_device *dev) + { + struct fec_enet_private *fep = netdev_priv(dev); +- volatile uint *s = &(fep->phy_status); + uint status; + +- status = *s & ~(PHY_STAT_LINK | PHY_STAT_FAULT | PHY_STAT_ANC); ++ status = fep->phy_status & ~(PHY_STAT_LINK | PHY_STAT_FAULT | PHY_STAT_ANC); + + if (mii_reg & 0x0004) + status |= PHY_STAT_LINK; +@@ -778,31 +1115,30 @@ static void mii_parse_sr(uint mii_reg, s + status |= PHY_STAT_FAULT; + if (mii_reg & 0x0020) + status |= PHY_STAT_ANC; +- *s = status; ++ ++ fep->phy_status = status; + } + + static void mii_parse_cr(uint mii_reg, struct net_device *dev) + { + struct fec_enet_private *fep = netdev_priv(dev); +- volatile uint *s = &(fep->phy_status); + uint status; + +- status = *s & ~(PHY_CONF_ANE | PHY_CONF_LOOP); ++ status = fep->phy_status & ~(PHY_CONF_ANE | PHY_CONF_LOOP); + + if (mii_reg & 0x1000) + status |= PHY_CONF_ANE; + if (mii_reg & 0x4000) + status |= PHY_CONF_LOOP; +- *s = status; ++ fep->phy_status = status; + } + + static void mii_parse_anar(uint mii_reg, struct net_device *dev) + { + struct fec_enet_private *fep = netdev_priv(dev); +- volatile uint *s = &(fep->phy_status); + uint status; + +- status = *s & ~(PHY_CONF_SPMASK); ++ status = fep->phy_status & ~(PHY_CONF_SPMASK); + + if (mii_reg & 0x0020) + status |= PHY_CONF_10HDX; +@@ -812,7 +1148,7 @@ static void mii_parse_anar(uint mii_reg, + status |= PHY_CONF_100HDX; + if (mii_reg & 0x00100) + status |= PHY_CONF_100FDX; +- *s = status; ++ fep->phy_status = status; + } + + /* ------------------------------------------------------------------------- */ +@@ -827,10 +1163,9 @@ static void mii_parse_anar(uint mii_reg, + static void mii_parse_lxt970_csr(uint mii_reg, struct net_device *dev) + { + struct fec_enet_private *fep = netdev_priv(dev); +- volatile uint *s = &(fep->phy_status); + uint status; + +- status = *s & ~(PHY_STAT_SPMASK); ++ status = fep->phy_status & ~(PHY_STAT_SPMASK); + if (mii_reg & 0x0800) { + if (mii_reg & 0x1000) + status |= PHY_STAT_100FDX; +@@ -842,7 +1177,7 @@ static void mii_parse_lxt970_csr(uint mi + else + status |= PHY_STAT_10HDX; + } +- *s = status; ++ fep->phy_status = status; + } + + static phy_cmd_t const phy_cmd_lxt970_config[] = { +@@ -898,16 +1233,15 @@ static phy_info_t const phy_info_lxt970 + static void mii_parse_lxt971_sr2(uint mii_reg, struct net_device *dev) + { + struct fec_enet_private *fep = netdev_priv(dev); +- volatile uint *s = &(fep->phy_status); + uint status; + +- status = *s & ~(PHY_STAT_SPMASK | PHY_STAT_LINK | PHY_STAT_ANC); ++ status = fep->phy_status & ~(PHY_STAT_SPMASK | PHY_STAT_LINK | PHY_STAT_ANC); + + if (mii_reg & 0x0400) { +- fep->link = 1; ++ fep->linkstatus = 1; + status |= PHY_STAT_LINK; + } else { +- fep->link = 0; ++ fep->linkstatus = 0; + } + if (mii_reg & 0x0080) + status |= PHY_STAT_ANC; +@@ -925,7 +1259,7 @@ static void mii_parse_lxt971_sr2(uint mi + if (mii_reg & 0x0008) + status |= PHY_STAT_FAULT; + +- *s = status; ++ fep->phy_status = status; + } + + static phy_cmd_t const phy_cmd_lxt971_config[] = { +@@ -982,10 +1316,9 @@ static phy_info_t const phy_info_lxt971 + static void mii_parse_qs6612_pcr(uint mii_reg, struct net_device *dev) + { + struct fec_enet_private *fep = netdev_priv(dev); +- volatile uint *s = &(fep->phy_status); + uint status; + +- status = *s & ~(PHY_STAT_SPMASK); ++ status = fep->phy_status & ~(PHY_STAT_SPMASK); + + switch((mii_reg >> 2) & 7) { + case 1: status |= PHY_STAT_10HDX; break; +@@ -994,7 +1327,7 @@ static void mii_parse_qs6612_pcr(uint mi + case 6: status |= PHY_STAT_100FDX; break; + } + +- *s = status; ++ fep->phy_status = status; + } + + static phy_cmd_t const phy_cmd_qs6612_config[] = { +@@ -1052,10 +1385,9 @@ static phy_info_t const phy_info_qs6612 + static void mii_parse_am79c874_dr(uint mii_reg, struct net_device *dev) + { + struct fec_enet_private *fep = netdev_priv(dev); +- volatile uint *s = &(fep->phy_status); + uint status; + +- status = *s & ~(PHY_STAT_SPMASK | PHY_STAT_ANC); ++ status = fep->phy_status & ~(PHY_STAT_SPMASK | PHY_STAT_ANC); + + if (mii_reg & 0x0080) + status |= PHY_STAT_ANC; +@@ -1064,7 +1396,7 @@ static void mii_parse_am79c874_dr(uint m + else + status |= ((mii_reg & 0x0800) ? PHY_STAT_10FDX : PHY_STAT_10HDX); + +- *s = status; ++ fep->phy_status = status; + } + + static phy_cmd_t const phy_cmd_am79c874_config[] = { +@@ -1107,7 +1439,7 @@ static phy_info_t const phy_info_am79c87 + /* register definitions for the 8721 */ + + #define MII_KS8721BL_RXERCR 21 +-#define MII_KS8721BL_ICSR 27 ++#define MII_KS8721BL_ICSR 22 + #define MII_KS8721BL_PHYCR 31 + + static phy_cmd_t const phy_cmd_ks8721bl_config[] = { +@@ -1149,32 +1481,31 @@ static phy_info_t const phy_info_ks8721b + static void mii_parse_dp8384x_sr2(uint mii_reg, struct net_device *dev) + { + struct fec_enet_private *fep = netdev_priv(dev); +- volatile uint *s = &(fep->phy_status); + +- *s &= ~(PHY_STAT_SPMASK | PHY_STAT_LINK | PHY_STAT_ANC); ++ fep->phy_status &= ~(PHY_STAT_SPMASK | PHY_STAT_LINK | PHY_STAT_ANC); + + /* Link up */ + if (mii_reg & 0x0001) { +- fep->link = 1; +- *s |= PHY_STAT_LINK; ++ fep->linkstatus = 1; ++ fep->phy_status |= PHY_STAT_LINK; + } else +- fep->link = 0; ++ fep->linkstatus = 0; + /* Status of link */ + if (mii_reg & 0x0010) /* Autonegotioation complete */ +- *s |= PHY_STAT_ANC; ++ fep->phy_status |= PHY_STAT_ANC; + if (mii_reg & 0x0002) { /* 10MBps? */ + if (mii_reg & 0x0004) /* Full Duplex? */ +- *s |= PHY_STAT_10FDX; ++ fep->phy_status |= PHY_STAT_10FDX; + else +- *s |= PHY_STAT_10HDX; ++ fep->phy_status |= PHY_STAT_10HDX; + } else { /* 100 Mbps? */ + if (mii_reg & 0x0004) /* Full Duplex? */ +- *s |= PHY_STAT_100FDX; ++ fep->phy_status |= PHY_STAT_100FDX; + else +- *s |= PHY_STAT_100HDX; ++ fep->phy_status |= PHY_STAT_100HDX; + } + if (mii_reg & 0x0008) +- *s |= PHY_STAT_FAULT; ++ fep->phy_status |= PHY_STAT_FAULT; + } + + static phy_info_t phy_info_dp83848= { +@@ -1211,92 +1542,362 @@ static phy_info_t const * const phy_info + &phy_info_dp83848, + NULL + }; +- +-/* ------------------------------------------------------------------------- */ +-#ifdef HAVE_mii_link_interrupt +-static irqreturn_t +-mii_link_interrupt(int irq, void * dev_id); ++#endif + + /* +- * This is specific to the MII interrupt setup of the M5272EVB. ++ * do some initializtion based architecture of this chip ++MOVED to platform_data hooks! + */ +-static void __inline__ fec_request_mii_intr(struct net_device *dev) +-{ +- if (request_irq(66, mii_link_interrupt, IRQF_DISABLED, "fec(MII)", dev) != 0) +- printk("FEC: Could not allocate fec(MII) IRQ(66)!\n"); +-} + +-static void __inline__ fec_disable_phy_intr(void) +-{ +- volatile unsigned long *icrp; +- icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1); +- *icrp = 0x08000000; +-} ++#define PHY_POLL_LINK_ON (1 * HZ) ++#define PHY_POLL_LINK_OFF (HZ / 5) + +-static void __inline__ fec_phy_ack_intr(void) ++static int fec_mii_read(struct mii_bus *bus, int phy_id, int regnum); ++ ++#ifdef CONFIG_PHYLIB ++static void fec_link_change(struct net_device *dev) + { +- volatile unsigned long *icrp; +- /* Acknowledge the interrupt */ +- icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1); +- *icrp = 0x0d000000; +-} +-#endif ++ struct fec_enet_private *fep = netdev_priv(dev); ++ struct phy_device *phydev = fep->phy; + +-#ifdef CONFIG_M5272 +-static void __inline__ fec_get_mac(struct net_device *dev) ++ if (phydev->link != fep->linkstatus || ++ phydev->duplex != fep->full_duplex) { ++ DBG(0, "%s: link status changed from %d to %d %s -> %s duplex\n", __FUNCTION__, ++ fep->linkstatus, phydev->link, fep->full_duplex ? "full" : "half", ++ phydev->duplex ? "full" : "half"); ++ if (phydev->link) { ++ fec_restart(dev, phydev->duplex); ++ } else { ++ fec_stop(dev); ++ } ++ if (fep->linkstatus != phydev->link && netif_msg_link(fep)) { ++ phy_print_status(phydev); ++ } ++ fep->linkstatus = phydev->link; ++#if 0 ++ int i; ++ for (i = 0; i < 32; i++) { ++ DBG(0, "%s: PHY reg[%02x]=%04x\n", __FUNCTION__, i, ++ fec_mii_read(fep->mii, fep->phy_addr, i)); ++ } ++#endif ++ } ++} ++#else ++static void fec_link_change(struct net_device *dev) + { + struct fec_enet_private *fep = netdev_priv(dev); +- volatile fec_t *fecp; +- unsigned char *iap, tmpaddr[ETH_ALEN]; + +- fecp = fep->hwp; ++ DBG(0, "%s: link status changed from %d to %d\n", __FUNCTION__, ++ fep->old_linkstatus, fep->linkstatus); ++ if (fep->linkstatus) { ++ int duplex; + +- if (FEC_FLASHMAC) { +- /* +- * Get MAC address from FLASH. +- * If it is all 1's or 0's, use the default. +- */ +- iap = (unsigned char *)FEC_FLASHMAC; +- if ((iap[0] == 0) && (iap[1] == 0) && (iap[2] == 0) && +- (iap[3] == 0) && (iap[4] == 0) && (iap[5] == 0)) +- iap = fec_mac_default; +- if ((iap[0] == 0xff) && (iap[1] == 0xff) && (iap[2] == 0xff) && +- (iap[3] == 0xff) && (iap[4] == 0xff) && (iap[5] == 0xff)) +- iap = fec_mac_default; ++ duplex = 0; ++ if (fep->phy_status & (PHY_STAT_100FDX | PHY_STAT_10FDX)) { ++ duplex = 1; ++ } ++ fec_restart(dev, duplex); ++ if (fep->phy_timer) { ++ mod_timer(fep->phy_timer, jiffies + PHY_POLL_LINK_ON); ++ } + } else { +- *((unsigned long *) &tmpaddr[0]) = fecp->fec_addr_low; +- *((unsigned short *) &tmpaddr[4]) = (fecp->fec_addr_high >> 16); +- iap = &tmpaddr[0]; ++ fec_stop(dev); ++ if (fep->phy_timer) { ++ mod_timer(fep->phy_timer, jiffies + PHY_POLL_LINK_OFF); ++ } + } + +- memcpy(dev->dev_addr, iap, ETH_ALEN); +- +- /* Adjust MAC if using default MAC address */ +- if (iap == fec_mac_default) +- dev->dev_addr[ETH_ALEN-1] = fec_mac_default[ETH_ALEN-1] + fep->index; ++ fep->old_linkstatus = fep->linkstatus; + } +-#endif + +-/* ------------------------------------------------------------------------- */ +- +-static void mii_display_status(struct net_device *dev) ++static void fec_phy_timer(unsigned long data) + { ++ struct net_device *dev = (struct net_device *)data; + struct fec_enet_private *fep = netdev_priv(dev); +- volatile uint *s = &(fep->phy_status); ++ int link_poll_interval = fep->linkstatus ? PHY_POLL_LINK_ON : PHY_POLL_LINK_OFF; + +- if (!fep->link && !fep->old_link) { +- /* Link is still down - don't print anything */ ++ if (fep->old_linkstatus != fep->linkstatus) { ++ fec_link_change(dev); ++ } ++ mod_timer(fep->phy_timer, link_poll_interval); ++} ++#endif ++ ++/* ++ * Code specific to Freescale i.MXC ++ */ ++static int fec_request_intrs(struct platform_device *pdev, struct net_device *dev) ++{ ++ int ret; ++ struct fec_enet_private *fep = netdev_priv(dev); ++ ++ fep->etn_irq = platform_get_irq(pdev, 0); ++ fep->mii_irq = platform_get_irq(pdev, 1); ++ ++ /* Setup interrupt handlers. */ ++ ret = request_irq(fep->etn_irq, fec_enet_interrupt, 0, "fec", dev); ++ if (ret != 0) { ++ printk(KERN_ERR "FEC: Could not allocate FEC IRQ(%d)!\n", fep->etn_irq); ++ return ret; ++ } ++#ifndef CONFIG_PHYLIB ++ if (fep->mii_irq >= 0) { ++ /* TODO: disable now due to CPLD issue */ ++ ret = request_irq(fep->mii_irq, mii_link_interrupt, 0, "fec(MII)", dev); ++ if (ret != 0) { ++ printk(KERN_ERR "FEC: Could not allocate FEC(MII) IRQ(%d)!\n", ++ fep->mii_irq); ++ free_irq(fep->etn_irq, dev); ++ return ret; ++ } ++ /* ++ * board specific workaround should be done in board specific code ++ * This is unsafe anyway. An interrupt might have been asserted ++ * already. Use IRQ_NOAUTOEN with request_irq() to have irq initially disabled. ++ */ ++ fep->phy_int_enabled = 1; ++ } else { ++ fep->phy_timer = kzalloc(sizeof(struct timer_list), GFP_KERNEL); ++ if (fep->phy_timer == NULL) { ++ free_irq(fep->etn_irq, dev); ++ return -ENOMEM; ++ } ++ init_timer(fep->phy_timer); ++ fep->phy_timer->function = fec_phy_timer; ++ fep->phy_timer->data = (unsigned long)dev; ++ fec_link_change(dev); ++ } ++#endif ++ ++ return 0; ++} ++ ++static void fec_release_intrs(struct net_device *dev) ++{ ++ struct fec_enet_private *fep = netdev_priv(dev); ++ ++ free_irq(fep->etn_irq, dev); ++#ifndef CONFIG_PHYLIB ++ if (fep->mii_irq >= 0) { ++ free_irq(fep->mii_irq, dev); ++ } ++#endif ++} ++ ++#ifdef CONFIG_MACH_MX25 ++/* ++ * i.MX25 allows RMII mode to be configured via a gasket ++ */ ++#define FEC_MIIGSK_CFGR 0x300 ++#define FEC_MIIGSK_ENR 0x308 ++ ++#define FEC_MIIGSK_CFGR_FRCONT (1 << 6) ++#define FEC_MIIGSK_CFGR_LBMODE (1 << 4) ++#define FEC_MIIGSK_CFGR_EMODE (1 << 3) ++#define FEC_MIIGSK_CFGR_IF_MODE_MASK (3 << 0) ++#define FEC_MIIGSK_CFGR_IF_MODE_MII (0 << 0) ++#define FEC_MIIGSK_CFGR_IF_MODE_RMII (1 << 0) ++ ++#define FEC_MIIGSK_ENR_READY (1 << 2) ++#define FEC_MIIGSK_ENR_EN (1 << 1) ++ ++#ifndef DEBUG ++static inline unsigned long fec_reg_read16(struct fec_enet_private *fep, unsigned int reg) ++{ ++ return readw(fep->reg_base + reg); ++} ++ ++static inline void fec_reg_write(struct fec_enet_private *fep, unsigned int reg, unsigned long val) ++{ ++ writew(val, fep->reg_base + reg); ++} ++#else ++#define fec_reg_read16(fep, reg) __fec_reg_read16(fep, reg, __FUNCTION__, #reg) ++#define fec_reg_write16(fep, reg, val) __fec_reg_write16(fep, reg, val, __FUNCTION__, #reg) ++ ++static inline u16 __fec_reg_read16(struct fec_enet_private *fep, unsigned int reg, ++ const char *func, const char *reg_name) ++{ ++ u16 val = readw(fep->reg_base + reg); ++ DBG(0, "%s: Read %04x from %s(%03x)\n", func, val, reg_name, reg); ++ return val; ++} ++ ++static inline void __fec_reg_write16(struct fec_enet_private *fep, unsigned int reg, ++ u16 val, const char *func, const char *reg_name) ++{ ++ DBG(0, "%s: Writing %04x to %s(%03x)\n", func, val, reg_name, reg); ++ writew(val, fep->reg_base + reg); ++} ++#endif ++ ++static void fec_localhw_setup(struct net_device *dev) ++{ ++ struct fec_enet_private *fep = netdev_priv(dev); ++ int loops; ++ const int max_loops = 10000; ++ ++ /* ++ * Set up the MII gasket for RMII mode ++ */ ++ dev_dbg(&dev->dev, "enable RMII gasket\n"); ++ ++ /* disable the gasket and wait */ ++ fec_reg_write16(fep, FEC_MIIGSK_ENR, 0); ++ DBG(0, "%s: Waiting for RMII gasket idle\n", __FUNCTION__); ++ while (fec_reg_read16(fep, FEC_MIIGSK_ENR) & FEC_MIIGSK_ENR_READY) ++ udelay(1); ++ DBG(0, "%s: RMII gasket idle\n", __FUNCTION__); ++ ++ /* configure the gasket for RMII, 50 MHz, no loopback, no echo */ ++ fec_reg_write16(fep, FEC_MIIGSK_CFGR, FEC_MIIGSK_CFGR_IF_MODE_RMII); ++ ++ /* re-enable the gasket */ ++ fec_reg_write16(fep, FEC_MIIGSK_ENR, FEC_MIIGSK_ENR_EN); ++ fec_reg_read16(fep, FEC_MIIGSK_CFGR); ++ fec_reg_read16(fep, FEC_MIIGSK_ENR); ++ ++#if 1 ++ DBG(0, "%s: Waiting for RMII gasket ready\n", __FUNCTION__); ++ for (loops = 0; loops < max_loops; loops++) { ++ if (readw(fep->reg_base + FEC_MIIGSK_ENR) & FEC_MIIGSK_ENR_READY) ++ break; ++ udelay(1); ++ } ++ if (fec_reg_read16(fep, FEC_MIIGSK_ENR) & FEC_MIIGSK_ENR_READY) { ++ DBG(0, "%s: RMII gasket ready after %u loops\n", __FUNCTION__, loops); ++ } else { ++ DBG(0, "%s: RMII gasket NOT ready after %u loops\n", __FUNCTION__, loops); ++ } ++#endif ++} ++#else ++static inline void fec_localhw_setup(struct net_device *dev) ++{ ++} ++#endif ++ ++static int fec_set_mii(struct net_device *dev, struct fec_enet_private *fep) ++{ ++ unsigned long rate; ++ struct clk *clk; ++ ++ DBG(0, "%s: \n", __FUNCTION__); ++ ++ fec_reg_write(fep, FEC_RCR, OPT_FRAME_SIZE | RCR_MII_MODE); ++ fec_reg_write(fep, FEC_TCR, 0x00); ++ ++ /* ++ * Set MII speed to 2.5 MHz ++ */ ++ clk = clk_get(fep->dma_dev, NULL); ++ if (!IS_ERR(clk)) { ++ rate = clk_get_rate(clk); ++ clk_put(clk); ++ } else { ++ printk(KERN_ERR "Failed to get fec clock: %ld\n", PTR_ERR(clk)); ++ return PTR_ERR(clk); ++ } ++ fep->phy_speed = ((((rate + 4999999) / 2500000) / 2) & 0x3F) << 1; ++ fec_reg_write(fep, FEC_MSCR, fep->phy_speed); ++ DBG(0, "%s: clkdiv set to %u for MII clock %u at base clock %lu\n", ++ __FUNCTION__, fep->phy_speed >> 1, 2500000, rate); ++ DBG(0, "%s: actual MII clock is: %lu\n", __FUNCTION__, rate / (fep->phy_speed)); ++ ++ return 0; ++} ++ ++static const unsigned char default_mac[ETH_ALEN] = { ++ 0x00, 0x04, 0x9f, 0x00, 0x74, 0x4a, ++}; ++ ++#define FEC_IIM_BASE IO_ADDRESS(IIM_BASE_ADDR) ++static void fec_get_mac(struct net_device *dev) ++{ ++#if 1 ++ // keep bootloader assigned MAC address ++ struct fec_enet_private *fep = netdev_priv(dev); ++ unsigned long eth_addr = fec_reg_read(fep, FEC_PALR); ++ dev->dev_addr[0] = eth_addr >> 24; ++ dev->dev_addr[1] = eth_addr >> 16; ++ dev->dev_addr[2] = eth_addr >> 8; ++ dev->dev_addr[3] = eth_addr >> 0; ++ eth_addr = fec_reg_read(fep, FEC_PAUR); ++ dev->dev_addr[5] = eth_addr >> 16; ++ dev->dev_addr[4] = eth_addr >> 24; ++#else ++ int i; ++ unsigned long fec_mac_base = FEC_IIM_BASE + MXC_IIMKEY0; ++ ++ if (cpu_is_mx27_rev(CHIP_REV_2_0) > 0) { ++ fec_mac_base = FEC_IIM_BASE + MXC_IIMMAC; ++ } ++ ++ DBG(0, "%s: Reading MAC address from %08lx\n", __FUNCTION__, fec_mac_base); ++ for (i = 0; i < ETH_ALEN; i++) { ++ dev->dev_addr[ETH_ALEN - 1 - i] = __raw_readb(fec_mac_base + i * 4); ++ } ++ //memcpy(dev->dev_addr, default_mac, ETH_ALEN); ++#endif ++} ++ ++#ifdef CONFIG_PHYLIB ++static inline void fec_enable_phy_intr(struct fec_enet_private *fep) ++{ ++} ++static inline void fec_disable_phy_intr(struct fec_enet_private *fep) ++{ ++} ++static inline void fec_phy_ack_intr(struct fec_enet_private *fep) ++{ ++} ++#else ++static inline void fec_enable_phy_intr(struct fec_enet_private *fep) ++{ ++ if (!fep->phy_int_enabled) { ++ fep->phy_int_enabled = 1; ++ enable_irq(fep->mii_irq); ++ } ++} ++ ++static inline void fec_disable_phy_intr(struct fec_enet_private *fep) ++{ ++ if (fep->phy_int_enabled) { ++ disable_irq(fep->mii_irq); ++ fep->phy_int_enabled = 0; ++ } ++} ++ ++static inline void fec_phy_ack_intr(struct fec_enet_private *fep) ++{ ++ if (fep->phy_int_enabled) { ++ disable_irq(fep->mii_irq); ++ fep->phy_int_enabled = 0; ++ } ++} ++#endif ++ ++/* ------------------------------------------------------------------------- */ ++ ++#ifndef CONFIG_PHYLIB ++static void mii_display_status(struct net_device *dev) ++{ ++ struct fec_enet_private *fep = netdev_priv(dev); ++ ++ if (!fep->linkstatus && !fep->old_linkstatus) { ++ /* Link is still down - don't print anything */ + return; + } + + printk("%s: status: ", dev->name); + +- if (!fep->link) { ++ if (!fep->linkstatus) { + printk("link down"); + } else { + printk("link up"); + +- switch(*s & PHY_STAT_SPMASK) { ++ switch(fep->phy_status & PHY_STAT_SPMASK) { + case PHY_STAT_100FDX: printk(", 100MBit Full Duplex"); break; + case PHY_STAT_100HDX: printk(", 100MBit Half Duplex"); break; + case PHY_STAT_10FDX: printk(", 10MBit Full Duplex"); break; +@@ -1305,20 +1906,19 @@ static void mii_display_status(struct ne + printk(", Unknown speed/duplex"); + } + +- if (*s & PHY_STAT_ANC) ++ if (fep->phy_status & PHY_STAT_ANC) + printk(", auto-negotiation complete"); + } + +- if (*s & PHY_STAT_FAULT) ++ if (fep->phy_status & PHY_STAT_FAULT) + printk(", remote fault"); + + printk(".\n"); + } + +-static void mii_display_config(struct work_struct *work) ++static void mii_display_config(struct work_struct *w) + { +- struct fec_enet_private *fep = container_of(work, struct fec_enet_private, phy_task); +- struct net_device *dev = fep->netdev; ++ struct fec_enet_private *fep = container_of(w, struct fec_enet_private, phy_task); + uint status = fep->phy_status; + + /* +@@ -1326,7 +1926,7 @@ static void mii_display_config(struct wo + ** the workqueue. It is thus safe to allow to reuse it. + */ + fep->mii_phy_task_queued = 0; +- printk("%s: config: auto-negotiation ", dev->name); ++ //printk("%s: config: auto-negotiation ", dev->name); + + if (status & PHY_CONF_ANE) + printk("on"); +@@ -1351,11 +1951,21 @@ static void mii_display_config(struct wo + + fep->sequence_done = 1; + } ++#endif + +-static void mii_relink(struct work_struct *work) ++#ifndef CONFIG_PHYLIB ++static inline void *priv_netdev(struct fec_enet_private *fep) + { +- struct fec_enet_private *fep = container_of(work, struct fec_enet_private, phy_task); +- struct net_device *dev = fep->netdev; ++ /* ugly hack, stolen from include linux/netdevice.h */ ++ return (char *)fep - ((sizeof(struct net_device) ++ + NETDEV_ALIGN_CONST) ++ & ~NETDEV_ALIGN_CONST); ++} ++ ++static void mii_relink(struct work_struct *w) ++{ ++ struct fec_enet_private *fep = container_of(w, struct fec_enet_private, phy_task); ++ struct net_device *dev = priv_netdev(fep); + int duplex; + + /* +@@ -1363,23 +1973,19 @@ static void mii_relink(struct work_struc + ** the workqueue. It is thus safe to allow to reuse it. + */ + fep->mii_phy_task_queued = 0; +- fep->link = (fep->phy_status & PHY_STAT_LINK) ? 1 : 0; ++ fep->linkstatus = (fep->phy_status & PHY_STAT_LINK) ? 1 : 0; + mii_display_status(dev); +- fep->old_link = fep->link; ++ fep->old_linkstatus = fep->linkstatus; + +- if (fep->link) { ++ if (fep->linkstatus) { + duplex = 0; +- if (fep->phy_status +- & (PHY_STAT_100FDX | PHY_STAT_10FDX)) ++ if (fep->phy_status & (PHY_STAT_100FDX | PHY_STAT_10FDX)) { + duplex = 1; ++ } + fec_restart(dev, duplex); +- } else ++ } else { + fec_stop(dev); +- +-#if 0 +- enable_irq(fep->mii_irq); +-#endif +- ++ } + } + + /* mii_queue_relink is called in interrupt context from mii_link_interrupt */ +@@ -1429,15 +2035,14 @@ phy_cmd_t const phy_cmd_config[] = { + static void + mii_discover_phy3(uint mii_reg, struct net_device *dev) + { +- struct fec_enet_private *fep; ++ struct fec_enet_private *fep = netdev_priv(dev); + int i; + +- fep = netdev_priv(dev); + fep->phy_id |= (mii_reg & 0xffff); + printk("fec: PHY @ 0x%x, ID 0x%08x", fep->phy_addr, fep->phy_id); + +- for(i = 0; phy_info[i]; i++) { +- if(phy_info[i]->id == (fep->phy_id >> 4)) ++ for (i = 0; phy_info[i]; i++) { ++ if (phy_info[i]->id == (fep->phy_id >> 4)) + break; + } + +@@ -1456,13 +2061,9 @@ mii_discover_phy3(uint mii_reg, struct n + static void + mii_discover_phy(uint mii_reg, struct net_device *dev) + { +- struct fec_enet_private *fep; +- volatile fec_t *fecp; ++ struct fec_enet_private *fep = netdev_priv(dev); + uint phytype; + +- fep = netdev_priv(dev); +- fecp = fep->hwp; +- + if (fep->phy_addr < 32) { + if ((phytype = (mii_reg & 0xffff)) != 0xffff && phytype != 0) { + +@@ -1470,39 +2071,40 @@ mii_discover_phy(uint mii_reg, struct ne + */ + fep->phy_id = phytype << 16; + mii_queue(dev, mk_mii_read(MII_REG_PHYIR2), +- mii_discover_phy3); ++ mii_discover_phy3); + } else { + fep->phy_addr++; + mii_queue(dev, mk_mii_read(MII_REG_PHYIR1), +- mii_discover_phy); ++ mii_discover_phy); + } + } else { + printk("FEC: No PHY device found.\n"); + /* Disable external MII interface */ +- fecp->fec_mii_speed = fep->phy_speed = 0; +-#ifdef HAVE_mii_link_interrupt +- fec_disable_phy_intr(); +-#endif ++ fec_disable_phy_intr(fep); ++ fec_reg_write(fep, FEC_MSCR, 0); + } + } ++#endif + +-/* This interrupt occurs when the PHY detects a link change. +-*/ +-#ifdef HAVE_mii_link_interrupt ++#ifndef CONFIG_PHYLIB + static irqreturn_t +-mii_link_interrupt(int irq, void * dev_id) ++mii_link_interrupt(int irq, void *dev_id) + { +- struct net_device *dev = dev_id; ++ struct net_device *dev = dev_id; + struct fec_enet_private *fep = netdev_priv(dev); + +- fec_phy_ack_intr(); ++ DBG(0, "%s: \n", __FUNCTION__); + +-#if 0 +- disable_irq(fep->mii_irq); /* disable now, enable later */ +-#endif ++ fec_phy_ack_intr(fep); + +- mii_do_cmd(dev, fep->phy->ack_int); +- mii_do_cmd(dev, phy_cmd_relink); /* restart and display status */ ++ /* ++ * Some board will trigger phy interrupt before phy enable. ++ * And at that moment , fep->phy is not initialized. ++ */ ++ if (fep->phy) { ++ mii_do_cmd(dev, fep->phy->ack_int); ++ mii_do_cmd(dev, phy_cmd_relink); /* restart and display status */ ++ } + + return IRQ_HANDLED; + } +@@ -1511,16 +2113,31 @@ mii_link_interrupt(int irq, void * dev_i + static int + fec_enet_open(struct net_device *dev) + { ++ int ret = 0; + struct fec_enet_private *fep = netdev_priv(dev); + + /* I should reset the ring buffers here, but I don't yet know + * a simple way to do that. + */ +- fec_set_mac_address(dev); ++ DBG(0, "%s: \n", __FUNCTION__); ++ _fec_set_mac_address(dev); + +- fep->sequence_done = 0; +- fep->link = 0; ++#ifdef CONFIG_PHYLIB ++ fec_restart(dev, 0); + ++ ret = fec_connect_phy(dev, fep); ++ if (ret != 0) { ++ DBG(0, "%s: Failed to connect to PHY: %d\n", __FUNCTION__, ret); ++ return ret; ++ } ++ phy_start(fep->phy); ++ ++ fep->linkstatus = fep->phy->link; ++ //fec_restart(dev, 0); ++ DBG(0, "%s: Link status is: %d\n", __FUNCTION__, fep->linkstatus); ++#else ++ fep->linkstatus = 0; ++ fep->sequence_done = 0; + if (fep->phy) { + mii_do_cmd(dev, fep->phy->ack_int); + mii_do_cmd(dev, fep->phy->config); +@@ -1542,16 +2159,20 @@ fec_enet_open(struct net_device *dev) + * based on this device does not implement a PHY interrupt, + * so we are never notified of link change. + */ +- fep->link = 1; ++ fep->linkstatus = 1; + } else { +- fep->link = 1; /* lets just try it and see */ ++ fep->linkstatus = 1; /* lets just try it and see */ + /* no phy, go full duplex, it's most likely a hub chip */ + fec_restart(dev, 1); + } +- +- netif_start_queue(dev); ++ fep->old_linkstatus = fep->linkstatus; ++#endif + fep->opened = 1; +- return 0; /* Success */ ++#if 1 ++ /* enable receiver */ ++ fec_reg_write(fep, FEC_RDAR, DONT_CARE); ++#endif ++ return ret; + } + + static int +@@ -1559,15 +2180,46 @@ fec_enet_close(struct net_device *dev) + { + struct fec_enet_private *fep = netdev_priv(dev); + +- /* Don't know what to do yet. +- */ ++ DBG(0, "%s: \n", __FUNCTION__); ++ + fep->opened = 0; +- netif_stop_queue(dev); +- fec_stop(dev); ++ if (fep->linkstatus) { ++ fec_stop(dev); ++ } ++#ifdef CONFIG_PHYLIB ++ if (fep->phy) { ++ DBG(0, "%s: Stopping PHY %p\n", __FUNCTION__, fep->phy); ++ phy_stop(fep->phy); + ++ DBG(0, "%s: Disconnecting PHY %p\n", __FUNCTION__, fep->phy); ++ phy_disconnect(fep->phy); ++ fep->phy = NULL; ++ } ++#endif ++#if 1 ++ /* Whack a reset. We should wait for this. ++ */ ++ fec_reg_write(fep, FEC_ECR, FEC_ECR_RESET); ++ udelay(10); ++ ++ /* Mask and clear outstanding MII command interrupts. ++ */ ++ fec_reg_write(fep, FEC_EIMR, 0); ++ fec_reg_write(fep, FEC_EIR, FEC_ENET_MII); ++ fec_disable_phy_intr(fep); ++ /* Switch off MII */ ++ fec_reg_write(fep, FEC_MSCR, 0); ++#endif + return 0; + } + ++static struct net_device_stats *fec_enet_get_stats(struct net_device *dev) ++{ ++ struct fec_enet_private *fep = netdev_priv(dev); ++ ++ return &fep->stats; ++} ++ + /* Set or clear the multicast filter for this adaptor. + * Skeleton taken from sunlance driver. + * The CPM Ethernet implementation allows Multicast as well as individual +@@ -1583,37 +2235,32 @@ fec_enet_close(struct net_device *dev) + + static void set_multicast_list(struct net_device *dev) + { +- struct fec_enet_private *fep; +- volatile fec_t *ep; ++ struct fec_enet_private *fep = netdev_priv(dev); + struct dev_mc_list *dmi; + unsigned int i, j, bit, data, crc; + unsigned char hash; + +- fep = netdev_priv(dev); +- ep = fep->hwp; +- +- if (dev->flags&IFF_PROMISC) { +- ep->fec_r_cntrl |= 0x0008; ++ if (dev->flags & IFF_PROMISC) { ++ fec_reg_write(fep, FEC_RCR, fec_reg_read(fep, FEC_RCR) | RCR_PROM); + } else { + +- ep->fec_r_cntrl &= ~0x0008; ++ fec_reg_write(fep, FEC_RCR, fec_reg_read(fep, FEC_RCR) & ~RCR_PROM); + + if (dev->flags & IFF_ALLMULTI) { + /* Catch all multicast addresses, so set the + * filter to all 1's. + */ +- ep->fec_grp_hash_table_high = 0xffffffff; +- ep->fec_grp_hash_table_low = 0xffffffff; ++ fec_reg_write(fep, FEC_IAUR, ~0); ++ fec_reg_write(fep, FEC_IALR, ~0); + } else { + /* Clear filter and add the addresses in hash register. + */ +- ep->fec_grp_hash_table_high = 0; +- ep->fec_grp_hash_table_low = 0; ++ fec_reg_write(fep, FEC_IAUR, 0); ++ fec_reg_write(fep, FEC_IALR, 0); + + dmi = dev->mc_list; + +- for (j = 0; j < dev->mc_count; j++, dmi = dmi->next) +- { ++ for (j = 0; j < dev->mc_count; j++, dmi = dmi->next) { + /* Only support group multicast for now. + */ + if (!(dmi->dmi_addr[0] & 1)) +@@ -1621,13 +2268,11 @@ static void set_multicast_list(struct ne + + /* calculate crc32 value of mac address + */ +- crc = 0xffffffff; ++ crc = ~0; + +- for (i = 0; i < dmi->dmi_addrlen; i++) +- { ++ for (i = 0; i < dmi->dmi_addrlen; i++) { + data = dmi->dmi_addr[i]; +- for (bit = 0; bit < 8; bit++, data >>= 1) +- { ++ for (bit = 0; bit < 8; bit++, data >>= 1) { + crc = (crc >> 1) ^ + (((crc ^ data) & 1) ? CRC32_POLY : 0); + } +@@ -1639,9 +2284,13 @@ static void set_multicast_list(struct ne + hash = (crc >> (32 - HASH_BITS)) & 0x3f; + + if (hash > 31) +- ep->fec_grp_hash_table_high |= 1 << (hash - 32); ++ fec_reg_write(fep, FEC_IAUR, ++ fec_reg_read(fep, FEC_IAUR) | ++ (1 << (hash - 32))); + else +- ep->fec_grp_hash_table_low |= 1 << hash; ++ fec_reg_write(fep, FEC_IALR, ++ fec_reg_read(fep, FEC_IALR) | ++ (1 << hash)); + } + } + } +@@ -1650,106 +2299,272 @@ static void set_multicast_list(struct ne + /* Set a MAC change in hardware. + */ + static void +-fec_set_mac_address(struct net_device *dev) ++_fec_set_mac_address(struct net_device *dev) + { +- volatile fec_t *fecp; +- +- fecp = ((struct fec_enet_private *)netdev_priv(dev))->hwp; ++ struct fec_enet_private *fep = netdev_priv(dev); + + /* Set station address. */ +- fecp->fec_addr_low = dev->dev_addr[3] | (dev->dev_addr[2] << 8) | +- (dev->dev_addr[1] << 16) | (dev->dev_addr[0] << 24); +- fecp->fec_addr_high = (dev->dev_addr[5] << 16) | +- (dev->dev_addr[4] << 24); ++ fec_reg_write(fep, FEC_PALR, dev->dev_addr[3] | (dev->dev_addr[2] << 8) | ++ (dev->dev_addr[1] << 16) | (dev->dev_addr[0] << 24)); ++ fec_reg_write(fep, FEC_PAUR, (dev->dev_addr[5] << 16) | ++ (dev->dev_addr[4] << 24)); ++} ++ ++static int ++fec_set_mac_address(struct net_device *dev, void *_addr) ++{ ++ struct sockaddr *addr = _addr; ++ ++ if (!is_valid_ether_addr((const char *)&addr->sa_data)) { ++ printk(KERN_WARNING "Bad ethernet address: %02x:%02x:%02x:%02x:%02x:%02x\n", ++ addr->sa_data[0], addr->sa_data[1], addr->sa_data[2], addr->sa_data[3], ++ addr->sa_data[4], addr->sa_data[5]); ++ return -EINVAL; ++ } ++ printk(KERN_DEBUG "Setting MAC address to %02x:%02x:%02x:%02x:%02x:%02x\n", ++ addr->sa_data[0], addr->sa_data[1], addr->sa_data[2], addr->sa_data[3], ++ addr->sa_data[4], addr->sa_data[5]); ++ ++ memcpy(&dev->dev_addr, &addr->sa_data, ETH_ALEN); + ++ _fec_set_mac_address(dev); ++ ++ return 0; + } + +- /* +- * XXX: We need to clean up on failure exits here. +- * +- * index is only used in legacy code +- */ +-int __init fec_enet_init(struct net_device *dev, int index) ++static void fec_enet_free_buffers(struct fec_enet_private *fep) ++{ ++ cbd_t *bdp = fep->rx_bd_base; ++ int i; ++ ++ DBG(0, "%s: Freeing TX bounce buffers %p\n", __FUNCTION__, fep->tx_bounce[0]); ++ kfree(fep->tx_bounce[0]); ++ memset(fep->tx_bounce, 0, TX_RING_SIZE * sizeof(void*)); ++ for (i = 0; i < RX_RING_SIZE; i++, bdp++) { ++ if (fep->rx_skbuff[i] != NULL) { ++ DBG(0, "%s: Freeing RX skb %p\n", __FUNCTION__, fep->rx_skbuff[i]); ++ fec_enet_rxbuf_unmap(fep, bdp, FEC_ENET_RX_FRSIZE); ++ kfree_skb(fep->rx_skbuff[i]); ++ fep->rx_skbuff[i] = NULL; ++ } ++ } ++} ++ ++#ifdef CONFIG_PHYLIB ++/* called by the generic PHY layer in interrupt context */ ++static int phy_regs[32] = { [0 ... ARRAY_SIZE(phy_regs) - 1] = -1}; ++static int fec_mii_read(struct mii_bus *bus, int phy_id, int regnum) + { ++ int ret; ++ struct net_device *dev = bus->priv; + struct fec_enet_private *fep = netdev_priv(dev); +- unsigned long mem_addr; +- volatile cbd_t *bdp; +- cbd_t *cbd_base; +- volatile fec_t *fecp; +- int i, j; ++ unsigned long regval = mk_mii_read(regnum) | phy_id << 23; ++ unsigned long flags; ++ int loops = 0; + +- /* Allocate memory for buffer descriptors. +- */ +- mem_addr = (unsigned long)dma_alloc_coherent(NULL, PAGE_SIZE, +- &fep->bd_dma, GFP_KERNEL); +- if (mem_addr == 0) { +- printk("FEC: allocate descriptor memory failed?\n"); ++ DBG(1, "%s: \n", __FUNCTION__); ++#if 0 ++ DBG(0, "%s: ECR: %08lx\n", __FUNCTION__, fec_reg_read(fep, FEC_ECR)); ++ DBG(0, "%s: EIR: %08lx\n", __FUNCTION__, fec_reg_read(fep, FEC_EIR)); ++ DBG(0, "%s: EIMR: %08lx\n", __FUNCTION__, fec_reg_read(fep, FEC_EIMR)); ++ DBG(0, "%s: RCR: %08lx\n", __FUNCTION__, fec_reg_read(fep, FEC_RCR)); ++ DBG(0, "%s: TCR: %08lx\n", __FUNCTION__, fec_reg_read(fep, FEC_TCR)); ++#endif ++ spin_lock_irqsave(&fep->lock, flags); ++ fep->mii_complete = 0; ++ fec_reg_write(fep, FEC_MMFR, regval); ++ spin_unlock_irqrestore(&fep->lock, flags); ++ ++ while (!fep->mii_complete) { ++ if (loops++ == 1000) { ++ DBG(1, "%s: Waiting for MII completion\n", __FUNCTION__); ++ } ++ cpu_relax(); ++ } ++ if (loops >= 1000) { ++ DBG(1, "%s: MII transaction completed\n", __FUNCTION__); ++ } ++ ret = fec_reg_read(fep, FEC_MMFR); ++ if (ret < 0) { ++ DBG(0, "%s: Failed to read PHY[%02x] reg %02x: %d\n", __FUNCTION__, ++ phy_id, regnum, ret); ++ return ret; ++ } ++ ret &= 0xffff; ++ if (phy_regs[regnum] != ret) { ++ DBG(1, "%s: Read %04x from PHY[%02x] reg %02x\n", __FUNCTION__, ++ ret, phy_id, regnum); ++ phy_regs[regnum] = ret; ++ } ++ return ret; ++} ++ ++static int fec_mii_write(struct mii_bus *bus, int phy_id, int regnum, u16 val) ++{ ++ struct net_device *dev = bus->priv; ++ struct fec_enet_private *fep = netdev_priv(dev); ++ unsigned long regval = mk_mii_write(regnum, val) | phy_id << 23; ++ unsigned long flags; ++ ++ DBG(0, "%s: \n", __FUNCTION__); ++ ++ spin_lock_irqsave(&fep->lock, flags); ++ fep->mii_complete = 0; ++ fec_reg_write(fep, FEC_MMFR, regval); ++ spin_unlock_irqrestore(&fep->lock, flags); ++ ++ while (!fep->mii_complete) { ++ cpu_relax(); ++ } ++ DBG(1, "%s: Wrote %04x to PHY[%02x] reg %02x\n", __FUNCTION__, val, phy_id, regnum); ++ return 0; ++} ++ ++static int fec_mii_reset(struct mii_bus *bus) ++{ ++ DBG(0, "%s: \n", __FUNCTION__); ++ memset(phy_regs, -1, sizeof(phy_regs)); ++ return 0; ++} ++ ++static int fec_init_phy(struct net_device *dev, struct fec_enet_private *fep) ++{ ++ int ret; ++ int i; ++ struct mii_bus *mii; ++ ++ mii = mdiobus_alloc(); ++ if (mii == NULL) { + return -ENOMEM; + } ++ mii->name = "fec mii"; ++ mii->read = fec_mii_read; ++ mii->write = fec_mii_write; ++ mii->reset = fec_mii_reset; ++ mii->priv = dev; ++ snprintf(mii->id, MII_BUS_ID_SIZE, "%x", 0); ++ mii->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); ++ for (i = 0; i < PHY_MAX_ADDR; i++) { ++ mii->irq[i] = fep->mii_irq >= 0 ? fep->mii_irq : PHY_POLL; ++ } ++ ++ ret = mdiobus_register(mii); ++ if (ret != 0) { ++ DBG(0, "%s: Failed to register MII bus: %d\n", __FUNCTION__, ret); ++ kfree(mii->irq); ++ mdiobus_free(mii); ++ return ret; ++ } ++ fep->phy_addr = -1; ++ DBG(0, "%s: MII bus registered\n", __FUNCTION__); ++ for (i = 0; i < PHY_MAX_ADDR; i++) { ++ if (mii->phy_map[i] != NULL) { ++ fep->phy_addr = i; ++ break; ++ } ++ } ++ if (fep->phy_addr == -1) { ++ DBG(0, "%s: No PHY found\n", __FUNCTION__); ++ return -ENODEV; ++ } ++ DBG(0, "%s: Using PHY at addr %02x\n", __FUNCTION__, fep->phy_addr); ++ fep->mii = mii; + +- spin_lock_init(&fep->hw_lock); +- spin_lock_init(&fep->mii_lock); ++ return 0; ++} + +- /* Create an Ethernet device instance. +- */ +- fecp = (volatile fec_t *)dev->base_addr; ++static int fec_connect_phy(struct net_device *dev, struct fec_enet_private *fep) ++{ ++ struct mii_bus *mii = fep->mii; + +- fep->index = index; +- fep->hwp = fecp; +- fep->netdev = dev; ++ DBG(0, "%s: Connecting PHY at addr %02x\n", __FUNCTION__, ++ fep->phy_addr); + +- /* Whack a reset. We should wait for this. +- */ +- fecp->fec_ecntrl = 1; +- udelay(10); ++ fep->phy = phy_connect(dev, dev_name(&mii->phy_map[fep->phy_addr]->dev), ++ fec_link_change, 0, mii->phy_map[fep->phy_addr]->interface); ++ if (IS_ERR(fep->phy)) { ++ int ret = PTR_ERR(fep->phy); ++ printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); ++ fep->phy = NULL; ++ return ret; ++ } ++ DBG(0, "%s: Registered PHY %s[%02x] IRQ %d with %s\n", __FUNCTION__, ++ dev_name(&fep->phy->dev), fep->phy_addr, fep->phy->irq, dev->name); + +- /* Set the Ethernet address */ +-#ifdef CONFIG_M5272 +- fec_get_mac(dev); ++ return 0; ++} + #else +- { +- unsigned long l; +- l = fecp->fec_addr_low; +- dev->dev_addr[0] = (unsigned char)((l & 0xFF000000) >> 24); +- dev->dev_addr[1] = (unsigned char)((l & 0x00FF0000) >> 16); +- dev->dev_addr[2] = (unsigned char)((l & 0x0000FF00) >> 8); +- dev->dev_addr[3] = (unsigned char)((l & 0x000000FF) >> 0); +- l = fecp->fec_addr_high; +- dev->dev_addr[4] = (unsigned char)((l & 0xFF000000) >> 24); +- dev->dev_addr[5] = (unsigned char)((l & 0x00FF0000) >> 16); +- } ++static int fec_init_phy(struct net_device *dev, struct fec_enet_private *fep) ++{ ++ /* Queue up command to detect the PHY and initialize the ++ * remainder of the interface. ++ */ ++ fep->phy_id_done = 0; ++ fep->phy_addr = 0; ++ mii_queue(dev, mk_mii_read(MII_REG_PHYIR1), mii_discover_phy); ++ ++ return 0; ++} + #endif + +- cbd_base = (cbd_t *)mem_addr; ++/* Initialize the FEC Ethernet on 860T (or ColdFire 5272). ++ */ ++ /* ++ * XXX: We need to clean up on failure exits here. ++ */ + +- /* Set receive and transmit descriptor base. ++int __devinit fec_enet_init(struct platform_device *pdev, struct net_device *dev) ++{ ++ int ret; ++ struct fec_enet_private *fep = netdev_priv(dev); ++ cbd_t *bdp; ++ struct sk_buff *pskb; ++ int i; ++ void *mem; ++ ++ spin_lock_init(&fep->lock); ++ ++ /* Whack a reset. We should wait for this. + */ +- fep->rx_bd_base = cbd_base; +- fep->tx_bd_base = cbd_base + RX_RING_SIZE; ++ fec_reg_write(fep, FEC_ECR, FEC_ECR_RESET); ++ udelay(10); ++ ++ /* Set the Ethernet address. If using multiple Enets on the 8xx, ++ * this needs some work to get unique addresses. ++ * ++ * This is our default MAC address unless the user changes ++ * it via eth_mac_addr (our dev->set_mac_addr handler). ++ */ ++ fec_get_mac(dev); + + fep->dirty_tx = fep->cur_tx = fep->tx_bd_base; + fep->cur_rx = fep->rx_bd_base; + + fep->skb_cur = fep->skb_dirty = 0; + +- /* Initialize the receive buffer descriptors. ++ /* allocate memory for TX bounce buffers */ ++ mem = kzalloc(TX_RING_SIZE * FEC_ENET_TX_FRSIZE, GFP_KERNEL); ++ if (mem == NULL) { ++ return -ENOMEM; ++ } ++ ++ fec_enet_cbd_get(fep); ++ ++ /* Initialize the transmit buffer descriptors. + */ +- bdp = fep->rx_bd_base; +- for (i=0; itx_bd_base; + +- /* Allocate a page. +- */ +- mem_addr = __get_free_page(GFP_KERNEL); +- /* XXX: missing check for allocation failure */ ++ DBG(0, "%s: Allocated %d byte of TX buffer memory @ %p\n", __FUNCTION__, ++ TX_RING_SIZE * FEC_ENET_TX_FRSIZE, mem); ++ for (i = 0; i < TX_RING_SIZE; i++) { ++ fep->tx_bounce[i] = mem; ++ DBG(0, "%s: TX bounce buffer[%d]=%p\n", __FUNCTION__, i, fep->tx_bounce[i]); ++ mem = (void *)((unsigned long)(mem + FEC_ENET_TX_FRSIZE)); + + /* Initialize the BD for every fragment in the page. + */ +- for (j=0; jcbd_sc = BD_ENET_RX_EMPTY; +- bdp->cbd_bufaddr = __pa(mem_addr); +- mem_addr += FEC_ENET_RX_FRSIZE; +- bdp++; +- } ++ bdp->cbd_bufaddr = ~0; ++ bdp++; + } + + /* Set the last buffer to wrap. +@@ -1757,87 +2572,88 @@ int __init fec_enet_init(struct net_devi + bdp--; + bdp->cbd_sc |= BD_SC_WRAP; + +- /* ...and the same for transmmit. ++ /* ...and the same for receive. + */ +- bdp = fep->tx_bd_base; +- for (i=0, j=FEC_ENET_TX_FRPPG; i= FEC_ENET_TX_FRPPG) { +- mem_addr = __get_free_page(GFP_KERNEL); +- j = 1; +- } else { +- mem_addr += FEC_ENET_TX_FRSIZE; +- j++; ++ bdp = fep->rx_bd_base; ++ for (i = 0; i < RX_RING_SIZE; i++, bdp++) { ++ pskb = __dev_alloc_skb(FEC_ENET_RX_FRSIZE, GFP_KERNEL); ++ if (pskb == NULL) { ++ DBG(0, "%s: Failed to allocate RX skb; cleaning up\n", __FUNCTION__); ++ ret = -ENOMEM; ++ goto cleanup; + } +- fep->tx_bounce[i] = (unsigned char *) mem_addr; +- +- /* Initialize the BD for every fragment in the page. +- */ +- bdp->cbd_sc = 0; +- bdp->cbd_bufaddr = 0; +- bdp++; ++ DBG(0, "%s: RX skb allocated @ %p\n", __FUNCTION__, pskb); ++ fep->rx_skbuff[i] = pskb; ++ pskb->data = FEC_ADDR_ALIGNMENT(pskb->data); ++ bdp->cbd_sc = BD_ENET_RX_EMPTY; ++ bdp->cbd_bufaddr = ~0; ++ fec_enet_rxbuf_map(fep, bdp, pskb->data, FEC_ENET_RX_FRSIZE); + } +- + /* Set the last buffer to wrap. + */ + bdp--; + bdp->cbd_sc |= BD_SC_WRAP; ++ fec_enet_cbd_put(fep); + + /* Set receive and transmit descriptor base. + */ +- fecp->fec_r_des_start = fep->bd_dma; +- fecp->fec_x_des_start = (unsigned long)fep->bd_dma + sizeof(cbd_t) +- * RX_RING_SIZE; +- +-#ifdef HAVE_mii_link_interrupt +- fec_request_mii_intr(dev); +-#endif +- +- fecp->fec_grp_hash_table_high = 0; +- fecp->fec_grp_hash_table_low = 0; +- fecp->fec_r_buff_size = PKT_MAXBLR_SIZE; +- fecp->fec_ecntrl = 2; +- fecp->fec_r_des_active = 0; +-#ifndef CONFIG_M5272 +- fecp->fec_hash_table_high = 0; +- fecp->fec_hash_table_low = 0; +-#endif ++ fec_reg_write(fep, FEC_ERDSR, fep->cbd_phys_base); ++ fec_reg_write(fep, FEC_ETDSR, fep->cbd_phys_base + RX_RING_SIZE * sizeof(cbd_t)); + ++ /* Install our interrupt handlers. This varies depending on ++ * the architecture. ++ */ ++ ret = fec_request_intrs(pdev, dev); ++ if (ret != 0) { ++ goto cleanup; ++ } ++ /* Clear and enable interrupts */ ++ fec_reg_write(fep, FEC_EIR, fec_reg_read(fep, FEC_EIR)); ++ fec_reg_write(fep, FEC_EIMR, FEC_ENET_TXF | FEC_ENET_TXB | ++ FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII); ++ ++ fec_reg_write(fep, FEC_IAUR, 0); ++ fec_reg_write(fep, FEC_IALR, 0); ++ fec_reg_write(fep, FEC_EMRBR, PKT_MAXBLR_SIZE); ++ fec_reg_write(fep, FEC_ECR, FEC_ECR_ETHER_EN); ++ fec_localhw_setup(dev); ++#if 0 ++ /* do this in enet_open()! */ ++ fec_reg_write(fep, FEC_RDAR, DONT_CARE); ++#endif + /* The FEC Ethernet specific entries in the device structure. */ + dev->open = fec_enet_open; + dev->hard_start_xmit = fec_enet_start_xmit; + dev->tx_timeout = fec_timeout; + dev->watchdog_timeo = TX_TIMEOUT; + dev->stop = fec_enet_close; ++ dev->get_stats = fec_enet_get_stats; + dev->set_multicast_list = set_multicast_list; ++ dev->set_mac_address = fec_set_mac_address; + +- for (i=0; ifec_r_cntrl = OPT_FRAME_SIZE | 0x04; +- fecp->fec_x_cntrl = 0x00; +- +- /* +- * Set MII speed to 2.5 MHz +- */ +- fep->phy_speed = ((((clk_get_rate(fep->clk) / 2 + 4999999) +- / 2500000) / 2) & 0x3F) << 1; +- fecp->fec_mii_speed = fep->phy_speed; +- fec_restart(dev, 0); +- +- /* Clear and enable interrupts */ +- fecp->fec_ievent = 0xffc00000; +- fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_RXF | FEC_ENET_MII); +- +- /* Queue up command to detect the PHY and initialize the +- * remainder of the interface. +- */ +- fep->phy_id_done = 0; +- fep->phy_addr = 0; +- mii_queue(dev, mk_mii_read(MII_REG_PHYIR1), mii_discover_phy); ++ ret = fec_set_mii(dev, fep); ++ if (ret) { ++ DBG(0, "%s: Failed to initialize MII interface: %d\n", __FUNCTION__, ret); ++ goto cleanup; ++ } + ++ ret = fec_init_phy(dev, fep); ++ if (ret) { ++ DBG(0, "%s: Failed to initialize PHY: %d\n", __FUNCTION__, ret); ++ goto cleanup; ++ } + return 0; ++ cleanup: ++ fec_enet_free_buffers(fep); ++ fec_enet_cbd_put(fep); ++ return ret; + } + + /* This function is called to start or restart the FEC during a link +@@ -1847,60 +2663,67 @@ int __init fec_enet_init(struct net_devi + static void + fec_restart(struct net_device *dev, int duplex) + { +- struct fec_enet_private *fep; +- volatile cbd_t *bdp; +- volatile fec_t *fecp; ++ struct fec_enet_private *fep = netdev_priv(dev); ++ cbd_t *bdp; + int i; ++ u32 rcr = OPT_FRAME_SIZE | RCR_MII_MODE; /* MII enable */ ++ u32 tcr = TCR_HBC; + +- fep = netdev_priv(dev); +- fecp = fep->hwp; +- ++ DBG(0, "%s: Restarting FEC in %s-duplex mode\n", __FUNCTION__, ++ duplex ? "full" : "half"); + /* Whack a reset. We should wait for this. +- */ +- fecp->fec_ecntrl = 1; ++ */ ++ fec_reg_write(fep, FEC_ECR, FEC_ECR_RESET); + udelay(10); + ++ /* Enable interrupts we wish to service. ++ */ ++ fec_reg_write(fep, FEC_EIMR, FEC_ENET_TXF | FEC_ENET_TXB | ++ FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII); ++ + /* Clear any outstanding interrupt. +- */ +- fecp->fec_ievent = 0xffc00000; ++ * ++ */ ++ fec_reg_write(fep, FEC_EIR, FEC_ENET_MASK); ++ ++ fec_enable_phy_intr(fep); + + /* Set station address. +- */ +- fec_set_mac_address(dev); ++ */ ++ _fec_set_mac_address(dev); + + /* Reset all multicast. +- */ +- fecp->fec_grp_hash_table_high = 0; +- fecp->fec_grp_hash_table_low = 0; ++ */ ++ fec_reg_write(fep, FEC_IAUR, 0); ++ fec_reg_write(fep, FEC_IALR, 0); + + /* Set maximum receive buffer size. +- */ +- fecp->fec_r_buff_size = PKT_MAXBLR_SIZE; ++ */ ++ fec_reg_write(fep, FEC_EMRBR, PKT_MAXBLR_SIZE); + + /* Set receive and transmit descriptor base. +- */ +- fecp->fec_r_des_start = fep->bd_dma; +- fecp->fec_x_des_start = (unsigned long)fep->bd_dma + sizeof(cbd_t) +- * RX_RING_SIZE; ++ */ ++ fec_reg_write(fep, FEC_ERDSR, fep->cbd_phys_base); ++ fec_reg_write(fep, FEC_ETDSR, fep->cbd_phys_base + RX_RING_SIZE * sizeof(cbd_t)); + + fep->dirty_tx = fep->cur_tx = fep->tx_bd_base; + fep->cur_rx = fep->rx_bd_base; + + /* Reset SKB transmit buffers. +- */ ++ */ + fep->skb_cur = fep->skb_dirty = 0; +- for (i=0; i<=TX_RING_MOD_MASK; i++) { ++ bdp = fep->tx_bd_base; ++ for (i = 0; i <= TX_RING_MOD_MASK; i++) { + if (fep->tx_skbuff[i] != NULL) { +- dev_kfree_skb_any(fep->tx_skbuff[i]); +- fep->tx_skbuff[i] = NULL; ++ fec_free_skb(fep, bdp, &fep->tx_skbuff[i]); ++ bdp++; + } + } + + /* Initialize the receive buffer descriptors. +- */ ++ */ + bdp = fep->rx_bd_base; +- for (i=0; icbd_sc = BD_ENET_RX_EMPTY; +@@ -1908,246 +2731,366 @@ fec_restart(struct net_device *dev, int + } + + /* Set the last buffer to wrap. +- */ ++ */ + bdp--; + bdp->cbd_sc |= BD_SC_WRAP; + + /* ...and the same for transmmit. +- */ ++ */ + bdp = fep->tx_bd_base; +- for (i=0; icbd_sc = 0; +- bdp->cbd_bufaddr = 0; ++ bdp->cbd_bufaddr = ~0; + bdp++; + } + + /* Set the last buffer to wrap. +- */ ++ */ + bdp--; + bdp->cbd_sc |= BD_SC_WRAP; + + /* Enable MII mode. +- */ ++ */ + if (duplex) { +- fecp->fec_r_cntrl = OPT_FRAME_SIZE | 0x04;/* MII enable */ +- fecp->fec_x_cntrl = 0x04; /* FD enable */ ++ tcr |= TCR_FDEN; /* FD enable */ + } else { +- /* MII enable|No Rcv on Xmit */ +- fecp->fec_r_cntrl = OPT_FRAME_SIZE | 0x06; +- fecp->fec_x_cntrl = 0x00; ++ rcr |= RCR_DRT; /* No Rcv on Xmit */ + } ++ fec_reg_write(fep, FEC_RCR, rcr); ++ fec_reg_write(fep, FEC_TCR, tcr); + fep->full_duplex = duplex; + + /* Set MII speed. +- */ +- fecp->fec_mii_speed = fep->phy_speed; ++ */ ++ fec_reg_write(fep, FEC_MSCR, fep->phy_speed); + + /* And last, enable the transmit and receive processing. +- */ +- fecp->fec_ecntrl = 2; +- fecp->fec_r_des_active = 0; ++ */ ++ fec_reg_write(fep, FEC_ECR, FEC_ECR_ETHER_EN); ++ fec_localhw_setup(dev); ++ fec_reg_write(fep, FEC_RDAR, DONT_CARE); + +- /* Enable interrupts we wish to service. +- */ +- fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_RXF | FEC_ENET_MII); ++ DBG(0, "%s: Starting netif queue\n", __FUNCTION__); ++ netif_start_queue(dev); + } + + static void + fec_stop(struct net_device *dev) + { +- volatile fec_t *fecp; +- struct fec_enet_private *fep; ++ struct fec_enet_private *fep = netdev_priv(dev); + +- fep = netdev_priv(dev); +- fecp = fep->hwp; ++ DBG(0, "%s: Stopping netif queue\n", __FUNCTION__); ++ netif_stop_queue(dev); + + /* +- ** We cannot expect a graceful transmit stop without link !!! +- */ +- if (fep->link) +- { +- fecp->fec_x_cntrl = 0x01; /* Graceful transmit stop */ ++ * We cannot expect a graceful transmit stop without link! ++ */ ++ if (fep->linkstatus) { ++ fec_reg_write(fep, FEC_TCR, 0x01); /* Graceful transmit stop */ + udelay(10); +- if (!(fecp->fec_ievent & FEC_ENET_GRA)) +- printk("fec_stop : Graceful transmit stop did not complete !\n"); +- } +- ++ if (!(fec_reg_read(fep, FEC_EIR) & FEC_ENET_GRA)) ++ dev_warn(&dev->dev, "Graceful transmit stop did not complete!\n"); ++ } ++#if 0 + /* Whack a reset. We should wait for this. +- */ +- fecp->fec_ecntrl = 1; ++ */ ++ fec_reg_write(fep, FEC_ECR, FEC_ECR_RESET); + udelay(10); +- +- /* Clear outstanding MII command interrupts. +- */ +- fecp->fec_ievent = FEC_ENET_MII; +- +- fecp->fec_imask = FEC_ENET_MII; +- fecp->fec_mii_speed = fep->phy_speed; ++ /* Mask and clear outstanding MII command interrupts. ++ */ ++ fec_reg_write(fep, FEC_EIMR, 0); ++ fec_reg_write(fep, FEC_EIR, FEC_ENET_MII); ++ fec_enable_phy_intr(fep); ++ fec_reg_write(fep, FEC_MSCR, fep->phy_speed); ++#endif + } + +-static int __devinit +-fec_probe(struct platform_device *pdev) ++static int __devinit fec_enet_probe(struct platform_device *pdev) + { ++ int ret; + struct fec_enet_private *fep; +- struct net_device *ndev; +- int i, irq, ret = 0; +- struct resource *r; +- +- r = platform_get_resource(pdev, IORESOURCE_MEM, 0); +- if (!r) +- return -ENXIO; ++ struct net_device *dev; ++ struct fec_enet_platform_data *pdata = pdev->dev.platform_data; ++ struct resource *res_mem1; ++ struct resource *res_mem2; ++ ++ res_mem1 = platform_get_resource(pdev, IORESOURCE_MEM, 0); ++ if (res_mem1 == NULL) { ++ return -ENODEV; ++ } + +- r = request_mem_region(r->start, resource_size(r), pdev->name); +- if (!r) ++ res_mem1 = request_mem_region(res_mem1->start, ++ resource_size(res_mem1), ++ DRV_NAME); ++ if (res_mem1 == NULL) { + return -EBUSY; ++ } ++ res_mem2 = platform_get_resource(pdev, IORESOURCE_MEM, 1); ++ if (res_mem2 != NULL) { ++ res_mem2 = request_mem_region(res_mem2->start, ++ resource_size(res_mem2), ++ DRV_NAME); ++ if (res_mem2 == NULL) { ++ ret = -EBUSY; ++ goto release1; ++ } ++ } + +- /* Init network device */ +- ndev = alloc_etherdev(sizeof(struct fec_enet_private)); +- if (!ndev) +- return -ENOMEM; +- +- SET_NETDEV_DEV(ndev, &pdev->dev); +- +- /* setup board info structure */ +- fep = netdev_priv(ndev); +- memset(fep, 0, sizeof(*fep)); ++ dev = alloc_etherdev(sizeof(struct fec_enet_private)); ++ if (dev == NULL) { ++ ret = -ENOMEM; ++ goto release2; ++ } ++ platform_set_drvdata(pdev, dev); ++ fep = netdev_priv(dev); ++ fep->res_mem1 = res_mem1; ++ fep->res_mem2 = res_mem2; ++ fep->dma_dev = &pdev->dev; ++ ++ fep->reg_base = ioremap(res_mem1->start, resource_size(res_mem1)); ++ if (fep->reg_base == NULL) { ++ printk("FEC: Mapping FEC registers failed\n"); ++ ret = -ENOMEM; ++ goto free_netdev; ++ } ++ DBG(0, "%s: FEC registers @ %08lx mapped to %p\n", __FUNCTION__, ++ (unsigned long)res_mem1->start, fep->reg_base); + +- ndev->base_addr = (unsigned long)ioremap(r->start, resource_size(r)); ++ fep->mib_base = ioremap(res_mem2->start, resource_size(res_mem2)); ++ if (fep->mib_base == NULL) { ++ printk("FEC: Mapping FEC registers failed\n"); ++ ret = -ENOMEM; ++ goto unmap1; ++ } ++ DBG(0, "%s: FEC registers @ %08lx mapped to %p\n", __FUNCTION__, ++ (unsigned long)res_mem2->start, fep->mib_base); + +- if (!ndev->base_addr) { ++ /* Allocate memory for buffer descriptors. */ ++ fep->cbd_mem_base = dma_alloc_coherent(&pdev->dev, CBD_BUF_SIZE, ++ &fep->cbd_phys_base, ++ GFP_KERNEL); ++ if (fep->cbd_mem_base == NULL) { ++ printk("FEC: allocate descriptor memory failed\n"); + ret = -ENOMEM; +- goto failed_ioremap; ++ goto unmap2; + } ++ DBG(0, "%s: Allocated %lu [(%u + %lu) * %d] byte for CBD buffer @ %p[%08lx]\n", ++ __FUNCTION__, CBD_BUF_SIZE, TX_RING_SIZE, RX_RING_SIZE, ++ sizeof(cbd_t), fep->cbd_mem_base, ++ (unsigned long)fep->cbd_phys_base); + +- platform_set_drvdata(pdev, ndev); ++ /* Set receive and transmit descriptor base. ++ */ ++ fep->rx_bd_base = fep->cbd_mem_base; ++ fep->tx_bd_base = fep->rx_bd_base + RX_RING_SIZE; + +- /* This device has up to three irqs on some platforms */ +- for (i = 0; i < 3; i++) { +- irq = platform_get_irq(pdev, i); +- if (i && irq < 0) +- break; +- ret = request_irq(irq, fec_enet_interrupt, IRQF_DISABLED, pdev->name, ndev); +- if (ret) { +- while (i >= 0) { +- irq = platform_get_irq(pdev, i); +- free_irq(irq, ndev); +- i--; +- } +- goto failed_irq; +- } ++ printk("FEC ENET Driver\n"); ++ ret = platform_func(pdata->arch_init, pdev); ++ if (ret != 0) { ++ dev_err(&pdev->dev, "platform init failed: %d\n", ret); ++ goto free_dma; + } + +- fep->clk = clk_get(&pdev->dev, "fec_clk"); +- if (IS_ERR(fep->clk)) { +- ret = PTR_ERR(fep->clk); +- goto failed_clk; ++ ret = fec_enet_init(pdev, dev); ++ if (ret != 0) { ++ goto fec_disable; + } +- clk_enable(fep->clk); + +- ret = fec_enet_init(ndev, 0); +- if (ret) +- goto failed_init; ++ /* Enable most messages by default */ ++ fep->msg_enable = (NETIF_MSG_IFUP << 1) - 1; ++ ret = register_netdev(dev); ++ if (ret != 0) { ++ /* XXX: missing cleanup here */ ++ goto free_buffers; ++ } + +- ret = register_netdev(ndev); +- if (ret) +- goto failed_register; ++ printk(KERN_INFO "%s: ethernet %02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, ++ dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], ++ dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); + + return 0; + +-failed_register: +-failed_init: +- clk_disable(fep->clk); +- clk_put(fep->clk); +-failed_clk: +- for (i = 0; i < 3; i++) { +- irq = platform_get_irq(pdev, i); +- if (irq > 0) +- free_irq(irq, ndev); +- } +-failed_irq: +- iounmap((void __iomem *)ndev->base_addr); +-failed_ioremap: +- free_netdev(ndev); ++ free_buffers: ++ fec_enet_free_buffers(fep); ++ ++ fec_disable: ++ platform_func(pdata->arch_exit, pdev); ++ ++ free_dma: ++ dma_free_coherent(&pdev->dev, CBD_BUF_SIZE, fep->cbd_mem_base, fep->cbd_phys_base); ++ ++ unmap2: ++ if (fep->mib_base) ++ iounmap(fep->mib_base); ++ ++ unmap1: ++ iounmap(fep->reg_base); ++ ++ free_netdev: ++ free_netdev(dev); ++ ++ release2: ++ if (res_mem2 != NULL) { ++ release_resource(res_mem2); ++ } ++ ++ release1: ++ release_resource(res_mem1); + + return ret; + } + +-static int __devexit +-fec_drv_remove(struct platform_device *pdev) ++static int __devexit fec_enet_remove(struct platform_device *pdev) + { +- struct net_device *ndev = platform_get_drvdata(pdev); +- struct fec_enet_private *fep = netdev_priv(ndev); ++ struct net_device *dev = platform_get_drvdata(pdev); ++ struct fec_enet_private *fep = netdev_priv(dev); ++ ++ unregister_netdev(dev); ++ free_netdev(dev); ++ ++#ifdef CONFIG_PHYLIB ++ if (fep->mii != NULL) { ++ kfree(fep->mii->irq); ++ mdiobus_unregister(fep->mii); ++ } ++ mdiobus_free(fep->mii); ++#endif ++ fec_release_intrs(dev); ++ ++ DBG(0, "%s: Unmapping FEC registers %p\n", __FUNCTION__, fep->reg_base); ++ iounmap(fep->reg_base); ++ if (fep->mib_base) ++ iounmap(fep->mib_base); ++ ++ fec_enet_free_buffers(fep); + +- platform_set_drvdata(pdev, NULL); ++ DBG(0, "%s: Freeing CBD buffer area %p[%08lx]\n", __FUNCTION__, ++ fep->cbd_mem_base, (unsigned long)fep->cbd_phys_base); ++ dma_free_coherent(&pdev->dev, CBD_BUF_SIZE, fep->cbd_mem_base, fep->cbd_phys_base); + +- fec_stop(ndev); +- clk_disable(fep->clk); +- clk_put(fep->clk); +- iounmap((void __iomem *)ndev->base_addr); +- unregister_netdev(ndev); +- free_netdev(ndev); ++ release_resource(fep->res_mem1); ++ if (fep->res_mem2 != NULL) { ++ release_resource(fep->res_mem2); ++ } + return 0; + } + +-static int +-fec_suspend(struct platform_device *dev, pm_message_t state) ++static void fec_enet_shutdown(struct platform_device *pdev) + { +- struct net_device *ndev = platform_get_drvdata(dev); +- struct fec_enet_private *fep; ++ struct fec_enet_platform_data *pdata = pdev->dev.platform_data; ++ ++ DBG(0, "%s: Shutting down FEC Hardware\n", __FUNCTION__); ++ platform_func(pdata->arch_exit, pdev); ++} ++ ++#ifdef CONFIG_PM ++static int fec_enet_suspend(struct platform_device *pdev, pm_message_t state) ++{ ++ int ret; ++ struct fec_enet_platform_data *pdata = pdev->dev.platform_data; ++ struct net_device *ndev = platform_get_drvdata(pdev); ++ struct fec_enet_private *fep = netdev_priv(ndev); + +- if (ndev) { +- fep = netdev_priv(ndev); +- if (netif_running(ndev)) { +- netif_device_detach(ndev); +- fec_stop(ndev); ++ if (netif_running(ndev)) { ++ DBG(0, "%s: Detaching netif\n", __FUNCTION__); ++ netif_device_detach(ndev); ++#ifdef CONFIG_PHYLIB ++ DBG(0, "%s: Disconnecting PHY %p\n", __FUNCTION__, fep->phy); ++ phy_disconnect(fep->phy); ++ fep->phy = NULL; ++#endif ++ } ++#ifndef CONFIG_PHYLIB ++ if (fep->phy_timer) { ++ ret = del_timer_sync(fep->phy_timer); ++ if (ret != 0) { ++ DBG(0, "%s: Failed to delete PHY timer: %d\n", __FUNCTION__, ret); ++ return ret; + } + } +- return 0; ++#endif ++ DBG(0, "%s: Shutting down FEC Hardware %d\n", __FUNCTION__, ++ netif_running(ndev)); ++ ret = platform_func(pdata->suspend, pdev); ++ if (ret != 0 && netif_running(ndev)) { ++ DBG(0, "%s: Failed to suspend: %d\n", __FUNCTION__, ret); ++ /* Undo suspend */ ++#ifdef CONFIG_PHYLIB ++ DBG(0, "%s: Reconnecting PHY\n", __FUNCTION__); ++ if (fec_connect_phy(ndev, fep) != 0) { ++ DBG(0, "%s: Failed to connect to PHY\n", __FUNCTION__); ++ return ret; ++ } ++ phy_start(fep->phy); ++#endif ++ fec_link_change(ndev); ++ netif_device_attach(ndev); ++ } ++ return ret; + } + +-static int +-fec_resume(struct platform_device *dev) ++static int fec_enet_resume(struct platform_device *pdev) + { +- struct net_device *ndev = platform_get_drvdata(dev); ++ int ret; ++ struct fec_enet_platform_data *pdata = pdev->dev.platform_data; ++ struct net_device *ndev = platform_get_drvdata(pdev); + +- if (ndev) { +- if (netif_running(ndev)) { +- fec_enet_init(ndev, 0); +- netif_device_attach(ndev); ++ DBG(0, "%s: Powering up FEC Hardware %d\n", __FUNCTION__, ++ netif_running(ndev)); ++ ret = platform_func(pdata->resume, pdev); ++ if (ret != 0) { ++ DBG(0, "%s: Failed to resume: %d\n", __FUNCTION__, ret); ++ return ret; ++ } ++ if (netif_running(ndev)) { ++#ifdef CONFIG_PHYLIB ++ struct fec_enet_private *fep = netdev_priv(ndev); ++ ++ DBG(0, "%s: Reconnecting PHY\n", __FUNCTION__); ++ ret = fec_connect_phy(ndev, fep); ++ if (ret != 0) { ++ DBG(0, "%s: Failed to connect to PHY: %d\n", __FUNCTION__, ret); ++ return ret; + } ++ phy_start(fep->phy); ++#endif ++ fec_link_change(ndev); ++ netif_device_attach(ndev); + } + return 0; + } ++#else ++#define fec_enet_suspend NULL ++#define fec_enet_resume NULL ++#endif + +-static struct platform_driver fec_driver = { +- .driver = { +- .name = "fec", +- .owner = THIS_MODULE, ++static struct platform_driver fec_enet_driver = { ++ .driver = { ++ .name = DRV_NAME, + }, +- .probe = fec_probe, +- .remove = __devexit_p(fec_drv_remove), +- .suspend = fec_suspend, +- .resume = fec_resume, ++ .probe = fec_enet_probe, ++ .remove = __devexit_p(fec_enet_remove), ++ .shutdown = fec_enet_shutdown, ++ .suspend = fec_enet_suspend, ++ .resume = fec_enet_resume, + }; + +-static int __init +-fec_enet_module_init(void) ++static int __init fec_enet_module_init(void) + { +- printk(KERN_INFO "FEC Ethernet Driver\n"); ++ int ret; ++ ++ ret = platform_driver_register(&fec_enet_driver); + +- return platform_driver_register(&fec_driver); ++ return ret; + } ++module_init(fec_enet_module_init); + +-static void __exit +-fec_enet_cleanup(void) ++static void __exit fec_enet_module_cleanup(void) + { +- platform_driver_unregister(&fec_driver); ++ platform_driver_unregister(&fec_enet_driver); + } +- +-module_exit(fec_enet_cleanup); +-module_init(fec_enet_module_init); ++module_exit(fec_enet_module_cleanup); + + MODULE_LICENSE("GPL"); +diff -urNp linux-2.6.30-rc4/drivers/net/fec.h linux-2.6.30-rc4-karo/drivers/net/fec.h +--- linux-2.6.30-rc4/drivers/net/fec.h 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/drivers/net/fec.h 2009-06-02 17:05:27.000000000 +0200 +@@ -13,6 +13,15 @@ + #define FEC_H + /****************************************************************************/ + ++/* ++ * dummy value to write into RDAR,TDAR. FEC hardware will scan the TX/RX ++ * descriptors in memory upon any write access to those registers. ++ * The actual value written to those registers does not matter. ++*/ ++#define DONT_CARE 0 ++#define RDAR_BUSY (1 << 24) ++#define TDAR_BUSY (1 << 24) ++ + #if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \ + defined(CONFIG_M520x) || defined(CONFIG_M532x) || defined(CONFIG_ARCH_MXC) + /* +@@ -20,6 +29,36 @@ + * registers in the same peripheral device on different models + * of the ColdFire! + */ ++// relying on structure alignment for hardware register is just evil ++#ifndef GARBAGE ++#define FEC_EIR 0x004 ++#define FEC_EIMR 0x008 ++#define FEC_RDAR 0x010 ++#define FEC_TDAR 0x014 ++#define FEC_ECR 0x024 ++#define FEC_MMFR 0x040 ++#define FEC_MSCR 0x044 ++#define FEC_MIBC 0x064 ++#define FEC_RCR 0x084 ++#define FEC_TCR 0x0c4 ++#define FEC_PALR 0x0e4 ++#define FEC_PAUR 0x0e8 ++#define FEC_OPD 0x0ec ++#define FEC_IAUR 0x118 ++#define FEC_IALR 0x11c ++#define FEC_GAUR 0x120 ++#define FEC_GALR 0x124 ++#define FEC_TFWR 0x144 ++#define FEC_FRBR 0x14c ++#define FEC_FRSR 0x150 ++#define FEC_ERDSR 0x180 ++#define FEC_ETDSR 0x184 ++#define FEC_EMRBR 0x188 ++ ++#define FEC_ECR_RESET (1 << 0) ++#define FEC_ECR_ETHER_EN (1 << 1) ++#else ++ + typedef struct fec { + unsigned long fec_reserved0; + unsigned long fec_ievent; /* Interrupt event reg */ +@@ -57,6 +96,7 @@ typedef struct fec { + unsigned long fec_x_des_start; /* Transmit descriptor ring */ + unsigned long fec_r_buff_size; /* Maximum receive buff size */ + } fec_t; ++#endif + + #else + +@@ -88,8 +128,8 @@ typedef struct fec { + unsigned long fec_reserved7[158]; + unsigned long fec_addr_low; /* Low 32bits MAC address */ + unsigned long fec_addr_high; /* High 16bits MAC address */ +- unsigned long fec_grp_hash_table_high;/* High 32bits hash table */ +- unsigned long fec_grp_hash_table_low; /* Low 32bits hash table */ ++ unsigned long fec_hash_table_high; /* High 32bits hash table */ ++ unsigned long fec_hash_table_low; /* Low 32bits hash table */ + unsigned long fec_r_des_start; /* Receive descriptor ring */ + unsigned long fec_x_des_start; /* Transmit descriptor ring */ + unsigned long fec_r_buff_size; /* Maximum receive buff size */ +@@ -103,17 +143,20 @@ typedef struct fec { + /* + * Define the buffer descriptor structure. + */ +-#ifdef CONFIG_ARCH_MXC ++/* Please see "Receive Buffer Descriptor Field Definitions" in Specification. ++ * It's LE. ++ */ ++#if defined(CONFIG_ARCH_MXC) + typedef struct bufdesc { +- unsigned short cbd_datlen; /* Data length */ +- unsigned short cbd_sc; /* Control and status info */ +- unsigned long cbd_bufaddr; /* Buffer address */ ++ unsigned short cbd_datlen; /* Data length */ ++ unsigned short cbd_sc; /* Control and status info */ ++ dma_addr_t cbd_bufaddr; /* Buffer address as seen by FEC Hardware */ + } cbd_t; + #else + typedef struct bufdesc { + unsigned short cbd_sc; /* Control and status info */ + unsigned short cbd_datlen; /* Data length */ +- unsigned long cbd_bufaddr; /* Buffer address */ ++ dma_addr_t cbd_bufaddr; /* Buffer address */ + } cbd_t; + #endif + +@@ -121,7 +164,7 @@ typedef struct bufdesc { + * The following definitions courtesy of commproc.h, which where + * Copyright (c) 1997 Dan Malek (dmalek@jlc.net). + */ +-#define BD_SC_EMPTY ((ushort)0x8000) /* Recieve is empty */ ++#define BD_SC_EMPTY ((ushort)0x8000) /* Receive is empty */ + #define BD_SC_READY ((ushort)0x8000) /* Transmit is ready */ + #define BD_SC_WRAP ((ushort)0x2000) /* Last buffer descriptor */ + #define BD_SC_INTRPT ((ushort)0x1000) /* Interrupt on change */ +@@ -168,5 +211,22 @@ typedef struct bufdesc { + #define BD_ENET_TX_STATS ((ushort)0x03ff) /* All status bits */ + + ++#define RCR_LOOP (1 << 0) ++#define RCR_DRT (1 << 1) ++#define RCR_MII_MODE (1 << 2) ++#define RCR_PROM (1 << 3) ++#define RCR_BC_REJ (1 << 4) ++#define RCR_FCE (1 << 5) ++#define RCR_MAX_FL_SHIFT 16 ++#define RCR_MAX_FL_MASK (0x7ff << (RCR_MAX_FL_SHIFT)) ++#define RCR_MAX_FL_set(n) (((n) << (RCR_MAX_FL_SHIFT)) & (RCR_MAX_FL_MASK)) ++#define RCR_MAX_FL_get(n) (((n) & (RCR_MAX_FL_MASK)) >> (RCR_MAX_FL_SHIFT)) ++ ++#define TCR_GTS (1 << 0) ++#define TCR_HBC (1 << 1) ++#define TCR_FDEN (1 << 2) ++#define TCR_TFCPAUSE (1 << 3) ++#define TCR_RFCPAUSE (1 << 4) ++ + /****************************************************************************/ + #endif /* FEC_H */ +diff -urNp linux-2.6.30-rc4/drivers/video/imxfb.c linux-2.6.30-rc4-karo/drivers/video/imxfb.c +--- linux-2.6.30-rc4/drivers/video/imxfb.c 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/drivers/video/imxfb.c 2009-06-02 17:05:26.000000000 +0200 +@@ -570,7 +570,7 @@ static int imxfb_resume(struct platform_ + #define imxfb_resume NULL + #endif + +-static int __init imxfb_init_fbinfo(struct platform_device *pdev) ++static int __devinit imxfb_init_fbinfo(struct platform_device *pdev) + { + struct imx_fb_platform_data *pdata = pdev->dev.platform_data; + struct fb_info *info = dev_get_drvdata(&pdev->dev); +@@ -636,7 +636,7 @@ static int __init imxfb_init_fbinfo(stru + return 0; + } + +-static int __init imxfb_probe(struct platform_device *pdev) ++static int __devinit imxfb_probe(struct platform_device *pdev) + { + struct imxfb_info *fbi; + struct fb_info *info; +@@ -754,7 +754,7 @@ failed_map: + failed_getclock: + iounmap(fbi->regs); + failed_ioremap: +- release_mem_region(res->start, res->end - res->start); ++ release_mem_region(res->start, resource_size(res)); + failed_req: + kfree(info->pseudo_palette); + failed_init: +@@ -763,7 +763,7 @@ failed_init: + return ret; + } + +-static int __devexit imxfb_remove(struct platform_device *pdev) ++static int imxfb_remove(struct platform_device *pdev) + { + struct imx_fb_platform_data *pdata; + struct fb_info *info = platform_get_drvdata(pdev); +@@ -785,7 +785,7 @@ static int __devexit imxfb_remove(struct + framebuffer_release(info); + + iounmap(fbi->regs); +- release_mem_region(res->start, res->end - res->start + 1); ++ release_mem_region(res->start, resource_size(res)); + clk_disable(fbi->clk); + clk_put(fbi->clk); + +@@ -794,7 +794,7 @@ static int __devexit imxfb_remove(struct + return 0; + } + +-void imxfb_shutdown(struct platform_device * dev) ++void imxfb_shutdown(struct platform_device *dev) + { + struct fb_info *info = platform_get_drvdata(dev); + struct imxfb_info *fbi = info->par; +@@ -804,7 +804,8 @@ void imxfb_shutdown(struct platform_dev + static struct platform_driver imxfb_driver = { + .suspend = imxfb_suspend, + .resume = imxfb_resume, +- .remove = __devexit_p(imxfb_remove), ++// .remove = __devexit_p(imxfb_remove), ++ .remove = imxfb_remove, + .shutdown = imxfb_shutdown, + .driver = { + .name = DRIVER_NAME, +diff -urNp linux-2.6.30-rc4/include/linux/fec_enet.h linux-2.6.30-rc4-karo/include/linux/fec_enet.h +--- linux-2.6.30-rc4/include/linux/fec_enet.h 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.6.30-rc4-karo/include/linux/fec_enet.h 2009-06-02 17:05:27.000000000 +0200 +@@ -0,0 +1,26 @@ ++/* ++ * Copyright (C) 2007 Lothar Wassmann ++ * ++ * platform_data definitions for fec_enet device ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * version 2 as published by the Free Software Foundation ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the: ++ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 ++ */ ++ ++struct fec_enet_platform_data { ++ /* callback for platform specific initialization */ ++ int (*arch_init)(struct platform_device *dev); ++ void (*arch_exit)(struct platform_device *dev); ++ int (*suspend)(struct platform_device *dev); ++ int (*resume)(struct platform_device *dev); ++}; +diff -urNp linux-2.6.30-rc4/kernel/printk.c linux-2.6.30-rc4-karo/kernel/printk.c +--- linux-2.6.30-rc4/kernel/printk.c 2009-05-13 09:46:19.000000000 +0200 ++++ linux-2.6.30-rc4-karo/kernel/printk.c 2009-06-02 17:05:27.000000000 +0200 +@@ -637,9 +637,12 @@ static int acquire_console_semaphore_for + static const char recursion_bug_msg [] = + KERN_CRIT "BUG: recent printk recursion!\n"; + static int recursion_bug; +-static int new_text_line = 1; ++ static int new_text_line = 1; + static char printk_buf[1024]; + ++#ifdef CONFIG_DEBUG_LL ++extern void asmlinkage printascii(const char *); ++#endif + asmlinkage int vprintk(const char *fmt, va_list args) + { + int printed_len = 0; +@@ -687,6 +690,9 @@ asmlinkage int vprintk(const char *fmt, + sizeof(printk_buf) - printed_len, fmt, args); + + ++#ifdef CONFIG_DEBUG_LL ++ printascii(printk_buf); ++#endif + /* + * Copy the output into log_buf. If the caller didn't provide + * appropriate log level tags, we insert them here diff --git a/recipes/linux/linux_2.6.30.bb b/recipes/linux/linux_2.6.30.bb index 577b915828..4114de1048 100644 --- a/recipes/linux/linux_2.6.30.bb +++ b/recipes/linux/linux_2.6.30.bb @@ -14,3 +14,6 @@ SRC_URI = "${KERNELORG_MIRROR}/pub/linux/kernel/v2.6/linux-${PV}.tar.bz2 \ file://defconfig" SRC_URI_append_mpc8315e-rdb = " file://mpc8315erdb-add-msi-to-dts.patch;patch=1" + +SRC_URI_append_tx25 = " file://linux-2.6.30-rc4-karo.diff;patch=1" + -- cgit v1.2.3 From 7e4b03d13079c74c6b7dc7d7b53afd1b1cd8c042 Mon Sep 17 00:00:00 2001 From: Florian Boor Date: Fri, 19 Jun 2009 22:44:01 +0200 Subject: linux: Use 2.6.30 for the TX25 --- recipes/linux/linux_2.6.30.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/linux/linux_2.6.30.bb b/recipes/linux/linux_2.6.30.bb index 4114de1048..6dd445ac8e 100644 --- a/recipes/linux/linux_2.6.30.bb +++ b/recipes/linux/linux_2.6.30.bb @@ -7,6 +7,7 @@ S = "${WORKDIR}/linux-${PV}" # Mark archs/machines that this kernel supports DEFAULT_PREFERENCE = "-1" DEFAULT_PREFERENCE_mpc8315e-rdb = "1" +DEFAULT_PREFERENCE_tx25 = "1" COMPATIBLE_MACHINE = "mpc8315e-rdb" @@ -16,4 +17,3 @@ SRC_URI = "${KERNELORG_MIRROR}/pub/linux/kernel/v2.6/linux-${PV}.tar.bz2 \ SRC_URI_append_mpc8315e-rdb = " file://mpc8315erdb-add-msi-to-dts.patch;patch=1" SRC_URI_append_tx25 = " file://linux-2.6.30-rc4-karo.diff;patch=1" - -- cgit v1.2.3 From 1f4f1ed2f1986d50e7de022ffaae4f5688f6aa13 Mon Sep 17 00:00:00 2001 From: Florian Boor Date: Fri, 19 Jun 2009 23:09:12 +0200 Subject: zbar: New recipe for zbar barcode decoder. --- recipes/zbar/zbar_0.8.bb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 recipes/zbar/zbar_0.8.bb diff --git a/recipes/zbar/zbar_0.8.bb b/recipes/zbar/zbar_0.8.bb new file mode 100644 index 0000000000..f971bc3f2b --- /dev/null +++ b/recipes/zbar/zbar_0.8.bb @@ -0,0 +1,25 @@ +DESCRIPTION = "2D barcode scanner toolkit." +SECTION = "graphics" +LICENSE = "GPL" +DEPENDS = "intltool-native gtk+ libpng jpeg" +PR = "r0" + +SRC_URI = "${SOURCEFORGE_MIRROR}/${PN}/${P}.tar.bz2" + +inherit autotools pkgconfig + +do_stage () { + autotools_stage_all +} + +EXTRA_OECONF = " --without-imagemagick --without-qt --without-python" + +PACKAGES += "libzbar libzbargtk" + +FILES_${PN} = "${bindir}/zbar*" +FILES_${PN}-doc = "${datadir}/doc ${datadir}/man " +FILES_${PN}-dbg += " ${bindir}/.debug" +FILES_libzbar = "${libdir}/libzbar.so.*" +FILES_libzbar-dev = "${libdir}/libzbar.so ${libdir}/libzbar.*a ${includedir}/zbar* " +FILES_libzbargtk = "${libdir}/libzbargtk.so.*" +FILES_libzbargtk-dev = "${libdir}/libzbargtk.so ${libdir}/libzbargtk.*a" -- cgit v1.2.3 From dfc9b3d6f7f05b7c67995540d4d71b44db9684f8 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 19:15:15 -0400 Subject: meta-toolchain: Use ${layout_base_libdir} not usr/lib for opkg. --- recipes/meta/meta-toolchain.bb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/recipes/meta/meta-toolchain.bb b/recipes/meta/meta-toolchain.bb index b8ed8013a9..6bb12ea663 100644 --- a/recipes/meta/meta-toolchain.bb +++ b/recipes/meta/meta-toolchain.bb @@ -62,17 +62,18 @@ do_populate_sdk() { revipkgarchs="$arch $revipkgarchs" done - mkdir -p ${SDK_OUTPUT}/usr/lib/opkg + mkdir -p ${SDK_OUTPUT}/${layout_base_libdir}/opkg ${IPKG_HOST} update ${IPKG_HOST} -force-depends install ${TOOLCHAIN_HOST_TASK} - mkdir -p ${SDK_OUTPUT}/${SDK_PATH}/${TARGET_SYS}/usr/lib/opkg + mkdir -p ${SDK_OUTPUT}/${prefix}/${TARGET_SYS}/${layout_base_libdir}/opkg ${IPKG_TARGET} update ${IPKG_TARGET} install ${TOOLCHAIN_TARGET_TASK} - install -d ${SDK_OUTPUT}/${prefix}/usr/lib/opkg - mv ${SDK_OUTPUT}/usr/lib/opkg/* ${SDK_OUTPUT}/${prefix}/usr/lib/opkg/ - rm -Rf ${SDK_OUTPUT}/usr/lib + install -d ${SDK_OUTPUT}/${prefix}/${layout_base_libdir}/opkg + mv ${SDK_OUTPUT}/${layout_base_libdir}/opkg/* \ + ${SDK_OUTPUT}/${prefix}/${layout_base_libdir}/opkg/ + rm -Rf ${SDK_OUTPUT}/${layout_base_libdir} install -d ${SDK_OUTPUT}/${prefix}/${TARGET_SYS}/${layout_sysconfdir} install -m 0644 ${IPKGCONF_TARGET} ${IPKGCONF_SDK} ${SDK_OUTPUT}/${prefix}/${TARGET_SYS}/${layout_sysconfdir}/ -- cgit v1.2.3 From 073b1af549edb818bb2038c5a72959db997b8145 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 19:39:11 -0400 Subject: gcc-3.3.4: Use INC_PR --- recipes/gcc/gcc-3.3.4.inc | 2 ++ recipes/gcc/gcc-cross-sdk_3.3.4.bb | 2 +- recipes/gcc/gcc-cross_3.3.4.bb | 2 +- recipes/gcc/gcc_3.3.4.bb | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/recipes/gcc/gcc-3.3.4.inc b/recipes/gcc/gcc-3.3.4.inc index eec46d556d..635e617a78 100644 --- a/recipes/gcc/gcc-3.3.4.inc +++ b/recipes/gcc/gcc-3.3.4.inc @@ -1,5 +1,7 @@ require gcc-common.inc +INC_PR = "r10" + SRC_URI = "${GNU_MIRROR}/gcc/releases/gcc-${PV}/gcc-${PV}.tar.bz2 \ file://arm-gotoff.dpatch;patch=1;pnum=0 \ file://arm-ldm.dpatch;patch=1;pnum=0 \ diff --git a/recipes/gcc/gcc-cross-sdk_3.3.4.bb b/recipes/gcc/gcc-cross-sdk_3.3.4.bb index ed9c18c557..525d1822b8 100644 --- a/recipes/gcc/gcc-cross-sdk_3.3.4.bb +++ b/recipes/gcc/gcc-cross-sdk_3.3.4.bb @@ -1,4 +1,4 @@ -PR = "r7" +PR = "${INC_PR}.1" inherit sdk diff --git a/recipes/gcc/gcc-cross_3.3.4.bb b/recipes/gcc/gcc-cross_3.3.4.bb index 462b9cdc66..0bf1951bea 100644 --- a/recipes/gcc/gcc-cross_3.3.4.bb +++ b/recipes/gcc/gcc-cross_3.3.4.bb @@ -1,4 +1,4 @@ -PR ="r10" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-cross.inc diff --git a/recipes/gcc/gcc_3.3.4.bb b/recipes/gcc/gcc_3.3.4.bb index 1bbab50930..fdafce2474 100644 --- a/recipes/gcc/gcc_3.3.4.bb +++ b/recipes/gcc/gcc_3.3.4.bb @@ -1,4 +1,4 @@ -PR = "r6" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-configure-target.inc -- cgit v1.2.3 From 36d5d93bf4fd470368ff92e9345a582c543a074a Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 19:41:18 -0400 Subject: gcc-3.4.3: Switch to INC_PR --- recipes/gcc/gcc-3.4.3.inc | 2 ++ recipes/gcc/gcc-cross-sdk_3.4.3.bb | 2 +- recipes/gcc/gcc-cross_3.4.3.bb | 2 +- recipes/gcc/gcc_3.4.3.bb | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/recipes/gcc/gcc-3.4.3.inc b/recipes/gcc/gcc-3.4.3.inc index 6511dfbd17..72f9042212 100644 --- a/recipes/gcc/gcc-3.4.3.inc +++ b/recipes/gcc/gcc-3.4.3.inc @@ -1,5 +1,7 @@ require gcc-common.inc +INC_PR = "r18" + SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2 \ file://gcc34-reverse-compare.patch;patch=1 \ file://gcc34-arm-ldm.patch;patch=1 \ diff --git a/recipes/gcc/gcc-cross-sdk_3.4.3.bb b/recipes/gcc/gcc-cross-sdk_3.4.3.bb index 0b1f6613bf..78c4cc0f4f 100644 --- a/recipes/gcc/gcc-cross-sdk_3.4.3.bb +++ b/recipes/gcc/gcc-cross-sdk_3.4.3.bb @@ -1,4 +1,4 @@ -PR = "r6" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-cross-sdk.inc diff --git a/recipes/gcc/gcc-cross_3.4.3.bb b/recipes/gcc/gcc-cross_3.4.3.bb index 0ecee8ad89..0bf1951bea 100644 --- a/recipes/gcc/gcc-cross_3.4.3.bb +++ b/recipes/gcc/gcc-cross_3.4.3.bb @@ -1,4 +1,4 @@ -PR = "r18" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-cross.inc diff --git a/recipes/gcc/gcc_3.4.3.bb b/recipes/gcc/gcc_3.4.3.bb index fb5a85a4b5..fdafce2474 100644 --- a/recipes/gcc/gcc_3.4.3.bb +++ b/recipes/gcc/gcc_3.4.3.bb @@ -1,4 +1,4 @@ -PR = "r17" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-configure-target.inc -- cgit v1.2.3 From be7846117e5c48e401a9602061a695264afeb331 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 19:43:59 -0400 Subject: gcc-3.4.4: Switch to INC_PR --- recipes/gcc/gcc-3.4.4.inc | 2 ++ recipes/gcc/gcc-cross-sdk_3.4.4.bb | 2 +- recipes/gcc/gcc-cross_3.4.4.bb | 2 +- recipes/gcc/gcc-native_3.4.4.bb | 2 +- recipes/gcc/gcc_3.4.4.bb | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/recipes/gcc/gcc-3.4.4.inc b/recipes/gcc/gcc-3.4.4.inc index 2bed5f8959..9a02c5d20b 100644 --- a/recipes/gcc/gcc-3.4.4.inc +++ b/recipes/gcc/gcc-3.4.4.inc @@ -1,5 +1,7 @@ require gcc-common.inc +INC_PR = "r14" + SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2 \ file://gcc34-reverse-compare.patch;patch=1 \ file://gcc34-arm-ldm.patch;patch=1 \ diff --git a/recipes/gcc/gcc-cross-sdk_3.4.4.bb b/recipes/gcc/gcc-cross-sdk_3.4.4.bb index e3346590d5..6cb136a3d2 100644 --- a/recipes/gcc/gcc-cross-sdk_3.4.4.bb +++ b/recipes/gcc/gcc-cross-sdk_3.4.4.bb @@ -1,4 +1,4 @@ -PR = "r8" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-cross-sdk.inc diff --git a/recipes/gcc/gcc-cross_3.4.4.bb b/recipes/gcc/gcc-cross_3.4.4.bb index 43d4b76037..0bf1951bea 100644 --- a/recipes/gcc/gcc-cross_3.4.4.bb +++ b/recipes/gcc/gcc-cross_3.4.4.bb @@ -1,4 +1,4 @@ -PR = "r14" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-cross.inc diff --git a/recipes/gcc/gcc-native_3.4.4.bb b/recipes/gcc/gcc-native_3.4.4.bb index c3f8106d3a..5686b4bc93 100644 --- a/recipes/gcc/gcc-native_3.4.4.bb +++ b/recipes/gcc/gcc-native_3.4.4.bb @@ -1,4 +1,4 @@ -PR = "r9" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-configure-target.inc diff --git a/recipes/gcc/gcc_3.4.4.bb b/recipes/gcc/gcc_3.4.4.bb index 73e908ae24..fdafce2474 100644 --- a/recipes/gcc/gcc_3.4.4.bb +++ b/recipes/gcc/gcc_3.4.4.bb @@ -1,4 +1,4 @@ -PR = "r12" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-configure-target.inc -- cgit v1.2.3 From 82ca98eff84d6350b323fecfe8e93f6255c10a40 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 19:45:21 -0400 Subject: gcc-4.1.0: Switch to INC_PR --- recipes/gcc/gcc-4.1.0.inc | 2 ++ recipes/gcc/gcc-cross-sdk_4.1.0.bb | 2 +- recipes/gcc/gcc-cross_4.1.0.bb | 2 +- recipes/gcc/gcc_4.1.0.bb | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/recipes/gcc/gcc-4.1.0.inc b/recipes/gcc/gcc-4.1.0.inc index d6f6198013..7bb1a34f76 100644 --- a/recipes/gcc/gcc-4.1.0.inc +++ b/recipes/gcc/gcc-4.1.0.inc @@ -1,5 +1,7 @@ require gcc-common.inc +INC_PR = "r9" + DEFAULT_PREFERENCE = "-1" # Use the same patches as gcc-4.1.1 does diff --git a/recipes/gcc/gcc-cross-sdk_4.1.0.bb b/recipes/gcc/gcc-cross-sdk_4.1.0.bb index 6b6097fb00..f133db31b1 100644 --- a/recipes/gcc/gcc-cross-sdk_4.1.0.bb +++ b/recipes/gcc/gcc-cross-sdk_4.1.0.bb @@ -1,4 +1,4 @@ -PR = "r6" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-cross-sdk.inc diff --git a/recipes/gcc/gcc-cross_4.1.0.bb b/recipes/gcc/gcc-cross_4.1.0.bb index 7675e473d3..9513c657f3 100644 --- a/recipes/gcc/gcc-cross_4.1.0.bb +++ b/recipes/gcc/gcc-cross_4.1.0.bb @@ -1,4 +1,4 @@ -PR = "r9" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-cross4.inc diff --git a/recipes/gcc/gcc_4.1.0.bb b/recipes/gcc/gcc_4.1.0.bb index 5e2598079b..fdafce2474 100644 --- a/recipes/gcc/gcc_4.1.0.bb +++ b/recipes/gcc/gcc_4.1.0.bb @@ -1,4 +1,4 @@ -PR = "r7" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-configure-target.inc -- cgit v1.2.3 From 8d1f74b25a01325f3621fae6cca55aafb4ed09e5 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 19:46:55 -0400 Subject: gcc-4.1.1: Switch to INC_PR --- recipes/gcc/gcc-4.1.1.inc | 2 ++ recipes/gcc/gcc-cross-sdk_4.1.1.bb | 2 +- recipes/gcc/gcc-cross_4.1.1.bb | 2 +- recipes/gcc/gcc_4.1.1.bb | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/recipes/gcc/gcc-4.1.1.inc b/recipes/gcc/gcc-4.1.1.inc index f16928479b..20da89aee6 100644 --- a/recipes/gcc/gcc-4.1.1.inc +++ b/recipes/gcc/gcc-4.1.1.inc @@ -2,6 +2,8 @@ require gcc-common.inc DEPENDS = "mpfr gmp" +INC_PR = "r23" + SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2 \ file://100-uclibc-conf.patch;patch=1 \ file://110-arm-eabi.patch;patch=1 \ diff --git a/recipes/gcc/gcc-cross-sdk_4.1.1.bb b/recipes/gcc/gcc-cross-sdk_4.1.1.bb index a6418f6404..f133db31b1 100644 --- a/recipes/gcc/gcc-cross-sdk_4.1.1.bb +++ b/recipes/gcc/gcc-cross-sdk_4.1.1.bb @@ -1,4 +1,4 @@ -PR = "r8" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-cross-sdk.inc diff --git a/recipes/gcc/gcc-cross_4.1.1.bb b/recipes/gcc/gcc-cross_4.1.1.bb index da797597d7..08ae7a552c 100644 --- a/recipes/gcc/gcc-cross_4.1.1.bb +++ b/recipes/gcc/gcc-cross_4.1.1.bb @@ -1,4 +1,4 @@ -PR = "r22" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-cross4.inc diff --git a/recipes/gcc/gcc_4.1.1.bb b/recipes/gcc/gcc_4.1.1.bb index 3d202f9930..fdafce2474 100644 --- a/recipes/gcc/gcc_4.1.1.bb +++ b/recipes/gcc/gcc_4.1.1.bb @@ -1,4 +1,4 @@ -PR = "r23" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-configure-target.inc -- cgit v1.2.3 From 781df6069c548eb5d7db6e9bfea92536538984c2 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 19:47:34 -0400 Subject: gcc-4.1.2: Switch to INC_PR --- recipes/gcc/gcc-4.1.2.inc | 2 ++ recipes/gcc/gcc-cross-sdk_4.1.2.bb | 2 +- recipes/gcc/gcc-cross_4.1.2.bb | 2 +- recipes/gcc/gcc_4.1.2.bb | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/recipes/gcc/gcc-4.1.2.inc b/recipes/gcc/gcc-4.1.2.inc index ed4e3c408d..2eaa133f97 100644 --- a/recipes/gcc/gcc-4.1.2.inc +++ b/recipes/gcc/gcc-4.1.2.inc @@ -2,6 +2,8 @@ require gcc-common.inc DEPENDS = "mpfr gmp" +INC_PR = "r20" + SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2 \ file://100-uclibc-conf.patch;patch=1 \ file://110-arm-eabi.patch;patch=1 \ diff --git a/recipes/gcc/gcc-cross-sdk_4.1.2.bb b/recipes/gcc/gcc-cross-sdk_4.1.2.bb index 7bc24806bb..9a9eb8ca56 100644 --- a/recipes/gcc/gcc-cross-sdk_4.1.2.bb +++ b/recipes/gcc/gcc-cross-sdk_4.1.2.bb @@ -1,4 +1,4 @@ -PR = "r10" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-cross-sdk.inc diff --git a/recipes/gcc/gcc-cross_4.1.2.bb b/recipes/gcc/gcc-cross_4.1.2.bb index 2effd3e62e..85f90b31a1 100644 --- a/recipes/gcc/gcc-cross_4.1.2.bb +++ b/recipes/gcc/gcc-cross_4.1.2.bb @@ -1,4 +1,4 @@ -PR = "r20" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-cross4.inc diff --git a/recipes/gcc/gcc_4.1.2.bb b/recipes/gcc/gcc_4.1.2.bb index 711aa35a32..22465d50d7 100644 --- a/recipes/gcc/gcc_4.1.2.bb +++ b/recipes/gcc/gcc_4.1.2.bb @@ -1,4 +1,4 @@ -PR = "r15" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-configure-target.inc -- cgit v1.2.3 From 6f012276b32d0b32e97d9584bc808a99dc9810ad Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 19:48:32 -0400 Subject: gcc-4.2.2: Switch to INC_PR --- recipes/gcc/gcc-4.2.2.inc | 2 ++ recipes/gcc/gcc-cross-sdk_4.2.2.bb | 2 +- recipes/gcc/gcc-cross_4.2.2.bb | 2 +- recipes/gcc/gcc_4.2.2.bb | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/recipes/gcc/gcc-4.2.2.inc b/recipes/gcc/gcc-4.2.2.inc index 7bb17cefed..fcebabc112 100644 --- a/recipes/gcc/gcc-4.2.2.inc +++ b/recipes/gcc/gcc-4.2.2.inc @@ -3,6 +3,8 @@ LICENSE = "GPLv3" DEPENDS = "mpfr gmp" +INC_PR = "r14" + SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2 \ file://100-uclibc-conf.patch;patch=1 \ file://103-uclibc-conf-noupstream.patch;patch=1 \ diff --git a/recipes/gcc/gcc-cross-sdk_4.2.2.bb b/recipes/gcc/gcc-cross-sdk_4.2.2.bb index a326263c06..27a7ae0a7f 100644 --- a/recipes/gcc/gcc-cross-sdk_4.2.2.bb +++ b/recipes/gcc/gcc-cross-sdk_4.2.2.bb @@ -1,4 +1,4 @@ -PR = "r8" +PR = "${INC_PR}.1" inherit sdk diff --git a/recipes/gcc/gcc-cross_4.2.2.bb b/recipes/gcc/gcc-cross_4.2.2.bb index 8e20d03e68..4e7fc479d1 100644 --- a/recipes/gcc/gcc-cross_4.2.2.bb +++ b/recipes/gcc/gcc-cross_4.2.2.bb @@ -1,4 +1,4 @@ -PR = "r14" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-cross4.inc diff --git a/recipes/gcc/gcc_4.2.2.bb b/recipes/gcc/gcc_4.2.2.bb index f0471d473f..6b20b47f1a 100644 --- a/recipes/gcc/gcc_4.2.2.bb +++ b/recipes/gcc/gcc_4.2.2.bb @@ -1,4 +1,4 @@ -PR = "r11" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-configure-target.inc -- cgit v1.2.3 From 0ccf91c95b3f21a6ada8630c9b205f8a780f5420 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 19:49:13 -0400 Subject: gcc-4.2.3: Switch to INC_PR --- recipes/gcc/gcc-4.2.3.inc | 2 ++ recipes/gcc/gcc-cross-sdk_4.2.3.bb | 2 +- recipes/gcc/gcc-cross_4.2.3.bb | 2 +- recipes/gcc/gcc_4.2.3.bb | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/recipes/gcc/gcc-4.2.3.inc b/recipes/gcc/gcc-4.2.3.inc index 7d623f53e3..b324f176dd 100644 --- a/recipes/gcc/gcc-4.2.3.inc +++ b/recipes/gcc/gcc-4.2.3.inc @@ -3,6 +3,8 @@ LICENSE = "GPLv3" DEPENDS = "mpfr gmp" +INC_PR = "r10" + SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2 \ file://100-uclibc-conf.patch;patch=1 \ file://103-uclibc-conf-noupstream.patch;patch=1 \ diff --git a/recipes/gcc/gcc-cross-sdk_4.2.3.bb b/recipes/gcc/gcc-cross-sdk_4.2.3.bb index 297bd8ece8..27a7ae0a7f 100644 --- a/recipes/gcc/gcc-cross-sdk_4.2.3.bb +++ b/recipes/gcc/gcc-cross-sdk_4.2.3.bb @@ -1,4 +1,4 @@ -PR = "r7" +PR = "${INC_PR}.1" inherit sdk diff --git a/recipes/gcc/gcc-cross_4.2.3.bb b/recipes/gcc/gcc-cross_4.2.3.bb index 816eddba19..4e7fc479d1 100644 --- a/recipes/gcc/gcc-cross_4.2.3.bb +++ b/recipes/gcc/gcc-cross_4.2.3.bb @@ -1,4 +1,4 @@ -PR = "r10" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-cross4.inc diff --git a/recipes/gcc/gcc_4.2.3.bb b/recipes/gcc/gcc_4.2.3.bb index ca22e0f69c..6b20b47f1a 100644 --- a/recipes/gcc/gcc_4.2.3.bb +++ b/recipes/gcc/gcc_4.2.3.bb @@ -1,4 +1,4 @@ -PR = "r9" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-configure-target.inc -- cgit v1.2.3 From af245faf6ddef5286f17cf0a292d91ec15fdecb1 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 19:53:10 -0400 Subject: gcc-4.3.1: Switch to INC_PR --- recipes/gcc/gcc-4.3.1.inc | 2 ++ recipes/gcc/gcc-cross-sdk_4.3.1.bb | 2 +- recipes/gcc/gcc-cross_4.3.1.bb | 2 +- recipes/gcc/gcc_4.3.1.bb | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/recipes/gcc/gcc-4.3.1.inc b/recipes/gcc/gcc-4.3.1.inc index d5390d7f27..f475eba417 100644 --- a/recipes/gcc/gcc-4.3.1.inc +++ b/recipes/gcc/gcc-4.3.1.inc @@ -7,6 +7,8 @@ LICENSE = "GPLv3" DEPENDS = "mpfr gmp" +INC_PR = "r18" + SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2 \ file://fedora/gcc43-c++-builtin-redecl.patch;patch=1;pnum=0 \ file://fedora/gcc43-ia64-libunwind.patch;patch=1;pnum=0 \ diff --git a/recipes/gcc/gcc-cross-sdk_4.3.1.bb b/recipes/gcc/gcc-cross-sdk_4.3.1.bb index 45557b6003..27a7ae0a7f 100644 --- a/recipes/gcc/gcc-cross-sdk_4.3.1.bb +++ b/recipes/gcc/gcc-cross-sdk_4.3.1.bb @@ -1,4 +1,4 @@ -PR = "r15" +PR = "${INC_PR}.1" inherit sdk diff --git a/recipes/gcc/gcc-cross_4.3.1.bb b/recipes/gcc/gcc-cross_4.3.1.bb index 2764039081..398ee2ee79 100644 --- a/recipes/gcc/gcc-cross_4.3.1.bb +++ b/recipes/gcc/gcc-cross_4.3.1.bb @@ -1,4 +1,4 @@ -PR = "r18" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-cross4.inc diff --git a/recipes/gcc/gcc_4.3.1.bb b/recipes/gcc/gcc_4.3.1.bb index af35244ec1..2153f272ee 100644 --- a/recipes/gcc/gcc_4.3.1.bb +++ b/recipes/gcc/gcc_4.3.1.bb @@ -1,4 +1,4 @@ -PR = "r12" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-configure-target.inc -- cgit v1.2.3 From 9ee3d21325e571f27b7248370f58eaaaf405e070 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 19:53:49 -0400 Subject: gcc-4.3.2: Switch to INC_PR --- recipes/gcc/gcc-4.3.2.inc | 2 ++ recipes/gcc/gcc-cross-sdk_4.3.2.bb | 2 +- recipes/gcc/gcc-cross_4.3.2.bb | 2 +- recipes/gcc/gcc_4.3.2.bb | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/recipes/gcc/gcc-4.3.2.inc b/recipes/gcc/gcc-4.3.2.inc index 967eb92285..a6e6b7bd19 100644 --- a/recipes/gcc/gcc-4.3.2.inc +++ b/recipes/gcc/gcc-4.3.2.inc @@ -7,6 +7,8 @@ LICENSE = "GPLv3" DEPENDS = "mpfr gmp" +INC_PR = "r8" + SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2 \ file://fedora/gcc43-c++-builtin-redecl.patch;patch=1;pnum=0 \ file://fedora/gcc43-ia64-libunwind.patch;patch=1;pnum=0 \ diff --git a/recipes/gcc/gcc-cross-sdk_4.3.2.bb b/recipes/gcc/gcc-cross-sdk_4.3.2.bb index 297bd8ece8..27a7ae0a7f 100644 --- a/recipes/gcc/gcc-cross-sdk_4.3.2.bb +++ b/recipes/gcc/gcc-cross-sdk_4.3.2.bb @@ -1,4 +1,4 @@ -PR = "r7" +PR = "${INC_PR}.1" inherit sdk diff --git a/recipes/gcc/gcc-cross_4.3.2.bb b/recipes/gcc/gcc-cross_4.3.2.bb index 598da3c912..5eb6b5fbe8 100644 --- a/recipes/gcc/gcc-cross_4.3.2.bb +++ b/recipes/gcc/gcc-cross_4.3.2.bb @@ -1,4 +1,4 @@ -PR = "r8" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-cross4.inc require gcc-configure-cross.inc diff --git a/recipes/gcc/gcc_4.3.2.bb b/recipes/gcc/gcc_4.3.2.bb index fddf437351..60180755c9 100644 --- a/recipes/gcc/gcc_4.3.2.bb +++ b/recipes/gcc/gcc_4.3.2.bb @@ -1,4 +1,4 @@ -PR = "r5" +PR = "${INC_PR}.1" require gcc-${PV}.inc require gcc-configure-target.inc require gcc-package-target.inc -- cgit v1.2.3 From 793b86cc83d0822d50e65422fd00ce9479129fbe Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 19:55:22 -0400 Subject: gcc-4.4.0: Switch to INC_PR --- recipes/gcc/gcc-4.4.0.inc | 2 ++ recipes/gcc/gcc-cross-sdk_4.4.0.bb | 2 +- recipes/gcc/gcc-cross_4.4.0.bb | 2 +- recipes/gcc/gcc_4.4.0.bb | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/recipes/gcc/gcc-4.4.0.inc b/recipes/gcc/gcc-4.4.0.inc index 3cb9763545..6ea9123460 100644 --- a/recipes/gcc/gcc-4.4.0.inc +++ b/recipes/gcc/gcc-4.4.0.inc @@ -7,6 +7,8 @@ LICENSE = "GPLv3" DEPENDS = "mpfr gmp" +INC_PR = "r1" + FILESPATHPKG .= ":gcc-$PV" SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2 \ diff --git a/recipes/gcc/gcc-cross-sdk_4.4.0.bb b/recipes/gcc/gcc-cross-sdk_4.4.0.bb index a62d13bd2c..513cca1ddc 100644 --- a/recipes/gcc/gcc-cross-sdk_4.4.0.bb +++ b/recipes/gcc/gcc-cross-sdk_4.4.0.bb @@ -4,7 +4,7 @@ require gcc-${PV}.inc require gcc-cross-sdk.inc require gcc-configure-sdk.inc require gcc-package-sdk.inc -PR = "r0" +PR = "${INC_PR}.1" DEPENDS += "gmp-native mpfr-native" diff --git a/recipes/gcc/gcc-cross_4.4.0.bb b/recipes/gcc/gcc-cross_4.4.0.bb index 731a956ef2..4db1b33945 100644 --- a/recipes/gcc/gcc-cross_4.4.0.bb +++ b/recipes/gcc/gcc-cross_4.4.0.bb @@ -2,7 +2,7 @@ require gcc-${PV}.inc require gcc-cross4.inc require gcc-configure-cross.inc require gcc-package-cross.inc -PR = "r1" +PR = "${INC_PR}.1" SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch;patch=1 " diff --git a/recipes/gcc/gcc_4.4.0.bb b/recipes/gcc/gcc_4.4.0.bb index 6ac2b58305..9773205c52 100644 --- a/recipes/gcc/gcc_4.4.0.bb +++ b/recipes/gcc/gcc_4.4.0.bb @@ -1,7 +1,7 @@ require gcc-${PV}.inc require gcc-configure-target.inc require gcc-package-target.inc -PR = "r0" +PR = "${INC_PR}.1" # GCC 4.4.0 installs crt* in a '4.4.0' dir.... FILES_${PN} += "\ -- cgit v1.2.3 From 598ee434efdc895bfdbc004b8e51b5d5707bc6b6 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 19:56:18 -0400 Subject: gcc-package-sdk.inc: ${layout_base_bindir} is not the path to where the real binary is. The binary will always be two levels back, and it will always be in ${bindir} as that's what we pass to configure, so basename that to find the right directory name. Bump INC_PR in gcc-canadian-sdk 4.2.4, gcc-cross-sdk 4.2.4/4.3.3/4.4.0 --- recipes/gcc/gcc-canadian-sdk_4.2.4.bb | 2 +- recipes/gcc/gcc-cross-sdk_4.2.4.bb | 2 +- recipes/gcc/gcc-cross-sdk_4.3.3.bb | 2 +- recipes/gcc/gcc-package-sdk.inc | 5 ++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/recipes/gcc/gcc-canadian-sdk_4.2.4.bb b/recipes/gcc/gcc-canadian-sdk_4.2.4.bb index 409970be5f..dadb5b04f6 100644 --- a/recipes/gcc/gcc-canadian-sdk_4.2.4.bb +++ b/recipes/gcc/gcc-canadian-sdk_4.2.4.bb @@ -1,6 +1,6 @@ inherit canadian-sdk -PR = "${INC_PR}.1" +PR = "${INC_PR}.2" FILESDIR = "${@os.path.dirname(bb.data.getVar('FILE',d,1))}/gcc-${PV}" diff --git a/recipes/gcc/gcc-cross-sdk_4.2.4.bb b/recipes/gcc/gcc-cross-sdk_4.2.4.bb index c5a0a1aa88..ab52a9ae04 100644 --- a/recipes/gcc/gcc-cross-sdk_4.2.4.bb +++ b/recipes/gcc/gcc-cross-sdk_4.2.4.bb @@ -1,4 +1,4 @@ -PR = "${INC_PR}.1" +PR = "${INC_PR}.2" inherit sdk diff --git a/recipes/gcc/gcc-cross-sdk_4.3.3.bb b/recipes/gcc/gcc-cross-sdk_4.3.3.bb index 27a7ae0a7f..6be2538cd5 100644 --- a/recipes/gcc/gcc-cross-sdk_4.3.3.bb +++ b/recipes/gcc/gcc-cross-sdk_4.3.3.bb @@ -1,4 +1,4 @@ -PR = "${INC_PR}.1" +PR = "${INC_PR}.2" inherit sdk diff --git a/recipes/gcc/gcc-package-sdk.inc b/recipes/gcc/gcc-package-sdk.inc index 3d9cc0c53a..dcf2c890e4 100644 --- a/recipes/gcc/gcc-package-sdk.inc +++ b/recipes/gcc/gcc-package-sdk.inc @@ -48,10 +48,9 @@ do_install () { # Create the ${prefix}/${TARGET_SYS}/bin/* symlinks install -d ${D}${prefix}/${TARGET_SYS}/bin/ for l in ${D}${bindir}/*; do - echo $l - ln -sf "../../${layout_base_bindir}/`basename $l`" "${D}${prefix}/${TARGET_SYS}/bin/`basename $l | sed -e 's,${TARGET_PREFIX},,'`" + ln -sf "../../`basename ${bindir}`/`basename $l`" "${D}${prefix}/${TARGET_SYS}/bin/`basename $l | sed -e 's,${TARGET_PREFIX},,'`" done - ln -sf "${bindir}/${TARGET_PREFIX}gcc${EXEEXT}" "${D}${prefix}/${TARGET_SYS}/bin/cc${EXEEXT}" + ln -sf "../../`basename ${bindir}`/${TARGET_PREFIX}gcc${EXEEXT}" "${D}${prefix}/${TARGET_SYS}/bin/cc${EXEEXT}" # Manually run the target stripper since we won't get it run by # the packaging. -- cgit v1.2.3 From c528566fbc35002b4eeaf9e57705d4958bb25698 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 19:58:18 -0400 Subject: binutils-cross-sdk: ${layout_base_bindir} is not the path to where the real binary is. The binary will always be two levels back, and it will always be in ${bindir} as that's what we pass to configure, so basename that to find the right directory name --- recipes/binutils/binutils-cross-sdk.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/binutils/binutils-cross-sdk.inc b/recipes/binutils/binutils-cross-sdk.inc index 6e9cda09b8..0ebe5147e6 100644 --- a/recipes/binutils/binutils-cross-sdk.inc +++ b/recipes/binutils/binutils-cross-sdk.inc @@ -17,7 +17,7 @@ do_install () { rm ${D}${prefix}/${TARGET_SYS}/bin/.debug -Rf rm ${D}${prefix}/${TARGET_SYS}/bin/* for l in ${D}${bindir}/*; do - ln -sf "../../${layout_base_bindir}/`basename $l`" "${D}${prefix}/${TARGET_SYS}/bin/`basename $l | sed -e 's,${TARGET_PREFIX},,'`" + ln -sf "../../`basename ${bindir}`/`basename $l`" "${D}${prefix}/${TARGET_SYS}/bin/`basename $l | sed -e 's,${TARGET_PREFIX},,'`" done # Install the libiberty header -- cgit v1.2.3 From e0f4953d78ace0e95a23bf75dfea19f7be9a594a Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 20:20:23 -0400 Subject: binutils-2.14.90.0.6: Switch to INC_PR --- recipes/binutils/binutils-cross-sdk_2.14.90.0.6.bb | 2 +- recipes/binutils/binutils_2.14.90.0.6.bb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/binutils/binutils-cross-sdk_2.14.90.0.6.bb b/recipes/binutils/binutils-cross-sdk_2.14.90.0.6.bb index f84a61d1f5..2f13b264a1 100644 --- a/recipes/binutils/binutils-cross-sdk_2.14.90.0.6.bb +++ b/recipes/binutils/binutils-cross-sdk_2.14.90.0.6.bb @@ -1,3 +1,3 @@ require binutils_${PV}.bb require binutils-cross-sdk.inc -PR = "r1" +PR = "${INC_PR}.1" diff --git a/recipes/binutils/binutils_2.14.90.0.6.bb b/recipes/binutils/binutils_2.14.90.0.6.bb index e3ab895446..ed12244bf9 100644 --- a/recipes/binutils/binutils_2.14.90.0.6.bb +++ b/recipes/binutils/binutils_2.14.90.0.6.bb @@ -2,7 +2,8 @@ SECTION = "devel" LICENSE = "GPL" inherit autotools gettext -PR = "r5" +INC_PR = "r5" +PR = "${INC_PR}.1" DESCRIPTION = "A GNU collection of binary utilities" HOMEPAGE = "http://www.gnu.org/software/binutils/" -- cgit v1.2.3 From 867b91643b7fa61cc7d66d414c91ddff528cfa5b Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 20:20:31 -0400 Subject: binutils-2.14.90.0.7: Switch to INC_PR --- recipes/binutils/binutils-cross-sdk_2.14.90.0.7.bb | 2 +- recipes/binutils/binutils_2.14.90.0.7.bb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/binutils/binutils-cross-sdk_2.14.90.0.7.bb b/recipes/binutils/binutils-cross-sdk_2.14.90.0.7.bb index f84a61d1f5..2f13b264a1 100644 --- a/recipes/binutils/binutils-cross-sdk_2.14.90.0.7.bb +++ b/recipes/binutils/binutils-cross-sdk_2.14.90.0.7.bb @@ -1,3 +1,3 @@ require binutils_${PV}.bb require binutils-cross-sdk.inc -PR = "r1" +PR = "${INC_PR}.1" diff --git a/recipes/binutils/binutils_2.14.90.0.7.bb b/recipes/binutils/binutils_2.14.90.0.7.bb index 3447c4fea8..0d74328649 100644 --- a/recipes/binutils/binutils_2.14.90.0.7.bb +++ b/recipes/binutils/binutils_2.14.90.0.7.bb @@ -5,7 +5,8 @@ inherit autotools gettext DESCRIPTION = "A GNU collection of binary utilities" HOMEPAGE = "http://www.gnu.org/software/binutils/" LICENSE = "GPL" -PR = "r6" +INC_PR = "r6" +PR = "${INC_PR}.1" PACKAGES = "${PN} ${PN}-dev ${PN}-doc ${PN}-symlinks" -- cgit v1.2.3 From 7ea0d46f102074f36f37f07dfa7d2b60ed61072f Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 20:20:39 -0400 Subject: binutils-2.15.94.0.1: Switch to INC_PR --- recipes/binutils/binutils-cross-sdk_2.15.94.0.1.bb | 2 +- recipes/binutils/binutils_2.15.94.0.1.bb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/binutils/binutils-cross-sdk_2.15.94.0.1.bb b/recipes/binutils/binutils-cross-sdk_2.15.94.0.1.bb index 40e9889691..2f13b264a1 100644 --- a/recipes/binutils/binutils-cross-sdk_2.15.94.0.1.bb +++ b/recipes/binutils/binutils-cross-sdk_2.15.94.0.1.bb @@ -1,3 +1,3 @@ require binutils_${PV}.bb require binutils-cross-sdk.inc -PR = "r2" +PR = "${INC_PR}.1" diff --git a/recipes/binutils/binutils_2.15.94.0.1.bb b/recipes/binutils/binutils_2.15.94.0.1.bb index 74a902b5e6..cdcf14534e 100644 --- a/recipes/binutils/binutils_2.15.94.0.1.bb +++ b/recipes/binutils/binutils_2.15.94.0.1.bb @@ -2,7 +2,8 @@ DESCRIPTION = "A GNU collection of binary utilities" HOMEPAGE = "http://www.gnu.org/software/binutils/" SECTION = "devel" LICENSE = "GPL" -PR = "r5" +INC_PR = "r5" +PR = "${INC_PR}.1" inherit autotools gettext -- cgit v1.2.3 From 90515bc834a967b5056204531d08f65775ba4351 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 20:20:46 -0400 Subject: binutils-2.16.91.0.6: Switch to INC_PR --- recipes/binutils/binutils-cross-sdk_2.16.91.0.6.bb | 2 +- recipes/binutils/binutils_2.16.91.0.6.bb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/binutils/binutils-cross-sdk_2.16.91.0.6.bb b/recipes/binutils/binutils-cross-sdk_2.16.91.0.6.bb index f84a61d1f5..2f13b264a1 100644 --- a/recipes/binutils/binutils-cross-sdk_2.16.91.0.6.bb +++ b/recipes/binutils/binutils-cross-sdk_2.16.91.0.6.bb @@ -1,3 +1,3 @@ require binutils_${PV}.bb require binutils-cross-sdk.inc -PR = "r1" +PR = "${INC_PR}.1" diff --git a/recipes/binutils/binutils_2.16.91.0.6.bb b/recipes/binutils/binutils_2.16.91.0.6.bb index b2511492b3..3461c891ba 100644 --- a/recipes/binutils/binutils_2.16.91.0.6.bb +++ b/recipes/binutils/binutils_2.16.91.0.6.bb @@ -2,7 +2,8 @@ DESCRIPTION = "A GNU collection of binary utilities" HOMEPAGE = "http://www.gnu.org/software/binutils/" SECTION = "devel" LICENSE = "GPL" -PR = "r3" +INC_PR = "r3" +PR = "${INC_PR}.1" # glibc 2.3 has issues with this version # of binutils. -- cgit v1.2.3 From 467626ffc8de48360cb49bbbc8f1f4ffc95e143b Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 20:20:52 -0400 Subject: binutils-2.16.91.0.7: Switch to INC_PR --- recipes/binutils/binutils-cross-sdk_2.16.91.0.7.bb | 2 +- recipes/binutils/binutils_2.16.91.0.7.bb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/binutils/binutils-cross-sdk_2.16.91.0.7.bb b/recipes/binutils/binutils-cross-sdk_2.16.91.0.7.bb index cde4e42942..2f13b264a1 100644 --- a/recipes/binutils/binutils-cross-sdk_2.16.91.0.7.bb +++ b/recipes/binutils/binutils-cross-sdk_2.16.91.0.7.bb @@ -1,3 +1,3 @@ require binutils_${PV}.bb require binutils-cross-sdk.inc -PR = "r5" +PR = "${INC_PR}.1" diff --git a/recipes/binutils/binutils_2.16.91.0.7.bb b/recipes/binutils/binutils_2.16.91.0.7.bb index 76c128583d..0fb1996ced 100644 --- a/recipes/binutils/binutils_2.16.91.0.7.bb +++ b/recipes/binutils/binutils_2.16.91.0.7.bb @@ -3,7 +3,8 @@ HOMEPAGE = "http://www.gnu.org/software/binutils/" SECTION = "devel" LICENSE = "GPL" DEFAULT_PREFERENCE = "-1" -PR = "r2" +INC_PR = "r5" +PR = "${INC_PR}.1" inherit autotools gettext -- cgit v1.2.3 From a84d0f48e6632fe73b51c68386f80d659b87f8f4 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 20:20:59 -0400 Subject: binutils-2.17.50.0.12: Switch to INC_PR --- recipes/binutils/binutils-cross-sdk_2.17.50.0.12.bb | 2 +- recipes/binutils/binutils_2.17.50.0.12.bb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/binutils/binutils-cross-sdk_2.17.50.0.12.bb b/recipes/binutils/binutils-cross-sdk_2.17.50.0.12.bb index cde4e42942..2f13b264a1 100644 --- a/recipes/binutils/binutils-cross-sdk_2.17.50.0.12.bb +++ b/recipes/binutils/binutils-cross-sdk_2.17.50.0.12.bb @@ -1,3 +1,3 @@ require binutils_${PV}.bb require binutils-cross-sdk.inc -PR = "r5" +PR = "${INC_PR}.1" diff --git a/recipes/binutils/binutils_2.17.50.0.12.bb b/recipes/binutils/binutils_2.17.50.0.12.bb index d24d24e1bc..d39ebc79b0 100644 --- a/recipes/binutils/binutils_2.17.50.0.12.bb +++ b/recipes/binutils/binutils_2.17.50.0.12.bb @@ -1,5 +1,6 @@ require binutils.inc -PR = "r2" +INC_PR = "r5" +PR = "${INC_PR}.1" SRC_URI = \ "${KERNELORG_MIRROR}/pub/linux/devel/binutils/binutils-${PV}.tar.bz2 \ -- cgit v1.2.3 From c69f12b8ea34e7d2ae606a8d00bcec3ce6452dff Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 20:21:03 -0400 Subject: binutils-2.18.50.0.7: Switch to INC_PR --- recipes/binutils/binutils-cross-sdk_2.18.50.0.7.bb | 2 +- recipes/binutils/binutils-cross_2.18.50.0.7.bb | 1 - recipes/binutils/binutils_2.18.50.0.7.bb | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/binutils/binutils-cross-sdk_2.18.50.0.7.bb b/recipes/binutils/binutils-cross-sdk_2.18.50.0.7.bb index cde4e42942..2f13b264a1 100644 --- a/recipes/binutils/binutils-cross-sdk_2.18.50.0.7.bb +++ b/recipes/binutils/binutils-cross-sdk_2.18.50.0.7.bb @@ -1,3 +1,3 @@ require binutils_${PV}.bb require binutils-cross-sdk.inc -PR = "r5" +PR = "${INC_PR}.1" diff --git a/recipes/binutils/binutils-cross_2.18.50.0.7.bb b/recipes/binutils/binutils-cross_2.18.50.0.7.bb index b78a30ac47..d245f7d11a 100644 --- a/recipes/binutils/binutils-cross_2.18.50.0.7.bb +++ b/recipes/binutils/binutils-cross_2.18.50.0.7.bb @@ -1,4 +1,3 @@ FILESDIR = "${@os.path.dirname(bb.data.getVar('FILE',d,1))}/binutils-${PV}" require binutils_${PV}.bb require binutils-cross.inc - diff --git a/recipes/binutils/binutils_2.18.50.0.7.bb b/recipes/binutils/binutils_2.18.50.0.7.bb index d2e3e3bcd8..2e2bb54d00 100644 --- a/recipes/binutils/binutils_2.18.50.0.7.bb +++ b/recipes/binutils/binutils_2.18.50.0.7.bb @@ -1,4 +1,5 @@ -PR = "r7" +INC_PR = "r7" +PR = "${INC_PR}.1" require binutils.inc LICENSE = "GPLv3" -- cgit v1.2.3 From de6775aaa98c9d4b2ad587ed423a7e5145f8498a Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 20:21:13 -0400 Subject: binutils-2.18: Switch to INC_PR --- recipes/binutils/binutils-cross-sdk_2.18.bb | 2 +- recipes/binutils/binutils-cross_2.18.bb | 1 - recipes/binutils/binutils_2.18.bb | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/binutils/binutils-cross-sdk_2.18.bb b/recipes/binutils/binutils-cross-sdk_2.18.bb index cde4e42942..2f13b264a1 100644 --- a/recipes/binutils/binutils-cross-sdk_2.18.bb +++ b/recipes/binutils/binutils-cross-sdk_2.18.bb @@ -1,3 +1,3 @@ require binutils_${PV}.bb require binutils-cross-sdk.inc -PR = "r5" +PR = "${INC_PR}.1" diff --git a/recipes/binutils/binutils-cross_2.18.bb b/recipes/binutils/binutils-cross_2.18.bb index b78a30ac47..d245f7d11a 100644 --- a/recipes/binutils/binutils-cross_2.18.bb +++ b/recipes/binutils/binutils-cross_2.18.bb @@ -1,4 +1,3 @@ FILESDIR = "${@os.path.dirname(bb.data.getVar('FILE',d,1))}/binutils-${PV}" require binutils_${PV}.bb require binutils-cross.inc - diff --git a/recipes/binutils/binutils_2.18.bb b/recipes/binutils/binutils_2.18.bb index 3b650c679b..87214644db 100644 --- a/recipes/binutils/binutils_2.18.bb +++ b/recipes/binutils/binutils_2.18.bb @@ -1,4 +1,5 @@ -PR = "r6" +INC_PR = "r6" +PR = "${INC_PR}.1" require binutils.inc LICENSE = "GPLv3" -- cgit v1.2.3 From 4b69ea8dbccf5e5a1c102e1e4078ae5601a9b94f Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 20:21:20 -0400 Subject: binutils-2.19.1: Switch to INC_PR --- recipes/binutils/binutils-cross-sdk_2.19.1.bb | 2 +- recipes/binutils/binutils-cross_2.19.1.bb | 1 - recipes/binutils/binutils_2.19.1.bb | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/binutils/binutils-cross-sdk_2.19.1.bb b/recipes/binutils/binutils-cross-sdk_2.19.1.bb index f84a61d1f5..2f13b264a1 100644 --- a/recipes/binutils/binutils-cross-sdk_2.19.1.bb +++ b/recipes/binutils/binutils-cross-sdk_2.19.1.bb @@ -1,3 +1,3 @@ require binutils_${PV}.bb require binutils-cross-sdk.inc -PR = "r1" +PR = "${INC_PR}.1" diff --git a/recipes/binutils/binutils-cross_2.19.1.bb b/recipes/binutils/binutils-cross_2.19.1.bb index b78a30ac47..d245f7d11a 100644 --- a/recipes/binutils/binutils-cross_2.19.1.bb +++ b/recipes/binutils/binutils-cross_2.19.1.bb @@ -1,4 +1,3 @@ FILESDIR = "${@os.path.dirname(bb.data.getVar('FILE',d,1))}/binutils-${PV}" require binutils_${PV}.bb require binutils-cross.inc - diff --git a/recipes/binutils/binutils_2.19.1.bb b/recipes/binutils/binutils_2.19.1.bb index 7ff6159c30..ea2de737ea 100644 --- a/recipes/binutils/binutils_2.19.1.bb +++ b/recipes/binutils/binutils_2.19.1.bb @@ -1,4 +1,5 @@ -PR = "r1" +INC_PR = "r1" +PR = "${INC_PR}.1" require binutils.inc LICENSE = "GPLv3" -- cgit v1.2.3 From 5d1ef2932748b14cc0b23e9064538beaf9d789fb Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 20:21:28 -0400 Subject: binutils-2.19.51.0.3: Switch to INC_PR --- recipes/binutils/binutils-cross-sdk_2.19.51.0.3.bb | 2 +- recipes/binutils/binutils-cross_2.19.51.0.3.bb | 1 - recipes/binutils/binutils_2.19.51.0.3.bb | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/binutils/binutils-cross-sdk_2.19.51.0.3.bb b/recipes/binutils/binutils-cross-sdk_2.19.51.0.3.bb index 76dff5449f..2f13b264a1 100644 --- a/recipes/binutils/binutils-cross-sdk_2.19.51.0.3.bb +++ b/recipes/binutils/binutils-cross-sdk_2.19.51.0.3.bb @@ -1,3 +1,3 @@ require binutils_${PV}.bb require binutils-cross-sdk.inc -PR = "r0" +PR = "${INC_PR}.1" diff --git a/recipes/binutils/binutils-cross_2.19.51.0.3.bb b/recipes/binutils/binutils-cross_2.19.51.0.3.bb index b78a30ac47..d245f7d11a 100644 --- a/recipes/binutils/binutils-cross_2.19.51.0.3.bb +++ b/recipes/binutils/binutils-cross_2.19.51.0.3.bb @@ -1,4 +1,3 @@ FILESDIR = "${@os.path.dirname(bb.data.getVar('FILE',d,1))}/binutils-${PV}" require binutils_${PV}.bb require binutils-cross.inc - diff --git a/recipes/binutils/binutils_2.19.51.0.3.bb b/recipes/binutils/binutils_2.19.51.0.3.bb index 698ba2bc22..cf208b2ea9 100644 --- a/recipes/binutils/binutils_2.19.51.0.3.bb +++ b/recipes/binutils/binutils_2.19.51.0.3.bb @@ -1,4 +1,5 @@ -PR = "r1" +INC_PR = "r1" +PR = "${INC_PR}.1" require binutils.inc LICENSE = "GPLv3" -- cgit v1.2.3 From 6fefecfed9b6d7c882ba3dcce806736c5013233b Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 20:21:36 -0400 Subject: binutils-2.19: Switch to INC_PR --- recipes/binutils/binutils-cross-sdk_2.19.bb | 2 +- recipes/binutils/binutils-cross_2.19.bb | 1 - recipes/binutils/binutils_2.19.bb | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/binutils/binutils-cross-sdk_2.19.bb b/recipes/binutils/binutils-cross-sdk_2.19.bb index f84a61d1f5..2f13b264a1 100644 --- a/recipes/binutils/binutils-cross-sdk_2.19.bb +++ b/recipes/binutils/binutils-cross-sdk_2.19.bb @@ -1,3 +1,3 @@ require binutils_${PV}.bb require binutils-cross-sdk.inc -PR = "r1" +PR = "${INC_PR}.1" diff --git a/recipes/binutils/binutils-cross_2.19.bb b/recipes/binutils/binutils-cross_2.19.bb index b78a30ac47..d245f7d11a 100644 --- a/recipes/binutils/binutils-cross_2.19.bb +++ b/recipes/binutils/binutils-cross_2.19.bb @@ -1,4 +1,3 @@ FILESDIR = "${@os.path.dirname(bb.data.getVar('FILE',d,1))}/binutils-${PV}" require binutils_${PV}.bb require binutils-cross.inc - diff --git a/recipes/binutils/binutils_2.19.bb b/recipes/binutils/binutils_2.19.bb index 652e705313..c1d821e11c 100644 --- a/recipes/binutils/binutils_2.19.bb +++ b/recipes/binutils/binutils_2.19.bb @@ -1,4 +1,5 @@ -PR = "r2" +INC_PR = "r2" +PR = "${INC_PR}.1" require binutils.inc LICENSE = "GPLv3" -- cgit v1.2.3 From b52781c95e58c89e20f68c3f5cceccd85761aa2b Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Jun 2009 20:21:41 -0400 Subject: binutils-cvs: Switch to INC_PR --- recipes/binutils/binutils-cross-sdk_cvs.bb | 2 +- recipes/binutils/binutils_cvs.bb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/binutils/binutils-cross-sdk_cvs.bb b/recipes/binutils/binutils-cross-sdk_cvs.bb index 94d2704a6f..b01afc4070 100644 --- a/recipes/binutils/binutils-cross-sdk_cvs.bb +++ b/recipes/binutils/binutils-cross-sdk_cvs.bb @@ -1,4 +1,4 @@ require binutils_cvs.bb require binutils-cross-sdk.inc -PR = "r5" +PR = "${INC_PR}.1" FILESPATHPKG .= ":binutils-cvs" diff --git a/recipes/binutils/binutils_cvs.bb b/recipes/binutils/binutils_cvs.bb index 75c88867f1..f47de6f2ee 100644 --- a/recipes/binutils/binutils_cvs.bb +++ b/recipes/binutils/binutils_cvs.bb @@ -1,6 +1,7 @@ FILESDIR = "${@os.path.dirname(bb.data.getVar('FILE',d,1))}/binutils-cvs" PV = "0.0+cvs${SRCDATE}" -PR = "r0" +INC_PR = "r5" +PR = "${INC_PR}.1" require binutils.inc -- cgit v1.2.3 From 4926fc282489d6dcd8c618100a74f6f24897dbfe Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Sat, 20 Jun 2009 11:06:21 +0200 Subject: util-linux-ng: fix packaging, u-a and replace hardcoded paths * also switch to INC_PR to make Tom happy --- recipes/util-linux-ng/util-linux-ng.inc | 21 ++++++++++++--------- recipes/util-linux-ng/util-linux-ng_2.13.1.bb | 2 +- recipes/util-linux-ng/util-linux-ng_2.14.bb | 2 +- recipes/util-linux-ng/util-linux-ng_2.15.bb | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/recipes/util-linux-ng/util-linux-ng.inc b/recipes/util-linux-ng/util-linux-ng.inc index 8b526efd95..9bfcc03e43 100644 --- a/recipes/util-linux-ng/util-linux-ng.inc +++ b/recipes/util-linux-ng/util-linux-ng.inc @@ -8,6 +8,8 @@ AUTOTOOLS_STAGE_PKGCONFIG = "1" DEFAULT_PREFERENCE = "-1" +INC_PR = "r6" + # allows for a release candidate RC ?= "" @@ -19,14 +21,14 @@ PACKAGES_DYNAMIC = "libblkid*" FILES_${PN}-doc += "/usr/share/misc/getopt/getopt-*.*" FILES_${PN} = "${bindir} ${sbindir} ${base_bindir} ${base_sbindir}" -FILES_util-linux-ng-fdisk = "/sbin/fdisk.${PN}" -FILES_util-linux-ng-cfdisk = "/sbin/cfdisk" -FILES_util-linux-ng-sfdisk = "/sbin/sfdisk" -FILES_util-linux-ng-swaponoff = "/sbin/swapon.${PN} /sbin/swapoff.${PN}" -FILES_util-linux-ng-losetup = "/sbin/losetup.${PN}" -FILES_util-linux-ng-mount = "/bin/mount.${PN} ${sysconfdir}/default/mountall" -FILES_util-linux-ng-umount = "/bin/umount.${PN}" -FILES_util-linux-ng-readprofile = "/usr/sbin/readprofile.${PN}" +FILES_util-linux-ng-fdisk = "${base_sbindir}/fdisk.${PN}" +FILES_util-linux-ng-cfdisk = "${base_sbindir}/cfdisk" +FILES_util-linux-ng-sfdisk = "${base_sbindir}/sfdisk" +FILES_util-linux-ng-swaponoff = "${base_sbindir}/swapon.${PN} ${base_sbindir}/swapoff.${PN}" +FILES_util-linux-ng-losetup = "${base_sbindir}/losetup.${PN}" +FILES_util-linux-ng-mount = "${base_bindir}/mount.${PN} ${sysconfdir}/default/mountall" +FILES_util-linux-ng-umount = "${base_bindir}/umount.${PN}" +FILES_util-linux-ng-readprofile = "${sbindir}/readprofile.${PN}" PACKAGES =+ "${PN}-mountall" FILES_${PN}-mountall = "${sysconfdir}/default/mountall" @@ -129,7 +131,8 @@ do_install () { install -d ${D}${sysconfdir}/default/ echo 'MOUNTALL="-t nonfs,nosmbfs,noncpfs"' > ${D}${sysconfdir}/default/mountall - ln -sf ${sbindir}/swapon ${D}${sbindir}/swapoff.${PN} + rm ${D}${sbindir}/swap* -f + ln -sf ${base_sbindir}/swapon.${PN} ${D}${base_sbindir}/swapoff.${PN} ln -sf ${sbindir}/shutdown ${D}${sbindir}/reboot.${PN} ln -sf ${sbindir}/shutdown ${D}${sbindir}/halt.${PN} ln -sf ${sbindir}/shutdown ${D}${sbindir}/fastboot diff --git a/recipes/util-linux-ng/util-linux-ng_2.13.1.bb b/recipes/util-linux-ng/util-linux-ng_2.13.1.bb index 8fded14fbe..c239b15226 100644 --- a/recipes/util-linux-ng/util-linux-ng_2.13.1.bb +++ b/recipes/util-linux-ng/util-linux-ng_2.13.1.bb @@ -5,4 +5,4 @@ SRC_URI = "${KERNELORG_MIRROR}/pub/linux/utils/util-linux-ng/v2.13/util-linux-ng #SRC_URI += "file://glibc-fix.patch;patch=1" #SRC_URI += "file://glibc-umount2.patch;patch=1" -PR = "r1" +PR = "${INC_PR}" diff --git a/recipes/util-linux-ng/util-linux-ng_2.14.bb b/recipes/util-linux-ng/util-linux-ng_2.14.bb index 6ba26304c0..d7eafd3602 100644 --- a/recipes/util-linux-ng/util-linux-ng_2.14.bb +++ b/recipes/util-linux-ng/util-linux-ng_2.14.bb @@ -1,6 +1,6 @@ require util-linux-ng.inc -PR = "r5" +PR = "${INC_PR}" SRC_URI += "file://util-linux-ng-uclibc-versionsort.patch;patch=1 \ file://util-linux-ng-replace-siginterrupt.patch;patch=1 \ diff --git a/recipes/util-linux-ng/util-linux-ng_2.15.bb b/recipes/util-linux-ng/util-linux-ng_2.15.bb index c52fc75e34..1e36dd3ffc 100644 --- a/recipes/util-linux-ng/util-linux-ng_2.15.bb +++ b/recipes/util-linux-ng/util-linux-ng_2.15.bb @@ -1,6 +1,6 @@ require util-linux-ng.inc -PR = "r3" +PR = "${INC_PR}" SRC_URI += "file://fix-make-c.patch;patch=1 \ file://optional-uuid.patch;patch=1 \ -- cgit v1.2.3 From 1b460b4e284436b141e49237274899702604d240 Mon Sep 17 00:00:00 2001 From: Phil Blundell Date: Sat, 20 Jun 2009 10:43:47 +0100 Subject: micro{-uclibc}: use ${LIBC} instead of PREFERRED_LIBC, per suggestion from Tom Rini --- conf/distro/micro-uclibc.conf | 2 +- conf/distro/micro.conf | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/conf/distro/micro-uclibc.conf b/conf/distro/micro-uclibc.conf index 08d8e303cf..f793d4a3c1 100644 --- a/conf/distro/micro-uclibc.conf +++ b/conf/distro/micro-uclibc.conf @@ -28,7 +28,7 @@ TARGET_OS_armeb = "linux-uclibcgnueabi" ############################################################################# # TOOLCHAIN ############################################################################# -PREFERRED_LIBC = "uclibc" +LIBC = "uclibc" ############################################################################# # PREFERRED PROVIDERS diff --git a/conf/distro/micro.conf b/conf/distro/micro.conf index f8b293de28..c566d7502d 100644 --- a/conf/distro/micro.conf +++ b/conf/distro/micro.conf @@ -47,11 +47,11 @@ require conf/distro/include/sane-feed-${PREFERRED_PKG_FORMAT}.inc # IMAGES ############################################################################# # Name generated images -IMAGE_NAME = "${DISTRO_NAME}-${IMAGE_BASENAME}-${PREFERRED_LIBC}-\ +IMAGE_NAME = "${DISTRO_NAME}-${IMAGE_BASENAME}-${LIBC}-\ ${PREFERRED_PKG_FORMAT}-${DISTRO_VERSION}-${MACHINE}" -CACHE ?= "${TMPDIR}/cache/${PREFERRED_LIBC}/${MACHINE}" -DEPLOY_DIR ?= "${TMPDIR}/deploy/${PREFERRED_LIBC}" +CACHE ?= "${TMPDIR}/cache/${LIBC}/${MACHINE}" +DEPLOY_DIR ?= "${TMPDIR}/deploy/${LIBC}" DEPLOY_DIR_IMAGE = "${DEPLOY_DIR}/images/${MACHINE}" # Image output types @@ -66,7 +66,7 @@ MACHINE_KERNEL_VERSION = "2.6" ############################################################################# # TOOLCHAIN ############################################################################# -PREFERRED_LIBC = "glibc" +LIBC = "glibc" require conf/distro/include/sane-toolchain.inc ############################################################################# @@ -110,3 +110,4 @@ USE_LDCONFIG = "0" # Disable online package management ONLINE_PACKAGE_MANAGEMENT = "none" + -- cgit v1.2.3 From c37cfc7c523a3765807efaa827d78b9d4f3729e2 Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Sat, 20 Jun 2009 12:25:01 +0200 Subject: util-linux-ng: only delete bogus symlink, not all swap* binaries for crazy people that have sbindir == base_sbindir --- recipes/util-linux-ng/util-linux-ng.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/util-linux-ng/util-linux-ng.inc b/recipes/util-linux-ng/util-linux-ng.inc index 9bfcc03e43..59d2f0818b 100644 --- a/recipes/util-linux-ng/util-linux-ng.inc +++ b/recipes/util-linux-ng/util-linux-ng.inc @@ -131,7 +131,7 @@ do_install () { install -d ${D}${sysconfdir}/default/ echo 'MOUNTALL="-t nonfs,nosmbfs,noncpfs"' > ${D}${sysconfdir}/default/mountall - rm ${D}${sbindir}/swap* -f + rm ${D}${sbindir}/swapoff -f ln -sf ${base_sbindir}/swapon.${PN} ${D}${base_sbindir}/swapoff.${PN} ln -sf ${sbindir}/shutdown ${D}${sbindir}/reboot.${PN} ln -sf ${sbindir}/shutdown ${D}${sbindir}/halt.${PN} -- cgit v1.2.3 From bf3ca542b4bd66e784dcd35dabd002aba7e69a1d Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Sat, 20 Jun 2009 12:41:21 +0200 Subject: clutter(-gst)-0.9: fix GLES build --- recipes/clutter/clutter-0.9_git.bb | 6 +++--- recipes/clutter/clutter-gst-0.9_git.bb | 12 +++++++----- recipes/clutter/clutter-gst.inc | 6 +++++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/recipes/clutter/clutter-0.9_git.bb b/recipes/clutter/clutter-0.9_git.bb index 6155d33fe1..ed333cef07 100644 --- a/recipes/clutter/clutter-0.9_git.bb +++ b/recipes/clutter/clutter-0.9_git.bb @@ -1,9 +1,9 @@ require clutter.inc -SRCREV = "b9a53d379d3aaca4b09a90cd44d5a9d9736a2435" +SRCREV = "fdaaa8b6d701d2b43fd2750de1b018b5af5577ea" -PV = "0.9.3" -PR = "r2" +PV = "0.9.4" +PR = "r0" PR_append = "+git${SRCREV}" SRC_URI = "git://git.clutter-project.org/clutter.git;protocol=git \ diff --git a/recipes/clutter/clutter-gst-0.9_git.bb b/recipes/clutter/clutter-gst-0.9_git.bb index f875c5d5fa..5a0b2cd18b 100644 --- a/recipes/clutter/clutter-gst-0.9_git.bb +++ b/recipes/clutter/clutter-gst-0.9_git.bb @@ -1,12 +1,14 @@ require clutter-gst.inc -SRCREV = "460826267cbb50c257cf7d957f8f9483a678da4e" +DEPENDS += "clutter-0.9" + +SRCREV = "487552b95f7ccce00118619d5b4256936621eb5e" PV = "0.9.0" -PR = "r1" +PR = "r3" PR_append = "+git${SRCREV}" -SRC_URI = "git://git.clutter-project.org/clutter-gst.git;protocol=git;branch=1.0-integration \ - file://autofoo.patch;patch=1 \ - file://0001-clutter-gst-videosink-guard-GL-calls-with-ifdef-CL.patch;patch=1" +SRC_URI = "git://git.clutter-project.org/clutter-gst.git;protocol=git \ + file://0001-clutter-gst-videosink-guard-GL-calls-with-ifdef-CL.patch;patch=1 \ + file://gtk-doc.make" S = "${WORKDIR}/git" diff --git a/recipes/clutter/clutter-gst.inc b/recipes/clutter/clutter-gst.inc index caaa7559b8..fa8f810f65 100644 --- a/recipes/clutter/clutter-gst.inc +++ b/recipes/clutter/clutter-gst.inc @@ -10,7 +10,11 @@ FILES_${PN}-examples = "${bindir}/video-player ${bindir}/video-sink ${bindir}/au inherit autotools pkgconfig do_configure_prepend() { - touch ${S}/gtk-doc.make + if [ -e ${WORKDIR}/gtk-doc.make ] ; then + cp ${WORKDIR}/gtk-doc.make ${S}/gtk-doc.make + else + touch ${S}/gtk-doc.make + fi } do_stage () { -- cgit v1.2.3 From c71a5d2885bedbec41d984fe58790141be2e52b4 Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Sat, 20 Jun 2009 19:16:30 +0200 Subject: angstrom: inheric recipe_sanity by default --- conf/distro/include/angstrom.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conf/distro/include/angstrom.inc b/conf/distro/include/angstrom.inc index 7a6e9a463a..525f949331 100644 --- a/conf/distro/include/angstrom.inc +++ b/conf/distro/include/angstrom.inc @@ -80,6 +80,9 @@ INHERIT += "angstrom-mirrors" INHERIT += "insane" QA_LOG = "1" +#run QA tests on recipes +INHERIT += "recipe_sanity" + #save statistical info on images INHERIT += "testlab" -- cgit v1.2.3 From abbbb26e6ad384278a620f3b4c2e85c235c6ccc5 Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Sat, 20 Jun 2009 19:31:33 +0200 Subject: image bbclass: fix logic buglet in lingua code --- classes/image.bbclass | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/classes/image.bbclass b/classes/image.bbclass index 0d798fa7db..864230bc91 100644 --- a/classes/image.bbclass +++ b/classes/image.bbclass @@ -243,8 +243,8 @@ if [ -e ${IMAGE_ROOTFS}/usr/bin/opkg-cl ] ; then ${OPKG} update ${OPKG} list_installed | awk '{print $1}' |sort | uniq > /tmp/installed-packages - for i in $(cat /tmp/installed-packages) ; do - for translation in ${IMAGE_LINGUAS}; do + for i in $(cat /tmp/installed-packages | grep -v locale) ; do + for translation in ${IMAGE_LINGUAS} $(echo ${IMAGE_LINGUAS} | awk -F_ '{print $1}'); do echo ${i}-locale-${translation} done done | sort | uniq > /tmp/wanted-locale-packages @@ -252,9 +252,8 @@ if [ -e ${IMAGE_ROOTFS}/usr/bin/opkg-cl ] ; then ${OPKG} list | awk '{print $1}' |grep locale |sort | uniq > /tmp/available-locale-packages cat /tmp/wanted-locale-packages /tmp/available-locale-packages | sort | uniq -d > /tmp/pending-locale-packages - cat /tmp/installed-packages /tmp/pending-locale-packages | grep locale | sort | uniq -u > /tmp/translation-list - cat /tmp/translation-list | xargs ${OPKG} -nodeps install + cat /tmp/pending-locale-packages | xargs ${OPKG} -nodeps install rm -f ${IMAGE_ROOTFS}${libdir}/opkg/lists/* for i in ${IMAGE_ROOTFS}${libdir}/opkg/info/*.preinst; do -- cgit v1.2.3 From 33f2b9be9db180fe4c3c873d944fb175a5ecf835 Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Sat, 20 Jun 2009 19:51:24 +0200 Subject: linux-omap pm 2.6.29: tweak versioning, attempt to get sound working for beagle --- .../linux-omap-pm-2.6.29/beagleboard/defconfig | 10 +++++-- .../linux-omap-pm-2.6.29/fix-audio-capture.patch | 33 ++++++++++++++++++++++ recipes/linux/linux-omap-pm_2.6.29.bb | 4 ++- 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 recipes/linux/linux-omap-pm-2.6.29/fix-audio-capture.patch diff --git a/recipes/linux/linux-omap-pm-2.6.29/beagleboard/defconfig b/recipes/linux/linux-omap-pm-2.6.29/beagleboard/defconfig index 5e0a85a708..a992a5994e 100644 --- a/recipes/linux/linux-omap-pm-2.6.29/beagleboard/defconfig +++ b/recipes/linux/linux-omap-pm-2.6.29/beagleboard/defconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Linux kernel version: 2.6.29-omap1 -# Fri Jun 19 15:20:15 2009 +# Sat Jun 20 13:15:25 2009 # CONFIG_ARM=y CONFIG_SYS_SUPPORTS_APM_EMULATION=y @@ -220,9 +220,9 @@ CONFIG_ARCH_OMAP3430=y # CONFIG_MACH_NOKIA_RX51 is not set # CONFIG_MACH_OMAP_LDP is not set # CONFIG_MACH_OMAP_3430SDP is not set -# CONFIG_MACH_OMAP3EVM is not set +CONFIG_MACH_OMAP3EVM=y CONFIG_MACH_OMAP3_BEAGLE=y -# CONFIG_MACH_OVERO is not set +CONFIG_MACH_OVERO=y # CONFIG_MACH_OMAP3_PANDORA is not set # @@ -1821,8 +1821,12 @@ CONFIG_SND_USB_CAIAQ=m CONFIG_SND_USB_CAIAQ_INPUT=y CONFIG_SND_SOC=y CONFIG_SND_OMAP_SOC=y +CONFIG_SND_OMAP_SOC_MCBSP=y +CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE=y +CONFIG_SND_OMAP_SOC_OVERO=m CONFIG_SND_SOC_I2C_AND_SPI=y # CONFIG_SND_SOC_ALL_CODECS is not set +CONFIG_SND_SOC_TWL4030=y # CONFIG_SOUND_PRIME is not set CONFIG_HID_SUPPORT=y CONFIG_HID=y diff --git a/recipes/linux/linux-omap-pm-2.6.29/fix-audio-capture.patch b/recipes/linux/linux-omap-pm-2.6.29/fix-audio-capture.patch new file mode 100644 index 0000000000..7470a7cacc --- /dev/null +++ b/recipes/linux/linux-omap-pm-2.6.29/fix-audio-capture.patch @@ -0,0 +1,33 @@ +diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c +index ee2f0d3..8b4aafb 100644 +--- a/sound/soc/codecs/twl4030.c ++++ b/sound/soc/codecs/twl4030.c +@@ -45,8 +45,8 @@ static const u8 twl4030_reg[TWL4030_CACHEREGNUM] = { + 0xc3, /* REG_OPTION (0x2) */ + 0x00, /* REG_UNKNOWN (0x3) */ + 0x00, /* REG_MICBIAS_CTL (0x4) */ +- 0x20, /* REG_ANAMICL (0x5) */ +- 0x00, /* REG_ANAMICR (0x6) */ ++ 0x34, /* REG_ANAMICL (0x5) */ ++ 0x14, /* REG_ANAMICR (0x6) */ + 0x00, /* REG_AVADC_CTL (0x7) */ + 0x00, /* REG_ADCMICSEL (0x8) */ + 0x00, /* REG_DIGMIXING (0x9) */ + +--- /tmp/Kconfig 2009-06-20 13:13:21.000000000 +0200 ++++ git/sound/soc/omap/Kconfig 2009-06-20 13:14:02.000000000 +0200 +@@ -15,6 +15,14 @@ + help + Say Y if you want to add support for SoC audio on Nokia N810. + ++config SND_OMAP_SOC_OMAP3_BEAGLE ++ tristate "SoC Audio support for OMAP3 Beagle" ++ depends on SND_OMAP_SOC && MACH_OMAP3_BEAGLE ++ select SND_OMAP_SOC_MCBSP ++ select SND_SOC_TWL4030 ++ help ++ Say Y if you want to add support for SoC audio on the Beagleboard. ++ + config SND_OMAP_SOC_OSK5912 + tristate "SoC Audio support for omap osk5912" + depends on SND_OMAP_SOC && MACH_OMAP_OSK diff --git a/recipes/linux/linux-omap-pm_2.6.29.bb b/recipes/linux/linux-omap-pm_2.6.29.bb index 9748278389..80303774f3 100644 --- a/recipes/linux/linux-omap-pm_2.6.29.bb +++ b/recipes/linux/linux-omap-pm_2.6.29.bb @@ -7,7 +7,8 @@ COMPATIBLE_MACHINE = "omap5912osk|omap1710h3|omap2430sdp|omap2420h4|beagleboard| SRCREV = "cbfc461bd5c4d0aff8501dd82db18146a22f49cf" -PV = "2.6.29-pm1+gitr${SRCREV}" +PV = "2.6.29" +MACHINE_KERNEL_PR_append = "-pm1+gitr${SRCREV}" SRC_URI = "git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git;protocol=git;branch=pm-2.6.29 \ file://defconfig" @@ -93,6 +94,7 @@ SRC_URI_append = " \ file://dss2/merge-fixups.diff;patch=1 \ file://overo-cpufreq.diff;patch=1 \ file://register-all-OPPs.diff;patch=1 \ + file://fix-audio-capture.patch;patch=1 \ " -- cgit v1.2.3 From 88a723232bc43676679951c0b115a42daf032528 Mon Sep 17 00:00:00 2001 From: Andrea Adami Date: Sat, 20 Jun 2009 23:14:10 +0200 Subject: kexecboot: sanitize recipe - recipe_sanity: RDEPENDS should not be set, but is set to 'kexec-static' - Phil Blundell:" - In almost all cases the app ought to be setting RDEPENDS_${PN}, not - RDEPENDS. Otherwise the documentation, debug data and suchlike will - end up getting the same dependency, which is seldom useful. - The same goes for most of the other R* variables." --- recipes/kexecboot/kexecboot.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/kexecboot/kexecboot.inc b/recipes/kexecboot/kexecboot.inc index 5f3f34948e..fdcbf55621 100644 --- a/recipes/kexecboot/kexecboot.inc +++ b/recipes/kexecboot/kexecboot.inc @@ -1,7 +1,7 @@ LICENSE = "GPL" DEPENDS = "klibc" -RDEPENDS = "kexec-static" +RDEPENDS_${PN} = "kexec-static" inherit autotools -- cgit v1.2.3 From 0219e9fd2fdb945dcaa6e24c7ce3e07d269d9ecc Mon Sep 17 00:00:00 2001 From: Andrea Adami Date: Sun, 21 Jun 2009 00:25:46 +0200 Subject: kexec-tools: rename static recipes built against klibc --- .../initramfs-module-kexecboot_1.0.bb | 2 +- recipes/kexec/kexec-tools-klibc-static_1.101.bb | 22 ++++++++++++++++++++ recipes/kexec/kexec-tools-klibc-static_2.0.0.bb | 24 ++++++++++++++++++++++ recipes/kexec/kexec-tools-static_1.101.bb | 23 --------------------- recipes/kexec/kexec-tools-static_2.0.0.bb | 24 ---------------------- recipes/kexecboot/kexecboot.inc | 2 +- 6 files changed, 48 insertions(+), 49 deletions(-) create mode 100644 recipes/kexec/kexec-tools-klibc-static_1.101.bb create mode 100644 recipes/kexec/kexec-tools-klibc-static_2.0.0.bb delete mode 100644 recipes/kexec/kexec-tools-static_1.101.bb delete mode 100644 recipes/kexec/kexec-tools-static_2.0.0.bb diff --git a/recipes/initrdscripts/initramfs-module-kexecboot_1.0.bb b/recipes/initrdscripts/initramfs-module-kexecboot_1.0.bb index 3080269920..7f1e7cd5f9 100644 --- a/recipes/initrdscripts/initramfs-module-kexecboot_1.0.bb +++ b/recipes/initrdscripts/initramfs-module-kexecboot_1.0.bb @@ -1,7 +1,7 @@ SRC_URI = "file://87-kexecboot.sh" PR = "r2" DESCRIPTION = "An initramfs module for kexecing kernel from rootfs." -RDEPENDS = "initramfs-uniboot kexec-static" +RDEPENDS = "initramfs-uniboot kexec-klibc-static" do_install() { install -d ${D}/initrd.d diff --git a/recipes/kexec/kexec-tools-klibc-static_1.101.bb b/recipes/kexec/kexec-tools-klibc-static_1.101.bb new file mode 100644 index 0000000000..4ad59ce257 --- /dev/null +++ b/recipes/kexec/kexec-tools-klibc-static_1.101.bb @@ -0,0 +1,22 @@ +# the binaries are statical linked against klibc +require kexec-tools.inc + +PR = "r5" +DEPENDS = "klibc" + +SRC_URI += "file://kexec-klibc.patch;patch=1" +S = "${WORKDIR}/kexec-tools-${PV}" + +EXTRA_OECONF = " --without-zlib" + +export CC=${TARGET_PREFIX}klcc + +# standart oe cflags don't work with klcc +export CFLAGS="" +export CPPFLAGS="" +export LDFLAGS="" + +PACKAGES =+ "kexec-klibc-static kdump-klibc-static" + +FILES_kexec-klibc-static = "${sbindir}/kexec" +FILES_kdump-klibc-static = "${sbindir}/kdump" diff --git a/recipes/kexec/kexec-tools-klibc-static_2.0.0.bb b/recipes/kexec/kexec-tools-klibc-static_2.0.0.bb new file mode 100644 index 0000000000..da12db185b --- /dev/null +++ b/recipes/kexec/kexec-tools-klibc-static_2.0.0.bb @@ -0,0 +1,24 @@ +# the binaries are statical linked against klibc +require kexec-tools2.inc + +DEFAULT_PREFERENCE = "-1" + +PR = "r0" +DEPENDS = "klibc" + +SRC_URI += "file://kexec2-klibc.patch;patch=1" +S = "${WORKDIR}/kexec-tools-${PV}" + +EXTRA_OECONF = " --without-zlib" + +export CC=${TARGET_PREFIX}klcc + +# standart oe cflags don't work with klcc +export CFLAGS="" +export CPPFLAGS="" +export LDFLAGS="" + +PACKAGES =+ "kexec-klibc-static kdump-klibc-static" + +FILES_kexec-klibc-static = "${sbindir}/kexec" +FILES_kdump-klibc-static = "${sbindir}/kdump" diff --git a/recipes/kexec/kexec-tools-static_1.101.bb b/recipes/kexec/kexec-tools-static_1.101.bb deleted file mode 100644 index ea44b57cf1..0000000000 --- a/recipes/kexec/kexec-tools-static_1.101.bb +++ /dev/null @@ -1,23 +0,0 @@ -# the binaries are statical linked against klibc -require kexec-tools.inc - -PR = "r5" -DEPENDS = "klibc" - -SRC_URI += "file://kexec-klibc.patch;patch=1" -S = "${WORKDIR}/kexec-tools-${PV}" - -EXTRA_OECONF = " --without-zlib" - -export CC=${TARGET_PREFIX}klcc - -# standart oe cflags don't work with klcc -export CFLAGS="" -export CPPFLAGS="" -export LDFLAGS="" - -PACKAGES =+ "kexec-static kdump-static" - -FILES_kexec-static = "${sbindir}/kexec" -FILES_kdump-static = "${sbindir}/kdump" - diff --git a/recipes/kexec/kexec-tools-static_2.0.0.bb b/recipes/kexec/kexec-tools-static_2.0.0.bb deleted file mode 100644 index a0d02aa9ac..0000000000 --- a/recipes/kexec/kexec-tools-static_2.0.0.bb +++ /dev/null @@ -1,24 +0,0 @@ -# the binaries are statical linked against klibc -require kexec-tools2.inc - -DEFAULT_PREFERENCE = "-1" - -PR = "r0" -DEPENDS = "klibc" - -SRC_URI += "file://kexec2-klibc.patch;patch=1" -S = "${WORKDIR}/kexec-tools-${PV}" - -EXTRA_OECONF = " --without-zlib" - -export CC=${TARGET_PREFIX}klcc - -# standart oe cflags don't work with klcc -export CFLAGS="" -export CPPFLAGS="" -export LDFLAGS="" - -PACKAGES =+ "kexec-static kdump-static" - -FILES_kexec-static = "${sbindir}/kexec" -FILES_kdump-static = "${sbindir}/kdump" diff --git a/recipes/kexecboot/kexecboot.inc b/recipes/kexecboot/kexecboot.inc index fdcbf55621..ebd193beea 100644 --- a/recipes/kexecboot/kexecboot.inc +++ b/recipes/kexecboot/kexecboot.inc @@ -1,7 +1,7 @@ LICENSE = "GPL" DEPENDS = "klibc" -RDEPENDS_${PN} = "kexec-static" +RDEPENDS_${PN} = "kexec-klibc-static" inherit autotools -- cgit v1.2.3 From e71f23a8ef42b469829a88accb4988bce61aace5 Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Sun, 21 Jun 2009 10:22:03 +0200 Subject: checksums: add more checksums --- conf/checksums.ini | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/conf/checksums.ini b/conf/checksums.ini index 5ed7513a79..21aa9a4f7c 100644 --- a/conf/checksums.ini +++ b/conf/checksums.ini @@ -1026,6 +1026,14 @@ sha256=6fd69febfd804437a9d5b610502c6d3c2caabef7a4832a3bcac2357515adaa71 md5=e65a007157e3e26807db52299497109d sha256=e064a939bf7e37774b89a39515ecf96c4d19c81e050bcf0dae28d1eab4d86196 +[http://install.source.dir.com/TI-C6x-CGT-v6.0.16-eval.tar.gz] +md5=152fdf383df154b33478a0312752bade +sha256=0eb1d3af0a02179edb91b5468972265f13c3a89990549f289233c0784937ab9e + +[http://install.source.dir.com/TI-C6x-CGT-v6.0.21-eval.tar.gz] +md5=65c8166ad0edb468c5327d1109d84229 +sha256=6011f7a10fa71a540503fc8d54140728022ec89eb8bc2ef344002bb11cf25667 + [http://sdgsystems.com/pub/ipaq/hx4700/src/TIInit_3.2.26.bts] md5=8741490a25b98230973446400971bba9 sha256=c1f29cfd31c335a409bdc530c2e68661d20a1e3c2e5d64454470b6700a40681e @@ -4594,6 +4602,10 @@ sha256=22b1f489afef6849919220591ffc51615b9cddbea61b66b43791fdeebb4dbe09 md5=78012718a15d43e2c4952db7409c9e7e sha256=792776053c5842c4335d3f17d9f0c789063ad34c4fc0e2ccabbdefbd84f14726 +[http://arago-project.org/files/short-term/demo/demo-app-src.tar.gz] +md5=92cea8c3ea5db7ad6073b0feb33cf911 +sha256=caf7aa9ea60947bf6fb03ecee8bf3ea2ddf250fe2486ae24b8349d6ff3b74d3d + [http://freedesktop.org/software/desktop-file-utils/releases/desktop-file-utils-0.14.tar.gz] md5=e0b5057a4e3166f34635ac6f27c712c0 sha256=97856d2621d4e3273340b7f1172c2e074c74263629b05bde0f0f077425ec0699 @@ -9722,6 +9734,10 @@ sha256=05d83a609aaea44ea8c979897f336cb8b5537a39b271af2831e6cca3851d3007 md5=75a3359ece6a1c11a9e5463d79e274e8 sha256=b50072ff6f36087b8ecebf509e6d44ab2e91292b1a3a5806a7f1437a382723e9 +[http://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-0.10.12.tar.bz2] +md5=63309cf0bb21f3efd4e43868c314f919 +sha256=18387f78b721ce6b56c02f886ec89774a4e58b7883c70ab2ae6c1af58f1661c9 + [http://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-0.10.3.tar.bz2] md5=8545a02c408976c5e9f0c2cf3c6a362e sha256=648f1ef813c64c7eedd45d164eb41ba21366bba8ec5fcbff3100458721be489e @@ -10946,6 +10962,10 @@ sha256=11a5f5084488c480f3ff5a24d64d7147bb64272bf60a0ba51330a56c5b50cab9 md5=82e7c8fdb6211839246b788c040a796b sha256=a606e230b22d9d029998b84e5d6311a8ba35a304fe457e254eb5fd19943cd639 +[http://arago-project.org/files/short-term/demo/images.tar.bz2] +md5=a080f5a4ed42c56767c07e55c1266727 +sha256=9c6f58c44051563a788f7e9202957d839822081d99ecb001314265166c20eb95 + [http://xorg.freedesktop.org/releases/individual/util/imake-1.0.2.tar.gz] md5=b5c3a719d60a14ca2378dc1259ee60df sha256=8008b4366ab96abfdac2c91808b79ec2cc5649966b41cfb07b14b6fbd798651c @@ -23138,6 +23158,10 @@ sha256=11b067df2ce38baa36566bd29ab14bbf2f7c0fcc15e01a5be2a6a85000c39104 md5=e6388feb0ffcd189af779f165c124b4d sha256=6b964fb220a46438adf6ec37082da66332a3ce74ca4913b863b17d9ab720681f +[http://install.source.dir.com/ti_cgt_c6000_6.0.21_setup_linux_x86.bin] +md5=5bfeaacb628b56005a8865a177af01e4 +sha256=fcfa98e2c8ff18e8e6d5b2ff5e94f20b719150fe7bb4a130cfa360e02df2156a + [http://www.openzaurus.org/download/3.5.4/sources/tickypip-0.1.2.tar.gz] md5=5a085296b1147fe970a256a9b2d0f91f sha256=f3b5722c145ebeee3523b4941afdaf75d03a56f1922a9d3662dc1715aa24ca34 -- cgit v1.2.3 From 04d8917f4ce8bd97882c3731fbf47aef467f0fc0 Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Sun, 21 Jun 2009 12:43:24 +0200 Subject: dvsdk: sync with TI overlay, but change a few things: * fix toolchain paths to work with internal toolchains * start installing to ${datadir} again * use MACHINE_KERNEL_PR for kernel modules * and more fixes --- recipes/dvsdk/gstreamer-ti_svn.bb | 15 +++++--- recipes/dvsdk/readme.txt | 11 ++---- recipes/dvsdk/ti-cgt6x-native_6.0.16.bb | 18 ---------- recipes/dvsdk/ti-cgt6x-native_6.0.21.bb | 20 +++++++++++ recipes/dvsdk/ti-cgt6x-sdk_6.0.16.bb | 26 -------------- recipes/dvsdk/ti-cgt6x-sdk_6.0.21.bb | 26 ++++++++++++++ recipes/dvsdk/ti-cgt6x.inc | 40 ++++++++++++++++++++++ recipes/dvsdk/ti-cmem-module_2.23.1.bb | 10 ++++-- recipes/dvsdk/ti-cmem-module_2.23.bb | 3 +- recipes/dvsdk/ti-codec-combo-dm355-sdk_1.13.bb | 2 +- recipes/dvsdk/ti-codec-combo-dm355_1.13.bb | 4 +-- recipes/dvsdk/ti-codec-combo-dm6446-sdk_2.05.bb | 31 +++++++++++++++++ recipes/dvsdk/ti-codec-combo-dm6446_2.05.bb | 32 +++++++++++++++++ .../dvsdk/ti-codec-combo-omap3530-sdk_3.16.1.bb | 2 +- recipes/dvsdk/ti-codec-combo-omap3530_3.16.1.bb | 26 ++++++++++++-- recipes/dvsdk/ti-codec-engine-sdk_2.23.1.bb | 2 +- recipes/dvsdk/ti-codec-engine_2.23.1.bb | 10 +++--- recipes/dvsdk/ti-dm355mm-module_1.13.bb | 3 +- recipes/dvsdk/ti-dmai.inc | 3 +- recipes/dvsdk/ti-dmai_svn.bb | 2 +- recipes/dvsdk/ti-dspbios-native_5.33.02.bb | 2 +- recipes/dvsdk/ti-dspbios-sdk_5.33.02.bb | 2 +- recipes/dvsdk/ti-dsplink-module_1.61.3.bb | 13 +++---- recipes/dvsdk/ti-lpm-module_2.23.1.bb | 4 ++- recipes/dvsdk/ti-rules-make-sdk.bb | 2 +- recipes/dvsdk/ti-sdma-module_2.23.1.bb | 3 +- recipes/dvsdk/ti-xdctools-native_3.10.03.bb | 2 +- recipes/dvsdk/ti-xdctools-sdk_3.10.03.bb | 2 +- 28 files changed, 223 insertions(+), 93 deletions(-) delete mode 100644 recipes/dvsdk/ti-cgt6x-native_6.0.16.bb create mode 100644 recipes/dvsdk/ti-cgt6x-native_6.0.21.bb delete mode 100644 recipes/dvsdk/ti-cgt6x-sdk_6.0.16.bb create mode 100644 recipes/dvsdk/ti-cgt6x-sdk_6.0.21.bb create mode 100644 recipes/dvsdk/ti-codec-combo-dm6446-sdk_2.05.bb create mode 100644 recipes/dvsdk/ti-codec-combo-dm6446_2.05.bb diff --git a/recipes/dvsdk/gstreamer-ti_svn.bb b/recipes/dvsdk/gstreamer-ti_svn.bb index 85d85e0467..6eeffd0225 100644 --- a/recipes/dvsdk/gstreamer-ti_svn.bb +++ b/recipes/dvsdk/gstreamer-ti_svn.bb @@ -10,12 +10,14 @@ SRC_URI = "svn://gforge.ti.com/svn/gstreamer_ti/trunk;module=gstreamer_ti;proto= " # Again, no '.' in PWD allowed :( -PR = "r17" +PR = "r23" PV = "svnr${SRCREV}" S = "${WORKDIR}/gstreamer_ti/ti_build/ticodecplugin" -installdir = "${prefix}/ti" +installdir = "${datadir}/ti" + +META_SDK_PATH ?= "${CROSS_DIR}" DMAI_INSTALL_DIR = "${STAGING_DIR}/${MULTIMACH_TARGET_SYS}/ti-dmai" CE_INSTALL_DIR="${STAGING_DIR}/${MULTIMACH_TARGET_SYS}/ti-codec-engine" @@ -52,9 +54,9 @@ PLATFORM_beagleboard = "omap3530" export PLATFORM -CROSS_COMPILE = "${CROSS_DIR}/bin/${TARGET_PREFIX}" -CSTOOL_DIR = "${CROSS_DIR}" -MVTOOL_DIR = "${CROSS_DIR}" +CROSS_COMPILE=${META_SDK_PATH}/bin/${TARGET_PREFIX} +CSTOOL_DIR=${META_SDK_PATH} +MVTOOL_DIR=${META_SDK_PATH} export CROSS_COMPILE export CSTOOL_DIR export MVTOOL_DIR @@ -72,6 +74,9 @@ do_install_prepend () { # default loadmodule script is hard-coded for insmod, change to modprobe sed -i 's/insmod/modprobe/g' ${D}/${installdir}/gst/${PLATFORM}/loadmodules.sh sed -i 's/.ko//g' ${D}/${installdir}/gst/${PLATFORM}/loadmodules.sh + if [ "${PLATFORM}" = "omap3530" ]; then + echo "modprobe sdmak" >> ${D}/${installdir}/gst/${PLATFORM}/loadmodules.sh + fi chmod 0755 ${D}/${installdir}/gst -R } diff --git a/recipes/dvsdk/readme.txt b/recipes/dvsdk/readme.txt index 8dd71e6fee..daf7bf6be5 100644 --- a/recipes/dvsdk/readme.txt +++ b/recipes/dvsdk/readme.txt @@ -1,10 +1,5 @@ -placeholder for readme -todo with this package -- rename top level dsplink directory -- repartion code into different recipes - create codecengine-examples package -/DONE - fix lpm build to pick up Module.symversion -- cleanup device selection script - not good to just /d the targets - need cleaner solution -- staging needs work +The software needed can be downloaded from: +* http://software-dl.ti.com/dsps/dsps_registered_sw/sdo_sb/targetcontent/ +* https://www-a.ti.com/downloads/sds_support/TICodegenerationTools/download.htm -- add ce 2.22 diff --git a/recipes/dvsdk/ti-cgt6x-native_6.0.16.bb b/recipes/dvsdk/ti-cgt6x-native_6.0.16.bb deleted file mode 100644 index 310662435f..0000000000 --- a/recipes/dvsdk/ti-cgt6x-native_6.0.16.bb +++ /dev/null @@ -1,18 +0,0 @@ -require ti-cgt6x.inc -inherit native - -SRC_URI = "http://install.source.dir.com/TI-C6x-CGT-v6.0.16-eval.tar.gz" - -S = "${WORKDIR}/cg6x_6_0_16" - -# Yes, the xdc stuff still breaks with a '.' in PWD -PV = "6016" -PR = "r12" - -do_stage() { - install -d ${STAGING_DIR_NATIVE}/${PN} - cp -pPrf ${S}/* ${STAGING_DIR_NATIVE}/${PN}/ -} - -AUTOTOOLS_NATIVE_STAGE_INSTALL="1" - diff --git a/recipes/dvsdk/ti-cgt6x-native_6.0.21.bb b/recipes/dvsdk/ti-cgt6x-native_6.0.21.bb new file mode 100644 index 0000000000..d980f46c16 --- /dev/null +++ b/recipes/dvsdk/ti-cgt6x-native_6.0.21.bb @@ -0,0 +1,20 @@ +require ti-cgt6x.inc +inherit native + +SRC_URI = "http://install.source.dir.com/ti_cgt_c6000_6.0.21_setup_linux_x86.bin" + +BINFILE="ti_cgt_c6000_6.0.21_setup_linux_x86.bin" + +S = "${WORKDIR}/cgt" + +# Yes, the xdc stuff still breaks with a '.' in PWD +PV = "6021" +PR = "r3" + +do_stage() { + install -d ${STAGING_DIR_NATIVE}/${PN} + cp -pPrf ${S}/* ${STAGING_DIR_NATIVE}/${PN}/ +} + +AUTOTOOLS_NATIVE_STAGE_INSTALL="1" + diff --git a/recipes/dvsdk/ti-cgt6x-sdk_6.0.16.bb b/recipes/dvsdk/ti-cgt6x-sdk_6.0.16.bb deleted file mode 100644 index 52b99b4eb0..0000000000 --- a/recipes/dvsdk/ti-cgt6x-sdk_6.0.16.bb +++ /dev/null @@ -1,26 +0,0 @@ -require ti-cgt6x.inc -inherit sdk - -SRC_URI = "http://install.source.dir.com/TI-C6x-CGT-v6.0.16-eval.tar.gz" - -S = "${WORKDIR}/cg6x_6_0_16" - -# Yes, the xdc stuff still breaks with a '.' in PWD -PV = "6016" -PR = "r12" - -do_install() { - install -d ${D}/${prefix}/dvsdk/cg6x_6_0_16 - cp -pPrf ${S}/* ${D}/${prefix}/dvsdk/cg6x_6_0_16 - - # Creates rules.make file - mkdir -p ${STAGING_DIR_HOST}/ti-sdk-rules - echo "# Where the TI C6x codegen tool is installed." > ${STAGING_DIR_HOST}/ti-sdk-rules/cgt6x.Rules.make - echo "CODEGEN_INSTALL_DIR=${prefix}/dvsdk/cg6x_6_0_16" >> ${STAGING_DIR_HOST}/ti-sdk-rules/cgt6x.Rules.make - echo "" >> ${STAGING_DIR_HOST}/ti-sdk-rules/cgt6x.Rules.make -} - -INHIBIT_PACKAGE_STRIP = "1" -FILES_${PN} = "${prefix}/dvsdk/cg6x_6_0_16" -INSANE_SKIP_${PN} = True - diff --git a/recipes/dvsdk/ti-cgt6x-sdk_6.0.21.bb b/recipes/dvsdk/ti-cgt6x-sdk_6.0.21.bb new file mode 100644 index 0000000000..f0ad126ac4 --- /dev/null +++ b/recipes/dvsdk/ti-cgt6x-sdk_6.0.21.bb @@ -0,0 +1,26 @@ +require ti-cgt6x.inc +inherit sdk + +SRC_URI = "http://install.source.dir.com/ti_cgt_c6000_6.0.21_setup_linux_x86.bin" + +S = "${WORKDIR}/cgt" + +# Yes, the xdc stuff still breaks with a '.' in PWD +PV = "6021" +PR = "r3" + +do_install() { + install -d ${D}/${prefix}/dvsdk/cg6x_6_0_21 + cp -pPrf ${S}/* ${D}/${prefix}/dvsdk/cg6x_6_0_21 + + # Creates rules.make file + mkdir -p ${STAGING_DIR_HOST}/ti-sdk-rules + echo "# Where the TI C6x codegen tool is installed." > ${STAGING_DIR_HOST}/ti-sdk-rules/cgt6x.Rules.make + echo "CODEGEN_INSTALL_DIR=${prefix}/dvsdk/cg6x_6_0_21" >> ${STAGING_DIR_HOST}/ti-sdk-rules/cgt6x.Rules.make + echo "" >> ${STAGING_DIR_HOST}/ti-sdk-rules/cgt6x.Rules.make +} + +INHIBIT_PACKAGE_STRIP = "1" +FILES_${PN} = "${prefix}/dvsdk/cg6x_6_0_21" +INSANE_SKIP_${PN} = True + diff --git a/recipes/dvsdk/ti-cgt6x.inc b/recipes/dvsdk/ti-cgt6x.inc index ad76cfe31f..35a9252cfe 100644 --- a/recipes/dvsdk/ti-cgt6x.inc +++ b/recipes/dvsdk/ti-cgt6x.inc @@ -1,2 +1,42 @@ DESCRIPTION = "Code Generation Tools for TI DaVinci and OMAP" +# This file defines function used for extracting .bin file + +python do_unpack () { + bb.build.exec_func('base_do_unpack', d) + bb.build.exec_func('ti_bin_do_unpack', d) +} + +python ti_bin_do_unpack() { + + import os + + localdata = bb.data.createCopy(d) + bb.data.update_data(localdata) + + binfile = bb.data.getVar('BINFILE', localdata) + + # Change to the working directory + save_cwd = os.getcwd() + workdir = bb.data.getVar('WORKDIR', localdata) + workdir = bb.data.expand(workdir, localdata) + os.chdir(workdir) + + # Make the InstallJammer binary executable so we can run it + os.chmod(binfile, 0755) + + # Run the InstallJammer binary and accept the EULA + filename = "HOME=%s ./%s" % (workdir, binfile) + f = os.popen(filename,'w') + print >>f, "Y\n" + print >>f, "qY\n" + print >>f, "%s/cgt\n" % workdir + print >>f, " \n" + print >>f, " \n" + + f.close() + + # Return to the previous directory + os.chdir(save_cwd) +} + diff --git a/recipes/dvsdk/ti-cmem-module_2.23.1.bb b/recipes/dvsdk/ti-cmem-module_2.23.1.bb index 097319c722..f02383d980 100644 --- a/recipes/dvsdk/ti-cmem-module_2.23.1.bb +++ b/recipes/dvsdk/ti-cmem-module_2.23.1.bb @@ -5,12 +5,16 @@ inherit module DEPENDS = "virtual/kernel perl-native" RDEPENDS = "update-modules" +# Download codec_engine_2_23_01.tar.gz from +# https://www-a.ti.com/downloads/sds_support/targetcontent/CE/ce_2_23/index.html + SRC_URI = "http://install.source.dir.com/codec_engine_2_23_01.tar.gz" # Set the source directory S = "${WORKDIR}/codec_engine_2_23_01" -PR = "r18" +#This is a kernel module, don't set PR directly +MACHINE_KERNEL_PR_append = "a" PV = "2231" do_compile() { @@ -38,7 +42,7 @@ do_install () { LINUXKERNEL_INSTALL_DIR="${STAGING_KERNEL_DIR}" \ MVTOOL_PREFIX="${TARGET_PREFIX}" \ UCTOOL_PREFIX="${TARGET_PREFIX}" \ - EXEC_DIR="${D}${prefix}/ti/ti-cmem-apps" \ + EXEC_DIR="${D}${datadir}/ti/ti-cmem-apps" \ install } @@ -57,7 +61,7 @@ pkg_postrm () { INHIBIT_PACKAGE_STRIP = "1" FILES_${PN} = "/lib/modules/${KERNEL_VERSION}/kernel/drivers/dsp/cmemk.ko" PACKAGES += " ti-cmem-apps" -FILES_ti-cmem-apps = "${prefix}/ti/ti-cmem-apps/*" +FILES_ti-cmem-apps = "${datadir}/ti/ti-cmem-apps/*" INSANE_SKIP_ti-cmem-apps = True diff --git a/recipes/dvsdk/ti-cmem-module_2.23.bb b/recipes/dvsdk/ti-cmem-module_2.23.bb index 15f8af349e..60324fbc30 100644 --- a/recipes/dvsdk/ti-cmem-module_2.23.bb +++ b/recipes/dvsdk/ti-cmem-module_2.23.bb @@ -10,7 +10,8 @@ SRC_URI = "http://install.source.dir.com/codec_engine_2_23.tar.gz" # Set the source directory S = "${WORKDIR}/codec_engine_2_23" -PR = "r11" +#This is a kernel module, don't set PR directly +MACHINE_KERNEL_PR_append = "a" PV = "223" do_compile() { diff --git a/recipes/dvsdk/ti-codec-combo-dm355-sdk_1.13.bb b/recipes/dvsdk/ti-codec-combo-dm355-sdk_1.13.bb index 3a63faf7e7..05952d2a6a 100644 --- a/recipes/dvsdk/ti-codec-combo-dm355-sdk_1.13.bb +++ b/recipes/dvsdk/ti-codec-combo-dm355-sdk_1.13.bb @@ -12,7 +12,7 @@ BINFILE="dm355_codecs_setuplinux_1_13_000.bin" # Yes, the xdc stuff still breaks with a '.' in PWD PV = "113" -PR = "r13" +PR = "r16" do_compile() { echo "Do nothing" diff --git a/recipes/dvsdk/ti-codec-combo-dm355_1.13.bb b/recipes/dvsdk/ti-codec-combo-dm355_1.13.bb index 3827a1f7e1..cfc1c9005a 100644 --- a/recipes/dvsdk/ti-codec-combo-dm355_1.13.bb +++ b/recipes/dvsdk/ti-codec-combo-dm355_1.13.bb @@ -7,11 +7,11 @@ SRC_URI = "http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/dv S = "${WORKDIR}/dm355_codecs_1_13_000" BINFILE="dm355_codecs_setuplinux_1_13_000.bin" -installdir = "${prefix}/ti" +installdir = "${datadir}/ti" # Yes, the xdc stuff still breaks with a '.' in PWD PV = "113" -PR = "r12" +PR = "r15" do_compile() { echo "Do nothing" diff --git a/recipes/dvsdk/ti-codec-combo-dm6446-sdk_2.05.bb b/recipes/dvsdk/ti-codec-combo-dm6446-sdk_2.05.bb new file mode 100644 index 0000000000..f02d49a048 --- /dev/null +++ b/recipes/dvsdk/ti-codec-combo-dm6446-sdk_2.05.bb @@ -0,0 +1,31 @@ +DESCRIPTION = "DM6446 Codec Combo 2.05" +inherit sdk + +# Should be replaced with real http URL, but for now create codec combo tar from DVSDK installation. +SRC_URI = "ftp://install.source.dir.com/dm6446_dvsdk_combos_2_05.tar.gz" + +S = "${WORKDIR}/dm6446_dvsdk_combos_2_05" + +# Yes, the xdc stuff still breaks with a '.' in PWD +PV = "205" +PR = "r10" + +# DM6446 combo has Makefile. We don't want to rebuild anything here. +do_compile() { + echo "do nothing" +} + +do_install() { + install -d ${D}/${prefix}/dvsdk/dm6446_dvsdk_combos_2_05 + cp -pPrf ${S}/* ${D}/${prefix}/dvsdk/dm6446_dvsdk_combos_2_05 + + # Creates rules.make file + mkdir -p ${STAGING_DIR_HOST}/ti-sdk-rules + echo "# Where the codec servers are installed." > ${STAGING_DIR_HOST}/ti-sdk-rules/codec.Rules.make + echo "CODEC_INSTALL_DIR=${prefix}/dvsdk/dm6446_dvsdk_combos_2_05" >> ${STAGING_DIR_HOST}/ti-sdk-rules/codec.Rules.make +} + +INHIBIT_PACKAGE_STRIP = "1" +INSANE_SKIP_${PN} = True +FILES_${PN} = "${prefix}/dvsdk/dm6446_dvsdk_combos_2_05/*" + diff --git a/recipes/dvsdk/ti-codec-combo-dm6446_2.05.bb b/recipes/dvsdk/ti-codec-combo-dm6446_2.05.bb new file mode 100644 index 0000000000..04f946bc19 --- /dev/null +++ b/recipes/dvsdk/ti-codec-combo-dm6446_2.05.bb @@ -0,0 +1,32 @@ +DESCRIPTION = "DM6446 Codec Combo 2.05" + +# Should be replaced with real http URL, but for now create codec combo tar from DVSDK installation. +SRC_URI = "http://install.source.dir.com/dm6446_dvsdk_combos_2_05.tar.gz" + +S = "${WORKDIR}/dm6446_dvsdk_combos_2_05" + +# Yes, the xdc stuff still breaks with a '.' in PWD +PV = "205" +PR = "r11" + +installdir = "${datadir}/ti" +do_compile() { + echo "do nothing" +} + +do_install () { + install -d ${D}/${installdir}/codec-combo + cd ${S} + for file in `find . -name *.x64P`; do + cp ${file} ${D}/${installdir}/codec-combo + done +} + +do_stage() { + install -d ${STAGING_DIR}/${MULTIMACH_TARGET_SYS}/${PN} + cp -pPrf ${S}/* ${STAGING_DIR}/${MULTIMACH_TARGET_SYS}/${PN}/ +} + +PACKAGE_ARCH = "${MACHINE_ARCH}" +FILES_${PN} = "/${installdir}/codec-combo/*" + diff --git a/recipes/dvsdk/ti-codec-combo-omap3530-sdk_3.16.1.bb b/recipes/dvsdk/ti-codec-combo-omap3530-sdk_3.16.1.bb index 0a396c7ba6..966e568af9 100644 --- a/recipes/dvsdk/ti-codec-combo-omap3530-sdk_3.16.1.bb +++ b/recipes/dvsdk/ti-codec-combo-omap3530-sdk_3.16.1.bb @@ -13,7 +13,7 @@ S = "${WORKDIR}/omap3530_dvsdk_combos_tspa_3_16_01" # Yes, the xdc stuff still breaks with a '.' in PWD PV = "316" -PR = "r8" +PR = "r10" do_compile () { echo "No nothing" diff --git a/recipes/dvsdk/ti-codec-combo-omap3530_3.16.1.bb b/recipes/dvsdk/ti-codec-combo-omap3530_3.16.1.bb index 154527a700..76ebb46818 100644 --- a/recipes/dvsdk/ti-codec-combo-omap3530_3.16.1.bb +++ b/recipes/dvsdk/ti-codec-combo-omap3530_3.16.1.bb @@ -10,13 +10,33 @@ TARFILE = "omap3530_dvsdk_combos_tspa/omap3530_dvsdk_combos_tspa_3_16_01.tar.gz" S = "${WORKDIR}/omap3530_dvsdk_combos_tspa_3_16_01" +DEPENDS="ti-codec-engine" + +CE_INSTALL_DIR="${STAGING_DIR}/${MULTIMACH_TARGET_SYS}/ti-codec-engine" +FC_INSTALL_DIR="${STAGING_DIR}/${MULTIMACH_TARGET_SYS}/ti-codec-engine/cetools" +LINK_INSTALL_DIR="${STAGING_DIR}/${MULTIMACH_TARGET_SYS}/ti-codec-engine/cetools" +CMEM_INSTALL_DIR="${STAGING_DIR}/${MULTIMACH_TARGET_SYS}/ti-codec-engine/cetools" +LPM_INSTALL_DIR="${STAGING_DIR}/${MULTIMACH_TARGET_SYS}/ti-codec-engine/cetools" +BIOS_INSTALL_DIR="${STAGING_DIR_NATIVE}/ti-dspbios-native" +CODEGEN_INSTALL_DIR="${STAGING_DIR_NATIVE}/ti-cgt6x-native" +XDC_INSTALL_DIR="${STAGING_DIR_NATIVE}/ti-xdctools-native" + +export ${CODEGEN_INSTALL_DIR} + # Yes, the xdc stuff still breaks with a '.' in PWD PV = "3161" -PR = "r9" -installdir = "${prefix}/ti" +PR = "r12" +installdir = "${datadir}/ti" do_compile() { - echo "Do not rebuild for now" + make CE_INSTALL_DIR=${CE_INSTALL_DIR} \ + FC_INSTALL_DIR=${FC_INSTALL_DIR} \ + LINK_INSTALL_DIR=${LINK_INSTALL_DIR} \ + CMEM_INSTALL_DIR=${CMEM_INSTALL_DIR} \ + LPM_INSTALL_DIR=${LPM_INSTALL_DIR} \ + BIOS_INSTALL_DIR=${BIOS_INSTALL_DIR} \ + CODEGEN_INSTALL_DIR=${CODEGEN_INSTALL_DIR} \ + XDC_INSTALL_DIR=${XDC_INSTALL_DIR} \ } do_install () { diff --git a/recipes/dvsdk/ti-codec-engine-sdk_2.23.1.bb b/recipes/dvsdk/ti-codec-engine-sdk_2.23.1.bb index 340a222315..4f9f6b9bf1 100644 --- a/recipes/dvsdk/ti-codec-engine-sdk_2.23.1.bb +++ b/recipes/dvsdk/ti-codec-engine-sdk_2.23.1.bb @@ -2,7 +2,7 @@ DESCRIPTION = "Codec Engine 2.23.01 for TI ARM/DSP processors" inherit sdk # tconf from xdctools dislikes '.' in pwd :/ -PR = "r11" +PR = "r17" PV = "2231" SRC_URI = "http://install.source.dir.com/codec_engine_2_23_01.tar.gz " diff --git a/recipes/dvsdk/ti-codec-engine_2.23.1.bb b/recipes/dvsdk/ti-codec-engine_2.23.1.bb index 3d06971a60..a553476427 100644 --- a/recipes/dvsdk/ti-codec-engine_2.23.1.bb +++ b/recipes/dvsdk/ti-codec-engine_2.23.1.bb @@ -1,13 +1,13 @@ DESCRIPTION = "Codec Engine 2.23.01 for TI ARM/DSP processors" # compile time dependencies -DEPENDS_dm6446-evm += "ti-xdctools-native ti-cgt6x-native ti-dspbios-native ti-codec-combo-dm6446" -DEPENDS_omap3evm += "ti-cgt6x-native ti-dspbios-native ti-codec-combo-omap3530 ti-xdctools-native" -DEPENDS_beagleboard += "ti-cgt6x-native ti-dspbios-native ti-codec-combo-omap3530 ti-xdctools-native" -DEPENDS_dm355-evm += "ti-codec-combo-dm355 ti-xdctools-native" +DEPENDS_dm6446-evm += "ti-xdctools-native ti-cgt6x-native ti-dspbios-native" +DEPENDS_omap3evm += "ti-cgt6x-native ti-dspbios-native ti-xdctools-native" +DEPENDS_beagleboard += "ti-cgt6x-native ti-dspbios-native ti-xdctools-native" +DEPENDS_dm355-evm += "ti-xdctools-native" # tconf from xdctools dislikes '.' in pwd :/ -PR = "r13" +PR = "r16" PV = "2231" SRC_URI = "http://install.source.dir.com/codec_engine_2_23_01.tar.gz " diff --git a/recipes/dvsdk/ti-dm355mm-module_1.13.bb b/recipes/dvsdk/ti-dm355mm-module_1.13.bb index cb8c39d021..0a2c6af14f 100644 --- a/recipes/dvsdk/ti-dm355mm-module_1.13.bb +++ b/recipes/dvsdk/ti-dm355mm-module_1.13.bb @@ -14,7 +14,8 @@ BINFILE="dm355_codecs_setuplinux_1_13_000.bin" # Yes, the xdc stuff still breaks with a '.' in PWD PV = "113" -PR = "r15" +#This is a kernel module, don't set PR directly +MACHINE_KERNEL_PR_append = "a" do_configure() { find ${S} -name "*.ko" -exec rm {} \; || true diff --git a/recipes/dvsdk/ti-dmai.inc b/recipes/dvsdk/ti-dmai.inc index 497e65df25..d90a906cf9 100644 --- a/recipes/dvsdk/ti-dmai.inc +++ b/recipes/dvsdk/ti-dmai.inc @@ -2,7 +2,7 @@ DESCRIPTION = "DMAI for TI ARM/DSP processors" # NOTE: Use Brijesh' DMAI development branch. The URL *must* be updated once # we have stable DMAI 2.x on gforge. -SRCREV = "189" +SRCREV = "195" SRC_URI = "svn://gforge.ti.com/svn/dmai/branches;module=BRIJESH_GIT_031809;proto=https;user=anonymous;pswd='' \ file://loadmodules-ti-dmai-dm355_al.sh \ file://loadmodules-ti-dmai-dm6446_al.sh \ @@ -12,4 +12,5 @@ SRC_URI = "svn://gforge.ti.com/svn/dmai/branches;module=BRIJESH_GIT_031809;proto S = "${WORKDIR}/BRIJESH_GIT_031809/davinci_multimedia_application_interface" # Yes, the xdc stuff still breaks with a '.' in PWD PV = "svnr${SRCREV}" +PR = "r27" diff --git a/recipes/dvsdk/ti-dmai_svn.bb b/recipes/dvsdk/ti-dmai_svn.bb index 0524fe6609..e089595086 100644 --- a/recipes/dvsdk/ti-dmai_svn.bb +++ b/recipes/dvsdk/ti-dmai_svn.bb @@ -8,7 +8,7 @@ DEPENDS_beagleboard += "alsa-lib ti-codec-engine ti-xdctools-native ti-dspbios- DEPENDS_dm6446-evm += "alsa-lib ti-codec-engine ti-xdctools-native ti-dspbios-native ti-cgt6x-native ti-codec-combo-dm6446 virtual/kernel " DEPENDS_dm355-evm += "alsa-lib ti-codec-engine ti-xdctools-native ti-codec-combo-dm355 virtual/kernel" -installdir = "${prefix}/ti" +installdir = "${datadir}/ti" # Define DMAI build time variables TARGET ?= "all" diff --git a/recipes/dvsdk/ti-dspbios-native_5.33.02.bb b/recipes/dvsdk/ti-dspbios-native_5.33.02.bb index 911eeda68c..e017a0366c 100644 --- a/recipes/dvsdk/ti-dspbios-native_5.33.02.bb +++ b/recipes/dvsdk/ti-dspbios-native_5.33.02.bb @@ -8,7 +8,7 @@ S = "${WORKDIR}/bios_5_33_02" # Yes, the xdc stuff still breaks with a '.' in PWD PV = "533" -PR = "r11" +PR = "r13" do_stage() { install -d ${STAGING_DIR_NATIVE}/${PN} diff --git a/recipes/dvsdk/ti-dspbios-sdk_5.33.02.bb b/recipes/dvsdk/ti-dspbios-sdk_5.33.02.bb index a67ac238a8..da3657eed3 100644 --- a/recipes/dvsdk/ti-dspbios-sdk_5.33.02.bb +++ b/recipes/dvsdk/ti-dspbios-sdk_5.33.02.bb @@ -8,7 +8,7 @@ S = "${WORKDIR}/bios_5_33_02" # Yes, the xdc stuff still breaks with a '.' in PWD PV = "533" -PR = "r11" +PR = "r13" do_install() { install -d ${D}/${prefix}/dvsdk/bios_5_33_02 diff --git a/recipes/dvsdk/ti-dsplink-module_1.61.3.bb b/recipes/dvsdk/ti-dsplink-module_1.61.3.bb index 764af7e6e8..492305f5c5 100644 --- a/recipes/dvsdk/ti-dsplink-module_1.61.3.bb +++ b/recipes/dvsdk/ti-dsplink-module_1.61.3.bb @@ -5,10 +5,11 @@ inherit module DEPENDS += " virtual/kernel perl-native ti-dspbios-native ti-cgt6x-native update-modules" # tconf from xdctools dislikes '.' in pwd :/ -PR = "r11" PV = "1613" +#This is a kernel module, don't set PR directly +MACHINE_KERNEL_PR_append = "a" -installdir = "${prefix}/ti" +installdir = "${datadir}/ti" SRC_URI = "http://install.source.dir.com/codec_engine_2_23_01.tar.gz \ file://loadmodules-ti-dsplink-apps.sh \ file://unloadmodules-ti-dsplink-apps.sh" @@ -18,18 +19,12 @@ S = "${WORKDIR}/codec_engine_2_23_01" # DSPLINK - Config Variable for different platform DSPLINKPLATFORM ?= "DAVINCI" -DSPLINKPLATFORM_omap3evm ?= "OMAP3530" -DSPLINKPLATFORM_beagleboard ?= "OMAP3530" DSPLINKPLATFORM_dm6446-evm ?= "DAVINCI" DSPLINKDSPCFG ?= "DM6446GEMSHMEM" -DSPLINKDSPCFG_omap3evm ?= "OMAP3530SHMEM" -DSPLINKDSPCFG_beagleboard ?= "OMAP3530SHMEM" DSPLINKDSPCFG_dm6446-evm ?= "DM6446GEMSHMEM" DSPLINKGPPOS ?= "MVL5G" -DSPLINKGPPOS_omap3evm ?= "OMAPLSP" -DSPLINKGPPOS_beagleboard ?= "OMAPLSP" DSPLINKGPPOS_dm6446-evm ?= "MVL5G" export DSPLINK="${S}/cetools/packages/dsplink" @@ -153,7 +148,7 @@ INHIBIT_PACKAGE_STRIP = "1" PACKAGES += " ti-dsplink-apps" FILES_${PN} = "/lib/modules/${KERNEL_VERSION}/kernel/drivers/dsp/*" -FILES_ti-dsplink-apps = "/${installdir}/dsplink/*" +FILES_ti-dsplink-apps = "${installdir}/dsplink/*" # Disable QA check untils we figure out how to pass LDFLAGS in build INSANE_SKIP_${PN} = True diff --git a/recipes/dvsdk/ti-lpm-module_2.23.1.bb b/recipes/dvsdk/ti-lpm-module_2.23.1.bb index 790b7f99d0..8684fa1f97 100644 --- a/recipes/dvsdk/ti-lpm-module_2.23.1.bb +++ b/recipes/dvsdk/ti-lpm-module_2.23.1.bb @@ -4,8 +4,10 @@ inherit module # compile and run time dependencies DEPENDS = " virtual/kernel perl-native ti-dsplink-module" -PR = "r9" PV = "2231" +#This is a kernel module, don't set PR directly +MACHINE_KERNEL_PR_append = "a" + SRC_URI = "http://install.source.dir.com/codec_engine_2_23_01.tar.gz " diff --git a/recipes/dvsdk/ti-rules-make-sdk.bb b/recipes/dvsdk/ti-rules-make-sdk.bb index b60e3a44a5..e1890bf606 100644 --- a/recipes/dvsdk/ti-rules-make-sdk.bb +++ b/recipes/dvsdk/ti-rules-make-sdk.bb @@ -2,7 +2,7 @@ DESCRIPTION = "This package creates Rules.make file and copies top label Makefil inherit sdk -PR="r4" +PR="r7" FILES=${@os.path.dirname(bb.data.getVar('FILE',d,1))}/files/dvsdk-rules diff --git a/recipes/dvsdk/ti-sdma-module_2.23.1.bb b/recipes/dvsdk/ti-sdma-module_2.23.1.bb index 924a61866a..4c104a0c10 100644 --- a/recipes/dvsdk/ti-sdma-module_2.23.1.bb +++ b/recipes/dvsdk/ti-sdma-module_2.23.1.bb @@ -4,8 +4,9 @@ inherit module # compile and run time dependencies DEPENDS = "virtual/kernel perl-native" -PR = "r9" PV = "2231" +#This is a kernel module, don't set PR directly +MACHINE_KERNEL_PR_append = "a" SRC_URI = "http://install.source.dir.com/codec_engine_2_23_01.tar.gz " diff --git a/recipes/dvsdk/ti-xdctools-native_3.10.03.bb b/recipes/dvsdk/ti-xdctools-native_3.10.03.bb index a41098e051..c37170ad7d 100644 --- a/recipes/dvsdk/ti-xdctools-native_3.10.03.bb +++ b/recipes/dvsdk/ti-xdctools-native_3.10.03.bb @@ -8,7 +8,7 @@ S = "${WORKDIR}/xdctools_3_10_03" # Yes, the xdc stuff still breaks with a '.' in PWD PV = "310" -PR = "r14" +PR = "r16" do_stage() { install -d ${STAGING_DIR_NATIVE}/${PN} diff --git a/recipes/dvsdk/ti-xdctools-sdk_3.10.03.bb b/recipes/dvsdk/ti-xdctools-sdk_3.10.03.bb index b68a0fcb00..43ce1d0a20 100644 --- a/recipes/dvsdk/ti-xdctools-sdk_3.10.03.bb +++ b/recipes/dvsdk/ti-xdctools-sdk_3.10.03.bb @@ -8,7 +8,7 @@ S = "${WORKDIR}/xdctools_3_10_03" # Yes, the xdc stuff still breaks with a '.' in PWD PV = "310" -PR = "r14" +PR = "r16" do_install() { install -d ${D}/${prefix}/dvsdk/xdctools_3_10_03 -- cgit v1.2.3 From 1e399b99b1fecf7bc68ef27f104dadf2a607a5de Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Sun, 21 Jun 2009 13:02:47 +0200 Subject: angstrom source mirror: blacklist some more packages --- contrib/angstrom/source-mirror.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/angstrom/source-mirror.txt b/contrib/angstrom/source-mirror.txt index eb1f74ade1..7d068f5fea 100644 --- a/contrib/angstrom/source-mirror.txt +++ b/contrib/angstrom/source-mirror.txt @@ -10,7 +10,9 @@ rsync ~/OE/downloads/ angstrom@linuxtogo.org:~/website/unstable/sources/ -aPvz \ --exclude "umac.ko" \ --exclude "IPL_*.zip" \ --exclude "*.lock" \ + --exclude "bios*" \ --exclude "codec_*" \ --exclude "dsplink*" \ --exclude "*GFX*" \ + --exclude "TI-*" \ --exclude "*.bin" -- cgit v1.2.3 From a055ed17249b7896510791071f6a951cad7ec7ae Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Sun, 21 Jun 2009 13:04:00 +0200 Subject: angstrom feed uploader: blacklist some more packages --- contrib/angstrom/upload-packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/angstrom/upload-packages.sh b/contrib/angstrom/upload-packages.sh index 593cf13fba..3978e8778f 100644 --- a/contrib/angstrom/upload-packages.sh +++ b/contrib/angstrom/upload-packages.sh @@ -32,7 +32,7 @@ cat files-remote files-local | sort | uniq -u >files-uniq cat files-uniq files-local | sort | uniq -d > files-trans # Remove SGX files -rm -f upload-queue/ti*codec* upload-queue/*3.00.* +rm -f upload-queue/bigbuck* upload-queue/*libgles* upload-queue/*3.00.* # Copy over non-duplicate files echo "Starting rsync..." -- cgit v1.2.3 From 2da567db254f2692ec6a9299ff4b40b0ea345dac Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Sun, 21 Jun 2009 13:04:22 +0200 Subject: Angstrom feed builder: build dvb apps as well --- contrib/angstrom/build-feeds.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/angstrom/build-feeds.sh b/contrib/angstrom/build-feeds.sh index 0991049b08..8f5755a546 100755 --- a/contrib/angstrom/build-feeds.sh +++ b/contrib/angstrom/build-feeds.sh @@ -104,6 +104,10 @@ do distcc \ dsniff \ duke3d \ + dvb-apps \ + dvbstream \ + dvbtraffic \ + dvbtune \ e-uae \ e-wm \ ekiga \ @@ -320,6 +324,7 @@ do win4 \ wireshark \ wpa-gui \ + wscan \ wt \ wt3 \ x11vnc \ -- cgit v1.2.3 From 3abef810942471deea4b3a7382a3bb83cdeb0346 Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Sun, 21 Jun 2009 14:56:28 +0200 Subject: dvb-apps: update to current state * statically link apps to avoid problems with the 'libraries' it tries to create --- recipes/dvbtools/dvb-apps-1.1.1/makefile.patch | 89 - .../dvbtools/dvb-apps-1.1.1/update-to-trunk.diff | 84310 +++++++++++++++++++ recipes/dvbtools/dvb-apps_1.1.1.bb | 60 +- 3 files changed, 84338 insertions(+), 121 deletions(-) delete mode 100644 recipes/dvbtools/dvb-apps-1.1.1/makefile.patch create mode 100644 recipes/dvbtools/dvb-apps-1.1.1/update-to-trunk.diff diff --git a/recipes/dvbtools/dvb-apps-1.1.1/makefile.patch b/recipes/dvbtools/dvb-apps-1.1.1/makefile.patch deleted file mode 100644 index d3acb45d05..0000000000 --- a/recipes/dvbtools/dvb-apps-1.1.1/makefile.patch +++ /dev/null @@ -1,89 +0,0 @@ -Index: linuxtv-dvb-apps-1.1.1/test/Makefile -=================================================================== ---- linuxtv-dvb-apps-1.1.1.orig/test/Makefile 2004-01-17 17:59:46.000000000 +0100 -+++ linuxtv-dvb-apps-1.1.1/test/Makefile 2008-03-25 20:04:23.000000000 +0100 -@@ -1,6 +1,6 @@ - # Makefile for Linux DVB API Version 3 test programs - --CC = gcc -+ - CFLAGS = -g -O2 -W -Wall -I../include - - TARGETS = \ -Index: linuxtv-dvb-apps-1.1.1/util/av7110_loadkeys/Makefile -=================================================================== ---- linuxtv-dvb-apps-1.1.1.orig/util/av7110_loadkeys/Makefile 2004-01-17 17:59:46.000000000 +0100 -+++ linuxtv-dvb-apps-1.1.1/util/av7110_loadkeys/Makefile 2008-03-25 20:04:23.000000000 +0100 -@@ -1,7 +1,6 @@ --CC = gcc - CFLAGS = -g -Wall -O2 - --all: av7110_loadkeys evtest -+all: evtest - - av7110_loadkeys: av7110_loadkeys.o - -Index: linuxtv-dvb-apps-1.1.1/util/lib/Makefile -=================================================================== ---- linuxtv-dvb-apps-1.1.1.orig/util/lib/Makefile 2004-01-17 17:59:46.000000000 +0100 -+++ linuxtv-dvb-apps-1.1.1/util/lib/Makefile 2008-03-25 20:04:23.000000000 +0100 -@@ -1,5 +1,5 @@ - --CC = gcc -+ - CFLAGS = -MD -g -Wall -O2 -I../../include -I. - LFLAGS = -g -Wall - -Index: linuxtv-dvb-apps-1.1.1/util/scan/Makefile -=================================================================== ---- linuxtv-dvb-apps-1.1.1.orig/util/scan/Makefile 2006-05-18 01:34:53.000000000 +0200 -+++ linuxtv-dvb-apps-1.1.1/util/scan/Makefile 2008-03-25 20:04:23.000000000 +0100 -@@ -1,5 +1,5 @@ - --CC = gcc -+ - CFLAGS = -MD -g -Wall -O2 -I../../include - LFLAGS = -g -Wall - -Index: linuxtv-dvb-apps-1.1.1/util/szap/Makefile -=================================================================== ---- linuxtv-dvb-apps-1.1.1.orig/util/szap/Makefile 2006-05-18 01:31:54.000000000 +0200 -+++ linuxtv-dvb-apps-1.1.1/util/szap/Makefile 2008-03-25 20:04:23.000000000 +0100 -@@ -1,4 +1,4 @@ --CC = gcc -+ - CFLAGS = -MD -Wall -g -O2 -I../../include -I../lib - LFLAGS = -Wall -g -O2 - RM = rm -f -Index: linuxtv-dvb-apps-1.1.1/util/dvbdate/Makefile -=================================================================== ---- linuxtv-dvb-apps-1.1.1.orig/util/dvbdate/Makefile 2004-01-17 17:59:46.000000000 +0100 -+++ linuxtv-dvb-apps-1.1.1/util/dvbdate/Makefile 2008-03-25 20:04:23.000000000 +0100 -@@ -1,5 +1,4 @@ - --CC = gcc - CFLAGS = -g -O2 -MD -Wall -I. -I../../include - LFLAGS = - -Index: linuxtv-dvb-apps-1.1.1/util/dvbnet/Makefile -=================================================================== ---- linuxtv-dvb-apps-1.1.1.orig/util/dvbnet/Makefile 2004-01-17 17:59:46.000000000 +0100 -+++ linuxtv-dvb-apps-1.1.1/util/dvbnet/Makefile 2008-03-25 20:04:23.000000000 +0100 -@@ -1,5 +1,4 @@ - --CC = gcc - CFLAGS = -g -O2 -MD -Wall -I. -I../../include - LFLAGS = - -Index: linuxtv-dvb-apps-1.1.1/util/dvbtraffic/Makefile -=================================================================== ---- linuxtv-dvb-apps-1.1.1.orig/util/dvbtraffic/Makefile 2004-01-19 18:10:16.000000000 +0100 -+++ linuxtv-dvb-apps-1.1.1/util/dvbtraffic/Makefile 2008-03-25 20:09:00.000000000 +0100 -@@ -1,6 +1,6 @@ - - dvbtraffic: dvbtraffic.c -- gcc -MD -g -O2 -Wall -I../../include $< -o $@ -+ $(CC) -MD -g -O2 -Wall -I../../include $< -o $@ - - clean: - rm -f *.o *.d dvbtraffic diff --git a/recipes/dvbtools/dvb-apps-1.1.1/update-to-trunk.diff b/recipes/dvbtools/dvb-apps-1.1.1/update-to-trunk.diff new file mode 100644 index 0000000000..6d4a66a501 --- /dev/null +++ b/recipes/dvbtools/dvb-apps-1.1.1/update-to-trunk.diff @@ -0,0 +1,84310 @@ + COPYING | 339 + COPYING.LGPL | 502 + + INSTALL | 26 + Make.rules | 104 + Makefile | 32 + README | 46 + TODO | 1 + include/audio.h | 140 + include/ca.h | 90 + include/dmx.h | 154 + include/frontend.h | 648 + + include/linux/dvb/audio.h | 125 + include/linux/dvb/ca.h | 91 + include/linux/dvb/dmx.h | 181 + include/linux/dvb/frontend.h | 267 + include/linux/dvb/net.h | 41 + include/linux/dvb/osd.h | 111 + include/linux/dvb/version.h | 29 + include/linux/dvb/video.h | 199 + include/net.h | 53 + include/osd.h | 142 + include/version.h | 29 + include/video.h | 277 + lib/Makefile | 11 + lib/libdvbapi/Makefile | 25 + lib/libdvbapi/dvbaudio.c | 50 + lib/libdvbapi/dvbaudio.h | 55 + lib/libdvbapi/dvbca.c | 159 + lib/libdvbapi/dvbca.h | 135 + lib/libdvbapi/dvbdemux.c | 255 + lib/libdvbapi/dvbdemux.h | 204 + lib/libdvbapi/dvbfe.c | 574 + + lib/libdvbapi/dvbfe.h | 333 + lib/libdvbapi/dvbnet.c | 104 + lib/libdvbapi/dvbnet.h | 87 + lib/libdvbapi/dvbvideo.c | 46 + lib/libdvbapi/dvbvideo.h | 46 + lib/libdvbcfg/Makefile | 18 + lib/libdvbcfg/dvbcfg_common.c | 136 + lib/libdvbcfg/dvbcfg_common.h | 37 + lib/libdvbcfg/dvbcfg_scanfile.c | 282 + lib/libdvbcfg/dvbcfg_scanfile.h | 61 + lib/libdvbcfg/dvbcfg_zapchannel.c | 384 + + lib/libdvbcfg/dvbcfg_zapchannel.h | 77 + lib/libdvbcfg/zapchannel.txt | 72 + lib/libdvben50221/Makefile | 49 + lib/libdvben50221/asn_1.c | 83 + lib/libdvben50221/asn_1.h | 41 + lib/libdvben50221/en50221_app_ai.c | 191 + lib/libdvben50221/en50221_app_ai.h | 136 + lib/libdvben50221/en50221_app_auth.c | 180 + lib/libdvben50221/en50221_app_auth.h | 123 + lib/libdvben50221/en50221_app_ca.c | 631 + + lib/libdvben50221/en50221_app_ca.h | 264 + lib/libdvben50221/en50221_app_datetime.c | 173 + lib/libdvben50221/en50221_app_datetime.h | 119 + lib/libdvben50221/en50221_app_dvb.c | 282 + lib/libdvben50221/en50221_app_dvb.h | 176 + lib/libdvben50221/en50221_app_epg.c | 167 + lib/libdvben50221/en50221_app_epg.h | 138 + lib/libdvben50221/en50221_app_lowspeed.c | 533 + + lib/libdvben50221/en50221_app_lowspeed.h | 219 + lib/libdvben50221/en50221_app_mmi.c | 1397 +++ + lib/libdvben50221/en50221_app_mmi.h | 618 + + lib/libdvben50221/en50221_app_rm.c | 307 + lib/libdvben50221/en50221_app_rm.h | 187 + lib/libdvben50221/en50221_app_smartcard.c | 296 + lib/libdvben50221/en50221_app_smartcard.h | 200 + lib/libdvben50221/en50221_app_tags.h | 104 + lib/libdvben50221/en50221_app_teletext.c | 141 + lib/libdvben50221/en50221_app_teletext.h | 107 + lib/libdvben50221/en50221_app_utils.c | 38 + lib/libdvben50221/en50221_app_utils.h | 112 + lib/libdvben50221/en50221_errno.h | 49 + lib/libdvben50221/en50221_session.c | 1055 ++ + lib/libdvben50221/en50221_session.h | 232 + lib/libdvben50221/en50221_stdcam.c | 54 + lib/libdvben50221/en50221_stdcam.h | 102 + lib/libdvben50221/en50221_stdcam_hlci.c | 216 + lib/libdvben50221/en50221_stdcam_llci.c | 437 + + lib/libdvben50221/en50221_transport.c | 1296 +++ + lib/libdvben50221/en50221_transport.h | 234 + lib/libdvbmisc/dvbmisc.h | 72 + lib/libdvbsec/Makefile | 17 + lib/libdvbsec/dvbsec_api.c | 951 ++ + lib/libdvbsec/dvbsec_api.h | 436 + + lib/libdvbsec/dvbsec_cfg.c | 366 + + lib/libdvbsec/dvbsec_cfg.h | 203 + lib/libesg/Makefile | 27 + lib/libesg/TODO | 18 + lib/libesg/bootstrap/Makefile | 24 + lib/libesg/bootstrap/access_descriptor.c | 115 + lib/libesg/bootstrap/access_descriptor.h | 86 + lib/libesg/bootstrap/provider_discovery_descriptor.c | 50 + lib/libesg/bootstrap/provider_discovery_descriptor.h | 59 + lib/libesg/encapsulation/Makefile | 28 + lib/libesg/encapsulation/auxiliary_data.h | 62 + lib/libesg/encapsulation/container.c | 206 + lib/libesg/encapsulation/container.h | 94 + lib/libesg/encapsulation/data_repository.c | 53 + lib/libesg/encapsulation/data_repository.h | 59 + lib/libesg/encapsulation/fragment_management_information.c | 118 + lib/libesg/encapsulation/fragment_management_information.h | 96 + lib/libesg/encapsulation/string_repository.c | 54 + lib/libesg/encapsulation/string_repository.h | 60 + lib/libesg/representation/Makefile | 26 + lib/libesg/representation/bim_decoder_init.h | 40 + lib/libesg/representation/encapsulated_bim_esg_xml_fragment.h | 40 + lib/libesg/representation/encapsulated_textual_esg_xml_fragment.c | 70 + lib/libesg/representation/encapsulated_textual_esg_xml_fragment.h | 60 + lib/libesg/representation/init_message.c | 112 + lib/libesg/representation/init_message.h | 80 + lib/libesg/representation/textual_decoder_init.c | 128 + lib/libesg/representation/textual_decoder_init.h | 104 + lib/libesg/transport/Makefile | 22 + lib/libesg/transport/session_partition_declaration.c | 253 + lib/libesg/transport/session_partition_declaration.h | 139 + lib/libesg/types.c | 37 + lib/libesg/types.h | 53 + lib/libesg/xml/provider_discovery_descriptor.xsd | 22 + lib/libucsi/Makefile | 34 + lib/libucsi/atsc/Makefile | 55 + lib/libucsi/atsc/ac3_descriptor.h | 112 + lib/libucsi/atsc/atsc_text.c | 743 ++ + lib/libucsi/atsc/caption_service_descriptor.h | 137 + lib/libucsi/atsc/component_name_descriptor.h | 92 + lib/libucsi/atsc/content_advisory_descriptor.h | 235 + lib/libucsi/atsc/cvct_section.c | 77 + lib/libucsi/atsc/cvct_section.h | 228 + lib/libucsi/atsc/dcc_arriving_request_descriptor.h | 107 + lib/libucsi/atsc/dcc_departing_request_descriptor.h | 108 + lib/libucsi/atsc/dccsct_section.c | 109 + lib/libucsi/atsc/dccsct_section.h | 327 + lib/libucsi/atsc/dcct_section.c | 96 + lib/libucsi/atsc/dcct_section.h | 380 + + lib/libucsi/atsc/descriptor.h | 68 + lib/libucsi/atsc/eit_section.c | 71 + lib/libucsi/atsc/eit_section.h | 191 + lib/libucsi/atsc/ett_section.c | 42 + lib/libucsi/atsc/ett_section.h | 91 + lib/libucsi/atsc/extended_channel_name_descriptor.h | 92 + lib/libucsi/atsc/genre_descriptor.h | 82 + lib/libucsi/atsc/mgt_section.c | 76 + lib/libucsi/atsc/mgt_section.h | 215 + lib/libucsi/atsc/rc_descriptor.h | 83 + lib/libucsi/atsc/rrt_section.c | 108 + lib/libucsi/atsc/rrt_section.h | 379 + + lib/libucsi/atsc/section.h | 84 + lib/libucsi/atsc/service_location_descriptor.h | 141 + lib/libucsi/atsc/stt_section.c | 42 + lib/libucsi/atsc/stt_section.h | 105 + lib/libucsi/atsc/stuffing_descriptor.h | 82 + lib/libucsi/atsc/time_shifted_service_descriptor.h | 136 + lib/libucsi/atsc/tvct_section.c | 81 + lib/libucsi/atsc/tvct_section.h | 227 + lib/libucsi/atsc/types.c | 71 + lib/libucsi/atsc/types.h | 227 + lib/libucsi/crc32.c | 89 + lib/libucsi/crc32.h | 58 + lib/libucsi/descriptor.h | 129 + lib/libucsi/dvb/Makefile | 123 + lib/libucsi/dvb/ac3_descriptor.h | 88 + lib/libucsi/dvb/adaptation_field_data_descriptor.h | 62 + lib/libucsi/dvb/ait_application_descriptor.h | 204 + lib/libucsi/dvb/ait_application_icons_descriptor.h | 157 + lib/libucsi/dvb/ait_application_name_descriptor.h | 145 + lib/libucsi/dvb/ait_external_application_authorisation_descriptor.h | 125 + lib/libucsi/dvb/ancillary_data_descriptor.h | 67 + lib/libucsi/dvb/announcement_support_descriptor.h | 219 + lib/libucsi/dvb/application_signalling_descriptor.h | 124 + lib/libucsi/dvb/bat_section.c | 77 + lib/libucsi/dvb/bat_section.h | 211 + lib/libucsi/dvb/bouquet_name_descriptor.h | 82 + lib/libucsi/dvb/ca_identifier_descriptor.h | 94 + lib/libucsi/dvb/cable_delivery_descriptor.h | 70 + lib/libucsi/dvb/cell_frequency_link_descriptor.h | 190 + lib/libucsi/dvb/cell_list_descriptor.h | 201 + lib/libucsi/dvb/component_descriptor.h | 147 + lib/libucsi/dvb/content_descriptor.h | 116 + lib/libucsi/dvb/content_identifier_descriptor.h | 233 + lib/libucsi/dvb/country_availability_descriptor.h | 120 + lib/libucsi/dvb/data_broadcast_descriptor.h | 139 + lib/libucsi/dvb/data_broadcast_id_descriptor.h | 221 + lib/libucsi/dvb/default_authority_descriptor.h | 82 + lib/libucsi/dvb/descriptor.h | 230 + lib/libucsi/dvb/dit_section.c | 32 + lib/libucsi/dvb/dit_section.h | 54 + lib/libucsi/dvb/dsng_descriptor.h | 80 + lib/libucsi/dvb/eit_section.c | 63 + lib/libucsi/dvb/eit_section.h | 160 + lib/libucsi/dvb/extended_event_descriptor.h | 232 + lib/libucsi/dvb/frequency_list_descriptor.h | 107 + lib/libucsi/dvb/int_section.c | 79 + lib/libucsi/dvb/int_section.h | 245 + lib/libucsi/dvb/ip_mac_platform_name_descriptor.h | 87 + lib/libucsi/dvb/ip_mac_platform_provider_name_descriptor.h | 87 + lib/libucsi/dvb/ip_mac_stream_location_descriptor.h | 73 + lib/libucsi/dvb/linkage_descriptor.h | 480 + + lib/libucsi/dvb/local_time_offset_descriptor.h | 127 + lib/libucsi/dvb/mhp_data_broadcast_id_descriptor.h | 110 + lib/libucsi/dvb/mosaic_descriptor.h | 324 + lib/libucsi/dvb/mpe_fec_section.h | 73 + lib/libucsi/dvb/multilingual_bouquet_name_descriptor.h | 145 + lib/libucsi/dvb/multilingual_component_descriptor.h | 149 + lib/libucsi/dvb/multilingual_network_name_descriptor.h | 145 + lib/libucsi/dvb/multilingual_service_name_descriptor.h | 197 + lib/libucsi/dvb/network_name_descriptor.h | 82 + lib/libucsi/dvb/nit_section.c | 78 + lib/libucsi/dvb/nit_section.h | 207 + lib/libucsi/dvb/nvod_reference_descriptor.h | 125 + lib/libucsi/dvb/parental_rating_descriptor.h | 135 + lib/libucsi/dvb/partial_transport_stream_descriptor.h | 68 + lib/libucsi/dvb/pdc_descriptor.h | 64 + lib/libucsi/dvb/private_data_specifier_descriptor.h | 63 + lib/libucsi/dvb/related_content_descriptor.h | 56 + lib/libucsi/dvb/rnt_rar_over_dvb_stream_descriptor.h | 110 + lib/libucsi/dvb/rnt_rar_over_ip_descriptor.h | 87 + lib/libucsi/dvb/rnt_rnt_scan_descriptor.h | 125 + lib/libucsi/dvb/rst_section.c | 47 + lib/libucsi/dvb/rst_section.h | 110 + lib/libucsi/dvb/s2_satellite_delivery_descriptor.h | 116 + lib/libucsi/dvb/satellite_delivery_descriptor.h | 73 + lib/libucsi/dvb/scrambling_descriptor.h | 61 + lib/libucsi/dvb/sdt_section.c | 60 + lib/libucsi/dvb/sdt_section.h | 157 + lib/libucsi/dvb/section.h | 108 + lib/libucsi/dvb/service_availability_descriptor.h | 98 + lib/libucsi/dvb/service_descriptor.h | 163 + lib/libucsi/dvb/service_identifier_descriptor.h | 82 + lib/libucsi/dvb/service_list_descriptor.h | 122 + lib/libucsi/dvb/service_move_descriptor.h | 67 + lib/libucsi/dvb/short_event_descriptor.h | 135 + lib/libucsi/dvb/short_smoothing_buffer_descriptor.h | 87 + lib/libucsi/dvb/sit_section.c | 69 + lib/libucsi/dvb/sit_section.h | 173 + lib/libucsi/dvb/st_section.c | 29 + lib/libucsi/dvb/st_section.h | 77 + lib/libucsi/dvb/stream_identifier_descriptor.h | 61 + lib/libucsi/dvb/stuffing_descriptor.h | 82 + lib/libucsi/dvb/subtitling_descriptor.h | 126 + lib/libucsi/dvb/target_ip_address_descriptor.h | 116 + lib/libucsi/dvb/target_ip_slash_descriptor.h | 116 + lib/libucsi/dvb/target_ip_source_slash_descriptor.h | 118 + lib/libucsi/dvb/target_ipv6_address_descriptor.h | 116 + lib/libucsi/dvb/target_ipv6_slash_descriptor.h | 116 + lib/libucsi/dvb/target_ipv6_source_slash_descriptor.h | 118 + lib/libucsi/dvb/tdt_section.c | 33 + lib/libucsi/dvb/tdt_section.h | 54 + lib/libucsi/dvb/telephone_descriptor.h | 150 + lib/libucsi/dvb/teletext_descriptor.h | 127 + lib/libucsi/dvb/terrestrial_delivery_descriptor.h | 77 + lib/libucsi/dvb/time_shifted_event_descriptor.h | 65 + lib/libucsi/dvb/time_shifted_service_descriptor.h | 63 + lib/libucsi/dvb/time_slice_fec_identifier_descriptor.h | 94 + lib/libucsi/dvb/tot_section.c | 50 + lib/libucsi/dvb/tot_section.h | 97 + lib/libucsi/dvb/transport_stream_descriptor.h | 82 + lib/libucsi/dvb/tva_container_section.c | 33 + lib/libucsi/dvb/tva_container_section.h | 90 + lib/libucsi/dvb/tva_id_descriptor.h | 124 + lib/libucsi/dvb/types.c | 270 + lib/libucsi/dvb/types.h | 127 + lib/libucsi/dvb/vbi_data_descriptor.h | 186 + lib/libucsi/dvb/vbi_teletext_descriptor.h | 116 + lib/libucsi/endianops.h | 128 + lib/libucsi/mpeg/Makefile | 66 + lib/libucsi/mpeg/audio_stream_descriptor.h | 65 + lib/libucsi/mpeg/ca_descriptor.h | 91 + lib/libucsi/mpeg/cat_section.c | 34 + lib/libucsi/mpeg/cat_section.h | 94 + lib/libucsi/mpeg/content_labelling_descriptor.h | 356 + + lib/libucsi/mpeg/copyright_descriptor.h | 89 + lib/libucsi/mpeg/data_stream_alignment_descriptor.h | 73 + lib/libucsi/mpeg/datagram_section.h | 81 + lib/libucsi/mpeg/descriptor.h | 102 + lib/libucsi/mpeg/external_es_id_descriptor.h | 63 + lib/libucsi/mpeg/fmc_descriptor.h | 122 + lib/libucsi/mpeg/fmxbuffer_size_descriptor.h | 83 + lib/libucsi/mpeg/hierarchy_descriptor.h | 83 + lib/libucsi/mpeg/ibp_descriptor.h | 65 + lib/libucsi/mpeg/iod_descriptor.h | 87 + lib/libucsi/mpeg/iso_639_language_descriptor.h | 124 + lib/libucsi/mpeg/maximum_bitrate_descriptor.h | 64 + lib/libucsi/mpeg/metadata_descriptor.h | 472 + + lib/libucsi/mpeg/metadata_pointer_descriptor.h | 360 + + lib/libucsi/mpeg/metadata_section.c | 27 + lib/libucsi/mpeg/metadata_section.h | 122 + lib/libucsi/mpeg/metadata_std_descriptor.h | 72 + lib/libucsi/mpeg/mpeg4_audio_descriptor.h | 61 + lib/libucsi/mpeg/mpeg4_video_descriptor.h | 61 + lib/libucsi/mpeg/multiplex_buffer_descriptor.h | 65 + lib/libucsi/mpeg/multiplex_buffer_utilization_descriptor.h | 67 + lib/libucsi/mpeg/muxcode_descriptor.h | 82 + lib/libucsi/mpeg/odsmt_section.c | 80 + lib/libucsi/mpeg/odsmt_section.h | 224 + lib/libucsi/mpeg/pat_section.c | 46 + lib/libucsi/mpeg/pat_section.h | 118 + lib/libucsi/mpeg/pmt_section.c | 71 + lib/libucsi/mpeg/pmt_section.h | 188 + lib/libucsi/mpeg/private_data_indicator_descriptor.h | 63 + lib/libucsi/mpeg/registration_descriptor.h | 91 + lib/libucsi/mpeg/section.h | 60 + lib/libucsi/mpeg/sl_descriptor.h | 63 + lib/libucsi/mpeg/smoothing_buffer_descriptor.h | 66 + lib/libucsi/mpeg/std_descriptor.h | 62 + lib/libucsi/mpeg/system_clock_descriptor.h | 65 + lib/libucsi/mpeg/target_background_grid_descriptor.h | 66 + lib/libucsi/mpeg/tsdt_section.c | 34 + lib/libucsi/mpeg/tsdt_section.h | 94 + lib/libucsi/mpeg/types.h | 127 + lib/libucsi/mpeg/video_stream_descriptor.h | 101 + lib/libucsi/mpeg/video_window_descriptor.h | 64 + lib/libucsi/section.h | 253 + lib/libucsi/section_buf.c | 173 + lib/libucsi/section_buf.h | 124 + lib/libucsi/testrecord.txt | 146 + lib/libucsi/transport_packet.c | 256 + lib/libucsi/transport_packet.h | 195 + lib/libucsi/types.h | 36 + libdvb2/README | 23 + test/Makefile | 64 + test/README | 11 + test/dia | 1 + test/diseqc.c | 19 + test/evtest.c | 251 + test/hex_dump.c | 1 + test/libdvbcfg/Makefile | 12 + test/libdvbcfg/dvbcfg_test.c | 100 + test/libdvbcfg/test_zapchannels.txt | 446 + + test/libdvben50221/Makefile | 14 + test/libdvben50221/test-app.c | 854 ++ + test/libdvben50221/test-session.c | 171 + test/libdvben50221/test-transport.c | 144 + test/libdvbsec/Makefile | 12 + test/libdvbsec/dvbsec_test.c | 85 + test/libdvbsec/test_sec.txt | 28 + test/libesg/Makefile | 12 + test/libesg/samples/ESGProviderDiscoveryDescriptor.xml | 13 + test/libesg/testesg.c | 563 + + test/libucsi/Makefile | 13 + test/libucsi/testucsi.c | 3528 ++++++++++ + test/lnb.c | 101 + test/lnb.h | 22 + test/sendburst.c | 14 + test/set22k.c | 18 + test/setpid.c | 17 + test/setvoltage.c | 18 + test/szap2.c | 767 ++ + test/test.c | 81 + test/test_audio.c | 41 + test/test_av.c | 100 + test/test_av_play.c | 516 + + test/test_dvr.c | 3 + test/test_dvr_play.c | 1 + test/test_front.c | 37 + test/test_sec_ne.c | 7 + test/test_sections.c | 3 + test/test_stc.c | 1 + test/test_stillimage.c | 7 + test/test_switch.c | 106 + test/test_tt.c | 1 + test/test_vevent.c | 6 + test/test_video.c | 51 + test/video.c | 42 + util/Makefile | 25 + util/atsc_epg/Makefile | 16 + util/atsc_epg/README | 12 + util/atsc_epg/atsc_epg.c | 1249 +++ + util/av7110_loadkeys/Makefile | 53 + util/av7110_loadkeys/README | 15 + util/av7110_loadkeys/activy.rcmm | 1 + util/av7110_loadkeys/av7110_loadkeys.c | 48 + util/av7110_loadkeys/evtest.c | 177 + util/av7110_loadkeys/galaxis.rcmm | 3 + util/av7110_loadkeys/generate-keynames.sh | 37 + util/av7110_loadkeys/hauppauge.rc5 | 1 + util/av7110_loadkeys/hauppauge2.rc5 | 40 + util/av7110_loadkeys/hauppauge_grey.rc5 | 1 + util/av7110_loadkeys/input_fake.h | 15 + util/av7110_loadkeys/philips1358.rc5 | 5 + util/av7110_loadkeys/technotrend.rc5 | 41 + util/dib3000-watch/Makefile | 13 + util/dib3000-watch/README.dib3000-watch | 29 + util/dib3000-watch/dib-i2c.h | 43 + util/dib3000-watch/dib3000-watch.c | 296 + util/dib3000-watch/dib3000-watch.h | 46 + util/dib3000-watch/dib3000.h | 56 + util/dib3000-watch/make-i2c-dev | 6 + util/dst-utils/Makefile | 13 + util/dst-utils/dst_test.c | 258 + util/dvbdate/Makefile | 28 + util/dvbdate/dvbdate.c | 282 + util/dvbnet/Makefile | 32 + util/dvbnet/dvbnet.c | 106 + util/dvbnet/net_start.pl | 1 + util/dvbnet/version.h.in | 1 + util/dvbscan/Makefile | 22 + util/dvbscan/dvbscan.c | 370 + + util/dvbscan/dvbscan.h | 136 + util/dvbscan/dvbscan_atsc.c | 30 + util/dvbscan/dvbscan_dvb.c | 30 + util/dvbscan/dvbscan_structutils.c | 99 + util/dvbtraffic/Makefile | 17 + util/dvbtraffic/dvbtraffic.c | 110 + util/femon/Makefile | 15 + util/femon/femon.c | 175 + util/gnutv/Makefile | 21 + util/gnutv/gnutv.c | 375 + + util/gnutv/gnutv.h | 37 + util/gnutv/gnutv_ca.c | 404 + + util/gnutv/gnutv_ca.h | 40 + util/gnutv/gnutv_data.c | 483 + + util/gnutv/gnutv_data.h | 39 + util/gnutv/gnutv_dvb.c | 376 + + util/gnutv/gnutv_dvb.h | 44 + util/lib/Makefile | 20 + util/lib/lnb.c | 101 + util/lib/lnb.h | 24 + util/scan/Makefile | 46 + util/scan/README | 26 + util/scan/atsc/us-ATSC-center-frequencies-8VSB | 1 + util/scan/atsc/us-NTSC-center-frequencies-8VSB | 1 + util/scan/atsc/us-NY-TWC-NYC | 53 + util/scan/atsc_psip_section.c | 62 + util/scan/atsc_psip_section.h | 60 + util/scan/atsc_psip_section.pl | 76 + util/scan/diseqc.c | 5 + util/scan/diseqc.h | 1 + util/scan/dump-vdr.c | 13 + util/scan/dump-vdr.h | 1 + util/scan/dump-zap.c | 1 + util/scan/dump-zap.h | 1 + util/scan/dvb-c/at-Innsbruck | 8 + util/scan/dvb-c/at-KarrerNet | 18 + util/scan/dvb-c/at-Liwest | 31 + util/scan/dvb-c/at-SalzburgAG | 8 + util/scan/dvb-c/be-IN.DI-Integan | 16 + util/scan/dvb-c/ch-Rega-Sense | 34 + util/scan/dvb-c/ch-Video2000 | 5 + util/scan/dvb-c/ch-Zuerich-cablecom | 3 + util/scan/dvb-c/cz-Moravianet | 24 + util/scan/dvb-c/de-Berlin | 1 + util/scan/dvb-c/de-Kabel_BW | 16 + util/scan/dvb-c/de-Muenchen | 27 + util/scan/dvb-c/de-Primacom | 23 + util/scan/dvb-c/de-Unitymedia | 35 + util/scan/dvb-c/de-iesy | 19 + util/scan/dvb-c/de-neftv | 23 + util/scan/dvb-c/dk-Copenhagen-AFDK | 11 + util/scan/dvb-c/dk-Odense | 10 + util/scan/dvb-c/es-Euskaltel | 19 + util/scan/dvb-c/fi-3ktv | 23 + util/scan/dvb-c/fi-HTV | 4 + util/scan/dvb-c/fi-Joensuu-Tikka | 13 + util/scan/dvb-c/fi-TTV | 4 + util/scan/dvb-c/fi-Turku | 17 + util/scan/dvb-c/fi-jkl | 10 + util/scan/dvb-c/fi-sonera | 12 + util/scan/dvb-c/fr-noos-numericable | 41 + util/scan/dvb-c/lu-Ettelbruck-ACE | 20 + util/scan/dvb-c/nl-Ziggo | 14 + util/scan/dvb-c/nl-Ziggo-Zwolle | 26 + util/scan/dvb-c/no-Oslo-CanalDigital | 13 + util/scan/dvb-c/no-Oslo-Get | 22 + util/scan/dvb-c/se-Gothnet | 23 + util/scan/dvb-c/se-comhem | 3 + util/scan/dvb-h/README | 3 + util/scan/dvb-h/fi-Helsinki | 2 + util/scan/dvb-h/fi-Oulu | 2 + util/scan/dvb-h/fi-Oulu-Nokia-devel | 4 + util/scan/dvb-h/fi-Turku | 2 + util/scan/dvb-s/ABS1-75.0E | 10 + util/scan/dvb-s/AMC1-103w | 5 + util/scan/dvb-s/AMC2-85w | 6 + util/scan/dvb-s/AMC3-87w | 10 + util/scan/dvb-s/AMC4-101w | 10 + util/scan/dvb-s/AMC5-79w | 5 + util/scan/dvb-s/AMC6-72w | 44 + util/scan/dvb-s/AMC9-83w | 18 + util/scan/dvb-s/Amazonas-61.0W | 54 + util/scan/dvb-s/Amos-4w | 48 + util/scan/dvb-s/Anik-F1-107.3W | 7 + util/scan/dvb-s/AsiaSat3S_C-105.5E | 122 + util/scan/dvb-s/Astra-28.2E | 186 + util/scan/dvb-s/Atlantic-Bird-1-12.5W | 30 + util/scan/dvb-s/BrasilSat-B1-75.0W | 11 + util/scan/dvb-s/BrasilSat-B2-65.0W | 34 + util/scan/dvb-s/BrasilSat-B3-84.0W | 85 + util/scan/dvb-s/BrasilSat-B4-70.0W | 39 + util/scan/dvb-s/Estrela-do-Sul-63.0W | 27 + util/scan/dvb-s/Eurobird1-28.5E | 5 + util/scan/dvb-s/Eurobird9-9.0E | 16 + util/scan/dvb-s/EutelsatW2-16E | 59 + util/scan/dvb-s/Express-3A-11.0W | 4 + util/scan/dvb-s/ExpressAM1-40.0E | 5 + util/scan/dvb-s/ExpressAM2-80.0E | 35 + util/scan/dvb-s/ExpressAM22-53.0E | 9 + util/scan/dvb-s/Galaxy10R-123w | 10 + util/scan/dvb-s/Galaxy11-91w | 49 + util/scan/dvb-s/Galaxy25-97w | 19 + util/scan/dvb-s/Galaxy26-93w | 58 + util/scan/dvb-s/Galaxy27-129w | 4 + util/scan/dvb-s/Galaxy28-89w | 41 + util/scan/dvb-s/Galaxy3C-95w | 4 + util/scan/dvb-s/Hispasat-30.0W | 37 + util/scan/dvb-s/Hotbird-13.0E | 93 + util/scan/dvb-s/IA5-97w | 18 + util/scan/dvb-s/IA6-93w | 61 + util/scan/dvb-s/IA7-129w | 4 + util/scan/dvb-s/IA8-89w | 34 + util/scan/dvb-s/Intel4-72.0E | 6 + util/scan/dvb-s/Intel904-60.0E | 13 + util/scan/dvb-s/Intelsat-1002-1.0W | 20 + util/scan/dvb-s/Intelsat-11-43.0W | 4 + util/scan/dvb-s/Intelsat-1R-45.0W | 44 + util/scan/dvb-s/Intelsat-3R-43.0W | 35 + util/scan/dvb-s/Intelsat-6B-43.0W | 17 + util/scan/dvb-s/Intelsat-705-50.0W | 7 + util/scan/dvb-s/Intelsat-707-53.0W | 5 + util/scan/dvb-s/Intelsat-805-55.5W | 67 + util/scan/dvb-s/Intelsat-9-58.0W | 58 + util/scan/dvb-s/Intelsat-903-34.5W | 7 + util/scan/dvb-s/Intelsat-905-24.5W | 9 + util/scan/dvb-s/Intelsat-907-27.5W | 9 + util/scan/dvb-s/NSS-10-37.5W | 12 + util/scan/dvb-s/NSS-7-22.0W | 25 + util/scan/dvb-s/NSS-806-40.5W | 108 + util/scan/dvb-s/Nahuel-1-71.8W | 11 + util/scan/dvb-s/Nilesat101+102-7.0W | 41 + util/scan/dvb-s/OptusC1-156E | 20 + util/scan/dvb-s/SBS6-74w | 4 + util/scan/dvb-s/Satmex-5-116.8W | 72 + util/scan/dvb-s/Satmex-6-113.0W | 19 + util/scan/dvb-s/Sirius-5.0E | 57 + util/scan/dvb-s/Telecom2-8.0W | 17 + util/scan/dvb-s/Telstar12-15.0W | 26 + util/scan/dvb-s/Thor-1.0W | 32 + util/scan/dvb-s/Turksat-42.0E | 104 + util/scan/dvb-s/Yamal201-90.0E | 48 + util/scan/dvb-t/ad-Andorra | 6 + util/scan/dvb-t/at-Official | 24 + util/scan/dvb-t/au-Adelaide | 12 + util/scan/dvb-t/au-Brisbane | 12 + util/scan/dvb-t/au-Cairns | 12 + util/scan/dvb-t/au-Canberra-Black-Mt | 12 + util/scan/dvb-t/au-Coonabarabran | 16 + util/scan/dvb-t/au-Darwin | 8 + util/scan/dvb-t/au-GoldCoast | 21 + util/scan/dvb-t/au-Hobart | 12 + util/scan/dvb-t/au-Mackay | 14 + util/scan/dvb-t/au-Melbourne | 12 + util/scan/dvb-t/au-Melbourne-Upwey | 12 + util/scan/dvb-t/au-MidNorthCoast | 22 + util/scan/dvb-t/au-Newcastle | 12 + util/scan/dvb-t/au-Perth | 12 + util/scan/dvb-t/au-Perth_Roleystone | 12 + util/scan/dvb-t/au-SpencerGulf | 8 + util/scan/dvb-t/au-SunshineCoast | 12 + util/scan/dvb-t/au-Sydney_Kings_Cross | 14 + util/scan/dvb-t/au-Sydney_North_Shore | 16 + util/scan/dvb-t/au-Tamworth | 38 + util/scan/dvb-t/au-Townsville | 12 + util/scan/dvb-t/au-WaggaWagga | 12 + util/scan/dvb-t/au-Wollongong | 40 + util/scan/dvb-t/au-canberra | 6 + util/scan/dvb-t/au-sydney_north_shore | 12 + util/scan/dvb-t/be-Brussels | 5 + util/scan/dvb-t/be-Libramont | 10 + util/scan/dvb-t/be-Schoten | 3 + util/scan/dvb-t/be-St_Pieters_Leeuw | 3 + util/scan/dvb-t/be-Tournai | 3 + util/scan/dvb-t/ch-All | 31 + util/scan/dvb-t/ch-Citycable | 18 + util/scan/dvb-t/cz-Brno | 10 + util/scan/dvb-t/cz-Domazlice | 3 + util/scan/dvb-t/cz-Klet | 4 + util/scan/dvb-t/cz-Ostrava | 3 + util/scan/dvb-t/cz-Plzen | 8 + util/scan/dvb-t/cz-Praha | 7 + util/scan/dvb-t/de-Baden-Wuerttemberg | 20 + util/scan/dvb-t/de-Bayern | 40 + util/scan/dvb-t/de-Berlin | 12 + util/scan/dvb-t/de-Brandenburg | 7 + util/scan/dvb-t/de-Bremen | 9 + util/scan/dvb-t/de-Hamburg | 16 + util/scan/dvb-t/de-Hessen | 19 + util/scan/dvb-t/de-Mecklenburg-Vorpommern | 12 + util/scan/dvb-t/de-Niedersachsen | 40 + util/scan/dvb-t/de-Nordrhein-Westfalen | 27 + util/scan/dvb-t/de-Rheinland-Pfalz | 12 + util/scan/dvb-t/de-Saarland | 7 + util/scan/dvb-t/de-Sachsen | 12 + util/scan/dvb-t/de-Sachsen-Anhalt | 12 + util/scan/dvb-t/de-Schleswig-Holstein | 18 + util/scan/dvb-t/de-Thueringen | 10 + util/scan/dvb-t/dk-All | 17 + util/scan/dvb-t/es-Albacete | 8 + util/scan/dvb-t/es-Alfabia | 8 + util/scan/dvb-t/es-Alicante | 9 + util/scan/dvb-t/es-Alpicat | 8 + util/scan/dvb-t/es-Asturias | 8 + util/scan/dvb-t/es-Bilbao | 6 + util/scan/dvb-t/es-Cadiz | 8 + util/scan/dvb-t/es-Carceres | 10 + util/scan/dvb-t/es-Collserola | 12 + util/scan/dvb-t/es-Donostia | 14 + util/scan/dvb-t/es-Huesca | 8 + util/scan/dvb-t/es-Las_Palmas | 8 + util/scan/dvb-t/es-Lugo | 9 + util/scan/dvb-t/es-Madrid | 8 + util/scan/dvb-t/es-Malaga | 9 + util/scan/dvb-t/es-Muros-Noia | 9 + util/scan/dvb-t/es-Mussara | 8 + util/scan/dvb-t/es-Rocacorba | 6 + util/scan/dvb-t/es-Santander | 7 + util/scan/dvb-t/es-Santiago_de_Compostela | 9 + util/scan/dvb-t/es-Sevilla | 8 + util/scan/dvb-t/es-Valencia | 9 + util/scan/dvb-t/es-Valladolid | 7 + util/scan/dvb-t/es-Vilamarxant | 4 + util/scan/dvb-t/es-Zaragoza | 7 + util/scan/dvb-t/fi-Aanekoski | 6 + util/scan/dvb-t/fi-Aanekoski_Konginkangas | 5 + util/scan/dvb-t/fi-Ahtari | 4 + util/scan/dvb-t/fi-Ala-Vuokki | 4 + util/scan/dvb-t/fi-Alajarvi | 5 + util/scan/dvb-t/fi-Ammansaari | 4 + util/scan/dvb-t/fi-Anjalankoski | 6 + util/scan/dvb-t/fi-Enontekio_Ahovaara_Raattama | 4 + util/scan/dvb-t/fi-Espoo | 5 + util/scan/dvb-t/fi-Eurajoki | 6 + util/scan/dvb-t/fi-Fiskars | 6 + util/scan/dvb-t/fi-Haapavesi | 6 + util/scan/dvb-t/fi-Hameenkyro_Kyroskoski | 5 + util/scan/dvb-t/fi-Hameenlinna_Painokangas | 5 + util/scan/dvb-t/fi-Hanko | 5 + util/scan/dvb-t/fi-Hartola | 4 + util/scan/dvb-t/fi-Heinavesi | 4 + util/scan/dvb-t/fi-Heinola | 6 + util/scan/dvb-t/fi-Hetta | 4 + util/scan/dvb-t/fi-Houtskari | 5 + util/scan/dvb-t/fi-Hyrynsalmi | 4 + util/scan/dvb-t/fi-Hyrynsalmi_Kyparavaara | 4 + util/scan/dvb-t/fi-Hyrynsalmi_Paljakka | 4 + util/scan/dvb-t/fi-Hyvinkaa_Musta-Mannisto | 5 + util/scan/dvb-t/fi-Ii_Raiskio | 4 + util/scan/dvb-t/fi-Iisalmi | 4 + util/scan/dvb-t/fi-Ikaalinen | 5 + util/scan/dvb-t/fi-Ikaalinen_Riitiala | 5 + util/scan/dvb-t/fi-Inari | 4 + util/scan/dvb-t/fi-Inari_Janispaa | 4 + util/scan/dvb-t/fi-Inari_Naatamo | 4 + util/scan/dvb-t/fi-Ivalo_Saarineitamovaara | 4 + util/scan/dvb-t/fi-Jalasjarvi | 5 + util/scan/dvb-t/fi-Jamsa_Kaipola | 5 + util/scan/dvb-t/fi-Jamsa_Kuorevesi_Halli | 5 + util/scan/dvb-t/fi-Jamsa_Matkosvuori | 6 + util/scan/dvb-t/fi-Jamsa_Ouninpohja | 4 + util/scan/dvb-t/fi-Jamsankoski | 5 + util/scan/dvb-t/fi-Joensuu_Vestinkallio | 4 + util/scan/dvb-t/fi-Joroinen_Puukkola | 4 + util/scan/dvb-t/fi-Joutsa_Lankia | 5 + util/scan/dvb-t/fi-Joutseno | 6 + util/scan/dvb-t/fi-Juntusranta | 4 + util/scan/dvb-t/fi-Juupajoki_Kopsamo | 4 + util/scan/dvb-t/fi-Jyvaskyla | 6 + util/scan/dvb-t/fi-Jyvaskylan_mlk_Vaajakoski | 4 + util/scan/dvb-t/fi-Kaavi_Sivakkavaara_Luikonlahti | 4 + util/scan/dvb-t/fi-Kajaani_Pollyvaara | 4 + util/scan/dvb-t/fi-Kalajoki | 4 + util/scan/dvb-t/fi-Kangaslampi | 5 + util/scan/dvb-t/fi-Kangasniemi_Turkinmaki | 5 + util/scan/dvb-t/fi-Kankaanpaa | 5 + util/scan/dvb-t/fi-Karigasniemi | 4 + util/scan/dvb-t/fi-Karkkila | 6 + util/scan/dvb-t/fi-Karstula | 4 + util/scan/dvb-t/fi-Karvia | 5 + util/scan/dvb-t/fi-Kaunispaa | 4 + util/scan/dvb-t/fi-Kemijarvi_Suomutunturi | 4 + util/scan/dvb-t/fi-Kerimaki | 6 + util/scan/dvb-t/fi-Keuruu | 6 + util/scan/dvb-t/fi-Keuruu_Haapamaki | 5 + util/scan/dvb-t/fi-Kihnio | 5 + util/scan/dvb-t/fi-Kiihtelysvaara | 4 + util/scan/dvb-t/fi-Kilpisjarvi | 4 + util/scan/dvb-t/fi-Kittila_Sirkka_Levitunturi | 4 + util/scan/dvb-t/fi-Kolari_Vuolittaja | 4 + util/scan/dvb-t/fi-Koli | 6 + util/scan/dvb-t/fi-Korpilahti_Vaarunvuori | 5 + util/scan/dvb-t/fi-Korppoo | 5 + util/scan/dvb-t/fi-Kruunupyy | 6 + util/scan/dvb-t/fi-Kuhmo_Iivantiira | 4 + util/scan/dvb-t/fi-Kuhmo_Lentiira | 4 + util/scan/dvb-t/fi-Kuhmo_Tikkasenmaki | 4 + util/scan/dvb-t/fi-Kuhmoinen | 5 + util/scan/dvb-t/fi-Kuhmoinen_Harjunsalmi | 5 + util/scan/dvb-t/fi-Kuhmoinen_Puukkoinen | 4 + util/scan/dvb-t/fi-Kuopio | 6 + util/scan/dvb-t/fi-Kustavi_Viherlahti | 5 + util/scan/dvb-t/fi-Kuttanen | 4 + util/scan/dvb-t/fi-Kuusamo_Hamppulampi | 4 + util/scan/dvb-t/fi-Kyyjarvi_Noposenaho | 4 + util/scan/dvb-t/fi-Lahti | 6 + util/scan/dvb-t/fi-Lapua | 6 + util/scan/dvb-t/fi-Laukaa | 5 + util/scan/dvb-t/fi-Laukaa_Vihtavuori | 5 + util/scan/dvb-t/fi-Lavia_Lavianjarvi | 4 + util/scan/dvb-t/fi-Lieksa_Vieki | 5 + util/scan/dvb-t/fi-Lohja | 6 + util/scan/dvb-t/fi-Loimaa | 5 + util/scan/dvb-t/fi-Luhanka | 5 + util/scan/dvb-t/fi-Luopioinen | 5 + util/scan/dvb-t/fi-Mantta | 5 + util/scan/dvb-t/fi-Mantyharju | 4 + util/scan/dvb-t/fi-Mikkeli | 6 + util/scan/dvb-t/fi-Muonio_Olostunturi | 4 + util/scan/dvb-t/fi-Nilsia | 5 + util/scan/dvb-t/fi-Nilsia_Keski-Siikajarvi | 4 + util/scan/dvb-t/fi-Nilsia_Pisa | 4 + util/scan/dvb-t/fi-Nokia | 6 + util/scan/dvb-t/fi-Nokia_Siuro_Linnavuori | 5 + util/scan/dvb-t/fi-Nummi-Pusula_Hyonola | 5 + util/scan/dvb-t/fi-Nurmes_Kortevaara | 4 + util/scan/dvb-t/fi-Orivesi_Langelmaki_Talviainen | 4 + util/scan/dvb-t/fi-Oulu | 6 + util/scan/dvb-t/fi-Padasjoki | 5 + util/scan/dvb-t/fi-Padasjoki_Arrakoski | 5 + util/scan/dvb-t/fi-Paltamo_Kivesvaara | 4 + util/scan/dvb-t/fi-Parikkala | 5 + util/scan/dvb-t/fi-Parkano | 5 + util/scan/dvb-t/fi-Pello | 4 + util/scan/dvb-t/fi-Pello_Ratasvaara | 4 + util/scan/dvb-t/fi-Perho | 5 + util/scan/dvb-t/fi-Pernaja | 5 + util/scan/dvb-t/fi-Pieksamaki_Halkokumpu | 4 + util/scan/dvb-t/fi-Pihtipudas | 5 + util/scan/dvb-t/fi-Porvoo_Suomenkyla | 5 + util/scan/dvb-t/fi-Posio | 4 + util/scan/dvb-t/fi-Pudasjarvi | 4 + util/scan/dvb-t/fi-Pudasjarvi_Iso-Syote | 4 + util/scan/dvb-t/fi-Pudasjarvi_Kangasvaara | 4 + util/scan/dvb-t/fi-Puolanka | 5 + util/scan/dvb-t/fi-Pyhatunturi | 4 + util/scan/dvb-t/fi-Pyhavuori | 5 + util/scan/dvb-t/fi-Pylkonmaki_Karankajarvi | 4 + util/scan/dvb-t/fi-Raahe_Mestauskallio | 5 + util/scan/dvb-t/fi-Raahe_Piehinki | 4 + util/scan/dvb-t/fi-Ranua_Haasionmaa | 4 + util/scan/dvb-t/fi-Ranua_Leppiaho | 4 + util/scan/dvb-t/fi-Rautavaara_Angervikko | 5 + util/scan/dvb-t/fi-Rautjarvi_Simpele | 4 + util/scan/dvb-t/fi-Ristijarvi | 4 + util/scan/dvb-t/fi-Rovaniemi | 5 + util/scan/dvb-t/fi-Rovaniemi_Ala-Nampa_Yli-Nampa_Rantalaki | 4 + util/scan/dvb-t/fi-Rovaniemi_Kaihuanvaara | 4 + util/scan/dvb-t/fi-Rovaniemi_Karhuvaara_Marrasjarvi | 4 + util/scan/dvb-t/fi-Rovaniemi_Marasenkallio | 4 + util/scan/dvb-t/fi-Rovaniemi_Meltaus_Sorviselka | 4 + util/scan/dvb-t/fi-Rovaniemi_Sonka | 4 + util/scan/dvb-t/fi-Ruka | 5 + util/scan/dvb-t/fi-Ruovesi_Storminiemi | 5 + util/scan/dvb-t/fi-Saarijarvi | 5 + util/scan/dvb-t/fi-Saarijarvi_Kalmari | 4 + util/scan/dvb-t/fi-Saarijarvi_Mahlu | 4 + util/scan/dvb-t/fi-Salla_Hirvasvaara | 4 + util/scan/dvb-t/fi-Salla_Ihistysjanka | 4 + util/scan/dvb-t/fi-Salla_Naruska | 4 + util/scan/dvb-t/fi-Salla_Sallatunturi | 4 + util/scan/dvb-t/fi-Salla_Sarivaara | 4 + util/scan/dvb-t/fi-Salo_Isokyla | 6 + util/scan/dvb-t/fi-Savukoski_Martti_Haarahonganmaa | 4 + util/scan/dvb-t/fi-Savukoski_Tanhua | 4 + util/scan/dvb-t/fi-Siilinjarvi | 5 + util/scan/dvb-t/fi-Sipoo_Norrkulla | 5 + util/scan/dvb-t/fi-Sodankyla_Pittiovaara | 4 + util/scan/dvb-t/fi-Sulkava_Vaatalanmaki | 4 + util/scan/dvb-t/fi-Suomussalmi_Myllylahti | 4 + util/scan/dvb-t/fi-Sysma_Liikola | 5 + util/scan/dvb-t/fi-Taivalkoski | 4 + util/scan/dvb-t/fi-Taivalkoski_Taivalvaara | 4 + util/scan/dvb-t/fi-Tammela | 6 + util/scan/dvb-t/fi-Tammisaari | 5 + util/scan/dvb-t/fi-Tampere | 4 + util/scan/dvb-t/fi-Tampere_Pyynikki | 6 + util/scan/dvb-t/fi-Tervola | 5 + util/scan/dvb-t/fi-Turku | 5 + util/scan/dvb-t/fi-Utsjoki | 4 + util/scan/dvb-t/fi-Utsjoki_Nuorgam_Njallavaara | 4 + util/scan/dvb-t/fi-Utsjoki_Nuorgam_raja | 4 + util/scan/dvb-t/fi-Utsjoki_Nuvvus | 4 + util/scan/dvb-t/fi-Utsjoki_Outakoski | 4 + util/scan/dvb-t/fi-Utsjoki_Polvarniemi | 4 + util/scan/dvb-t/fi-Utsjoki_Rovisuvanto | 4 + util/scan/dvb-t/fi-Utsjoki_Tenola | 4 + util/scan/dvb-t/fi-Uusikaupunki_Orivo | 5 + util/scan/dvb-t/fi-Vaala | 4 + util/scan/dvb-t/fi-Vaasa | 5 + util/scan/dvb-t/fi-Valtimo | 4 + util/scan/dvb-t/fi-Vammala_Jyranvuori | 5 + util/scan/dvb-t/fi-Vammala_Roismala | 4 + util/scan/dvb-t/fi-Vammala_Savi | 4 + util/scan/dvb-t/fi-Vantaa_Hakunila | 6 + util/scan/dvb-t/fi-Varpaisjarvi_Honkamaki | 5 + util/scan/dvb-t/fi-Virrat_Lappavuori | 5 + util/scan/dvb-t/fi-Vuokatti | 6 + util/scan/dvb-t/fi-Vuotso | 4 + util/scan/dvb-t/fi-Ylitornio_Ainiovaara | 5 + util/scan/dvb-t/fi-Ylitornio_Raanujarvi | 4 + util/scan/dvb-t/fi-Yllas | 4 + util/scan/dvb-t/fr-Abbeville | 25 + util/scan/dvb-t/fr-Agen | 25 + util/scan/dvb-t/fr-Ajaccio | 25 + util/scan/dvb-t/fr-Albi | 25 + util/scan/dvb-t/fr-Alençon | 25 + util/scan/dvb-t/fr-Ales | 25 + util/scan/dvb-t/fr-Ales-Bouquet | 25 + util/scan/dvb-t/fr-Amiens | 25 + util/scan/dvb-t/fr-Angers | 25 + util/scan/dvb-t/fr-Annecy | 25 + util/scan/dvb-t/fr-Arcachon | 25 + util/scan/dvb-t/fr-Argenton | 25 + util/scan/dvb-t/fr-Aubenas | 25 + util/scan/dvb-t/fr-Aurillac | 25 + util/scan/dvb-t/fr-Autun | 25 + util/scan/dvb-t/fr-Auxerre | 25 + util/scan/dvb-t/fr-Avignon | 25 + util/scan/dvb-t/fr-BarleDuc | 25 + util/scan/dvb-t/fr-Bastia | 25 + util/scan/dvb-t/fr-Bayonne | 25 + util/scan/dvb-t/fr-Bergerac | 25 + util/scan/dvb-t/fr-Besançon | 25 + util/scan/dvb-t/fr-Bordeaux | 9 + util/scan/dvb-t/fr-Bordeaux-Bouliac | 25 + util/scan/dvb-t/fr-Bordeaux-Cauderan | 25 + util/scan/dvb-t/fr-Boulogne | 25 + util/scan/dvb-t/fr-Bourges | 25 + util/scan/dvb-t/fr-Brest | 9 + util/scan/dvb-t/fr-Brive | 25 + util/scan/dvb-t/fr-Caen | 25 + util/scan/dvb-t/fr-Caen-Pincon | 25 + util/scan/dvb-t/fr-Cannes | 25 + util/scan/dvb-t/fr-Carcassonne | 25 + util/scan/dvb-t/fr-Chambery | 30 + util/scan/dvb-t/fr-Chartres | 25 + util/scan/dvb-t/fr-Chennevieres | 25 + util/scan/dvb-t/fr-Cherbourg | 25 + util/scan/dvb-t/fr-ClermontFerrand | 25 + util/scan/dvb-t/fr-Cluses | 23 + util/scan/dvb-t/fr-Dieppe | 25 + util/scan/dvb-t/fr-Dijon | 28 + util/scan/dvb-t/fr-Dunkerque | 30 + util/scan/dvb-t/fr-Epinal | 25 + util/scan/dvb-t/fr-Evreux | 25 + util/scan/dvb-t/fr-Forbach | 30 + util/scan/dvb-t/fr-Gex | 30 + util/scan/dvb-t/fr-Grenoble | 25 + util/scan/dvb-t/fr-Gueret | 25 + util/scan/dvb-t/fr-Hirson | 30 + util/scan/dvb-t/fr-Hyeres | 25 + util/scan/dvb-t/fr-LaRochelle | 25 + util/scan/dvb-t/fr-Laval | 25 + util/scan/dvb-t/fr-LeCreusot | 25 + util/scan/dvb-t/fr-LeHavre | 25 + util/scan/dvb-t/fr-LeMans | 21 + util/scan/dvb-t/fr-LePuyEnVelay | 25 + util/scan/dvb-t/fr-Lille | 30 + util/scan/dvb-t/fr-Lille-Lambersart | 25 + util/scan/dvb-t/fr-LilleT2 | 13 + util/scan/dvb-t/fr-Limoges | 25 + util/scan/dvb-t/fr-Longwy | 30 + util/scan/dvb-t/fr-Lorient | 25 + util/scan/dvb-t/fr-Lyon-Fourviere | 18 + util/scan/dvb-t/fr-Lyon-Pilat | 17 + util/scan/dvb-t/fr-Macon | 30 + util/scan/dvb-t/fr-Mantes | 25 + util/scan/dvb-t/fr-Marseille | 6 + util/scan/dvb-t/fr-Maubeuge | 30 + util/scan/dvb-t/fr-Meaux | 25 + util/scan/dvb-t/fr-Mende | 25 + util/scan/dvb-t/fr-Menton | 25 + util/scan/dvb-t/fr-Metz | 30 + util/scan/dvb-t/fr-Mezieres | 30 + util/scan/dvb-t/fr-Montbeliard | 18 + util/scan/dvb-t/fr-Montlucon | 25 + util/scan/dvb-t/fr-Montpellier | 25 + util/scan/dvb-t/fr-Mulhouse | 26 + util/scan/dvb-t/fr-Nancy | 25 + util/scan/dvb-t/fr-Nantes | 8 + util/scan/dvb-t/fr-NeufchatelEnBray | 25 + util/scan/dvb-t/fr-Nice | 25 + util/scan/dvb-t/fr-Niort | 7 + util/scan/dvb-t/fr-Orleans | 17 + util/scan/dvb-t/fr-Paris | 19 + util/scan/dvb-t/fr-Parthenay | 25 + util/scan/dvb-t/fr-Perpignan | 25 + util/scan/dvb-t/fr-Poitiers | 25 + util/scan/dvb-t/fr-Privas | 25 + util/scan/dvb-t/fr-Reims | 25 + util/scan/dvb-t/fr-Rennes | 7 + util/scan/dvb-t/fr-Roanne | 25 + util/scan/dvb-t/fr-Rouen | 8 + util/scan/dvb-t/fr-SaintEtienne | 25 + util/scan/dvb-t/fr-SaintRaphael | 25 + util/scan/dvb-t/fr-Sannois | 25 + util/scan/dvb-t/fr-Sarrebourg | 30 + util/scan/dvb-t/fr-Sens | 25 + util/scan/dvb-t/fr-Strasbourg | 18 + util/scan/dvb-t/fr-Toulon | 25 + util/scan/dvb-t/fr-Toulouse | 8 + util/scan/dvb-t/fr-Toulouse-Midi | 25 + util/scan/dvb-t/fr-Tours | 25 + util/scan/dvb-t/fr-Troyes | 25 + util/scan/dvb-t/fr-Ussel | 25 + util/scan/dvb-t/fr-Valence | 25 + util/scan/dvb-t/fr-Valenciennes | 30 + util/scan/dvb-t/fr-Vannes | 7 + util/scan/dvb-t/fr-Villebon | 22 + util/scan/dvb-t/fr-Vittel | 30 + util/scan/dvb-t/fr-Voiron | 30 + util/scan/dvb-t/gr-Athens | 3 + util/scan/dvb-t/hk-HongKong | 18 + util/scan/dvb-t/hr-Zagreb | 3 + util/scan/dvb-t/is-Reykjavik | 13 + util/scan/dvb-t/it-Aosta | 21 + util/scan/dvb-t/it-Bari | 18 + util/scan/dvb-t/it-Bologna | 28 + util/scan/dvb-t/it-Bolzano | 5 + util/scan/dvb-t/it-Cagliari | 23 + util/scan/dvb-t/it-Caivano | 17 + util/scan/dvb-t/it-Catania | 27 + util/scan/dvb-t/it-Conero | 8 + util/scan/dvb-t/it-Firenze | 20 + util/scan/dvb-t/it-Genova | 12 + util/scan/dvb-t/it-Livorno | 15 + util/scan/dvb-t/it-Milano | 15 + util/scan/dvb-t/it-Pagnacco | 27 + util/scan/dvb-t/it-Palermo | 23 + util/scan/dvb-t/it-Pescara | 15 + util/scan/dvb-t/it-Pisa | 18 + util/scan/dvb-t/it-Roma | 16 + util/scan/dvb-t/it-S-Stefano_al_mare | 19 + util/scan/dvb-t/it-Sassari | 33 + util/scan/dvb-t/it-Torino | 13 + util/scan/dvb-t/it-Trieste | 23 + util/scan/dvb-t/it-Varese | 16 + util/scan/dvb-t/it-Venezia | 19 + util/scan/dvb-t/it-Verona | 19 + util/scan/dvb-t/lu-All | 5 + util/scan/dvb-t/lv-Riga | 25 + util/scan/dvb-t/nl-All | 42 + util/scan/dvb-t/nl-AlphenaandenRijn | 7 + util/scan/dvb-t/nl-Randstad | 7 + util/scan/dvb-t/no-Trondelag_Stjordal | 7 + util/scan/dvb-t/nz-Waiatarua | 13 + util/scan/dvb-t/pl-Rzeszow | 3 + util/scan/dvb-t/pl-Warszawa | 4 + util/scan/dvb-t/pl-Wroclaw | 3 + util/scan/dvb-t/se-Alvdalen_Brunnsberg | 3 + util/scan/dvb-t/se-Alvdalsasen | 3 + util/scan/dvb-t/se-Alvsbyn | 7 + util/scan/dvb-t/se-Amot | 3 + util/scan/dvb-t/se-Ange_Snoberg | 6 + util/scan/dvb-t/se-Angebo | 3 + util/scan/dvb-t/se-Angelholm_Vegeholm | 7 + util/scan/dvb-t/se-Arvidsjaur_Jultrask | 6 + util/scan/dvb-t/se-Aspeboda | 3 + util/scan/dvb-t/se-Atvidaberg | 4 + util/scan/dvb-t/se-Avesta_Krylbo | 4 + util/scan/dvb-t/se-Backefors | 7 + util/scan/dvb-t/se-Bankeryd | 4 + util/scan/dvb-t/se-Bergsjo_Balleberget | 3 + util/scan/dvb-t/se-Bergvik | 3 + util/scan/dvb-t/se-Bollebygd | 4 + util/scan/dvb-t/se-Bollnas | 6 + util/scan/dvb-t/se-Boras_Dalsjofors | 7 + util/scan/dvb-t/se-Boras_Sjobo | 4 + util/scan/dvb-t/se-Borlange_Idkerberget | 6 + util/scan/dvb-t/se-Borlange_Nygardarna | 4 + util/scan/dvb-t/se-Bottnaryd_Ryd | 3 + util/scan/dvb-t/se-Bromsebro | 4 + util/scan/dvb-t/se-Bruzaholm | 3 + util/scan/dvb-t/se-Byxelkrok | 4 + util/scan/dvb-t/se-Dadran | 3 + util/scan/dvb-t/se-Dalfors | 3 + util/scan/dvb-t/se-Dalstuga | 3 + util/scan/dvb-t/se-Degerfors | 6 + util/scan/dvb-t/se-Delary | 3 + util/scan/dvb-t/se-Djura | 3 + util/scan/dvb-t/se-Drevdagen | 3 + util/scan/dvb-t/se-Duvnas | 3 + util/scan/dvb-t/se-Duvnas_Basna | 3 + util/scan/dvb-t/se-Edsbyn | 3 + util/scan/dvb-t/se-Emmaboda_Balshult | 6 + util/scan/dvb-t/se-Enviken | 4 + util/scan/dvb-t/se-Fagersta | 4 + util/scan/dvb-t/se-Falerum_Centrum | 3 + util/scan/dvb-t/se-Falun_Lovberget | 6 + util/scan/dvb-t/se-Farila | 3 + util/scan/dvb-t/se-Faro_Ajkerstrask | 4 + util/scan/dvb-t/se-Farosund_Bunge | 7 + util/scan/dvb-t/se-Filipstad_Klockarhojden | 6 + util/scan/dvb-t/se-Finnveden | 6 + util/scan/dvb-t/se-Fredriksberg | 3 + util/scan/dvb-t/se-Fritsla | 3 + util/scan/dvb-t/se-Furudal | 3 + util/scan/dvb-t/se-Gallivare | 6 + util/scan/dvb-t/se-Garpenberg_Kuppgarden | 3 + util/scan/dvb-t/se-Gavle | 6 + util/scan/dvb-t/se-Gavle_Skogmur | 6 + util/scan/dvb-t/se-Gnarp | 3 + util/scan/dvb-t/se-Gnesta | 4 + util/scan/dvb-t/se-Gnosjo_Marieholm | 3 + util/scan/dvb-t/se-Goteborg_Brudaremossen | 7 + util/scan/dvb-t/se-Goteborg_Slattadamm | 7 + util/scan/dvb-t/se-Gullbrandstorp | 3 + util/scan/dvb-t/se-Gunnarsbo | 3 + util/scan/dvb-t/se-Gusum | 3 + util/scan/dvb-t/se-Hagfors_Varmullsasen | 6 + util/scan/dvb-t/se-Hallaryd | 3 + util/scan/dvb-t/se-Hallbo | 3 + util/scan/dvb-t/se-Halmstad_Hamnen | 4 + util/scan/dvb-t/se-Halmstad_Oskarstrom | 6 + util/scan/dvb-t/se-Harnosand_Harnon | 6 + util/scan/dvb-t/se-Hassela | 3 + util/scan/dvb-t/se-Havdhem | 7 + util/scan/dvb-t/se-Hedemora | 3 + util/scan/dvb-t/se-Helsingborg_Olympia | 7 + util/scan/dvb-t/se-Hennan | 3 + util/scan/dvb-t/se-Hestra_Aspas | 3 + util/scan/dvb-t/se-Hjo_Grevback | 3 + util/scan/dvb-t/se-Hofors | 6 + util/scan/dvb-t/se-Hogfors | 3 + util/scan/dvb-t/se-Hogsby_Virstad | 4 + util/scan/dvb-t/se-Holsbybrunn_Holsbyholm | 3 + util/scan/dvb-t/se-Horby_Sallerup | 7 + util/scan/dvb-t/se-Horken | 3 + util/scan/dvb-t/se-Hudiksvall_Forsa | 6 + util/scan/dvb-t/se-Hudiksvall_Galgberget | 4 + util/scan/dvb-t/se-Huskvarna | 3 + util/scan/dvb-t/se-Idre | 3 + util/scan/dvb-t/se-Ingatorp | 3 + util/scan/dvb-t/se-Ingvallsbenning | 3 + util/scan/dvb-t/se-Irevik | 4 + util/scan/dvb-t/se-Jamjo | 4 + util/scan/dvb-t/se-Jarnforsen | 3 + util/scan/dvb-t/se-Jarvso | 3 + util/scan/dvb-t/se-Jokkmokk_Tjalmejaure | 6 + util/scan/dvb-t/se-Jonkoping_Bondberget | 6 + util/scan/dvb-t/se-Kalix | 6 + util/scan/dvb-t/se-Karbole | 3 + util/scan/dvb-t/se-Karlsborg_Vaberget | 3 + util/scan/dvb-t/se-Karlshamn | 6 + util/scan/dvb-t/se-Karlskrona_Vamo | 6 + util/scan/dvb-t/se-Karlstad_Sormon | 9 + util/scan/dvb-t/se-Kaxholmen_Vistakulle | 3 + util/scan/dvb-t/se-Kinnastrom | 3 + util/scan/dvb-t/se-Kiruna_Kirunavaara | 6 + util/scan/dvb-t/se-Kisa | 7 + util/scan/dvb-t/se-Knared | 3 + util/scan/dvb-t/se-Kopmanholmen | 6 + util/scan/dvb-t/se-Kopparberg | 4 + util/scan/dvb-t/se-Kramfors_Lugnvik | 6 + util/scan/dvb-t/se-Kristinehamn_Utsiktsberget | 6 + util/scan/dvb-t/se-Kungsater | 3 + util/scan/dvb-t/se-Kungsberget_GI | 3 + util/scan/dvb-t/se-Langshyttan | 3 + util/scan/dvb-t/se-Langshyttan_Engelsfors | 3 + util/scan/dvb-t/se-Leksand_Karingberget | 3 + util/scan/dvb-t/se-Lerdala | 3 + util/scan/dvb-t/se-Lilltjara_Digerberget | 3 + util/scan/dvb-t/se-Limedsforsen | 3 + util/scan/dvb-t/se-Lindshammar_Ramkvilla | 3 + util/scan/dvb-t/se-Linkoping_Vattentornet | 7 + util/scan/dvb-t/se-Ljugarn | 4 + util/scan/dvb-t/se-Loffstrand | 6 + util/scan/dvb-t/se-Lonneberga | 4 + util/scan/dvb-t/se-Lorstrand | 3 + util/scan/dvb-t/se-Ludvika_Bjorkasen | 4 + util/scan/dvb-t/se-Lumsheden_Trekanten | 3 + util/scan/dvb-t/se-Lycksele_Knaften | 6 + util/scan/dvb-t/se-Mahult | 3 + util/scan/dvb-t/se-Malmo_Jagersro | 7 + util/scan/dvb-t/se-Malung | 4 + util/scan/dvb-t/se-Mariannelund | 3 + util/scan/dvb-t/se-Markaryd_Hualtet | 4 + util/scan/dvb-t/se-Matfors | 6 + util/scan/dvb-t/se-Molnbo_Tallstugan | 2 + util/scan/dvb-t/se-Molndal_Vasterberget | 7 + util/scan/dvb-t/se-Mora_Eldris | 6 + util/scan/dvb-t/se-Motala_Ervasteby | 7 + util/scan/dvb-t/se-Mullsjo_Torestorp | 4 + util/scan/dvb-t/se-Nassjo | 6 + util/scan/dvb-t/se-Navekvarn | 3 + util/scan/dvb-t/se-Norrahammar | 3 + util/scan/dvb-t/se-Norrkoping_Krokek | 7 + util/scan/dvb-t/se-Norrtalje_Sodra_Bergen | 7 + util/scan/dvb-t/se-Nykoping | 3 + util/scan/dvb-t/se-Orebro_Lockhyttan | 7 + util/scan/dvb-t/se-Ornskoldsvik_As | 6 + util/scan/dvb-t/se-Oskarshamn | 6 + util/scan/dvb-t/se-Ostersund_Brattasen | 7 + util/scan/dvb-t/se-Osthammar_Valo | 7 + util/scan/dvb-t/se-Overkalix | 6 + util/scan/dvb-t/se-Oxberg | 3 + util/scan/dvb-t/se-Pajala | 6 + util/scan/dvb-t/se-Paulistom | 3 + util/scan/dvb-t/se-Rattvik | 3 + util/scan/dvb-t/se-Rengsjo | 3 + util/scan/dvb-t/se-Rorbacksnas | 3 + util/scan/dvb-t/se-Sagmyra | 3 + util/scan/dvb-t/se-Salen | 3 + util/scan/dvb-t/se-Salfjallet | 3 + util/scan/dvb-t/se-Sarna_Mickeltemplet | 3 + util/scan/dvb-t/se-Satila | 3 + util/scan/dvb-t/se-Saxdalen | 3 + util/scan/dvb-t/se-Siljansnas_Uvberget | 3 + util/scan/dvb-t/se-Skarstad | 3 + util/scan/dvb-t/se-Skattungbyn | 3 + util/scan/dvb-t/se-Skelleftea | 6 + util/scan/dvb-t/se-Skene_Nycklarberget | 3 + util/scan/dvb-t/se-Skovde | 7 + util/scan/dvb-t/se-Smedjebacken_Uvberget | 6 + util/scan/dvb-t/se-Soderhamn | 4 + util/scan/dvb-t/se-Soderkoping | 4 + util/scan/dvb-t/se-Sodertalje_Ragnhildsborg | 8 + util/scan/dvb-t/se-Solleftea_Hallsta | 6 + util/scan/dvb-t/se-Solleftea_Multra | 6 + util/scan/dvb-t/se-Sorsjon | 3 + util/scan/dvb-t/se-Stockholm_Marieberg | 7 + util/scan/dvb-t/se-Stockholm_Nacka | 8 + util/scan/dvb-t/se-Stora_Skedvi | 3 + util/scan/dvb-t/se-Storfjaten | 3 + util/scan/dvb-t/se-Storuman | 6 + util/scan/dvb-t/se-Stromstad | 7 + util/scan/dvb-t/se-Styrsjobo | 3 + util/scan/dvb-t/se-Sundborn | 3 + util/scan/dvb-t/se-Sundsbruk | 6 + util/scan/dvb-t/se-Sundsvall_S_Stadsberget | 7 + util/scan/dvb-t/se-Sunne_Blabarskullen | 6 + util/scan/dvb-t/se-Svartnas | 3 + util/scan/dvb-t/se-Sveg_Brickan | 6 + util/scan/dvb-t/se-Taberg | 3 + util/scan/dvb-t/se-Tandadalen | 3 + util/scan/dvb-t/se-Tasjo | 6 + util/scan/dvb-t/se-Tollsjo | 3 + util/scan/dvb-t/se-Torsby_Bada | 6 + util/scan/dvb-t/se-Tranas_Bredkarr | 4 + util/scan/dvb-t/se-Tranemo | 3 + util/scan/dvb-t/se-Transtrand_Bolheden | 4 + util/scan/dvb-t/se-Traryd_Betas | 4 + util/scan/dvb-t/se-Trollhattan | 7 + util/scan/dvb-t/se-Trosa | 4 + util/scan/dvb-t/se-Tystberga | 3 + util/scan/dvb-t/se-Uddevalla_Herrestad | 7 + util/scan/dvb-t/se-Ullared | 3 + util/scan/dvb-t/se-Ulricehamn | 4 + util/scan/dvb-t/se-Ulvshyttan_Porjus | 3 + util/scan/dvb-t/se-Uppsala_Rickomberga | 3 + util/scan/dvb-t/se-Uppsala_Vedyxa | 7 + util/scan/dvb-t/se-Vaddo_Elmsta | 4 + util/scan/dvb-t/se-Valdemarsvik | 4 + util/scan/dvb-t/se-Vannas_Granlundsberget | 6 + util/scan/dvb-t/se-Vansbro_Hummelberget | 3 + util/scan/dvb-t/se-Varberg_Grimeton | 6 + util/scan/dvb-t/se-Vasteras_Lillharad | 7 + util/scan/dvb-t/se-Vastervik_Farhult | 6 + util/scan/dvb-t/se-Vaxbo | 3 + util/scan/dvb-t/se-Vessigebro | 3 + util/scan/dvb-t/se-Vetlanda_Nye | 3 + util/scan/dvb-t/se-Vikmanshyttan | 3 + util/scan/dvb-t/se-Virserum | 6 + util/scan/dvb-t/se-Visby_Follingbo | 7 + util/scan/dvb-t/se-Visby_Hamnen | 7 + util/scan/dvb-t/se-Visingso | 3 + util/scan/dvb-t/se-Vislanda_Nydala | 6 + util/scan/dvb-t/se-Voxna | 3 + util/scan/dvb-t/se-Ystad_Metallgatan | 7 + util/scan/dvb-t/se-Yttermalung | 3 + util/scan/dvb-t/sk-BanskaBystrica | 4 + util/scan/dvb-t/sk-Bratislava | 4 + util/scan/dvb-t/sk-Kosice | 4 + util/scan/dvb-t/tw-Kaohsiung | 6 + util/scan/dvb-t/tw-Taipei | 7 + util/scan/dvb-t/uk-Aberdare | 10 + util/scan/dvb-t/uk-Angus | 10 + util/scan/dvb-t/uk-BeaconHill | 10 + util/scan/dvb-t/uk-Belmont | 10 + util/scan/dvb-t/uk-Bilsdale | 10 + util/scan/dvb-t/uk-BlackHill | 11 + util/scan/dvb-t/uk-Blaenplwyf | 10 + util/scan/dvb-t/uk-BluebellHill | 10 + util/scan/dvb-t/uk-Bressay | 10 + util/scan/dvb-t/uk-BrierleyHill | 10 + util/scan/dvb-t/uk-BristolIlchesterCres | 10 + util/scan/dvb-t/uk-BristolKingsWeston | 10 + util/scan/dvb-t/uk-Bromsgrove | 10 + util/scan/dvb-t/uk-BrougherMountain | 10 + util/scan/dvb-t/uk-Caldbeck | 10 + util/scan/dvb-t/uk-CaradonHill | 10 + util/scan/dvb-t/uk-Carmel | 10 + util/scan/dvb-t/uk-Chatton | 10 + util/scan/dvb-t/uk-Chesterfield | 10 + util/scan/dvb-t/uk-Craigkelly | 10 + util/scan/dvb-t/uk-CrystalPalace | 11 + util/scan/dvb-t/uk-Darvel | 10 + util/scan/dvb-t/uk-Divis | 10 + util/scan/dvb-t/uk-Dover | 14 + util/scan/dvb-t/uk-Durris | 10 + util/scan/dvb-t/uk-Eitshal | 10 + util/scan/dvb-t/uk-EmleyMoor | 10 + util/scan/dvb-t/uk-Fenham | 10 + util/scan/dvb-t/uk-Fenton | 10 + util/scan/dvb-t/uk-Ferryside | 8 + util/scan/dvb-t/uk-Guildford | 10 + util/scan/dvb-t/uk-Hannington | 9 + util/scan/dvb-t/uk-Hastings | 10 + util/scan/dvb-t/uk-Heathfield | 10 + util/scan/dvb-t/uk-HemelHempstead | 10 + util/scan/dvb-t/uk-HuntshawCross | 13 + util/scan/dvb-t/uk-Idle | 10 + util/scan/dvb-t/uk-KeelylangHill | 10 + util/scan/dvb-t/uk-Keighley | 10 + util/scan/dvb-t/uk-KilveyHill | 10 + util/scan/dvb-t/uk-KnockMore | 10 + util/scan/dvb-t/uk-Lancaster | 10 + util/scan/dvb-t/uk-LarkStoke | 10 + util/scan/dvb-t/uk-Limavady | 10 + util/scan/dvb-t/uk-Llanddona | 10 + util/scan/dvb-t/uk-Malvern | 10 + util/scan/dvb-t/uk-Mendip | 10 + util/scan/dvb-t/uk-Midhurst | 10 + util/scan/dvb-t/uk-Moel-y-Parc | 10 + util/scan/dvb-t/uk-Nottingham | 10 + util/scan/dvb-t/uk-OliversMount | 10 + util/scan/dvb-t/uk-Oxford | 11 + util/scan/dvb-t/uk-PendleForest | 10 + util/scan/dvb-t/uk-Plympton | 10 + util/scan/dvb-t/uk-PontopPike | 11 + util/scan/dvb-t/uk-Pontypool | 10 + util/scan/dvb-t/uk-Presely | 10 + util/scan/dvb-t/uk-Redruth | 9 + util/scan/dvb-t/uk-Reigate | 11 + util/scan/dvb-t/uk-RidgeHill | 10 + util/scan/dvb-t/uk-Rosemarkie | 10 + util/scan/dvb-t/uk-Rosneath | 10 + util/scan/dvb-t/uk-Rowridge | 11 + util/scan/dvb-t/uk-RumsterForest | 10 + util/scan/dvb-t/uk-Saddleworth | 10 + util/scan/dvb-t/uk-Salisbury | 10 + util/scan/dvb-t/uk-SandyHeath | 11 + util/scan/dvb-t/uk-Selkirk | 10 + util/scan/dvb-t/uk-Sheffield | 10 + util/scan/dvb-t/uk-StocklandHill | 10 + util/scan/dvb-t/uk-Storeton | 9 + util/scan/dvb-t/uk-Sudbury | 12 + util/scan/dvb-t/uk-SuttonColdfield | 10 + util/scan/dvb-t/uk-Tacolneston | 10 + util/scan/dvb-t/uk-TheWrekin | 15 + util/scan/dvb-t/uk-Torosay | 10 + util/scan/dvb-t/uk-TunbridgeWells | 10 + util/scan/dvb-t/uk-Waltham | 10 + util/scan/dvb-t/uk-Wenvoe | 10 + util/scan/dvb-t/uk-WhitehawkHill | 10 + util/scan/dvb-t/uk-WinterHill | 14 + util/scan/dvb-t/vn-Hanoi | 5 + util/scan/list.h | 6 + util/scan/lnb.c | 1 + util/scan/lnb.h | 2 + util/scan/scan.c | 62 + util/scan/scan.h | 1 + util/scan/section_generate.pl | 92 + util/szap/Makefile | 39 + util/szap/README | 23 + util/szap/azap.c | 8 + util/szap/channels-conf/atsc/make_atsc_chanconf.pl | 110 + util/szap/channels-conf/atsc/us-Raleigh-Durham | 8 + util/szap/channels-conf/dvb-c/de-Berlin | 171 + util/szap/channels-conf/dvb-s/Astra-19.2E | 226 + util/szap/channels-conf/dvb-s/Astra-28.2E | 522 + + util/szap/channels-conf/dvb-s/BrasilSat-B3-84.0W | 39 + util/szap/channels-conf/dvb-t/au-Adelaide | 28 + util/szap/channels-conf/dvb-t/au-Brisbane | 29 + util/szap/channels-conf/dvb-t/au-Hobart | 18 + util/szap/channels-conf/dvb-t/au-Melbourne | 17 + util/szap/channels-conf/dvb-t/au-Sydney-NorthShore | 31 + util/szap/channels-conf/dvb-t/cz-Praha | 16 + util/szap/channels-conf/dvb-t/de-Berlin | 47 + util/szap/channels-conf/dvb-t/de-Braunschweig | 25 + util/szap/channels-conf/dvb-t/de-Bremen | 25 + util/szap/channels-conf/dvb-t/de-Koeln-Bonn | 23 + util/szap/channels-conf/dvb-t/de-Leipzig | 7 + util/szap/channels-conf/dvb-t/de-Luebeck | 22 + util/szap/channels-conf/dvb-t/de-Rhein-Main | 6 + util/szap/channels-conf/dvb-t/de-Ruhrgebiet | 46 + util/szap/channels-conf/dvb-t/es-Alpicat | 19 + util/szap/channels-conf/dvb-t/es-Collserola | 19 + util/szap/channels-conf/dvb-t/es-Madrid | 26 + util/szap/channels-conf/dvb-t/es-Mussara | 19 + util/szap/channels-conf/dvb-t/uk-Crystal-Palace | 67 + util/szap/channels-conf/dvb-t/uk-Hannington | 28 + util/szap/channels-conf/dvb-t/uk-Oxford | 41 + util/szap/channels-conf/dvb-t/uk-Reigate | 51 + util/szap/channels-conf/dvb-t/uk-Sandy-Heath | 12 + util/szap/channels.conf-dvbc-berlin | 171 + util/szap/channels.conf-dvbs-astra | 226 + util/szap/channels.conf-dvbt-australia | 31 + util/szap/channels.conf-dvbt-berlin | 51 + util/szap/channels.conf-dvbt-collserola | 25 + util/szap/channels.conf-dvbt-crystal-palace | 70 + util/szap/channels.conf-dvbt-hannington | 28 + util/szap/channels.conf-dvbt-madrid | 16 + util/szap/channels.conf-dvbt-oxford | 41 + util/szap/channels.conf-dvbt-reigate | 51 + util/szap/channels.conf-dvbt-sandy_heath | 13 + util/szap/czap.c | 145 + util/szap/femon.c | 149 + util/szap/lnb.c | 101 + util/szap/lnb.h | 22 + util/szap/szap.c | 220 + util/szap/tzap.c | 344 + util/ttusb_dec_reset/Makefile | 28 + util/ttusb_dec_reset/ttusb_dec_reset.c | 4 + util/zap/Makefile | 20 + util/zap/zap.c | 226 + util/zap/zap_ca.c | 198 + util/zap/zap_ca.h | 37 + util/zap/zap_dvb.c | 353 + + util/zap/zap_dvb.h | 41 + 1328 files changed, 71527 insertions(+), 3595 deletions(-) +diff -Nurd linuxtv-dvb-apps-1.1.1/COPYING dvb-apps/COPYING +--- linuxtv-dvb-apps-1.1.1/COPYING 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/COPYING 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,339 @@ ++ GNU GENERAL PUBLIC LICENSE ++ Version 2, June 1991 ++ ++ Copyright (C) 1989, 1991 Free Software Foundation, Inc., ++ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ Everyone is permitted to copy and distribute verbatim copies ++ of this license document, but changing it is not allowed. ++ ++ Preamble ++ ++ The licenses for most software are designed to take away your ++freedom to share and change it. By contrast, the GNU General Public ++License is intended to guarantee your freedom to share and change free ++software--to make sure the software is free for all its users. This ++General Public License applies to most of the Free Software ++Foundation's software and to any other program whose authors commit to ++using it. (Some other Free Software Foundation software is covered by ++the GNU Lesser General Public License instead.) You can apply it to ++your programs, too. ++ ++ When we speak of free software, we are referring to freedom, not ++price. Our General Public Licenses are designed to make sure that you ++have the freedom to distribute copies of free software (and charge for ++this service if you wish), that you receive source code or can get it ++if you want it, that you can change the software or use pieces of it ++in new free programs; and that you know you can do these things. ++ ++ To protect your rights, we need to make restrictions that forbid ++anyone to deny you these rights or to ask you to surrender the rights. ++These restrictions translate to certain responsibilities for you if you ++distribute copies of the software, or if you modify it. ++ ++ For example, if you distribute copies of such a program, whether ++gratis or for a fee, you must give the recipients all the rights that ++you have. You must make sure that they, too, receive or can get the ++source code. And you must show them these terms so they know their ++rights. ++ ++ We protect your rights with two steps: (1) copyright the software, and ++(2) offer you this license which gives you legal permission to copy, ++distribute and/or modify the software. ++ ++ Also, for each author's protection and ours, we want to make certain ++that everyone understands that there is no warranty for this free ++software. If the software is modified by someone else and passed on, we ++want its recipients to know that what they have is not the original, so ++that any problems introduced by others will not reflect on the original ++authors' reputations. ++ ++ Finally, any free program is threatened constantly by software ++patents. We wish to avoid the danger that redistributors of a free ++program will individually obtain patent licenses, in effect making the ++program proprietary. To prevent this, we have made it clear that any ++patent must be licensed for everyone's free use or not licensed at all. ++ ++ The precise terms and conditions for copying, distribution and ++modification follow. ++ ++ GNU GENERAL PUBLIC LICENSE ++ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION ++ ++ 0. This License applies to any program or other work which contains ++a notice placed by the copyright holder saying it may be distributed ++under the terms of this General Public License. The "Program", below, ++refers to any such program or work, and a "work based on the Program" ++means either the Program or any derivative work under copyright law: ++that is to say, a work containing the Program or a portion of it, ++either verbatim or with modifications and/or translated into another ++language. (Hereinafter, translation is included without limitation in ++the term "modification".) Each licensee is addressed as "you". ++ ++Activities other than copying, distribution and modification are not ++covered by this License; they are outside its scope. The act of ++running the Program is not restricted, and the output from the Program ++is covered only if its contents constitute a work based on the ++Program (independent of having been made by running the Program). ++Whether that is true depends on what the Program does. ++ ++ 1. You may copy and distribute verbatim copies of the Program's ++source code as you receive it, in any medium, provided that you ++conspicuously and appropriately publish on each copy an appropriate ++copyright notice and disclaimer of warranty; keep intact all the ++notices that refer to this License and to the absence of any warranty; ++and give any other recipients of the Program a copy of this License ++along with the Program. ++ ++You may charge a fee for the physical act of transferring a copy, and ++you may at your option offer warranty protection in exchange for a fee. ++ ++ 2. You may modify your copy or copies of the Program or any portion ++of it, thus forming a work based on the Program, and copy and ++distribute such modifications or work under the terms of Section 1 ++above, provided that you also meet all of these conditions: ++ ++ a) You must cause the modified files to carry prominent notices ++ stating that you changed the files and the date of any change. ++ ++ b) You must cause any work that you distribute or publish, that in ++ whole or in part contains or is derived from the Program or any ++ part thereof, to be licensed as a whole at no charge to all third ++ parties under the terms of this License. ++ ++ c) If the modified program normally reads commands interactively ++ when run, you must cause it, when started running for such ++ interactive use in the most ordinary way, to print or display an ++ announcement including an appropriate copyright notice and a ++ notice that there is no warranty (or else, saying that you provide ++ a warranty) and that users may redistribute the program under ++ these conditions, and telling the user how to view a copy of this ++ License. (Exception: if the Program itself is interactive but ++ does not normally print such an announcement, your work based on ++ the Program is not required to print an announcement.) ++ ++These requirements apply to the modified work as a whole. If ++identifiable sections of that work are not derived from the Program, ++and can be reasonably considered independent and separate works in ++themselves, then this License, and its terms, do not apply to those ++sections when you distribute them as separate works. But when you ++distribute the same sections as part of a whole which is a work based ++on the Program, the distribution of the whole must be on the terms of ++this License, whose permissions for other licensees extend to the ++entire whole, and thus to each and every part regardless of who wrote it. ++ ++Thus, it is not the intent of this section to claim rights or contest ++your rights to work written entirely by you; rather, the intent is to ++exercise the right to control the distribution of derivative or ++collective works based on the Program. ++ ++In addition, mere aggregation of another work not based on the Program ++with the Program (or with a work based on the Program) on a volume of ++a storage or distribution medium does not bring the other work under ++the scope of this License. ++ ++ 3. You may copy and distribute the Program (or a work based on it, ++under Section 2) in object code or executable form under the terms of ++Sections 1 and 2 above provided that you also do one of the following: ++ ++ a) Accompany it with the complete corresponding machine-readable ++ source code, which must be distributed under the terms of Sections ++ 1 and 2 above on a medium customarily used for software interchange; or, ++ ++ b) Accompany it with a written offer, valid for at least three ++ years, to give any third party, for a charge no more than your ++ cost of physically performing source distribution, a complete ++ machine-readable copy of the corresponding source code, to be ++ distributed under the terms of Sections 1 and 2 above on a medium ++ customarily used for software interchange; or, ++ ++ c) Accompany it with the information you received as to the offer ++ to distribute corresponding source code. (This alternative is ++ allowed only for noncommercial distribution and only if you ++ received the program in object code or executable form with such ++ an offer, in accord with Subsection b above.) ++ ++The source code for a work means the preferred form of the work for ++making modifications to it. For an executable work, complete source ++code means all the source code for all modules it contains, plus any ++associated interface definition files, plus the scripts used to ++control compilation and installation of the executable. However, as a ++special exception, the source code distributed need not include ++anything that is normally distributed (in either source or binary ++form) with the major components (compiler, kernel, and so on) of the ++operating system on which the executable runs, unless that component ++itself accompanies the executable. ++ ++If distribution of executable or object code is made by offering ++access to copy from a designated place, then offering equivalent ++access to copy the source code from the same place counts as ++distribution of the source code, even though third parties are not ++compelled to copy the source along with the object code. ++ ++ 4. You may not copy, modify, sublicense, or distribute the Program ++except as expressly provided under this License. Any attempt ++otherwise to copy, modify, sublicense or distribute the Program is ++void, and will automatically terminate your rights under this License. ++However, parties who have received copies, or rights, from you under ++this License will not have their licenses terminated so long as such ++parties remain in full compliance. ++ ++ 5. You are not required to accept this License, since you have not ++signed it. However, nothing else grants you permission to modify or ++distribute the Program or its derivative works. These actions are ++prohibited by law if you do not accept this License. Therefore, by ++modifying or distributing the Program (or any work based on the ++Program), you indicate your acceptance of this License to do so, and ++all its terms and conditions for copying, distributing or modifying ++the Program or works based on it. ++ ++ 6. Each time you redistribute the Program (or any work based on the ++Program), the recipient automatically receives a license from the ++original licensor to copy, distribute or modify the Program subject to ++these terms and conditions. You may not impose any further ++restrictions on the recipients' exercise of the rights granted herein. ++You are not responsible for enforcing compliance by third parties to ++this License. ++ ++ 7. If, as a consequence of a court judgment or allegation of patent ++infringement or for any other reason (not limited to patent issues), ++conditions are imposed on you (whether by court order, agreement or ++otherwise) that contradict the conditions of this License, they do not ++excuse you from the conditions of this License. If you cannot ++distribute so as to satisfy simultaneously your obligations under this ++License and any other pertinent obligations, then as a consequence you ++may not distribute the Program at all. For example, if a patent ++license would not permit royalty-free redistribution of the Program by ++all those who receive copies directly or indirectly through you, then ++the only way you could satisfy both it and this License would be to ++refrain entirely from distribution of the Program. ++ ++If any portion of this section is held invalid or unenforceable under ++any particular circumstance, the balance of the section is intended to ++apply and the section as a whole is intended to apply in other ++circumstances. ++ ++It is not the purpose of this section to induce you to infringe any ++patents or other property right claims or to contest validity of any ++such claims; this section has the sole purpose of protecting the ++integrity of the free software distribution system, which is ++implemented by public license practices. Many people have made ++generous contributions to the wide range of software distributed ++through that system in reliance on consistent application of that ++system; it is up to the author/donor to decide if he or she is willing ++to distribute software through any other system and a licensee cannot ++impose that choice. ++ ++This section is intended to make thoroughly clear what is believed to ++be a consequence of the rest of this License. ++ ++ 8. If the distribution and/or use of the Program is restricted in ++certain countries either by patents or by copyrighted interfaces, the ++original copyright holder who places the Program under this License ++may add an explicit geographical distribution limitation excluding ++those countries, so that distribution is permitted only in or among ++countries not thus excluded. In such case, this License incorporates ++the limitation as if written in the body of this License. ++ ++ 9. The Free Software Foundation may publish revised and/or new versions ++of the General Public License from time to time. Such new versions will ++be similar in spirit to the present version, but may differ in detail to ++address new problems or concerns. ++ ++Each version is given a distinguishing version number. If the Program ++specifies a version number of this License which applies to it and "any ++later version", you have the option of following the terms and conditions ++either of that version or of any later version published by the Free ++Software Foundation. If the Program does not specify a version number of ++this License, you may choose any version ever published by the Free Software ++Foundation. ++ ++ 10. If you wish to incorporate parts of the Program into other free ++programs whose distribution conditions are different, write to the author ++to ask for permission. For software which is copyrighted by the Free ++Software Foundation, write to the Free Software Foundation; we sometimes ++make exceptions for this. Our decision will be guided by the two goals ++of preserving the free status of all derivatives of our free software and ++of promoting the sharing and reuse of software generally. ++ ++ NO WARRANTY ++ ++ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY ++FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN ++OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES ++PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED ++OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ++MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS ++TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE ++PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, ++REPAIR OR CORRECTION. ++ ++ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING ++WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR ++REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, ++INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING ++OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED ++TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY ++YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER ++PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGES. ++ ++ END OF TERMS AND CONDITIONS ++ ++ How to Apply These Terms to Your New Programs ++ ++ If you develop a new program, and you want it to be of the greatest ++possible use to the public, the best way to achieve this is to make it ++free software which everyone can redistribute and change under these terms. ++ ++ To do so, attach the following notices to the program. It is safest ++to attach them to the start of each source file to most effectively ++convey the exclusion of warranty; and each file should have at least ++the "copyright" line and a pointer to where the full notice is found. ++ ++ ++ Copyright (C) ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 2 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License along ++ with this program; if not, write to the Free Software Foundation, Inc., ++ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ ++Also add information on how to contact you by electronic and paper mail. ++ ++If the program is interactive, make it output a short notice like this ++when it starts in an interactive mode: ++ ++ Gnomovision version 69, Copyright (C) year name of author ++ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. ++ This is free software, and you are welcome to redistribute it ++ under certain conditions; type `show c' for details. ++ ++The hypothetical commands `show w' and `show c' should show the appropriate ++parts of the General Public License. Of course, the commands you use may ++be called something other than `show w' and `show c'; they could even be ++mouse-clicks or menu items--whatever suits your program. ++ ++You should also get your employer (if you work as a programmer) or your ++school, if any, to sign a "copyright disclaimer" for the program, if ++necessary. Here is a sample; alter the names: ++ ++ Yoyodyne, Inc., hereby disclaims all copyright interest in the program ++ `Gnomovision' (which makes passes at compilers) written by James Hacker. ++ ++ , 1 April 1989 ++ Ty Coon, President of Vice ++ ++This General Public License does not permit incorporating your program into ++proprietary programs. If your program is a subroutine library, you may ++consider it more useful to permit linking proprietary applications with the ++library. If this is what you want to do, use the GNU Lesser General ++Public License instead of this License. +diff -Nurd linuxtv-dvb-apps-1.1.1/COPYING.LGPL dvb-apps/COPYING.LGPL +--- linuxtv-dvb-apps-1.1.1/COPYING.LGPL 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/COPYING.LGPL 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,502 @@ ++ GNU LESSER GENERAL PUBLIC LICENSE ++ Version 2.1, February 1999 ++ ++ Copyright (C) 1991, 1999 Free Software Foundation, Inc. ++ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ Everyone is permitted to copy and distribute verbatim copies ++ of this license document, but changing it is not allowed. ++ ++[This is the first released version of the Lesser GPL. It also counts ++ as the successor of the GNU Library Public License, version 2, hence ++ the version number 2.1.] ++ ++ Preamble ++ ++ The licenses for most software are designed to take away your ++freedom to share and change it. By contrast, the GNU General Public ++Licenses are intended to guarantee your freedom to share and change ++free software--to make sure the software is free for all its users. ++ ++ This license, the Lesser General Public License, applies to some ++specially designated software packages--typically libraries--of the ++Free Software Foundation and other authors who decide to use it. You ++can use it too, but we suggest you first think carefully about whether ++this license or the ordinary General Public License is the better ++strategy to use in any particular case, based on the explanations below. ++ ++ When we speak of free software, we are referring to freedom of use, ++not price. Our General Public Licenses are designed to make sure that ++you have the freedom to distribute copies of free software (and charge ++for this service if you wish); that you receive source code or can get ++it if you want it; that you can change the software and use pieces of ++it in new free programs; and that you are informed that you can do ++these things. ++ ++ To protect your rights, we need to make restrictions that forbid ++distributors to deny you these rights or to ask you to surrender these ++rights. These restrictions translate to certain responsibilities for ++you if you distribute copies of the library or if you modify it. ++ ++ For example, if you distribute copies of the library, whether gratis ++or for a fee, you must give the recipients all the rights that we gave ++you. You must make sure that they, too, receive or can get the source ++code. If you link other code with the library, you must provide ++complete object files to the recipients, so that they can relink them ++with the library after making changes to the library and recompiling ++it. And you must show them these terms so they know their rights. ++ ++ We protect your rights with a two-step method: (1) we copyright the ++library, and (2) we offer you this license, which gives you legal ++permission to copy, distribute and/or modify the library. ++ ++ To protect each distributor, we want to make it very clear that ++there is no warranty for the free library. Also, if the library is ++modified by someone else and passed on, the recipients should know ++that what they have is not the original version, so that the original ++author's reputation will not be affected by problems that might be ++introduced by others. ++ ++ Finally, software patents pose a constant threat to the existence of ++any free program. We wish to make sure that a company cannot ++effectively restrict the users of a free program by obtaining a ++restrictive license from a patent holder. Therefore, we insist that ++any patent license obtained for a version of the library must be ++consistent with the full freedom of use specified in this license. ++ ++ Most GNU software, including some libraries, is covered by the ++ordinary GNU General Public License. This license, the GNU Lesser ++General Public License, applies to certain designated libraries, and ++is quite different from the ordinary General Public License. We use ++this license for certain libraries in order to permit linking those ++libraries into non-free programs. ++ ++ When a program is linked with a library, whether statically or using ++a shared library, the combination of the two is legally speaking a ++combined work, a derivative of the original library. The ordinary ++General Public License therefore permits such linking only if the ++entire combination fits its criteria of freedom. The Lesser General ++Public License permits more lax criteria for linking other code with ++the library. ++ ++ We call this license the "Lesser" General Public License because it ++does Less to protect the user's freedom than the ordinary General ++Public License. It also provides other free software developers Less ++of an advantage over competing non-free programs. These disadvantages ++are the reason we use the ordinary General Public License for many ++libraries. However, the Lesser license provides advantages in certain ++special circumstances. ++ ++ For example, on rare occasions, there may be a special need to ++encourage the widest possible use of a certain library, so that it becomes ++a de-facto standard. To achieve this, non-free programs must be ++allowed to use the library. A more frequent case is that a free ++library does the same job as widely used non-free libraries. In this ++case, there is little to gain by limiting the free library to free ++software only, so we use the Lesser General Public License. ++ ++ In other cases, permission to use a particular library in non-free ++programs enables a greater number of people to use a large body of ++free software. For example, permission to use the GNU C Library in ++non-free programs enables many more people to use the whole GNU ++operating system, as well as its variant, the GNU/Linux operating ++system. ++ ++ Although the Lesser General Public License is Less protective of the ++users' freedom, it does ensure that the user of a program that is ++linked with the Library has the freedom and the wherewithal to run ++that program using a modified version of the Library. ++ ++ The precise terms and conditions for copying, distribution and ++modification follow. Pay close attention to the difference between a ++"work based on the library" and a "work that uses the library". The ++former contains code derived from the library, whereas the latter must ++be combined with the library in order to run. ++ ++ GNU LESSER GENERAL PUBLIC LICENSE ++ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION ++ ++ 0. This License Agreement applies to any software library or other ++program which contains a notice placed by the copyright holder or ++other authorized party saying it may be distributed under the terms of ++this Lesser General Public License (also called "this License"). ++Each licensee is addressed as "you". ++ ++ A "library" means a collection of software functions and/or data ++prepared so as to be conveniently linked with application programs ++(which use some of those functions and data) to form executables. ++ ++ The "Library", below, refers to any such software library or work ++which has been distributed under these terms. A "work based on the ++Library" means either the Library or any derivative work under ++copyright law: that is to say, a work containing the Library or a ++portion of it, either verbatim or with modifications and/or translated ++straightforwardly into another language. (Hereinafter, translation is ++included without limitation in the term "modification".) ++ ++ "Source code" for a work means the preferred form of the work for ++making modifications to it. For a library, complete source code means ++all the source code for all modules it contains, plus any associated ++interface definition files, plus the scripts used to control compilation ++and installation of the library. ++ ++ Activities other than copying, distribution and modification are not ++covered by this License; they are outside its scope. The act of ++running a program using the Library is not restricted, and output from ++such a program is covered only if its contents constitute a work based ++on the Library (independent of the use of the Library in a tool for ++writing it). Whether that is true depends on what the Library does ++and what the program that uses the Library does. ++ ++ 1. You may copy and distribute verbatim copies of the Library's ++complete source code as you receive it, in any medium, provided that ++you conspicuously and appropriately publish on each copy an ++appropriate copyright notice and disclaimer of warranty; keep intact ++all the notices that refer to this License and to the absence of any ++warranty; and distribute a copy of this License along with the ++Library. ++ ++ You may charge a fee for the physical act of transferring a copy, ++and you may at your option offer warranty protection in exchange for a ++fee. ++ ++ 2. You may modify your copy or copies of the Library or any portion ++of it, thus forming a work based on the Library, and copy and ++distribute such modifications or work under the terms of Section 1 ++above, provided that you also meet all of these conditions: ++ ++ a) The modified work must itself be a software library. ++ ++ b) You must cause the files modified to carry prominent notices ++ stating that you changed the files and the date of any change. ++ ++ c) You must cause the whole of the work to be licensed at no ++ charge to all third parties under the terms of this License. ++ ++ d) If a facility in the modified Library refers to a function or a ++ table of data to be supplied by an application program that uses ++ the facility, other than as an argument passed when the facility ++ is invoked, then you must make a good faith effort to ensure that, ++ in the event an application does not supply such function or ++ table, the facility still operates, and performs whatever part of ++ its purpose remains meaningful. ++ ++ (For example, a function in a library to compute square roots has ++ a purpose that is entirely well-defined independent of the ++ application. Therefore, Subsection 2d requires that any ++ application-supplied function or table used by this function must ++ be optional: if the application does not supply it, the square ++ root function must still compute square roots.) ++ ++These requirements apply to the modified work as a whole. If ++identifiable sections of that work are not derived from the Library, ++and can be reasonably considered independent and separate works in ++themselves, then this License, and its terms, do not apply to those ++sections when you distribute them as separate works. But when you ++distribute the same sections as part of a whole which is a work based ++on the Library, the distribution of the whole must be on the terms of ++this License, whose permissions for other licensees extend to the ++entire whole, and thus to each and every part regardless of who wrote ++it. ++ ++Thus, it is not the intent of this section to claim rights or contest ++your rights to work written entirely by you; rather, the intent is to ++exercise the right to control the distribution of derivative or ++collective works based on the Library. ++ ++In addition, mere aggregation of another work not based on the Library ++with the Library (or with a work based on the Library) on a volume of ++a storage or distribution medium does not bring the other work under ++the scope of this License. ++ ++ 3. You may opt to apply the terms of the ordinary GNU General Public ++License instead of this License to a given copy of the Library. To do ++this, you must alter all the notices that refer to this License, so ++that they refer to the ordinary GNU General Public License, version 2, ++instead of to this License. (If a newer version than version 2 of the ++ordinary GNU General Public License has appeared, then you can specify ++that version instead if you wish.) Do not make any other change in ++these notices. ++ ++ Once this change is made in a given copy, it is irreversible for ++that copy, so the ordinary GNU General Public License applies to all ++subsequent copies and derivative works made from that copy. ++ ++ This option is useful when you wish to copy part of the code of ++the Library into a program that is not a library. ++ ++ 4. You may copy and distribute the Library (or a portion or ++derivative of it, under Section 2) in object code or executable form ++under the terms of Sections 1 and 2 above provided that you accompany ++it with the complete corresponding machine-readable source code, which ++must be distributed under the terms of Sections 1 and 2 above on a ++medium customarily used for software interchange. ++ ++ If distribution of object code is made by offering access to copy ++from a designated place, then offering equivalent access to copy the ++source code from the same place satisfies the requirement to ++distribute the source code, even though third parties are not ++compelled to copy the source along with the object code. ++ ++ 5. A program that contains no derivative of any portion of the ++Library, but is designed to work with the Library by being compiled or ++linked with it, is called a "work that uses the Library". Such a ++work, in isolation, is not a derivative work of the Library, and ++therefore falls outside the scope of this License. ++ ++ However, linking a "work that uses the Library" with the Library ++creates an executable that is a derivative of the Library (because it ++contains portions of the Library), rather than a "work that uses the ++library". The executable is therefore covered by this License. ++Section 6 states terms for distribution of such executables. ++ ++ When a "work that uses the Library" uses material from a header file ++that is part of the Library, the object code for the work may be a ++derivative work of the Library even though the source code is not. ++Whether this is true is especially significant if the work can be ++linked without the Library, or if the work is itself a library. The ++threshold for this to be true is not precisely defined by law. ++ ++ If such an object file uses only numerical parameters, data ++structure layouts and accessors, and small macros and small inline ++functions (ten lines or less in length), then the use of the object ++file is unrestricted, regardless of whether it is legally a derivative ++work. (Executables containing this object code plus portions of the ++Library will still fall under Section 6.) ++ ++ Otherwise, if the work is a derivative of the Library, you may ++distribute the object code for the work under the terms of Section 6. ++Any executables containing that work also fall under Section 6, ++whether or not they are linked directly with the Library itself. ++ ++ 6. As an exception to the Sections above, you may also combine or ++link a "work that uses the Library" with the Library to produce a ++work containing portions of the Library, and distribute that work ++under terms of your choice, provided that the terms permit ++modification of the work for the customer's own use and reverse ++engineering for debugging such modifications. ++ ++ You must give prominent notice with each copy of the work that the ++Library is used in it and that the Library and its use are covered by ++this License. You must supply a copy of this License. If the work ++during execution displays copyright notices, you must include the ++copyright notice for the Library among them, as well as a reference ++directing the user to the copy of this License. Also, you must do one ++of these things: ++ ++ a) Accompany the work with the complete corresponding ++ machine-readable source code for the Library including whatever ++ changes were used in the work (which must be distributed under ++ Sections 1 and 2 above); and, if the work is an executable linked ++ with the Library, with the complete machine-readable "work that ++ uses the Library", as object code and/or source code, so that the ++ user can modify the Library and then relink to produce a modified ++ executable containing the modified Library. (It is understood ++ that the user who changes the contents of definitions files in the ++ Library will not necessarily be able to recompile the application ++ to use the modified definitions.) ++ ++ b) Use a suitable shared library mechanism for linking with the ++ Library. A suitable mechanism is one that (1) uses at run time a ++ copy of the library already present on the user's computer system, ++ rather than copying library functions into the executable, and (2) ++ will operate properly with a modified version of the library, if ++ the user installs one, as long as the modified version is ++ interface-compatible with the version that the work was made with. ++ ++ c) Accompany the work with a written offer, valid for at ++ least three years, to give the same user the materials ++ specified in Subsection 6a, above, for a charge no more ++ than the cost of performing this distribution. ++ ++ d) If distribution of the work is made by offering access to copy ++ from a designated place, offer equivalent access to copy the above ++ specified materials from the same place. ++ ++ e) Verify that the user has already received a copy of these ++ materials or that you have already sent this user a copy. ++ ++ For an executable, the required form of the "work that uses the ++Library" must include any data and utility programs needed for ++reproducing the executable from it. However, as a special exception, ++the materials to be distributed need not include anything that is ++normally distributed (in either source or binary form) with the major ++components (compiler, kernel, and so on) of the operating system on ++which the executable runs, unless that component itself accompanies ++the executable. ++ ++ It may happen that this requirement contradicts the license ++restrictions of other proprietary libraries that do not normally ++accompany the operating system. Such a contradiction means you cannot ++use both them and the Library together in an executable that you ++distribute. ++ ++ 7. You may place library facilities that are a work based on the ++Library side-by-side in a single library together with other library ++facilities not covered by this License, and distribute such a combined ++library, provided that the separate distribution of the work based on ++the Library and of the other library facilities is otherwise ++permitted, and provided that you do these two things: ++ ++ a) Accompany the combined library with a copy of the same work ++ based on the Library, uncombined with any other library ++ facilities. This must be distributed under the terms of the ++ Sections above. ++ ++ b) Give prominent notice with the combined library of the fact ++ that part of it is a work based on the Library, and explaining ++ where to find the accompanying uncombined form of the same work. ++ ++ 8. You may not copy, modify, sublicense, link with, or distribute ++the Library except as expressly provided under this License. Any ++attempt otherwise to copy, modify, sublicense, link with, or ++distribute the Library is void, and will automatically terminate your ++rights under this License. However, parties who have received copies, ++or rights, from you under this License will not have their licenses ++terminated so long as such parties remain in full compliance. ++ ++ 9. You are not required to accept this License, since you have not ++signed it. However, nothing else grants you permission to modify or ++distribute the Library or its derivative works. These actions are ++prohibited by law if you do not accept this License. Therefore, by ++modifying or distributing the Library (or any work based on the ++Library), you indicate your acceptance of this License to do so, and ++all its terms and conditions for copying, distributing or modifying ++the Library or works based on it. ++ ++ 10. Each time you redistribute the Library (or any work based on the ++Library), the recipient automatically receives a license from the ++original licensor to copy, distribute, link with or modify the Library ++subject to these terms and conditions. You may not impose any further ++restrictions on the recipients' exercise of the rights granted herein. ++You are not responsible for enforcing compliance by third parties with ++this License. ++ ++ 11. If, as a consequence of a court judgment or allegation of patent ++infringement or for any other reason (not limited to patent issues), ++conditions are imposed on you (whether by court order, agreement or ++otherwise) that contradict the conditions of this License, they do not ++excuse you from the conditions of this License. If you cannot ++distribute so as to satisfy simultaneously your obligations under this ++License and any other pertinent obligations, then as a consequence you ++may not distribute the Library at all. For example, if a patent ++license would not permit royalty-free redistribution of the Library by ++all those who receive copies directly or indirectly through you, then ++the only way you could satisfy both it and this License would be to ++refrain entirely from distribution of the Library. ++ ++If any portion of this section is held invalid or unenforceable under any ++particular circumstance, the balance of the section is intended to apply, ++and the section as a whole is intended to apply in other circumstances. ++ ++It is not the purpose of this section to induce you to infringe any ++patents or other property right claims or to contest validity of any ++such claims; this section has the sole purpose of protecting the ++integrity of the free software distribution system which is ++implemented by public license practices. Many people have made ++generous contributions to the wide range of software distributed ++through that system in reliance on consistent application of that ++system; it is up to the author/donor to decide if he or she is willing ++to distribute software through any other system and a licensee cannot ++impose that choice. ++ ++This section is intended to make thoroughly clear what is believed to ++be a consequence of the rest of this License. ++ ++ 12. If the distribution and/or use of the Library is restricted in ++certain countries either by patents or by copyrighted interfaces, the ++original copyright holder who places the Library under this License may add ++an explicit geographical distribution limitation excluding those countries, ++so that distribution is permitted only in or among countries not thus ++excluded. In such case, this License incorporates the limitation as if ++written in the body of this License. ++ ++ 13. The Free Software Foundation may publish revised and/or new ++versions of the Lesser General Public License from time to time. ++Such new versions will be similar in spirit to the present version, ++but may differ in detail to address new problems or concerns. ++ ++Each version is given a distinguishing version number. If the Library ++specifies a version number of this License which applies to it and ++"any later version", you have the option of following the terms and ++conditions either of that version or of any later version published by ++the Free Software Foundation. If the Library does not specify a ++license version number, you may choose any version ever published by ++the Free Software Foundation. ++ ++ 14. If you wish to incorporate parts of the Library into other free ++programs whose distribution conditions are incompatible with these, ++write to the author to ask for permission. For software which is ++copyrighted by the Free Software Foundation, write to the Free ++Software Foundation; we sometimes make exceptions for this. Our ++decision will be guided by the two goals of preserving the free status ++of all derivatives of our free software and of promoting the sharing ++and reuse of software generally. ++ ++ NO WARRANTY ++ ++ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO ++WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. ++EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR ++OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY ++KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE ++IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ++PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE ++LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME ++THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. ++ ++ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN ++WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY ++AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU ++FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR ++CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE ++LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING ++RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A ++FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF ++SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH ++DAMAGES. ++ ++ END OF TERMS AND CONDITIONS ++ ++ How to Apply These Terms to Your New Libraries ++ ++ If you develop a new library, and you want it to be of the greatest ++possible use to the public, we recommend making it free software that ++everyone can redistribute and change. You can do so by permitting ++redistribution under these terms (or, alternatively, under the terms of the ++ordinary General Public License). ++ ++ To apply these terms, attach the following notices to the library. It is ++safest to attach them to the start of each source file to most effectively ++convey the exclusion of warranty; and each file should have at least the ++"copyright" line and a pointer to where the full notice is found. ++ ++ ++ Copyright (C) ++ ++ This library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ This library 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 ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ ++Also add information on how to contact you by electronic and paper mail. ++ ++You should also get your employer (if you work as a programmer) or your ++school, if any, to sign a "copyright disclaimer" for the library, if ++necessary. Here is a sample; alter the names: ++ ++ Yoyodyne, Inc., hereby disclaims all copyright interest in the ++ library `Frob' (a library for tweaking knobs) written by James Random Hacker. ++ ++ , 1 April 1990 ++ Ty Coon, President of Vice ++ ++That's all there is to it! +diff -Nurd linuxtv-dvb-apps-1.1.1/include/audio.h dvb-apps/include/audio.h +--- linuxtv-dvb-apps-1.1.1/include/audio.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/include/audio.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,140 @@ ++/* ++ * audio.h ++ * ++ * Copyright (C) 2000 Ralph Metzler ++ * & Marcus Metzler ++ * for convergence integrated media GmbH ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Lesser Public License ++ * as published by the Free Software Foundation; either version 2.1 ++ * 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 Lesser General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ * ++ */ ++ ++#ifndef _DVBAUDIO_H_ ++#define _DVBAUDIO_H_ ++ ++#ifdef __KERNEL__ ++#include ++#else ++#include ++#endif ++ ++ ++typedef enum { ++ AUDIO_SOURCE_DEMUX, /* Select the demux as the main source */ ++ AUDIO_SOURCE_MEMORY /* Select internal memory as the main source */ ++} audio_stream_source_t; ++ ++ ++typedef enum { ++ AUDIO_STOPPED, /* Device is stopped */ ++ AUDIO_PLAYING, /* Device is currently playing */ ++ AUDIO_PAUSED /* Device is paused */ ++} audio_play_state_t; ++ ++ ++typedef enum { ++ AUDIO_STEREO, ++ AUDIO_MONO_LEFT, ++ AUDIO_MONO_RIGHT, ++ AUDIO_MONO, ++ AUDIO_STEREO_SWAPPED ++} audio_channel_select_t; ++ ++ ++typedef struct audio_mixer { ++ unsigned int volume_left; ++ unsigned int volume_right; ++ // what else do we need? bass, pass-through, ... ++} audio_mixer_t; ++ ++ ++typedef struct audio_status { ++ int AV_sync_state; /* sync audio and video? */ ++ int mute_state; /* audio is muted */ ++ audio_play_state_t play_state; /* current playback state */ ++ audio_stream_source_t stream_source; /* current stream source */ ++ audio_channel_select_t channel_select; /* currently selected channel */ ++ int bypass_mode; /* pass on audio data to */ ++ audio_mixer_t mixer_state; /* current mixer state */ ++} audio_status_t; /* separate decoder hardware */ ++ ++ ++typedef ++struct audio_karaoke{ /* if Vocal1 or Vocal2 are non-zero, they get mixed */ ++ int vocal1; /* into left and right t at 70% each */ ++ int vocal2; /* if both, Vocal1 and Vocal2 are non-zero, Vocal1 gets*/ ++ int melody; /* mixed into the left channel and */ ++ /* Vocal2 into the right channel at 100% each. */ ++ /* if Melody is non-zero, the melody channel gets mixed*/ ++} audio_karaoke_t; /* into left and right */ ++ ++ ++typedef uint16_t audio_attributes_t; ++/* bits: descr. */ ++/* 15-13 audio coding mode (0=ac3, 2=mpeg1, 3=mpeg2ext, 4=LPCM, 6=DTS, */ ++/* 12 multichannel extension */ ++/* 11-10 audio type (0=not spec, 1=language included) */ ++/* 9- 8 audio application mode (0=not spec, 1=karaoke, 2=surround) */ ++/* 7- 6 Quantization / DRC (mpeg audio: 1=DRC exists)(lpcm: 0=16bit, */ ++/* 5- 4 Sample frequency fs (0=48kHz, 1=96kHz) */ ++/* 2- 0 number of audio channels (n+1 channels) */ ++ ++ ++/* for GET_CAPABILITIES and SET_FORMAT, the latter should only set one bit */ ++#define AUDIO_CAP_DTS 1 ++#define AUDIO_CAP_LPCM 2 ++#define AUDIO_CAP_MP1 4 ++#define AUDIO_CAP_MP2 8 ++#define AUDIO_CAP_MP3 16 ++#define AUDIO_CAP_AAC 32 ++#define AUDIO_CAP_OGG 64 ++#define AUDIO_CAP_SDDS 128 ++#define AUDIO_CAP_AC3 256 ++ ++#define AUDIO_STOP _IO('o', 1) ++#define AUDIO_PLAY _IO('o', 2) ++#define AUDIO_PAUSE _IO('o', 3) ++#define AUDIO_CONTINUE _IO('o', 4) ++#define AUDIO_SELECT_SOURCE _IO('o', 5) ++#define AUDIO_SET_MUTE _IO('o', 6) ++#define AUDIO_SET_AV_SYNC _IO('o', 7) ++#define AUDIO_SET_BYPASS_MODE _IO('o', 8) ++#define AUDIO_CHANNEL_SELECT _IO('o', 9) ++#define AUDIO_GET_STATUS _IOR('o', 10, audio_status_t) ++ ++#define AUDIO_GET_CAPABILITIES _IOR('o', 11, unsigned int) ++#define AUDIO_CLEAR_BUFFER _IO('o', 12) ++#define AUDIO_SET_ID _IO('o', 13) ++#define AUDIO_SET_MIXER _IOW('o', 14, audio_mixer_t) ++#define AUDIO_SET_STREAMTYPE _IO('o', 15) ++#define AUDIO_SET_EXT_ID _IO('o', 16) ++#define AUDIO_SET_ATTRIBUTES _IOW('o', 17, audio_attributes_t) ++#define AUDIO_SET_KARAOKE _IOW('o', 18, audio_karaoke_t) ++ ++/** ++ * AUDIO_GET_PTS ++ * ++ * Read the 33 bit presentation time stamp as defined ++ * in ITU T-REC-H.222.0 / ISO/IEC 13818-1. ++ * ++ * The PTS should belong to the currently played ++ * frame if possible, but may also be a value close to it ++ * like the PTS of the last decoded frame or the last PTS ++ * extracted by the PES parser. ++ */ ++#define AUDIO_GET_PTS _IOR('o', 19, __u64) ++#define AUDIO_BILINGUAL_CHANNEL_SELECT _IO('o', 20) ++ ++#endif /* _DVBAUDIO_H_ */ +diff -Nurd linuxtv-dvb-apps-1.1.1/include/ca.h dvb-apps/include/ca.h +--- linuxtv-dvb-apps-1.1.1/include/ca.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/include/ca.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,90 @@ ++/* ++ * ca.h ++ * ++ * Copyright (C) 2000 Ralph Metzler ++ * & Marcus Metzler ++ * for convergence integrated media GmbH ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Lesser Public License ++ * as published by the Free Software Foundation; either version 2.1 ++ * 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 Lesser General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ * ++ */ ++ ++#ifndef _DVBCA_H_ ++#define _DVBCA_H_ ++ ++/* slot interface types and info */ ++ ++typedef struct ca_slot_info { ++ int num; /* slot number */ ++ ++ int type; /* CA interface this slot supports */ ++#define CA_CI 1 /* CI high level interface */ ++#define CA_CI_LINK 2 /* CI link layer level interface */ ++#define CA_CI_PHYS 4 /* CI physical layer level interface */ ++#define CA_DESCR 8 /* built-in descrambler */ ++#define CA_SC 128 /* simple smart card interface */ ++ ++ unsigned int flags; ++#define CA_CI_MODULE_PRESENT 1 /* module (or card) inserted */ ++#define CA_CI_MODULE_READY 2 ++} ca_slot_info_t; ++ ++ ++/* descrambler types and info */ ++ ++typedef struct ca_descr_info { ++ unsigned int num; /* number of available descramblers (keys) */ ++ unsigned int type; /* type of supported scrambling system */ ++#define CA_ECD 1 ++#define CA_NDS 2 ++#define CA_DSS 4 ++} ca_descr_info_t; ++ ++typedef struct ca_caps { ++ unsigned int slot_num; /* total number of CA card and module slots */ ++ unsigned int slot_type; /* OR of all supported types */ ++ unsigned int descr_num; /* total number of descrambler slots (keys) */ ++ unsigned int descr_type; /* OR of all supported types */ ++} ca_caps_t; ++ ++/* a message to/from a CI-CAM */ ++typedef struct ca_msg { ++ unsigned int index; ++ unsigned int type; ++ unsigned int length; ++ unsigned char msg[256]; ++} ca_msg_t; ++ ++typedef struct ca_descr { ++ unsigned int index; ++ unsigned int parity; /* 0 == even, 1 == odd */ ++ unsigned char cw[8]; ++} ca_descr_t; ++ ++typedef struct ca_pid { ++ unsigned int pid; ++ int index; /* -1 == disable*/ ++} ca_pid_t; ++ ++#define CA_RESET _IO('o', 128) ++#define CA_GET_CAP _IOR('o', 129, ca_caps_t) ++#define CA_GET_SLOT_INFO _IOR('o', 130, ca_slot_info_t) ++#define CA_GET_DESCR_INFO _IOR('o', 131, ca_descr_info_t) ++#define CA_GET_MSG _IOR('o', 132, ca_msg_t) ++#define CA_SEND_MSG _IOW('o', 133, ca_msg_t) ++#define CA_SET_DESCR _IOW('o', 134, ca_descr_t) ++#define CA_SET_PID _IOW('o', 135, ca_pid_t) ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/include/dmx.h dvb-apps/include/dmx.h +--- linuxtv-dvb-apps-1.1.1/include/dmx.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/include/dmx.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,154 @@ ++/* ++ * dmx.h ++ * ++ * Copyright (C) 2000 Marcus Metzler ++ * & Ralph Metzler ++ * for convergence integrated media GmbH ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public License ++ * as published by the Free Software Foundation; either version 2.1 ++ * 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 Lesser General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ * ++ */ ++ ++#ifndef _DVBDMX_H_ ++#define _DVBDMX_H_ ++ ++#include ++#ifdef __KERNEL__ ++#include ++#else ++#include ++#endif ++ ++ ++#define DMX_FILTER_SIZE 16 ++ ++typedef enum ++{ ++ DMX_OUT_DECODER, /* Streaming directly to decoder. */ ++ DMX_OUT_TAP, /* Output going to a memory buffer */ ++ /* (to be retrieved via the read command).*/ ++ DMX_OUT_TS_TAP /* Output multiplexed into a new TS */ ++ /* (to be retrieved by reading from the */ ++ /* logical DVR device). */ ++} dmx_output_t; ++ ++ ++typedef enum ++{ ++ DMX_IN_FRONTEND, /* Input from a front-end device. */ ++ DMX_IN_DVR /* Input from the logical DVR device. */ ++} dmx_input_t; ++ ++ ++typedef enum ++{ ++ DMX_PES_AUDIO0, ++ DMX_PES_VIDEO0, ++ DMX_PES_TELETEXT0, ++ DMX_PES_SUBTITLE0, ++ DMX_PES_PCR0, ++ ++ DMX_PES_AUDIO1, ++ DMX_PES_VIDEO1, ++ DMX_PES_TELETEXT1, ++ DMX_PES_SUBTITLE1, ++ DMX_PES_PCR1, ++ ++ DMX_PES_AUDIO2, ++ DMX_PES_VIDEO2, ++ DMX_PES_TELETEXT2, ++ DMX_PES_SUBTITLE2, ++ DMX_PES_PCR2, ++ ++ DMX_PES_AUDIO3, ++ DMX_PES_VIDEO3, ++ DMX_PES_TELETEXT3, ++ DMX_PES_SUBTITLE3, ++ DMX_PES_PCR3, ++ ++ DMX_PES_OTHER ++} dmx_pes_type_t; ++ ++#define DMX_PES_AUDIO DMX_PES_AUDIO0 ++#define DMX_PES_VIDEO DMX_PES_VIDEO0 ++#define DMX_PES_TELETEXT DMX_PES_TELETEXT0 ++#define DMX_PES_SUBTITLE DMX_PES_SUBTITLE0 ++#define DMX_PES_PCR DMX_PES_PCR0 ++ ++ ++typedef struct dmx_filter ++{ ++ __u8 filter[DMX_FILTER_SIZE]; ++ __u8 mask[DMX_FILTER_SIZE]; ++ __u8 mode[DMX_FILTER_SIZE]; ++} dmx_filter_t; ++ ++ ++struct dmx_sct_filter_params ++{ ++ __u16 pid; ++ dmx_filter_t filter; ++ __u32 timeout; ++ __u32 flags; ++#define DMX_CHECK_CRC 1 ++#define DMX_ONESHOT 2 ++#define DMX_IMMEDIATE_START 4 ++#define DMX_KERNEL_CLIENT 0x8000 ++}; ++ ++ ++struct dmx_pes_filter_params ++{ ++ __u16 pid; ++ dmx_input_t input; ++ dmx_output_t output; ++ dmx_pes_type_t pes_type; ++ __u32 flags; ++}; ++ ++typedef struct dmx_caps { ++ __u32 caps; ++ int num_decoders; ++} dmx_caps_t; ++ ++typedef enum { ++ DMX_SOURCE_FRONT0 = 0, ++ DMX_SOURCE_FRONT1, ++ DMX_SOURCE_FRONT2, ++ DMX_SOURCE_FRONT3, ++ DMX_SOURCE_DVR0 = 16, ++ DMX_SOURCE_DVR1, ++ DMX_SOURCE_DVR2, ++ DMX_SOURCE_DVR3 ++} dmx_source_t; ++ ++struct dmx_stc { ++ unsigned int num; /* input : which STC? 0..N */ ++ unsigned int base; /* output: divisor for stc to get 90 kHz clock */ ++ __u64 stc; /* output: stc in 'base'*90 kHz units */ ++}; ++ ++ ++#define DMX_START _IO('o', 41) ++#define DMX_STOP _IO('o', 42) ++#define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params) ++#define DMX_SET_PES_FILTER _IOW('o', 44, struct dmx_pes_filter_params) ++#define DMX_SET_BUFFER_SIZE _IO('o', 45) ++#define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5]) ++#define DMX_GET_CAPS _IOR('o', 48, dmx_caps_t) ++#define DMX_SET_SOURCE _IOW('o', 49, dmx_source_t) ++#define DMX_GET_STC _IOWR('o', 50, struct dmx_stc) ++ ++#endif /*_DVBDMX_H_*/ +diff -Nurd linuxtv-dvb-apps-1.1.1/include/frontend.h dvb-apps/include/frontend.h +--- linuxtv-dvb-apps-1.1.1/include/frontend.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/include/frontend.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,648 @@ ++/* ++ * frontend.h ++ * ++ * Copyright (C) 2000 Marcus Metzler ++ * Ralph Metzler ++ * Holger Waechtler ++ * Andre Draszik ++ * for convergence integrated media GmbH ++ * ++ * Copyright (C) Manu Abraham ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public License ++ * as published by the Free Software Foundation; either version 2.1 ++ * 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 Lesser General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ * ++ */ ++ ++#ifndef _DVBFRONTEND_H_ ++#define _DVBFRONTEND_H_ ++ ++#include ++ ++ ++typedef enum fe_type { ++ FE_QPSK, ++ FE_QAM, ++ FE_OFDM, ++ FE_ATSC ++} fe_type_t; ++ ++ ++typedef enum fe_caps { ++ FE_IS_STUPID = 0, ++ FE_CAN_INVERSION_AUTO = 0x1, ++ FE_CAN_FEC_1_2 = 0x2, ++ FE_CAN_FEC_2_3 = 0x4, ++ FE_CAN_FEC_3_4 = 0x8, ++ FE_CAN_FEC_4_5 = 0x10, ++ FE_CAN_FEC_5_6 = 0x20, ++ FE_CAN_FEC_6_7 = 0x40, ++ FE_CAN_FEC_7_8 = 0x80, ++ FE_CAN_FEC_8_9 = 0x100, ++ FE_CAN_FEC_AUTO = 0x200, ++ FE_CAN_QPSK = 0x400, ++ FE_CAN_QAM_16 = 0x800, ++ FE_CAN_QAM_32 = 0x1000, ++ FE_CAN_QAM_64 = 0x2000, ++ FE_CAN_QAM_128 = 0x4000, ++ FE_CAN_QAM_256 = 0x8000, ++ FE_CAN_QAM_AUTO = 0x10000, ++ FE_CAN_TRANSMISSION_MODE_AUTO = 0x20000, ++ FE_CAN_BANDWIDTH_AUTO = 0x40000, ++ FE_CAN_GUARD_INTERVAL_AUTO = 0x80000, ++ FE_CAN_HIERARCHY_AUTO = 0x100000, ++ FE_CAN_8VSB = 0x200000, ++ FE_CAN_16VSB = 0x400000, ++ FE_NEEDS_BENDING = 0x20000000, // not supported anymore, don't use (frontend requires frequency bending) ++ FE_CAN_RECOVER = 0x40000000, // frontend can recover from a cable unplug automatically ++ FE_CAN_MUTE_TS = 0x80000000 // frontend can stop spurious TS data output ++} fe_caps_t; ++ ++ ++struct dvb_frontend_info { ++ char name[128]; ++ fe_type_t type; ++ __u32 frequency_min; ++ __u32 frequency_max; ++ __u32 frequency_stepsize; ++ __u32 frequency_tolerance; ++ __u32 symbol_rate_min; ++ __u32 symbol_rate_max; ++ __u32 symbol_rate_tolerance; /* ppm */ ++ __u32 notifier_delay; /* DEPRECATED */ ++ fe_caps_t caps; ++}; ++ ++ ++/** ++ * Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for ++ * the meaning of this struct... ++ */ ++struct dvb_diseqc_master_cmd { ++ __u8 msg [6]; /* { framing, address, command, data [3] } */ ++ __u8 msg_len; /* valid values are 3...6 */ ++}; ++ ++ ++struct dvb_diseqc_slave_reply { ++ __u8 msg [4]; /* { framing, data [3] } */ ++ __u8 msg_len; /* valid values are 0...4, 0 means no msg */ ++ int timeout; /* return from ioctl after timeout ms with */ ++}; /* errorcode when no message was received */ ++ ++ ++typedef enum fe_sec_voltage { ++ SEC_VOLTAGE_13, ++ SEC_VOLTAGE_18, ++ SEC_VOLTAGE_OFF ++} fe_sec_voltage_t; ++ ++ ++typedef enum fe_sec_tone_mode { ++ SEC_TONE_ON, ++ SEC_TONE_OFF ++} fe_sec_tone_mode_t; ++ ++ ++typedef enum fe_sec_mini_cmd { ++ SEC_MINI_A, ++ SEC_MINI_B ++} fe_sec_mini_cmd_t; ++ ++ ++typedef enum fe_status { ++ FE_HAS_SIGNAL = 0x01, /* found something above the noise level */ ++ FE_HAS_CARRIER = 0x02, /* found a DVB signal */ ++ FE_HAS_VITERBI = 0x04, /* FEC is stable */ ++ FE_HAS_SYNC = 0x08, /* found sync bytes */ ++ FE_HAS_LOCK = 0x10, /* everything's working... */ ++ FE_TIMEDOUT = 0x20, /* no lock within the last ~2 seconds */ ++ FE_REINIT = 0x40 /* frontend was reinitialized, */ ++} fe_status_t; /* application is recommended to reset */ ++ /* DiSEqC, tone and parameters */ ++ ++typedef enum fe_spectral_inversion { ++ INVERSION_OFF, ++ INVERSION_ON, ++ INVERSION_AUTO ++} fe_spectral_inversion_t; ++ ++ ++typedef enum fe_code_rate { ++ FEC_NONE = 0, ++ FEC_1_2, ++ FEC_2_3, ++ FEC_3_4, ++ FEC_4_5, ++ FEC_5_6, ++ FEC_6_7, ++ FEC_7_8, ++ FEC_8_9, ++ FEC_AUTO ++} fe_code_rate_t; ++ ++ ++typedef enum fe_modulation { ++ QPSK, ++ QAM_16, ++ QAM_32, ++ QAM_64, ++ QAM_128, ++ QAM_256, ++ QAM_AUTO, ++ VSB_8, ++ VSB_16 ++} fe_modulation_t; ++ ++typedef enum fe_transmit_mode { ++ TRANSMISSION_MODE_2K, ++ TRANSMISSION_MODE_8K, ++ TRANSMISSION_MODE_AUTO ++} fe_transmit_mode_t; ++ ++typedef enum fe_bandwidth { ++ BANDWIDTH_8_MHZ, ++ BANDWIDTH_7_MHZ, ++ BANDWIDTH_6_MHZ, ++ BANDWIDTH_AUTO ++} fe_bandwidth_t; ++ ++ ++typedef enum fe_guard_interval { ++ GUARD_INTERVAL_1_32, ++ GUARD_INTERVAL_1_16, ++ GUARD_INTERVAL_1_8, ++ GUARD_INTERVAL_1_4, ++ GUARD_INTERVAL_AUTO ++} fe_guard_interval_t; ++ ++ ++typedef enum fe_hierarchy { ++ HIERARCHY_NONE, ++ HIERARCHY_1, ++ HIERARCHY_2, ++ HIERARCHY_4, ++ HIERARCHY_AUTO ++} fe_hierarchy_t; ++ ++ ++struct dvb_qpsk_parameters { ++ __u32 symbol_rate; /* symbol rate in Symbols per second */ ++ fe_code_rate_t fec_inner; /* forward error correction (see above) */ ++}; ++ ++struct dvb_qam_parameters { ++ __u32 symbol_rate; /* symbol rate in Symbols per second */ ++ fe_code_rate_t fec_inner; /* forward error correction (see above) */ ++ fe_modulation_t modulation; /* modulation type (see above) */ ++}; ++ ++struct dvb_vsb_parameters { ++ fe_modulation_t modulation; /* modulation type (see above) */ ++}; ++ ++struct dvb_ofdm_parameters { ++ fe_bandwidth_t bandwidth; ++ fe_code_rate_t code_rate_HP; /* high priority stream code rate */ ++ fe_code_rate_t code_rate_LP; /* low priority stream code rate */ ++ fe_modulation_t constellation; /* modulation type (see above) */ ++ fe_transmit_mode_t transmission_mode; ++ fe_guard_interval_t guard_interval; ++ fe_hierarchy_t hierarchy_information; ++}; ++ ++ ++struct dvb_frontend_parameters { ++ __u32 frequency; /* (absolute) frequency in Hz for QAM/OFDM/ATSC */ ++ /* intermediate frequency in kHz for QPSK */ ++ fe_spectral_inversion_t inversion; ++ union { ++ struct dvb_qpsk_parameters qpsk; ++ struct dvb_qam_parameters qam; ++ struct dvb_ofdm_parameters ofdm; ++ struct dvb_vsb_parameters vsb; ++ } u; ++}; ++ ++ ++/** ++ * When set, this flag will disable any zigzagging or other "normal" tuning ++ * behaviour. Additionally, there will be no automatic monitoring of the lock ++ * status, and hence no frontend events will be generated. If a frontend device ++ * is closed, this flag will be automatically turned off when the device is ++ * reopened read-write. ++ */ ++#define FE_TUNE_MODE_ONESHOT 0x01 ++ ++ ++#define FE_GET_INFO _IOR('o', 61, struct dvb_frontend_info) ++ ++#define FE_DISEQC_RESET_OVERLOAD _IO('o', 62) ++#define FE_DISEQC_SEND_MASTER_CMD _IOW('o', 63, struct dvb_diseqc_master_cmd) ++#define FE_DISEQC_RECV_SLAVE_REPLY _IOR('o', 64, struct dvb_diseqc_slave_reply) ++#define FE_DISEQC_SEND_BURST _IO('o', 65) /* fe_sec_mini_cmd_t */ ++ ++#define FE_SET_TONE _IO('o', 66) /* fe_sec_tone_mode_t */ ++#define FE_SET_VOLTAGE _IO('o', 67) /* fe_sec_voltage_t */ ++#define FE_ENABLE_HIGH_LNB_VOLTAGE _IO('o', 68) /* int */ ++ ++#define FE_READ_STATUS _IOR('o', 69, fe_status_t) ++#define FE_READ_BER _IOR('o', 70, __u32) ++#define FE_READ_SIGNAL_STRENGTH _IOR('o', 71, __u16) ++#define FE_READ_SNR _IOR('o', 72, __u16) ++#define FE_READ_UNCORRECTED_BLOCKS _IOR('o', 73, __u32) ++ ++#define FE_SET_FRONTEND _IOW('o', 76, struct dvb_frontend_parameters) ++#define FE_GET_FRONTEND _IOR('o', 77, struct dvb_frontend_parameters) ++#define FE_SET_FRONTEND_TUNE_MODE _IO('o', 81) /* unsigned int */ ++ ++#define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */ ++ ++/* ++ * References: ++ * DVB-S : EN 300 421 ++ * DVB-S2: EN 302 307, TR 102 376, EN 301 210 ++ * DVB-C : EN 300 429 ++ * DVB-T : EN 300 744 ++ * DVB-H : EN 300 304 ++ * ATSC : A/53A ++ */ ++ ++/* ++ * Delivery Systems ++ * needs to set/queried for multistandard frontends ++ */ ++enum dvbfe_delsys { ++ DVBFE_DELSYS_DVBS = (1 << 0), ++ DVBFE_DELSYS_DSS = (1 << 1), ++ DVBFE_DELSYS_DVBS2 = (1 << 2), ++ DVBFE_DELSYS_DVBC = (1 << 3), ++ DVBFE_DELSYS_DVBT = (1 << 4), ++ DVBFE_DELSYS_DVBH = (1 << 5), ++ DVBFE_DELSYS_ATSC = (1 << 6), ++ DVBFE_DELSYS_DUMMY = (1 << 31) ++}; ++#define DVBFE_GET_DELSYS _IOR('o', 82, enum dvbfe_delsys) ++#define DVBFE_SET_DELSYS _IOW('o', 87, enum dvbfe_delsys) ++ ++/* Modulation types */ ++enum dvbfe_modulation { ++ DVBFE_MOD_NONE = (0 << 0), ++ DVBFE_MOD_BPSK = (1 << 0), ++ DVBFE_MOD_QPSK = (1 << 1), ++ DVBFE_MOD_OQPSK = (1 << 2), ++ DVBFE_MOD_8PSK = (1 << 3), ++ DVBFE_MOD_16APSK = (1 << 4), ++ DVBFE_MOD_32APSK = (1 << 5), ++ DVBFE_MOD_QAM4 = (1 << 6), ++ DVBFE_MOD_QAM16 = (1 << 7), ++ DVBFE_MOD_QAM32 = (1 << 8), ++ DVBFE_MOD_QAM64 = (1 << 9), ++ DVBFE_MOD_QAM128 = (1 << 10), ++ DVBFE_MOD_QAM256 = (1 << 11), ++ DVBFE_MOD_QAM512 = (1 << 12), ++ DVBFE_MOD_QAM1024 = (1 << 13), ++ DVBFE_MOD_QAMAUTO = (1 << 14), ++ DVBFE_MOD_OFDM = (1 << 15), ++ DVBFE_MOD_COFDM = (1 << 16), ++ DVBFE_MOD_VSB8 = (1 << 17), ++ DVBFE_MOD_VSB16 = (1 << 18), ++ DVBFE_MOD_AUTO = (1 << 31) ++}; ++ ++/* ++ * Convolution Code Rate (Viterbi Inner Code Rate) ++ * DVB-S2 uses LDPC. Information on LDPC can be found at ++ * http://www.ldpc-codes.com ++ */ ++enum dvbfe_fec { ++ DVBFE_FEC_NONE = (0 << 0), ++ DVBFE_FEC_1_4 = (1 << 0), ++ DVBFE_FEC_1_3 = (1 << 1), ++ DVBFE_FEC_2_5 = (1 << 2), ++ DVBFE_FEC_1_2 = (1 << 3), ++ DVBFE_FEC_3_5 = (1 << 4), ++ DVBFE_FEC_2_3 = (1 << 5), ++ DVBFE_FEC_3_4 = (1 << 6), ++ DVBFE_FEC_4_5 = (1 << 7), ++ DVBFE_FEC_5_6 = (1 << 8), ++ DVBFE_FEC_6_7 = (1 << 9), ++ DVBFE_FEC_7_8 = (1 << 10), ++ DVBFE_FEC_8_9 = (1 << 11), ++ DVBFE_FEC_9_10 = (1 << 12), ++ DVBFE_FEC_AUTO = (1 << 31) ++}; ++ ++/* Frontend Inversion (I/Q Swap) */ ++enum dvbfe_inversion { ++ DVBFE_INVERSION_OFF = 0, ++ DVBFE_INVERSION_ON = 1, ++ DVBFE_INVERSION_AUTO = 2 ++}; ++ ++/* DVB-S parameters */ ++struct dvbs_params { ++ __u32 symbol_rate; ++ ++ enum dvbfe_modulation modulation; ++ enum dvbfe_fec fec; ++}; ++ ++/* DSS parameters */ ++struct dss_params { ++ __u32 symbol_rate; ++ ++ enum dvbfe_modulation modulation; ++ enum dvbfe_fec fec; ++}; ++ ++/* ++ * Rolloff Rate (Nyquist Filter Rolloff) ++ * NOTE: DVB-S2 has rates of 0.20, 0.25, 0.35 ++ * Values are x100 ++ * Applies to DVB-S2 ++ */ ++enum dvbfe_rolloff { ++ DVBFE_ROLLOFF_35 = 0, ++ DVBFE_ROLLOFF_25 = 1, ++ DVBFE_ROLLOFF_20 = 2, ++ DVBFE_ROLLOFF_UNKNOWN = 3 ++}; ++ ++/* DVB-S2 parameters */ ++struct dvbs2_params { ++ __u32 symbol_rate; ++ ++ enum dvbfe_modulation modulation; ++ enum dvbfe_fec fec; ++ ++ /* Informational fields only */ ++ enum dvbfe_rolloff rolloff; ++ ++ __u8 matype_1; ++ __u8 matype_2; ++ __u8 upl_1; ++ __u8 upl_2; ++ __u8 dfl_1; ++ __u8 dfl_2; ++ __u8 sync; ++ __u8 syncd_1; ++ __u8 syncd_2; ++ ++ __u8 pad[32]; ++}; ++ ++/* DVB-C parameters */ ++struct dvbc_params { ++ __u32 symbol_rate; ++ enum dvbfe_modulation modulation; ++ enum dvbfe_fec fec; ++}; ++ ++/* DVB-T Channel bandwidth */ ++enum dvbfe_bandwidth { ++ DVBFE_BANDWIDTH_8_MHZ = (1 << 0), ++ DVBFE_BANDWIDTH_7_MHZ = (1 << 1), ++ DVBFE_BANDWIDTH_6_MHZ = (1 << 2), ++ DVBFE_BANDWIDTH_5_MHZ = (1 << 3), ++ DVBFE_BANDWIDTH_AUTO = (1 << 31) ++}; ++ ++/* DVB-T/DVB-H transmission mode */ ++enum dvbfe_transmission_mode { ++ DVBFE_TRANSMISSION_MODE_2K = (1 << 0), ++ DVBFE_TRANSMISSION_MODE_4K = (1 << 1), ++ DVBFE_TRANSMISSION_MODE_8K = (1 << 2), ++ DVBFE_TRANSMISSION_MODE_AUTO = (1 << 31) ++}; ++ ++/* DVB-T/DVB-H Guard interval */ ++enum dvbfe_guard_interval { ++ DVBFE_GUARD_INTERVAL_1_32 = (1 << 1), ++ DVBFE_GUARD_INTERVAL_1_16 = (1 << 2), ++ DVBFE_GUARD_INTERVAL_1_8 = (1 << 3), ++ DVBFE_GUARD_INTERVAL_1_4 = (1 << 4), ++ DVBFE_GUARD_INTERVAL_AUTO = (1 << 31) ++}; ++ ++/* DVB-T/DVB-H Hierarchial modulation */ ++enum dvbfe_hierarchy { ++ DVBFE_HIERARCHY_OFF = (1 << 0), ++ DVBFE_HIERARCHY_ON = (1 << 1), ++ DVBFE_HIERARCHY_AUTO = (1 << 2) ++}; ++ ++/* DVB-T/DVB-H Rolloff's */ ++enum dvbfe_alpha { ++ DVBFE_ALPHA_1 = (1 << 0), ++ DVBFE_ALPHA_2 = (1 << 1), ++ DVBFE_ALPHA_4 = (1 << 2) ++}; ++ ++/* Stream priority (Hierachial coding) */ ++enum dvbfe_stream_priority { ++ DVBFE_STREAM_PRIORITY_HP = (0 << 0), ++ DVBFE_STREAM_PRIORITY_LP = (1 << 0) ++}; ++ ++/* DVB-T parameters */ ++struct dvbt_params { ++ enum dvbfe_modulation constellation; ++ enum dvbfe_bandwidth bandwidth; ++ enum dvbfe_fec code_rate_HP; ++ enum dvbfe_fec code_rate_LP; ++ enum dvbfe_transmission_mode transmission_mode; ++ enum dvbfe_guard_interval guard_interval; ++ enum dvbfe_hierarchy hierarchy; ++ enum dvbfe_alpha alpha; ++ enum dvbfe_stream_priority priority; ++ ++ __u8 pad[32]; ++}; ++ ++/* DVB-H Interleaver type */ ++enum dvbfe_interleaver { ++ DVBFE_INTERLEAVER_NATIVE = (1 << 0), ++ DVBFE_INTERLEAVER_INDEPTH = (1 << 1), ++ DVBFE_INTERLEAVER_AUTO = (1 << 31) ++}; ++ ++/* DVB-H MPE-FEC Indicator */ ++enum dvbfe_mpefec { ++ DVBFE_MPEFEC_OFF = (1 << 0), ++ DVBFE_MPEFEC_ON = (1 << 1) ++}; ++ ++/* DVB-H Timeslicing Indicator */ ++enum dvbfe_timeslicing { ++ DVBFE_TIMESLICING_OFF = (1 << 0), ++ DVBFE_TIMESLICING_ON = (1 << 1) ++}; ++ ++/* DVB-H parameters */ ++struct dvbh_params { ++ enum dvbfe_modulation constellation; ++ enum dvbfe_fec code_rate_HP; ++ enum dvbfe_fec code_rate_LP; ++ enum dvbfe_transmission_mode transmission_mode; ++ enum dvbfe_guard_interval guard_interval; ++ enum dvbfe_hierarchy hierarchy; ++ enum dvbfe_alpha alpha; ++ enum dvbfe_interleaver interleaver; ++ enum dvbfe_mpefec mpefec; ++ enum dvbfe_timeslicing timeslicing; ++ enum dvbfe_stream_priority priority; ++ ++ __u32 bandwidth; ++ __u8 pad[32]; ++}; ++ ++/* ATSC parameters */ ++struct atsc_params { ++ enum dvbfe_modulation modulation; ++ ++ __u8 pad[32]; ++}; ++ ++/* DVB Frontend Tuning Parameters */ ++struct dvbfe_params { ++ __u32 frequency; ++ enum fe_spectral_inversion inversion; ++ enum dvbfe_delsys delivery; ++ ++ __u8 pad[32]; ++ ++ union { ++ struct dvbs_params dvbs; ++ struct dss_params dss; ++ struct dvbs2_params dvbs2; ++ struct dvbc_params dvbc; ++ struct dvbt_params dvbt; ++ struct dvbh_params dvbh; ++ struct atsc_params atsc; ++ ++ __u8 pad[128]; ++ } delsys; ++}; ++#define DVBFE_SET_PARAMS _IOW('o', 83, struct dvbfe_params) ++#define DVBFE_GET_PARAMS _IOWR('o', 84, struct dvbfe_params) ++ ++/* DVB-S capability bitfields */ ++struct dvbfe_dvbs_info { ++ enum dvbfe_modulation modulation; ++ enum dvbfe_fec fec; ++}; ++ ++/* DSS capability bitfields */ ++struct dvbfe_dss_info { ++ enum dvbfe_modulation modulation; ++ enum dvbfe_fec fec; ++}; ++ ++/* DVB-S2 capability bitfields */ ++struct dvbfe_dvbs2_info { ++ enum dvbfe_modulation modulation; ++ enum dvbfe_fec fec; ++ ++ __u8 pad[32]; ++}; ++ ++/* DVB-C capability bitfields */ ++struct dvbfe_dvbc_info { ++ enum dvbfe_modulation modulation; ++}; ++ ++/* DVB-T capability bitfields */ ++struct dvbfe_dvbt_info { ++ enum dvbfe_modulation modulation; ++ enum dvbfe_stream_priority stream_priority; ++ ++ __u8 pad[32]; ++}; ++ ++/* DVB-H capability bitfields */ ++struct dvbfe_dvbh_info { ++ enum dvbfe_modulation modulation; ++ enum dvbfe_stream_priority stream_priority; ++ ++ __u8 pad[32]; ++}; ++ ++/* ATSC capability bitfields */ ++struct dvbfe_atsc_info { ++ enum dvbfe_modulation modulation; ++ ++ __u8 pad[32]; ++}; ++ ++/* DVB Frontend related Information */ ++struct dvbfe_info { ++ char name[128]; ++ ++ union { ++ struct dvbfe_dvbs_info dvbs; ++ struct dvbfe_dss_info dss; ++ struct dvbfe_dvbs2_info dvbs2; ++ struct dvbfe_dvbc_info dvbc; ++ struct dvbfe_dvbt_info dvbt; ++ struct dvbfe_dvbh_info dvbh; ++ struct dvbfe_atsc_info atsc; ++ ++ __u8 pad[128]; ++ } delsys; ++ ++ __u32 frequency_min; ++ __u32 frequency_max; ++ __u32 frequency_step; ++ __u32 frequency_tolerance; ++ __u32 symbol_rate_min; ++ __u32 symbol_rate_max; ++ __u32 symbol_rate_tolerance; ++ ++ enum fe_spectral_inversion inversion; ++ ++ __u8 pad[128]; ++}; ++#define DVBFE_GET_INFO _IOR('o', 85, struct dvbfe_info) ++ ++enum dvbfe_status { ++ DVBFE_HAS_SIGNAL = (1 << 0), /* something above noise floor */ ++ DVBFE_HAS_CARRIER = (1 << 1), /* Signal found */ ++ DVBFE_HAS_VITERBI = (1 << 2), /* FEC is stable */ ++ DVBFE_HAS_SYNC = (1 << 3), /* SYNC found */ ++ DVBFE_HAS_LOCK = (1 << 4), /* OK .. */ ++ DVBFE_TIMEDOUT = (1 << 5), /* no lock in last ~2 s */ ++ DVBFE_STATUS_DUMMY = (1 << 31) ++}; ++ ++/* DVB Frontend events */ ++struct dvbfe_events { ++ enum dvbfe_status status; ++ ++ __u8 pad[32]; ++}; ++ ++struct dvb_frontend_event { ++ fe_status_t status; ++ struct dvb_frontend_parameters parameters; ++}; ++#define FE_GET_EVENT _IOR('o', 78, struct dvb_frontend_event) ++ ++struct dvbfe_event { ++ struct dvbfe_events fe_events; ++ struct dvbfe_params fe_params; ++}; ++#define DVBFE_GET_EVENT _IOR('o', 86, struct dvbfe_event) ++ ++#endif /*_DVBFRONTEND_H_*/ +diff -Nurd linuxtv-dvb-apps-1.1.1/include/linux/dvb/audio.h dvb-apps/include/linux/dvb/audio.h +--- linuxtv-dvb-apps-1.1.1/include/linux/dvb/audio.h 2004-01-17 17:59:46.000000000 +0100 ++++ dvb-apps/include/linux/dvb/audio.h 1970-01-01 01:00:00.000000000 +0100 +@@ -1,125 +0,0 @@ +-/* +- * audio.h +- * +- * Copyright (C) 2000 Ralph Metzler +- * & Marcus Metzler +- for convergence integrated media GmbH +- * +- * This program is free software; you can redistribute it and/or +- * modify it under the terms of the GNU General Lesser Public License +- * as published by the Free Software Foundation; either version 2.1 +- * 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 Lesser General Public License +- * along with this program; if not, write to the Free Software +- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +- * +- */ +- +-#ifndef _DVBAUDIO_H_ +-#define _DVBAUDIO_H_ +- +-#ifdef __KERNEL__ +-#include +-#else +-#include +-#endif +- +- +-typedef enum { +- AUDIO_SOURCE_DEMUX, /* Select the demux as the main source */ +- AUDIO_SOURCE_MEMORY /* Select internal memory as the main source */ +-} audio_stream_source_t; +- +- +-typedef enum { +- AUDIO_STOPPED, /* Device is stopped */ +- AUDIO_PLAYING, /* Device is currently playing */ +- AUDIO_PAUSED /* Device is paused */ +-} audio_play_state_t; +- +- +-typedef enum { +- AUDIO_STEREO, +- AUDIO_MONO_LEFT, +- AUDIO_MONO_RIGHT +-} audio_channel_select_t; +- +- +-typedef struct audio_mixer { +- unsigned int volume_left; +- unsigned int volume_right; +- // what else do we need? bass, pass-through, ... +-} audio_mixer_t; +- +- +-typedef struct audio_status { +- int AV_sync_state; /* sync audio and video? */ +- int mute_state; /* audio is muted */ +- audio_play_state_t play_state; /* current playback state */ +- audio_stream_source_t stream_source; /* current stream source */ +- audio_channel_select_t channel_select; /* currently selected channel */ +- int bypass_mode; /* pass on audio data to */ +- audio_mixer_t mixer_state; /* current mixer state */ +-} audio_status_t; /* separate decoder hardware */ +- +- +-typedef +-struct audio_karaoke{ /* if Vocal1 or Vocal2 are non-zero, they get mixed */ +- int vocal1; /* into left and right t at 70% each */ +- int vocal2; /* if both, Vocal1 and Vocal2 are non-zero, Vocal1 gets*/ +- int melody; /* mixed into the left channel and */ +- /* Vocal2 into the right channel at 100% each. */ +- /* if Melody is non-zero, the melody channel gets mixed*/ +-} audio_karaoke_t; /* into left and right */ +- +- +-typedef uint16_t audio_attributes_t; +-/* bits: descr. */ +-/* 15-13 audio coding mode (0=ac3, 2=mpeg1, 3=mpeg2ext, 4=LPCM, 6=DTS, */ +-/* 12 multichannel extension */ +-/* 11-10 audio type (0=not spec, 1=language included) */ +-/* 9- 8 audio application mode (0=not spec, 1=karaoke, 2=surround) */ +-/* 7- 6 Quantization / DRC (mpeg audio: 1=DRC exists)(lpcm: 0=16bit, */ +-/* 5- 4 Sample frequency fs (0=48kHz, 1=96kHz) */ +-/* 2- 0 number of audio channels (n+1 channels) */ +- +- +-/* for GET_CAPABILITIES and SET_FORMAT, the latter should only set one bit */ +-#define AUDIO_CAP_DTS 1 +-#define AUDIO_CAP_LPCM 2 +-#define AUDIO_CAP_MP1 4 +-#define AUDIO_CAP_MP2 8 +-#define AUDIO_CAP_MP3 16 +-#define AUDIO_CAP_AAC 32 +-#define AUDIO_CAP_OGG 64 +-#define AUDIO_CAP_SDDS 128 +-#define AUDIO_CAP_AC3 256 +- +-#define AUDIO_STOP _IO('o', 1) +-#define AUDIO_PLAY _IO('o', 2) +-#define AUDIO_PAUSE _IO('o', 3) +-#define AUDIO_CONTINUE _IO('o', 4) +-#define AUDIO_SELECT_SOURCE _IO('o', 5) +-#define AUDIO_SET_MUTE _IO('o', 6) +-#define AUDIO_SET_AV_SYNC _IO('o', 7) +-#define AUDIO_SET_BYPASS_MODE _IO('o', 8) +-#define AUDIO_CHANNEL_SELECT _IO('o', 9) +-#define AUDIO_GET_STATUS _IOR('o', 10, audio_status_t) +- +-#define AUDIO_GET_CAPABILITIES _IOR('o', 11, unsigned int) +-#define AUDIO_CLEAR_BUFFER _IO('o', 12) +-#define AUDIO_SET_ID _IO('o', 13) +-#define AUDIO_SET_MIXER _IOW('o', 14, audio_mixer_t) +-#define AUDIO_SET_STREAMTYPE _IO('o', 15) +-#define AUDIO_SET_EXT_ID _IO('o', 16) +-#define AUDIO_SET_ATTRIBUTES _IOW('o', 17, audio_attributes_t) +-#define AUDIO_SET_KARAOKE _IOW('o', 18, audio_karaoke_t) +- +-#endif /* _DVBAUDIO_H_ */ +- +diff -Nurd linuxtv-dvb-apps-1.1.1/include/linux/dvb/ca.h dvb-apps/include/linux/dvb/ca.h +--- linuxtv-dvb-apps-1.1.1/include/linux/dvb/ca.h 2004-01-17 17:59:46.000000000 +0100 ++++ dvb-apps/include/linux/dvb/ca.h 1970-01-01 01:00:00.000000000 +0100 +@@ -1,91 +0,0 @@ +-/* +- * ca.h +- * +- * Copyright (C) 2000 Ralph Metzler +- * & Marcus Metzler +- for convergence integrated media GmbH +- * +- * This program is free software; you can redistribute it and/or +- * modify it under the terms of the GNU General Lesser Public License +- * as published by the Free Software Foundation; either version 2.1 +- * 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 Lesser General Public License +- * along with this program; if not, write to the Free Software +- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +- * +- */ +- +-#ifndef _DVBCA_H_ +-#define _DVBCA_H_ +- +-/* slot interface types and info */ +- +-typedef struct ca_slot_info { +- int num; /* slot number */ +- +- int type; /* CA interface this slot supports */ +-#define CA_CI 1 /* CI high level interface */ +-#define CA_CI_LINK 2 /* CI link layer level interface */ +-#define CA_CI_PHYS 4 /* CI physical layer level interface */ +-#define CA_DESCR 8 /* built-in descrambler */ +-#define CA_SC 128 /* simple smart card interface */ +- +- unsigned int flags; +-#define CA_CI_MODULE_PRESENT 1 /* module (or card) inserted */ +-#define CA_CI_MODULE_READY 2 +-} ca_slot_info_t; +- +- +-/* descrambler types and info */ +- +-typedef struct ca_descr_info { +- unsigned int num; /* number of available descramblers (keys) */ +- unsigned int type; /* type of supported scrambling system */ +-#define CA_ECD 1 +-#define CA_NDS 2 +-#define CA_DSS 4 +-} ca_descr_info_t; +- +-typedef struct ca_caps { +- unsigned int slot_num; /* total number of CA card and module slots */ +- unsigned int slot_type; /* OR of all supported types */ +- unsigned int descr_num; /* total number of descrambler slots (keys) */ +- unsigned int descr_type; /* OR of all supported types */ +-} ca_caps_t; +- +-/* a message to/from a CI-CAM */ +-typedef struct ca_msg { +- unsigned int index; +- unsigned int type; +- unsigned int length; +- unsigned char msg[256]; +-} ca_msg_t; +- +-typedef struct ca_descr { +- unsigned int index; +- unsigned int parity; /* 0 == even, 1 == odd */ +- unsigned char cw[8]; +-} ca_descr_t; +- +-typedef struct ca_pid { +- unsigned int pid; +- int index; /* -1 == disable*/ +-} ca_pid_t; +- +-#define CA_RESET _IO('o', 128) +-#define CA_GET_CAP _IOR('o', 129, ca_caps_t) +-#define CA_GET_SLOT_INFO _IOR('o', 130, ca_slot_info_t) +-#define CA_GET_DESCR_INFO _IOR('o', 131, ca_descr_info_t) +-#define CA_GET_MSG _IOR('o', 132, ca_msg_t) +-#define CA_SEND_MSG _IOW('o', 133, ca_msg_t) +-#define CA_SET_DESCR _IOW('o', 134, ca_descr_t) +-#define CA_SET_PID _IOW('o', 135, ca_pid_t) +- +-#endif +- +diff -Nurd linuxtv-dvb-apps-1.1.1/include/linux/dvb/dmx.h dvb-apps/include/linux/dvb/dmx.h +--- linuxtv-dvb-apps-1.1.1/include/linux/dvb/dmx.h 2004-01-17 17:59:46.000000000 +0100 ++++ dvb-apps/include/linux/dvb/dmx.h 1970-01-01 01:00:00.000000000 +0100 +@@ -1,181 +0,0 @@ +-/* +- * dmx.h +- * +- * Copyright (C) 2000 Marcus Metzler +- * & Ralph Metzler +- for convergence integrated media GmbH +- * +- * This program is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public License +- * as published by the Free Software Foundation; either version 2.1 +- * 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 Lesser General Public License +- * along with this program; if not, write to the Free Software +- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +- * +- */ +- +-#ifndef _DVBDMX_H_ +-#define _DVBDMX_H_ +- +-#include +-#ifdef __KERNEL__ +-#include +-#else +-#include +-#endif +- +- +-#define DMX_FILTER_SIZE 16 +- +-typedef enum +-{ +- DMX_OUT_DECODER, /* Streaming directly to decoder. */ +- DMX_OUT_TAP, /* Output going to a memory buffer */ +- /* (to be retrieved via the read command).*/ +- DMX_OUT_TS_TAP /* Output multiplexed into a new TS */ +- /* (to be retrieved by reading from the */ +- /* logical DVR device). */ +-} dmx_output_t; +- +- +-typedef enum +-{ +- DMX_IN_FRONTEND, /* Input from a front-end device. */ +- DMX_IN_DVR /* Input from the logical DVR device. */ +-} dmx_input_t; +- +- +-typedef enum +-{ +- DMX_PES_AUDIO0, +- DMX_PES_VIDEO0, +- DMX_PES_TELETEXT0, +- DMX_PES_SUBTITLE0, +- DMX_PES_PCR0, +- +- DMX_PES_AUDIO1, +- DMX_PES_VIDEO1, +- DMX_PES_TELETEXT1, +- DMX_PES_SUBTITLE1, +- DMX_PES_PCR1, +- +- DMX_PES_AUDIO2, +- DMX_PES_VIDEO2, +- DMX_PES_TELETEXT2, +- DMX_PES_SUBTITLE2, +- DMX_PES_PCR2, +- +- DMX_PES_AUDIO3, +- DMX_PES_VIDEO3, +- DMX_PES_TELETEXT3, +- DMX_PES_SUBTITLE3, +- DMX_PES_PCR3, +- +- DMX_PES_OTHER +-} dmx_pes_type_t; +- +-#define DMX_PES_AUDIO DMX_PES_AUDIO0 +-#define DMX_PES_VIDEO DMX_PES_VIDEO0 +-#define DMX_PES_TELETEXT DMX_PES_TELETEXT0 +-#define DMX_PES_SUBTITLE DMX_PES_SUBTITLE0 +-#define DMX_PES_PCR DMX_PES_PCR0 +- +- +-typedef enum +-{ +- DMX_SCRAMBLING_EV, +- DMX_FRONTEND_EV +-} dmx_event_t; +- +- +-typedef enum +-{ +- DMX_SCRAMBLING_OFF, +- DMX_SCRAMBLING_ON +-} dmx_scrambling_status_t; +- +- +-typedef struct dmx_filter +-{ +- __u8 filter[DMX_FILTER_SIZE]; +- __u8 mask[DMX_FILTER_SIZE]; +- __u8 mode[DMX_FILTER_SIZE]; +-} dmx_filter_t; +- +- +-struct dmx_sct_filter_params +-{ +- __u16 pid; +- dmx_filter_t filter; +- __u32 timeout; +- __u32 flags; +-#define DMX_CHECK_CRC 1 +-#define DMX_ONESHOT 2 +-#define DMX_IMMEDIATE_START 4 +-#define DMX_KERNEL_CLIENT 0x8000 +-}; +- +- +-struct dmx_pes_filter_params +-{ +- __u16 pid; +- dmx_input_t input; +- dmx_output_t output; +- dmx_pes_type_t pes_type; +- __u32 flags; +-}; +- +- +-struct dmx_event +-{ +- dmx_event_t event; +- time_t timeStamp; +- union +- { +- dmx_scrambling_status_t scrambling; +- } u; +-}; +- +-typedef struct dmx_caps { +- __u32 caps; +- int num_decoders; +-} dmx_caps_t; +- +-typedef enum { +- DMX_SOURCE_FRONT0 = 0, +- DMX_SOURCE_FRONT1, +- DMX_SOURCE_FRONT2, +- DMX_SOURCE_FRONT3, +- DMX_SOURCE_DVR0 = 16, +- DMX_SOURCE_DVR1, +- DMX_SOURCE_DVR2, +- DMX_SOURCE_DVR3 +-} dmx_source_t; +- +-struct dmx_stc { +- unsigned int num; /* input : which STC? 0..N */ +- unsigned int base; /* output: divisor for stc to get 90 kHz clock */ +- __u64 stc; /* output: stc in 'base'*90 kHz units */ +-}; +- +- +-#define DMX_START _IO('o', 41) +-#define DMX_STOP _IO('o', 42) +-#define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params) +-#define DMX_SET_PES_FILTER _IOW('o', 44, struct dmx_pes_filter_params) +-#define DMX_SET_BUFFER_SIZE _IO('o', 45) +-#define DMX_GET_EVENT _IOR('o', 46, struct dmx_event) +-#define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5]) +-#define DMX_GET_CAPS _IOR('o', 48, dmx_caps_t) +-#define DMX_SET_SOURCE _IOW('o', 49, dmx_source_t) +-#define DMX_GET_STC _IOWR('o', 50, struct dmx_stc) +- +-#endif /*_DVBDMX_H_*/ +- +diff -Nurd linuxtv-dvb-apps-1.1.1/include/linux/dvb/frontend.h dvb-apps/include/linux/dvb/frontend.h +--- linuxtv-dvb-apps-1.1.1/include/linux/dvb/frontend.h 2006-05-18 01:32:38.000000000 +0200 ++++ dvb-apps/include/linux/dvb/frontend.h 1970-01-01 01:00:00.000000000 +0100 +@@ -1,267 +0,0 @@ +-/* +- * frontend.h +- * +- * Copyright (C) 2000 Marcus Metzler +- * Ralph Metzler +- * Holger Waechtler +- * Andre Draszik +- * for convergence integrated media GmbH +- * +- * This program is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public License +- * as published by the Free Software Foundation; either version 2.1 +- * 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 Lesser General Public License +- * along with this program; if not, write to the Free Software +- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +- * +- */ +- +-#ifndef _DVBFRONTEND_H_ +-#define _DVBFRONTEND_H_ +- +-#include +- +- +-typedef enum fe_type { +- FE_QPSK, +- FE_QAM, +- FE_OFDM, +- FE_ATSC +-} fe_type_t; +- +- +-typedef enum fe_caps { +- FE_IS_STUPID = 0, +- FE_CAN_INVERSION_AUTO = 0x1, +- FE_CAN_FEC_1_2 = 0x2, +- FE_CAN_FEC_2_3 = 0x4, +- FE_CAN_FEC_3_4 = 0x8, +- FE_CAN_FEC_4_5 = 0x10, +- FE_CAN_FEC_5_6 = 0x20, +- FE_CAN_FEC_6_7 = 0x40, +- FE_CAN_FEC_7_8 = 0x80, +- FE_CAN_FEC_8_9 = 0x100, +- FE_CAN_FEC_AUTO = 0x200, +- FE_CAN_QPSK = 0x400, +- FE_CAN_QAM_16 = 0x800, +- FE_CAN_QAM_32 = 0x1000, +- FE_CAN_QAM_64 = 0x2000, +- FE_CAN_QAM_128 = 0x4000, +- FE_CAN_QAM_256 = 0x8000, +- FE_CAN_QAM_AUTO = 0x10000, +- FE_CAN_TRANSMISSION_MODE_AUTO = 0x20000, +- FE_CAN_BANDWIDTH_AUTO = 0x40000, +- FE_CAN_GUARD_INTERVAL_AUTO = 0x80000, +- FE_CAN_HIERARCHY_AUTO = 0x100000, +- FE_CAN_8VSB = 0x200000, +- FE_CAN_16VSB = 0x400000, +- FE_NEEDS_BENDING = 0x20000000, // not supported anymore, don't use (frontend requires frequency bending) +- FE_CAN_RECOVER = 0x40000000, // frontend can recover from a cable unplug automatically +- FE_CAN_MUTE_TS = 0x80000000 // frontend can stop spurious TS data output +-} fe_caps_t; +- +- +-struct dvb_frontend_info { +- char name[128]; +- fe_type_t type; +- __u32 frequency_min; +- __u32 frequency_max; +- __u32 frequency_stepsize; +- __u32 frequency_tolerance; +- __u32 symbol_rate_min; +- __u32 symbol_rate_max; +- __u32 symbol_rate_tolerance; /* ppm */ +- __u32 notifier_delay; /* DEPRECATED */ +- fe_caps_t caps; +-}; +- +- +-/** +- * Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for +- * the meaning of this struct... +- */ +-struct dvb_diseqc_master_cmd { +- __u8 msg [6]; /* { framing, address, command, data [3] } */ +- __u8 msg_len; /* valid values are 3...6 */ +-}; +- +- +-struct dvb_diseqc_slave_reply { +- __u8 msg [4]; /* { framing, data [3] } */ +- __u8 msg_len; /* valid values are 0...4, 0 means no msg */ +- int timeout; /* return from ioctl after timeout ms with */ +-}; /* errorcode when no message was received */ +- +- +-typedef enum fe_sec_voltage { +- SEC_VOLTAGE_13, +- SEC_VOLTAGE_18, +- SEC_VOLTAGE_OFF +-} fe_sec_voltage_t; +- +- +-typedef enum fe_sec_tone_mode { +- SEC_TONE_ON, +- SEC_TONE_OFF +-} fe_sec_tone_mode_t; +- +- +-typedef enum fe_sec_mini_cmd { +- SEC_MINI_A, +- SEC_MINI_B +-} fe_sec_mini_cmd_t; +- +- +-typedef enum fe_status { +- FE_HAS_SIGNAL = 0x01, /* found something above the noise level */ +- FE_HAS_CARRIER = 0x02, /* found a DVB signal */ +- FE_HAS_VITERBI = 0x04, /* FEC is stable */ +- FE_HAS_SYNC = 0x08, /* found sync bytes */ +- FE_HAS_LOCK = 0x10, /* everything's working... */ +- FE_TIMEDOUT = 0x20, /* no lock within the last ~2 seconds */ +- FE_REINIT = 0x40 /* frontend was reinitialized, */ +-} fe_status_t; /* application is recommended to reset */ +- /* DiSEqC, tone and parameters */ +- +-typedef enum fe_spectral_inversion { +- INVERSION_OFF, +- INVERSION_ON, +- INVERSION_AUTO +-} fe_spectral_inversion_t; +- +- +-typedef enum fe_code_rate { +- FEC_NONE = 0, +- FEC_1_2, +- FEC_2_3, +- FEC_3_4, +- FEC_4_5, +- FEC_5_6, +- FEC_6_7, +- FEC_7_8, +- FEC_8_9, +- FEC_AUTO +-} fe_code_rate_t; +- +- +-typedef enum fe_modulation { +- QPSK, +- QAM_16, +- QAM_32, +- QAM_64, +- QAM_128, +- QAM_256, +- QAM_AUTO, +- VSB_8, +- VSB_16 +-} fe_modulation_t; +- +-typedef enum fe_transmit_mode { +- TRANSMISSION_MODE_2K, +- TRANSMISSION_MODE_8K, +- TRANSMISSION_MODE_AUTO +-} fe_transmit_mode_t; +- +-typedef enum fe_bandwidth { +- BANDWIDTH_8_MHZ, +- BANDWIDTH_7_MHZ, +- BANDWIDTH_6_MHZ, +- BANDWIDTH_AUTO +-} fe_bandwidth_t; +- +- +-typedef enum fe_guard_interval { +- GUARD_INTERVAL_1_32, +- GUARD_INTERVAL_1_16, +- GUARD_INTERVAL_1_8, +- GUARD_INTERVAL_1_4, +- GUARD_INTERVAL_AUTO +-} fe_guard_interval_t; +- +- +-typedef enum fe_hierarchy { +- HIERARCHY_NONE, +- HIERARCHY_1, +- HIERARCHY_2, +- HIERARCHY_4, +- HIERARCHY_AUTO +-} fe_hierarchy_t; +- +- +-struct dvb_qpsk_parameters { +- __u32 symbol_rate; /* symbol rate in Symbols per second */ +- fe_code_rate_t fec_inner; /* forward error correction (see above) */ +-}; +- +-struct dvb_qam_parameters { +- __u32 symbol_rate; /* symbol rate in Symbols per second */ +- fe_code_rate_t fec_inner; /* forward error correction (see above) */ +- fe_modulation_t modulation; /* modulation type (see above) */ +-}; +- +-struct dvb_vsb_parameters { +- fe_modulation_t modulation; /* modulation type (see above) */ +-}; +- +-struct dvb_ofdm_parameters { +- fe_bandwidth_t bandwidth; +- fe_code_rate_t code_rate_HP; /* high priority stream code rate */ +- fe_code_rate_t code_rate_LP; /* low priority stream code rate */ +- fe_modulation_t constellation; /* modulation type (see above) */ +- fe_transmit_mode_t transmission_mode; +- fe_guard_interval_t guard_interval; +- fe_hierarchy_t hierarchy_information; +-}; +- +- +-struct dvb_frontend_parameters { +- __u32 frequency; /* (absolute) frequency in Hz for QAM/OFDM/ATSC */ +- /* intermediate frequency in kHz for QPSK */ +- fe_spectral_inversion_t inversion; +- union { +- struct dvb_qpsk_parameters qpsk; +- struct dvb_qam_parameters qam; +- struct dvb_ofdm_parameters ofdm; +- struct dvb_vsb_parameters vsb; +- } u; +-}; +- +- +-struct dvb_frontend_event { +- fe_status_t status; +- struct dvb_frontend_parameters parameters; +-}; +- +- +- +-#define FE_GET_INFO _IOR('o', 61, struct dvb_frontend_info) +- +-#define FE_DISEQC_RESET_OVERLOAD _IO('o', 62) +-#define FE_DISEQC_SEND_MASTER_CMD _IOW('o', 63, struct dvb_diseqc_master_cmd) +-#define FE_DISEQC_RECV_SLAVE_REPLY _IOR('o', 64, struct dvb_diseqc_slave_reply) +-#define FE_DISEQC_SEND_BURST _IO('o', 65) /* fe_sec_mini_cmd_t */ +- +-#define FE_SET_TONE _IO('o', 66) /* fe_sec_tone_mode_t */ +-#define FE_SET_VOLTAGE _IO('o', 67) /* fe_sec_voltage_t */ +-#define FE_ENABLE_HIGH_LNB_VOLTAGE _IO('o', 68) /* int */ +- +-#define FE_READ_STATUS _IOR('o', 69, fe_status_t) +-#define FE_READ_BER _IOR('o', 70, __u32) +-#define FE_READ_SIGNAL_STRENGTH _IOR('o', 71, __u16) +-#define FE_READ_SNR _IOR('o', 72, __u16) +-#define FE_READ_UNCORRECTED_BLOCKS _IOR('o', 73, __u32) +- +-#define FE_SET_FRONTEND _IOW('o', 76, struct dvb_frontend_parameters) +-#define FE_GET_FRONTEND _IOR('o', 77, struct dvb_frontend_parameters) +-#define FE_GET_EVENT _IOR('o', 78, struct dvb_frontend_event) +- +-#define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */ +- +-#endif /*_DVBFRONTEND_H_*/ +diff -Nurd linuxtv-dvb-apps-1.1.1/include/linux/dvb/net.h dvb-apps/include/linux/dvb/net.h +--- linuxtv-dvb-apps-1.1.1/include/linux/dvb/net.h 2004-01-17 17:59:46.000000000 +0100 ++++ dvb-apps/include/linux/dvb/net.h 1970-01-01 01:00:00.000000000 +0100 +@@ -1,41 +0,0 @@ +-/* +- * net.h +- * +- * Copyright (C) 2000 Marcus Metzler +- * & Ralph Metzler +- for convergence integrated media GmbH +- * +- * This program is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public License +- * as published by the Free Software Foundation; either version 2.1 +- * 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 Lesser General Public License +- * along with this program; if not, write to the Free Software +- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +- * +- */ +- +-#ifndef _DVBNET_H_ +-#define _DVBNET_H_ +- +-#include +- +- +-struct dvb_net_if { +- __u16 pid; +- __u16 if_num; +-}; +- +- +-#define NET_ADD_IF _IOWR('o', 52, struct dvb_net_if) +-#define NET_REMOVE_IF _IO('o', 53) +-#define NET_GET_IF _IOWR('o', 54, struct dvb_net_if) +- +-#endif /*_DVBNET_H_*/ +- +diff -Nurd linuxtv-dvb-apps-1.1.1/include/linux/dvb/osd.h dvb-apps/include/linux/dvb/osd.h +--- linuxtv-dvb-apps-1.1.1/include/linux/dvb/osd.h 2004-01-17 17:59:46.000000000 +0100 ++++ dvb-apps/include/linux/dvb/osd.h 1970-01-01 01:00:00.000000000 +0100 +@@ -1,111 +0,0 @@ +-/* +- * osd.h +- * +- * Copyright (C) 2001 Ralph Metzler +- * & Marcus Metzler +- for convergence integrated media GmbH +- * +- * This program is free software; you can redistribute it and/or +- * modify it under the terms of the GNU General Lesser Public License +- * as published by the Free Software Foundation; either version 2.1 +- * 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 Lesser General Public License +- * along with this program; if not, write to the Free Software +- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +- * +- */ +- +-#ifndef _DVBOSD_H_ +-#define _DVBOSD_H_ +- +-typedef enum { +- // All functions return -2 on "not open" +- OSD_Close=1, // () +- // Disables OSD and releases the buffers +- // returns 0 on success +- OSD_Open, // (x0,y0,x1,y1,BitPerPixel[2/4/8](color&0x0F),mix[0..15](color&0xF0)) +- // Opens OSD with this size and bit depth +- // returns 0 on success, -1 on DRAM allocation error, -2 on "already open" +- OSD_Show, // () +- // enables OSD mode +- // returns 0 on success +- OSD_Hide, // () +- // disables OSD mode +- // returns 0 on success +- OSD_Clear, // () +- // Sets all pixel to color 0 +- // returns 0 on success +- OSD_Fill, // (color) +- // Sets all pixel to color +- // returns 0 on success +- OSD_SetColor, // (color,R{x0},G{y0},B{x1},opacity{y1}) +- // set palette entry to , and apply +- // R,G,B: 0..255 +- // R=Red, G=Green, B=Blue +- // opacity=0: pixel opacity 0% (only video pixel shows) +- // opacity=1..254: pixel opacity as specified in header +- // opacity=255: pixel opacity 100% (only OSD pixel shows) +- // returns 0 on success, -1 on error +- OSD_SetPalette, // (firstcolor{color},lastcolor{x0},data) +- // Set a number of entries in the palette +- // sets the entries "firstcolor" through "lastcolor" from the array "data" +- // data has 4 byte for each color: +- // R,G,B, and a opacity value: 0->transparent, 1..254->mix, 255->pixel +- OSD_SetTrans, // (transparency{color}) +- // Sets transparency of mixed pixel (0..15) +- // returns 0 on success +- OSD_SetPixel, // (x0,y0,color) +- // sets pixel , to color number +- // returns 0 on success, -1 on error +- OSD_GetPixel, // (x0,y0) +- // returns color number of pixel ,, or -1 +- OSD_SetRow, // (x0,y0,x1,data) +- // fills pixels x0,y through x1,y with the content of data[] +- // returns 0 on success, -1 on clipping all pixel (no pixel drawn) +- OSD_SetBlock, // (x0,y0,x1,y1,increment{color},data) +- // fills pixels x0,y0 through x1,y1 with the content of data[] +- // inc contains the width of one line in the data block, +- // inc<=0 uses blockwidth as linewidth +- // returns 0 on success, -1 on clipping all pixel +- OSD_FillRow, // (x0,y0,x1,color) +- // fills pixels x0,y through x1,y with the color +- // returns 0 on success, -1 on clipping all pixel +- OSD_FillBlock, // (x0,y0,x1,y1,color) +- // fills pixels x0,y0 through x1,y1 with the color +- // returns 0 on success, -1 on clipping all pixel +- OSD_Line, // (x0,y0,x1,y1,color) +- // draw a line from x0,y0 to x1,y1 with the color +- // returns 0 on success +- OSD_Query, // (x0,y0,x1,y1,xasp{color}}), yasp=11 +- // fills parameters with the picture dimensions and the pixel aspect ratio +- // returns 0 on success +- OSD_Test, // () +- // draws a test picture. for debugging purposes only +- // returns 0 on success +-// TODO: remove "test" in final version +- OSD_Text, // (x0,y0,size,color,text) +- OSD_SetWindow, // (x0) set window with number 0 +- * for convergence integrated media GmbH +- * +- * This program is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public License +- * as published by the Free Software Foundation; either version 2.1 +- * 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 Lesser General Public License +- * along with this program; if not, write to the Free Software +- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +- * +- */ +- +-#ifndef _DVBVERSION_H_ +-#define _DVBVERSION_H_ +- +-#define DVB_API_VERSION 3 +- +-#endif /*_DVBVERSION_H_*/ +- +diff -Nurd linuxtv-dvb-apps-1.1.1/include/linux/dvb/video.h dvb-apps/include/linux/dvb/video.h +--- linuxtv-dvb-apps-1.1.1/include/linux/dvb/video.h 2004-01-17 17:59:46.000000000 +0100 ++++ dvb-apps/include/linux/dvb/video.h 1970-01-01 01:00:00.000000000 +0100 +@@ -1,199 +0,0 @@ +-/* +- * video.h +- * +- * Copyright (C) 2000 Marcus Metzler +- * & Ralph Metzler +- for convergence integrated media GmbH +- * +- * This program is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public License +- * as published by the Free Software Foundation; either version 2.1 +- * 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 Lesser General Public License +- * along with this program; if not, write to the Free Software +- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +- * +- */ +- +-#ifndef _DVBVIDEO_H_ +-#define _DVBVIDEO_H_ +- +-#ifdef __KERNEL__ +-#include +-#else +-#include +-#include +-#endif +- +- +-typedef enum { +- VIDEO_FORMAT_4_3, /* Select 4:3 format */ +- VIDEO_FORMAT_16_9, /* Select 16:9 format. */ +- VIDEO_FORMAT_221_1 /* 2.21:1 */ +-} video_format_t; +- +- +-typedef enum { +- VIDEO_SYSTEM_PAL, +- VIDEO_SYSTEM_NTSC, +- VIDEO_SYSTEM_PALN, +- VIDEO_SYSTEM_PALNc, +- VIDEO_SYSTEM_PALM, +- VIDEO_SYSTEM_NTSC60, +- VIDEO_SYSTEM_PAL60, +- VIDEO_SYSTEM_PALM60 +-} video_system_t; +- +- +-typedef enum { +- VIDEO_PAN_SCAN, /* use pan and scan format */ +- VIDEO_LETTER_BOX, /* use letterbox format */ +- VIDEO_CENTER_CUT_OUT /* use center cut out format */ +-} video_displayformat_t; +- +-typedef struct { +- int w; +- int h; +- video_format_t aspect_ratio; +-} video_size_t; +- +-typedef enum { +- VIDEO_SOURCE_DEMUX, /* Select the demux as the main source */ +- VIDEO_SOURCE_MEMORY /* If this source is selected, the stream +- comes from the user through the write +- system call */ +-} video_stream_source_t; +- +- +-typedef enum { +- VIDEO_STOPPED, /* Video is stopped */ +- VIDEO_PLAYING, /* Video is currently playing */ +- VIDEO_FREEZED /* Video is freezed */ +-} video_play_state_t; +- +- +-struct video_event { +- int32_t type; +-#define VIDEO_EVENT_SIZE_CHANGED 1 +- time_t timestamp; +- union { +- video_size_t size; +- } u; +-}; +- +- +-struct video_status { +- int video_blank; /* blank video on freeze? */ +- video_play_state_t play_state; /* current state of playback */ +- video_stream_source_t stream_source; /* current source (demux/memory) */ +- video_format_t video_format; /* current aspect ratio of stream*/ +- video_displayformat_t display_format;/* selected cropping mode */ +-}; +- +- +-struct video_still_picture { +- char *iFrame; /* pointer to a single iframe in memory */ +- int32_t size; +-}; +- +- +-typedef +-struct video_highlight { +- int active; /* 1=show highlight, 0=hide highlight */ +- uint8_t contrast1; /* 7- 4 Pattern pixel contrast */ +- /* 3- 0 Background pixel contrast */ +- uint8_t contrast2; /* 7- 4 Emphasis pixel-2 contrast */ +- /* 3- 0 Emphasis pixel-1 contrast */ +- uint8_t color1; /* 7- 4 Pattern pixel color */ +- /* 3- 0 Background pixel color */ +- uint8_t color2; /* 7- 4 Emphasis pixel-2 color */ +- /* 3- 0 Emphasis pixel-1 color */ +- uint32_t ypos; /* 23-22 auto action mode */ +- /* 21-12 start y */ +- /* 9- 0 end y */ +- uint32_t xpos; /* 23-22 button color number */ +- /* 21-12 start x */ +- /* 9- 0 end x */ +-} video_highlight_t; +- +- +-typedef struct video_spu { +- int active; +- int stream_id; +-} video_spu_t; +- +- +-typedef struct video_spu_palette { /* SPU Palette information */ +- int length; +- uint8_t *palette; +-} video_spu_palette_t; +- +- +-typedef struct video_navi_pack { +- int length; /* 0 ... 1024 */ +- uint8_t data[1024]; +-} video_navi_pack_t; +- +- +-typedef uint16_t video_attributes_t; +-/* bits: descr. */ +-/* 15-14 Video compression mode (0=MPEG-1, 1=MPEG-2) */ +-/* 13-12 TV system (0=525/60, 1=625/50) */ +-/* 11-10 Aspect ratio (0=4:3, 3=16:9) */ +-/* 9- 8 permitted display mode on 4:3 monitor (0=both, 1=only pan-sca */ +-/* 7 line 21-1 data present in GOP (1=yes, 0=no) */ +-/* 6 line 21-2 data present in GOP (1=yes, 0=no) */ +-/* 5- 3 source resolution (0=720x480/576, 1=704x480/576, 2=352x480/57 */ +-/* 2 source letterboxed (1=yes, 0=no) */ +-/* 0 film/camera mode (0=camera, 1=film (625/50 only)) */ +- +- +-/* bit definitions for capabilities: */ +-/* can the hardware decode MPEG1 and/or MPEG2? */ +-#define VIDEO_CAP_MPEG1 1 +-#define VIDEO_CAP_MPEG2 2 +-/* can you send a system and/or program stream to video device? +- (you still have to open the video and the audio device but only +- send the stream to the video device) */ +-#define VIDEO_CAP_SYS 4 +-#define VIDEO_CAP_PROG 8 +-/* can the driver also handle SPU, NAVI and CSS encoded data? +- (CSS API is not present yet) */ +-#define VIDEO_CAP_SPU 16 +-#define VIDEO_CAP_NAVI 32 +-#define VIDEO_CAP_CSS 64 +- +- +-#define VIDEO_STOP _IO('o', 21) +-#define VIDEO_PLAY _IO('o', 22) +-#define VIDEO_FREEZE _IO('o', 23) +-#define VIDEO_CONTINUE _IO('o', 24) +-#define VIDEO_SELECT_SOURCE _IO('o', 25) +-#define VIDEO_SET_BLANK _IO('o', 26) +-#define VIDEO_GET_STATUS _IOR('o', 27, struct video_status) +-#define VIDEO_GET_EVENT _IOR('o', 28, struct video_event) +-#define VIDEO_SET_DISPLAY_FORMAT _IO('o', 29) +-#define VIDEO_STILLPICTURE _IOW('o', 30, struct video_still_picture) +-#define VIDEO_FAST_FORWARD _IO('o', 31) +-#define VIDEO_SLOWMOTION _IO('o', 32) +-#define VIDEO_GET_CAPABILITIES _IOR('o', 33, unsigned int) +-#define VIDEO_CLEAR_BUFFER _IO('o', 34) +-#define VIDEO_SET_ID _IO('o', 35) +-#define VIDEO_SET_STREAMTYPE _IO('o', 36) +-#define VIDEO_SET_FORMAT _IO('o', 37) +-#define VIDEO_SET_SYSTEM _IO('o', 38) +-#define VIDEO_SET_HIGHLIGHT _IOW('o', 39, video_highlight_t) +-#define VIDEO_SET_SPU _IOW('o', 50, video_spu_t) +-#define VIDEO_SET_SPU_PALETTE _IOW('o', 51, video_spu_palette_t) +-#define VIDEO_GET_NAVI _IOR('o', 52, video_navi_pack_t) +-#define VIDEO_SET_ATTRIBUTES _IO('o', 53) +-#define VIDEO_GET_SIZE _IOR('o', 55, video_size_t) +- +-#endif /*_DVBVIDEO_H_*/ +- +diff -Nurd linuxtv-dvb-apps-1.1.1/include/net.h dvb-apps/include/net.h +--- linuxtv-dvb-apps-1.1.1/include/net.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/include/net.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,53 @@ ++/* ++ * net.h ++ * ++ * Copyright (C) 2000 Marcus Metzler ++ * & Ralph Metzler ++ * for convergence integrated media GmbH ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public License ++ * as published by the Free Software Foundation; either version 2.1 ++ * 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 Lesser General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ * ++ */ ++ ++#ifndef _DVBNET_H_ ++#define _DVBNET_H_ ++ ++#include ++ ++ ++struct dvb_net_if { ++ __u16 pid; ++ __u16 if_num; ++ __u8 feedtype; ++#define DVB_NET_FEEDTYPE_MPE 0 /* multi protocol encapsulation */ ++#define DVB_NET_FEEDTYPE_ULE 1 /* ultra lightweight encapsulation */ ++}; ++ ++ ++#define NET_ADD_IF _IOWR('o', 52, struct dvb_net_if) ++#define NET_REMOVE_IF _IO('o', 53) ++#define NET_GET_IF _IOWR('o', 54, struct dvb_net_if) ++ ++ ++/* binary compatibility cruft: */ ++struct __dvb_net_if_old { ++ __u16 pid; ++ __u16 if_num; ++}; ++#define __NET_ADD_IF_OLD _IOWR('o', 52, struct __dvb_net_if_old) ++#define __NET_GET_IF_OLD _IOWR('o', 54, struct __dvb_net_if_old) ++ ++ ++#endif /*_DVBNET_H_*/ +diff -Nurd linuxtv-dvb-apps-1.1.1/include/osd.h dvb-apps/include/osd.h +--- linuxtv-dvb-apps-1.1.1/include/osd.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/include/osd.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,142 @@ ++/* ++ * osd.h ++ * ++ * Copyright (C) 2001 Ralph Metzler ++ * & Marcus Metzler ++ * for convergence integrated media GmbH ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Lesser Public License ++ * as published by the Free Software Foundation; either version 2.1 ++ * 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 Lesser General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ * ++ */ ++ ++#ifndef _DVBOSD_H_ ++#define _DVBOSD_H_ ++ ++typedef enum { ++ // All functions return -2 on "not open" ++ OSD_Close=1, // () ++ // Disables OSD and releases the buffers ++ // returns 0 on success ++ OSD_Open, // (x0,y0,x1,y1,BitPerPixel[2/4/8](color&0x0F),mix[0..15](color&0xF0)) ++ // Opens OSD with this size and bit depth ++ // returns 0 on success, -1 on DRAM allocation error, -2 on "already open" ++ OSD_Show, // () ++ // enables OSD mode ++ // returns 0 on success ++ OSD_Hide, // () ++ // disables OSD mode ++ // returns 0 on success ++ OSD_Clear, // () ++ // Sets all pixel to color 0 ++ // returns 0 on success ++ OSD_Fill, // (color) ++ // Sets all pixel to color ++ // returns 0 on success ++ OSD_SetColor, // (color,R{x0},G{y0},B{x1},opacity{y1}) ++ // set palette entry to , and apply ++ // R,G,B: 0..255 ++ // R=Red, G=Green, B=Blue ++ // opacity=0: pixel opacity 0% (only video pixel shows) ++ // opacity=1..254: pixel opacity as specified in header ++ // opacity=255: pixel opacity 100% (only OSD pixel shows) ++ // returns 0 on success, -1 on error ++ OSD_SetPalette, // (firstcolor{color},lastcolor{x0},data) ++ // Set a number of entries in the palette ++ // sets the entries "firstcolor" through "lastcolor" from the array "data" ++ // data has 4 byte for each color: ++ // R,G,B, and a opacity value: 0->transparent, 1..254->mix, 255->pixel ++ OSD_SetTrans, // (transparency{color}) ++ // Sets transparency of mixed pixel (0..15) ++ // returns 0 on success ++ OSD_SetPixel, // (x0,y0,color) ++ // sets pixel , to color number ++ // returns 0 on success, -1 on error ++ OSD_GetPixel, // (x0,y0) ++ // returns color number of pixel ,, or -1 ++ OSD_SetRow, // (x0,y0,x1,data) ++ // fills pixels x0,y through x1,y with the content of data[] ++ // returns 0 on success, -1 on clipping all pixel (no pixel drawn) ++ OSD_SetBlock, // (x0,y0,x1,y1,increment{color},data) ++ // fills pixels x0,y0 through x1,y1 with the content of data[] ++ // inc contains the width of one line in the data block, ++ // inc<=0 uses blockwidth as linewidth ++ // returns 0 on success, -1 on clipping all pixel ++ OSD_FillRow, // (x0,y0,x1,color) ++ // fills pixels x0,y through x1,y with the color ++ // returns 0 on success, -1 on clipping all pixel ++ OSD_FillBlock, // (x0,y0,x1,y1,color) ++ // fills pixels x0,y0 through x1,y1 with the color ++ // returns 0 on success, -1 on clipping all pixel ++ OSD_Line, // (x0,y0,x1,y1,color) ++ // draw a line from x0,y0 to x1,y1 with the color ++ // returns 0 on success ++ OSD_Query, // (x0,y0,x1,y1,xasp{color}}), yasp=11 ++ // fills parameters with the picture dimensions and the pixel aspect ratio ++ // returns 0 on success ++ OSD_Test, // () ++ // draws a test picture. for debugging purposes only ++ // returns 0 on success ++// TODO: remove "test" in final version ++ OSD_Text, // (x0,y0,size,color,text) ++ OSD_SetWindow, // (x0) set window with number 0 ++ * for convergence integrated media GmbH ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public License ++ * as published by the Free Software Foundation; either version 2.1 ++ * 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 Lesser General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ * ++ */ ++ ++#ifndef _DVBVERSION_H_ ++#define _DVBVERSION_H_ ++ ++#define DVB_API_VERSION 3 ++#define DVB_API_VERSION_MINOR 3 ++ ++#endif /*_DVBVERSION_H_*/ +diff -Nurd linuxtv-dvb-apps-1.1.1/include/video.h dvb-apps/include/video.h +--- linuxtv-dvb-apps-1.1.1/include/video.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/include/video.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,277 @@ ++/* ++ * video.h ++ * ++ * Copyright (C) 2000 Marcus Metzler ++ * & Ralph Metzler ++ * for convergence integrated media GmbH ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public License ++ * as published by the Free Software Foundation; either version 2.1 ++ * 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 Lesser General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ * ++ */ ++ ++#ifndef _DVBVIDEO_H_ ++#define _DVBVIDEO_H_ ++ ++#ifdef __KERNEL__ ++#include ++#else ++#include ++#include ++#include ++#endif ++ ++ ++typedef enum { ++ VIDEO_FORMAT_4_3, /* Select 4:3 format */ ++ VIDEO_FORMAT_16_9, /* Select 16:9 format. */ ++ VIDEO_FORMAT_221_1 /* 2.21:1 */ ++} video_format_t; ++ ++ ++typedef enum { ++ VIDEO_SYSTEM_PAL, ++ VIDEO_SYSTEM_NTSC, ++ VIDEO_SYSTEM_PALN, ++ VIDEO_SYSTEM_PALNc, ++ VIDEO_SYSTEM_PALM, ++ VIDEO_SYSTEM_NTSC60, ++ VIDEO_SYSTEM_PAL60, ++ VIDEO_SYSTEM_PALM60 ++} video_system_t; ++ ++ ++typedef enum { ++ VIDEO_PAN_SCAN, /* use pan and scan format */ ++ VIDEO_LETTER_BOX, /* use letterbox format */ ++ VIDEO_CENTER_CUT_OUT /* use center cut out format */ ++} video_displayformat_t; ++ ++typedef struct { ++ int w; ++ int h; ++ video_format_t aspect_ratio; ++} video_size_t; ++ ++typedef enum { ++ VIDEO_SOURCE_DEMUX, /* Select the demux as the main source */ ++ VIDEO_SOURCE_MEMORY /* If this source is selected, the stream ++ comes from the user through the write ++ system call */ ++} video_stream_source_t; ++ ++ ++typedef enum { ++ VIDEO_STOPPED, /* Video is stopped */ ++ VIDEO_PLAYING, /* Video is currently playing */ ++ VIDEO_FREEZED /* Video is freezed */ ++} video_play_state_t; ++ ++ ++/* Decoder commands */ ++#define VIDEO_CMD_PLAY (0) ++#define VIDEO_CMD_STOP (1) ++#define VIDEO_CMD_FREEZE (2) ++#define VIDEO_CMD_CONTINUE (3) ++ ++/* Flags for VIDEO_CMD_FREEZE */ ++#define VIDEO_CMD_FREEZE_TO_BLACK (1 << 0) ++ ++/* Flags for VIDEO_CMD_STOP */ ++#define VIDEO_CMD_STOP_TO_BLACK (1 << 0) ++#define VIDEO_CMD_STOP_IMMEDIATELY (1 << 1) ++ ++/* Play input formats: */ ++/* The decoder has no special format requirements */ ++#define VIDEO_PLAY_FMT_NONE (0) ++/* The decoder requires full GOPs */ ++#define VIDEO_PLAY_FMT_GOP (1) ++ ++/* The structure must be zeroed before use by the application ++ This ensures it can be extended safely in the future. */ ++struct video_command { ++ __u32 cmd; ++ __u32 flags; ++ union { ++ struct { ++ __u64 pts; ++ } stop; ++ ++ struct { ++ /* 0 or 1000 specifies normal speed, ++ 1 specifies forward single stepping, ++ -1 specifies backward single stepping, ++ >1: playback at speed/1000 of the normal speed, ++ <-1: reverse playback at (-speed/1000) of the normal speed. */ ++ __s32 speed; ++ __u32 format; ++ } play; ++ ++ struct { ++ __u32 data[16]; ++ } raw; ++ }; ++}; ++ ++/* FIELD_UNKNOWN can be used if the hardware does not know whether ++ the Vsync is for an odd, even or progressive (i.e. non-interlaced) ++ field. */ ++#define VIDEO_VSYNC_FIELD_UNKNOWN (0) ++#define VIDEO_VSYNC_FIELD_ODD (1) ++#define VIDEO_VSYNC_FIELD_EVEN (2) ++#define VIDEO_VSYNC_FIELD_PROGRESSIVE (3) ++ ++struct video_event { ++ int32_t type; ++#define VIDEO_EVENT_SIZE_CHANGED 1 ++#define VIDEO_EVENT_FRAME_RATE_CHANGED 2 ++#define VIDEO_EVENT_DECODER_STOPPED 3 ++#define VIDEO_EVENT_VSYNC 4 ++ time_t timestamp; ++ union { ++ video_size_t size; ++ unsigned int frame_rate; /* in frames per 1000sec */ ++ unsigned char vsync_field; /* unknown/odd/even/progressive */ ++ } u; ++}; ++ ++ ++struct video_status { ++ int video_blank; /* blank video on freeze? */ ++ video_play_state_t play_state; /* current state of playback */ ++ video_stream_source_t stream_source; /* current source (demux/memory) */ ++ video_format_t video_format; /* current aspect ratio of stream*/ ++ video_displayformat_t display_format;/* selected cropping mode */ ++}; ++ ++ ++struct video_still_picture { ++ char *iFrame; /* pointer to a single iframe in memory */ ++ int32_t size; ++}; ++ ++ ++typedef ++struct video_highlight { ++ int active; /* 1=show highlight, 0=hide highlight */ ++ uint8_t contrast1; /* 7- 4 Pattern pixel contrast */ ++ /* 3- 0 Background pixel contrast */ ++ uint8_t contrast2; /* 7- 4 Emphasis pixel-2 contrast */ ++ /* 3- 0 Emphasis pixel-1 contrast */ ++ uint8_t color1; /* 7- 4 Pattern pixel color */ ++ /* 3- 0 Background pixel color */ ++ uint8_t color2; /* 7- 4 Emphasis pixel-2 color */ ++ /* 3- 0 Emphasis pixel-1 color */ ++ uint32_t ypos; /* 23-22 auto action mode */ ++ /* 21-12 start y */ ++ /* 9- 0 end y */ ++ uint32_t xpos; /* 23-22 button color number */ ++ /* 21-12 start x */ ++ /* 9- 0 end x */ ++} video_highlight_t; ++ ++ ++typedef struct video_spu { ++ int active; ++ int stream_id; ++} video_spu_t; ++ ++ ++typedef struct video_spu_palette { /* SPU Palette information */ ++ int length; ++ uint8_t *palette; ++} video_spu_palette_t; ++ ++ ++typedef struct video_navi_pack { ++ int length; /* 0 ... 1024 */ ++ uint8_t data[1024]; ++} video_navi_pack_t; ++ ++ ++typedef uint16_t video_attributes_t; ++/* bits: descr. */ ++/* 15-14 Video compression mode (0=MPEG-1, 1=MPEG-2) */ ++/* 13-12 TV system (0=525/60, 1=625/50) */ ++/* 11-10 Aspect ratio (0=4:3, 3=16:9) */ ++/* 9- 8 permitted display mode on 4:3 monitor (0=both, 1=only pan-sca */ ++/* 7 line 21-1 data present in GOP (1=yes, 0=no) */ ++/* 6 line 21-2 data present in GOP (1=yes, 0=no) */ ++/* 5- 3 source resolution (0=720x480/576, 1=704x480/576, 2=352x480/57 */ ++/* 2 source letterboxed (1=yes, 0=no) */ ++/* 0 film/camera mode (0=camera, 1=film (625/50 only)) */ ++ ++ ++/* bit definitions for capabilities: */ ++/* can the hardware decode MPEG1 and/or MPEG2? */ ++#define VIDEO_CAP_MPEG1 1 ++#define VIDEO_CAP_MPEG2 2 ++/* can you send a system and/or program stream to video device? ++ (you still have to open the video and the audio device but only ++ send the stream to the video device) */ ++#define VIDEO_CAP_SYS 4 ++#define VIDEO_CAP_PROG 8 ++/* can the driver also handle SPU, NAVI and CSS encoded data? ++ (CSS API is not present yet) */ ++#define VIDEO_CAP_SPU 16 ++#define VIDEO_CAP_NAVI 32 ++#define VIDEO_CAP_CSS 64 ++ ++ ++#define VIDEO_STOP _IO('o', 21) ++#define VIDEO_PLAY _IO('o', 22) ++#define VIDEO_FREEZE _IO('o', 23) ++#define VIDEO_CONTINUE _IO('o', 24) ++#define VIDEO_SELECT_SOURCE _IO('o', 25) ++#define VIDEO_SET_BLANK _IO('o', 26) ++#define VIDEO_GET_STATUS _IOR('o', 27, struct video_status) ++#define VIDEO_GET_EVENT _IOR('o', 28, struct video_event) ++#define VIDEO_SET_DISPLAY_FORMAT _IO('o', 29) ++#define VIDEO_STILLPICTURE _IOW('o', 30, struct video_still_picture) ++#define VIDEO_FAST_FORWARD _IO('o', 31) ++#define VIDEO_SLOWMOTION _IO('o', 32) ++#define VIDEO_GET_CAPABILITIES _IOR('o', 33, unsigned int) ++#define VIDEO_CLEAR_BUFFER _IO('o', 34) ++#define VIDEO_SET_ID _IO('o', 35) ++#define VIDEO_SET_STREAMTYPE _IO('o', 36) ++#define VIDEO_SET_FORMAT _IO('o', 37) ++#define VIDEO_SET_SYSTEM _IO('o', 38) ++#define VIDEO_SET_HIGHLIGHT _IOW('o', 39, video_highlight_t) ++#define VIDEO_SET_SPU _IOW('o', 50, video_spu_t) ++#define VIDEO_SET_SPU_PALETTE _IOW('o', 51, video_spu_palette_t) ++#define VIDEO_GET_NAVI _IOR('o', 52, video_navi_pack_t) ++#define VIDEO_SET_ATTRIBUTES _IO('o', 53) ++#define VIDEO_GET_SIZE _IOR('o', 55, video_size_t) ++#define VIDEO_GET_FRAME_RATE _IOR('o', 56, unsigned int) ++ ++/** ++ * VIDEO_GET_PTS ++ * ++ * Read the 33 bit presentation time stamp as defined ++ * in ITU T-REC-H.222.0 / ISO/IEC 13818-1. ++ * ++ * The PTS should belong to the currently played ++ * frame if possible, but may also be a value close to it ++ * like the PTS of the last decoded frame or the last PTS ++ * extracted by the PES parser. ++ */ ++#define VIDEO_GET_PTS _IOR('o', 57, __u64) ++ ++/* Read the number of displayed frames since the decoder was started */ ++#define VIDEO_GET_FRAME_COUNT _IOR('o', 58, __u64) ++ ++#define VIDEO_COMMAND _IOWR('o', 59, struct video_command) ++#define VIDEO_TRY_COMMAND _IOWR('o', 60, struct video_command) ++ ++#endif /*_DVBVIDEO_H_*/ +diff -Nurd linuxtv-dvb-apps-1.1.1/INSTALL dvb-apps/INSTALL +--- linuxtv-dvb-apps-1.1.1/INSTALL 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/INSTALL 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,26 @@ ++Requirements: ++ ++For ttusb_dec_reset, you will need libusb. ++ ++Building: ++ ++Simply type ++$ make ++ ++Build options ++ static=1 - Build all applications statically. ++ V=1 - Verbose output during build. ++ ttusb_dec_reset=1 - Build the optional ttusb_dec_reset. ++ ++Installing: ++ ++Install libraries and utils to /usr/[bin,include,lib,share] ++$ make install ++ ++Install options ++ prefix=<...> - basic installation dir [default: /usr] ++ bindir=<...> - installation dir for applications [default: $(prefix)/bin] ++ includedir=<...> - installation dir for include files [default: $(prefix)/include] ++ libdir=<...> - installation dir for applications [default: $(prefix)/lib] ++ sharedir=<...> - installation dir for shared data [default: $(prefix)/share] ++ DESTDIR=<...> - prefix for all files, useful for packaging +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbaudio.c dvb-apps/lib/libdvbapi/dvbaudio.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbaudio.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbapi/dvbaudio.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,50 @@ ++/* ++ * libdvbnet - a DVB network support library ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "dvbaudio.h" ++ ++int dvbaudio_open(int adapter, int audiodeviceid) ++{ ++ char filename[PATH_MAX+1]; ++ int fd; ++ ++ sprintf(filename, "/dev/dvb/adapter%i/audio%i", adapter, audiodeviceid); ++ if ((fd = open(filename, O_RDWR)) < 0) { ++ // if that failed, try a flat /dev structure ++ sprintf(filename, "/dev/dvb%i.audio%i", adapter, audiodeviceid); ++ fd = open(filename, O_RDWR); ++ } ++ ++ return fd; ++} ++ ++int dvbaudio_set_bypass(int fd, int bypass) ++{ ++ return ioctl(fd, AUDIO_SET_BYPASS_MODE, bypass); ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbaudio.h dvb-apps/lib/libdvbapi/dvbaudio.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbaudio.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbapi/dvbaudio.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,55 @@ ++/* ++ * libdvbnet - a DVB network support library ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef LIBDVBAUDIO_H ++#define LIBDVBAUDIO_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * Open a DVB audio device. ++ * ++ * @param adapter DVB adapter ID. ++ * @param audiodeviceid Id of audio device of that adapter to open. ++ * @return A unix file descriptor on success, or -1 on failure. ++ */ ++extern int dvbaudio_open(int adapter, int audiodeviceid); ++ ++/** ++ * Control audio bypass - i.e. output decoded audio, or the raw bitstream (e.g. AC3). ++ * ++ * @param fd Audio device opened with dvbaudio_open(). ++ * @param bypass 1=> enable bypass, 0=> disable. ++ * @return 0 on success, nonzero on failure. ++ */ ++extern int dvbaudio_set_bypass(int fd, int bypass); ++ ++// FIXME: this is a stub library ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif // LIBDVBAUDIO_H +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbca.c dvb-apps/lib/libdvbapi/dvbca.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbca.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbapi/dvbca.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,159 @@ ++/* ++ * libdvbca - interface onto raw CA devices ++ * ++ * Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "dvbca.h" ++ ++ ++int dvbca_open(int adapter, int cadevice) ++{ ++ char filename[PATH_MAX+1]; ++ int fd; ++ ++ sprintf(filename, "/dev/dvb/adapter%i/ca%i", adapter, cadevice); ++ if ((fd = open(filename, O_RDWR)) < 0) { ++ // if that failed, try a flat /dev structure ++ sprintf(filename, "/dev/dvb%i.ca%i", adapter, cadevice); ++ fd = open(filename, O_RDWR); ++ } ++ ++ return fd; ++} ++ ++int dvbca_reset(int fd, uint8_t slot) ++{ ++ return ioctl(fd, CA_RESET, (1 << slot)); ++} ++ ++int dvbca_get_interface_type(int fd, uint8_t slot) ++{ ++ ca_slot_info_t info; ++ ++ info.num = slot; ++ if (ioctl(fd, CA_GET_SLOT_INFO, &info)) ++ return -1; ++ ++ if (info.type & CA_CI_LINK) ++ return DVBCA_INTERFACE_LINK; ++ if (info.type & CA_CI) ++ return DVBCA_INTERFACE_HLCI; ++ ++ return -1; ++} ++ ++int dvbca_get_cam_state(int fd, uint8_t slot) ++{ ++ ca_slot_info_t info; ++ ++ info.num = slot; ++ if (ioctl(fd, CA_GET_SLOT_INFO, &info)) ++ return -1; ++ ++ if (info.flags == 0) ++ return DVBCA_CAMSTATE_MISSING; ++ if (info.flags & CA_CI_MODULE_READY) ++ return DVBCA_CAMSTATE_READY; ++ if (info.flags & CA_CI_MODULE_PRESENT) ++ return DVBCA_CAMSTATE_INITIALISING; ++ ++ return -1; ++} ++ ++int dvbca_link_write(int fd, uint8_t slot, uint8_t connection_id, ++ uint8_t *data, uint16_t data_length) ++{ ++ uint8_t *buf = malloc(data_length + 2); ++ if (buf == NULL) ++ return -1; ++ ++ buf[0] = slot; ++ buf[1] = connection_id; ++ memcpy(buf+2, data, data_length); ++ ++ int result = write(fd, buf, data_length+2); ++ free(buf); ++ return result; ++} ++ ++int dvbca_link_read(int fd, uint8_t *slot, uint8_t *connection_id, ++ uint8_t *data, uint16_t data_length) ++{ ++ int size; ++ ++ uint8_t *buf = malloc(data_length + 2); ++ if (buf == NULL) ++ return -1; ++ ++ if ((size = read(fd, buf, data_length+2)) < 2) ++ return -1; ++ ++ *slot = buf[0]; ++ *connection_id = buf[1]; ++ memcpy(data, buf+2, size-2); ++ free(buf); ++ ++ return size - 2; ++} ++ ++int dvbca_hlci_write(int fd, uint8_t *data, uint16_t data_length) ++{ ++ struct ca_msg msg; ++ ++ if (data_length > 256) { ++ return -1; ++ } ++ memset(&msg, 0, sizeof(msg)); ++ msg.length = data_length; ++ ++ memcpy(msg.msg, data, data_length); ++ ++ return ioctl(fd, CA_SEND_MSG, &msg); ++} ++ ++int dvbca_hlci_read(int fd, uint32_t app_tag, uint8_t *data, ++ uint16_t data_length) ++{ ++ struct ca_msg msg; ++ ++ if (data_length > 256) { ++ data_length = 256; ++ } ++ memset(&msg, 0, sizeof(msg)); ++ msg.length = data_length; ++ msg.msg[0] = app_tag >> 16; ++ msg.msg[1] = app_tag >> 8; ++ msg.msg[2] = app_tag; ++ ++ int status = ioctl(fd, CA_GET_MSG, &msg); ++ if (status < 0) return status; ++ ++ if (msg.length > data_length) msg.length = data_length; ++ memcpy(data, msg.msg, msg.length); ++ return msg.length; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbca.h dvb-apps/lib/libdvbapi/dvbca.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbca.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbapi/dvbca.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,135 @@ ++/* ++ * libdvbca - interface onto raw CA devices ++ * ++ * Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef LIBDVBCA_H ++#define LIBDVBCA_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * The types of CA interface we support. ++ */ ++#define DVBCA_INTERFACE_LINK 0 ++#define DVBCA_INTERFACE_HLCI 1 ++ ++/** ++ * States a CAM in a slot can be in. ++ */ ++#define DVBCA_CAMSTATE_MISSING 0 ++#define DVBCA_CAMSTATE_INITIALISING 1 ++#define DVBCA_CAMSTATE_READY 2 ++ ++ ++/** ++ * Open a CA device. Multiple CAMs can be accessed through a CA device. ++ * ++ * @param adapter Index of the DVB adapter. ++ * @param cadevice Index of the CA device on that adapter (usually 0). ++ * @return A unix file descriptor on success, or -1 on failure. ++ */ ++extern int dvbca_open(int adapter, int cadevice); ++ ++/** ++ * Reset a CAM. ++ * ++ * @param fd File handle opened with dvbca_open. ++ * @param slot Slot where the requested CAM is in. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int dvbca_reset(int fd, uint8_t slot); ++ ++/** ++ * Get the interface type of a CAM. ++ * ++ * @param fd File handle opened with dvbca_open. ++ * @param slot Slot where the requested CAM is in. ++ * @return One of the DVBCA_INTERFACE_* values, or -1 on failure. ++ */ ++extern int dvbca_get_interface_type(int fd, uint8_t slot); ++ ++/** ++ * Get the state of a CAM. ++ * ++ * @param fd File handle opened with dvbca_open. ++ * @param slot Slot where the requested CAM is in. ++ * @return One of the DVBCA_CAMSTATE_* values, or -1 on failure. ++ */ ++extern int dvbca_get_cam_state(int fd, uint8_t slot); ++ ++/** ++ * Write a message to a CAM using a link-layer interface. ++ * ++ * @param fd File handle opened with dvbca_open. ++ * @param slot Slot where the requested CAM is in. ++ * @param connection_id Connection ID of the message. ++ * @param data Data to write. ++ * @param data_length Number of bytes to write. ++ * @return 0 on success, or -1 on failure. ++ */ ++extern int dvbca_link_write(int fd, uint8_t slot, uint8_t connection_id, ++ uint8_t *data, uint16_t data_length); ++ ++/** ++ * Read a message from a CAM using a link-layer interface. ++ * ++ * @param fd File handle opened with dvbca_open. ++ * @param slot Slot where the responding CAM is in. ++ * @param connection_id Destination for the connection ID the message came from. ++ * @param data Data that was read. ++ * @param data_length Max number of bytes to read. ++ * @return Number of bytes read on success, or -1 on failure. ++ */ ++extern int dvbca_link_read(int fd, uint8_t *slot, uint8_t *connection_id, ++ uint8_t *data, uint16_t data_length); ++ ++// FIXME how do we determine which CAM slot of a CA is meant? ++/** ++ * Write a message to a CAM using an HLCI interface. ++ * ++ * @param fd File handle opened with dvbca_open. ++ * @param data Data to write. ++ * @param data_length Number of bytes to write. ++ * @return 0 on success, or -1 on failure. ++ */ ++extern int dvbca_hlci_write(int fd, uint8_t *data, uint16_t data_length); ++ ++// FIXME how do we determine which CAM slot of a CA is meant? ++/** ++ * Read a message from a CAM using an HLCI interface. ++ * ++ * @param fd File handle opened with dvbca_open. ++ * @param app_tag Application layer tag giving the message type to read. ++ * @param data Data that was read. ++ * @param data_length Max number of bytes to read. ++ * @return Number of bytes read on success, or -1 on failure. ++ */ ++extern int dvbca_hlci_read(int fd, uint32_t app_tag, uint8_t *data, ++ uint16_t data_length); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif // LIBDVBCA_H +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbdemux.c dvb-apps/lib/libdvbapi/dvbdemux.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbdemux.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbapi/dvbdemux.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,255 @@ ++/* ++ * libdvbdemux - a DVB demux library ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "dvbdemux.h" ++ ++ ++int dvbdemux_open_demux(int adapter, int demuxdevice, int nonblocking) ++{ ++ char filename[PATH_MAX+1]; ++ int flags = O_RDWR; ++ int fd; ++ ++ if (nonblocking) ++ flags |= O_NONBLOCK; ++ ++ sprintf(filename, "/dev/dvb/adapter%i/demux%i", adapter, demuxdevice); ++ if ((fd = open(filename, flags)) < 0) { ++ // if that failed, try a flat /dev structure ++ sprintf(filename, "/dev/dvb%i.demux%i", adapter, demuxdevice); ++ fd = open(filename, flags); ++ } ++ ++ return fd; ++} ++ ++int dvbdemux_open_dvr(int adapter, int dvrdevice, int readonly, int nonblocking) ++{ ++ char filename[PATH_MAX+1]; ++ int flags = O_RDWR; ++ int fd; ++ ++ if (readonly) ++ flags = O_RDONLY; ++ if (nonblocking) ++ flags |= O_NONBLOCK; ++ ++ sprintf(filename, "/dev/dvb/adapter%i/dvr%i", adapter, dvrdevice); ++ if ((fd = open(filename, flags)) < 0) { ++ // if that failed, try a flat /dev structure ++ sprintf(filename, "/dev/dvb%i.dvr%i", adapter, dvrdevice); ++ fd = open(filename, flags); ++ } ++ ++ return fd; ++} ++ ++int dvbdemux_set_section_filter(int fd, int pid, ++ uint8_t filter[18], uint8_t mask[18], ++ int start, int checkcrc) ++{ ++ struct dmx_sct_filter_params sctfilter; ++ ++ memset(&sctfilter, 0, sizeof(sctfilter)); ++ sctfilter.pid = pid; ++ memcpy(sctfilter.filter.filter, filter, 1); ++ memcpy(sctfilter.filter.filter+1, filter+3, 15); ++ memcpy(sctfilter.filter.mask, mask, 1); ++ memcpy(sctfilter.filter.mask+1, mask+3, 15); ++ memset(sctfilter.filter.mode, 0, 16); ++ if (start) ++ sctfilter.flags |= DMX_IMMEDIATE_START; ++ if (checkcrc) ++ sctfilter.flags |= DMX_CHECK_CRC; ++ ++ return ioctl(fd, DMX_SET_FILTER, &sctfilter); ++} ++ ++int dvbdemux_set_pes_filter(int fd, int pid, ++ int input, int output, ++ int pestype, ++ int start) ++{ ++ struct dmx_pes_filter_params filter; ++ ++ memset(&filter, 0, sizeof(filter)); ++ filter.pid = pid; ++ ++ switch(input) { ++ case DVBDEMUX_INPUT_FRONTEND: ++ filter.input = DMX_IN_FRONTEND; ++ break; ++ ++ case DVBDEMUX_INPUT_DVR: ++ filter.input = DMX_IN_DVR; ++ break; ++ ++ default: ++ return -EINVAL; ++ } ++ ++ switch(output) { ++ case DVBDEMUX_OUTPUT_DECODER: ++ filter.output = DMX_OUT_DECODER; ++ break; ++ ++ case DVBDEMUX_OUTPUT_DEMUX: ++ filter.output = DMX_OUT_TAP; ++ break; ++ ++ case DVBDEMUX_OUTPUT_DVR: ++ filter.output = DMX_OUT_TS_TAP; ++ break; ++ ++#ifdef DMX_OUT_TSDEMUX_TAP ++ case DVBDEMUX_OUTPUT_TS_DEMUX: ++ filter.output = DMX_OUT_TSDEMUX_TAP; ++ break; ++#endif ++ ++ default: ++ return -EINVAL; ++ } ++ ++ switch(pestype) { ++ case DVBDEMUX_PESTYPE_AUDIO: ++ filter.pes_type = DMX_PES_AUDIO; ++ break; ++ ++ case DVBDEMUX_PESTYPE_VIDEO: ++ filter.pes_type = DMX_PES_VIDEO; ++ break; ++ ++ case DVBDEMUX_PESTYPE_TELETEXT: ++ filter.pes_type = DMX_PES_TELETEXT; ++ break; ++ ++ case DVBDEMUX_PESTYPE_SUBTITLE: ++ filter.pes_type = DMX_PES_SUBTITLE; ++ break; ++ ++ case DVBDEMUX_PESTYPE_PCR: ++ filter.pes_type = DMX_PES_PCR; ++ break; ++ ++ default: ++ return -EINVAL; ++ } ++ ++ if (start) ++ filter.flags |= DMX_IMMEDIATE_START; ++ ++ return ioctl(fd, DMX_SET_PES_FILTER, &filter); ++} ++ ++int dvbdemux_set_pid_filter(int fd, int pid, ++ int input, int output, ++ int start) ++{ ++ struct dmx_pes_filter_params filter; ++ ++ memset(&filter, 0, sizeof(filter)); ++ if (pid == -1) ++ filter.pid = 0x2000; ++ else ++ filter.pid = pid; ++ ++ switch(input) { ++ case DVBDEMUX_INPUT_FRONTEND: ++ filter.input = DMX_IN_FRONTEND; ++ break; ++ ++ case DVBDEMUX_INPUT_DVR: ++ filter.input = DMX_IN_DVR; ++ break; ++ ++ default: ++ return -EINVAL; ++ } ++ ++ switch(output) { ++ case DVBDEMUX_OUTPUT_DECODER: ++ filter.output = DMX_OUT_DECODER; ++ break; ++ ++ case DVBDEMUX_OUTPUT_DEMUX: ++ filter.output = DMX_OUT_TAP; ++ break; ++ ++ case DVBDEMUX_OUTPUT_DVR: ++ filter.output = DMX_OUT_TS_TAP; ++ break; ++ ++#ifdef DMX_OUT_TSDEMUX_TAP ++ case DVBDEMUX_OUTPUT_TS_DEMUX: ++ filter.output = DMX_OUT_TSDEMUX_TAP; ++ break; ++#endif ++ ++ default: ++ return -EINVAL; ++ } ++ ++ filter.pes_type = DMX_PES_OTHER; ++ ++ if (start) ++ filter.flags |= DMX_IMMEDIATE_START; ++ ++ return ioctl(fd, DMX_SET_PES_FILTER, &filter); ++} ++ ++int dvbdemux_start(int fd) ++{ ++ return ioctl(fd, DMX_START); ++} ++ ++int dvbdemux_stop(int fd) ++{ ++ return ioctl(fd, DMX_STOP); ++} ++ ++int dvbdemux_get_stc(int fd, uint64_t *stc) ++{ ++ struct dmx_stc _stc; ++ int result; ++ ++ memset(stc, 0, sizeof(_stc)); ++ if ((result = ioctl(fd, DMX_GET_STC, &_stc)) != 0) { ++ return result; ++ } ++ ++ *stc = _stc.stc / _stc.base; ++ return 0; ++} ++ ++int dvbdemux_set_buffer(int fd, int bufsize) ++{ ++ return ioctl(fd, DMX_SET_BUFFER_SIZE, bufsize); ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbdemux.h dvb-apps/lib/libdvbapi/dvbdemux.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbdemux.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbapi/dvbdemux.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,204 @@ ++/* ++ * libdvbdemux - a DVB demux library ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef LIBDVBDEMUX_H ++#define LIBDVBDEMUX_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * Source of the data to be demuxed. ++ * ++ * FRONTEND. The data will be read from the frontend on the adapter. ++ * ++ * DVR. The data will be read from the DVR device of the adapter (of course, ++ * you need to write data TO the DVR device as well). ++ */ ++#define DVBDEMUX_INPUT_FRONTEND 0 ++#define DVBDEMUX_INPUT_DVR 1 ++ ++/** ++ * Destination of the demuxed data. ++ * ++ * DECODER. Sends the data directly to a hardware decoder (if present). ++ * ++ * DEMUX. Sends the PID stream to the current demux file descriptor. HOWEVER, the ++ * data will be the payload *only* - transport stream headers will be stripped. ++ * ++ * DVR sends the data to the DVR device. The data will be the complete transport ++ * stream packets with headers intact. Note: if multiple filters specify ++ * DVBDEMUX_OUTPUT_DVR, the individual PID streams will be re-multiplexed ++ * together. ++ */ ++#define DVBDEMUX_OUTPUT_DECODER 0 ++#define DVBDEMUX_OUTPUT_DEMUX 1 ++#define DVBDEMUX_OUTPUT_DVR 2 ++#define DVBDEMUX_OUTPUT_TS_DEMUX 3 ++ ++/** ++ * PES types. ++ */ ++#define DVBDEMUX_PESTYPE_AUDIO 0 ++#define DVBDEMUX_PESTYPE_VIDEO 1 ++#define DVBDEMUX_PESTYPE_TELETEXT 2 ++#define DVBDEMUX_PESTYPE_SUBTITLE 3 ++#define DVBDEMUX_PESTYPE_PCR 4 ++ ++ ++/** ++ * Open a demux device. Can be called multiple times. These let you setup a ++ * single filter per FD. It can can also be read() from if you use a section ++ * filter, or create a pes_filter or raw_filter with output DVBDEMUX_OUTPUT_DEMUX. ++ * ++ * @param adapter Index of the DVB adapter. ++ * @param demuxdevice Index of the demux device on that adapter (usually 0). ++ * @param nonblocking If 1, frontend will be opened in nonblocking mode. ++ * @return A unix file descriptor on success, or -1 on failure. ++ */ ++extern int dvbdemux_open_demux(int adapter, int demuxdevice, int nonblocking); ++ ++/** ++ * Open a DVR device. May be opened for writing or reading once. ++ * It is used to either write() transport stream data to be demuxed ++ * (if input == DVBDEMUX_INPUT_DVR), or to read() a stream of demuxed data ++ * (if output == DVBDEMUX_OUTPUT_DVR). ++ * ++ * Note, all demux filters with output set to DVBDEMUX_OUTPUT_DVR will be ++ * multiplexed together and output their data on this device. ++ * ++ * @param adapter Index of the DVB adapter. ++ * @param dvrdevice Index of the dvr device on that adapter (usually 0) ++ * @param readonly If 1, frontend will be opened in readonly mode only. ++ * @param nonblocking If 1, frontend will be opened in nonblocking mode. ++ * @return A unix file descriptor on success, or -1 on failure. ++ */ ++extern int dvbdemux_open_dvr(int adapter, int dvrdevice, int readonly, int nonblocking); ++ ++/** ++ * Set filter for the first 18 bytes of decoded SI table sections. Note that ++ * bytes 1 and 2 are _not_ filtered since they contain the length field. ++ * ++ * Conceptually, the driver computes the following for each filtered bit. ++ * ++ * (filter[X].bit[Y] & mask[X].bit[Y]) == (header[X].bit[Y] & mask[X].bit[Y]) ++ * ++ * Any sections which do not match this criteria for every bit will be discarded. ++ * ++ * The SI data is always read from the frontend, and is always returned by ++ * read()ing the demux fd. FIXME: check this statement! ++ * ++ * @param fd FD as opened with dvbdemux_open_demux() above. ++ * @param pid PID of the stream. ++ * @param filter The filter values of the first 18 bytes of the desired sections. ++ * @param mask Bitmask indicating which bits in the filter array should be tested ++ * (if a bit is 1, it will be tested). ++ * @param start If 1, the filter will be started immediately. Otherwise you must ++ * call dvbdemux_start() manually. ++ * @param checkcrc If 1, the driver will check the CRC on the table sections. ++ * Any bad sections will be dropped. ++ * @return 0 on success, nonzero on failure. ++ */ ++extern int dvbdemux_set_section_filter(int fd, int pid, ++ uint8_t filter[18], uint8_t mask[18], ++ int start, int checkcrc); ++ ++/** ++ * Set filter for a stream of PES data. This call can only used for cards ++ * equipped with a hardware decoder. ++ * ++ * @param fd FD as opened with dvbdemux_open_demux() above. ++ * @param pid PID of the stream. ++ * @param input One of DVBDEMUX_INPUT_*. ++ * @param output One of DVBDEMUX_OUTPUT_*. ++ * @param pestype One of DVBDEMUX_PESTYPE_* - this tells the decoder the type ++ * of data in this stream. ++ * @param start If 1, the filter will be started immediately. Otherwise you must ++ * call dvbdemux_start() manually. ++ * @return 0 on success, nonzero on failure. ++ */ ++extern int dvbdemux_set_pes_filter(int fd, int pid, ++ int input, int output, ++ int pestype, ++ int start); ++ ++/** ++ * Create a pid filter - this will extract transport stream packets for a ++ * specified PID. ++ * ++ * Note: The wildcard PID can only be used on "budget" cards. ++ * ++ * @param fd FD as opened with dvbdemux_open_demux() above. ++ * @param pid PID to retrieve, or use -1 as a wildcard for ALL PIDs. ++ * @param input One of DVBDEMUX_INPUT_*. ++ * @param output One of DVBDEMUX_OUTPUT_*. ++ * @param start If 1, the filter will be started immediately. Otherwise you must ++ * call dvbdemux_start() manually. ++ * @return 0 on success, nonzero on failure. ++ */ ++extern int dvbdemux_set_pid_filter(int fd, int pid, ++ int input, int output, ++ int start); ++ ++/** ++ * Start a demux going. ++ * ++ * @param fd FD as opened with dvbdemux_open_demux() above. ++ * @return 0 on success, nonzero on failure. ++ */ ++extern int dvbdemux_start(int fd); ++ ++/** ++ * Stop a demux. ++ * ++ * @param fd FD as opened with dvbdemux_open_demux() above. ++ * @return 0 on success, nonzero on failure. ++ */ ++extern int dvbdemux_stop(int fd); ++ ++/** ++ * Retrieve the current STC from the demux. This call can only used for cards ++ * equipped with a hardware decoder. ++ * ++ * @param fd FD as opened with dvbdemux_open_demux() above. ++ * @param stc Where to put the retrieved STC value (in 90kHz clock). ++ * @return 0 on success, nonzero on failure. ++ */ ++extern int dvbdemux_get_stc(int fd, uint64_t *stc); ++ ++/** ++ * Change the internal buffer size used by the demuxer. The default buffer size ++ * is 8192 bytes. Can only be used if the demux in question is stopped. ++ * ++ * @param fd FD as opened with dvbdemux_open_demux() above. ++ * @param bufsize New buffer size to use. ++ * @return 0 on success, nonzero on failure. ++ */ ++extern int dvbdemux_set_buffer(int fd, int bufsize); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif // LIBDVBDEMUX_H +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbfe.c dvb-apps/lib/libdvbapi/dvbfe.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbfe.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbapi/dvbfe.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,574 @@ ++/* ++ * libdvbfe - a DVB frontend library ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * Copyright (C) 2005 Manu Abraham ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#define _GNU_SOURCE ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "dvbfe.h" ++ ++int verbose = 0; ++ ++static int dvbfe_spectral_inversion_to_kapi[][2] = ++{ ++ { DVBFE_INVERSION_OFF, INVERSION_OFF }, ++ { DVBFE_INVERSION_ON, INVERSION_ON }, ++ { DVBFE_INVERSION_AUTO, INVERSION_AUTO }, ++ { -1, -1 } ++}; ++ ++static int dvbfe_code_rate_to_kapi[][2] = ++{ ++ { DVBFE_FEC_NONE, FEC_NONE }, ++ { DVBFE_FEC_1_2, FEC_1_2 }, ++ { DVBFE_FEC_2_3, FEC_2_3 }, ++ { DVBFE_FEC_3_4, FEC_3_4 }, ++ { DVBFE_FEC_4_5, FEC_4_5 }, ++ { DVBFE_FEC_5_6, FEC_5_6 }, ++ { DVBFE_FEC_6_7, FEC_6_7 }, ++ { DVBFE_FEC_7_8, FEC_7_8 }, ++ { DVBFE_FEC_8_9, FEC_8_9 }, ++ { DVBFE_FEC_AUTO, FEC_AUTO }, ++ { -1, -1 } ++}; ++ ++static int dvbfe_dvbt_const_to_kapi[][2] = ++{ ++ { DVBFE_DVBT_CONST_QPSK, FE_QPSK }, ++ { DVBFE_DVBT_CONST_QAM_16, QAM_16 }, ++ { DVBFE_DVBT_CONST_QAM_32, QAM_32 }, ++ { DVBFE_DVBT_CONST_QAM_64, QAM_64 }, ++ { DVBFE_DVBT_CONST_QAM_128, QAM_128 }, ++ { DVBFE_DVBT_CONST_QAM_256, QAM_256 }, ++ { DVBFE_DVBT_CONST_AUTO, QAM_AUTO }, ++ { -1, -1 } ++}; ++ ++static int dvbfe_dvbc_mod_to_kapi[][2] = ++{ ++ { DVBFE_DVBC_MOD_QAM_16, QAM_16 }, ++ { DVBFE_DVBC_MOD_QAM_32, QAM_32 }, ++ { DVBFE_DVBC_MOD_QAM_64, QAM_64 }, ++ { DVBFE_DVBC_MOD_QAM_128, QAM_128 }, ++ { DVBFE_DVBC_MOD_QAM_256, QAM_256 }, ++ { DVBFE_DVBC_MOD_AUTO, QAM_AUTO }, ++ { -1, -1 } ++}; ++ ++static int dvbfe_atsc_mod_to_kapi[][2] = ++{ ++ { DVBFE_ATSC_MOD_QAM_64, QAM_64 }, ++ { DVBFE_ATSC_MOD_QAM_256, QAM_256 }, ++ { DVBFE_ATSC_MOD_VSB_8, VSB_8 }, ++ { DVBFE_ATSC_MOD_VSB_16, VSB_16 }, ++ { DVBFE_ATSC_MOD_AUTO, QAM_AUTO }, ++ { -1, -1 } ++}; ++ ++static int dvbfe_dvbt_transmit_mode_to_kapi[][2] = ++{ ++ { DVBFE_DVBT_TRANSMISSION_MODE_2K, TRANSMISSION_MODE_2K }, ++ { DVBFE_DVBT_TRANSMISSION_MODE_8K, TRANSMISSION_MODE_8K }, ++ { DVBFE_DVBT_TRANSMISSION_MODE_AUTO, TRANSMISSION_MODE_AUTO }, ++ { -1, -1 } ++}; ++ ++static int dvbfe_dvbt_bandwidth_to_kapi[][2] = ++{ ++ { DVBFE_DVBT_BANDWIDTH_8_MHZ, BANDWIDTH_8_MHZ }, ++ { DVBFE_DVBT_BANDWIDTH_7_MHZ, BANDWIDTH_7_MHZ }, ++ { DVBFE_DVBT_BANDWIDTH_6_MHZ, BANDWIDTH_6_MHZ }, ++ { DVBFE_DVBT_BANDWIDTH_AUTO, BANDWIDTH_AUTO }, ++ { -1, -1 } ++}; ++ ++static int dvbfe_dvbt_guard_interval_to_kapi[][2] = ++{ ++ { DVBFE_DVBT_GUARD_INTERVAL_1_32, GUARD_INTERVAL_1_32}, ++ { DVBFE_DVBT_GUARD_INTERVAL_1_16, GUARD_INTERVAL_1_16}, ++ { DVBFE_DVBT_GUARD_INTERVAL_1_8, GUARD_INTERVAL_1_8}, ++ { DVBFE_DVBT_GUARD_INTERVAL_1_4, GUARD_INTERVAL_1_4}, ++ { DVBFE_DVBT_GUARD_INTERVAL_AUTO, GUARD_INTERVAL_AUTO}, ++ { -1, -1 } ++}; ++ ++static int dvbfe_dvbt_hierarchy_to_kapi[][2] = ++{ ++ { DVBFE_DVBT_HIERARCHY_NONE, HIERARCHY_NONE }, ++ { DVBFE_DVBT_HIERARCHY_1, HIERARCHY_1 }, ++ { DVBFE_DVBT_HIERARCHY_2, HIERARCHY_2 }, ++ { DVBFE_DVBT_HIERARCHY_4, HIERARCHY_4 }, ++ { DVBFE_DVBT_HIERARCHY_AUTO, HIERARCHY_AUTO }, ++ { -1, -1 } ++}; ++ ++ ++static int lookupval(int val, int reverse, int table[][2]) ++{ ++ int i =0; ++ ++ while(table[i][0] != -1) { ++ if (!reverse) { ++ if (val == table[i][0]) { ++ return table[i][1]; ++ } ++ } else { ++ if (val == table[i][1]) { ++ return table[i][0]; ++ } ++ } ++ i++; ++ } ++ ++ return -1; ++} ++ ++ ++struct dvbfe_handle { ++ int fd; ++ enum dvbfe_type type; ++ char *name; ++}; ++ ++struct dvbfe_handle *dvbfe_open(int adapter, int frontend, int readonly) ++{ ++ char filename[PATH_MAX+1]; ++ struct dvbfe_handle *fehandle; ++ int fd; ++ struct dvb_frontend_info info; ++ ++ // flags ++ int flags = O_RDWR; ++ if (readonly) { ++ flags = O_RDONLY; ++ } ++ ++ // open it (try normal /dev structure first) ++ sprintf(filename, "/dev/dvb/adapter%i/frontend%i", adapter, frontend); ++ if ((fd = open(filename, flags)) < 0) { ++ // if that failed, try a flat /dev structure ++ sprintf(filename, "/dev/dvb%i.frontend%i", adapter, frontend); ++ if ((fd = open(filename, flags)) < 0) { ++ return NULL; ++ } ++ } ++ ++ // determine fe type ++ if (ioctl(fd, FE_GET_INFO, &info)) { ++ close(fd); ++ return NULL; ++ } ++ ++ // setup structure ++ fehandle = (struct dvbfe_handle*) malloc(sizeof(struct dvbfe_handle)); ++ memset(fehandle, 0, sizeof(struct dvbfe_handle)); ++ fehandle->fd = fd; ++ switch(info.type) { ++ case FE_QPSK: ++ fehandle->type = DVBFE_TYPE_DVBS; ++ break; ++ ++ case FE_QAM: ++ fehandle->type = DVBFE_TYPE_DVBC; ++ break; ++ ++ case FE_OFDM: ++ fehandle->type = DVBFE_TYPE_DVBT; ++ break; ++ ++ case FE_ATSC: ++ fehandle->type = DVBFE_TYPE_ATSC; ++ break; ++ } ++ fehandle->name = strndup(info.name, sizeof(info.name)); ++ ++ // done ++ return fehandle; ++} ++ ++void dvbfe_close(struct dvbfe_handle *fehandle) ++{ ++ close(fehandle->fd); ++ free(fehandle->name); ++ free(fehandle); ++} ++ ++extern int dvbfe_get_info(struct dvbfe_handle *fehandle, ++ enum dvbfe_info_mask querymask, ++ struct dvbfe_info *result, ++ enum dvbfe_info_querytype querytype, ++ int timeout) ++{ ++ int returnval = 0; ++ struct dvb_frontend_event kevent; ++ int ok = 0; ++ ++ result->name = fehandle->name; ++ result->type = fehandle->type; ++ ++ switch(querytype) { ++ case DVBFE_INFO_QUERYTYPE_IMMEDIATE: ++ if (querymask & DVBFE_INFO_LOCKSTATUS) { ++ if (!ioctl(fehandle->fd, FE_READ_STATUS, &kevent.status)) { ++ returnval |= DVBFE_INFO_LOCKSTATUS; ++ } ++ } ++ if (querymask & DVBFE_INFO_FEPARAMS) { ++ if (!ioctl(fehandle->fd, FE_GET_FRONTEND, &kevent.parameters)) { ++ returnval |= DVBFE_INFO_FEPARAMS; ++ } ++ } ++ break; ++ ++ case DVBFE_INFO_QUERYTYPE_LOCKCHANGE: ++ { ++ struct pollfd pollfd; ++ pollfd.fd = fehandle->fd; ++ pollfd.events = POLLIN | POLLERR; ++ ++ ok = 1; ++ if (poll(&pollfd, 1, timeout) < 0) ++ ok = 0; ++ if (pollfd.revents & POLLERR) ++ ok = 0; ++ if (!(pollfd.revents & POLLIN)) ++ ok = 0; ++ } ++ ++ if (ok && ++ ((querymask & DVBFE_INFO_LOCKSTATUS) || ++ (querymask & DVBFE_INFO_FEPARAMS))) { ++ if (!ioctl(fehandle->fd, FE_GET_EVENT, &kevent)) { ++ if (querymask & DVBFE_INFO_LOCKSTATUS) ++ returnval |= DVBFE_INFO_LOCKSTATUS; ++ if (querymask & DVBFE_INFO_FEPARAMS) ++ returnval |= DVBFE_INFO_FEPARAMS; ++ } ++ } ++ break; ++ } ++ ++ if (returnval & DVBFE_INFO_LOCKSTATUS) { ++ result->signal = kevent.status & FE_HAS_SIGNAL ? 1 : 0; ++ result->carrier = kevent.status & FE_HAS_CARRIER ? 1 : 0; ++ result->viterbi = kevent.status & FE_HAS_VITERBI ? 1 : 0; ++ result->sync = kevent.status & FE_HAS_SYNC ? 1 : 0; ++ result->lock = kevent.status & FE_HAS_LOCK ? 1 : 0; ++ } ++ ++ if (returnval & DVBFE_INFO_FEPARAMS) { ++ result->feparams.frequency = kevent.parameters.frequency; ++ result->feparams.inversion = lookupval(kevent.parameters.inversion, 1, dvbfe_spectral_inversion_to_kapi); ++ switch(fehandle->type) { ++ case FE_QPSK: ++ result->feparams.u.dvbs.symbol_rate = kevent.parameters.u.qpsk.symbol_rate; ++ result->feparams.u.dvbs.fec_inner = ++ lookupval(kevent.parameters.u.qpsk.fec_inner, 1, dvbfe_code_rate_to_kapi); ++ break; ++ ++ case FE_QAM: ++ result->feparams.u.dvbc.symbol_rate = kevent.parameters.u.qam.symbol_rate; ++ result->feparams.u.dvbc.fec_inner = ++ lookupval(kevent.parameters.u.qam.fec_inner, 1, dvbfe_code_rate_to_kapi); ++ result->feparams.u.dvbc.modulation = ++ lookupval(kevent.parameters.u.qam.modulation, 1, dvbfe_dvbc_mod_to_kapi); ++ break; ++ ++ case FE_OFDM: ++ result->feparams.u.dvbt.bandwidth = ++ lookupval(kevent.parameters.u.ofdm.bandwidth, 1, dvbfe_dvbt_bandwidth_to_kapi); ++ result->feparams.u.dvbt.code_rate_HP = ++ lookupval(kevent.parameters.u.ofdm.code_rate_HP, 1, dvbfe_code_rate_to_kapi); ++ result->feparams.u.dvbt.code_rate_LP = ++ lookupval(kevent.parameters.u.ofdm.code_rate_LP, 1, dvbfe_code_rate_to_kapi); ++ result->feparams.u.dvbt.constellation = ++ lookupval(kevent.parameters.u.ofdm.constellation, 1, dvbfe_dvbt_const_to_kapi); ++ result->feparams.u.dvbt.transmission_mode = ++ lookupval(kevent.parameters.u.ofdm.transmission_mode, 1, dvbfe_dvbt_transmit_mode_to_kapi); ++ result->feparams.u.dvbt.guard_interval = ++ lookupval(kevent.parameters.u.ofdm.guard_interval, 1, dvbfe_dvbt_guard_interval_to_kapi); ++ result->feparams.u.dvbt.hierarchy_information = ++ lookupval(kevent.parameters.u.ofdm.hierarchy_information, 1, dvbfe_dvbt_hierarchy_to_kapi); ++ break; ++ ++ case FE_ATSC: ++ result->feparams.u.atsc.modulation = ++ lookupval(kevent.parameters.u.vsb.modulation, 1, dvbfe_atsc_mod_to_kapi); ++ break; ++ } ++ } ++ ++ if (querymask & DVBFE_INFO_BER) { ++ if (!ioctl(fehandle->fd, FE_READ_BER, &result->ber)) ++ returnval |= DVBFE_INFO_BER; ++ } ++ if (querymask & DVBFE_INFO_SIGNAL_STRENGTH) { ++ if (!ioctl(fehandle->fd, FE_READ_SIGNAL_STRENGTH, &result->signal_strength)) ++ returnval |= DVBFE_INFO_SIGNAL_STRENGTH; ++ } ++ if (querymask & DVBFE_INFO_SNR) { ++ if (!ioctl(fehandle->fd, FE_READ_SNR, &result->snr)) ++ returnval |= DVBFE_INFO_SNR; ++ } ++ if (querymask & DVBFE_INFO_UNCORRECTED_BLOCKS) { ++ if (!ioctl(fehandle->fd, FE_READ_UNCORRECTED_BLOCKS, &result->ucblocks)) ++ returnval |= DVBFE_INFO_UNCORRECTED_BLOCKS; ++ } ++ ++ // done ++ return returnval; ++} ++ ++int dvbfe_set(struct dvbfe_handle *fehandle, ++ struct dvbfe_parameters *params, ++ int timeout) ++{ ++ struct dvb_frontend_parameters kparams; ++ int res; ++ struct timeval endtime; ++ fe_status_t status; ++ ++ kparams.frequency = params->frequency; ++ kparams.inversion = lookupval(params->inversion, 0, dvbfe_spectral_inversion_to_kapi); ++ switch(fehandle->type) { ++ case FE_QPSK: ++ kparams.u.qpsk.symbol_rate = params->u.dvbs.symbol_rate; ++ kparams.u.qpsk.fec_inner = lookupval(params->u.dvbs.fec_inner, 0, dvbfe_code_rate_to_kapi); ++ break; ++ ++ case FE_QAM: ++ kparams.u.qam.symbol_rate = params->u.dvbc.symbol_rate; ++ kparams.u.qam.fec_inner = lookupval(params->u.dvbc.fec_inner, 0, dvbfe_code_rate_to_kapi); ++ kparams.u.qam.modulation = lookupval(params->u.dvbc.modulation, 0, dvbfe_dvbc_mod_to_kapi); ++ break; ++ ++ case FE_OFDM: ++ kparams.u.ofdm.bandwidth = lookupval(params->u.dvbt.bandwidth, 0, dvbfe_dvbt_bandwidth_to_kapi); ++ kparams.u.ofdm.code_rate_HP = lookupval(params->u.dvbt.code_rate_HP, 0, dvbfe_code_rate_to_kapi); ++ kparams.u.ofdm.code_rate_LP = lookupval(params->u.dvbt.code_rate_LP, 0, dvbfe_code_rate_to_kapi); ++ kparams.u.ofdm.constellation = lookupval(params->u.dvbt.constellation, 0, dvbfe_dvbt_const_to_kapi); ++ kparams.u.ofdm.transmission_mode = ++ lookupval(params->u.dvbt.transmission_mode, 0, dvbfe_dvbt_transmit_mode_to_kapi); ++ kparams.u.ofdm.guard_interval = ++ lookupval(params->u.dvbt.guard_interval, 0, dvbfe_dvbt_guard_interval_to_kapi); ++ kparams.u.ofdm.hierarchy_information = ++ lookupval(params->u.dvbt.hierarchy_information, 0, dvbfe_dvbt_hierarchy_to_kapi); ++ break; ++ ++ case FE_ATSC: ++ kparams.u.vsb.modulation = lookupval(params->u.atsc.modulation, 0, dvbfe_atsc_mod_to_kapi); ++ break; ++ ++ default: ++ return -EINVAL; ++ } ++ ++ // set it and check for error ++ res = ioctl(fehandle->fd, FE_SET_FRONTEND, &kparams); ++ if (res) ++ return res; ++ ++ // 0 => return immediately ++ if (timeout == 0) { ++ return 0; ++ } ++ ++ /* calculate timeout */ ++ if (timeout > 0) { ++ gettimeofday(&endtime, NULL); ++ timeout *= 1000; ++ endtime.tv_sec += timeout / 1000000; ++ endtime.tv_usec += timeout % 1000000; ++ } ++ ++ /* wait for a lock */ ++ while(1) { ++ /* has it locked? */ ++ if (!ioctl(fehandle->fd, FE_READ_STATUS, &status)) { ++ if (status & FE_HAS_LOCK) { ++ break; ++ } ++ } ++ ++ /* check for timeout */ ++ if (timeout > 0) { ++ struct timeval curtime; ++ gettimeofday(&curtime, NULL); ++ if ((curtime.tv_sec > endtime.tv_sec) || ++ ((curtime.tv_sec == endtime.tv_sec) && (curtime.tv_usec >= endtime.tv_usec))) { ++ break; ++ } ++ } ++ ++ /* delay for a bit */ ++ usleep(100000); ++ } ++ ++ /* exit */ ++ if (status & FE_HAS_LOCK) ++ return 0; ++ return -ETIMEDOUT; ++} ++ ++int dvbfe_get_pollfd(struct dvbfe_handle *handle) ++{ ++ return handle->fd; ++} ++ ++int dvbfe_set_22k_tone(struct dvbfe_handle *fehandle, enum dvbfe_sec_tone_mode tone) ++{ ++ int ret = 0; ++ ++ switch (tone) { ++ case DVBFE_SEC_TONE_OFF: ++ ret = ioctl(fehandle->fd, FE_SET_TONE, SEC_TONE_OFF); ++ break; ++ case DVBFE_SEC_TONE_ON: ++ ret = ioctl(fehandle->fd, FE_SET_TONE, SEC_TONE_ON); ++ break; ++ default: ++ print(verbose, ERROR, 1, "Invalid command !"); ++ break; ++ } ++ if (ret == -1) ++ print(verbose, ERROR, 1, "IOCTL failed !"); ++ ++ return ret; ++} ++ ++int dvbfe_set_tone_data_burst(struct dvbfe_handle *fehandle, enum dvbfe_sec_mini_cmd minicmd) ++{ ++ int ret = 0; ++ ++ switch (minicmd) { ++ case DVBFE_SEC_MINI_A: ++ ret = ioctl(fehandle->fd, FE_DISEQC_SEND_BURST, SEC_MINI_A); ++ break; ++ case DVBFE_SEC_MINI_B: ++ ret = ioctl(fehandle->fd, FE_DISEQC_SEND_BURST, SEC_MINI_B); ++ break; ++ default: ++ print(verbose, ERROR, 1, "Invalid command"); ++ break; ++ } ++ if (ret == -1) ++ print(verbose, ERROR, 1, "IOCTL failed"); ++ ++ return ret; ++} ++ ++int dvbfe_set_voltage(struct dvbfe_handle *fehandle, enum dvbfe_sec_voltage voltage) ++{ ++ int ret = 0; ++ ++ switch (voltage) { ++ case DVBFE_SEC_VOLTAGE_OFF: ++ ret = ioctl(fehandle->fd, FE_SET_VOLTAGE, SEC_VOLTAGE_OFF); ++ break; ++ case DVBFE_SEC_VOLTAGE_13: ++ ret = ioctl(fehandle->fd, FE_SET_VOLTAGE, SEC_VOLTAGE_13); ++ break; ++ case DVBFE_SEC_VOLTAGE_18: ++ ret = ioctl(fehandle->fd, FE_SET_VOLTAGE, SEC_VOLTAGE_18); ++ break; ++ default: ++ print(verbose, ERROR, 1, "Invalid command"); ++ break; ++ } ++ if (ret == -1) ++ print(verbose, ERROR, 1, "IOCTL failed"); ++ ++ return ret; ++} ++ ++int dvbfe_set_high_lnb_voltage(struct dvbfe_handle *fehandle, int on) ++{ ++ switch (on) { ++ case 0: ++ ioctl(fehandle->fd, FE_ENABLE_HIGH_LNB_VOLTAGE, 0); ++ break; ++ default: ++ ioctl(fehandle->fd, FE_ENABLE_HIGH_LNB_VOLTAGE, 1); ++ break; ++ } ++ return 0; ++} ++ ++int dvbfe_do_dishnetworks_legacy_command(struct dvbfe_handle *fehandle, unsigned int cmd) ++{ ++ int ret = 0; ++ ++ ret = ioctl(fehandle->fd, FE_DISHNETWORK_SEND_LEGACY_CMD, cmd); ++ if (ret == -1) ++ print(verbose, ERROR, 1, "IOCTL failed"); ++ ++ return ret; ++} ++ ++int dvbfe_do_diseqc_command(struct dvbfe_handle *fehandle, uint8_t *data, uint8_t len) ++{ ++ int ret = 0; ++ struct dvb_diseqc_master_cmd diseqc_message; ++ ++ if (len > 6) ++ return -EINVAL; ++ ++ diseqc_message.msg_len = len; ++ memcpy(diseqc_message.msg, data, len); ++ ++ ret = ioctl(fehandle->fd, FE_DISEQC_SEND_MASTER_CMD, &diseqc_message); ++ if (ret == -1) ++ print(verbose, ERROR, 1, "IOCTL failed"); ++ ++ return ret; ++} ++ ++int dvbfe_diseqc_read(struct dvbfe_handle *fehandle, int timeout, unsigned char *buf, unsigned int len) ++{ ++ struct dvb_diseqc_slave_reply reply; ++ int result; ++ ++ if (len > 4) ++ len = 4; ++ ++ reply.timeout = timeout; ++ reply.msg_len = len; ++ ++ if ((result = ioctl(fehandle->fd, FE_DISEQC_RECV_SLAVE_REPLY, reply)) != 0) ++ return result; ++ ++ if (reply.msg_len < len) ++ len = reply.msg_len; ++ memcpy(buf, reply.msg, len); ++ ++ return len; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbfe.h dvb-apps/lib/libdvbapi/dvbfe.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbfe.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbapi/dvbfe.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,333 @@ ++/* ++ * libdvbfe - a DVB frontend library ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * Copyright (C) 2005 Manu Abraham ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef LIBDVBFE_H ++#define LIBDVBFE_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * The types of frontend we support. ++ */ ++enum dvbfe_type { ++ DVBFE_TYPE_DVBS, ++ DVBFE_TYPE_DVBC, ++ DVBFE_TYPE_DVBT, ++ DVBFE_TYPE_ATSC, ++}; ++ ++enum dvbfe_spectral_inversion { ++ DVBFE_INVERSION_OFF, ++ DVBFE_INVERSION_ON, ++ DVBFE_INVERSION_AUTO ++}; ++ ++enum dvbfe_code_rate { ++ DVBFE_FEC_NONE, ++ DVBFE_FEC_1_2, ++ DVBFE_FEC_2_3, ++ DVBFE_FEC_3_4, ++ DVBFE_FEC_4_5, ++ DVBFE_FEC_5_6, ++ DVBFE_FEC_6_7, ++ DVBFE_FEC_7_8, ++ DVBFE_FEC_8_9, ++ DVBFE_FEC_AUTO ++}; ++ ++enum dvbfe_dvbt_const { ++ DVBFE_DVBT_CONST_QPSK, ++ DVBFE_DVBT_CONST_QAM_16, ++ DVBFE_DVBT_CONST_QAM_32, ++ DVBFE_DVBT_CONST_QAM_64, ++ DVBFE_DVBT_CONST_QAM_128, ++ DVBFE_DVBT_CONST_QAM_256, ++ DVBFE_DVBT_CONST_AUTO ++}; ++ ++enum dvbfe_dvbc_mod { ++ DVBFE_DVBC_MOD_QAM_16, ++ DVBFE_DVBC_MOD_QAM_32, ++ DVBFE_DVBC_MOD_QAM_64, ++ DVBFE_DVBC_MOD_QAM_128, ++ DVBFE_DVBC_MOD_QAM_256, ++ DVBFE_DVBC_MOD_AUTO, ++}; ++ ++enum dvbfe_atsc_mod { ++ DVBFE_ATSC_MOD_QAM_64, ++ DVBFE_ATSC_MOD_QAM_256, ++ DVBFE_ATSC_MOD_VSB_8, ++ DVBFE_ATSC_MOD_VSB_16, ++ DVBFE_ATSC_MOD_AUTO ++}; ++ ++enum dvbfe_dvbt_transmit_mode { ++ DVBFE_DVBT_TRANSMISSION_MODE_2K, ++ DVBFE_DVBT_TRANSMISSION_MODE_8K, ++ DVBFE_DVBT_TRANSMISSION_MODE_AUTO ++}; ++ ++enum dvbfe_dvbt_bandwidth { ++ DVBFE_DVBT_BANDWIDTH_8_MHZ, ++ DVBFE_DVBT_BANDWIDTH_7_MHZ, ++ DVBFE_DVBT_BANDWIDTH_6_MHZ, ++ DVBFE_DVBT_BANDWIDTH_AUTO ++}; ++ ++enum dvbfe_dvbt_guard_interval { ++ DVBFE_DVBT_GUARD_INTERVAL_1_32, ++ DVBFE_DVBT_GUARD_INTERVAL_1_16, ++ DVBFE_DVBT_GUARD_INTERVAL_1_8, ++ DVBFE_DVBT_GUARD_INTERVAL_1_4, ++ DVBFE_DVBT_GUARD_INTERVAL_AUTO ++}; ++ ++enum dvbfe_dvbt_hierarchy { ++ DVBFE_DVBT_HIERARCHY_NONE, ++ DVBFE_DVBT_HIERARCHY_1, ++ DVBFE_DVBT_HIERARCHY_2, ++ DVBFE_DVBT_HIERARCHY_4, ++ DVBFE_DVBT_HIERARCHY_AUTO ++}; ++ ++/** ++ * Structure used to store and communicate frontend parameters. ++ */ ++struct dvbfe_parameters { ++ uint32_t frequency; ++ enum dvbfe_spectral_inversion inversion; ++ union { ++ struct { ++ uint32_t symbol_rate; ++ enum dvbfe_code_rate fec_inner; ++ } dvbs; ++ ++ struct { ++ uint32_t symbol_rate; ++ enum dvbfe_code_rate fec_inner; ++ enum dvbfe_dvbc_mod modulation; ++ } dvbc; ++ ++ struct { ++ enum dvbfe_dvbt_bandwidth bandwidth; ++ enum dvbfe_code_rate code_rate_HP; ++ enum dvbfe_code_rate code_rate_LP; ++ enum dvbfe_dvbt_const constellation; ++ enum dvbfe_dvbt_transmit_mode transmission_mode; ++ enum dvbfe_dvbt_guard_interval guard_interval; ++ enum dvbfe_dvbt_hierarchy hierarchy_information; ++ } dvbt; ++ ++ struct { ++ enum dvbfe_atsc_mod modulation; ++ } atsc; ++ } u; ++}; ++ ++enum dvbfe_sec_voltage { ++ DVBFE_SEC_VOLTAGE_13, ++ DVBFE_SEC_VOLTAGE_18, ++ DVBFE_SEC_VOLTAGE_OFF ++}; ++ ++enum dvbfe_sec_tone_mode { ++ DVBFE_SEC_TONE_ON, ++ DVBFE_SEC_TONE_OFF ++}; ++ ++enum dvbfe_sec_mini_cmd { ++ DVBFE_SEC_MINI_A, ++ DVBFE_SEC_MINI_B ++}; ++ ++/** ++ * Mask of values used in the dvbfe_get_info() call. ++ */ ++enum dvbfe_info_mask { ++ DVBFE_INFO_LOCKSTATUS = 0x01, ++ DVBFE_INFO_FEPARAMS = 0x02, ++ DVBFE_INFO_BER = 0x04, ++ DVBFE_INFO_SIGNAL_STRENGTH = 0x08, ++ DVBFE_INFO_SNR = 0x10, ++ DVBFE_INFO_UNCORRECTED_BLOCKS = 0x20, ++}; ++ ++/** ++ * Structure containing values used by the dvbfe_get_info() call. ++ */ ++struct dvbfe_info { ++ enum dvbfe_type type; /* always retrieved */ ++ const char *name; /* always retrieved */ ++ unsigned int signal : 1; /* } DVBFE_INFO_LOCKSTATUS */ ++ unsigned int carrier : 1; /* } */ ++ unsigned int viterbi : 1; /* } */ ++ unsigned int sync : 1; /* } */ ++ unsigned int lock : 1; /* } */ ++ struct dvbfe_parameters feparams; /* DVBFE_INFO_FEPARAMS */ ++ uint32_t ber; /* DVBFE_INFO_BER */ ++ uint16_t signal_strength; /* DVBFE_INFO_SIGNAL_STRENGTH */ ++ uint16_t snr; /* DVBFE_INFO_SNR */ ++ uint32_t ucblocks; /* DVBFE_INFO_UNCORRECTED_BLOCKS */ ++}; ++ ++/** ++ * Possible types of query used in dvbfe_get_info. ++ * ++ * DVBFE_INFO_QUERYTYPE_IMMEDIATE - interrogate frontend for most up to date values. ++ * DVBFE_INFO_QUERYTYPE_LOCKCHANGE - return details from queued lock status ++ * change events, or wait for one to occur ++ * if none are queued. ++ */ ++enum dvbfe_info_querytype { ++ DVBFE_INFO_QUERYTYPE_IMMEDIATE, ++ DVBFE_INFO_QUERYTYPE_LOCKCHANGE, ++}; ++ ++ ++/** ++ * Frontend handle datatype. ++ */ ++struct dvbfe_handle; ++ ++/** ++ * Open a DVB frontend. ++ * ++ * @param adapter DVB adapter ID. ++ * @param frontend Frontend ID of that adapter to open. ++ * @param readonly If 1, frontend will be opened in readonly mode only. ++ * @return A handle on success, or NULL on failure. ++ */ ++extern struct dvbfe_handle *dvbfe_open(int adapter, int frontend, int readonly); ++ ++/** ++ * Close a DVB frontend. ++ * ++ * @param fehandle Handle opened with dvbfe_open(). ++ */ ++extern void dvbfe_close(struct dvbfe_handle *handle); ++ ++/** ++ * Set the frontend tuning parameters. ++ * ++ * Note: this function provides only the basic tuning operation; you might want to ++ * investigate dvbfe_set_sec() in sec.h for a unified device tuning operation. ++ * ++ * @param fehandle Handle opened with dvbfe_open(). ++ * @param params Params to set. ++ * @param timeout <0 => wait forever for lock. 0=>return immediately, >0=> ++ * number of milliseconds to wait for a lock. ++ * @return 0 on locked (or if timeout==0 and everything else worked), or ++ * nonzero on failure (including no lock). ++ */ ++extern int dvbfe_set(struct dvbfe_handle *fehandle, ++ struct dvbfe_parameters *params, ++ int timeout); ++ ++/** ++ * Retrieve information about the frontend. ++ * ++ * @param fehandle Handle opened with dvbfe_open(). ++ * @param querymask ORed bitmask of desired DVBFE_INFO_* values. ++ * @param result Where to put the retrieved results. ++ * @param querytype Type of query requested. ++ * @param timeout Timeout in ms to use if querytype==lockchange (0=>no timeout, <0=> wait forever). ++ * @return ORed bitmask of DVBFE_INFO_* indicating which values were read successfully. ++ */ ++extern int dvbfe_get_info(struct dvbfe_handle *fehandle, ++ enum dvbfe_info_mask querymask, ++ struct dvbfe_info *result, ++ enum dvbfe_info_querytype querytype, ++ int timeout); ++ ++/** ++ * Get a file descriptor for polling for lock status changes. ++ * ++ * @param fehandle Handle opened with dvbfe_open(). ++ * @return FD for polling. ++ */ ++extern int dvbfe_get_pollfd(struct dvbfe_handle *handle); ++ ++/** ++ * Tone/Data Burst control ++ * @param fehandle Handle opened with dvbfe_open(). ++ * @param tone, SEC_TONE_ON/SEC_TONE_OFF ++ */ ++extern int dvbfe_set_22k_tone(struct dvbfe_handle *handle, enum dvbfe_sec_tone_mode tone); ++ ++/** ++ * 22khz Tone control ++ * @param fehandle Handle opened with dvbfe_open(). ++ * @param adapter, minicmd, SEC_MINI_A/SEC_MINI_B ++ */ ++extern int dvbfe_set_tone_data_burst(struct dvbfe_handle *handle, enum dvbfe_sec_mini_cmd minicmd); ++ ++/** ++ * Voltage control ++ * @param fehandle Handle opened with dvbfe_open(). ++ * @param polarization, SEC_VOLTAGE_13/SEC_VOLTAGE_18/SEC_VOLTAGE_OFF ++ */ ++extern int dvbfe_set_voltage(struct dvbfe_handle *handle, enum dvbfe_sec_voltage voltage); ++ ++/** ++ * High LNB voltage control (increases voltage by 1v to compensate for long cables) ++ * @param fehandle Handle opened with dvbfe_open(). ++ * @param on 1 to enable, 0 to disable. ++ */ ++extern int dvbfe_set_high_lnb_voltage(struct dvbfe_handle *fehandle, int on); ++ ++/** ++ * Send a legacy Dish Networks command ++ * @param fehandle Handle opened with dvbfe_open(). ++ * @param cmd, the command to send ++ */ ++extern int dvbfe_do_dishnetworks_legacy_command(struct dvbfe_handle *handle, unsigned int cmd); ++ ++/** ++ * Send a DiSEqC Command ++ * @param fehandle Handle opened with dvbfe_open(). ++ * @param data, a pointer to am array containing the data to be sent. ++ * @param len Length of data in bytes, max 6 bytes. ++ */ ++extern int dvbfe_do_diseqc_command(struct dvbfe_handle *handle, uint8_t *data, uint8_t len); ++ ++/** ++ * Read a DISEQC response from the frontend. ++ * ++ * @param fehandle Handle opened with dvbfe_open(). ++ * @param timeout Timeout for DISEQC response. ++ * @param buf Buffer to store response in. ++ * @param len Number of bytes in buffer. ++ * @return >= 0 on success (number of received bytes), <0 on failure. ++ */ ++extern int dvbfe_diseqc_read(struct dvbfe_handle *fehandle, int timeout, unsigned char *buf, unsigned int len); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif // LIBDVBFE_H +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbnet.c dvb-apps/lib/libdvbapi/dvbnet.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbnet.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbapi/dvbnet.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,104 @@ ++/* ++ * libdvbnet - a DVB network support library ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "dvbnet.h" ++ ++int dvbnet_open(int adapter, int netdeviceid) ++{ ++ char filename[PATH_MAX+1]; ++ int fd; ++ ++ sprintf(filename, "/dev/dvb/adapter%i/net%i", adapter, netdeviceid); ++ if ((fd = open(filename, O_RDWR)) < 0) { ++ // if that failed, try a flat /dev structure ++ sprintf(filename, "/dev/dvb%i.net%i", adapter, netdeviceid); ++ fd = open(filename, O_RDWR); ++ } ++ ++ return fd; ++} ++ ++int dvbnet_add_interface(int fd, uint16_t pid, enum dvbnet_encap encapsulation) ++{ ++ struct dvb_net_if params; ++ int status; ++ ++ memset(¶ms, 0, sizeof(params)); ++ params.pid = pid; ++ ++ switch(encapsulation) { ++ case DVBNET_ENCAP_MPE: ++ params.feedtype = DVB_NET_FEEDTYPE_MPE; ++ break; ++ ++ case DVBNET_ENCAP_ULE: ++ params.feedtype = DVB_NET_FEEDTYPE_ULE; ++ break; ++ ++ default: ++ return -EINVAL; ++ } ++ ++ status = ioctl(fd, NET_ADD_IF, ¶ms); ++ if (status < 0) ++ return status; ++ return params.if_num; ++} ++ ++int dvbnet_get_interface(int fd, int ifnum, uint16_t *pid, enum dvbnet_encap *encapsulation) ++{ ++ struct dvb_net_if info; ++ int res; ++ ++ memset(&info, 0, sizeof(struct dvb_net_if)); ++ info.if_num = ifnum; ++ ++ if ((res = ioctl(fd, NET_GET_IF, &info)) < 0) ++ return res; ++ ++ *pid = info.pid; ++ switch(info.feedtype) { ++ case DVB_NET_FEEDTYPE_MPE: ++ *encapsulation = DVBNET_ENCAP_MPE; ++ break; ++ ++ case DVB_NET_FEEDTYPE_ULE: ++ *encapsulation = DVBNET_ENCAP_ULE; ++ break; ++ ++ default: ++ return -EINVAL; ++ } ++ return 0; ++} ++ ++int dvbnet_remove_interface(int fd, int ifnum) ++{ ++ return ioctl(fd, NET_REMOVE_IF, ifnum); ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbnet.h dvb-apps/lib/libdvbapi/dvbnet.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbnet.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbapi/dvbnet.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,87 @@ ++/* ++ * libdvbnet - a DVB network support library ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef LIBDVBNET_H ++#define LIBDVBNET_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * Possible encapsulations of data. ++ */ ++enum dvbnet_encap { ++ DVBNET_ENCAP_MPE, ++ DVBNET_ENCAP_ULE, ++}; ++ ++/** ++ * The maximum allowed number of dvb network devices per adapter netdevice. ++ */ ++#define DVBNET_MAX_INTERFACES 10 ++ ++/** ++ * Open a DVB net interface. ++ * ++ * @param adapter DVB adapter ID. ++ * @param netdeviceid Network control interface of that adapter to open. ++ * @return A unix file descriptor on success, or -1 on failure. ++ */ ++extern int dvbnet_open(int adapter, int netdeviceid); ++ ++/** ++ * Create a new DVBNET interface. ++ * ++ * @param fd FD opened with libdvbnet_open(). ++ * @param pid PID of the stream containing the network data. ++ * @param encapsulation Encapsulation type of the stream (one of DVBNET_ENCAP_*). ++ * @return Index of new interface on success, < 0 on failure. ++ */ ++extern int dvbnet_add_interface(int fd, uint16_t pid, enum dvbnet_encap encapsulation); ++ ++/** ++ * Get details of a DVBNET interface. ++ * ++ * @param fd FD opened with libdvbnet_open(). ++ * @param ifnum Index of interface to retrieve. ++ * @param pid The PID of the interface. ++ * @param encapsulation The encapsulation of the interface (DVBNET_ENCAP_*). ++ * @return 0 on success, nonzero on failure. ++ */ ++extern int dvbnet_get_interface(int fd, int ifnum, uint16_t *pid, enum dvbnet_encap *encapsulation); ++ ++/** ++ * Remove a DVBNET interface. ++ * ++ * @param fd FD opened with libdvbnet_open(). ++ * @param ifnum Index of interface to remove. ++ * @return 0 on success, nonzero on failure. ++ */ ++extern int dvbnet_remove_interface(int fd, int ifnum); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif // LIBDVBNET_H +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbvideo.c dvb-apps/lib/libdvbapi/dvbvideo.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbvideo.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbapi/dvbvideo.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,46 @@ ++/* ++ * libdvbnet - a DVB network support library ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "dvbvideo.h" ++ ++int dvbvideo_open(int adapter, int videodeviceid) ++{ ++ char filename[PATH_MAX+1]; ++ int fd; ++ ++ sprintf(filename, "/dev/dvb/adapter%i/video%i", adapter, videodeviceid); ++ if ((fd = open(filename, O_RDWR)) < 0) { ++ // if that failed, try a flat /dev structure ++ sprintf(filename, "/dev/dvb%i.video%i", adapter, videodeviceid); ++ fd = open(filename, O_RDWR); ++ } ++ ++ return fd; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbvideo.h dvb-apps/lib/libdvbapi/dvbvideo.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvbapi/dvbvideo.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbapi/dvbvideo.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,46 @@ ++/* ++ * libdvbnet - a DVB network support library ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef LIBDVBVIDEO_H ++#define LIBDVBVIDEO_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * Open a DVB video device. ++ * ++ * @param adapter DVB adapter ID. ++ * @param videodeviceid Id of video device of that adapter to open. ++ * @return A unix file descriptor on success, or -1 on failure. ++ */ ++extern int dvbvideo_open(int adapter, int videodeviceid); ++ ++// FIXME: this is a stub library ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif // LIBDVBVIDEO_H +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbapi/Makefile dvb-apps/lib/libdvbapi/Makefile +--- linuxtv-dvb-apps-1.1.1/lib/libdvbapi/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbapi/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,25 @@ ++# Makefile for linuxtv.org dvb-apps/lib/libdvbapi ++ ++includes = dvbaudio.h \ ++ dvbca.h \ ++ dvbdemux.h \ ++ dvbfe.h \ ++ dvbnet.h \ ++ dvbvideo.h ++ ++objects = dvbaudio.o \ ++ dvbca.o \ ++ dvbdemux.o \ ++ dvbfe.o \ ++ dvbnet.o \ ++ dvbvideo.o ++ ++lib_name = libdvbapi ++ ++CPPFLAGS += -I../../lib ++ ++.PHONY: all ++ ++all: library ++ ++include ../../Make.rules +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbcfg/dvbcfg_common.c dvb-apps/lib/libdvbcfg/dvbcfg_common.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvbcfg/dvbcfg_common.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbcfg/dvbcfg_common.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,136 @@ ++/* ++ * dvbcfg - support for linuxtv configuration files ++ * common functions ++ * ++ * Copyright (C) 2006 Christoph Pfister ++ * Copyright (C) 2005 Andrew de Quincey ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++#include ++#include "dvbcfg_common.h" ++ ++int dvbcfg_parse_int(char **text, char *tokens) ++{ ++ char *start = *text; ++ char *stop = *text; ++ int value; ++ ++ while (*stop != '\0') { ++ if (strchr(tokens, *stop) != NULL) { ++ *stop = '\0'; ++ stop++; ++ break; ++ } ++ stop++; ++ } ++ ++ if (sscanf(start, "%i", &value) == 1) { ++ *text = stop; ++ return value; ++ } ++ ++ *text = NULL; ++ return -1; ++} ++ ++int dvbcfg_parse_char(char **text, char *tokens) ++{ ++ char *start = *text; ++ char *stop = *text; ++ char value; ++ ++ while (*stop != '\0') { ++ if (strchr(tokens, *stop) != NULL) { ++ *stop = '\0'; ++ stop++; ++ break; ++ } ++ stop++; ++ } ++ ++ if (sscanf(start, "%c", &value) == 1) { ++ *text = stop; ++ return value; ++ } ++ ++ *text = NULL; ++ return -1; ++} ++ ++int dvbcfg_parse_setting(char **text, char *tokens, const struct dvbcfg_setting *settings) ++{ ++ char *start = *text; ++ char *stop = *text; ++ ++ while (*stop != '\0') { ++ if (strchr(tokens, *stop) != NULL) { ++ *stop = '\0'; ++ stop++; ++ break; ++ } ++ stop++; ++ } ++ ++ while (settings->name) { ++ if (strcmp(start, settings->name) == 0) { ++ *text = stop; ++ return settings->value; ++ } ++ settings++; ++ } ++ ++ *text = NULL; ++ return -1; ++} ++ ++void dvbcfg_parse_string(char **text, char *tokens, char *dest, unsigned long size) ++{ ++ char *start = *text; ++ char *stop = *text; ++ unsigned long length; ++ ++ while ((*stop != '\0') && (strchr(tokens, *stop) == NULL)) ++ stop++; ++ ++ length = (stop - start) + 1; ++ ++ if (length <= size) { ++ if (strchr(tokens, *stop) != NULL) { ++ *stop = '\0'; ++ *text = stop + 1; ++ } else ++ *text = stop; ++ memcpy(dest, start, length); ++ return; ++ } ++ ++ *text = NULL; ++ return; ++} ++ ++const char *dvbcfg_lookup_setting(unsigned int setting, const struct dvbcfg_setting *settings) ++{ ++ while (settings->name) { ++ if (setting == settings->value) ++ return settings->name; ++ settings++; ++ } ++ ++ return NULL; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbcfg/dvbcfg_common.h dvb-apps/lib/libdvbcfg/dvbcfg_common.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvbcfg/dvbcfg_common.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbcfg/dvbcfg_common.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,37 @@ ++/* ++ * dvbcfg - support for linuxtv configuration files ++ * common functions ++ * ++ * Copyright (C) 2006 Christoph Pfister ++ * Copyright (C) 2005 Andrew de Quincey ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef DVBCFG_COMMON_H ++#define DVBCFG_COMMON_H 1 ++ ++struct dvbcfg_setting { ++ const char *name; ++ unsigned int value; ++}; ++ ++extern int dvbcfg_parse_int(char **text, char *tokens); ++extern int dvbcfg_parse_char(char **text, char *tokens); ++extern int dvbcfg_parse_setting(char **text, char *tokens, const struct dvbcfg_setting *settings); ++extern void dvbcfg_parse_string(char **text, char *tokens, char *dest, unsigned long size); ++extern const char *dvbcfg_lookup_setting(unsigned int setting, const struct dvbcfg_setting *settings); ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbcfg/dvbcfg_scanfile.c dvb-apps/lib/libdvbcfg/dvbcfg_scanfile.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvbcfg/dvbcfg_scanfile.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbcfg/dvbcfg_scanfile.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,282 @@ ++/* ++ * dvbcfg - support for linuxtv configuration files ++ * scan channel file support ++ * ++ * Copyright (C) 2006 Christoph Pfister ++ * Copyright (C) 2005 Andrew de Quincey ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#define _GNU_SOURCE ++ ++#include ++#include ++ ++#include "dvbcfg_scanfile.h" ++#include "dvbcfg_common.h" ++ ++static const struct dvbcfg_setting dvbcfg_fec_list[] = { ++ { "1/2", DVBFE_FEC_1_2 }, ++ { "2/3", DVBFE_FEC_2_3 }, ++ { "3/4", DVBFE_FEC_3_4 }, ++ { "4/5", DVBFE_FEC_4_5 }, ++ { "5/6", DVBFE_FEC_5_6 }, ++ { "6/7", DVBFE_FEC_6_7 }, ++ { "7/8", DVBFE_FEC_7_8 }, ++ { "8/9", DVBFE_FEC_8_9 }, ++ { "AUTO", DVBFE_FEC_AUTO }, ++ { "NONE", DVBFE_FEC_NONE }, ++ { NULL, 0 } ++}; ++ ++static const struct dvbcfg_setting dvbcfg_dvbc_modulation_list[] = { ++ { "QAM16", DVBFE_DVBC_MOD_QAM_16 }, ++ { "QAM32", DVBFE_DVBC_MOD_QAM_32 }, ++ { "QAM64", DVBFE_DVBC_MOD_QAM_64 }, ++ { "QAM128", DVBFE_DVBC_MOD_QAM_128 }, ++ { "QAM256", DVBFE_DVBC_MOD_QAM_256 }, ++ { "AUTO", DVBFE_DVBC_MOD_AUTO }, ++ { NULL, 0 } ++}; ++ ++static const struct dvbcfg_setting dvbcfg_bandwidth_list[] = { ++ { "6MHz", DVBFE_DVBT_BANDWIDTH_6_MHZ }, ++ { "7MHz", DVBFE_DVBT_BANDWIDTH_7_MHZ }, ++ { "8MHz", DVBFE_DVBT_BANDWIDTH_8_MHZ }, ++ { "AUTO", DVBFE_DVBT_BANDWIDTH_AUTO }, ++ { NULL, 0 } ++}; ++ ++static const struct dvbcfg_setting dvbcfg_constellation_list[] = { ++ { "QAM16", DVBFE_DVBT_CONST_QAM_16 }, ++ { "QAM32", DVBFE_DVBT_CONST_QAM_32 }, ++ { "QAM64", DVBFE_DVBT_CONST_QAM_64 }, ++ { "QAM128", DVBFE_DVBT_CONST_QAM_128 }, ++ { "QAM256", DVBFE_DVBT_CONST_QAM_256 }, ++ { "QPSK", DVBFE_DVBT_CONST_QPSK }, ++ { "AUTO", DVBFE_DVBT_CONST_AUTO }, ++ { NULL, 0 } ++}; ++ ++static const struct dvbcfg_setting dvbcfg_transmission_mode_list[] = { ++ { "2k", DVBFE_DVBT_TRANSMISSION_MODE_2K }, ++ { "8k", DVBFE_DVBT_TRANSMISSION_MODE_8K }, ++ { "AUTO", DVBFE_DVBT_TRANSMISSION_MODE_AUTO }, ++ { NULL, 0 } ++}; ++ ++static const struct dvbcfg_setting dvbcfg_guard_interval_list[] = { ++ { "1/32", DVBFE_DVBT_GUARD_INTERVAL_1_32 }, ++ { "1/16", DVBFE_DVBT_GUARD_INTERVAL_1_16 }, ++ { "1/8", DVBFE_DVBT_GUARD_INTERVAL_1_8 }, ++ { "1/4", DVBFE_DVBT_GUARD_INTERVAL_1_4 }, ++ { "AUTO", DVBFE_DVBT_GUARD_INTERVAL_AUTO }, ++ { NULL, 0 } ++}; ++ ++static const struct dvbcfg_setting dvbcfg_hierarchy_list[] = { ++ { "1", DVBFE_DVBT_HIERARCHY_1 }, ++ { "2", DVBFE_DVBT_HIERARCHY_2 }, ++ { "4", DVBFE_DVBT_HIERARCHY_4 }, ++ { "AUTO", DVBFE_DVBT_HIERARCHY_AUTO }, ++ { "NONE", DVBFE_DVBT_HIERARCHY_NONE }, ++ { NULL, 0 } ++}; ++ ++static const struct dvbcfg_setting dvbcfg_atsc_modulation_list[] = { ++ { "8VSB", DVBFE_ATSC_MOD_VSB_8 }, ++ { "16VSB", DVBFE_ATSC_MOD_VSB_16 }, ++ { "QAM64", DVBFE_ATSC_MOD_QAM_64 }, ++ { "QAM256", DVBFE_ATSC_MOD_QAM_256 }, ++ { NULL, 0 } ++}; ++ ++int dvbcfg_scanfile_parse(FILE *file, dvbcfg_scancallback callback, void *private_data) ++{ ++ char *line_buf = NULL; ++ size_t line_size = 0; ++ int line_len = 0; ++ int ret_val = 0; ++ ++ while ((line_len = getline(&line_buf, &line_size, file)) > 0) { ++ char *line_tmp = line_buf; ++ char *line_pos = line_buf; ++ struct dvbcfg_scanfile tmp; ++ ++ /* remove newline and comments (started with hashes) */ ++ while ((*line_tmp != '\0') && (*line_tmp != '\n') && (*line_tmp != '#')) ++ line_tmp++; ++ *line_tmp = '\0'; ++ ++ /* always use inversion auto */ ++ tmp.fe_params.inversion = DVBFE_INVERSION_AUTO; ++ ++ /* parse frontend type */ ++ switch(dvbcfg_parse_char(&line_pos, " ")) { ++ case 'T': ++ tmp.fe_type = DVBFE_TYPE_DVBT; ++ break; ++ case 'C': ++ tmp.fe_type = DVBFE_TYPE_DVBC; ++ break; ++ case 'S': ++ tmp.fe_type = DVBFE_TYPE_DVBS; ++ break; ++ case 'A': ++ tmp.fe_type = DVBFE_TYPE_ATSC; ++ break; ++ default: ++ continue; ++ } ++ ++ /* parse frontend specific settings */ ++ switch (tmp.fe_type) { ++ case DVBFE_TYPE_ATSC: ++ ++ /* parse frequency */ ++ tmp.fe_params.frequency = dvbcfg_parse_int(&line_pos, " "); ++ if (!line_pos) ++ continue; ++ ++ /* modulation */ ++ tmp.fe_params.u.atsc.modulation = ++ dvbcfg_parse_setting(&line_pos, " ", dvbcfg_atsc_modulation_list); ++ if (!line_pos) ++ continue; ++ ++ break; ++ ++ case DVBFE_TYPE_DVBC: ++ ++ /* parse frequency */ ++ tmp.fe_params.frequency = dvbcfg_parse_int(&line_pos, " "); ++ if (!line_pos) ++ continue; ++ ++ /* symbol rate */ ++ tmp.fe_params.u.dvbc.symbol_rate = dvbcfg_parse_int(&line_pos, " "); ++ if (!line_pos) ++ continue; ++ ++ /* fec */ ++ tmp.fe_params.u.dvbc.fec_inner = ++ dvbcfg_parse_setting(&line_pos, " ", dvbcfg_fec_list); ++ if (!line_pos) ++ continue; ++ ++ /* modulation */ ++ tmp.fe_params.u.dvbc.modulation = ++ dvbcfg_parse_setting(&line_pos, " ", dvbcfg_dvbc_modulation_list); ++ if (!line_pos) ++ continue; ++ ++ break; ++ ++ case DVBFE_TYPE_DVBS: ++ ++ /* parse frequency */ ++ tmp.fe_params.frequency = dvbcfg_parse_int(&line_pos, " "); ++ if (!line_pos) ++ continue; ++ ++ /* polarization */ ++ tmp.polarization = tolower(dvbcfg_parse_char(&line_pos, " ")); ++ if (!line_pos) ++ continue; ++ if ((tmp.polarization != 'h') && ++ (tmp.polarization != 'v') && ++ (tmp.polarization != 'l') && ++ (tmp.polarization != 'r')) ++ continue; ++ ++ /* symbol rate */ ++ tmp.fe_params.u.dvbs.symbol_rate = dvbcfg_parse_int(&line_pos, " "); ++ if (!line_pos) ++ continue; ++ ++ /* fec */ ++ tmp.fe_params.u.dvbc.fec_inner = ++ dvbcfg_parse_setting(&line_pos, " ", dvbcfg_fec_list); ++ if (!line_pos) ++ continue; ++ ++ break; ++ ++ case DVBFE_TYPE_DVBT: ++ ++ /* parse frequency */ ++ tmp.fe_params.frequency = dvbcfg_parse_int(&line_pos, " "); ++ if (!line_pos) ++ continue; ++ ++ /* bandwidth */ ++ tmp.fe_params.u.dvbt.bandwidth = ++ dvbcfg_parse_setting(&line_pos, " ", dvbcfg_bandwidth_list); ++ if (!line_pos) ++ continue; ++ ++ /* fec hp */ ++ tmp.fe_params.u.dvbt.code_rate_HP = ++ dvbcfg_parse_setting(&line_pos, " ", dvbcfg_fec_list); ++ if (!line_pos) ++ continue; ++ ++ /* fec lp */ ++ tmp.fe_params.u.dvbt.code_rate_LP = ++ dvbcfg_parse_setting(&line_pos, " ", dvbcfg_fec_list); ++ if (!line_pos) ++ continue; ++ ++ /* constellation */ ++ tmp.fe_params.u.dvbt.constellation = ++ dvbcfg_parse_setting(&line_pos, " ", dvbcfg_constellation_list); ++ if (!line_pos) ++ continue; ++ ++ /* transmission mode */ ++ tmp.fe_params.u.dvbt.transmission_mode = ++ dvbcfg_parse_setting(&line_pos, " ", dvbcfg_transmission_mode_list); ++ if (!line_pos) ++ continue; ++ ++ /* guard interval */ ++ tmp.fe_params.u.dvbt.guard_interval = ++ dvbcfg_parse_setting(&line_pos, " ", dvbcfg_guard_interval_list); ++ if (!line_pos) ++ continue; ++ ++ /* hierarchy */ ++ tmp.fe_params.u.dvbt.hierarchy_information = ++ dvbcfg_parse_setting(&line_pos, " ", dvbcfg_hierarchy_list); ++ if (!line_pos) ++ continue; ++ ++ break; ++ } ++ ++ /* invoke callback */ ++ if ((ret_val = callback(&tmp, private_data)) != 0) { ++ if (ret_val < 0) ++ ret_val = 0; ++ break; ++ } ++ } ++ ++ if (line_buf) ++ free(line_buf); ++ ++ return ret_val; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbcfg/dvbcfg_scanfile.h dvb-apps/lib/libdvbcfg/dvbcfg_scanfile.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvbcfg/dvbcfg_scanfile.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbcfg/dvbcfg_scanfile.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,61 @@ ++/* ++ * dvbcfg - support for linuxtv configuration files ++ * scan channel file support ++ * ++ * Copyright (C) 2006 Andrew de Quincey ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef DVBCFG_SCANFILE_H ++#define DVBCFG_SCANFILE_H ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++ ++struct dvbcfg_scanfile { ++ enum dvbfe_type fe_type; ++ struct dvbfe_parameters fe_params; ++ char polarization; /* l,r,v,h - only used for dvb-s */ ++}; ++ ++/** ++ * Callback used in dvbcfg_scanfile_parse() ++ * ++ * @param channel Selected channel ++ * @param private_data Private data for the callback ++ * @return 0 to continue, other values to stop (values > 0 are forwarded; see below) ++ */ ++typedef int (*dvbcfg_scancallback)(struct dvbcfg_scanfile *channel, void *private_data); ++ ++/** ++ * Parse a linuxtv scan file ++ * ++ * @param file Linuxtv scan file ++ * @param callback Callback called for each scan entry ++ * @param private_data Private data for the callback ++ * @return on success 0 or value from the callback if it's > 0, error code on failure ++ */ ++extern int dvbcfg_scanfile_parse(FILE *file, dvbcfg_scancallback callback, void *private_data); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* DVBCFG_SCANFILE_H */ +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbcfg/dvbcfg_zapchannel.c dvb-apps/lib/libdvbcfg/dvbcfg_zapchannel.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvbcfg/dvbcfg_zapchannel.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbcfg/dvbcfg_zapchannel.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,384 @@ ++/* ++ * dvbcfg - support for linuxtv configuration files ++ * zap channel file support ++ * ++ * Copyright (C) 2006 Christoph Pfister ++ * Copyright (C) 2005 Andrew de Quincey ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#define _GNU_SOURCE ++ ++#include ++#include ++#include ++ ++#include "dvbcfg_zapchannel.h" ++#include "dvbcfg_common.h" ++ ++static const struct dvbcfg_setting dvbcfg_inversion_list[] = { ++ { "INVERSION_ON", DVBFE_INVERSION_ON }, ++ { "INVERSION_OFF", DVBFE_INVERSION_OFF }, ++ { "INVERSION_AUTO", DVBFE_INVERSION_AUTO }, ++ { NULL, 0 } ++}; ++ ++static const struct dvbcfg_setting dvbcfg_fec_list[] = { ++ { "FEC_1_2", DVBFE_FEC_1_2 }, ++ { "FEC_2_3", DVBFE_FEC_2_3 }, ++ { "FEC_3_4", DVBFE_FEC_3_4 }, ++ { "FEC_4_5", DVBFE_FEC_4_5 }, ++ { "FEC_5_6", DVBFE_FEC_5_6 }, ++ { "FEC_6_7", DVBFE_FEC_6_7 }, ++ { "FEC_7_8", DVBFE_FEC_7_8 }, ++ { "FEC_8_9", DVBFE_FEC_8_9 }, ++ { "FEC_AUTO", DVBFE_FEC_AUTO }, ++ { "FEC_NONE", DVBFE_FEC_NONE }, ++ { NULL, 0 } ++}; ++ ++static const struct dvbcfg_setting dvbcfg_dvbc_modulation_list[] = { ++ { "QAM_16", DVBFE_DVBC_MOD_QAM_16 }, ++ { "QAM_32", DVBFE_DVBC_MOD_QAM_32 }, ++ { "QAM_64", DVBFE_DVBC_MOD_QAM_64 }, ++ { "QAM_128", DVBFE_DVBC_MOD_QAM_128 }, ++ { "QAM_256", DVBFE_DVBC_MOD_QAM_256 }, ++ { "QAM_AUTO", DVBFE_DVBC_MOD_AUTO }, ++ { NULL, 0 } ++}; ++ ++static const struct dvbcfg_setting dvbcfg_bandwidth_list[] = { ++ { "BANDWIDTH_6_MHZ", DVBFE_DVBT_BANDWIDTH_6_MHZ }, ++ { "BANDWIDTH_7_MHZ", DVBFE_DVBT_BANDWIDTH_7_MHZ }, ++ { "BANDWIDTH_8_MHZ", DVBFE_DVBT_BANDWIDTH_8_MHZ }, ++ { "BANDWIDTH_AUTO", DVBFE_DVBT_BANDWIDTH_AUTO }, ++ { NULL, 0 } ++}; ++ ++static const struct dvbcfg_setting dvbcfg_constellation_list[] = { ++ { "QAM_16", DVBFE_DVBT_CONST_QAM_16 }, ++ { "QAM_32", DVBFE_DVBT_CONST_QAM_32 }, ++ { "QAM_64", DVBFE_DVBT_CONST_QAM_64 }, ++ { "QAM_128", DVBFE_DVBT_CONST_QAM_128 }, ++ { "QAM_256", DVBFE_DVBT_CONST_QAM_256 }, ++ { "QPSK", DVBFE_DVBT_CONST_QPSK }, ++ { "QAM_AUTO", DVBFE_DVBT_CONST_AUTO }, ++ { NULL, 0 } ++}; ++ ++static const struct dvbcfg_setting dvbcfg_transmission_mode_list[] = { ++ { "TRANSMISSION_MODE_2K", DVBFE_DVBT_TRANSMISSION_MODE_2K }, ++ { "TRANSMISSION_MODE_8K", DVBFE_DVBT_TRANSMISSION_MODE_8K }, ++ { "TRANSMISSION_MODE_AUTO", DVBFE_DVBT_TRANSMISSION_MODE_AUTO }, ++ { NULL, 0 } ++}; ++ ++static const struct dvbcfg_setting dvbcfg_guard_interval_list[] = { ++ { "GUARD_INTERVAL_1_32", DVBFE_DVBT_GUARD_INTERVAL_1_32 }, ++ { "GUARD_INTERVAL_1_16", DVBFE_DVBT_GUARD_INTERVAL_1_16 }, ++ { "GUARD_INTERVAL_1_8", DVBFE_DVBT_GUARD_INTERVAL_1_8 }, ++ { "GUARD_INTERVAL_1_4", DVBFE_DVBT_GUARD_INTERVAL_1_4 }, ++ { "GUARD_INTERVAL_AUTO", DVBFE_DVBT_GUARD_INTERVAL_AUTO }, ++ { NULL, 0 } ++}; ++ ++static const struct dvbcfg_setting dvbcfg_hierarchy_list[] = { ++ { "HIERARCHY_1", DVBFE_DVBT_HIERARCHY_1 }, ++ { "HIERARCHY_2", DVBFE_DVBT_HIERARCHY_2 }, ++ { "HIERARCHY_4", DVBFE_DVBT_HIERARCHY_4 }, ++ { "HIERARCHY_AUTO", DVBFE_DVBT_HIERARCHY_AUTO }, ++ { "HIERARCHY_NONE", DVBFE_DVBT_HIERARCHY_NONE }, ++ { NULL, 0 } ++}; ++ ++static const struct dvbcfg_setting dvbcfg_atsc_modulation_list[] = { ++ { "8VSB", DVBFE_ATSC_MOD_VSB_8 }, ++ { "16VSB", DVBFE_ATSC_MOD_VSB_16 }, ++ { "QAM_64", DVBFE_ATSC_MOD_QAM_64 }, ++ { "QAM_256", DVBFE_ATSC_MOD_QAM_256 }, ++ { NULL, 0 } ++}; ++ ++int dvbcfg_zapchannel_parse(FILE *file, dvbcfg_zapcallback callback, void *private_data) ++{ ++ char *line_buf = NULL; ++ size_t line_size = 0; ++ int line_len = 0; ++ int ret_val = 0; ++ ++ while ((line_len = getline(&line_buf, &line_size, file)) > 0) { ++ char *line_tmp = line_buf; ++ char *line_pos = line_buf; ++ struct dvbcfg_zapchannel tmp; ++ ++ /* remove newline and comments (started with hashes) */ ++ while ((*line_tmp != '\0') && (*line_tmp != '\n') && (*line_tmp != '#')) ++ line_tmp++; ++ *line_tmp = '\0'; ++ ++ /* parse name */ ++ dvbcfg_parse_string(&line_pos, ":", tmp.name, sizeof(tmp.name)); ++ if (!line_pos) ++ continue; ++ ++ /* parse frequency */ ++ tmp.fe_params.frequency = dvbcfg_parse_int(&line_pos, ":"); ++ if (!line_pos) ++ continue; ++ ++ /* try to determine frontend type */ ++ if (strstr(line_pos, ":FEC_")) { ++ if (strstr(line_pos, ":HIERARCHY_")) ++ tmp.fe_type = DVBFE_TYPE_DVBT; ++ else ++ tmp.fe_type = DVBFE_TYPE_DVBC; ++ } else { ++ if (strstr(line_pos, "VSB:") || strstr(line_pos, "QAM_")) ++ tmp.fe_type = DVBFE_TYPE_ATSC; ++ else ++ tmp.fe_type = DVBFE_TYPE_DVBS; ++ } ++ ++ /* parse frontend specific settings */ ++ switch (tmp.fe_type) { ++ case DVBFE_TYPE_ATSC: ++ /* inversion */ ++ tmp.fe_params.inversion = DVBFE_INVERSION_AUTO; ++ ++ /* modulation */ ++ tmp.fe_params.u.atsc.modulation = ++ dvbcfg_parse_setting(&line_pos, ":", dvbcfg_atsc_modulation_list); ++ if (!line_pos) ++ continue; ++ ++ break; ++ ++ case DVBFE_TYPE_DVBC: ++ /* inversion */ ++ tmp.fe_params.inversion = ++ dvbcfg_parse_setting(&line_pos, ":", dvbcfg_inversion_list); ++ if (!line_pos) ++ continue; ++ ++ /* symbol rate */ ++ tmp.fe_params.u.dvbc.symbol_rate = dvbcfg_parse_int(&line_pos, ":"); ++ if (!line_pos) ++ continue; ++ ++ /* fec */ ++ tmp.fe_params.u.dvbc.fec_inner = ++ dvbcfg_parse_setting(&line_pos, ":", dvbcfg_fec_list); ++ if (!line_pos) ++ continue; ++ ++ /* modulation */ ++ tmp.fe_params.u.dvbc.modulation = ++ dvbcfg_parse_setting(&line_pos, ":", dvbcfg_dvbc_modulation_list); ++ if (!line_pos) ++ continue; ++ ++ break; ++ ++ case DVBFE_TYPE_DVBS: ++ /* adjust frequency */ ++ tmp.fe_params.frequency *= 1000; ++ ++ /* inversion */ ++ tmp.fe_params.inversion = DVBFE_INVERSION_AUTO; ++ ++ /* fec */ ++ tmp.fe_params.u.dvbs.fec_inner = DVBFE_FEC_AUTO; ++ ++ /* polarization */ ++ tmp.polarization = tolower(dvbcfg_parse_char(&line_pos, ":")); ++ if (!line_pos) ++ continue; ++ if ((tmp.polarization != 'h') && ++ (tmp.polarization != 'v') && ++ (tmp.polarization != 'l') && ++ (tmp.polarization != 'r')) ++ continue; ++ ++ /* satellite switch position */ ++ tmp.diseqc_switch = dvbcfg_parse_int(&line_pos, ":"); ++ if (!line_pos) ++ continue; ++ ++ /* symbol rate */ ++ tmp.fe_params.u.dvbs.symbol_rate = ++ dvbcfg_parse_int(&line_pos, ":") * 1000; ++ if (!line_pos) ++ continue; ++ ++ break; ++ ++ case DVBFE_TYPE_DVBT: ++ /* inversion */ ++ tmp.fe_params.inversion = ++ dvbcfg_parse_setting(&line_pos, ":", dvbcfg_inversion_list); ++ if (!line_pos) ++ continue; ++ ++ /* bandwidth */ ++ tmp.fe_params.u.dvbt.bandwidth = ++ dvbcfg_parse_setting(&line_pos, ":", dvbcfg_bandwidth_list); ++ if (!line_pos) ++ continue; ++ ++ /* fec hp */ ++ tmp.fe_params.u.dvbt.code_rate_HP = ++ dvbcfg_parse_setting(&line_pos, ":", dvbcfg_fec_list); ++ if (!line_pos) ++ continue; ++ ++ /* fec lp */ ++ tmp.fe_params.u.dvbt.code_rate_LP = ++ dvbcfg_parse_setting(&line_pos, ":", dvbcfg_fec_list); ++ if (!line_pos) ++ continue; ++ ++ /* constellation */ ++ tmp.fe_params.u.dvbt.constellation = ++ dvbcfg_parse_setting(&line_pos, ":", dvbcfg_constellation_list); ++ if (!line_pos) ++ continue; ++ ++ /* transmission mode */ ++ tmp.fe_params.u.dvbt.transmission_mode = ++ dvbcfg_parse_setting(&line_pos, ":", dvbcfg_transmission_mode_list); ++ if (!line_pos) ++ continue; ++ ++ /* guard interval */ ++ tmp.fe_params.u.dvbt.guard_interval = ++ dvbcfg_parse_setting(&line_pos, ":", dvbcfg_guard_interval_list); ++ if (!line_pos) ++ continue; ++ ++ /* hierarchy */ ++ tmp.fe_params.u.dvbt.hierarchy_information = ++ dvbcfg_parse_setting(&line_pos, ":", dvbcfg_hierarchy_list); ++ if (!line_pos) ++ continue; ++ ++ break; ++ } ++ ++ /* parse video and audio pids and service id */ ++ tmp.video_pid = dvbcfg_parse_int(&line_pos, ":"); ++ if (!line_pos) ++ continue; ++ tmp.audio_pid = dvbcfg_parse_int(&line_pos, ":"); ++ if (!line_pos) ++ continue; ++ tmp.service_id = dvbcfg_parse_int(&line_pos, ":"); ++ if (!line_pos) /* old files don't have a service id */ ++ tmp.service_id = 0; ++ ++ /* invoke callback */ ++ if ((ret_val = callback(&tmp, private_data)) != 0) { ++ if (ret_val < 0) ++ ret_val = 0; ++ break; ++ } ++ } ++ ++ if (line_buf) ++ free(line_buf); ++ ++ return ret_val; ++} ++ ++int dvbcfg_zapchannel_save(FILE *file, dvbcfg_zapcallback callback, void *private_data) ++{ ++ int ret_val = 0; ++ struct dvbcfg_zapchannel tmp; ++ ++ while ((ret_val = callback(&tmp, private_data)) == 0) { ++ /* name */ ++ if ((ret_val = fprintf(file, "%s:", tmp.name)) < 0) ++ return ret_val; ++ ++ /* frontend specific settings */ ++ switch (tmp.fe_type) { ++ case DVBFE_TYPE_ATSC: ++ if ((ret_val = fprintf(file, "%i:%s:", ++ tmp.fe_params.frequency, ++ dvbcfg_lookup_setting(tmp.fe_params.u.atsc.modulation, ++ dvbcfg_atsc_modulation_list))) < 0) ++ return ret_val; ++ ++ break; ++ ++ case DVBFE_TYPE_DVBC: ++ if ((ret_val = fprintf(file, "%i:%s:%i:%s:%s:", ++ tmp.fe_params.frequency, ++ dvbcfg_lookup_setting(tmp.fe_params.inversion, ++ dvbcfg_inversion_list), ++ tmp.fe_params.u.dvbc.symbol_rate, ++ dvbcfg_lookup_setting(tmp.fe_params.u.dvbc.fec_inner, ++ dvbcfg_fec_list), ++ dvbcfg_lookup_setting(tmp.fe_params.u.dvbc.modulation, ++ dvbcfg_dvbc_modulation_list))) < 0) ++ return ret_val; ++ ++ break; ++ ++ case DVBFE_TYPE_DVBS: ++ if ((ret_val = fprintf(file, "%i:%c:%i:%i:", ++ tmp.fe_params.frequency / 1000, ++ tolower(tmp.polarization), ++ tmp.diseqc_switch, ++ tmp.fe_params.u.dvbs.symbol_rate / 1000)) < 0) ++ return ret_val; ++ ++ break; ++ case DVBFE_TYPE_DVBT: ++ if ((ret_val = fprintf(file, "%i:%s:%s:%s:%s:%s:%s:%s:%s:", ++ tmp.fe_params.frequency, ++ dvbcfg_lookup_setting(tmp.fe_params.inversion, ++ dvbcfg_inversion_list), ++ dvbcfg_lookup_setting(tmp.fe_params.u.dvbt.bandwidth, ++ dvbcfg_bandwidth_list), ++ dvbcfg_lookup_setting(tmp.fe_params.u.dvbt.code_rate_HP, ++ dvbcfg_fec_list), ++ dvbcfg_lookup_setting(tmp.fe_params.u.dvbt.code_rate_LP, ++ dvbcfg_fec_list), ++ dvbcfg_lookup_setting(tmp.fe_params.u.dvbt.constellation, ++ dvbcfg_constellation_list), ++ dvbcfg_lookup_setting(tmp.fe_params.u.dvbt.transmission_mode, ++ dvbcfg_transmission_mode_list), ++ dvbcfg_lookup_setting(tmp.fe_params.u.dvbt.guard_interval, ++ dvbcfg_guard_interval_list), ++ dvbcfg_lookup_setting(tmp.fe_params.u.dvbt.hierarchy_information, ++ dvbcfg_hierarchy_list))) < 0) ++ return ret_val; ++ ++ break; ++ } ++ ++ /* video and audio pids and service id */ ++ if ((ret_val = fprintf(file, "%i:%i:%i\n", ++ tmp.video_pid, tmp.audio_pid, tmp.service_id)) < 0) ++ return ret_val; ++ ++ } ++ ++ if (ret_val < 0) ++ ret_val = 0; ++ ++ return ret_val; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbcfg/dvbcfg_zapchannel.h dvb-apps/lib/libdvbcfg/dvbcfg_zapchannel.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvbcfg/dvbcfg_zapchannel.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbcfg/dvbcfg_zapchannel.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,77 @@ ++/* ++ * dvbcfg - support for linuxtv configuration files ++ * zap channel file support ++ * ++ * Copyright (C) 2006 Christoph Pfister ++ * Copyright (C) 2005 Andrew de Quincey ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef DVBCFG_ZAPCHANNEL_H ++#define DVBCFG_ZAPCHANNEL_H ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++ ++struct dvbcfg_zapchannel { ++ char name[128]; ++ int video_pid; ++ int audio_pid; ++ int service_id; ++ enum dvbfe_type fe_type; ++ struct dvbfe_parameters fe_params; ++ char polarization; /* l,r,v,h - only used for dvb-s */ ++ int diseqc_switch; /* only used for dvb-s */ ++}; ++ ++/** ++ * Callback used in dvbcfg_zapchannel_parse() and dvbcfg_zapchannel_save() ++ * ++ * @param channel Selected channel ++ * @param private_data Private data for the callback ++ * @return 0 to continue, other values to stop (values > 0 are forwarded; see below) ++ */ ++typedef int (*dvbcfg_zapcallback)(struct dvbcfg_zapchannel *channel, void *private_data); ++ ++/** ++ * Parse a linuxtv channel file ++ * ++ * @param file Linuxtv channel file ++ * @param callback Callback called for each channel ++ * @param private_data Private data for the callback ++ * @return on success 0 or value from the callback if it's > 0, error code on failure ++ */ ++extern int dvbcfg_zapchannel_parse(FILE *file, dvbcfg_zapcallback callback, void *private_data); ++ ++/** ++ * Save to a linuxtv channel file ++ * ++ * @param file Linuxtv channel file ++ * @param callback Callback called for each channel ++ * @param private_data Private data for the callback ++ * @return on success 0 or value from the callback if it's > 0, error code on failure ++ */ ++extern int dvbcfg_zapchannel_save(FILE *file, dvbcfg_zapcallback callback, void *private_data); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* DVBCFG_ZAPCHANNEL_H */ +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbcfg/Makefile dvb-apps/lib/libdvbcfg/Makefile +--- linuxtv-dvb-apps-1.1.1/lib/libdvbcfg/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbcfg/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,18 @@ ++# Makefile for linuxtv.org dvb-apps/lib/libdvbcfg ++ ++includes = dvbcfg_zapchannel.h \ ++ dvbcfg_scanfile.h ++ ++objects = dvbcfg_zapchannel.o \ ++ dvbcfg_scanfile.o \ ++ dvbcfg_common.o ++ ++lib_name = libdvbcfg ++ ++CPPFLAGS += -I../../lib ++ ++.PHONY: all ++ ++all: library ++ ++include ../../Make.rules +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbcfg/zapchannel.txt dvb-apps/lib/libdvbcfg/zapchannel.txt +--- linuxtv-dvb-apps-1.1.1/lib/libdvbcfg/zapchannel.txt 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbcfg/zapchannel.txt 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,72 @@ ++/** ++ * The zapchannel file format specifies tuning parameters for channels. Each line describes ++ * a single channel, and consists of multiple options separated by ':'. The exact ++ * format of each line depends on the DVB type of the channel (i.e. DVBS, DVBT, DVBC, or ATSC). ++ * ++ * Note: the lines have been split across multiple lines in the following due to length issues. ++ * ++ * The format for DVBT channels is: ++ * ++ * :::::: ++ * :::: ++ * :: ++ * ++ * name: name of the channel ++ * frequency: frequency in Hz ++ * inversion: one of INVERSION_OFF, INVERSION_ON, or INVERSION_AUTO. ++ * bandwidth: one of BANDWIDTH_6_MHZ, BANDWIDTH_7_MHZ, or BANDWIDTH_8_MHZ. ++ * fec_hp: FEC of the high priority stream, one of: FEC_1_2, FEC_2_3, ++ * FEC_3_4, FEC_4_5, FEC_5_6, FEC_6_7, FEC_7_8, FEC_8_9, or FEC_AUTO. ++ * fec_lp: FEC of the low priority stream, one of: FEC_1_2, FEC_2_3, ++ * FEC_3_4, FEC_4_5, FEC_5_6, FEC_6_7, FEC_7_8, FEC_8_9, FEC_AUTO, or FEC_NONE. ++ * constellation: one of QPSK, QAM_128, QAM_16, QAM_256, QAM_32, or QAM_64. ++ * transmission: one of TRANSMISSION_MODE_2K, or TRANSMISSION_MODE_8K. ++ * guard_interval: one of GUARD_INTERVAL_1_32, GUARD_INTERVAL_1_16, GUARD_INTERVAL_1_8, or GUARD_INTERVAL_1_4. ++ * hierarchy: one of HIERARCHY_NONE, HIERARCHY_1, HIERARCHY_2, or HIERARCHY_4. ++ * video_pid: PID of the video stream. ++ * audio_pid: PID of the audio stream. ++ * channel_number: Transport stream channel number of the program. ++ * ++ * DVBC: ++ * ++ * ::::: ++ * ::: ++ * ++ * name: name of the channel ++ * frequency: frequency in Hz ++ * inversion: one of INVERSION_OFF, INVERSION_ON, or INVERSION_AUTO. ++ * symbol_rate: Symbol rate of the channel in ksyms. ++ * fec: One of: FEC_1_2, FEC_2_3, FEC_3_4, FEC_4_5, FEC_5_6, FEC_6_7, ++ * FEC_7_8, FEC_8_9, or FEC_AUTO. ++ * modulation: one of QAM_16, QAM_32, QAM_64, QAM_128, QAM_256, QAM_AUTO. ++ * video_pid: PID of the video stream. ++ * audio_pid: PID of the audio stream. ++ * channel_number: Transport stream channel number of the program. ++ * ++ * DVBS: ++ * ++ * ::::::: ++ * ++ * name: name of the channel ++ * frequency: frequency in kHz ++ * polarization: one of H,V,L, or R. ++ * satellite_switches: Treated as a 2 bit value controlling switches in SEC equipment: ++ * bit 0: controls "satellite switch", 0: A, 1: B ++ * bit 1: controls "switch option", 0: A, 1: B ++ * symbol_rate: Symbol rate of the channel in ksyms. ++ * video_pid: PID of the video stream. ++ * audio_pid: PID of the audio stream. ++ * channel_number: Transport stream channel number of the program. ++ * ++ * ATSC: ++ * ++ * :::::: ++ * ++ * name: name of the channel ++ * frequency: frequency in GHz ++ * inversion: one of INVERSION_OFF, INVERSION_ON, or INVERSION_AUTO. ++ * modulation: one of 8VSB, 16VSB, QAM_64, or QAM_256. ++ * video_pid: PID of the video stream. ++ * audio_pid: PID of the audio stream. ++ * channel_number: Transport stream channel number of the program. ++ */ +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/asn_1.c dvb-apps/lib/libdvben50221/asn_1.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/asn_1.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/asn_1.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,83 @@ ++/* ++ ASN.1 routines, implementation for libdvben50221 ++ an implementation for the High Level Common Interface ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include "asn_1.h" ++ ++int asn_1_decode(uint16_t * length, uint8_t * asn_1_array, ++ uint32_t asn_1_array_len) ++{ ++ uint8_t length_field; ++ ++ if (asn_1_array_len < 1) ++ return -1; ++ length_field = asn_1_array[0]; ++ ++ if (length_field < 0x80) { ++ // there is only one word ++ *length = length_field & 0x7f; ++ return 1; ++ } else if (length_field == 0x81) { ++ if (asn_1_array_len < 2) ++ return -1; ++ ++ *length = asn_1_array[1]; ++ return 2; ++ } else if (length_field == 0x82) { ++ if (asn_1_array_len < 3) ++ return -1; ++ ++ *length = (asn_1_array[1] << 8) | asn_1_array[2]; ++ return 3; ++ } ++ ++ return -1; ++} ++ ++int asn_1_encode(uint16_t length, uint8_t * asn_1_array, ++ uint32_t asn_1_array_len) ++{ ++ if (length < 0x80) { ++ if (asn_1_array_len < 1) ++ return -1; ++ ++ asn_1_array[0] = length & 0x7f; ++ return 1; ++ } else if (length < 0x100) { ++ if (asn_1_array_len < 2) ++ return -1; ++ ++ asn_1_array[0] = 0x81; ++ asn_1_array[1] = length; ++ return 2; ++ } else { ++ if (asn_1_array_len < 3) ++ return -1; ++ ++ asn_1_array[0] = 0x82; ++ asn_1_array[1] = length >> 8; ++ asn_1_array[2] = length; ++ return 3; ++ } ++ ++ // never reached ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/asn_1.h dvb-apps/lib/libdvben50221/asn_1.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/asn_1.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/asn_1.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,41 @@ ++/* ++ ASN.1 routines, implementation for libdvben50221 ++ an implementation for the High Level Common Interface ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#ifndef __ASN_1_H__ ++#define __ASN_1_H__ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++ ++int asn_1_decode(uint16_t * length, uint8_t * asn_1_array, ++ uint32_t asn_1_array_len); ++int asn_1_encode(uint16_t length, uint8_t * asn_1_array, ++ uint32_t asn_1_array_len); ++ ++#ifdef __cplusplus ++} ++#endif ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_ai.c dvb-apps/lib/libdvben50221/en50221_app_ai.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_ai.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_ai.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,191 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include "en50221_app_ai.h" ++#include "en50221_app_tags.h" ++#include "asn_1.h" ++ ++struct en50221_app_ai { ++ struct en50221_app_send_functions *funcs; ++ ++ en50221_app_ai_callback callback; ++ void *callback_arg; ++ ++ pthread_mutex_t lock; ++}; ++ ++static int en50221_app_ai_parse_app_info(struct en50221_app_ai *ai, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++ ++ ++struct en50221_app_ai *en50221_app_ai_create(struct en50221_app_send_functions *funcs) ++{ ++ struct en50221_app_ai *ai = NULL; ++ ++ // create structure and set it up ++ ai = malloc(sizeof(struct en50221_app_ai)); ++ if (ai == NULL) { ++ return NULL; ++ } ++ ai->funcs = funcs; ++ ai->callback = NULL; ++ ++ pthread_mutex_init(&ai->lock, NULL); ++ ++ // done ++ return ai; ++} ++ ++void en50221_app_ai_destroy(struct en50221_app_ai *ai) ++{ ++ pthread_mutex_destroy(&ai->lock); ++ free(ai); ++} ++ ++void en50221_app_ai_register_callback(struct en50221_app_ai *ai, ++ en50221_app_ai_callback callback, ++ void *arg) ++{ ++ pthread_mutex_lock(&ai->lock); ++ ai->callback = callback; ++ ai->callback_arg = arg; ++ pthread_mutex_unlock(&ai->lock); ++} ++ ++int en50221_app_ai_enquiry(struct en50221_app_ai *ai, ++ uint16_t session_number) ++{ ++ uint8_t data[4]; ++ ++ data[0] = (TAG_APP_INFO_ENQUIRY >> 16) & 0xFF; ++ data[1] = (TAG_APP_INFO_ENQUIRY >> 8) & 0xFF; ++ data[2] = TAG_APP_INFO_ENQUIRY & 0xFF; ++ data[3] = 0; ++ ++ return ai->funcs->send_data(ai->funcs->arg, session_number, data, 4); ++} ++ ++int en50221_app_ai_entermenu(struct en50221_app_ai *ai, ++ uint16_t session_number) ++{ ++ uint8_t data[4]; ++ ++ data[0] = (TAG_ENTER_MENU >> 16) & 0xFF; ++ data[1] = (TAG_ENTER_MENU >> 8) & 0xFF; ++ data[2] = TAG_ENTER_MENU & 0xFF; ++ data[3] = 0; ++ ++ return ai->funcs->send_data(ai->funcs->arg, session_number, data, 4); ++} ++ ++int en50221_app_ai_message(struct en50221_app_ai *ai, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t * data, uint32_t data_length) ++{ ++ (void) resource_id; ++ ++ // get the tag ++ if (data_length < 3) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint32_t tag = (data[0] << 16) | (data[1] << 8) | data[2]; ++ ++ switch (tag) { ++ case TAG_APP_INFO: ++ return en50221_app_ai_parse_app_info(ai, slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ } ++ ++ print(LOG_LEVEL, ERROR, 1, "Received unexpected tag %x\n", tag); ++ return -1; ++} ++ ++ ++ ++ ++ ++ ++ ++static int en50221_app_ai_parse_app_info(struct en50221_app_ai *ai, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ // parse the length field ++ int length_field_len; ++ uint16_t asn_data_length; ++ if ((length_field_len = asn_1_decode(&asn_data_length, data, data_length)) < 0) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received data with invalid length from module on slot %02x\n", ++ slot_id); ++ return -1; ++ } ++ // check it ++ if (asn_data_length < 6) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (asn_data_length > (data_length - length_field_len)) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint8_t *app_info = data + length_field_len; ++ ++ // parse the fields ++ uint8_t application_type = app_info[0]; ++ uint16_t application_manufacturer = (app_info[1] << 8) | app_info[2]; ++ uint16_t manufacturer_code = (app_info[3] << 8) | app_info[4]; ++ uint8_t menu_string_length = app_info[5]; ++ uint8_t *menu_string = app_info + 6; ++ ++ // check the menu_string_length ++ if (menu_string_length > (asn_data_length - 6)) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received bad menu string length - adjusting\n"); ++ menu_string_length = asn_data_length - 6; ++ } ++ // tell the app ++ pthread_mutex_lock(&ai->lock); ++ en50221_app_ai_callback cb = ai->callback; ++ void *cb_arg = ai->callback_arg; ++ pthread_mutex_unlock(&ai->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, ++ application_type, application_manufacturer, ++ manufacturer_code, menu_string_length, ++ menu_string); ++ } ++ return 0; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_ai.h dvb-apps/lib/libdvben50221/en50221_app_ai.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_ai.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_ai.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,136 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#ifndef __EN50221_APPLICATION_AI_H__ ++#define __EN50221_APPLICATION_AI_H__ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++ ++#define EN50221_APP_AI_RESOURCEID MKRID(2,1,1) ++ ++#define APPLICATION_TYPE_CA 0x01 ++#define APPLICATION_TYPE_EPG 0x02 ++ ++/** ++ * Type definition for application callback function - called when we receive ++ * an application info object. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Resource id concerned. ++ * @param application_type Type of application. ++ * @param application_manufacturer Manufacturer of application. ++ * @param manufacturer_code Manufacturer specific code. ++ * @param menu_string_length Length of menu string. ++ * @param menu_string The menu string itself. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_ai_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t application_type, ++ uint16_t application_manufacturer, ++ uint16_t manufacturer_code, ++ uint8_t menu_string_length, ++ uint8_t * menu_string); ++ ++/** ++ * Opaque type representing an application information resource. ++ */ ++struct en50221_app_ai; ++ ++/** ++ * Create an instance of an application information resource. ++ * ++ * @param funcs Send functions to use. ++ * @return Instance, or NULL on failure. ++ */ ++extern struct en50221_app_ai *en50221_app_ai_create(struct en50221_app_send_functions *funcs); ++ ++/** ++ * Destroy an instance of an application information resource. ++ * ++ * @param ai Instance to destroy. ++ */ ++extern void en50221_app_ai_destroy(struct en50221_app_ai *ai); ++ ++/** ++ * Register a callback for reception of application_info objects. ++ * ++ * @param ai Application information instance. ++ * @param callback Callback function. ++ * @param arg Private argument passed during calls to the callback. ++ */ ++extern void en50221_app_ai_register_callback(struct en50221_app_ai *ai, ++ en50221_app_ai_callback, ++ void *arg); ++ ++/** ++ * send a enquiry for the app_info provided by a module ++ * ++ * @param ai Application information instance. ++ * @param session_number Session to send on. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_ai_enquiry(struct en50221_app_ai *ai, ++ uint16_t session_number); ++ ++/** ++ * send a enter_menu tag, this will make the application ++ * open a new MMI session to provide a Menu, or so. ++ * ++ * @param ai Application information instance. ++ * @param session_number Session to send on. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_ai_entermenu(struct en50221_app_ai *ai, ++ uint16_t session_number); ++ ++/** ++ * Pass data received for this resource into it for parsing. ++ * ++ * @param ai Application information instance. ++ * @param slot_id Slot ID concerned. ++ * @param session_number Session number concerned. ++ * @param resource_id Resource ID concerned. ++ * @param data The data. ++ * @param data_length Length of data in bytes. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_ai_message(struct en50221_app_ai *ai, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t *data, ++ uint32_t data_length); ++ ++#ifdef __cplusplus ++} ++#endif ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_auth.c dvb-apps/lib/libdvben50221/en50221_app_auth.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_auth.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_auth.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,180 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include "en50221_app_auth.h" ++#include "en50221_app_tags.h" ++#include "asn_1.h" ++ ++struct en50221_app_auth { ++ struct en50221_app_send_functions *funcs; ++ ++ en50221_app_auth_request_callback callback; ++ void *callback_arg; ++ ++ pthread_mutex_t lock; ++}; ++ ++static int en50221_app_auth_parse_request(struct en50221_app_auth *private, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++ ++ ++struct en50221_app_auth *en50221_app_auth_create(struct en50221_app_send_functions *funcs) ++{ ++ struct en50221_app_auth *auth = NULL; ++ ++ // create structure and set it up ++ auth = malloc(sizeof(struct en50221_app_auth)); ++ if (auth == NULL) { ++ return NULL; ++ } ++ auth->funcs = funcs; ++ auth->callback = NULL; ++ ++ pthread_mutex_init(&auth->lock, NULL); ++ ++ // done ++ return auth; ++} ++ ++void en50221_app_auth_destroy(struct en50221_app_auth *auth) ++{ ++ pthread_mutex_destroy(&auth->lock); ++ free(auth); ++} ++ ++void en50221_app_auth_register_request_callback(struct en50221_app_auth *auth, ++ en50221_app_auth_request_callback callback, void *arg) ++{ ++ pthread_mutex_lock(&auth->lock); ++ auth->callback = callback; ++ auth->callback_arg = arg; ++ pthread_mutex_unlock(&auth->lock); ++} ++ ++int en50221_app_auth_send(struct en50221_app_auth *auth, ++ uint16_t session_number, ++ uint16_t auth_protocol_id, uint8_t * auth_data, ++ uint32_t auth_data_length) ++{ ++ uint8_t buf[10]; ++ ++ // the header ++ buf[0] = (TAG_AUTH_RESP >> 16) & 0xFF; ++ buf[1] = (TAG_AUTH_RESP >> 8) & 0xFF; ++ buf[2] = TAG_AUTH_RESP & 0xFF; ++ ++ // encode the length field ++ int length_field_len; ++ if ((length_field_len = asn_1_encode(auth_data_length + 2, buf + 3, 3)) < 0) { ++ return -1; ++ } ++ // the phase_id ++ buf[3 + length_field_len] = auth_protocol_id >> 8; ++ buf[3 + length_field_len + 1] = auth_protocol_id; ++ ++ // build the iovecs ++ struct iovec iov[2]; ++ iov[0].iov_base = buf; ++ iov[0].iov_len = 3 + length_field_len + 2; ++ iov[1].iov_base = auth_data; ++ iov[1].iov_len = auth_data_length; ++ ++ // sendit ++ return auth->funcs->send_datav(auth->funcs->arg, session_number, ++ iov, 2); ++} ++ ++int en50221_app_auth_message(struct en50221_app_auth *auth, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t * data, uint32_t data_length) ++{ ++ (void) resource_id; ++ ++ // get the tag ++ if (data_length < 3) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint32_t tag = (data[0] << 16) | (data[1] << 8) | data[2]; ++ ++ switch (tag) { ++ case TAG_AUTH_REQ: ++ return en50221_app_auth_parse_request(auth, slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ } ++ ++ print(LOG_LEVEL, ERROR, 1, "Received unexpected tag %x\n", tag); ++ return -1; ++} ++ ++ ++ ++static int en50221_app_auth_parse_request(struct en50221_app_auth *auth, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ // first of all, decode the length field ++ uint16_t asn_data_length; ++ int length_field_len; ++ if ((length_field_len = asn_1_decode(&asn_data_length, data, data_length)) < 0) { ++ print(LOG_LEVEL, ERROR, 1, "ASN.1 decode error\n"); ++ return -1; ++ } ++ // check it ++ if (asn_data_length < 2) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (asn_data_length > (data_length - length_field_len)) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint8_t *auth_data = data + length_field_len; ++ ++ // process it ++ uint16_t auth_protocol_id = (auth_data[0] << 8) | auth_data[1]; ++ ++ // tell the app ++ pthread_mutex_lock(&auth->lock); ++ en50221_app_auth_request_callback cb = auth->callback; ++ void *cb_arg = auth->callback_arg; ++ pthread_mutex_unlock(&auth->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, ++ auth_protocol_id, auth_data + 2, ++ asn_data_length - 2); ++ } ++ return 0; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_auth.h dvb-apps/lib/libdvben50221/en50221_app_auth.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_auth.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_auth.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,123 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#ifndef __EN50221_APPLICATION_auth_H__ ++#define __EN50221_APPLICATION_auth_H__ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++ ++#define EN50221_APP_AUTH_RESOURCEID MKRID(16,1,1) ++ ++/** ++ * Type definition for request - called when we receive a auth request from a CAM. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param auth_protocol_id Auth protocol id. ++ * @param auth_data Data for the request. ++ * @param auth_data_lenghth Number of bytes. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_auth_request_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint16_t auth_protcol_id, ++ uint8_t *auth_data, ++ uint32_t auth_data_length); ++ ++/** ++ * Opaque type representing a auth resource. ++ */ ++struct en50221_app_auth; ++ ++/** ++ * Create an instance of the auth resource. ++ * ++ * @param funcs Send functions to use. ++ * @return Instance, or NULL on failure. ++ */ ++extern struct en50221_app_auth *en50221_app_auth_create(struct en50221_app_send_functions *funcs); ++ ++/** ++ * Destroy an instance of the auth resource. ++ * ++ * @param auth Instance to destroy. ++ */ ++extern void en50221_app_auth_destroy(struct en50221_app_auth *auth); ++ ++/** ++ * Register the callback for when we receive a request. ++ * ++ * @param auth auth resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_auth_register_request_callback(struct en50221_app_auth *auth, ++ en50221_app_auth_request_callback callback, ++ void *arg); ++ ++/** ++ * Send an auth response to the CAM. ++ * ++ * @param auth auth resource instance. ++ * @param session_number Session number to send it on. ++ * @param auth_protocol_id Auth protocol id. ++ * @param auth_data Auth data. ++ * @param auth_data_length Number of bytes. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_auth_send(struct en50221_app_auth *auth, ++ uint16_t session_number, ++ uint16_t auth_protocol_id, ++ uint8_t *auth_data, ++ uint32_t auth_data_length); ++ ++/** ++ * Pass data received for this resource into it for parsing. ++ * ++ * @param auth Authentication instance. ++ * @param slot_id Slot ID concerned. ++ * @param session_number Session number concerned. ++ * @param resource_id Resource ID concerned. ++ * @param data The data. ++ * @param data_length Length of data in bytes. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_auth_message(struct en50221_app_auth *auth, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t *data, ++ uint32_t data_length); ++ ++#ifdef __cplusplus ++} ++#endif ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_ca.c dvb-apps/lib/libdvben50221/en50221_app_ca.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_ca.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_ca.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,631 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include ++#include "en50221_app_ca.h" ++#include "asn_1.h" ++ ++// tags supported by this resource ++#define TAG_CA_INFO_ENQUIRY 0x9f8030 ++#define TAG_CA_INFO 0x9f8031 ++#define TAG_CA_PMT 0x9f8032 ++#define TAG_CA_PMT_REPLY 0x9f8033 ++ ++struct en50221_app_ca { ++ struct en50221_app_send_functions *funcs; ++ ++ en50221_app_ca_info_callback ca_info_callback; ++ void *ca_info_callback_arg; ++ ++ en50221_app_ca_pmt_reply_callback ca_pmt_reply_callback; ++ void *ca_pmt_reply_callback_arg; ++ ++ pthread_mutex_t lock; ++}; ++ ++struct ca_pmt_descriptor { ++ uint8_t *descriptor; ++ uint16_t length; ++ ++ struct ca_pmt_descriptor *next; ++}; ++ ++struct ca_pmt_stream { ++ uint8_t stream_type; ++ uint16_t pid; ++ struct ca_pmt_descriptor *descriptors; ++ uint32_t descriptors_length; ++ uint32_t descriptors_count; ++ ++ struct ca_pmt_stream *next; ++}; ++ ++static int en50221_ca_extract_pmt_descriptors(struct mpeg_pmt_section *pmt, ++ struct ca_pmt_descriptor **outdescriptors); ++static int en50221_ca_extract_streams(struct mpeg_pmt_section *pmt, ++ struct ca_pmt_stream **outstreams); ++static void en50221_ca_try_move_pmt_descriptors(struct ca_pmt_descriptor **pmt_descriptors, ++ struct ca_pmt_stream **pmt_streams); ++static uint32_t en50221_ca_calculate_length(struct ca_pmt_descriptor *pmt_descriptors, ++ uint32_t *pmt_descriptors_length, ++ struct ca_pmt_stream *pmt_streams); ++static int en50221_app_ca_parse_info(struct en50221_app_ca *ca, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, uint32_t data_length); ++static int en50221_app_ca_parse_reply(struct en50221_app_ca *ca, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++ ++ ++ ++struct en50221_app_ca *en50221_app_ca_create(struct en50221_app_send_functions *funcs) ++{ ++ struct en50221_app_ca *ca = NULL; ++ ++ // create structure and set it up ++ ca = malloc(sizeof(struct en50221_app_ca)); ++ if (ca == NULL) { ++ return NULL; ++ } ++ ca->funcs = funcs; ++ ca->ca_info_callback = NULL; ++ ca->ca_pmt_reply_callback = NULL; ++ ++ pthread_mutex_init(&ca->lock, NULL); ++ ++ // done ++ return ca; ++} ++ ++void en50221_app_ca_destroy(struct en50221_app_ca *ca) ++{ ++ pthread_mutex_destroy(&ca->lock); ++ free(ca); ++} ++ ++void en50221_app_ca_register_info_callback(struct en50221_app_ca *ca, ++ en50221_app_ca_info_callback ++ callback, void *arg) ++{ ++ pthread_mutex_lock(&ca->lock); ++ ca->ca_info_callback = callback; ++ ca->ca_info_callback_arg = arg; ++ pthread_mutex_unlock(&ca->lock); ++} ++ ++void en50221_app_ca_register_pmt_reply_callback(struct en50221_app_ca *ca, ++ en50221_app_ca_pmt_reply_callback ++ callback, void *arg) ++{ ++ pthread_mutex_lock(&ca->lock); ++ ca->ca_pmt_reply_callback = callback; ++ ca->ca_pmt_reply_callback_arg = arg; ++ pthread_mutex_unlock(&ca->lock); ++} ++ ++int en50221_app_ca_info_enq(struct en50221_app_ca *ca, ++ uint16_t session_number) ++{ ++ uint8_t data[4]; ++ ++ data[0] = (TAG_CA_INFO_ENQUIRY >> 16) & 0xFF; ++ data[1] = (TAG_CA_INFO_ENQUIRY >> 8) & 0xFF; ++ data[2] = TAG_CA_INFO_ENQUIRY & 0xFF; ++ data[3] = 0; ++ return ca->funcs->send_data(ca->funcs->arg, session_number, data, 4); ++} ++ ++int en50221_app_ca_pmt(struct en50221_app_ca *ca, ++ uint16_t session_number, ++ uint8_t * ca_pmt, uint32_t ca_pmt_length) ++{ ++ uint8_t buf[10]; ++ ++ // set up the tag ++ buf[0] = (TAG_CA_PMT >> 16) & 0xFF; ++ buf[1] = (TAG_CA_PMT >> 8) & 0xFF; ++ buf[2] = TAG_CA_PMT & 0xFF; ++ ++ // encode the length field ++ int length_field_len; ++ if ((length_field_len = asn_1_encode(ca_pmt_length, buf + 3, 3)) < 0) { ++ return -1; ++ } ++ // build the iovecs ++ struct iovec iov[2]; ++ iov[0].iov_base = buf; ++ iov[0].iov_len = 3 + length_field_len; ++ iov[1].iov_base = ca_pmt; ++ iov[1].iov_len = ca_pmt_length; ++ ++ // create the data and send it ++ return ca->funcs->send_datav(ca->funcs->arg, session_number, iov, 2); ++} ++ ++int en50221_app_ca_message(struct en50221_app_ca *ca, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t * data, uint32_t data_length) ++{ ++ (void) resource_id; ++ ++ // get the tag ++ if (data_length < 3) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint32_t tag = (data[0] << 16) | (data[1] << 8) | data[2]; ++ ++ switch (tag) { ++ case TAG_CA_INFO: ++ return en50221_app_ca_parse_info(ca, slot_id, ++ session_number, data + 3, ++ data_length - 3); ++ case TAG_CA_PMT_REPLY: ++ return en50221_app_ca_parse_reply(ca, slot_id, ++ session_number, data + 3, ++ data_length - 3); ++ } ++ ++ print(LOG_LEVEL, ERROR, 1, "Received unexpected tag %x\n", tag); ++ return -1; ++} ++ ++int en50221_ca_format_pmt(struct mpeg_pmt_section *pmt, uint8_t * data, ++ uint32_t data_length, int move_ca_descriptors, ++ uint8_t ca_pmt_list_management, ++ uint8_t ca_pmt_cmd_id) ++{ ++ struct ca_pmt_descriptor *pmt_descriptors = NULL; ++ uint32_t pmt_descriptors_length = 0; ++ struct ca_pmt_stream *pmt_streams = NULL; ++ uint32_t total_required_length = 0; ++ struct ca_pmt_descriptor *cur_d; ++ struct ca_pmt_stream *cur_s; ++ int result = -1; ++ ++ // extract the descriptors and streams ++ if (en50221_ca_extract_pmt_descriptors(pmt, &pmt_descriptors)) ++ goto cleanup; ++ if (en50221_ca_extract_streams(pmt, &pmt_streams)) ++ goto cleanup; ++ ++ // try and merge them if we have no PMT descriptors ++ if ((pmt_descriptors == NULL) && move_ca_descriptors) { ++ en50221_ca_try_move_pmt_descriptors(&pmt_descriptors, ++ &pmt_streams); ++ } ++ // calculate the length of all descriptors/streams and the total length required ++ total_required_length = ++ en50221_ca_calculate_length(pmt_descriptors, ++ &pmt_descriptors_length, ++ pmt_streams); ++ ++ // ensure we were supplied with enough data ++ if (total_required_length > data_length) { ++ goto cleanup; ++ } ++ // format the start of the PMT ++ uint32_t data_pos = 0; ++ data[data_pos++] = ca_pmt_list_management; ++ data[data_pos++] = mpeg_pmt_section_program_number(pmt) >> 8; ++ data[data_pos++] = mpeg_pmt_section_program_number(pmt); ++ data[data_pos++] = ++ (pmt->head.version_number << 1) | pmt->head. ++ current_next_indicator; ++ data[data_pos++] = (pmt_descriptors_length >> 8) & 0x0f; ++ data[data_pos++] = pmt_descriptors_length; ++ ++ // append the PMT descriptors ++ if (pmt_descriptors_length) { ++ data[data_pos++] = ca_pmt_cmd_id; ++ cur_d = pmt_descriptors; ++ while (cur_d) { ++ memcpy(data + data_pos, cur_d->descriptor, ++ cur_d->length); ++ data_pos += cur_d->length; ++ cur_d = cur_d->next; ++ } ++ } ++ // now, append the streams ++ cur_s = pmt_streams; ++ while (cur_s) { ++ data[data_pos++] = cur_s->stream_type; ++ data[data_pos++] = (cur_s->pid >> 8) & 0x1f; ++ data[data_pos++] = cur_s->pid; ++ data[data_pos++] = (cur_s->descriptors_length >> 8) & 0x0f; ++ data[data_pos++] = cur_s->descriptors_length; ++ ++ // append the stream descriptors ++ if (cur_s->descriptors_length) { ++ data[data_pos++] = ca_pmt_cmd_id; ++ cur_d = cur_s->descriptors; ++ while (cur_d) { ++ memcpy(data + data_pos, cur_d->descriptor, ++ cur_d->length); ++ data_pos += cur_d->length; ++ cur_d = cur_d->next; ++ } ++ } ++ cur_s = cur_s->next; ++ } ++ result = data_pos; ++ ++ ++ cleanup: ++ // free the PMT descriptors ++ cur_d = pmt_descriptors; ++ while (cur_d) { ++ struct ca_pmt_descriptor *next = cur_d->next; ++ free(cur_d); ++ cur_d = next; ++ } ++ ++ // free the streams ++ cur_s = pmt_streams; ++ while (cur_s) { ++ struct ca_pmt_stream *next_s = cur_s->next; ++ ++ // free the stream descriptors ++ cur_d = cur_s->descriptors; ++ while (cur_d) { ++ struct ca_pmt_descriptor *next_d = cur_d->next; ++ free(cur_d); ++ cur_d = next_d; ++ } ++ ++ free(cur_s); ++ cur_s = next_s; ++ } ++ return result; ++} ++ ++ ++ ++ ++ ++ ++ ++static int en50221_ca_extract_pmt_descriptors(struct mpeg_pmt_section *pmt, ++ struct ca_pmt_descriptor **outdescriptors) ++{ ++ struct ca_pmt_descriptor *descriptors = NULL; ++ struct ca_pmt_descriptor *descriptors_tail = NULL; ++ struct ca_pmt_descriptor *cur_d; ++ ++ struct descriptor *cur_descriptor; ++ mpeg_pmt_section_descriptors_for_each(pmt, cur_descriptor) { ++ if (cur_descriptor->tag == dtag_mpeg_ca) { ++ // create a new structure for this one ++ struct ca_pmt_descriptor *new_d = ++ malloc(sizeof(struct ca_pmt_descriptor)); ++ if (new_d == NULL) { ++ goto error_exit; ++ } ++ new_d->descriptor = (uint8_t *) cur_descriptor; ++ new_d->length = cur_descriptor->len + 2; ++ new_d->next = NULL; ++ ++ // append it to the list ++ if (descriptors == NULL) { ++ descriptors = new_d; ++ } else { ++ descriptors_tail->next = new_d; ++ } ++ descriptors_tail = new_d; ++ } ++ } ++ *outdescriptors = descriptors; ++ return 0; ++ ++error_exit: ++ cur_d = descriptors; ++ while (cur_d) { ++ struct ca_pmt_descriptor *next = cur_d->next; ++ free(cur_d); ++ cur_d = next; ++ } ++ return -1; ++} ++ ++static int en50221_ca_extract_streams(struct mpeg_pmt_section *pmt, ++ struct ca_pmt_stream **outstreams) ++{ ++ struct ca_pmt_stream *streams = NULL; ++ struct ca_pmt_stream *streams_tail = NULL; ++ struct mpeg_pmt_stream *cur_stream; ++ struct descriptor *cur_descriptor; ++ struct ca_pmt_stream *cur_s; ++ ++ mpeg_pmt_section_streams_for_each(pmt, cur_stream) { ++ struct ca_pmt_descriptor *descriptors_tail = NULL; ++ ++ // create a new structure ++ struct ca_pmt_stream *new_s = ++ malloc(sizeof(struct ca_pmt_stream)); ++ if (new_s == NULL) { ++ goto exit_cleanup; ++ } ++ new_s->stream_type = cur_stream->stream_type; ++ new_s->pid = cur_stream->pid; ++ new_s->descriptors = NULL; ++ new_s->next = NULL; ++ new_s->descriptors_count = 0; ++ ++ // append it to the list ++ if (streams == NULL) { ++ streams = new_s; ++ } else { ++ streams_tail->next = new_s; ++ } ++ streams_tail = new_s; ++ ++ // now process the descriptors ++ mpeg_pmt_stream_descriptors_for_each(cur_stream, ++ cur_descriptor) { ++ if (cur_descriptor->tag == dtag_mpeg_ca) { ++ // create a new structure ++ struct ca_pmt_descriptor *new_d = ++ malloc(sizeof(struct ca_pmt_descriptor)); ++ if (new_d == NULL) { ++ goto exit_cleanup; ++ } ++ new_d->descriptor = ++ (uint8_t *) cur_descriptor; ++ new_d->length = cur_descriptor->len + 2; ++ new_d->next = NULL; ++ ++ // append it to the list ++ if (new_s->descriptors == NULL) { ++ new_s->descriptors = new_d; ++ } else { ++ descriptors_tail->next = new_d; ++ } ++ descriptors_tail = new_d; ++ new_s->descriptors_count++; ++ } ++ } ++ } ++ *outstreams = streams; ++ return 0; ++ ++exit_cleanup: ++ // free the streams ++ cur_s = streams; ++ while (cur_s) { ++ struct ca_pmt_stream *next_s = cur_s->next; ++ ++ // free the stream descriptors ++ struct ca_pmt_descriptor *cur_d = cur_s->descriptors; ++ while (cur_d) { ++ struct ca_pmt_descriptor *next_d = cur_d->next; ++ free(cur_d); ++ cur_d = next_d; ++ } ++ ++ free(cur_s); ++ cur_s = next_s; ++ } ++ return -1; ++} ++ ++static void en50221_ca_try_move_pmt_descriptors(struct ca_pmt_descriptor **pmt_descriptors, ++ struct ca_pmt_stream **pmt_streams) ++{ ++ // get the first stream ++ struct ca_pmt_stream *first_stream = *pmt_streams; ++ if (first_stream == NULL) ++ return; ++ ++ // Check that all the other streams with CA descriptors have exactly the same CA descriptors ++ struct ca_pmt_stream *cur_stream = first_stream->next; ++ while (cur_stream) { ++ // if there are differing numbers of descriptors, exit right now ++ if (cur_stream->descriptors_count != first_stream->descriptors_count) ++ return; ++ ++ // now verify the descriptors match ++ struct ca_pmt_descriptor *cur_descriptor = cur_stream->descriptors; ++ struct ca_pmt_descriptor *first_cur_descriptor = first_stream->descriptors; ++ while (cur_descriptor) { ++ // check the descriptors are the same length ++ if (cur_descriptor->length != first_cur_descriptor->length) ++ return; ++ ++ // check their contents match ++ if (memcmp(cur_descriptor->descriptor, ++ first_cur_descriptor->descriptor, ++ cur_descriptor->length)) { ++ return; ++ } ++ // move to next ++ cur_descriptor = cur_descriptor->next; ++ first_cur_descriptor = first_cur_descriptor->next; ++ } ++ ++ // move to next ++ cur_stream = cur_stream->next; ++ } ++ ++ // if we end up here, all descriptors in all streams matched ++ ++ // hook the first stream's descriptors into the PMT's ++ *pmt_descriptors = first_stream->descriptors; ++ first_stream->descriptors = NULL; ++ first_stream->descriptors_count = 0; ++ ++ // now free up all the descriptors in the other streams ++ cur_stream = first_stream->next; ++ while (cur_stream) { ++ struct ca_pmt_descriptor *cur_descriptor = cur_stream->descriptors; ++ while (cur_descriptor) { ++ struct ca_pmt_descriptor *next = cur_descriptor->next; ++ free(cur_descriptor); ++ cur_descriptor = next; ++ } ++ cur_stream->descriptors = NULL; ++ cur_stream->descriptors_count = 0; ++ cur_stream = cur_stream->next; ++ } ++} ++ ++static uint32_t en50221_ca_calculate_length(struct ca_pmt_descriptor *pmt_descriptors, ++ uint32_t *pmt_descriptors_length, ++ struct ca_pmt_stream *pmt_streams) ++{ ++ uint32_t total_required_length = 6; // header ++ struct ca_pmt_stream *cur_s; ++ ++ // calcuate the PMT descriptors length ++ (*pmt_descriptors_length) = 0; ++ struct ca_pmt_descriptor *cur_d = pmt_descriptors; ++ while (cur_d) { ++ (*pmt_descriptors_length) += cur_d->length; ++ cur_d = cur_d->next; ++ } ++ ++ // add on 1 byte for the ca_pmt_cmd_id if we have some descriptors. ++ if (*pmt_descriptors_length) ++ (*pmt_descriptors_length)++; ++ ++ // update the total required length ++ total_required_length += *pmt_descriptors_length; ++ ++ // calculate the length of descriptors in the streams ++ cur_s = pmt_streams; ++ while (cur_s) { ++ // calculate the size of descriptors in this stream ++ cur_s->descriptors_length = 0; ++ cur_d = cur_s->descriptors; ++ while (cur_d) { ++ cur_s->descriptors_length += cur_d->length; ++ cur_d = cur_d->next; ++ } ++ ++ // add on 1 byte for the ca_pmt_cmd_id if we have some descriptors. ++ if (cur_s->descriptors_length) ++ cur_s->descriptors_length++; ++ ++ // update the total required length; ++ total_required_length += 5 + cur_s->descriptors_length; ++ ++ cur_s = cur_s->next; ++ } ++ ++ // done ++ return total_required_length; ++} ++ ++static int en50221_app_ca_parse_info(struct en50221_app_ca *ca, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, uint32_t data_length) ++{ ++ // first of all, decode the length field ++ uint16_t asn_data_length; ++ int length_field_len; ++ if ((length_field_len = asn_1_decode(&asn_data_length, data, data_length)) < 0) { ++ print(LOG_LEVEL, ERROR, 1, "ASN.1 decode error\n"); ++ return -1; ++ } ++ // check it ++ if (asn_data_length > (data_length - length_field_len)) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ data += length_field_len; ++ ++ // parse ++ uint32_t ca_id_count = asn_data_length / 2; ++ ++ // byteswap the IDs ++ uint16_t *ids = (uint16_t *) data; ++ uint32_t i; ++ for (i = 0; i < ca_id_count; i++) { ++ bswap16(data); ++ data += 2; ++ } ++ ++ // tell the app ++ pthread_mutex_lock(&ca->lock); ++ en50221_app_ca_info_callback cb = ca->ca_info_callback; ++ void *cb_arg = ca->ca_info_callback_arg; ++ pthread_mutex_unlock(&ca->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, ca_id_count, ++ ids); ++ } ++ return 0; ++} ++ ++static int en50221_app_ca_parse_reply(struct en50221_app_ca *ca, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, uint32_t data_length) ++{ ++ // first of all, decode the length field ++ uint16_t asn_data_length; ++ int length_field_len; ++ if ((length_field_len = asn_1_decode(&asn_data_length, data, data_length)) < 0) { ++ print(LOG_LEVEL, ERROR, 1, "ASN.1 decode error\n"); ++ return -1; ++ } ++ // check it ++ if (asn_data_length < 4) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (asn_data_length > (data_length - length_field_len)) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ data += length_field_len; ++ data_length -= length_field_len; ++ ++ // process the reply table to fix endian issues ++ uint32_t pos = 4; ++ bswap16(data); ++ while (pos < asn_data_length) { ++ bswap16(data + pos); ++ pos += 3; ++ } ++ ++ // tell the app ++ pthread_mutex_lock(&ca->lock); ++ en50221_app_ca_pmt_reply_callback cb = ca->ca_pmt_reply_callback; ++ void *cb_arg = ca->ca_pmt_reply_callback_arg; ++ pthread_mutex_unlock(&ca->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, ++ (struct en50221_app_pmt_reply *) data, ++ asn_data_length); ++ } ++ return 0; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_ca.h dvb-apps/lib/libdvben50221/en50221_app_ca.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_ca.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_ca.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,264 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#ifndef __EN50221_APPLICATION_ca_H__ ++#define __EN50221_APPLICATION_ca_H__ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++#include ++#include ++ ++#define CA_LIST_MANAGEMENT_MORE 0x00 ++#define CA_LIST_MANAGEMENT_FIRST 0x01 ++#define CA_LIST_MANAGEMENT_LAST 0x02 ++#define CA_LIST_MANAGEMENT_ONLY 0x03 ++#define CA_LIST_MANAGEMENT_ADD 0x04 ++#define CA_LIST_MANAGEMENT_UPDATE 0x05 ++ ++#define CA_PMT_CMD_ID_OK_DESCRAMBLING 0x01 ++#define CA_PMT_CMD_ID_OK_MMI 0x02 ++#define CA_PMT_CMD_ID_QUERY 0x03 ++#define CA_PMT_CMD_ID_NOT_SELECTED 0x04 ++ ++#define CA_ENABLE_DESCRAMBLING_POSSIBLE 0x01 ++#define CA_ENABLE_DESCRAMBLING_POSSIBLE_PURCHASE 0x02 ++#define CA_ENABLE_DESCRAMBLING_POSSIBLE_TECHNICAL 0x03 ++#define CA_ENABLE_DESCRAMBLING_NOT_POSSIBLE_NO_ENTITLEMENT 0x71 ++#define CA_ENABLE_DESCRAMBLING_NOT_POSSIBLE_TECHNICAL 0x73 ++ ++ ++#define EN50221_APP_CA_RESOURCEID MKRID(3,1,1) ++ ++/** ++ * PMT reply structure. ++ */ ++struct en50221_app_pmt_reply { ++ uint16_t program_number; ++ EBIT3(uint8_t reserved_1 : 2;, ++ uint8_t version_number : 5;, ++ uint8_t current_next_indicator : 1;); ++ EBIT2(uint8_t CA_enable_flag : 1;, ++ uint8_t CA_enable : 7;); ++ /* struct en50221_app_pmt_stream streams[] */ ++} __attribute__ ((packed)); ++ ++/** ++ * A stream within a pmt reply structure. ++ */ ++struct en50221_app_pmt_stream { ++ EBIT2(uint16_t reserved_1 : 3;, ++ uint16_t es_pid :13;); ++ EBIT2(uint8_t CA_enable_flag : 1;, ++ uint8_t CA_enable : 7;); ++} __attribute__ ((packed)); ++ ++/** ++ * Convenience iterator for the streams field of the en50221_app_pmt_reply structure. ++ * ++ * @param pmt Pointer to the en50221_app_pmt_reply structure. ++ * @param pos Variable holding a pointer to the current en50221_app_pmt_stream. ++ * @param size Total size of the PMT reply. ++ */ ++#define en50221_app_pmt_reply_streams_for_each(pmt, pos, size) \ ++ for ((pos) = en50221_app_pmt_reply_streams_first(pmt, size); \ ++ (pos); \ ++ (pos) = en50221_app_pmt_reply_streams_next(pmt, pos, size)) ++ ++ ++/** ++ * Type definition for command - called when we receive a ca info response. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param ca_id_count Number of ca_system_ids. ++ * @param ca_ids Pointer to list of ca_system_ids. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_ca_info_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t ca_id_count, ++ uint16_t * ca_ids); ++ ++/** ++ * Type definition for pmt_reply - called when we receive a pmt_reply. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param reply Pointer to a struct en50221_app_pmt_reply. ++ * @param reply_size Total size of the struct en50221_app_pmt_reply in bytes. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_ca_pmt_reply_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ struct en50221_app_pmt_reply *reply, ++ uint32_t reply_size); ++ ++/** ++ * Opaque type representing a ca resource. ++ */ ++struct en50221_app_ca; ++ ++/** ++ * Create an instance of the ca resource. ++ * ++ * @param funcs Send functions to use. ++ * @return Instance, or NULL on failure. ++ */ ++extern struct en50221_app_ca *en50221_app_ca_create(struct en50221_app_send_functions *funcs); ++ ++/** ++ * Destroy an instance of the ca resource. ++ * ++ * @param ca Instance to destroy. ++ */ ++extern void en50221_app_ca_destroy(struct en50221_app_ca *ca); ++ ++/** ++ * Register the callback for when we receive a ca info. ++ * ++ * @param ca ca resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_ca_register_info_callback(struct en50221_app_ca *ca, ++ en50221_app_ca_info_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for when we receive a pmt_reply. ++ * ++ * @param ca ca resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_ca_register_pmt_reply_callback(struct en50221_app_ca *ca, ++ en50221_app_ca_pmt_reply_callback callback, ++ void *arg); ++ ++/** ++ * Send a ca_info_req to the CAM. ++ * ++ * @param ca ca resource instance. ++ * @param session_number Session number to send it on. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_ca_info_enq(struct en50221_app_ca *ca, ++ uint16_t session_number); ++ ++/** ++ * Send a ca_pmt structure to the CAM. ++ * ++ * @param ca ca resource instance. ++ * @param session_number Session number to send it on. ++ * @param ca_pmt A ca_pmt structure formatted with the en50221_ca_format_pmt() function. ++ * @param ca_pmt_length Length of ca_pmt structure in bytes. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_ca_pmt(struct en50221_app_ca *ca, ++ uint16_t session_number, ++ uint8_t * ca_pmt, ++ uint32_t ca_pmt_length); ++ ++/** ++ * Transform a libucsi PMT into a binary structure for sending to a CAM. ++ * ++ * @param pmt The source PMT structure. ++ * @param data Pointer to data buffer to write it to. ++ * @param data_length Number of bytes available in data buffer. ++ * @param move_ca_descriptors If non-zero, will attempt to move CA descriptors ++ * in order to reduce the size of the formatted CAPMT. ++ * @param ca_pmt_list_management One of the CA_LIST_MANAGEMENT_*. ++ * @param ca_pmt_cmd_id One of the CA_PMT_CMD_ID_*. ++ * @return Number of bytes used, or -1 on error. ++ */ ++extern int en50221_ca_format_pmt(struct mpeg_pmt_section *pmt, ++ uint8_t * data, ++ uint32_t data_length, ++ int move_ca_descriptors, ++ uint8_t ca_pmt_list_management, ++ uint8_t ca_pmt_cmd_id); ++ ++/** ++ * Pass data received for this resource into it for parsing. ++ * ++ * @param ca CA instance. ++ * @param slot_id Slot ID concerned. ++ * @param session_number Session number concerned. ++ * @param resource_id Resource ID concerned. ++ * @param data The data. ++ * @param data_length Length of data in bytes. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_ca_message(struct en50221_app_ca *ca, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t *data, ++ uint32_t data_length); ++ ++ ++ ++ ++static inline struct en50221_app_pmt_stream * ++ en50221_app_pmt_reply_streams_first(struct en50221_app_pmt_reply *reply, ++ uint32_t reply_size) ++{ ++ uint32_t pos = sizeof(struct en50221_app_pmt_reply); ++ ++ if (pos >= reply_size) ++ return NULL; ++ ++ return (struct en50221_app_pmt_stream *) ((uint8_t *) reply + pos); ++} ++ ++static inline struct en50221_app_pmt_stream * ++ en50221_app_pmt_reply_streams_next(struct en50221_app_pmt_reply *reply, ++ struct en50221_app_pmt_stream *pos, ++ uint32_t reply_size) ++{ ++ uint8_t *end = (uint8_t *) reply + reply_size; ++ uint8_t *next = ++ (uint8_t *) pos + ++ sizeof(struct en50221_app_pmt_stream); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct en50221_app_pmt_stream *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_datetime.c dvb-apps/lib/libdvben50221/en50221_app_datetime.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_datetime.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_datetime.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,173 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include ++#include "en50221_app_datetime.h" ++#include "en50221_app_tags.h" ++#include "asn_1.h" ++ ++struct en50221_app_datetime { ++ struct en50221_app_send_functions *funcs; ++ ++ en50221_app_datetime_enquiry_callback callback; ++ void *callback_arg; ++ ++ pthread_mutex_t lock; ++}; ++ ++static int en50221_app_datetime_parse_enquiry(struct en50221_app_datetime *datetime, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++ ++ ++ ++struct en50221_app_datetime *en50221_app_datetime_create(struct en50221_app_send_functions *funcs) ++{ ++ struct en50221_app_datetime *datetime = NULL; ++ ++ // create structure and set it up ++ datetime = malloc(sizeof(struct en50221_app_datetime)); ++ if (datetime == NULL) { ++ return NULL; ++ } ++ datetime->funcs = funcs; ++ datetime->callback = NULL; ++ ++ pthread_mutex_init(&datetime->lock, NULL); ++ ++ // done ++ return datetime; ++} ++ ++void en50221_app_datetime_destroy(struct en50221_app_datetime *datetime) ++{ ++ pthread_mutex_destroy(&datetime->lock); ++ free(datetime); ++} ++ ++void en50221_app_datetime_register_enquiry_callback(struct en50221_app_datetime *datetime, ++ en50221_app_datetime_enquiry_callback callback, ++ void *arg) ++{ ++ pthread_mutex_lock(&datetime->lock); ++ datetime->callback = callback; ++ datetime->callback_arg = arg; ++ pthread_mutex_unlock(&datetime->lock); ++} ++ ++int en50221_app_datetime_send(struct en50221_app_datetime *datetime, ++ uint16_t session_number, ++ time_t utc_time, int time_offset) ++{ ++ uint8_t data[11]; ++ int data_length; ++ ++ data[0] = (TAG_DATE_TIME >> 16) & 0xFF; ++ data[1] = (TAG_DATE_TIME >> 8) & 0xFF; ++ data[2] = TAG_DATE_TIME & 0xFF; ++ if (time_offset != -1) { ++ data[3] = 7; ++ unixtime_to_dvbdate(utc_time, data + 4); ++ data[9] = time_offset >> 8; ++ data[10] = time_offset; ++ data_length = 11; ++ } else { ++ data[3] = 5; ++ unixtime_to_dvbdate(utc_time, data + 4); ++ data_length = 9; ++ } ++ return datetime->funcs->send_data(datetime->funcs->arg, ++ session_number, data, ++ data_length); ++} ++ ++int en50221_app_datetime_message(struct en50221_app_datetime *datetime, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t * data, uint32_t data_length) ++{ ++ (void) resource_id; ++ ++ // get the tag ++ if (data_length < 3) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint32_t tag = (data[0] << 16) | (data[1] << 8) | data[2]; ++ ++ switch (tag) { ++ case TAG_DATE_TIME_ENQUIRY: ++ return en50221_app_datetime_parse_enquiry(datetime, ++ slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ } ++ ++ print(LOG_LEVEL, ERROR, 1, "Received unexpected tag %x\n", tag); ++ return -1; ++} ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++static int en50221_app_datetime_parse_enquiry(struct en50221_app_datetime *datetime, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ // validate data ++ if (data_length != 2) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (data[0] != 1) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint8_t response_interval = data[1]; ++ ++ // tell the app ++ pthread_mutex_lock(&datetime->lock); ++ en50221_app_datetime_enquiry_callback cb = datetime->callback; ++ void *cb_arg = datetime->callback_arg; ++ pthread_mutex_unlock(&datetime->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, ++ response_interval); ++ } ++ return 0; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_datetime.h dvb-apps/lib/libdvben50221/en50221_app_datetime.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_datetime.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_datetime.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,119 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#ifndef __EN50221_APPLICATION_DATETIME_H__ ++#define __EN50221_APPLICATION_DATETIME_H__ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++ ++#define EN50221_APP_DATETIME_RESOURCEID MKRID(36,1,1) ++ ++/** ++ * Type definition for enquiry - called when we receive a date/time enquiry from a CAM. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param response_interval Response interval requested by CAM. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_datetime_enquiry_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t response_interval); ++ ++/** ++ * Opaque type representing a datetime resource. ++ */ ++struct en50221_app_datetime; ++ ++/** ++ * Create an instance of the datetime resource. ++ * ++ * @param funcs Send functions to use. ++ * @return Instance, or NULL on failure. ++ */ ++extern struct en50221_app_datetime ++ *en50221_app_datetime_create(struct en50221_app_send_functions *funcs); ++ ++/** ++ * Destroy an instance of the datetime resource. ++ * ++ * @param datetime Instance to destroy. ++ */ ++extern void en50221_app_datetime_destroy(struct en50221_app_datetime *datetime); ++ ++/** ++ * Register the callback for when we receive a enquiry request. ++ * ++ * @param datetime datetime resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_datetime_register_enquiry_callback(struct en50221_app_datetime *datetime, ++ en50221_app_datetime_enquiry_callback callback, ++ void *arg); ++ ++/** ++ * Send the time to the CAM. ++ * ++ * @param datetime datetime resource instance. ++ * @param session_number Session number to send it on. ++ * @param utc_time UTC time in unix time format. ++ * @param time_offset If -1, the field will not be transmitted, otherwise it is the offset between ++ * UTC and local time in minutes. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_datetime_send(struct en50221_app_datetime *datetime, ++ uint16_t session_number, ++ time_t utc_time, ++ int time_offset); ++ ++/** ++ * Pass data received for this resource into it for parsing. ++ * ++ * @param datetime datetime instance. ++ * @param slot_id Slot ID concerned. ++ * @param session_number Session number concerned. ++ * @param resource_id Resource ID concerned. ++ * @param data The data. ++ * @param data_length Length of data in bytes. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_datetime_message(struct en50221_app_datetime *datetime, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t *data, ++ uint32_t data_length); ++ ++#ifdef __cplusplus ++} ++#endif ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_dvb.c dvb-apps/lib/libdvben50221/en50221_app_dvb.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_dvb.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_dvb.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,282 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include "en50221_app_dvb.h" ++#include "en50221_app_tags.h" ++#include "asn_1.h" ++ ++struct en50221_app_dvb { ++ struct en50221_app_send_functions *funcs; ++ ++ en50221_app_dvb_tune_callback tune_callback; ++ void *tune_callback_arg; ++ ++ en50221_app_dvb_replace_callback replace_callback; ++ void *replace_callback_arg; ++ ++ en50221_app_dvb_clear_replace_callback clear_replace_callback; ++ void *clear_replace_callback_arg; ++ ++ pthread_mutex_t lock; ++}; ++ ++static int en50221_app_dvb_parse_tune(struct en50221_app_dvb *dvb, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++ ++static int en50221_app_dvb_parse_replace(struct en50221_app_dvb *dvb, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++ ++static int en50221_app_dvb_parse_clear_replace(struct en50221_app_dvb *dvb, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++ ++ ++ ++struct en50221_app_dvb *en50221_app_dvb_create(struct en50221_app_send_functions *funcs) ++{ ++ struct en50221_app_dvb *dvb = NULL; ++ ++ // create structure and set it up ++ dvb = malloc(sizeof(struct en50221_app_dvb)); ++ if (dvb == NULL) { ++ return NULL; ++ } ++ dvb->funcs = funcs; ++ dvb->tune_callback = NULL; ++ dvb->replace_callback = NULL; ++ dvb->clear_replace_callback = NULL; ++ ++ pthread_mutex_init(&dvb->lock, NULL); ++ ++ // done ++ return dvb; ++} ++ ++void en50221_app_dvb_destroy(struct en50221_app_dvb *dvb) ++{ ++ pthread_mutex_destroy(&dvb->lock); ++ free(dvb); ++} ++ ++void en50221_app_dvb_register_tune_callback(struct en50221_app_dvb *dvb, ++ en50221_app_dvb_tune_callback callback, ++ void *arg) ++{ ++ pthread_mutex_lock(&dvb->lock); ++ dvb->tune_callback = callback; ++ dvb->tune_callback_arg = arg; ++ pthread_mutex_unlock(&dvb->lock); ++} ++ ++void en50221_app_dvb_register_replace_callback(struct en50221_app_dvb *dvb, ++ en50221_app_dvb_replace_callback callback, ++ void *arg) ++{ ++ pthread_mutex_lock(&dvb->lock); ++ dvb->replace_callback = callback; ++ dvb->replace_callback_arg = arg; ++ pthread_mutex_unlock(&dvb->lock); ++} ++ ++void en50221_app_dvb_register_clear_replace_callback(struct en50221_app_dvb *dvb, ++ en50221_app_dvb_clear_replace_callback callback, ++ void *arg) ++{ ++ pthread_mutex_lock(&dvb->lock); ++ dvb->clear_replace_callback = callback; ++ dvb->clear_replace_callback_arg = arg; ++ pthread_mutex_unlock(&dvb->lock); ++} ++ ++int en50221_app_dvb_ask_release(struct en50221_app_dvb *dvb, ++ uint16_t session_number) ++{ ++ uint8_t data[4]; ++ ++ data[0] = (TAG_ASK_RELEASE >> 16) & 0xFF; ++ data[1] = (TAG_ASK_RELEASE >> 8) & 0xFF; ++ data[2] = TAG_ASK_RELEASE & 0xFF; ++ data[3] = 0; ++ ++ return dvb->funcs->send_data(dvb->funcs->arg, session_number, data, 4); ++} ++ ++int en50221_app_dvb_message(struct en50221_app_dvb *dvb, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t * data, uint32_t data_length) ++{ ++ (void) resource_id; ++ ++ // get the tag ++ if (data_length < 3) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint32_t tag = (data[0] << 16) | (data[1] << 8) | data[2]; ++ ++ switch (tag) { ++ case TAG_TUNE: ++ return en50221_app_dvb_parse_tune(dvb, slot_id, ++ session_number, data + 3, ++ data_length - 3); ++ case TAG_REPLACE: ++ return en50221_app_dvb_parse_replace(dvb, slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ case TAG_CLEAR_REPLACE: ++ return en50221_app_dvb_parse_clear_replace(dvb, slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ } ++ ++ print(LOG_LEVEL, ERROR, 1, "Received unexpected tag %x\n", tag); ++ return -1; ++} ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++static int en50221_app_dvb_parse_tune(struct en50221_app_dvb *dvb, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, uint32_t data_length) ++{ ++ // validate data ++ if (data_length < 9) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (data[0] != 8) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint8_t *tune_data = data + 1; ++ ++ // parse it ++ uint16_t network_id = (tune_data[0] << 8) | tune_data[1]; ++ uint16_t original_network_id = (tune_data[2] << 8) | tune_data[3]; ++ uint16_t transport_stream_id = (tune_data[4] << 8) | tune_data[5]; ++ uint16_t service_id = (tune_data[6] << 8) | tune_data[7]; ++ ++ // tell the app ++ pthread_mutex_lock(&dvb->lock); ++ en50221_app_dvb_tune_callback cb = dvb->tune_callback; ++ void *cb_arg = dvb->tune_callback_arg; ++ pthread_mutex_unlock(&dvb->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, network_id, ++ original_network_id, transport_stream_id, ++ service_id); ++ } ++ return 0; ++} ++ ++static int en50221_app_dvb_parse_replace(struct en50221_app_dvb *dvb, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ // validate data ++ if (data_length < 6) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (data[0] != 5) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint8_t *replace_data = data + 1; ++ ++ // parse it ++ uint8_t replacement_ref = replace_data[0]; ++ uint16_t replace_pid = ++ ((replace_data[1] & 0x1f) << 8) | replace_data[2]; ++ uint16_t replacement_pid = ++ ((replace_data[3] & 0x1f) << 8) | replace_data[4]; ++ ++ // tell the app ++ pthread_mutex_lock(&dvb->lock); ++ en50221_app_dvb_replace_callback cb = dvb->replace_callback; ++ void *cb_arg = dvb->replace_callback_arg; ++ pthread_mutex_unlock(&dvb->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, replacement_ref, ++ replace_pid, replacement_pid); ++ } ++ return 0; ++} ++ ++static int en50221_app_dvb_parse_clear_replace(struct en50221_app_dvb *dvb, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ // validate data ++ if (data_length < 2) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (data[0] != 1) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint8_t *replace_data = data + 1; ++ ++ // parse it ++ uint8_t replacement_ref = replace_data[0]; ++ ++ // tell the app ++ pthread_mutex_lock(&dvb->lock); ++ en50221_app_dvb_clear_replace_callback cb = ++ dvb->clear_replace_callback; ++ void *cb_arg = dvb->clear_replace_callback_arg; ++ pthread_mutex_unlock(&dvb->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, ++ replacement_ref); ++ } ++ return 0; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_dvb.h dvb-apps/lib/libdvben50221/en50221_app_dvb.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_dvb.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_dvb.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,176 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#ifndef __EN50221_APPLICATION_DVB_H__ ++#define __EN50221_APPLICATION_DVB_H__ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++ ++#define EN50221_APP_DVB_RESOURCEID MKRID(32,1,1) ++ ++ ++/** ++ * Type definition for tune - called when we receive a tune request from a CAM. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param network_id Network id requested by CAM. ++ * @param original_network_id Original Network id requested by CAM. ++ * @param transport_stream_id Transport stream id requested by CAM. ++ * @param service_id Service id requested by CAM. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_dvb_tune_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint16_t network_id, ++ uint32_t original_network_id, ++ uint16_t transport_stream_id, ++ uint16_t service_id); ++ ++/** ++ * Type definition for replace - called when we receive a replace request from a CAM. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param replacement_ref Replacement ref. ++ * @param replaced_pid PID to replace. ++ * @param replacement_pid PID to replace it with. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_dvb_replace_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t replacement_ref, ++ uint16_t replaced_pid, ++ uint16_t replacement_pid); ++ ++ ++/** ++ * Type definition for clear_replace - called when we receive a clear_replace request from a CAM. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param replacement_ref Replacement ref. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_dvb_clear_replace_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t replacement_ref); ++ ++ ++/** ++ * Opaque type representing a dvb resource. ++ */ ++struct en50221_app_dvb; ++ ++/** ++ * Create an instance of the dvb resource. ++ * ++ * @param funcs Send functions to use. ++ * @return Instance, or NULL on failure. ++ */ ++extern struct en50221_app_dvb *en50221_app_dvb_create(struct en50221_app_send_functions *funcs); ++ ++/** ++ * Destroy an instance of the dvb resource. ++ * ++ * @param dvb Instance to destroy. ++ */ ++extern void en50221_app_dvb_destroy(struct en50221_app_dvb *dvb); ++ ++/** ++ * Register the callback for when we receive a tune request. ++ * ++ * @param dvb DVB resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_dvb_register_tune_callback(struct en50221_app_dvb *dvb, ++ en50221_app_dvb_tune_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for when we receive a replace request. ++ * ++ * @param dvb DVB resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_dvb_register_replace_callback(struct en50221_app_dvb *dvb, ++ en50221_app_dvb_replace_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for when we receive a clear replace request. ++ * ++ * @param dvb DVB resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_dvb_register_clear_replace_callback(struct en50221_app_dvb *dvb, ++ en50221_app_dvb_clear_replace_callback callback, ++ void *arg); ++ ++/** ++ * Send an ask release request to the CAM. ++ * ++ * @param dvb DVB resource instance. ++ * @param session_number Session number to send it on. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_dvb_ask_release(struct en50221_app_dvb *dvb, ++ uint16_t session_number); ++ ++/** ++ * Pass data received for this resource into it for parsing. ++ * ++ * @param dvb dvb instance. ++ * @param slot_id Slot ID concerned. ++ * @param session_number Session number concerned. ++ * @param resource_id Resource ID concerned. ++ * @param data The data. ++ * @param data_length Length of data in bytes. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_dvb_message(struct en50221_app_dvb *dvb, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t *data, ++ uint32_t data_length); ++ ++#ifdef __cplusplus ++} ++#endif ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_epg.c dvb-apps/lib/libdvben50221/en50221_app_epg.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_epg.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_epg.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,167 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include ++#include "en50221_app_epg.h" ++#include "en50221_app_tags.h" ++#include "asn_1.h" ++ ++struct en50221_app_epg { ++ struct en50221_app_send_functions *funcs; ++ ++ en50221_app_epg_reply_callback callback; ++ void *callback_arg; ++ ++ pthread_mutex_t lock; ++}; ++ ++static int en50221_app_epg_parse_reply(struct en50221_app_epg *private, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++ ++ ++ ++struct en50221_app_epg *en50221_app_epg_create(struct en50221_app_send_functions *funcs) ++{ ++ struct en50221_app_epg *epg = NULL; ++ ++ // create structure and set it up ++ epg = malloc(sizeof(struct en50221_app_epg)); ++ if (epg == NULL) { ++ return NULL; ++ } ++ epg->funcs = funcs; ++ epg->callback = NULL; ++ ++ pthread_mutex_init(&epg->lock, NULL); ++ ++ // done ++ return epg; ++} ++ ++void en50221_app_epg_destroy(struct en50221_app_epg *epg) ++{ ++ pthread_mutex_destroy(&epg->lock); ++ free(epg); ++} ++ ++void en50221_app_epg_register_enquiry_callback(struct en50221_app_epg *epg, ++ en50221_app_epg_reply_callback callback, ++ void *arg) ++{ ++ pthread_mutex_lock(&epg->lock); ++ epg->callback = callback; ++ epg->callback_arg = arg; ++ pthread_mutex_unlock(&epg->lock); ++} ++ ++int en50221_app_epg_enquire(struct en50221_app_epg *epg, ++ uint16_t session_number, ++ uint8_t command_id, ++ uint16_t network_id, ++ uint16_t original_network_id, ++ uint16_t transport_stream_id, ++ uint16_t service_id, uint16_t event_id) ++{ ++ uint8_t data[15]; ++ ++ data[0] = (TAG_EPG_ENQUIRY >> 16) & 0xFF; ++ data[1] = (TAG_EPG_ENQUIRY >> 8) & 0xFF; ++ data[2] = TAG_EPG_ENQUIRY & 0xFF; ++ data[3] = 11; ++ data[4] = command_id; ++ data[5] = network_id >> 8; ++ data[6] = network_id; ++ data[7] = original_network_id >> 8; ++ data[8] = original_network_id; ++ data[9] = transport_stream_id >> 8; ++ data[10] = transport_stream_id; ++ data[11] = service_id >> 8; ++ data[12] = service_id; ++ data[13] = event_id >> 8; ++ data[14] = event_id; ++ return epg->funcs->send_data(epg->funcs->arg, session_number, data, 15); ++} ++ ++int en50221_app_epg_message(struct en50221_app_epg *epg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t * data, uint32_t data_length) ++{ ++ struct en50221_app_epg *private = (struct en50221_app_epg *) epg; ++ (void) resource_id; ++ ++ // get the tag ++ if (data_length < 3) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint32_t tag = (data[0] << 16) | (data[1] << 8) | data[2]; ++ ++ switch (tag) { ++ case TAG_EPG_REPLY: ++ return en50221_app_epg_parse_reply(private, slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ } ++ ++ print(LOG_LEVEL, ERROR, 1, "Received unexpected tag %x\n", tag); ++ return -1; ++} ++ ++ ++ ++static int en50221_app_epg_parse_reply(struct en50221_app_epg *epg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ // validate data ++ if (data_length != 2) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (data[0] != 1) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint8_t event_status = data[1]; ++ ++ // tell the app ++ pthread_mutex_lock(&epg->lock); ++ en50221_app_epg_reply_callback cb = epg->callback; ++ void *cb_arg = epg->callback_arg; ++ pthread_mutex_unlock(&epg->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, event_status); ++ } ++ return 0; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_epg.h dvb-apps/lib/libdvben50221/en50221_app_epg.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_epg.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_epg.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,138 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#ifndef __EN50221_APPLICATION_epg_H__ ++#define __EN50221_APPLICATION_epg_H__ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++ ++#define EPG_COMMAND_ID_MMI 0x02 ++#define EPG_COMMAND_ID_QUERY 0x03 ++ ++#define EPG_EVENTSTATUS_ENTITLEMENT_UNKNOWN 0x00 ++#define EPG_EVENTSTATUS_ENTITLEMENT_AVAILABLE 0x01 ++#define EPG_EVENTSTATUS_ENTITLEMENT_NOT_AVAILABLE 0x02 ++#define EPG_EVENTSTATUS_MMI_DIALOGUE_REQUIRED 0x03 ++#define EPG_EVENTSTATUS_MMI_COMPLETE_UNKNOWN 0x04 ++#define EPG_EVENTSTATUS_MMI_COMPLETE_AVAILABLE 0x05 ++#define EPG_EVENTSTATUS_MMI_COMPLETE_NOT_AVAILABLE 0x06 ++ ++#define EN50221_APP_EPG_RESOURCEID(INSTANCE_NUM) MKRID(120,(INSTANCE_NUM),1) ++ ++ ++ ++/** ++ * Type definition for reply - called when we receive an EPG reply from a CAM. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param event_status One of the EPG_EVENTSTATUS_* values. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_epg_reply_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t event_status); ++ ++/** ++ * Opaque type representing a epg resource. ++ */ ++struct en50221_app_epg; ++ ++/** ++ * Create an instance of the epg resource. ++ * ++ * @param funcs Send functions to use. ++ * @return Instance, or NULL on failure. ++ */ ++extern struct en50221_app_epg *en50221_app_epg_create(struct en50221_app_send_functions *funcs); ++ ++/** ++ * Destroy an instance of the epg resource. ++ * ++ * @param epg Instance to destroy. ++ */ ++extern void en50221_app_epg_destroy(struct en50221_app_epg *epg); ++ ++/** ++ * Register the callback for when we receive a enquiry response. ++ * ++ * @param epg epg resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_epg_register_reply_callback(struct en50221_app_epg *epg, ++ en50221_app_epg_reply_callback callback, ++ void *arg); ++ ++/** ++ * Enquire about the entitlement status for an EPG entry. ++ * ++ * @param epg epg resource instance. ++ * @param session_number Session number to send it on. ++ * @param command_id One of the EPG_COMMAND_ID_* fields. ++ * @param network_id Network ID concerned. ++ * @param original_network_id Original network ID concerned. ++ * @param transport_stream_id Transport stream ID concerned. ++ * @param service_id Service ID concerned. ++ * @param event_id Event ID concerned. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_epg_enquire(struct en50221_app_epg *epg, ++ uint16_t session_number, ++ uint8_t command_id, ++ uint16_t network_id, ++ uint16_t original_network_id, ++ uint16_t transport_stream_id, ++ uint16_t service_id, ++ uint16_t event_id); ++ ++/** ++ * Pass data received for this resource into it for parsing. ++ * ++ * @param epg epg instance. ++ * @param slot_id Slot ID concerned. ++ * @param session_number Session number concerned. ++ * @param resource_id Resource ID concerned. ++ * @param data The data. ++ * @param data_length Length of data in bytes. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_epg_message(struct en50221_app_epg *epg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t *data, ++ uint32_t data_length); ++ ++#ifdef __cplusplus ++} ++#endif ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_lowspeed.c dvb-apps/lib/libdvben50221/en50221_app_lowspeed.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_lowspeed.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_lowspeed.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,533 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include "en50221_app_lowspeed.h" ++#include "en50221_app_tags.h" ++#include "asn_1.h" ++ ++struct en50221_app_lowspeed_session { ++ uint16_t session_number; ++ uint8_t *block_chain; ++ uint32_t block_length; ++ ++ struct en50221_app_lowspeed_session *next; ++}; ++ ++struct en50221_app_lowspeed { ++ struct en50221_app_send_functions *funcs; ++ ++ en50221_app_lowspeed_command_callback command_callback; ++ void *command_callback_arg; ++ ++ en50221_app_lowspeed_send_callback send_callback; ++ void *send_callback_arg; ++ ++ struct en50221_app_lowspeed_session *sessions; ++ ++ pthread_mutex_t lock; ++}; ++ ++static int en50221_app_lowspeed_parse_connect_on_channel(struct en50221_app_lowspeed_command *command, ++ uint8_t *data, ++ int data_length); ++static int en50221_app_lowspeed_parse_command(struct en50221_app_lowspeed *lowspeed, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t *data, ++ uint32_t data_length); ++static int en50221_app_lowspeed_parse_send(struct en50221_app_lowspeed *lowspeed, ++ uint8_t slot_id, ++ uint16_t session_number, ++ int more_last, ++ uint8_t *data, ++ uint32_t data_length); ++ ++ ++ ++struct en50221_app_lowspeed *en50221_app_lowspeed_create(struct en50221_app_send_functions *funcs) ++{ ++ struct en50221_app_lowspeed *lowspeed = NULL; ++ ++ // create structure and set it up ++ lowspeed = malloc(sizeof(struct en50221_app_lowspeed)); ++ if (lowspeed == NULL) { ++ return NULL; ++ } ++ lowspeed->funcs = funcs; ++ lowspeed->command_callback = NULL; ++ lowspeed->send_callback = NULL; ++ lowspeed->sessions = NULL; ++ ++ pthread_mutex_init(&lowspeed->lock, NULL); ++ ++ // done ++ return lowspeed; ++} ++ ++void en50221_app_lowspeed_destroy(struct en50221_app_lowspeed *lowspeed) ++{ ++ struct en50221_app_lowspeed_session *cur_s = lowspeed->sessions; ++ while (cur_s) { ++ struct en50221_app_lowspeed_session *next = cur_s->next; ++ if (cur_s->block_chain) ++ free(cur_s->block_chain); ++ free(cur_s); ++ cur_s = next; ++ } ++ ++ pthread_mutex_destroy(&lowspeed->lock); ++ free(lowspeed); ++} ++ ++void en50221_app_lowspeed_clear_session(struct en50221_app_lowspeed *lowspeed, ++ uint16_t session_number) ++{ ++ pthread_mutex_lock(&lowspeed->lock); ++ struct en50221_app_lowspeed_session *cur_s = lowspeed->sessions; ++ struct en50221_app_lowspeed_session *prev_s = NULL; ++ while (cur_s) { ++ if (cur_s->session_number == session_number) { ++ if (cur_s->block_chain) ++ free(cur_s->block_chain); ++ if (prev_s) { ++ prev_s->next = cur_s->next; ++ } else { ++ lowspeed->sessions = cur_s->next; ++ } ++ free(cur_s); ++ return; ++ } ++ ++ prev_s = cur_s; ++ cur_s = cur_s->next; ++ } ++ pthread_mutex_unlock(&lowspeed->lock); ++} ++ ++void en50221_app_lowspeed_register_command_callback(struct en50221_app_lowspeed *lowspeed, ++ en50221_app_lowspeed_command_callback callback, ++ void *arg) ++{ ++ pthread_mutex_lock(&lowspeed->lock); ++ lowspeed->command_callback = callback; ++ lowspeed->command_callback_arg = arg; ++ pthread_mutex_unlock(&lowspeed->lock); ++} ++ ++void en50221_app_lowspeed_register_send_callback(struct en50221_app_lowspeed *lowspeed, ++ en50221_app_lowspeed_send_callback callback, ++ void *arg) ++{ ++ pthread_mutex_lock(&lowspeed->lock); ++ lowspeed->send_callback = callback; ++ lowspeed->send_callback_arg = arg; ++ pthread_mutex_unlock(&lowspeed->lock); ++} ++ ++int en50221_app_lowspeed_send_comms_reply(struct en50221_app_lowspeed *lowspeed, ++ uint16_t session_number, ++ uint8_t comms_reply_id, ++ uint8_t return_value) ++{ ++ uint8_t data[6]; ++ ++ data[0] = (TAG_COMMS_REPLY >> 16) & 0xFF; ++ data[1] = (TAG_COMMS_REPLY >> 8) & 0xFF; ++ data[2] = TAG_COMMS_REPLY & 0xFF; ++ data[3] = 2; ++ data[4] = comms_reply_id; ++ data[5] = return_value; ++ return lowspeed->funcs->send_data(lowspeed->funcs->arg, ++ session_number, data, 6); ++} ++ ++int en50221_app_lowspeed_send_comms_data(struct en50221_app_lowspeed *lowspeed, ++ uint16_t session_number, ++ uint8_t phase_id, ++ uint32_t tx_data_length, ++ uint8_t * tx_data) ++{ ++ uint8_t buf[10]; ++ ++ // the spec defines this limit ++ if (tx_data_length > 254) { ++ return -1; ++ } ++ // set up the tag ++ buf[0] = (TAG_COMMS_RECV_LAST >> 16) & 0xFF; ++ buf[1] = (TAG_COMMS_RECV_LAST >> 8) & 0xFF; ++ buf[2] = TAG_COMMS_RECV_LAST & 0xFF; ++ ++ // encode the length field ++ int length_field_len; ++ if ((length_field_len = asn_1_encode(tx_data_length + 1, buf + 3, 3)) < 0) { ++ return -1; ++ } ++ // the phase_id ++ buf[3 + length_field_len] = phase_id; ++ ++ // build the iovecs ++ struct iovec iov[2]; ++ iov[0].iov_base = buf; ++ iov[0].iov_len = 3 + length_field_len + 1; ++ iov[1].iov_base = tx_data; ++ iov[1].iov_len = tx_data_length; ++ ++ // create the data and send it ++ return lowspeed->funcs->send_datav(lowspeed->funcs->arg, ++ session_number, iov, 2); ++} ++ ++int en50221_app_lowspeed_message(struct en50221_app_lowspeed *lowspeed, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t * data, uint32_t data_length) ++{ ++ (void) resource_id; ++ ++ // get the tag ++ if (data_length < 3) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint32_t tag = (data[0] << 16) | (data[1] << 8) | data[2]; ++ ++ switch (tag) { ++ case TAG_COMMS_COMMAND: ++ return en50221_app_lowspeed_parse_command(lowspeed, ++ slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ case TAG_COMMS_SEND_LAST: ++ return en50221_app_lowspeed_parse_send(lowspeed, slot_id, ++ session_number, 1, ++ data + 3, ++ data_length - 3); ++ case TAG_COMMS_SEND_MORE: ++ return en50221_app_lowspeed_parse_send(lowspeed, slot_id, ++ session_number, 0, ++ data + 3, ++ data_length - 3); ++ } ++ ++ print(LOG_LEVEL, ERROR, 1, "Received unexpected tag %x\n", tag); ++ return -1; ++} ++ ++ ++ ++static int en50221_app_lowspeed_parse_connect_on_channel(struct en50221_app_lowspeed_command *command, ++ uint8_t *data, ++ int data_length) ++{ ++ if (data_length < 3) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ // check the tag ++ uint32_t tag = (data[0] << 16) | (data[1] << 8) | data[2]; ++ if (tag != TAG_CONNECTION_DESCRIPTOR) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received bad CONNECT_ON_CHANNEL\n"); ++ return -1; ++ } ++ data += 3; ++ data_length -= 3; ++ ++ // parse the descriptor-length-field ++ uint16_t asn_data_length; ++ int length_field_len; ++ if ((length_field_len = asn_1_decode(&asn_data_length, data, data_length)) < 0) { ++ print(LOG_LEVEL, ERROR, 1, "ASN.1 decode error\n"); ++ return -1; ++ } ++ data += length_field_len; ++ data_length -= length_field_len; ++ ++ // check length field ++ if (asn_data_length > data_length) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (asn_data_length < 1) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ // get the descriptor type ++ command->u.connect_on_channel.descriptor_type = data[0]; ++ data++; ++ data_length--; ++ asn_data_length--; ++ ++ // deal with the descriptor itself ++ switch (command->u.connect_on_channel.descriptor_type) { ++ case CONNECTION_DESCRIPTOR_TYPE_TELEPHONE: ++ { ++ // get the raw descriptor and validate length ++ struct descriptor *d = (struct descriptor *) data; ++ if (asn_data_length < 2) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received short data\n"); ++ return -1; ++ } ++ if (asn_data_length != (2 + d->len)) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received short data\n"); ++ return -1; ++ } ++ if (d->tag != dtag_dvb_telephone) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received invalid telephone descriptor\n"); ++ return -1; ++ } ++ // parse the telephone descriptor ++ command->u.connect_on_channel.descriptor.telephone = dvb_telephone_descriptor_codec(d); ++ if (command->u.connect_on_channel.descriptor.telephone == NULL) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received invalid telephone descriptor\n"); ++ return -1; ++ } ++ data += 2 + d->len; ++ data_length -= 2 + d->len; ++ break; ++ } ++ ++ case CONNECTION_DESCRIPTOR_TYPE_CABLE: ++ if (asn_data_length != 1) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received short data\n"); ++ return -1; ++ } ++ command->u.connect_on_channel.descriptor.cable_channel_id = data[0]; ++ data++; ++ data_length--; ++ break; ++ default: ++ print(LOG_LEVEL, ERROR, 1, ++ "Received unknown connection descriptor %02x\n", ++ command->u.connect_on_channel.descriptor_type); ++ return -1; ++ } ++ ++ // parse the last bit ++ if (data_length != 2) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ command->u.connect_on_channel.retry_count = data[0]; ++ command->u.connect_on_channel.timeout = data[1]; ++ ++ // ok ++ return 0; ++} ++ ++static int en50221_app_lowspeed_parse_command(struct en50221_app_lowspeed *lowspeed, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ // first of all, decode the length field ++ uint16_t asn_data_length; ++ int length_field_len; ++ if ((length_field_len = asn_1_decode(&asn_data_length, data, data_length)) < 0) { ++ print(LOG_LEVEL, ERROR, 1, "ASN.1 decode error\n"); ++ return -1; ++ } ++ // check it ++ if (asn_data_length < 1) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (asn_data_length > (data_length - length_field_len)) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ data += length_field_len; ++ ++ // get command id ++ uint8_t command_id = data[0]; ++ data++; ++ asn_data_length--; ++ ++ // parse the command ++ struct en50221_app_lowspeed_command command; ++ switch (command_id) { ++ case COMMS_COMMAND_ID_CONNECT_ON_CHANNEL: ++ if (en50221_app_lowspeed_parse_connect_on_channel ++ (&command, data, asn_data_length)) { ++ return -1; ++ } ++ break; ++ case COMMS_COMMAND_ID_SET_PARAMS: ++ if (asn_data_length != 2) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received short data\n"); ++ return -1; ++ } ++ command.u.set_params.buffer_size = data[0]; ++ command.u.set_params.timeout = data[1]; ++ break; ++ case COMMS_COMMAND_ID_GET_NEXT_BUFFER: ++ if (asn_data_length != 1) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received short data\n"); ++ return -1; ++ } ++ command.u.get_next_buffer.phase_id = data[0]; ++ break; ++ ++ case COMMS_COMMAND_ID_DISCONNECT_ON_CHANNEL: ++ case COMMS_COMMAND_ID_ENQUIRE_STATUS: ++ break; ++ ++ default: ++ print(LOG_LEVEL, ERROR, 1, ++ "Received unexpected command_id %02x\n", command_id); ++ return -1; ++ } ++ ++ // tell the app ++ pthread_mutex_lock(&lowspeed->lock); ++ en50221_app_lowspeed_command_callback cb = lowspeed->command_callback; ++ void *cb_arg = lowspeed->command_callback_arg; ++ pthread_mutex_unlock(&lowspeed->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, command_id, ++ &command); ++ } ++ return 0; ++} ++ ++static int en50221_app_lowspeed_parse_send(struct en50221_app_lowspeed *lowspeed, ++ uint8_t slot_id, ++ uint16_t session_number, ++ int more_last, ++ uint8_t *data, ++ uint32_t data_length) ++{ ++ // first of all, decode the length field ++ uint16_t asn_data_length; ++ int length_field_len; ++ if ((length_field_len = asn_1_decode(&asn_data_length, data, data_length)) < 0) { ++ print(LOG_LEVEL, ERROR, 1, "ASN.1 decode error\n"); ++ return -1; ++ } ++ // check it ++ if (asn_data_length > (data_length - length_field_len)) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ // skip over the length field ++ data += length_field_len; ++ ++ // find previous session ++ pthread_mutex_lock(&lowspeed->lock); ++ struct en50221_app_lowspeed_session *cur_s = lowspeed->sessions; ++ while (cur_s) { ++ if (cur_s->session_number == session_number) ++ break; ++ cur_s = cur_s->next; ++ } ++ ++ // more data is still to come ++ if (!more_last) { ++ // if there was no previous session, create one ++ if (cur_s == NULL) { ++ cur_s = malloc(sizeof(struct en50221_app_lowspeed_session)); ++ if (cur_s == NULL) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Ran out of memory\n"); ++ pthread_mutex_unlock(&lowspeed->lock); ++ return -1; ++ } ++ cur_s->session_number = session_number; ++ cur_s->block_chain = NULL; ++ cur_s->block_length = 0; ++ cur_s->next = lowspeed->sessions; ++ lowspeed->sessions = cur_s; ++ } ++ // append the data ++ uint8_t *new_data = realloc(cur_s->block_chain, ++ cur_s->block_length + asn_data_length); ++ if (new_data == NULL) { ++ print(LOG_LEVEL, ERROR, 1, "Ran out of memory\n"); ++ pthread_mutex_unlock(&lowspeed->lock); ++ return -1; ++ } ++ memcpy(new_data + cur_s->block_length, data, asn_data_length); ++ cur_s->block_chain = new_data; ++ cur_s->block_length += asn_data_length; ++ ++ // done ++ pthread_mutex_unlock(&lowspeed->lock); ++ return 0; ++ } ++ // we hit the last of a possible chain of fragments ++ int do_free = 0; ++ if (cur_s != NULL) { ++ // we have a preceding fragment - need to append ++ uint8_t *new_data = realloc(cur_s->block_chain, ++ cur_s->block_length + asn_data_length); ++ if (new_data == NULL) { ++ print(LOG_LEVEL, ERROR, 1, "Ran out of memory\n"); ++ pthread_mutex_unlock(&lowspeed->lock); ++ return -1; ++ } ++ memcpy(new_data + cur_s->block_length, data, asn_data_length); ++ asn_data_length = cur_s->block_length + asn_data_length; ++ data = new_data; ++ cur_s->block_chain = NULL; ++ cur_s->block_length = 0; ++ do_free = 1; ++ } ++ // check the reassembled data length ++ if (asn_data_length < 1) { ++ pthread_mutex_unlock(&lowspeed->lock); ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ if (do_free) ++ free(data); ++ return -1; ++ } ++ // now, parse the data ++ uint8_t phase_id = data[0]; ++ ++ // tell the app ++ en50221_app_lowspeed_send_callback cb = lowspeed->send_callback; ++ void *cb_arg = lowspeed->send_callback_arg; ++ pthread_mutex_unlock(&lowspeed->lock); ++ int cbstatus = 0; ++ if (cb) { ++ cbstatus = ++ cb(cb_arg, slot_id, session_number, phase_id, data + 1, asn_data_length - 1); ++ } ++ // done ++ if (do_free) ++ free(data); ++ return cbstatus; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_lowspeed.h dvb-apps/lib/libdvben50221/en50221_app_lowspeed.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_lowspeed.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_lowspeed.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,219 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#ifndef __EN50221_APPLICATION_LOWSPEED_H__ ++#define __EN50221_APPLICATION_LOWSPEED_H__ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++#include ++ ++#define COMMS_COMMAND_ID_CONNECT_ON_CHANNEL 0x01 ++#define COMMS_COMMAND_ID_DISCONNECT_ON_CHANNEL 0x02 ++#define COMMS_COMMAND_ID_SET_PARAMS 0x03 ++#define COMMS_COMMAND_ID_ENQUIRE_STATUS 0x04 ++#define COMMS_COMMAND_ID_GET_NEXT_BUFFER 0x05 ++ ++#define CONNECTION_DESCRIPTOR_TYPE_TELEPHONE 0x01 ++#define CONNECTION_DESCRIPTOR_TYPE_CABLE 0x02 ++ ++#define COMMS_REPLY_ID_CONNECT_ACK 0x01 ++#define COMMS_REPLY_ID_DISCONNECT_ACK 0x02 ++#define COMMS_REPLY_ID_SET_PARAMS_ACK 0x03 ++#define COMMS_REPLY_ID_STATUS_REPLY 0x04 ++#define COMMS_REPLY_ID_GET_NEXT_BUFFER_ACK 0x05 ++#define COMMS_REPLY_ID_SEND_ACK 0x06 ++ ++#define EN50221_APP_LOWSPEED_RESOURCEID(DEVICE_TYPE, DEVICE_NUMBER) MKRID(96,((DEVICE_TYPE)<<2)|((DEVICE_NUMBER) & 0x03),1) ++ ++ ++/** ++ * Structure holding information on a received comms command. ++ */ ++struct en50221_app_lowspeed_command { ++ union { ++ struct { ++ uint8_t descriptor_type; // CONNECTION_DESCRIPTOR_TYPE_* ++ uint8_t retry_count; ++ uint8_t timeout; ++ union { ++ struct dvb_telephone_descriptor *telephone; ++ uint8_t cable_channel_id; ++ } descriptor; ++ } connect_on_channel; ++ ++ struct { ++ uint8_t buffer_size; ++ uint8_t timeout; ++ } set_params; ++ ++ struct { ++ uint8_t phase_id; ++ } get_next_buffer; ++ } u; ++}; ++ ++/** ++ * Type definition for command - called when we receive a comms command. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param command_id One of the COMMS_COMMAND_ID_* values ++ * @param command Pointer to a lowspeed command structure containing the command data. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_lowspeed_command_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t command_id, ++ struct en50221_app_lowspeed_command *command); ++ ++/** ++ * Type definition for send - called when we receive data to send. The block can be segmented into ++ * multiple pieces - last_more indicates the details of this. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param phase_id Comms phase id. ++ * @param data The data. ++ * @param length Number of bytes. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_lowspeed_send_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t phase_id, ++ uint8_t *data, ++ uint32_t length); ++ ++/** ++ * Opaque type representing a lowspeed resource. ++ */ ++struct en50221_app_lowspeed; ++ ++/** ++ * Create an instance of the lowspeed resource. ++ * ++ * @param funcs Send functions to use. ++ * @return Instance, or NULL on failure. ++ */ ++extern struct en50221_app_lowspeed * ++ en50221_app_lowspeed_create(struct en50221_app_send_functions *funcs); ++ ++/** ++ * Destroy an instance of the lowspeed resource. ++ * ++ * @param lowspeed Instance to destroy. ++ */ ++extern void en50221_app_lowspeed_destroy(struct en50221_app_lowspeed *lowspeed); ++ ++/** ++ * Informs the lowspeed object that a session to it has been closed - cleans up internal state. ++ * ++ * @param lowspeed lowspeed resource instance. ++ * @param session_number The session concerned. ++ */ ++extern void en50221_app_lowspeed_clear_session(struct en50221_app_lowspeed *lowspeed, ++ uint16_t session_number); ++ ++/** ++ * Register the callback for when we receive a comms command. ++ * ++ * @param lowspeed lowspeed resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_lowspeed_register_command_callback(struct en50221_app_lowspeed *lowspeed, ++ en50221_app_lowspeed_command_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for when we receive data to send. ++ * ++ * @param lowspeed lowspeed resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_lowspeed_register_send_callback(struct en50221_app_lowspeed *lowspeed, ++ en50221_app_lowspeed_send_callback callback, ++ void *arg); ++ ++/** ++ * Send a comms reply to the CAM. ++ * ++ * @param lowspeed lowspeed resource instance. ++ * @param session_number Session number to send it on. ++ * @param comms_reply_id One of the COMMS_REPLY_ID_* values. ++ * @param return_value Comms reply specific value. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_lowspeed_send_comms_reply(struct en50221_app_lowspeed *lowspeed, ++ uint16_t session_number, ++ uint8_t comms_reply_id, ++ uint8_t return_value); ++ ++/** ++ * Send received data to the CAM. ++ * ++ * @param lowspeed lowspeed resource instance. ++ * @param session_number Session number to send it on. ++ * @param phase_id Comms phase id. ++ * @param tx_data_length Length of data in bytes (max 254 bytes as per spec). ++ * @param tx_data Data. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_lowspeed_send_comms_data(struct en50221_app_lowspeed *lowspeed, ++ uint16_t session_number, ++ uint8_t phase_id, ++ uint32_t tx_data_length, ++ uint8_t * tx_data); ++ ++/** ++ * Pass data received for this resource into it for parsing. ++ * ++ * @param lowspeed lowspeed instance. ++ * @param slot_id Slot ID concerned. ++ * @param session_number Session number concerned. ++ * @param resource_id Resource ID concerned. ++ * @param data The data. ++ * @param data_length Length of data in bytes. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_lowspeed_message(struct en50221_app_lowspeed *lowspeed, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t * data, ++ uint32_t data_length); ++ ++#ifdef __cplusplus ++} ++#endif ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_mmi.c dvb-apps/lib/libdvben50221/en50221_app_mmi.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_mmi.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_mmi.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,1397 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include ++#include "en50221_app_mmi.h" ++#include "en50221_app_tags.h" ++#include "asn_1.h" ++ ++struct en50221_app_mmi_session { ++ uint16_t session_number; ++ ++ uint8_t *menu_block_chain; ++ uint32_t menu_block_length; ++ ++ uint8_t *list_block_chain; ++ uint32_t list_block_length; ++ ++ uint8_t *subtitlesegment_block_chain; ++ uint32_t subtitlesegment_block_length; ++ ++ uint8_t *subtitledownload_block_chain; ++ uint32_t subtitledownload_block_length; ++ ++ struct en50221_app_mmi_session *next; ++}; ++ ++struct en50221_app_mmi { ++ struct en50221_app_send_functions *funcs; ++ struct en50221_app_mmi_session *sessions; ++ ++ en50221_app_mmi_close_callback closecallback; ++ void *closecallback_arg; ++ ++ en50221_app_mmi_display_control_callback displaycontrolcallback; ++ void *displaycontrolcallback_arg; ++ ++ en50221_app_mmi_keypad_control_callback keypadcontrolcallback; ++ void *keypadcontrolcallback_arg; ++ ++ en50221_app_mmi_subtitle_segment_callback subtitlesegmentcallback; ++ void *subtitlesegmentcallback_arg; ++ ++ en50221_app_mmi_scene_end_mark_callback sceneendmarkcallback; ++ void *sceneendmarkcallback_arg; ++ ++ en50221_app_mmi_scene_control_callback scenecontrolcallback; ++ void *scenecontrolcallback_arg; ++ ++ en50221_app_mmi_subtitle_download_callback subtitledownloadcallback; ++ void *subtitledownloadcallback_arg; ++ ++ en50221_app_mmi_flush_download_callback flushdownloadcallback; ++ void *flushdownloadcallback_arg; ++ ++ en50221_app_mmi_enq_callback enqcallback; ++ void *enqcallback_arg; ++ ++ en50221_app_mmi_menu_callback menucallback; ++ void *menucallback_arg; ++ ++ en50221_app_mmi_list_callback listcallback; ++ void *listcallback_arg; ++ ++ pthread_mutex_t lock; ++}; ++ ++static int en50221_app_mmi_parse_close(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++static int en50221_app_mmi_parse_display_control(struct en50221_app_mmi ++ *mmi, uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++static int en50221_app_mmi_parse_keypad_control(struct en50221_app_mmi ++ *mmi, uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++static int en50221_app_mmi_parse_enq(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, uint32_t data_length); ++static int en50221_app_mmi_parse_list_menu(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t tag_id, int more_last, ++ uint8_t * data, ++ uint32_t data_length); ++static int en50221_app_mmi_parse_subtitle(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t tag_id, int more_last, ++ uint8_t * data, ++ uint32_t data_length); ++static int en50221_app_mmi_parse_scene_end_mark(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++static int en50221_app_mmi_parse_scene_control(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++static int en50221_app_mmi_parse_subtitle(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t tag_id, int more_last, ++ uint8_t * data, ++ uint32_t data_length); ++static int en50221_app_mmi_parse_flush_download(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++static int en50221_app_mmi_defragment(struct en50221_app_mmi *mmi, ++ uint16_t session_number, ++ uint32_t tag_id, int more_last, ++ uint8_t * indata, ++ uint32_t indata_length, ++ uint8_t ** outdata, ++ uint32_t * outdata_length); ++static int en50221_app_mmi_defragment_text(uint8_t * data, ++ uint32_t data_length, ++ uint8_t ** outdata, ++ uint32_t * outdata_length, ++ uint32_t * outconsumed); ++ ++ ++ ++struct en50221_app_mmi *en50221_app_mmi_create(struct en50221_app_send_functions *funcs) ++{ ++ struct en50221_app_mmi *mmi = NULL; ++ ++ // create structure and set it up ++ mmi = malloc(sizeof(struct en50221_app_mmi)); ++ if (mmi == NULL) { ++ return NULL; ++ } ++ mmi->funcs = funcs; ++ mmi->closecallback = NULL; ++ mmi->displaycontrolcallback = NULL; ++ mmi->keypadcontrolcallback = NULL; ++ mmi->subtitlesegmentcallback = NULL; ++ mmi->sceneendmarkcallback = NULL; ++ mmi->scenecontrolcallback = NULL; ++ mmi->subtitledownloadcallback = NULL; ++ mmi->flushdownloadcallback = NULL; ++ mmi->enqcallback = NULL; ++ mmi->menucallback = NULL; ++ mmi->listcallback = NULL; ++ mmi->sessions = NULL; ++ ++ pthread_mutex_init(&mmi->lock, NULL); ++ ++ // done ++ return mmi; ++} ++ ++void en50221_app_mmi_destroy(struct en50221_app_mmi *mmi) ++{ ++ struct en50221_app_mmi_session *cur_s = mmi->sessions; ++ while (cur_s) { ++ struct en50221_app_mmi_session *next = cur_s->next; ++ if (cur_s->menu_block_chain) ++ free(cur_s->menu_block_chain); ++ if (cur_s->list_block_chain) ++ free(cur_s->list_block_chain); ++ if (cur_s->subtitlesegment_block_chain) ++ free(cur_s->subtitlesegment_block_chain); ++ if (cur_s->subtitledownload_block_chain) ++ free(cur_s->subtitledownload_block_chain); ++ free(cur_s); ++ cur_s = next; ++ } ++ ++ pthread_mutex_destroy(&mmi->lock); ++ free(mmi); ++} ++ ++void en50221_app_mmi_clear_session(struct en50221_app_mmi *mmi, ++ uint16_t session_number) ++{ ++ pthread_mutex_lock(&mmi->lock); ++ struct en50221_app_mmi_session *cur_s = mmi->sessions; ++ struct en50221_app_mmi_session *prev_s = NULL; ++ while (cur_s) { ++ if (cur_s->session_number == session_number) { ++ if (cur_s->menu_block_chain) ++ free(cur_s->menu_block_chain); ++ if (cur_s->list_block_chain) ++ free(cur_s->list_block_chain); ++ if (cur_s->subtitlesegment_block_chain) ++ free(cur_s->subtitlesegment_block_chain); ++ if (cur_s->subtitledownload_block_chain) ++ free(cur_s->subtitledownload_block_chain); ++ if (prev_s) { ++ prev_s->next = cur_s->next; ++ } else { ++ mmi->sessions = cur_s->next; ++ } ++ free(cur_s); ++ return; ++ } ++ ++ prev_s = cur_s; ++ cur_s = cur_s->next; ++ } ++ pthread_mutex_unlock(&mmi->lock); ++} ++ ++void en50221_app_mmi_register_close_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_close_callback callback, ++ void *arg) ++{ ++ pthread_mutex_lock(&mmi->lock); ++ mmi->closecallback = callback; ++ mmi->closecallback_arg = arg; ++ pthread_mutex_unlock(&mmi->lock); ++} ++ ++void en50221_app_mmi_register_display_control_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_display_control_callback callback, ++ void *arg) ++{ ++ pthread_mutex_lock(&mmi->lock); ++ mmi->displaycontrolcallback = callback; ++ mmi->displaycontrolcallback_arg = arg; ++ pthread_mutex_unlock(&mmi->lock); ++} ++ ++void en50221_app_mmi_register_keypad_control_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_keypad_control_callback callback, ++ void *arg) ++{ ++ pthread_mutex_lock(&mmi->lock); ++ mmi->keypadcontrolcallback = callback; ++ mmi->keypadcontrolcallback_arg = arg; ++ pthread_mutex_unlock(&mmi->lock); ++} ++ ++void en50221_app_mmi_register_subtitle_segment_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_subtitle_segment_callback callback, ++ void *arg) ++{ ++ pthread_mutex_lock(&mmi->lock); ++ mmi->subtitlesegmentcallback = callback; ++ mmi->subtitlesegmentcallback_arg = arg; ++ pthread_mutex_unlock(&mmi->lock); ++} ++ ++void en50221_app_mmi_register_scene_end_mark_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_scene_end_mark_callback callback, void *arg) ++{ ++ pthread_mutex_lock(&mmi->lock); ++ mmi->sceneendmarkcallback = callback; ++ mmi->sceneendmarkcallback_arg = arg; ++ pthread_mutex_unlock(&mmi->lock); ++} ++ ++void en50221_app_mmi_register_scene_control_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_scene_control_callback callback, void *arg) ++{ ++ pthread_mutex_lock(&mmi->lock); ++ mmi->scenecontrolcallback = callback; ++ mmi->scenecontrolcallback_arg = arg; ++ pthread_mutex_unlock(&mmi->lock); ++} ++ ++void en50221_app_mmi_register_subtitle_download_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_subtitle_download_callback callback, ++ void *arg) ++{ ++ pthread_mutex_lock(&mmi->lock); ++ mmi->subtitledownloadcallback = callback; ++ mmi->subtitledownloadcallback_arg = arg; ++ pthread_mutex_unlock(&mmi->lock); ++} ++ ++void en50221_app_mmi_register_flush_download_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_flush_download_callback callback, ++ void *arg) ++{ ++ pthread_mutex_lock(&mmi->lock); ++ mmi->flushdownloadcallback = callback; ++ mmi->flushdownloadcallback_arg = arg; ++ pthread_mutex_unlock(&mmi->lock); ++} ++ ++void en50221_app_mmi_register_enq_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_enq_callback callback, ++ void *arg) ++{ ++ pthread_mutex_lock(&mmi->lock); ++ mmi->enqcallback = callback; ++ mmi->enqcallback_arg = arg; ++ pthread_mutex_unlock(&mmi->lock); ++} ++ ++void en50221_app_mmi_register_menu_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_menu_callback callback, ++ void *arg) ++{ ++ pthread_mutex_lock(&mmi->lock); ++ mmi->menucallback = callback; ++ mmi->menucallback_arg = arg; ++ pthread_mutex_unlock(&mmi->lock); ++} ++ ++void en50221_app_mmi_register_list_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_list_callback callback, ++ void *arg) ++{ ++ pthread_mutex_lock(&mmi->lock); ++ mmi->listcallback = callback; ++ mmi->listcallback_arg = arg; ++ pthread_mutex_unlock(&mmi->lock); ++} ++ ++int en50221_app_mmi_close(struct en50221_app_mmi *mmi, ++ uint16_t session_number, ++ uint8_t cmd_id, uint8_t delay) ++{ ++ uint8_t data[6]; ++ int data_length = 5; ++ ++ data[0] = (TAG_CLOSE_MMI >> 16) & 0xFF; ++ data[1] = (TAG_CLOSE_MMI >> 8) & 0xFF; ++ data[2] = TAG_CLOSE_MMI & 0xFF; ++ data[3] = 1; ++ data[4] = cmd_id; ++ if (cmd_id == MMI_CLOSE_MMI_CMD_ID_DELAY) { ++ data[3] = 2; ++ data[5] = delay; ++ data_length = 6; ++ } ++ return mmi->funcs->send_data(mmi->funcs->arg, session_number, data, ++ data_length); ++} ++ ++int en50221_app_mmi_display_reply(struct en50221_app_mmi *mmi, ++ uint16_t session_number, ++ uint8_t reply_id, ++ struct en50221_app_mmi_display_reply_details *details) ++{ ++ uint8_t data[32]; ++ struct iovec iov[2]; ++ uint32_t iov_count; ++ int length_field_len; ++ ++ // fill out the start of the header ++ data[0] = (TAG_DISPLAY_REPLY >> 16) & 0xFF; ++ data[1] = (TAG_DISPLAY_REPLY >> 8) & 0xFF; ++ data[2] = TAG_DISPLAY_REPLY & 0xFF; ++ ++ switch (reply_id) { ++ case MMI_DISPLAY_REPLY_ID_MMI_MODE_ACK: ++ data[3] = 2; ++ data[4] = reply_id; ++ data[5] = details->u.mode_ack.mmi_mode; ++ iov[0].iov_base = data; ++ iov[0].iov_len = 6; ++ iov_count = 1; ++ break; ++ ++ case MMI_DISPLAY_REPLY_ID_LIST_DISPLAY_CHAR_TABLES: ++ case MMI_DISPLAY_REPLY_ID_LIST_INPUT_CHAR_TABLES: ++ if ((length_field_len = ++ asn_1_encode(details->u.char_table.table_length + 1, data + 3, 3)) < 0) { ++ return -1; ++ } ++ data[3 + length_field_len] = reply_id; ++ iov[0].iov_base = data; ++ iov[0].iov_len = 3 + length_field_len + 1; ++ iov[1].iov_base = details->u.char_table.table; ++ iov[1].iov_len = details->u.char_table.table_length; ++ iov_count = 2; ++ break; ++ ++ case MMI_DISPLAY_REPLY_ID_LIST_OVERLAY_GFX_CHARACTERISTICS: ++ case MMI_DISPLAY_REPLY_ID_LIST_FULLSCREEN_GFX_CHARACTERISTICS: ++ { ++ if ((length_field_len = ++ asn_1_encode(1 + 9 + (details->u.gfx.num_pixel_depths * 2), data + 3, 3)) < 0) { ++ return -1; ++ } ++ data[3 + length_field_len] = reply_id; ++ data[3 + length_field_len + 1] = details->u.gfx.width >> 8; ++ data[3 + length_field_len + 2] = details->u.gfx.width; ++ data[3 + length_field_len + 3] = details->u.gfx.height >> 8; ++ data[3 + length_field_len + 4] = details->u.gfx.height; ++ data[3 + length_field_len + 5] = ++ ((details->u.gfx.aspect_ratio & 0x0f) << 4) | ++ ((details->u.gfx.gfx_relation_to_video & 0x07) << 1) | ++ (details->u.gfx.multiple_depths & 1); ++ data[3 + length_field_len + 6] = details->u.gfx.display_bytes >> 4; ++ data[3 + length_field_len + 7] = ++ ((details->u.gfx.display_bytes & 0x0f) << 4) | ++ ((details->u.gfx.composition_buffer_bytes & 0xf0) >> 4); ++ data[3 + length_field_len + 8] = ++ ((details->u.gfx.composition_buffer_bytes & 0x0f) << 4) | ++ ((details->u.gfx.object_cache_bytes & 0xf0) >> 4); ++ data[3 + length_field_len + 9] = ++ ((details->u.gfx.object_cache_bytes & 0x0f) << 4) | ++ (details->u.gfx.num_pixel_depths & 0x0f); ++ ++ // render the pixel depths themselves ++ uint8_t *pixdepths = ++ alloca(details->u.gfx.num_pixel_depths * 2); ++ if (pixdepths == NULL) { ++ return -1; ++ } ++ uint32_t i; ++ for (i = 0; i < details->u.gfx.num_pixel_depths; i++) { ++ pixdepths[0] = ++ ((details->u.gfx.pixel_depths[i].display_depth & 0x07) << 5) | ++ ((details->u.gfx.pixel_depths[i].pixels_per_byte & 0x07) << 2); ++ pixdepths[1] = ++ details->u.gfx.pixel_depths[i].region_overhead; ++ pixdepths += 2; ++ } ++ ++ // make up the iovs ++ iov[0].iov_base = data; ++ iov[0].iov_len = 3 + length_field_len + 10; ++ iov[1].iov_base = pixdepths; ++ iov[1].iov_len = ++ details->u.gfx.num_pixel_depths * 2; ++ iov_count = 2; ++ break; ++ } ++ ++ default: ++ data[3] = 1; ++ data[4] = reply_id; ++ iov[0].iov_base = data; ++ iov[0].iov_len = 5; ++ iov_count = 1; ++ break; ++ } ++ ++ // sendit ++ return mmi->funcs->send_datav(mmi->funcs->arg, session_number, iov, iov_count); ++} ++ ++int en50221_app_mmi_keypress(struct en50221_app_mmi *mmi, ++ uint16_t session_number, uint8_t keycode) ++{ ++ uint8_t data[5]; ++ ++ data[0] = (TAG_KEYPRESS >> 16) & 0xFF; ++ data[1] = (TAG_KEYPRESS >> 8) & 0xFF; ++ data[2] = TAG_KEYPRESS & 0xFF; ++ data[3] = 1; ++ data[4] = keycode; ++ return mmi->funcs->send_data(mmi->funcs->arg, session_number, data, 5); ++} ++ ++int en50221_app_mmi_display_message(struct en50221_app_mmi *mmi, ++ uint16_t session_number, ++ uint8_t display_message_id) ++{ ++ uint8_t data[5]; ++ ++ data[0] = (TAG_DISPLAY_MESSAGE >> 16) & 0xFF; ++ data[1] = (TAG_DISPLAY_MESSAGE >> 8) & 0xFF; ++ data[2] = TAG_DISPLAY_MESSAGE & 0xFF; ++ data[3] = 1; ++ data[4] = display_message_id; ++ return mmi->funcs->send_data(mmi->funcs->arg, session_number, data, 5); ++} ++ ++int en50221_app_mmi_scene_done(struct en50221_app_mmi *mmi, ++ uint16_t session_number, ++ uint8_t decoder_continue, ++ uint8_t scene_reveal, uint8_t scene_tag) ++{ ++ uint8_t data[5]; ++ ++ data[0] = (TAG_SCENE_DONE >> 16) & 0xFF; ++ data[1] = (TAG_SCENE_DONE >> 8) & 0xFF; ++ data[2] = TAG_SCENE_DONE & 0xFF; ++ data[3] = 1; ++ data[4] = ++ (decoder_continue ? 0x80 : 0x00) | ++ (scene_reveal ? 0x40 : 0x00) | ++ (scene_tag & 0x0f); ++ return mmi->funcs->send_data(mmi->funcs->arg, session_number, data, 5); ++} ++ ++int en50221_app_mmi_download_reply(struct en50221_app_mmi *mmi, ++ uint16_t session_number, ++ uint16_t object_id, ++ uint8_t download_reply_id) ++{ ++ uint8_t data[7]; ++ ++ data[0] = (TAG_DOWNLOAD_REPLY >> 16) & 0xFF; ++ data[1] = (TAG_DOWNLOAD_REPLY >> 8) & 0xFF; ++ data[2] = TAG_DOWNLOAD_REPLY & 0xFF; ++ data[3] = 3; ++ data[4] = object_id >> 8; ++ data[5] = object_id; ++ data[6] = download_reply_id; ++ return mmi->funcs->send_data(mmi->funcs->arg, session_number, data, 7); ++} ++ ++int en50221_app_mmi_answ(struct en50221_app_mmi *mmi, ++ uint16_t session_number, ++ uint8_t answ_id, ++ uint8_t * text, uint32_t text_count) ++{ ++ uint8_t buf[10]; ++ ++ // set up the tag ++ buf[0] = (TAG_ANSWER >> 16) & 0xFF; ++ buf[1] = (TAG_ANSWER >> 8) & 0xFF; ++ buf[2] = TAG_ANSWER & 0xFF; ++ ++ // encode the length field ++ struct iovec iov[2]; ++ int length_field_len = 0; ++ int iov_count = 1; ++ if (answ_id == MMI_ANSW_ID_ANSWER) { ++ if ((length_field_len = asn_1_encode(text_count + 1, buf + 3, 3)) < 0) { ++ return -1; ++ } ++ buf[3 + length_field_len] = answ_id; ++ ++ iov[0].iov_base = buf; ++ iov[0].iov_len = 3 + length_field_len + 1; ++ iov[1].iov_base = text; ++ iov[1].iov_len = text_count; ++ iov_count = 2; ++ } else { ++ buf[3] = 1; ++ buf[4] = answ_id; ++ iov[0].iov_base = buf; ++ iov[0].iov_len = 5; ++ iov_count = 1; ++ } ++ ++ // create the data and send it ++ return mmi->funcs->send_datav(mmi->funcs->arg, session_number, iov, ++ iov_count); ++} ++ ++int en50221_app_mmi_menu_answ(struct en50221_app_mmi *mmi, ++ uint16_t session_number, uint8_t choice_ref) ++{ ++ uint8_t data[5]; ++ ++ data[0] = (TAG_MENU_ANSWER >> 16) & 0xFF; ++ data[1] = (TAG_MENU_ANSWER >> 8) & 0xFF; ++ data[2] = TAG_MENU_ANSWER & 0xFF; ++ data[3] = 1; ++ data[4] = choice_ref; ++ return mmi->funcs->send_data(mmi->funcs->arg, session_number, data, 5); ++} ++ ++int en50221_app_mmi_message(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t * data, uint32_t data_length) ++{ ++ (void) resource_id; ++ ++ // get the tag ++ if (data_length < 3) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint32_t tag = (data[0] << 16) | (data[1] << 8) | data[2]; ++ ++ switch (tag) { ++ case TAG_CLOSE_MMI: ++ return en50221_app_mmi_parse_close(mmi, slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ case TAG_DISPLAY_CONTROL: ++ return en50221_app_mmi_parse_display_control(mmi, slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ case TAG_KEYPAD_CONTROL: ++ return en50221_app_mmi_parse_keypad_control(mmi, slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ case TAG_ENQUIRY: ++ return en50221_app_mmi_parse_enq(mmi, slot_id, ++ session_number, data + 3, ++ data_length - 3); ++ case TAG_MENU_LAST: ++ return en50221_app_mmi_parse_list_menu(mmi, slot_id, ++ session_number, tag, ++ 1, data + 3, ++ data_length - 3); ++ case TAG_MENU_MORE: ++ return en50221_app_mmi_parse_list_menu(mmi, slot_id, ++ session_number, tag, ++ 0, data + 3, ++ data_length - 3); ++ case TAG_LIST_LAST: ++ return en50221_app_mmi_parse_list_menu(mmi, slot_id, ++ session_number, tag, ++ 1, data + 3, ++ data_length - 3); ++ case TAG_LIST_MORE: ++ return en50221_app_mmi_parse_list_menu(mmi, slot_id, ++ session_number, tag, ++ 0, data + 3, ++ data_length - 3); ++ case TAG_SUBTITLE_SEGMENT_LAST: ++ return en50221_app_mmi_parse_subtitle(mmi, slot_id, ++ session_number, tag, ++ 1, data + 3, ++ data_length - 3); ++ case TAG_SUBTITLE_SEGMENT_MORE: ++ return en50221_app_mmi_parse_subtitle(mmi, slot_id, ++ session_number, tag, ++ 0, data + 3, ++ data_length - 3); ++ case TAG_SCENE_END_MARK: ++ return en50221_app_mmi_parse_scene_end_mark(mmi, slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ case TAG_SCENE_CONTROL: ++ return en50221_app_mmi_parse_scene_control(mmi, slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ case TAG_SUBTITLE_DOWNLOAD_LAST: ++ return en50221_app_mmi_parse_subtitle(mmi, slot_id, ++ session_number, tag, ++ 1, data + 3, ++ data_length - 3); ++ case TAG_SUBTITLE_DOWNLOAD_MORE: ++ return en50221_app_mmi_parse_subtitle(mmi, slot_id, ++ session_number, tag, ++ 0, data + 3, ++ data_length - 3); ++ case TAG_FLUSH_DOWNLOAD: ++ return en50221_app_mmi_parse_flush_download(mmi, slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ } ++ ++ print(LOG_LEVEL, ERROR, 1, "Received unexpected tag %x\n", tag); ++ return -1; ++} ++ ++ ++ ++ ++ ++static int en50221_app_mmi_parse_close(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ // validate data ++ if (data_length < 2) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (data[0] > (data_length - 1)) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint8_t cmd_id = data[1]; ++ uint8_t delay = 0; ++ if (cmd_id == MMI_CLOSE_MMI_CMD_ID_DELAY) { ++ if (data[0] != 2) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received short data\n"); ++ return -1; ++ } ++ delay = data[2]; ++ } ++ // tell the app ++ pthread_mutex_lock(&mmi->lock); ++ en50221_app_mmi_close_callback cb = mmi->closecallback; ++ void *cb_arg = mmi->closecallback_arg; ++ pthread_mutex_unlock(&mmi->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, cmd_id, delay); ++ } ++ return 0; ++} ++ ++static int en50221_app_mmi_parse_display_control(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t *data, ++ uint32_t data_length) ++{ ++ // validate data ++ if (data_length < 2) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (data[0] > (data_length - 1)) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint8_t cmd_id = data[1]; ++ uint8_t mmi_mode = 0; ++ if (cmd_id == MMI_DISPLAY_CONTROL_CMD_ID_SET_MMI_MODE) { ++ if (data[0] != 2) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received short data\n"); ++ return -1; ++ } ++ mmi_mode = data[2]; ++ } ++ // tell the app ++ pthread_mutex_lock(&mmi->lock); ++ en50221_app_mmi_display_control_callback cb = mmi->displaycontrolcallback; ++ void *cb_arg = mmi->displaycontrolcallback_arg; ++ pthread_mutex_unlock(&mmi->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, cmd_id, mmi_mode); ++ } ++ return 0; ++} ++ ++static int en50221_app_mmi_parse_keypad_control(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t *data, ++ uint32_t data_length) ++{ ++ // first of all, decode the length field ++ uint16_t asn_data_length; ++ int length_field_len; ++ if ((length_field_len = asn_1_decode(&asn_data_length, data, data_length)) < 0) { ++ print(LOG_LEVEL, ERROR, 1, "ASN.1 decode error\n"); ++ return -1; ++ } ++ // check it ++ if (asn_data_length > (data_length - length_field_len)) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (asn_data_length < 1) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ // skip over the length field ++ data += length_field_len; ++ ++ // extract the information ++ uint8_t cmd_id = data[0]; ++ uint8_t *keycodes = data + 1; ++ ++ // tell the app ++ pthread_mutex_lock(&mmi->lock); ++ en50221_app_mmi_keypad_control_callback cb = mmi->keypadcontrolcallback; ++ void *cb_arg = mmi->keypadcontrolcallback_arg; ++ pthread_mutex_unlock(&mmi->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, cmd_id, ++ keycodes, asn_data_length - 1); ++ } ++ return 0; ++} ++ ++static int en50221_app_mmi_parse_enq(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, uint32_t data_length) ++{ ++ // first of all, decode the length field ++ uint16_t asn_data_length; ++ int length_field_len; ++ if ((length_field_len = asn_1_decode(&asn_data_length, data, data_length)) < 0) { ++ print(LOG_LEVEL, ERROR, 1, "ASN.1 decode error\n"); ++ return -1; ++ } ++ // check it ++ if (asn_data_length > (data_length - length_field_len)) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (asn_data_length < 2) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ // skip over the length field ++ data += length_field_len; ++ ++ // extract the information ++ uint8_t blind_answer = (data[0] & 0x01) ? 1 : 0; ++ uint8_t answer_length = data[1]; ++ uint8_t *text = data + 2; ++ ++ // tell the app ++ pthread_mutex_lock(&mmi->lock); ++ en50221_app_mmi_enq_callback cb = mmi->enqcallback; ++ void *cb_arg = mmi->enqcallback_arg; ++ pthread_mutex_unlock(&mmi->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, blind_answer, ++ answer_length, text, asn_data_length - 2); ++ } ++ return 0; ++} ++ ++static int en50221_app_mmi_parse_list_menu(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t tag_id, int more_last, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ int result = 0; ++ uint8_t *text_flags = NULL; ++ struct en50221_app_mmi_text *text_data = NULL; ++ uint32_t i; ++ uint8_t text_count = 0; ++ ++ // first of all, decode the length field ++ uint16_t asn_data_length; ++ int length_field_len; ++ if ((length_field_len = asn_1_decode(&asn_data_length, data, data_length)) < 0) { ++ print(LOG_LEVEL, ERROR, 1, "ASN.1 decode error\n"); ++ return -1; ++ } ++ // check it ++ if (asn_data_length > (data_length - length_field_len)) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ // skip over the length field ++ data += length_field_len; ++ ++ // defragment ++ pthread_mutex_lock(&mmi->lock); ++ uint8_t *outdata; ++ uint32_t outdata_length; ++ int dfstatus = ++ en50221_app_mmi_defragment(mmi, session_number, tag_id, ++ more_last, ++ data, asn_data_length, ++ &outdata, &outdata_length); ++ if (dfstatus <= 0) { ++ pthread_mutex_unlock(&mmi->lock); ++ return dfstatus; ++ } ++ data = outdata; ++ data_length = outdata_length; ++ ++ // check the reassembled data length ++ if (data_length < 1) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ pthread_mutex_unlock(&mmi->lock); ++ result = -1; ++ goto exit_cleanup; ++ } ++ // now, parse the data ++ uint8_t choice_nb = data[0]; ++ text_count = choice_nb + 3; ++ if (choice_nb == 0xff) ++ text_count = 3; ++ data++; ++ data_length--; ++ ++ // variables for extracted text state ++ text_flags = alloca(text_count); ++ if (text_flags == NULL) { ++ pthread_mutex_unlock(&mmi->lock); ++ result = -1; ++ goto exit_cleanup; ++ } ++ memset(text_flags, 0, text_count); ++ text_data = (struct en50221_app_mmi_text *) ++ alloca(sizeof(struct en50221_app_mmi_text) * text_count); ++ if (text_data == NULL) { ++ pthread_mutex_unlock(&mmi->lock); ++ result = -1; ++ goto exit_cleanup; ++ } ++ memset(text_data, 0, ++ sizeof(struct en50221_app_mmi_text) * text_count); ++ ++ // extract the text! ++ for (i = 0; i < text_count; i++) { ++ uint32_t consumed = 0; ++ int cur_status = ++ en50221_app_mmi_defragment_text(data, data_length, ++ &text_data[i].text, ++ &text_data[i].text_length, ++ &consumed); ++ if (cur_status < 0) { ++ pthread_mutex_unlock(&mmi->lock); ++ result = -1; ++ goto exit_cleanup; ++ } ++ ++ text_flags[i] = cur_status; ++ data += consumed; ++ data_length -= consumed; ++ } ++ ++ // work out what to pass to the user ++ struct en50221_app_mmi_text *text_data_for_user = (struct en50221_app_mmi_text *) ++ alloca(sizeof(struct en50221_app_mmi_text) * text_count); ++ if (text_data_for_user == NULL) { ++ result = -1; ++ goto exit_cleanup; ++ } ++ memcpy(text_data_for_user, text_data, ++ sizeof(struct en50221_app_mmi_text) * text_count); ++ struct en50221_app_mmi_text *text_ptr = NULL; ++ if (text_count > 3) { ++ text_ptr = &text_data_for_user[3]; ++ } ++ uint8_t *items_raw = NULL; ++ uint32_t items_raw_length = 0; ++ if (choice_nb == 0xff) { ++ items_raw = data; ++ items_raw_length = data_length; ++ } ++ // do callback ++ result = 0; ++ switch (tag_id) { ++ case TAG_MENU_LAST: ++ { ++ en50221_app_mmi_menu_callback cb = mmi->menucallback; ++ void *cb_arg = mmi->menucallback_arg; ++ pthread_mutex_unlock(&mmi->lock); ++ if (cb) { ++ result = ++ cb(cb_arg, slot_id, session_number, ++ &text_data_for_user[0], ++ &text_data_for_user[1], ++ &text_data_for_user[2], ++ text_count - 3, text_ptr, ++ items_raw_length, items_raw); ++ } ++ break; ++ } ++ ++ case TAG_LIST_LAST: ++ { ++ en50221_app_mmi_list_callback cb = mmi->listcallback; ++ void *cb_arg = mmi->listcallback_arg; ++ pthread_mutex_unlock(&mmi->lock); ++ if (cb) { ++ result = ++ cb(cb_arg, slot_id, session_number, ++ &text_data_for_user[0], ++ &text_data_for_user[1], ++ &text_data_for_user[2], ++ text_count - 3, text_ptr, ++ items_raw_length, items_raw); ++ } ++ break; ++ } ++ ++ default: ++ pthread_mutex_unlock(&mmi->lock); ++ break; ++ } ++ ++exit_cleanup: ++ if ((dfstatus == 2) && outdata) ++ free(outdata); ++ if (text_flags && text_data) { ++ for (i = 0; i < text_count; i++) { ++ if ((text_flags[i] == 2) && text_data[i].text) { ++ free(text_data[i].text); ++ } ++ } ++ } ++ return result; ++} ++ ++static int en50221_app_mmi_parse_subtitle(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t tag_id, int more_last, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ // first of all, decode the length field ++ uint16_t asn_data_length; ++ int length_field_len; ++ if ((length_field_len = asn_1_decode(&asn_data_length, data, data_length)) < 0) { ++ print(LOG_LEVEL, ERROR, 1, "ASN.1 decode error\n"); ++ return -1; ++ } ++ // check it ++ if (asn_data_length > (data_length - length_field_len)) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ // skip over the length field ++ data += length_field_len; ++ ++ // defragment ++ pthread_mutex_lock(&mmi->lock); ++ uint8_t *outdata; ++ uint32_t outdata_length; ++ int dfstatus = ++ en50221_app_mmi_defragment(mmi, session_number, tag_id, ++ more_last, ++ data, asn_data_length, ++ &outdata, &outdata_length); ++ if (dfstatus <= 0) { ++ pthread_mutex_unlock(&mmi->lock); ++ return dfstatus; ++ } ++ // do callback ++ int cbstatus = 0; ++ switch (tag_id) { ++ case TAG_SUBTITLE_SEGMENT_LAST: ++ { ++ en50221_app_mmi_subtitle_segment_callback cb = ++ mmi->subtitlesegmentcallback; ++ void *cb_arg = mmi->subtitlesegmentcallback_arg; ++ pthread_mutex_unlock(&mmi->lock); ++ if (cb) { ++ cbstatus = ++ cb(cb_arg, slot_id, session_number, outdata, outdata_length); ++ } ++ break; ++ } ++ ++ case TAG_SUBTITLE_DOWNLOAD_LAST: ++ { ++ en50221_app_mmi_subtitle_download_callback cb = ++ mmi->subtitledownloadcallback; ++ void *cb_arg = mmi->subtitledownloadcallback_arg; ++ pthread_mutex_unlock(&mmi->lock); ++ if (cb) { ++ cbstatus = ++ cb(cb_arg, slot_id, session_number, outdata, outdata_length); ++ } ++ break; ++ } ++ } ++ ++ // free the data returned by the defragment call if asked to ++ if (dfstatus == 2) { ++ free(outdata); ++ } ++ // done ++ return cbstatus; ++} ++ ++static int en50221_app_mmi_parse_scene_end_mark(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ // validate data ++ if (data_length != 2) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (data[0] != 1) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint8_t flags = data[1]; ++ ++ // tell the app ++ pthread_mutex_lock(&mmi->lock); ++ en50221_app_mmi_scene_end_mark_callback cb = ++ mmi->sceneendmarkcallback; ++ void *cb_arg = mmi->sceneendmarkcallback_arg; ++ pthread_mutex_unlock(&mmi->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, ++ (flags & 0x80) ? 1 : 0, ++ (flags & 0x40) ? 1 : 0, ++ (flags & 0x20) ? 1 : 0, flags & 0x0f); ++ } ++ return 0; ++} ++ ++static int en50221_app_mmi_parse_scene_control(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ // validate data ++ if (data_length != 2) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (data[0] != 1) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint8_t flags = data[1]; ++ ++ // tell the app ++ pthread_mutex_lock(&mmi->lock); ++ en50221_app_mmi_scene_control_callback cb = mmi->scenecontrolcallback; ++ void *cb_arg = mmi->scenecontrolcallback_arg; ++ pthread_mutex_unlock(&mmi->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, ++ (flags & 0x80) ? 1 : 0, ++ (flags & 0x40) ? 1 : 0, flags & 0x0f); ++ } ++ return 0; ++} ++ ++static int en50221_app_mmi_parse_flush_download(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t *data, ++ uint32_t data_length) ++{ ++ // validate data ++ if (data_length != 1) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (data[0] != 0) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ // tell the app ++ pthread_mutex_lock(&mmi->lock); ++ en50221_app_mmi_flush_download_callback cb = mmi->flushdownloadcallback; ++ void *cb_arg = mmi->flushdownloadcallback_arg; ++ pthread_mutex_unlock(&mmi->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number); ++ } ++ return 0; ++} ++ ++static int en50221_app_mmi_defragment(struct en50221_app_mmi *mmi, ++ uint16_t session_number, ++ uint32_t tag_id, ++ int more_last, ++ uint8_t * indata, ++ uint32_t indata_length, ++ uint8_t ** outdata, ++ uint32_t * outdata_length) ++{ ++ struct en50221_app_mmi_session *cur_s = mmi->sessions; ++ while (cur_s) { ++ if (cur_s->session_number == session_number) ++ break; ++ cur_s = cur_s->next; ++ } ++ ++ // more data is still to come ++ if (!more_last) { ++ // if there was no previous session, create one ++ if (cur_s == NULL) { ++ cur_s = malloc(sizeof(struct en50221_app_mmi_session)); ++ if (cur_s == NULL) { ++ print(LOG_LEVEL, ERROR, 1, "Ran out of memory\n"); ++ return -1; ++ } ++ cur_s->session_number = session_number; ++ cur_s->menu_block_chain = NULL; ++ cur_s->menu_block_length = 0; ++ cur_s->list_block_chain = NULL; ++ cur_s->list_block_length = 0; ++ cur_s->subtitlesegment_block_chain = NULL; ++ cur_s->subtitlesegment_block_length = 0; ++ cur_s->subtitledownload_block_chain = NULL; ++ cur_s->subtitledownload_block_length = 0; ++ cur_s->next = mmi->sessions; ++ mmi->sessions = cur_s; ++ } ++ // find the block/block_length to use ++ uint8_t **block_chain; ++ uint32_t *block_length; ++ switch (tag_id) { ++ case TAG_MENU_LAST: ++ case TAG_MENU_MORE: ++ block_chain = &cur_s->menu_block_chain; ++ block_length = &cur_s->menu_block_length; ++ break; ++ case TAG_LIST_LAST: ++ case TAG_LIST_MORE: ++ block_chain = &cur_s->list_block_chain; ++ block_length = &cur_s->list_block_length; ++ break; ++ case TAG_SUBTITLE_SEGMENT_LAST: ++ case TAG_SUBTITLE_SEGMENT_MORE: ++ block_chain = &cur_s->subtitlesegment_block_chain; ++ block_length = &cur_s->subtitlesegment_block_length; ++ break; ++ case TAG_SUBTITLE_DOWNLOAD_LAST: ++ case TAG_SUBTITLE_DOWNLOAD_MORE: ++ block_chain = &cur_s->subtitledownload_block_chain; ++ block_length = &cur_s->subtitledownload_block_length; ++ break; ++ default: ++ return -1; ++ } ++ ++ // append the data ++ uint8_t *new_data = ++ realloc(*block_chain, *block_length + indata_length); ++ if (new_data == NULL) { ++ print(LOG_LEVEL, ERROR, 1, "Ran out of memory\n"); ++ return -1; ++ } ++ memcpy(new_data + *block_length, indata, indata_length); ++ *block_chain = new_data; ++ *block_length += indata_length; ++ ++ // success, but block not complete yet ++ return 0; ++ } ++ // we hit the last of a possible chain of fragments ++ if (cur_s != NULL) { ++ // find the block/block_length to use ++ uint8_t **block_chain; ++ uint32_t *block_length; ++ switch (tag_id) { ++ case TAG_MENU_LAST: ++ case TAG_MENU_MORE: ++ block_chain = &cur_s->menu_block_chain; ++ block_length = &cur_s->menu_block_length; ++ break; ++ case TAG_LIST_LAST: ++ case TAG_LIST_MORE: ++ block_chain = &cur_s->list_block_chain; ++ block_length = &cur_s->list_block_length; ++ break; ++ case TAG_SUBTITLE_SEGMENT_LAST: ++ case TAG_SUBTITLE_SEGMENT_MORE: ++ block_chain = &cur_s->subtitlesegment_block_chain; ++ block_length = &cur_s->subtitlesegment_block_length; ++ break; ++ case TAG_SUBTITLE_DOWNLOAD_LAST: ++ case TAG_SUBTITLE_DOWNLOAD_MORE: ++ block_chain = &cur_s->subtitledownload_block_chain; ++ block_length = &cur_s->subtitledownload_block_length; ++ break; ++ default: ++ return -1; ++ } ++ ++ // we have a preceding fragment - need to append ++ uint8_t *new_data = ++ realloc(*block_chain, *block_length + indata_length); ++ if (new_data == NULL) { ++ print(LOG_LEVEL, ERROR, 1, "Ran out of memory\n"); ++ return -1; ++ } ++ memcpy(new_data + *block_length, indata, indata_length); ++ *outdata_length = *block_length + indata_length; ++ *outdata = new_data; ++ *block_chain = NULL; ++ *block_length = 0; ++ ++ // success, and indicate to free the block when done ++ return 2; ++ } ++ // success, but indicate it is not to be freed ++ *outdata_length = indata_length; ++ *outdata = indata; ++ return 1; ++} ++ ++static int en50221_app_mmi_defragment_text(uint8_t * data, ++ uint32_t data_length, ++ uint8_t ** outdata, ++ uint32_t * outdata_length, ++ uint32_t * outconsumed) ++{ ++ uint8_t *text = NULL; ++ uint32_t text_length = 0; ++ uint32_t consumed = 0; ++ ++ while (1) { ++ // get the tag ++ if (data_length < 3) { ++ print(LOG_LEVEL, ERROR, 1, "Short data\n"); ++ if (text) ++ free(text); ++ return -1; ++ } ++ uint32_t tag = (data[0] << 16) | (data[1] << 8) | data[2]; ++ data += 3; ++ data_length -= 3; ++ consumed += 3; ++ ++ // get the length of the data and adjust ++ uint16_t asn_data_length; ++ int length_field_len; ++ if ((length_field_len = ++ asn_1_decode(&asn_data_length, data, ++ data_length)) < 0) { ++ print(LOG_LEVEL, ERROR, 1, "ASN.1 decode error\n"); ++ if (text) ++ free(text); ++ return -1; ++ } ++ data += length_field_len; ++ data_length -= length_field_len; ++ consumed += length_field_len; ++ ++ // deal with the tags ++ if (tag == TAG_TEXT_LAST) { ++ if (text == NULL) { ++ *outdata = data; ++ *outdata_length = asn_data_length; ++ *outconsumed = consumed + asn_data_length; ++ return 1; ++ } else { ++ // append the data ++ uint8_t *new_text = realloc(text, ++ text_length + asn_data_length); ++ if (new_text == NULL) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Ran out of memory\n"); ++ if (text) ++ free(text); ++ return -1; ++ } ++ memcpy(new_text + text_length, data, ++ asn_data_length); ++ *outdata = new_text; ++ *outdata_length = ++ text_length + asn_data_length; ++ *outconsumed = consumed + asn_data_length; ++ return 2; ++ } ++ ++ } else if (tag == TAG_TEXT_MORE) { ++ // append the data ++ uint8_t *new_text = ++ realloc(text, text_length + asn_data_length); ++ if (new_text == NULL) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Ran out of memory\n"); ++ if (text) ++ free(text); ++ return -1; ++ } ++ memcpy(new_text + text_length, data, ++ asn_data_length); ++ text = new_text; ++ text_length += asn_data_length; ++ ++ // consume the data ++ data += asn_data_length; ++ data_length -= asn_data_length; ++ consumed += asn_data_length; ++ } else { ++ // unknown tag ++ print(LOG_LEVEL, ERROR, 1, ++ "Unknown MMI text tag\n"); ++ if (text) ++ free(text); ++ return -1; ++ } ++ } ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_mmi.h dvb-apps/lib/libdvben50221/en50221_app_mmi.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_mmi.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_mmi.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,618 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#ifndef __EN50221_APPLICATION_mmi_H__ ++#define __EN50221_APPLICATION_mmi_H__ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++ ++#define EN50221_APP_MMI_RESOURCEID MKRID(64,1,1) ++ ++#define MMI_CLOSE_MMI_CMD_ID_IMMEDIATE 0x00 ++#define MMI_CLOSE_MMI_CMD_ID_DELAY 0x01 ++ ++#define MMI_DISPLAY_CONTROL_CMD_ID_SET_MMI_MODE 0x01 ++#define MMI_DISPLAY_CONTROL_CMD_ID_GET_DISPLAY_CHAR_TABLES 0x02 ++#define MMI_DISPLAY_CONTROL_CMD_ID_GET_INPUT_CHAR_TABLES 0x03 ++#define MMI_DISPLAY_CONTROL_CMD_ID_GET_OVERLAY_GFX_CHARACTERISTICS 0x04 ++#define MMI_DISPLAY_CONTROL_CMD_ID_GET_FULLSCREEN_GFX_CHARACTERISTICS 0x05 ++ ++#define MMI_DISPLAY_REPLY_ID_MMI_MODE_ACK 0x01 ++#define MMI_DISPLAY_REPLY_ID_LIST_DISPLAY_CHAR_TABLES 0x02 ++#define MMI_DISPLAY_REPLY_ID_LIST_INPUT_CHAR_TABLES 0x03 ++#define MMI_DISPLAY_REPLY_ID_LIST_OVERLAY_GFX_CHARACTERISTICS 0x04 ++#define MMI_DISPLAY_REPLY_ID_LIST_FULLSCREEN_GFX_CHARACTERISTICS 0x05 ++#define MMI_DISPLAY_REPLY_ID_UNKNOWN_CMD_ID 0xF0 ++#define MMI_DISPLAY_REPLY_ID_UNKNOWN_MMI_MODE 0xF1 ++#define MMI_DISPLAY_REPLY_ID_UNKNOWN_CHAR_TABLE 0xF2 ++ ++#define MMI_MODE_HIGH_LEVEL 0x01 ++#define MMI_MODE_LOW_LEVEL_OVERLAY_GFX 0x02 ++#define MMI_MODE_LOW_LEVEL_FULLSCREEN_GFX 0x03 ++ ++#define MMI_KEYPAD_CONTROL_CMD_ID_INTERCEPT_ALL 0x01 ++#define MMI_KEYPAD_CONTROL_CMD_ID_IGNORE_ALL 0x02 ++#define MMI_KEYPAD_CONTROL_CMD_ID_INTERCEPT_SELECTED 0x03 ++#define MMI_KEYPAD_CONTROL_CMD_ID_IGNORE_SELECTED 0x04 ++#define MMI_KEYPAD_CONTROL_CMD_ID_REJECT_KEYPRESS 0x05 ++ ++#define MMI_GFX_VIDEO_RELATION_NONE 0x00 ++#define MMI_GFX_VIDEO_RELATION_MATCHES_EXACTLY 0x07 ++ ++#define MMI_DISPLAY_MESSAGE_ID_OK 0x00 ++#define MMI_DISPLAY_MESSAGE_ID_ERROR 0x01 ++#define MMI_DISPLAY_MESSAGE_ID_OUT_OF_MEMORY 0x02 ++#define MMI_DISPLAY_MESSAGE_ID_SUBTITLE_SYNTAX_ERROR 0x03 ++#define MMI_DISPLAY_MESSAGE_ID_UNDEFINED_REGION 0x04 ++#define MMI_DISPLAY_MESSAGE_ID_UNDEFINED_CLUT 0x05 ++#define MMI_DISPLAY_MESSAGE_ID_UNDEFINED_OBJECT 0x06 ++#define MMI_DISPLAY_MESSAGE_ID_INCOMPATABLE_OBJECT 0x07 ++#define MMI_DISPLAY_MESSAGE_ID_UNKNOWN_CHARACTER 0x08 ++#define MMI_DISPLAY_MESSAGE_ID_DISPLAY_CHANGED 0x09 ++ ++#define MMI_DOWNLOAD_REPLY_ID_OK 0x00 ++#define MMI_DOWNLOAD_REPLY_ID_NOT_OBJECT_SEGMENT 0x01 ++#define MMI_DOWNLOAD_REPLY_ID_OUT_OF_MEMORY 0x02 ++ ++#define MMI_ANSW_ID_CANCEL 0x00 ++#define MMI_ANSW_ID_ANSWER 0x01 ++ ++/** ++ * A pixel depth as supplied with display_reply details ++ */ ++struct en50221_app_mmi_pixel_depth { ++ uint8_t display_depth; ++ uint8_t pixels_per_byte; ++ uint8_t region_overhead; ++}; ++ ++/** ++ * Details returned with a display_reply ++ */ ++struct en50221_app_mmi_display_reply_details { ++ union { ++ struct { ++ uint16_t width; ++ uint16_t height; ++ uint8_t aspect_ratio; ++ uint8_t gfx_relation_to_video; /* one of MMI_GFX_VIDEO_RELATION_* */ ++ uint8_t multiple_depths; ++ uint16_t display_bytes; ++ uint8_t composition_buffer_bytes; ++ uint8_t object_cache_bytes; ++ uint8_t num_pixel_depths; ++ struct en50221_app_mmi_pixel_depth *pixel_depths; ++ } gfx; /* MMI_DISPLAY_REPLY_ID_LIST_OVERLAY_GFX_CHARACTERISTICS or ++ MMI_DISPLAY_REPLY_ID_LIST_FULLSCREEN_GFX_CHARACTERISTICS */ ++ ++ struct { ++ uint32_t table_length; ++ uint8_t *table; ++ } char_table; /* MMI_DISPLAY_REPLY_ID_LIST_DISPLAY_CHAR_TABLES or ++ MMI_DISPLAY_REPLY_ID_LIST_INPUT_CHAR_TABLES */ ++ ++ struct { ++ uint8_t mmi_mode; /* one of the MMI_MODE_* values */ ++ } mode_ack; /* for MMI_DISPLAY_REPLY_ID_MMI_MODE_ACK */ ++ } u; ++}; ++ ++/** ++ * Pointer to a text string. ++ */ ++struct en50221_app_mmi_text { ++ uint8_t *text; ++ uint32_t text_length; ++}; ++ ++/** ++ * Type definition for close - called when we receive an mmi_close from a CAM. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param cmd_id One of the MMI_CLOSE_MMI_CMD_ID_* values. ++ * @param delay Delay supplied with MMI_CLOSE_MMI_CMD_ID_DELAY. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_mmi_close_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t cmd_id, ++ uint8_t delay); ++ ++/** ++ * Type definition for display_control callback. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param cmd_id One of the MMI_DISPLAY_CONTROL_CMD_ID_* values. ++ * @param delay One of the MMI_MODE_* values. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_mmi_display_control_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t cmd_id, ++ uint8_t mmi_mode); ++ ++/** ++ * Type definition for keypad_control callback. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param cmd_id One of the MMI_KEYPAD_CONTROL_CMD_ID_* values. ++ * @param key_codes Pointer to the key codes. ++ * @param key_codes_count Number of key codes. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_mmi_keypad_control_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t cmd_id, ++ uint8_t *key_codes, ++ uint32_t key_codes_count); ++ ++/** ++ * Type definition for subtitle_segment callback. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param segment Pointer to the segment data. ++ * @param segment_size Size of segment data. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_mmi_subtitle_segment_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t *segment, ++ uint32_t segment_size); ++ ++/** ++ * Type definition for scene_end_mark callback. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param decoder_continue_flag ++ * @param scene_reveal_flag ++ * @param send_scene_done ++ * @param scene_tag ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_mmi_scene_end_mark_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t decoder_continue_flag, ++ uint8_t scene_reveal_flag, ++ uint8_t send_scene_done, ++ uint8_t scene_tag); ++ ++/** ++ * Type definition for scene_control callback. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param decoder_continue_flag ++ * @param scene_reveal_flag ++ * @param scene_tag ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_mmi_scene_control_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t decoder_continue_flag, ++ uint8_t scene_reveal_flag, ++ uint8_t scene_tag); ++ ++/** ++ * Type definition for subtitle_download callback. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param segment Pointer to the segment data. ++ * @param segment_size Size of segment data. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_mmi_subtitle_download_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t *segment, ++ uint32_t segment_size); ++ ++/** ++ * Type definition for flush_download callback. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_mmi_flush_download_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number); ++ ++/** ++ * Type definition for enq callback. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param blind_answer 1=>Obscure text input in some manner, ++ * @param expected_answer_length Expected max number of characters to be returned. ++ * @param text Pointer to the text data. ++ * @param text_size Size of text data. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_mmi_enq_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t blind_answer, ++ uint8_t expected_answer_length, ++ uint8_t * text, ++ uint32_t text_size); ++ ++/** ++ * Type definition for menu callback. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param title Title text. ++ * @param sub_title Sub-Title text. ++ * @param bottom Bottom text. ++ * @param item_count Number of text elements in items. ++ * @param items Pointer to array of en50221_app_mmi_text structures which are standard menu choices, ++ * @param item_raw_length Length of item raw data. ++ * @param items_raw If nonstandard items were supplied, pointer to their data. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_mmi_menu_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ struct en50221_app_mmi_text *title, ++ struct en50221_app_mmi_text *sub_title, ++ struct en50221_app_mmi_text *bottom, ++ uint32_t item_count, ++ struct en50221_app_mmi_text *items, ++ uint32_t item_raw_length, ++ uint8_t *items_raw); ++ ++/** ++ * Type definition for list callback. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param title Title text. ++ * @param sub_title Sub-Title text. ++ * @param bottom Bottom text. ++ * @param item_count Number of text elements in items. ++ * @param items Pointer to array of en50221_app_mmi_text structures which are standard menu choices, ++ * @param item_raw_length Length of item raw data. ++ * @param items_raw If nonstandard items were supplied, pointer to their data. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_mmi_list_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ struct en50221_app_mmi_text *title, ++ struct en50221_app_mmi_text *sub_title, ++ struct en50221_app_mmi_text *bottom, ++ uint32_t item_count, ++ struct en50221_app_mmi_text *items, ++ uint32_t item_raw_length, ++ uint8_t *items_raw); ++ ++/** ++ * Opaque type representing a mmi resource. ++ */ ++struct en50221_app_mmi; ++ ++/** ++ * Create an instance of the mmi resource. ++ * ++ * @param funcs Send functions to use. ++ * @return Instance, or NULL on failure. ++ */ ++extern struct en50221_app_mmi *en50221_app_mmi_create(struct en50221_app_send_functions *funcs); ++ ++/** ++ * Destroy an instance of the mmi resource. ++ * ++ * @param mmi Instance to destroy. ++ */ ++extern void en50221_app_mmi_destroy(struct en50221_app_mmi *mmi); ++ ++/** ++ * Informs the mmi object that a session to it has been closed - cleans up internal state. ++ * ++ * @param mmi mmi resource instance. ++ * @param session_number The session concerned. ++ */ ++extern void en50221_app_mmi_clear_session(struct en50221_app_mmi *mmi, ++ uint16_t session_number); ++ ++/** ++ * Register the callback for when we receive an mmi_close request. ++ * ++ * @param mmi mmi resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_mmi_register_close_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_close_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for when we receive a display control request. ++ * ++ * @param mmi mmi resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_mmi_register_display_control_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_display_control_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for when we receive a keypad control request. ++ * ++ * @param mmi mmi resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_mmi_register_keypad_control_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_keypad_control_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for when we receive a subtitle segment request. ++ * ++ * @param mmi mmi resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_mmi_register_subtitle_segment_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_subtitle_segment_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for when we receive a scene end mark request. ++ * ++ * @param mmi mmi resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_mmi_register_scene_end_mark_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_scene_end_mark_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for when we receive a scene control request. ++ * ++ * @param mmi mmi resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_mmi_register_scene_control_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_scene_control_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for when we receive a subtitle download request. ++ * ++ * @param mmi mmi resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_mmi_register_subtitle_download_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_subtitle_download_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for when we receive a flush download request. ++ * ++ * @param mmi mmi resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_mmi_register_flush_download_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_flush_download_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for when we receive an enq request. ++ * ++ * @param mmi mmi resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_mmi_register_enq_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_enq_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for when we receive a menu request. ++ * ++ * @param mmi mmi resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_mmi_register_menu_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_menu_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for when we receive a list request. ++ * ++ * @param mmi mmi resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_mmi_register_list_callback(struct en50221_app_mmi *mmi, ++ en50221_app_mmi_list_callback callback, ++ void *arg); ++ ++/** ++ * Send an mmi_close to the cam. ++ * ++ * @param mmi mmi resource instance. ++ * @param session_number Session number to send it on. ++ * @param cmd_id One of the MMI_CLOSE_MMI_CMD_ID_* values. ++ * @param delay Delay to use if MMI_CLOSE_MMI_CMD_ID_DELAY specified. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_mmi_close(struct en50221_app_mmi *mmi, ++ uint16_t session_number, ++ uint8_t cmd_id, uint8_t delay); ++ ++/** ++ * Send a display_reply to the cam. ++ * ++ * @param mmi mmi resource instance. ++ * @param session_number Session number to send it on. ++ * @param reply_id One of the MMI_DISPLAY_REPLY_ID_* values. ++ * @param details The details of the reply - can be NULL if the chosen reply_id does not need it. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_mmi_display_reply(struct en50221_app_mmi *mmi, ++ uint16_t session_number, ++ uint8_t reply_id, ++ struct en50221_app_mmi_display_reply_details *details); ++ ++/** ++ * Send a keypress to the cam. ++ * ++ * @param mmi mmi resource instance. ++ * @param session_number Session number to send it on. ++ * @param keycode The keycode. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_mmi_keypress(struct en50221_app_mmi *mmi, ++ uint16_t session_number, ++ uint8_t keycode); ++ ++/** ++ * Send a display message to the cam. ++ * ++ * @param mmi mmi resource instance. ++ * @param session_number Session number to send it on. ++ * @param display_message_id One of the MMI_DISPLAY_MESSAGE_ID_* values. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_mmi_display_message(struct en50221_app_mmi *mmi, ++ uint16_t session_number, ++ uint8_t display_message_id); ++ ++/** ++ * Send a scene done message to the cam. ++ * ++ * @param mmi mmi resource instance. ++ * @param session_number Session number to send it on. ++ * @param decoder_continue Copy of flag in scene_end_mark. ++ * @param scene_reveal Copy of flag in scene_end_mark. ++ * @param scene_tag Scene tag this responds to. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_mmi_scene_done(struct en50221_app_mmi *mmi, ++ uint16_t session_number, ++ uint8_t decoder_continue, ++ uint8_t scene_reveal, ++ uint8_t scene_tag); ++ ++/** ++ * Send a download reply to the cam. ++ * ++ * @param mmi mmi resource instance. ++ * @param session_number Session number to send it on. ++ * @param object_id Object id. ++ * @param download_reply_id One of the MMI_DOWNLOAD_REPLY_ID_* values. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_mmi_download_reply(struct en50221_app_mmi *mmi, ++ uint16_t session_number, ++ uint16_t object_id, ++ uint8_t download_reply_id); ++ ++/** ++ * Send an answ to the cam. ++ * ++ * @param mmi mmi resource instance. ++ * @param session_number Session number to send it on. ++ * @param answ_id One of the MMI_ANSW_ID_* values. ++ * @param text The text if MMI_ANSW_ID_ANSWER. ++ * @param text_count Length of text. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_mmi_answ(struct en50221_app_mmi *mmi, ++ uint16_t session_number, ++ uint8_t answ_id, ++ uint8_t * text, ++ uint32_t text_count); ++ ++/** ++ * Send a menu answ to the cam. ++ * ++ * @param mmi mmi resource instance. ++ * @param session_number Session number to send it on. ++ * @param choice_ref Option chosen by user (0=>canceled). ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_mmi_menu_answ(struct en50221_app_mmi *mmi, ++ uint16_t session_number, ++ uint8_t choice_ref); ++ ++/** ++ * Pass data received for this resource into it for parsing. ++ * ++ * @param mmi mmi instance. ++ * @param slot_id Slot ID concerned. ++ * @param session_number Session number concerned. ++ * @param resource_id Resource ID concerned. ++ * @param data The data. ++ * @param data_length Length of data in bytes. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_mmi_message(struct en50221_app_mmi *mmi, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t *data, ++ uint32_t data_length); ++ ++#ifdef __cplusplus ++} ++#endif ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_rm.c dvb-apps/lib/libdvben50221/en50221_app_rm.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_rm.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_rm.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,307 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include ++#include "en50221_app_rm.h" ++#include "en50221_app_tags.h" ++#include "asn_1.h" ++ ++struct en50221_app_rm { ++ struct en50221_app_send_functions *funcs; ++ ++ en50221_app_rm_enq_callback enqcallback; ++ void *enqcallback_arg; ++ ++ en50221_app_rm_reply_callback replycallback; ++ void *replycallback_arg; ++ ++ en50221_app_rm_changed_callback changedcallback; ++ void *changedcallback_arg; ++ ++ pthread_mutex_t lock; ++}; ++ ++static int en50221_app_rm_parse_profile_enq(struct en50221_app_rm *rm, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++static int en50221_app_rm_parse_profile_reply(struct en50221_app_rm *rm, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++static int en50221_app_rm_parse_profile_change(struct en50221_app_rm *rm, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++ ++ ++struct en50221_app_rm *en50221_app_rm_create(struct ++ en50221_app_send_functions ++ *funcs) ++{ ++ struct en50221_app_rm *rm = NULL; ++ ++ // create structure and set it up ++ rm = malloc(sizeof(struct en50221_app_rm)); ++ if (rm == NULL) { ++ return NULL; ++ } ++ rm->funcs = funcs; ++ rm->enqcallback = NULL; ++ rm->replycallback = NULL; ++ rm->changedcallback = NULL; ++ ++ pthread_mutex_init(&rm->lock, NULL); ++ ++ // done ++ return rm; ++} ++ ++void en50221_app_rm_destroy(struct en50221_app_rm *rm) ++{ ++ pthread_mutex_destroy(&rm->lock); ++ free(rm); ++} ++ ++void en50221_app_rm_register_enq_callback(struct en50221_app_rm *rm, ++ en50221_app_rm_enq_callback ++ callback, void *arg) ++{ ++ pthread_mutex_lock(&rm->lock); ++ rm->enqcallback = callback; ++ rm->enqcallback_arg = arg; ++ pthread_mutex_unlock(&rm->lock); ++} ++ ++void en50221_app_rm_register_reply_callback(struct en50221_app_rm *rm, ++ en50221_app_rm_reply_callback ++ callback, void *arg) ++{ ++ pthread_mutex_lock(&rm->lock); ++ rm->replycallback = callback; ++ rm->replycallback_arg = arg; ++ pthread_mutex_unlock(&rm->lock); ++} ++ ++void en50221_app_rm_register_changed_callback(struct en50221_app_rm *rm, ++ en50221_app_rm_changed_callback ++ callback, void *arg) ++{ ++ pthread_mutex_lock(&rm->lock); ++ rm->changedcallback = callback; ++ rm->changedcallback_arg = arg; ++ pthread_mutex_unlock(&rm->lock); ++} ++ ++int en50221_app_rm_enq(struct en50221_app_rm *rm, uint16_t session_number) ++{ ++ uint8_t buf[4]; ++ ++ // set up the tag ++ buf[0] = (TAG_PROFILE_ENQUIRY >> 16) & 0xFF; ++ buf[1] = (TAG_PROFILE_ENQUIRY >> 8) & 0xFF; ++ buf[2] = TAG_PROFILE_ENQUIRY & 0xFF; ++ buf[3] = 0; ++ ++ // create the data and send it ++ return rm->funcs->send_data(rm->funcs->arg, session_number, buf, 4); ++} ++ ++int en50221_app_rm_reply(struct en50221_app_rm *rm, ++ uint16_t session_number, ++ uint32_t resource_id_count, ++ uint32_t * resource_ids) ++{ ++ uint8_t buf[10]; ++ ++ // set up the tag ++ buf[0] = (TAG_PROFILE >> 16) & 0xFF; ++ buf[1] = (TAG_PROFILE >> 8) & 0xFF; ++ buf[2] = TAG_PROFILE & 0xFF; ++ ++ // encode the length field ++ int length_field_len; ++ if ((length_field_len = asn_1_encode(resource_id_count * 4, buf + 3, 3)) < 0) { ++ return -1; ++ } ++ // copy the data and byteswap it ++ uint32_t *copy_resource_ids = alloca(4 * resource_id_count); ++ if (copy_resource_ids == NULL) { ++ return -1; ++ } ++ uint8_t *data = (uint8_t *) copy_resource_ids; ++ memcpy(data, resource_ids, resource_id_count * 4); ++ uint32_t i; ++ for (i = 0; i < resource_id_count; i++) { ++ bswap32(data); ++ data += 4; ++ } ++ ++ // build the iovecs ++ struct iovec iov[2]; ++ iov[0].iov_base = buf; ++ iov[0].iov_len = 3 + length_field_len; ++ iov[1].iov_base = (uint8_t *) copy_resource_ids; ++ iov[1].iov_len = resource_id_count * 4; ++ ++ // create the data and send it ++ return rm->funcs->send_datav(rm->funcs->arg, session_number, iov, 2); ++} ++ ++int en50221_app_rm_changed(struct en50221_app_rm *rm, ++ uint16_t session_number) ++{ ++ uint8_t buf[4]; ++ ++ // set up the tag ++ buf[0] = (TAG_PROFILE_CHANGE >> 16) & 0xFF; ++ buf[1] = (TAG_PROFILE_CHANGE >> 8) & 0xFF; ++ buf[2] = TAG_PROFILE_CHANGE & 0xFF; ++ buf[3] = 0; ++ ++ // create the data and send it ++ return rm->funcs->send_data(rm->funcs->arg, session_number, buf, 4); ++} ++ ++int en50221_app_rm_message(struct en50221_app_rm *rm, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t * data, uint32_t data_length) ++{ ++ (void) resource_id; ++ ++ // get the tag ++ if (data_length < 3) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint32_t tag = (data[0] << 16) | (data[1] << 8) | data[2]; ++ ++ // dispatch it ++ switch (tag) { ++ case TAG_PROFILE_ENQUIRY: ++ return en50221_app_rm_parse_profile_enq(rm, slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ case TAG_PROFILE: ++ return en50221_app_rm_parse_profile_reply(rm, slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ case TAG_PROFILE_CHANGE: ++ return en50221_app_rm_parse_profile_change(rm, slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ } ++ ++ print(LOG_LEVEL, ERROR, 1, "Received unexpected tag %x\n", tag); ++ return -1; ++} ++ ++ ++static int en50221_app_rm_parse_profile_enq(struct en50221_app_rm *rm, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ (void) data; ++ (void) data_length; ++ ++ pthread_mutex_lock(&rm->lock); ++ en50221_app_rm_enq_callback cb = rm->enqcallback; ++ void *cb_arg = rm->enqcallback_arg; ++ pthread_mutex_unlock(&rm->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number); ++ } ++ return 0; ++} ++ ++static int en50221_app_rm_parse_profile_reply(struct en50221_app_rm *rm, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ // first of all, decode the length field ++ uint16_t asn_data_length; ++ int length_field_len; ++ if ((length_field_len = asn_1_decode(&asn_data_length, data, data_length)) < 0) { ++ print(LOG_LEVEL, ERROR, 1, "ASN.1 decode error\n"); ++ return -1; ++ } ++ // check it ++ if (asn_data_length > (data_length - length_field_len)) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint32_t resources_count = asn_data_length / 4; ++ uint32_t *resource_ids = (uint32_t *) (data + length_field_len); ++ data += length_field_len; ++ ++ // byteswap it ++ uint32_t i; ++ for (i = 0; i < resources_count; i++) { ++ bswap32(data); ++ data += 4; ++ } ++ ++ // inform observer ++ pthread_mutex_lock(&rm->lock); ++ en50221_app_rm_reply_callback cb = rm->replycallback; ++ void *cb_arg = rm->replycallback_arg; ++ pthread_mutex_unlock(&rm->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, resources_count, resource_ids); ++ } ++ return 0; ++} ++ ++static int en50221_app_rm_parse_profile_change(struct en50221_app_rm *rm, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ (void) data; ++ (void) data_length; ++ ++ pthread_mutex_lock(&rm->lock); ++ en50221_app_rm_changed_callback cb = rm->changedcallback; ++ void *cb_arg = rm->changedcallback_arg; ++ pthread_mutex_unlock(&rm->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number); ++ } ++ return 0; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_rm.h dvb-apps/lib/libdvben50221/en50221_app_rm.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_rm.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_rm.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,187 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#ifndef __EN50221_APPLICATION_RM_H__ ++#define __EN50221_APPLICATION_RM_H__ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++ ++#define EN50221_APP_RM_RESOURCEID MKRID(1,1,1) ++ ++/** ++ * Type definition for profile_enq callback function - called when we receive ++ * a profile_enq from a CAM. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_rm_enq_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number); ++ ++/** ++ * Type definition for profile_reply callback function - called when we receive ++ * a profile_reply from a CAM. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param resource_id_count Number of resource_ids. ++ * @param resource_ids The resource ids themselves. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_rm_reply_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id_count, ++ uint32_t *resource_ids); ++/** ++ * Type definition for profile_changed callback function - called when we receive ++ * a profile_changed from a CAM. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_rm_changed_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number); ++ ++ ++ ++/** ++ * Opaque type representing a resource manager. ++ */ ++struct en50221_app_rm; ++ ++/** ++ * Create an instance of the resource manager. ++ * ++ * @param funcs Send functions to use. ++ * @return Instance, or NULL on failure. ++ */ ++extern struct en50221_app_rm *en50221_app_rm_create(struct en50221_app_send_functions *funcs); ++ ++/** ++ * Destroy an instance of the resource manager. ++ * ++ * @param rm Instance to destroy. ++ */ ++extern void en50221_app_rm_destroy(struct en50221_app_rm *rm); ++ ++/** ++ * Register the callback for when we receive a profile_enq from a CAM. ++ * ++ * @param rm Resource manager instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_rm_register_enq_callback(struct en50221_app_rm *rm, ++ en50221_app_rm_enq_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for when we receive a profile_reply from a CAM. ++ * ++ * @param rm Resource manager instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_rm_register_reply_callback(struct en50221_app_rm *rm, ++ en50221_app_rm_reply_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for when we receive a profile_changed from a CAM. ++ * ++ * @param rm Resource manager instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_rm_register_changed_callback(struct en50221_app_rm *rm, ++ en50221_app_rm_changed_callback callback, ++ void *arg); ++ ++/** ++ * Send a profile_enq to a CAM. ++ * ++ * @param rm Resource manager resource instance. ++ * @param session_number Session number to send it on. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_rm_enq(struct en50221_app_rm *rm, uint16_t session_number); ++ ++/** ++ * Send a profile_reply to a CAM. ++ * ++ * @param rm Resource manager resource instance. ++ * @param session_number Session number to send it on. ++ * @param resource_id_count Number of resource ids. ++ * @param resource_ids The resource IDs themselves ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_rm_reply(struct en50221_app_rm *rm, ++ uint16_t session_number, ++ uint32_t resource_id_count, ++ uint32_t * resource_ids); ++ ++/** ++ * Send a profile_changed to a CAM. ++ * ++ * @param rm Resource manager resource instance. ++ * @param session_number Session number to send it on. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_rm_changed(struct en50221_app_rm *rm, uint16_t session_number); ++ ++/** ++ * Pass data received for this resource into it for parsing. ++ * ++ * @param rm rm instance. ++ * @param slot_id Slot ID concerned. ++ * @param session_number Session number concerned. ++ * @param resource_id Resource ID concerned. ++ * @param data The data. ++ * @param data_length Length of data in bytes. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_rm_message(struct en50221_app_rm *rm, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t *data, ++ uint32_t data_length); ++ ++#ifdef __cplusplus ++} ++#endif ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_smartcard.c dvb-apps/lib/libdvben50221/en50221_app_smartcard.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_smartcard.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_smartcard.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,296 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include "en50221_app_smartcard.h" ++#include "en50221_app_tags.h" ++#include "asn_1.h" ++ ++struct en50221_app_smartcard { ++ struct en50221_app_send_functions *funcs; ++ ++ en50221_app_smartcard_command_callback command_callback; ++ void *command_callback_arg; ++ ++ en50221_app_smartcard_send_callback send_callback; ++ void *send_callback_arg; ++ ++ pthread_mutex_t lock; ++}; ++ ++static int en50221_app_smartcard_parse_command(struct en50221_app_smartcard *smartcard, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++ ++static int en50221_app_smartcard_parse_send(struct en50221_app_smartcard *smartcard, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++ ++ ++struct en50221_app_smartcard *en50221_app_smartcard_create(struct en50221_app_send_functions *funcs) ++{ ++ struct en50221_app_smartcard *smartcard = NULL; ++ ++ // create structure and set it up ++ smartcard = malloc(sizeof(struct en50221_app_smartcard)); ++ if (smartcard == NULL) { ++ return NULL; ++ } ++ smartcard->funcs = funcs; ++ smartcard->command_callback = NULL; ++ smartcard->send_callback = NULL; ++ ++ pthread_mutex_init(&smartcard->lock, NULL); ++ ++ // done ++ return smartcard; ++} ++ ++void en50221_app_smartcard_destroy(struct en50221_app_smartcard *smartcard) ++{ ++ pthread_mutex_destroy(&smartcard->lock); ++ free(smartcard); ++} ++ ++void en50221_app_smartcard_register_command_callback(struct en50221_app_smartcard *smartcard, ++ en50221_app_smartcard_command_callback callback, void *arg) ++{ ++ pthread_mutex_lock(&smartcard->lock); ++ smartcard->command_callback = callback; ++ smartcard->command_callback_arg = arg; ++ pthread_mutex_unlock(&smartcard->lock); ++} ++ ++void en50221_app_smartcard_register_send_callback(struct en50221_app_smartcard *smartcard, ++ en50221_app_smartcard_send_callback callback, void *arg) ++{ ++ pthread_mutex_lock(&smartcard->lock); ++ smartcard->send_callback = callback; ++ smartcard->send_callback_arg = arg; ++ pthread_mutex_unlock(&smartcard->lock); ++} ++ ++int en50221_app_smartcard_command_reply(struct en50221_app_smartcard *smartcard, ++ uint16_t session_number, ++ uint8_t reply_id, uint8_t status, ++ uint8_t *data, ++ uint32_t data_length) ++{ ++ uint8_t hdr[10]; ++ struct iovec iovec[2]; ++ int iov_count = 0; ++ ++ // the tag ++ hdr[0] = (TAG_SMARTCARD_REPLY >> 16) & 0xFF; ++ hdr[1] = (TAG_SMARTCARD_REPLY >> 8) & 0xFF; ++ hdr[2] = TAG_SMARTCARD_REPLY & 0xFF; ++ ++ // the rest of the data ++ if (reply_id == SMARTCARD_REPLY_ID_ANSW_TO_RESET) { ++ // encode the length field ++ int length_field_len; ++ if ((length_field_len = asn_1_encode(data_length + 2, data + 3, 3)) < 0) { ++ return -1; ++ } ++ // the rest of the header ++ hdr[3 + length_field_len] = reply_id; ++ hdr[3 + length_field_len + 1] = status; ++ iovec[0].iov_base = hdr; ++ iovec[0].iov_len = 3 + length_field_len + 2; ++ ++ // the data ++ iovec[1].iov_base = data; ++ iovec[1].iov_len = data_length; ++ iov_count = 2; ++ } else { ++ hdr[3] = 2; ++ hdr[4] = reply_id; ++ hdr[5] = status; ++ iovec[0].iov_base = data; ++ iovec[0].iov_len = 6; ++ iov_count = 1; ++ } ++ ++ return smartcard->funcs->send_datav(smartcard->funcs->arg, session_number, iovec, iov_count); ++} ++ ++int en50221_app_smartcard_receive(struct en50221_app_smartcard *smartcard, ++ uint16_t session_number, ++ uint8_t *data, ++ uint32_t data_length, ++ uint8_t SW1, uint8_t SW2) ++{ ++ uint8_t buf[10]; ++ uint8_t trailer[10]; ++ ++ // set up the tag ++ buf[0] = (TAG_SMARTCARD_RCV >> 16) & 0xFF; ++ buf[1] = (TAG_SMARTCARD_RCV >> 8) & 0xFF; ++ buf[2] = TAG_SMARTCARD_RCV & 0xFF; ++ ++ // encode the length field ++ int length_field_len; ++ if ((length_field_len = asn_1_encode(data_length + 2, buf + 3, 3)) < 0) { ++ return -1; ++ } ++ // set up the trailer ++ trailer[0] = SW1; ++ trailer[1] = SW2; ++ ++ // build the iovecs ++ struct iovec iov[3]; ++ iov[0].iov_base = buf; ++ iov[0].iov_len = 3 + length_field_len; ++ iov[1].iov_base = data; ++ iov[1].iov_len = data_length; ++ iov[2].iov_base = trailer; ++ iov[2].iov_len = 2; ++ ++ // create the data and send it ++ return smartcard->funcs->send_datav(smartcard->funcs->arg, ++ session_number, iov, 3); ++} ++ ++int en50221_app_smartcard_message(struct en50221_app_smartcard *smartcard, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t *data, uint32_t data_length) ++{ ++ (void) resource_id; ++ ++ // get the tag ++ if (data_length < 3) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint32_t tag = (data[0] << 16) | (data[1] << 8) | data[2]; ++ ++ switch (tag) { ++ case TAG_SMARTCARD_COMMAND: ++ return en50221_app_smartcard_parse_command(smartcard, ++ slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ case TAG_SMARTCARD_SEND: ++ return en50221_app_smartcard_parse_send(smartcard, slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ } ++ ++ print(LOG_LEVEL, ERROR, 1, "Received unexpected tag %x\n", tag); ++ return -1; ++} ++ ++ ++ ++ ++ ++ ++ ++static int en50221_app_smartcard_parse_command(struct en50221_app_smartcard *smartcard, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ if (data_length != 2) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (data[0] != 1) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint8_t command_id = data[1]; ++ ++ // tell the app ++ pthread_mutex_lock(&smartcard->lock); ++ en50221_app_smartcard_command_callback cb = smartcard->command_callback; ++ void *cb_arg = smartcard->command_callback_arg; ++ pthread_mutex_unlock(&smartcard->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, command_id); ++ } ++ return 0; ++} ++ ++static int en50221_app_smartcard_parse_send(struct en50221_app_smartcard *smartcard, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ // first of all, decode the length field ++ uint16_t asn_data_length; ++ int length_field_len; ++ if ((length_field_len = asn_1_decode(&asn_data_length, data, data_length)) < 0) { ++ print(LOG_LEVEL, ERROR, 1, "ASN.1 decode error\n"); ++ return -1; ++ } ++ // check it ++ if (asn_data_length < 8) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ if (asn_data_length > (data_length - length_field_len)) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ data += length_field_len; ++ ++ // parse ++ uint8_t CLA = data[0]; ++ uint8_t INS = data[1]; ++ uint8_t P1 = data[2]; ++ uint8_t P2 = data[3]; ++ uint16_t length_in = (data[4] << 8) | data[5]; ++ uint8_t *data_in = data + 6; ++ ++ // validate the length ++ if ((length_in + 8) != asn_data_length) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint16_t length_out = ++ (data[6 + length_in] << 8) | data[6 + length_in + 1]; ++ ++ // tell the app ++ pthread_mutex_lock(&smartcard->lock); ++ en50221_app_smartcard_send_callback cb = smartcard->send_callback; ++ void *cb_arg = smartcard->send_callback_arg; ++ pthread_mutex_unlock(&smartcard->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, CLA, INS, P1, ++ P2, data_in, length_in, length_out); ++ } ++ return 0; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_smartcard.h dvb-apps/lib/libdvben50221/en50221_app_smartcard.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_smartcard.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_smartcard.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,200 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#ifndef __EN50221_APPLICATION_smartcard_H__ ++#define __EN50221_APPLICATION_smartcard_H__ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++ ++#define SMARTCARD_COMMAND_ID_CONNECT 0x01 ++#define SMARTCARD_COMMAND_ID_DISCONNECT 0x02 ++#define SMARTCARD_COMMAND_ID_POWERON_CARD 0x03 ++#define SMARTCARD_COMMAND_ID_POWEROFF_CARD 0x04 ++#define SMARTCARD_COMMAND_ID_RESET_CARD 0x05 ++#define SMARTCARD_COMMAND_ID_RESET_STATUS 0x06 ++#define SMARTCARD_COMMAND_ID_READ_ANSW_TO_RESET 0x07 ++ ++#define SMARTCARD_REPLY_ID_CONNECTED 0x01 ++#define SMARTCARD_REPLY_ID_FREE 0x02 ++#define SMARTCARD_REPLY_ID_BUSY 0x03 ++#define SMARTCARD_REPLY_ID_ANSW_TO_RESET 0x04 ++#define SMARTCARD_REPLY_ID_NO_ANSW_TO_RESET 0x05 ++ ++#define SMARTCARD_STATUS_CARD_INSERTED 0x01 ++#define SMARTCARD_STATUS_CARD_REMOVED 0x02 ++#define SMARTCARD_STATUS_CARD_IN_PLACE_POWEROFF 0x03 ++#define SMARTCARD_STATUS_CARD_IN_PLACE_POWERON 0x04 ++#define SMARTCARD_STATUS_CARD_NO_CARD 0x05 ++#define SMARTCARD_STATUS_CARD_UNRESPONSIVE_CARD 0x06 ++#define SMARTCARD_STATUS_CARD_REFUSED_CARD 0x07 ++ ++#define EN50221_APP_SMARTCARD_RESOURCEID(DEVICE_NUMBER) MKRID(112, ((DEVICE_NUMBER)& 0x0f), 1) ++ ++ ++ ++/** ++ * Type definition for command - called when we receive a command. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param command_id One of the SMARTCARD_COMMAND_ID_* values ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_smartcard_command_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t command_id); ++ ++/** ++ * Type definition for command - called when we receive a send command. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param CLA CLA value. ++ * @param INS INS value. ++ * @param P1 P1 value. ++ * @param P2 P2 value. ++ * @param in Data to send to the card ++ * @param in_length Number of bytes to send. ++ * @param out_length Number of bytes expected. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_smartcard_send_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t CLA, ++ uint8_t INS, ++ uint8_t P1, ++ uint8_t P2, ++ uint8_t *in, ++ uint32_t in_length, ++ uint32_t out_length); ++ ++/** ++ * Opaque type representing a smartcard resource. ++ */ ++struct en50221_app_smartcard; ++ ++/** ++ * Create an instance of the smartcard resource. ++ * ++ * @param funcs Send functions to use. ++ * @return Instance, or NULL on failure. ++ */ ++extern struct en50221_app_smartcard * ++ en50221_app_smartcard_create(struct en50221_app_send_functions *funcs); ++ ++/** ++ * Destroy an instance of the smartcard resource. ++ * ++ * @param smartcard Instance to destroy. ++ */ ++extern void en50221_app_smartcard_destroy(struct en50221_app_smartcard *smartcard); ++ ++/** ++ * Register the callback for when we receive a comms command. ++ * ++ * @param smartcard smartcard resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_smartcard_register_command_callback(struct en50221_app_smartcard *smartcard, ++ en50221_app_smartcard_command_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for when we receive data to send. ++ * ++ * @param smartcard smartcard resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_smartcard_register_send_callback(struct en50221_app_smartcard *smartcard, ++ en50221_app_smartcard_send_callback callback, ++ void *arg); ++ ++/** ++ * Send a command response to the CAM. ++ * ++ * @param smartcard smartcard resource instance. ++ * @param session_number Session number to send it on. ++ * @param reply_id One of the SMARTCARD_REPLY_ID_* values. ++ * @param status One of the SMARTCARD_STATUS_* values. ++ * @param data Data to send when it is a SMARTCARD_REPLY_ID_ANSW_TO_RESET. ++ * @param data_length Length of data to send. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_smartcard_command_reply(struct en50221_app_smartcard *smartcard, ++ uint16_t session_number, ++ uint8_t reply_id, ++ uint8_t status, ++ uint8_t * data, ++ uint32_t data_length); ++ ++/** ++ * Send data received from a smartcart to the CAM. ++ * ++ * @param smartcard smartcard resource instance. ++ * @param session_number Session number to send it on. ++ * @param data Data to send when it is a SMARTCARD_REPLY_ID_ANSW_TO_RESET. ++ * @param data_length Length of data to send. ++ * @param SW1 SW1 value. ++ * @param SW2 SW2 value. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_smartcard_receive(struct en50221_app_smartcard *smartcard, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length, ++ uint8_t SW1, uint8_t SW2); ++ ++/** ++ * Pass data received for this resource into it for parsing. ++ * ++ * @param smartcard smartcard instance. ++ * @param slot_id Slot ID concerned. ++ * @param session_number Session number concerned. ++ * @param resource_id Resource ID concerned. ++ * @param data The data. ++ * @param data_length Length of data in bytes. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_smartcard_message(struct en50221_app_smartcard *smartcard, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t * data, ++ uint32_t data_length); ++ ++#ifdef __cplusplus ++} ++#endif ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_tags.h dvb-apps/lib/libdvben50221/en50221_app_tags.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_tags.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_tags.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,104 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#ifndef __EN50221_APP_TAGS_H__ ++#define __EN50221_APP_TAGS_H__ ++ ++/* Resource Manager */ ++#define TAG_PROFILE_ENQUIRY 0x9f8010 ++#define TAG_PROFILE 0x9f8011 ++#define TAG_PROFILE_CHANGE 0x9f8012 ++ ++/* Application Info */ ++#define TAG_APP_INFO_ENQUIRY 0x9f8020 ++#define TAG_APP_INFO 0x9f8021 ++#define TAG_ENTER_MENU 0x9f8022 ++ ++/* CA Support */ ++#define TAG_CA_INFO_ENQUIRY 0x9f8030 ++#define TAG_CA_INFO 0x9f8031 ++#define TAG_CA_PMT 0x9f8032 ++#define TAG_CA_PMT_REPLY 0x9f8033 ++ ++/* Host Control */ ++#define TAG_TUNE 0x9f8400 ++#define TAG_REPLACE 0x9f8401 ++#define TAG_CLEAR_REPLACE 0x9f8402 ++#define TAG_ASK_RELEASE 0x9f8403 ++ ++/* Date and Time */ ++#define TAG_DATE_TIME_ENQUIRY 0x9f8440 ++#define TAG_DATE_TIME 0x9f8441 ++ ++/* Man Machine Interface (MMI) */ ++#define TAG_CLOSE_MMI 0x9f8800 ++#define TAG_DISPLAY_CONTROL 0x9f8801 ++#define TAG_DISPLAY_REPLY 0x9f8802 ++#define TAG_TEXT_LAST 0x9f8803 ++#define TAG_TEXT_MORE 0x9f8804 ++#define TAG_KEYPAD_CONTROL 0x9f8805 ++#define TAG_KEYPRESS 0x9f8806 ++#define TAG_ENQUIRY 0x9f8807 ++#define TAG_ANSWER 0x9f8808 ++#define TAG_MENU_LAST 0x9f8809 ++#define TAG_MENU_MORE 0x9f880a ++#define TAG_MENU_ANSWER 0x9f880b ++#define TAG_LIST_LAST 0x9f880c ++#define TAG_LIST_MORE 0x9f880d ++#define TAG_SUBTITLE_SEGMENT_LAST 0x9f880e ++#define TAG_SUBTITLE_SEGMENT_MORE 0x9f880f ++#define TAG_DISPLAY_MESSAGE 0x9f8810 ++#define TAG_SCENE_END_MARK 0x9f8811 ++#define TAG_SCENE_DONE 0x9f8812 ++#define TAG_SCENE_CONTROL 0x9f8813 ++#define TAG_SUBTITLE_DOWNLOAD_LAST 0x9f8814 ++#define TAG_SUBTITLE_DOWNLOAD_MORE 0x9f8815 ++#define TAG_FLUSH_DOWNLOAD 0x9f8816 ++#define TAG_DOWNLOAD_REPLY 0x9f8817 ++ ++/* Low Speed Communications */ ++#define TAG_COMMS_COMMAND 0x9f8c00 ++#define TAG_CONNECTION_DESCRIPTOR 0x9f8c01 ++#define TAG_COMMS_REPLY 0x9f8c02 ++#define TAG_COMMS_SEND_LAST 0x9f8c03 ++#define TAG_COMMS_SEND_MORE 0x9f8c04 ++#define TAG_COMMS_RECV_LAST 0x9f8c05 ++#define TAG_COMMS_RECV_MORE 0x9f8c06 ++ ++/* Authentication */ ++#define TAG_AUTH_REQ 0x9f8200 ++#define TAG_AUTH_RESP 0x9f8201 ++ ++/* Teletext */ ++#define TAG_TELETEXT_EBU 0x9f9000 ++ ++/* Smartcard */ ++#define TAG_SMARTCARD_COMMAND 0x9f8e00 ++#define TAG_SMARTCARD_REPLY 0x9f8e01 ++#define TAG_SMARTCARD_SEND 0x9f8e02 ++#define TAG_SMARTCARD_RCV 0x9f8e03 ++ ++/* EPG */ ++#define TAG_EPG_ENQUIRY 0x9f8f00 ++#define TAG_EPG_REPLY 0x9f8f01 ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_teletext.c dvb-apps/lib/libdvben50221/en50221_app_teletext.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_teletext.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_teletext.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,141 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include "en50221_app_teletext.h" ++#include "en50221_app_tags.h" ++#include "asn_1.h" ++ ++struct en50221_app_teletext { ++ struct en50221_app_send_functions *funcs; ++ ++ en50221_app_teletext_callback callback; ++ void *callback_arg; ++ ++ pthread_mutex_t lock; ++}; ++ ++static int en50221_app_teletext_parse_ebu(struct en50221_app_teletext *teletext, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t * data, ++ uint32_t data_length); ++ ++ ++ ++struct en50221_app_teletext * ++ en50221_app_teletext_create(struct en50221_app_send_functions *funcs) ++{ ++ struct en50221_app_teletext *teletext = NULL; ++ ++ // create structure and set it up ++ teletext = malloc(sizeof(struct en50221_app_teletext)); ++ if (teletext == NULL) { ++ return NULL; ++ } ++ teletext->funcs = funcs; ++ teletext->callback = NULL; ++ ++ pthread_mutex_init(&teletext->lock, NULL); ++ ++ // done ++ return teletext; ++} ++ ++void en50221_app_teletext_destroy(struct en50221_app_teletext *teletext) ++{ ++ pthread_mutex_destroy(&teletext->lock); ++ free(teletext); ++} ++ ++void en50221_app_teletext_register_callback(struct en50221_app_teletext *teletext, ++ en50221_app_teletext_callback callback, void *arg) ++{ ++ pthread_mutex_lock(&teletext->lock); ++ teletext->callback = callback; ++ teletext->callback_arg = arg; ++ pthread_mutex_unlock(&teletext->lock); ++} ++ ++int en50221_app_teletext_message(struct en50221_app_teletext *teletext, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t * data, uint32_t data_length) ++{ ++ (void) resource_id; ++ ++ // get the tag ++ if (data_length < 3) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint32_t tag = (data[0] << 16) | (data[1] << 8) | data[2]; ++ ++ switch (tag) { ++ case TAG_TELETEXT_EBU: ++ return en50221_app_teletext_parse_ebu(teletext, slot_id, ++ session_number, ++ data + 3, ++ data_length - 3); ++ } ++ ++ print(LOG_LEVEL, ERROR, 1, "Received unexpected tag %x\n", tag); ++ return -1; ++} ++ ++ ++static int en50221_app_teletext_parse_ebu(struct en50221_app_teletext *teletext, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t *data, ++ uint32_t data_length) ++{ ++ // first of all, decode the length field ++ uint16_t asn_data_length; ++ int length_field_len; ++ if ((length_field_len = asn_1_decode(&asn_data_length, data, data_length)) < 0) { ++ print(LOG_LEVEL, ERROR, 1, "ASN.1 decode error\n"); ++ return -1; ++ } ++ ++ // check it ++ if (asn_data_length > (data_length - length_field_len)) { ++ print(LOG_LEVEL, ERROR, 1, "Received short data\n"); ++ return -1; ++ } ++ uint8_t *teletext_data = data + length_field_len; ++ ++ // tell the app ++ pthread_mutex_lock(&teletext->lock); ++ en50221_app_teletext_callback cb = teletext->callback; ++ void *cb_arg = teletext->callback_arg; ++ pthread_mutex_unlock(&teletext->lock); ++ if (cb) { ++ return cb(cb_arg, slot_id, session_number, teletext_data, ++ asn_data_length); ++ } ++ return 0; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_teletext.h dvb-apps/lib/libdvben50221/en50221_app_teletext.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_teletext.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_teletext.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,107 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#ifndef __EN50221_APPLICATION_teletext_H__ ++#define __EN50221_APPLICATION_teletext_H__ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++ ++#define EN50221_APP_TELETEXT_RESOURCEID MKRID(128, 1, 1) ++ ++ ++/** ++ * Type definition for request - called when we receive teletext from a CAM. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number concerned. ++ * @param teletext_data Data for the request. ++ * @param teletext_data_lenghth Number of bytes. ++ * @return 0 on success, -1 on failure. ++ */ ++typedef int (*en50221_app_teletext_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint8_t *teletext_data, ++ uint32_t teletext_data_length); ++ ++/** ++ * Opaque type representing a teletext resource. ++ */ ++struct en50221_app_teletext; ++ ++/** ++ * Create an instance of the teletext resource. ++ * ++ * @param funcs Send functions to use. ++ * @return Instance, or NULL on failure. ++ */ ++extern struct en50221_app_teletext * ++ en50221_app_teletext_create(struct en50221_app_send_functions *funcs); ++ ++/** ++ * Destroy an instance of the teletext resource. ++ * ++ * @param teletext Instance to destroy. ++ */ ++extern void en50221_app_teletext_destroy(struct en50221_app_teletext *teletext); ++ ++/** ++ * Register the callback for when we receive a request. ++ * ++ * @param teletext teletext resource instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_app_teletext_register_callback(struct en50221_app_teletext *teletext, ++ en50221_app_teletext_callback callback, ++ void *arg); ++ ++/** ++ * Pass data received for this resource into it for parsing. ++ * ++ * @param teletext teletext instance. ++ * @param slot_id Slot ID concerned. ++ * @param session_number Session number concerned. ++ * @param resource_id Resource ID concerned. ++ * @param data The data. ++ * @param data_length Length of data in bytes. ++ * @return 0 on success, -1 on failure. ++ */ ++extern int en50221_app_teletext_message(struct en50221_app_teletext *teletext, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t * data, ++ uint32_t data_length); ++ ++#ifdef __cplusplus ++} ++#endif ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_utils.c dvb-apps/lib/libdvben50221/en50221_app_utils.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_utils.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_utils.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,38 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include "en50221_app_utils.h" ++ ++struct en50221_app_public_resource_id ++ *en50221_app_decode_public_resource_id(struct en50221_app_public_resource_id *idf, ++ uint32_t resource_id) ++{ ++ // reject private resources ++ if ((resource_id & 0xc0000000) == 0xc0000000) ++ return NULL; ++ ++ idf->resource_class = (resource_id >> 16) & 0xffff; // use the resource_id as the MSBs of class ++ idf->resource_type = (resource_id >> 6) & 0x3ff; ++ idf->resource_version = resource_id & 0x3f; ++ return idf; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_utils.h dvb-apps/lib/libdvben50221/en50221_app_utils.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_app_utils.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_app_utils.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,112 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#ifndef __EN50221_APP_UTILS_H__ ++#define __EN50221_APP_UTILS_H__ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * A decomposed public resource structure. ++ * ++ * we will ignore private resource (resource_id_type==3), ++ * because they are not used by any modules at all and ++ * would need special code for any private resource anyway. ++ */ ++struct en50221_app_public_resource_id { ++ uint16_t resource_class; ++ uint16_t resource_type; ++ uint8_t resource_version; ++}; ++ ++typedef int (*en50221_send_data) (void *arg, ++ uint16_t session_number, ++ uint8_t * data, ++ uint16_t data_length); ++typedef int (*en50221_send_datav) (void *arg, ++ uint16_t session_number, ++ struct iovec * vector, ++ int iov_count); ++ ++/** ++ * An abstraction away from hardcoded send functions so different layers may be ++ * slotted in under the application layer. ++ */ ++struct en50221_app_send_functions { ++ /** ++ * Argument to pass to these functions. ++ */ ++ void *arg; ++ ++ /** ++ * Send data. ++ */ ++ en50221_send_data send_data; ++ ++ /** ++ * Send vector data. ++ */ ++ en50221_send_datav send_datav; ++}; ++ ++/** ++ * Make a host-endian uint32_t formatted resource id. ++ * ++ * @param CLASS Class of resource. ++ * @param TYPE Type of resource. ++ * @param VERSION Version of resource. ++ * @return Formatted resource id. ++ */ ++#define MKRID(CLASS, TYPE, VERSION) ((((CLASS)&0xffff)<<16) | (((TYPE)&0x3ff)<<6) | ((VERSION)&0x3f)) ++ ++/** ++ * Decode a host-endian public resource_id into an en50221_app_public_resource_id structure. ++ * ++ * @param idf Structure to write decoded resource_id into. ++ * @param resource_id ID to decode. ++ * @return Pointer to idf on success, or NULL if this is not a public resource. ++ */ ++struct en50221_app_public_resource_id * ++ en50221_app_decode_public_resource_id(struct en50221_app_public_resource_id *idf, ++ uint32_t resource_id); ++ ++/** ++ * Encode an en50221_app_public_resource_id structure into a host-endian uint32_t. ++ * ++ * @param idf Structure to encode. ++ * @return The encoded value ++ */ ++static inline uint32_t en50221_app_encode_public_resource_id(struct en50221_app_public_resource_id *idf) { ++ return MKRID(idf->resource_class, idf->resource_type, idf->resource_version); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_errno.h dvb-apps/lib/libdvben50221/en50221_errno.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_errno.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_errno.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,49 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 session layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#ifndef EN50221_ERRNO ++#define EN50221_ERRNO 1 ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#define EN50221ERR_CAREAD -1 /* error during read from CA device. */ ++#define EN50221ERR_CAWRITE -2 /* error during write to CA device. */ ++#define EN50221ERR_TIMEOUT -3 /* timeout occured waiting for a response from a device. */ ++#define EN50221ERR_BADSLOTID -4 /* bad slot ID supplied by user - the offending slot_id will not be set. */ ++#define EN50221ERR_BADCONNECTIONID -5 /* bad connection ID supplied by user. */ ++#define EN50221ERR_BADSTATE -6 /* slot/connection in the wrong state. */ ++#define EN50221ERR_BADCAMDATA -7 /* CAM supplied an invalid request. */ ++#define EN50221ERR_OUTOFMEMORY -8 /* memory allocation failed. */ ++#define EN50221ERR_ASNENCODE -9 /* ASN.1 encode failure - indicates library bug. */ ++#define EN50221ERR_OUTOFCONNECTIONS -10 /* no more connections available. */ ++#define EN50221ERR_OUTOFSLOTS -11 /* no more slots available - the offending slot_id will not be set. */ ++#define EN50221ERR_IOVLIMIT -12 /* Too many struct iovecs were used. */ ++#define EN50221ERR_BADSESSIONNUMBER -13 /* Bad session number suppplied by user. */ ++#define EN50221ERR_OUTOFSESSIONS -14 /* no more sessions available. */ ++ ++#ifdef __cplusplus ++} ++#endif ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_session.c dvb-apps/lib/libdvben50221/en50221_session.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_session.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_session.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,1055 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "en50221_transport.h" ++#include "en50221_session.h" ++#include "en50221_errno.h" ++#include "asn_1.h" ++ ++ ++// these are the possible session statuses ++#define S_STATUS_OPEN 0x00 // session is opened ++#define S_STATUS_CLOSE_NO_RES 0xF0 // could not open session, no proper resource available ++#define S_STATUS_CLOSE_RES_UNAVAILABLE 0xF1 // could not open session, resource unavailable ++#define S_STATUS_CLOSE_RES_LOW_VERSION 0xF2 // could not open session, resource version too low ++#define S_STATUS_CLOSE_RES_BUSY 0xF3 // could not open session, resource is busy ++ ++#define ST_OPEN_SESSION_REQ 0x91 // h<--m ++#define ST_OPEN_SESSION_RES 0x92 // h-->m ++#define ST_CREATE_SESSION 0x93 // h-->m ++#define ST_CREATE_SESSION_RES 0x94 // h<--m ++#define ST_CLOSE_SESSION_REQ 0x95 // h<->m ++#define ST_CLOSE_SESSION_RES 0x96 // h<->m ++#define ST_SESSION_NUMBER 0x90 // h<->m ++ ++#define S_STATE_IDLE 0x01 // this session is not in use ++#define S_STATE_ACTIVE 0x02 // this session is in use ++#define S_STATE_IN_CREATION 0x04 // this session waits for a ST_CREATE_SESSION_RES to become active ++#define S_STATE_IN_DELETION 0x08 // this session waits for ST_CLOSE_SESSION_RES to become idle again ++ ++ ++// for each session we store its identifier, the resource-id ++// it is linked to and the callback of the specific resource ++struct en50221_session { ++ uint8_t state; ++ uint32_t resource_id; ++ uint8_t slot_id; ++ uint8_t connection_id; ++ ++ en50221_sl_resource_callback callback; ++ void *callback_arg; ++ ++ pthread_mutex_t session_lock; ++}; ++ ++struct en50221_session_layer { ++ uint32_t max_sessions; ++ struct en50221_transport_layer *tl; ++ ++ en50221_sl_lookup_callback lookup; ++ void *lookup_arg; ++ ++ en50221_sl_session_callback session; ++ void *session_arg; ++ ++ pthread_mutex_t global_lock; ++ pthread_mutex_t setcallback_lock; ++ ++ int error; ++ ++ struct en50221_session *sessions; ++}; ++ ++static void en50221_sl_transport_callback(void *arg, int reason, ++ uint8_t * data, ++ uint32_t data_length, ++ uint8_t slot_id, ++ uint8_t connection_id); ++static int en50221_sl_alloc_new_session(struct en50221_session_layer *sl, ++ uint32_t resource_id, ++ uint8_t slot_id, ++ uint8_t connection_id, ++ en50221_sl_resource_callback ++ callback, void *arg); ++ ++ ++ ++ ++struct en50221_session_layer *en50221_sl_create(struct en50221_transport_layer *tl, ++ uint32_t max_sessions) ++{ ++ struct en50221_session_layer *sl = NULL; ++ uint32_t i; ++ ++ // setup structure ++ sl = (struct en50221_session_layer *) ++ malloc(sizeof(struct en50221_session_layer)); ++ if (sl == NULL) ++ goto error_exit; ++ sl->max_sessions = max_sessions; ++ sl->lookup = NULL; ++ sl->session = NULL; ++ sl->tl = tl; ++ sl->error = 0; ++ ++ // init the mutex ++ pthread_mutex_init(&sl->global_lock, NULL); ++ pthread_mutex_init(&sl->setcallback_lock, NULL); ++ ++ // create the slots ++ sl->sessions = malloc(sizeof(struct en50221_session) * max_sessions); ++ if (sl->sessions == NULL) ++ goto error_exit; ++ ++ // set them up ++ for (i = 0; i < max_sessions; i++) { ++ sl->sessions[i].state = S_STATE_IDLE; ++ sl->sessions[i].callback = NULL; ++ ++ pthread_mutex_init(&sl->sessions[i].session_lock, NULL); ++ } ++ ++ // register ourselves with the transport layer ++ en50221_tl_register_callback(tl, en50221_sl_transport_callback, sl); ++ ++ return sl; ++ ++error_exit: ++ en50221_sl_destroy(sl); ++ return NULL; ++} ++ ++void en50221_sl_destroy(struct en50221_session_layer *sl) ++{ ++ uint32_t i; ++ ++ if (sl) { ++ if (sl->sessions) { ++ for (i = 0; i < sl->max_sessions; i++) { ++ pthread_mutex_destroy(&sl->sessions[i].session_lock); ++ } ++ free(sl->sessions); ++ } ++ ++ pthread_mutex_destroy(&sl->setcallback_lock); ++ pthread_mutex_destroy(&sl->global_lock); ++ ++ free(sl); ++ } ++} ++ ++int en50221_sl_get_error(struct en50221_session_layer *sl) ++{ ++ return sl->error; ++} ++ ++void en50221_sl_register_lookup_callback(struct en50221_session_layer *sl, ++ en50221_sl_lookup_callback ++ callback, void *arg) ++{ ++ pthread_mutex_lock(&sl->setcallback_lock); ++ sl->lookup = callback; ++ sl->lookup_arg = arg; ++ pthread_mutex_unlock(&sl->setcallback_lock); ++} ++ ++void en50221_sl_register_session_callback(struct en50221_session_layer *sl, ++ en50221_sl_session_callback ++ callback, void *arg) ++{ ++ pthread_mutex_lock(&sl->setcallback_lock); ++ sl->session = callback; ++ sl->session_arg = arg; ++ pthread_mutex_unlock(&sl->setcallback_lock); ++} ++ ++int en50221_sl_create_session(struct en50221_session_layer *sl, ++ int slot_id, uint8_t connection_id, ++ uint32_t resource_id, ++ en50221_sl_resource_callback callback, ++ void *arg) ++{ ++ // lookup next free session_id: ++ pthread_mutex_lock(&sl->global_lock); ++ int session_number = ++ en50221_sl_alloc_new_session(sl, resource_id, slot_id, ++ connection_id, callback, arg); ++ if (session_number == -1) { ++ pthread_mutex_unlock(&sl->global_lock); ++ return -1; ++ } ++ pthread_mutex_unlock(&sl->global_lock); ++ ++ // make up the header ++ uint8_t hdr[8]; ++ hdr[0] = ST_CREATE_SESSION; ++ hdr[1] = 6; ++ hdr[2] = resource_id >> 24; ++ hdr[3] = resource_id >> 16; ++ hdr[4] = resource_id >> 8; ++ hdr[5] = resource_id; ++ hdr[6] = session_number >> 8; ++ hdr[7] = session_number; ++ ++ // send this command ++ if (en50221_tl_send_data(sl->tl, slot_id, connection_id, hdr, 8)) { ++ pthread_mutex_lock(&sl->sessions[session_number].session_lock); ++ if (sl->sessions[session_number].state == S_STATE_IN_CREATION) { ++ sl->sessions[session_number].state = S_STATE_IDLE; ++ } ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ ++ sl->error = en50221_tl_get_error(sl->tl); ++ return -1; ++ } ++ // ok. ++ return session_number; ++} ++ ++int en50221_sl_destroy_session(struct en50221_session_layer *sl, ++ uint16_t session_number) ++{ ++ if (session_number >= sl->max_sessions) { ++ sl->error = EN50221ERR_BADSESSIONNUMBER; ++ return -1; ++ } ++ ++ pthread_mutex_lock(&sl->sessions[session_number].session_lock); ++ if (!(sl->sessions[session_number].state & (S_STATE_ACTIVE | S_STATE_IN_DELETION))) { ++ sl->error = EN50221ERR_BADSESSIONNUMBER; ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ return -1; ++ } ++ // set the state ++ sl->sessions[session_number].state = S_STATE_IN_DELETION; ++ ++ // get essential details ++ uint8_t slot_id = sl->sessions[session_number].slot_id; ++ uint8_t connection_id = sl->sessions[session_number].connection_id; ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ ++ // sendit ++ uint8_t hdr[4]; ++ hdr[0] = ST_CLOSE_SESSION_REQ; ++ hdr[1] = 2; ++ hdr[2] = session_number >> 8; ++ hdr[3] = session_number; ++ if (en50221_tl_send_data(sl->tl, slot_id, connection_id, hdr, 4)) { ++ pthread_mutex_lock(&sl->sessions[session_number].session_lock); ++ if (sl->sessions[session_number].state == S_STATE_IN_DELETION) { ++ sl->sessions[session_number].state = S_STATE_IDLE; ++ } ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ ++ sl->error = en50221_tl_get_error(sl->tl); ++ return -1; ++ } ++ ++ return 0; ++} ++ ++int en50221_sl_send_data(struct en50221_session_layer *sl, ++ uint16_t session_number, ++ uint8_t *data, ++ uint16_t data_length) ++{ ++ if (session_number >= sl->max_sessions) { ++ sl->error = EN50221ERR_BADSESSIONNUMBER; ++ return -1; ++ } ++ ++ pthread_mutex_lock(&sl->sessions[session_number].session_lock); ++ if (sl->sessions[session_number].state != S_STATE_ACTIVE) { ++ sl->error = EN50221ERR_BADSESSIONNUMBER; ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ return -1; ++ } ++ // get essential details ++ uint8_t slot_id = sl->sessions[session_number].slot_id; ++ uint8_t connection_id = sl->sessions[session_number].connection_id; ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ ++ // sendit ++ struct iovec iov[2]; ++ uint8_t hdr[4]; ++ hdr[0] = ST_SESSION_NUMBER; ++ hdr[1] = 2; ++ hdr[2] = session_number >> 8; ++ hdr[3] = session_number; ++ iov[0].iov_base = hdr; ++ iov[0].iov_len = 4; ++ iov[1].iov_base = data; ++ iov[1].iov_len = data_length; ++ if (en50221_tl_send_datav(sl->tl, slot_id, connection_id, iov, 2)) { ++ sl->error = en50221_tl_get_error(sl->tl); ++ return -1; ++ } ++ ++ return 0; ++} ++ ++int en50221_sl_send_datav(struct en50221_session_layer *sl, ++ uint16_t session_number, ++ struct iovec *vector, ++ int iov_count) ++{ ++ if (session_number >= sl->max_sessions) { ++ sl->error = EN50221ERR_BADSESSIONNUMBER; ++ return -1; ++ } ++ ++ pthread_mutex_lock(&sl->sessions[session_number].session_lock); ++ if (sl->sessions[session_number].state != S_STATE_ACTIVE) { ++ sl->error = EN50221ERR_BADSESSIONNUMBER; ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ return -1; ++ } ++ if (iov_count > 9) { ++ sl->error = EN50221ERR_IOVLIMIT; ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ return -1; ++ } ++ uint8_t slot_id = sl->sessions[session_number].slot_id; ++ uint8_t connection_id = sl->sessions[session_number].connection_id; ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ ++ // make up the header ++ struct iovec out_iov[10]; ++ uint8_t hdr[4]; ++ hdr[0] = ST_SESSION_NUMBER; ++ hdr[1] = 2; ++ hdr[2] = session_number >> 8; ++ hdr[3] = session_number; ++ out_iov[0].iov_base = hdr; ++ out_iov[0].iov_len = 4; ++ ++ // make up the data ++ memcpy(&out_iov[1], vector, iov_count * sizeof(struct iovec)); ++ ++ // send this command ++ if (en50221_tl_send_datav(sl->tl, slot_id, connection_id, out_iov, iov_count + 1)) { ++ sl->error = en50221_tl_get_error(sl->tl); ++ return -1; ++ } ++ return 0; ++} ++ ++int en50221_sl_broadcast_data(struct en50221_session_layer *sl, ++ int slot_id, uint32_t resource_id, ++ uint8_t *data, uint16_t data_length) ++{ ++ uint32_t i; ++ ++ for (i = 0; i < sl->max_sessions; i++) { ++ pthread_mutex_lock(&sl->sessions[i].session_lock); ++ ++ if (sl->sessions[i].state != S_STATE_ACTIVE) { ++ pthread_mutex_unlock(&sl->sessions[i].session_lock); ++ continue; ++ } ++ if ((slot_id != -1) ++ && (slot_id != sl->sessions[i].slot_id)) { ++ pthread_mutex_unlock(&sl->sessions[i].session_lock); ++ continue; ++ } ++ ++ if (sl->sessions[i].resource_id == resource_id) { ++ pthread_mutex_unlock(&sl->sessions[i].session_lock); ++ en50221_sl_send_data(sl, i, data, data_length); ++ } else { ++ pthread_mutex_unlock(&sl->sessions[i].session_lock); ++ } ++ } ++ ++ return 0; ++} ++ ++ ++ ++static void en50221_sl_handle_open_session_request(struct en50221_session_layer *sl, ++ uint8_t *data, ++ uint32_t data_length, ++ uint8_t slot_id, ++ uint8_t connection_id) ++{ ++ // check ++ if (data_length < 5) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received data with invalid length from module on slot %02x\n", ++ slot_id); ++ return; ++ } ++ if (data[0] != 4) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received data with invalid length from module on slot %02x\n", ++ slot_id); ++ return; ++ } ++ // get the resource id ++ uint32_t requested_resource_id = ++ (data[1] << 24) | (data[2] << 16) | (data[3] << 8) | data[4]; ++ ++ // get lookup callback details ++ pthread_mutex_lock(&sl->setcallback_lock); ++ en50221_sl_lookup_callback lcb = sl->lookup; ++ void *lcb_arg = sl->lookup_arg; ++ pthread_mutex_unlock(&sl->setcallback_lock); ++ ++ // first of all, lookup this resource id ++ int status = S_STATUS_CLOSE_NO_RES; ++ en50221_sl_resource_callback resource_callback = NULL; ++ void *resource_arg = NULL; ++ uint32_t connected_resource_id; ++ if (lcb) { ++ status = ++ lcb(lcb_arg, slot_id, requested_resource_id, ++ &resource_callback, &resource_arg, ++ &connected_resource_id); ++ switch (status) { ++ case 0: ++ status = S_STATUS_OPEN; ++ break; ++ ++ case -1: ++ status = S_STATUS_CLOSE_NO_RES; ++ break; ++ ++ case -2: ++ status = S_STATUS_CLOSE_RES_LOW_VERSION; ++ break; ++ ++ case -3: ++ status = S_STATUS_CLOSE_RES_UNAVAILABLE; ++ break; ++ } ++ } ++ // if we found it, get a new session for it ++ int session_number = -1; ++ if (status == S_STATUS_OPEN) { ++ // lookup next free session_id: ++ pthread_mutex_lock(&sl->global_lock); ++ session_number = ++ en50221_sl_alloc_new_session(sl, connected_resource_id, ++ slot_id, connection_id, ++ resource_callback, ++ resource_arg); ++ pthread_mutex_unlock(&sl->global_lock); ++ ++ if (session_number == -1) { ++ status = S_STATUS_CLOSE_NO_RES; ++ } else { ++ // inform upper layers/ check availability ++ pthread_mutex_lock(&sl->setcallback_lock); ++ en50221_sl_session_callback cb = sl->session; ++ void *cb_arg = sl->session_arg; ++ pthread_mutex_unlock(&sl->setcallback_lock); ++ if (cb) { ++ if (cb(cb_arg, S_SCALLBACK_REASON_CAMCONNECTING, ++ slot_id, session_number, ++ connected_resource_id)) { ++ status = S_STATUS_CLOSE_RES_BUSY; ++ } ++ } else { ++ status = S_STATUS_CLOSE_RES_UNAVAILABLE; ++ } ++ } ++ } ++ // send response ++ uint8_t hdr[9]; ++ hdr[0] = ST_OPEN_SESSION_RES; ++ hdr[1] = 7; ++ hdr[2] = status; ++ hdr[3] = connected_resource_id >> 24; ++ hdr[4] = connected_resource_id >> 16; ++ hdr[5] = connected_resource_id >> 8; ++ hdr[6] = connected_resource_id; ++ hdr[7] = session_number >> 8; ++ hdr[8] = session_number; ++ if (en50221_tl_send_data(sl->tl, slot_id, connection_id, hdr, 9)) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Transport layer error %i occurred\n", ++ en50221_tl_get_error(sl->tl)); ++ status = S_STATUS_CLOSE_NO_RES; ++ // fallthrough ++ } ++ // inform upper layers what happened ++ if (session_number != -1) { ++ // setup session state apppropriately from upper layer response ++ pthread_mutex_lock(&sl->sessions[session_number].session_lock); ++ if (status != S_STATUS_OPEN) { ++ sl->sessions[session_number].state = S_STATE_IDLE; ++ } else { ++ sl->sessions[session_number].state = S_STATE_ACTIVE; ++ } ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ ++ // tell upper layers ++ if (sl->sessions[session_number].state == S_STATE_ACTIVE) { ++ pthread_mutex_lock(&sl->setcallback_lock); ++ en50221_sl_session_callback cb = sl->session; ++ void *cb_arg = sl->session_arg; ++ pthread_mutex_unlock(&sl->setcallback_lock); ++ ++ if (status == S_STATUS_OPEN) { ++ if (cb) ++ cb(cb_arg, ++ S_SCALLBACK_REASON_CAMCONNECTED, ++ slot_id, session_number, ++ connected_resource_id); ++ } else { ++ sl->sessions[session_number].state = ++ S_STATE_IDLE; ++ if (cb) ++ cb(cb_arg, ++ S_SCALLBACK_REASON_CAMCONNECTFAIL, ++ slot_id, session_number, ++ connected_resource_id); ++ } ++ } ++ } ++} ++ ++static void en50221_sl_handle_close_session_request(struct en50221_session_layer *sl, ++ uint8_t * data, ++ uint32_t data_length, ++ uint8_t slot_id, ++ uint8_t connection_id) ++{ ++ // check ++ if (data_length < 3) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received data with invalid length from module on slot %02x\n", ++ slot_id); ++ return; ++ } ++ if (data[0] != 2) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received data with invalid length from module on slot %02x\n", ++ slot_id); ++ return; ++ } ++ // extract session number ++ uint16_t session_number = (data[1] << 8) | data[2]; ++ ++ // check session number is ok ++ uint8_t code = 0x00; ++ uint32_t resource_id = 0; ++ if (session_number >= sl->max_sessions) { ++ code = 0xF0; // session close error ++ print(LOG_LEVEL, ERROR, 1, "Received bad session id %i\n", ++ slot_id); ++ } else { ++ pthread_mutex_lock(&sl->sessions[session_number]. ++ session_lock); ++ if (slot_id != sl->sessions[session_number].slot_id) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received unexpected session on invalid slot %i\n", ++ slot_id); ++ code = 0xF0; // session close error ++ } ++ if (connection_id != sl->sessions[session_number].connection_id) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received unexpected session on invalid slot %i\n", ++ slot_id); ++ code = 0xF0; // session close error ++ } ++ if (!(sl->sessions[session_number].state & (S_STATE_ACTIVE | S_STATE_IN_DELETION))) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received unexpected session on invalid slot %i\n", ++ slot_id); ++ code = 0xF0; // session close error ++ } ++ ++ if (code == 0x00) { ++ sl->sessions[session_number].state = S_STATE_IDLE; ++ code = 0x00; // close ok ++ } ++ resource_id = sl->sessions[session_number].resource_id; ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ } ++ ++ // make up the response ++ uint8_t hdr[5]; ++ hdr[0] = ST_CLOSE_SESSION_RES; ++ hdr[1] = 3; ++ hdr[2] = code; ++ hdr[3] = session_number >> 8; ++ hdr[4] = session_number; ++ ++ // sendit ++ if (en50221_tl_send_data(sl->tl, slot_id, connection_id, hdr, 5)) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Transport layer reports error %i on slot %i\n", ++ en50221_tl_get_error(sl->tl), slot_id); ++ } ++ // callback to announce destruction to resource if it was ok ++ if (code == 0x00) { ++ pthread_mutex_lock(&sl->setcallback_lock); ++ en50221_sl_session_callback cb = sl->session; ++ void *cb_arg = sl->session_arg; ++ pthread_mutex_unlock(&sl->setcallback_lock); ++ ++ if (cb) ++ cb(cb_arg, S_SCALLBACK_REASON_CLOSE, slot_id, ++ session_number, resource_id); ++ } ++} ++ ++static void en50221_sl_handle_create_session_response(struct en50221_session_layer *sl, ++ uint8_t * data, ++ uint32_t data_length, ++ uint8_t slot_id, ++ uint8_t connection_id) ++{ ++ // check ++ if (data_length < 8) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received data with invalid length from module on slot %02x\n", ++ slot_id); ++ return; ++ } ++ if (data[0] != 7) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received data with invalid length from module on slot %02x\n", ++ slot_id); ++ return; ++ } ++ // extract session number ++ uint16_t session_number = (data[5] << 8) | data[6]; ++ ++ // check session number is ok ++ if (session_number >= sl->max_sessions) { ++ print(LOG_LEVEL, ERROR, 1, "Received bad session id %i\n", ++ slot_id); ++ return; ++ } ++ ++ pthread_mutex_lock(&sl->sessions[session_number].session_lock); ++ if (slot_id != sl->sessions[session_number].slot_id) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received unexpected session on invalid slot %i\n", ++ slot_id); ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ return; ++ } ++ if (connection_id != sl->sessions[session_number].connection_id) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received unexpected session on invalid slot %i\n", ++ slot_id); ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ return; ++ } ++ if (sl->sessions[session_number].state != S_STATE_IN_CREATION) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received unexpected session on invalid slot %i\n", ++ slot_id); ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ return; ++ } ++ // extract status ++ if (data[1] != S_STATUS_OPEN) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Session creation failed 0x%02x\n", data[1]); ++ sl->sessions[session_number].state = S_STATE_IDLE; ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ ++ // inform upper layers ++ pthread_mutex_lock(&sl->setcallback_lock); ++ en50221_sl_session_callback cb = sl->session; ++ void *cb_arg = sl->session_arg; ++ pthread_mutex_unlock(&sl->setcallback_lock); ++ if (cb) ++ cb(cb_arg, S_SCALLBACK_REASON_CONNECTFAIL, slot_id, ++ session_number, ++ sl->sessions[session_number].resource_id); ++ return; ++ } ++ // set it active ++ sl->sessions[session_number].state = S_STATE_ACTIVE; ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ ++ // inform upper layers ++ pthread_mutex_lock(&sl->setcallback_lock); ++ en50221_sl_session_callback cb = sl->session; ++ void *cb_arg = sl->session_arg; ++ pthread_mutex_unlock(&sl->setcallback_lock); ++ if (cb) ++ cb(cb_arg, S_SCALLBACK_REASON_CONNECTED, slot_id, ++ session_number, ++ sl->sessions[session_number].resource_id); ++} ++ ++static void en50221_sl_handle_close_session_response(struct en50221_session_layer *sl, ++ uint8_t *data, ++ uint32_t data_length, ++ uint8_t slot_id, ++ uint8_t connection_id) ++{ ++ // check ++ if (data_length < 5) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received data with invalid length from module on slot %02x\n", ++ slot_id); ++ return; ++ } ++ if (data[0] != 4) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received data with invalid length from module on slot %02x\n", ++ slot_id); ++ return; ++ } ++ // extract session number ++ uint16_t session_number = (data[2] << 8) | data[3]; ++ ++ // check session number is ok ++ if (session_number >= sl->max_sessions) { ++ print(LOG_LEVEL, ERROR, 1, "Received bad session id %i\n", slot_id); ++ return; ++ } ++ ++ pthread_mutex_lock(&sl->sessions[session_number].session_lock); ++ if (slot_id != sl->sessions[session_number].slot_id) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received unexpected session on invalid slot %i\n", ++ slot_id); ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ return; ++ } ++ if (connection_id != sl->sessions[session_number].connection_id) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received unexpected session on invalid slot %i\n", ++ slot_id); ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ return; ++ } ++ if (sl->sessions[session_number].state != S_STATE_IN_DELETION) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received unexpected session on invalid slot %i\n", ++ slot_id); ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ return; ++ } ++ // extract status ++ if (data[1] != 0x00) { ++ print(LOG_LEVEL, ERROR, 1, "Session close failed 0x%02x\n", data[1]); ++ // just fallthrough anyway ++ } ++ // completed ++ sl->sessions[session_number].state = S_STATE_IDLE; ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++} ++ ++static void en50221_sl_handle_session_package(struct en50221_session_layer *sl, ++ uint8_t *data, ++ uint32_t data_length, ++ uint8_t slot_id, ++ uint8_t connection_id) ++{ ++ // check ++ if (data_length < 3) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received data with invalid length from module on slot %i\n", ++ slot_id); ++ return; ++ } ++ if (data[0] != 2) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received data with invalid length from module on slot %i\n", ++ slot_id); ++ return; ++ } ++ // get session number ++ uint16_t session_number = (data[1] << 8) | data[2]; ++ ++ // check it ++ if (session_number >= sl->max_sessions) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received data with bad session_number from module on slot %i\n", ++ slot_id); ++ return; ++ } ++ ++ pthread_mutex_lock(&sl->sessions[session_number].session_lock); ++ if (slot_id != sl->sessions[session_number].slot_id) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received unexpected session on invalid slot %i\n", ++ slot_id); ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ return; ++ } ++ if (connection_id != sl->sessions[session_number].connection_id) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received unexpected session on invalid slot %i\n", ++ slot_id); ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ return; ++ } ++ if (sl->sessions[session_number].state != S_STATE_ACTIVE) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received data with bad session_number from module on slot %i\n", ++ slot_id); ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ return; ++ } ++ ++ en50221_sl_resource_callback cb = sl->sessions[session_number].callback; ++ void *cb_arg = sl->sessions[session_number].callback_arg; ++ uint32_t resource_id = sl->sessions[session_number].resource_id; ++ pthread_mutex_unlock(&sl->sessions[session_number].session_lock); ++ ++ // there can be > 1 APDU following the package - all for the same session/resource_id tho. ++ data += 3; ++ data_length -= 3; ++ while (data_length) { ++ // check length field ++ if (data_length < 3) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received invalid sized session package from slot %i\n", ++ slot_id); ++ return; ++ } ++ // parse the APDU's length field ++ int length_field_len; ++ uint16_t asn_data_length; ++ if ((length_field_len = asn_1_decode(&asn_data_length, data + 3, data_length - 3)) < 0) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received invalid sized session package from slot %i\n", ++ slot_id); ++ return; ++ } ++ uint32_t apdu_length = 3 + length_field_len + asn_data_length; ++ ++ // check there is enough data ++ if (apdu_length > data_length) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received invalid sized session package from slot %i\n", ++ slot_id); ++ return; ++ } ++ // pass the APDU up to the higher layers ++ if (cb) ++ cb(cb_arg, slot_id, session_number, resource_id, data, apdu_length); ++ ++ // next! ++ data += apdu_length; ++ data_length -= apdu_length; ++ } ++ ++} ++ ++static void en50221_sl_transport_callback(void *arg, int reason, ++ uint8_t *data, ++ uint32_t data_length, ++ uint8_t slot_id, ++ uint8_t connection_id) ++{ ++ struct en50221_session_layer *sl = ++ (struct en50221_session_layer *) arg; ++ uint32_t i; ++ ++ // deal with the reason for this callback ++ switch (reason) { ++ case T_CALLBACK_REASON_DATA: ++ // fallthrough into rest of this function ++ break; ++ ++ case T_CALLBACK_REASON_CONNECTIONOPEN: ++ { ++ pthread_mutex_lock(&sl->setcallback_lock); ++ en50221_sl_session_callback cb = sl->session; ++ void *cb_arg = sl->session_arg; ++ pthread_mutex_unlock(&sl->setcallback_lock); ++ ++ if (cb) ++ cb(cb_arg, S_SCALLBACK_REASON_TC_CONNECT, ++ slot_id, connection_id, 0); ++ return; ++ } ++ ++ case T_CALLBACK_REASON_CAMCONNECTIONOPEN: ++ { ++ pthread_mutex_lock(&sl->setcallback_lock); ++ en50221_sl_session_callback cb = sl->session; ++ void *cb_arg = sl->session_arg; ++ pthread_mutex_unlock(&sl->setcallback_lock); ++ ++ if (cb) ++ cb(cb_arg, ++ S_SCALLBACK_REASON_TC_CAMCONNECT, ++ slot_id, connection_id, 0); ++ return; ++ } ++ ++ case T_CALLBACK_REASON_CONNECTIONCLOSE: ++ { ++ pthread_mutex_lock(&sl->setcallback_lock); ++ en50221_sl_session_callback cb = sl->session; ++ void *cb_arg = sl->session_arg; ++ pthread_mutex_unlock(&sl->setcallback_lock); ++ ++ for (i = 0; i < sl->max_sessions; i++) { ++ pthread_mutex_lock(&sl->sessions[i].session_lock); ++ ++ if (sl->sessions[i].state == S_STATE_IDLE) { ++ pthread_mutex_unlock(&sl->sessions[i].session_lock); ++ continue; ++ } ++ if (sl->sessions[i].connection_id != connection_id) { ++ pthread_mutex_unlock(&sl->sessions[i].session_lock); ++ continue; ++ } ++ ++ sl->sessions[i].state = S_STATE_IDLE; ++ ++ uint8_t _slot_id = sl->sessions[i].slot_id; ++ uint32_t resource_id = sl->sessions[i].resource_id; ++ pthread_mutex_unlock(&sl->sessions[i].session_lock); ++ ++ if (cb) ++ cb(cb_arg, S_SCALLBACK_REASON_CLOSE, _slot_id, i, resource_id); ++ } ++ return; ++ } ++ ++ case T_CALLBACK_REASON_SLOTCLOSE: ++ { ++ pthread_mutex_lock(&sl->setcallback_lock); ++ en50221_sl_session_callback cb = sl->session; ++ void *cb_arg = sl->session_arg; ++ pthread_mutex_unlock(&sl->setcallback_lock); ++ ++ for (i = 0; i < sl->max_sessions; i++) { ++ pthread_mutex_lock(&sl->sessions[i].session_lock); ++ ++ if (sl->sessions[i].state == S_STATE_IDLE) { ++ pthread_mutex_unlock(&sl->sessions[i].session_lock); ++ continue; ++ } ++ if (sl->sessions[i].slot_id != slot_id) { ++ pthread_mutex_unlock(&sl->sessions[i].session_lock); ++ continue; ++ } ++ sl->sessions[i].state = S_STATE_IDLE; ++ ++ uint32_t resource_id = sl->sessions[i].resource_id; ++ pthread_mutex_unlock(&sl->sessions[i].session_lock); ++ ++ if (cb) ++ cb(cb_arg, S_SCALLBACK_REASON_CLOSE, slot_id, i, resource_id); ++ ++ } ++ return; ++ } ++ } ++ ++ // sanity check data length ++ if (data_length < 1) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received data with invalid length from module on slot %i\n", ++ slot_id); ++ return; ++ } ++ // deal with the data ++ uint8_t spdu_tag = data[0]; ++ switch (spdu_tag) { ++ case ST_OPEN_SESSION_REQ: ++ en50221_sl_handle_open_session_request(sl, data + 1, ++ data_length - 1, ++ slot_id, ++ connection_id); ++ break; ++ ++ case ST_CLOSE_SESSION_REQ: ++ en50221_sl_handle_close_session_request(sl, data + 1, ++ data_length - 1, ++ slot_id, ++ connection_id); ++ break; ++ ++ case ST_SESSION_NUMBER: ++ en50221_sl_handle_session_package(sl, data + 1, ++ data_length - 1, slot_id, ++ connection_id); ++ break; ++ ++ case ST_CREATE_SESSION_RES: ++ en50221_sl_handle_create_session_response(sl, data + 1, ++ data_length - 1, ++ slot_id, ++ connection_id); ++ break; ++ ++ case ST_CLOSE_SESSION_RES: ++ en50221_sl_handle_close_session_response(sl, data + 1, ++ data_length - 1, ++ slot_id, ++ connection_id); ++ break; ++ ++ default: ++ print(LOG_LEVEL, ERROR, 1, ++ "Received unknown session tag %02x from module on slot %i", ++ spdu_tag, slot_id); ++ break; ++ } ++} ++ ++static int en50221_sl_alloc_new_session(struct en50221_session_layer *sl, ++ uint32_t resource_id, ++ uint8_t slot_id, ++ uint8_t connection_id, ++ en50221_sl_resource_callback ++ callback, void *arg) ++{ ++ int session_number = -1; ++ uint32_t i; ++ for (i = 1; i < sl->max_sessions; i++) { ++ if (sl->sessions[i].state == S_STATE_IDLE) { ++ session_number = i; ++ break; ++ } ++ } ++ if (session_number == -1) { ++ sl->error = EN50221ERR_OUTOFSESSIONS; ++ return -1; ++ } ++ // setup the session ++ sl->sessions[session_number].state = S_STATE_IN_CREATION; ++ sl->sessions[session_number].resource_id = resource_id; ++ sl->sessions[session_number].slot_id = slot_id; ++ sl->sessions[session_number].connection_id = connection_id; ++ sl->sessions[session_number].callback = callback; ++ sl->sessions[session_number].callback_arg = arg; ++ ++ // ok ++ return session_number; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_session.h dvb-apps/lib/libdvben50221/en50221_session.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_session.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_session.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,232 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 session layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian@jusst.de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++ ++#ifndef __EN50221_SESSION_H__ ++#define __EN50221_SESSION_H__ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++ ++#define S_SCALLBACK_REASON_CAMCONNECTING 0x00 // CAM originated session connecting to resource (check for availability) ++#define S_SCALLBACK_REASON_CAMCONNECTED 0x01 // CAM originated session connection established succesfully ++#define S_SCALLBACK_REASON_CAMCONNECTFAIL 0x02 // CAM originated session connection failed ++#define S_SCALLBACK_REASON_CONNECTED 0x03 // Host originated session ACKed by CAM. ++#define S_SCALLBACK_REASON_CONNECTFAIL 0x04 // Host originated session NACKed by CAM. ++#define S_SCALLBACK_REASON_CLOSE 0x05 // Session closed ++#define S_SCALLBACK_REASON_TC_CONNECT 0x06 // A host originated transport connection has been established. ++#define S_SCALLBACK_REASON_TC_CAMCONNECT 0x07 // A CAM originated transport connection has been established. ++ ++ ++/** ++ * Opaque type representing a session layer. ++ */ ++struct en50221_session_layer; ++ ++/** ++ * Type definition for resource callback function - called by session layer when data ++ * arrives for a particular resource. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number. ++ * @param resource_id Resource id. ++ * @param data The data. ++ * @param data_length Length of data in bytes. ++ * @return 0 on success, or -1 on failure. ++ */ ++typedef int (*en50221_sl_resource_callback) (void *arg, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id, ++ uint8_t * data, ++ uint32_t data_length); ++ ++/** ++ * Type definition for resource lookup callback function - used by the session layer to ++ * look up requested resources. ++ * ++ * @param arg Private argument. ++ * @param slot_id Slot id the request came from. ++ * @param requested_resource_id Resource id requested. ++ * @param callback_out Output parameter for pointer to resource callback function. ++ * @param arg_out Output parameter for arg to pass to resource callback. ++ * @param resource_id_out Set this to the resource_id connected to (e.g. may differ from resource_id due to versions). ++ * @return 0 on success, ++ * -1 if the resource was not found, ++ * -2 if it exists, but had a lower version, or ++ * -3 if it exists, but was unavailable. ++ */ ++typedef int (*en50221_sl_lookup_callback) (void *arg, ++ uint8_t slot_id, ++ uint32_t requested_resource_id, ++ en50221_sl_resource_callback * callback_out, ++ void **arg_out, ++ uint32_t *resource_id_out); ++ ++ ++/** ++ * Type definition for session callback function - used to inform top level code when a CAM ++ * modifies a session to a resource. ++ * ++ * @param arg Private argument. ++ * @param reason One of the S_CCALLBACK_REASON_* values above. ++ * @param slot_id Slot id concerned. ++ * @param session_number Session number. ++ * @param resource_id Resource id. ++ * @return 0 on sucess, or -1 on error. ++ */ ++typedef int (*en50221_sl_session_callback) (void *arg, int reason, ++ uint8_t slot_id, ++ uint16_t session_number, ++ uint32_t resource_id); ++ ++/** ++ * Construct a new instance of the session layer. ++ * ++ * @param tl The en50221_transport_layer instance to use. ++ * @param max_sessions Maximum number of sessions supported. ++ * @return The en50221_session_layer instance, or NULL on error. ++ */ ++extern struct en50221_session_layer *en50221_sl_create(struct en50221_transport_layer *tl, ++ uint32_t max_sessions); ++ ++/** ++ * Destroy an instance of the session layer. ++ * ++ * @param tl The en50221_session_layer instance. ++ */ ++extern void en50221_sl_destroy(struct en50221_session_layer *sl); ++ ++/** ++ * Gets the last error. ++ * ++ * @param tl The en50221_session_layer instance. ++ * @return One of the EN50221ERR_* values. ++ */ ++extern int en50221_sl_get_error(struct en50221_session_layer *tl); ++ ++/** ++ * Register the callback for resource lookup. ++ * ++ * @param sl The en50221_session_layer instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_sl_register_lookup_callback(struct en50221_session_layer *sl, ++ en50221_sl_lookup_callback callback, ++ void *arg); ++ ++/** ++ * Register the callback for informing about session from a cam. ++ * ++ * @param sl The en50221_session_layer instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_sl_register_session_callback(struct en50221_session_layer *sl, ++ en50221_sl_session_callback callback, ++ void *arg); ++ ++/** ++ * Create a new session to a module in a slot. ++ * ++ * @param sl The en50221_session_layer instance. ++ * @param slot The slot to connect to. ++ * @param resource_id The resource_id to connect to. ++ * @param callback The callback for received data. ++ * @param arg Argument to pass to the callback. ++ * @return The new session_number, or -1 on error. ++ */ ++extern int en50221_sl_create_session(struct en50221_session_layer *sl, int slot_id, ++ uint8_t connection_id, ++ uint32_t resource_id, ++ en50221_sl_resource_callback callback, ++ void *arg); ++ ++/** ++ * Destroy a session. ++ * ++ * @param sl The en50221_session_layer instance. ++ * @param session_number The session to destroy. ++ * @return 0 on success, or -1 on error. ++ */ ++extern int en50221_sl_destroy_session(struct en50221_session_layer *sl, ++ uint16_t session_number); ++ ++/** ++ * this function is used to take a data-block, pack into ++ * into a SPDU (SESSION_NUMBER) and send it to the transport layer ++ * ++ * @param sl The en50221_session_layer instance to use. ++ * @param session_number Session number concerned. ++ * @param data Data to send. ++ * @param data_length Length of data in bytes. ++ * @return 0 on success, or -1 on error. ++ */ ++extern int en50221_sl_send_data(struct en50221_session_layer *sl, ++ uint16_t session_number, ++ uint8_t * data, ++ uint16_t data_length); ++ ++/** ++ * this function is used to take a data-block, pack into ++ * into a SPDU (SESSION_NUMBER) and send it to the transport layer ++ * ++ * @param sl The en50221_session_layer instance to use. ++ * @param session_number Session number concerned. ++ * @param vector IOVEC to send. ++ * @param iov_count Number of elements in io vector. ++ * @return 0 on success, or -1 on error. ++ */ ++extern int en50221_sl_send_datav(struct en50221_session_layer *sl, ++ uint16_t session_number, ++ struct iovec *vector, ++ int iov_count); ++ ++/** ++ * this is used to send a message to all sessions, linked ++ * to resource res ++ * ++ * @param tl The en50221_session_layer instance to use. ++ * @param slot_id Set to -1 to send to any slot. Other values will send to only that slot. ++ * @param resource_id Resource id concerned. ++ * @param data Data to send. ++ * @param data_length Length of data in bytes. ++ * @return 0 on success, or -1 on error. ++ */ ++extern int en50221_sl_broadcast_data(struct en50221_session_layer *sl, ++ int slot_id, ++ uint32_t resource_id, ++ uint8_t * data, ++ uint16_t data_length); ++ ++#ifdef __cplusplus ++} ++#endif ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_stdcam.c dvb-apps/lib/libdvben50221/en50221_stdcam.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_stdcam.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_stdcam.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,54 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "en50221_stdcam.h" ++ ++struct en50221_stdcam *en50221_stdcam_create(int adapter, int slotnum, ++ struct en50221_transport_layer *tl, ++ struct en50221_session_layer *sl) ++{ ++ struct en50221_stdcam *result = NULL; ++ ++ int cafd = dvbca_open(adapter, 0); ++ if (cafd == -1) ++ return NULL; ++ ++ int ca_type = dvbca_get_interface_type(cafd, slotnum); ++ switch(ca_type) { ++ case DVBCA_INTERFACE_LINK: ++ result = en50221_stdcam_llci_create(cafd, slotnum, tl, sl); ++ break; ++ ++ case DVBCA_INTERFACE_HLCI: ++ result = en50221_stdcam_hlci_create(cafd, slotnum); ++ break; ++ } ++ ++ if (result == NULL) ++ close(cafd); ++ return result; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_stdcam.h dvb-apps/lib/libdvben50221/en50221_stdcam.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_stdcam.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_stdcam.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,102 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#ifndef EN50221_STDCAM_H ++#define EN50221_STDCAM_H 1 ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++#include ++#include ++ ++enum en50221_stdcam_status { ++ EN50221_STDCAM_CAM_NONE, ++ EN50221_STDCAM_CAM_INRESET, ++ EN50221_STDCAM_CAM_OK, ++ EN50221_STDCAM_CAM_BAD, ++}; ++ ++struct en50221_stdcam { ++ /* one of more of the following may be NULL if a CAM does not support it */ ++ struct en50221_app_ai *ai_resource; ++ struct en50221_app_ca *ca_resource; ++ struct en50221_app_mmi *mmi_resource; ++ ++ /* if any of these are -1, no connection is in place to this resource yet */ ++ int ai_session_number; ++ int ca_session_number; ++ int mmi_session_number; ++ ++ /* poll the stdcam instance */ ++ enum en50221_stdcam_status (*poll)(struct en50221_stdcam *stdcam); ++ ++ /* inform the stdcam of the current DVB time */ ++ void (*dvbtime)(struct en50221_stdcam *stdcam, time_t dvbtime); ++ ++ /* destroy the stdcam instance */ ++ void (*destroy)(struct en50221_stdcam *stdcam, int closefd); ++}; ++ ++/** ++ * Create an instance of the STDCAM for an LLCI interface. ++ * ++ * @param cafd FD of the CA device. ++ * @param slotnum Slotnum on that CA device. ++ * @param tl Transport layer instance to use. ++ * @param sl Session layer instance to use. ++ * @return en50221_stdcam instance, or NULL on error. ++ */ ++extern struct en50221_stdcam *en50221_stdcam_llci_create(int cafd, int slotnum, ++ struct en50221_transport_layer *tl, ++ struct en50221_session_layer *sl); ++ ++/** ++ * Create an instance of the STDCAM for an HLCI interface. ++ * ++ * @param cafd FD of the CA device. ++ * @param slotnum Slotnum on that CA device. ++ * @return en50221_stdcam instance, or NULL on error. ++ */ ++extern struct en50221_stdcam *en50221_stdcam_hlci_create(int cafd, int slotnum); ++ ++/** ++ * Convenience method to create a STDCAM interface for a ca device on a particular adapter. ++ * ++ * @param adapter The DVB adapter concerned. ++ * @param slotnum The ca slot number on that adapter. ++ * @param tl Transport layer instance to use (unused for HLCI cams). ++ * @param sl Session layer instance to use (unused for HLCI cams). ++ * @return en50221_stdcam instance, or NULL on error. ++ */ ++extern struct en50221_stdcam *en50221_stdcam_create(int adapter, int slotnum, ++ struct en50221_transport_layer *tl, ++ struct en50221_session_layer *sl); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_stdcam_hlci.c dvb-apps/lib/libdvben50221/en50221_stdcam_hlci.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_stdcam_hlci.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_stdcam_hlci.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,216 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "en50221_app_utils.h" ++#include "en50221_app_tags.h" ++#include "en50221_stdcam.h" ++ ++ ++struct en50221_stdcam_hlci { ++ struct en50221_stdcam stdcam; ++ ++ int cafd; ++ int slotnum; ++ int initialised; ++ struct en50221_app_send_functions sendfuncs; ++}; ++ ++static void en50221_stdcam_hlci_destroy(struct en50221_stdcam *stdcam, int closefd); ++static enum en50221_stdcam_status en50221_stdcam_hlci_poll(struct en50221_stdcam *stdcam); ++static int hlci_cam_added(struct en50221_stdcam_hlci *hlci); ++static int hlci_send_data(void *arg, uint16_t session_number, ++ uint8_t * data, uint16_t data_length); ++static int hlci_send_datav(void *arg, uint16_t session_number, ++ struct iovec *vector, int iov_count); ++ ++ ++ ++ ++struct en50221_stdcam *en50221_stdcam_hlci_create(int cafd, int slotnum) ++{ ++ // try and allocate space for the HLCI stdcam ++ struct en50221_stdcam_hlci *hlci = ++ malloc(sizeof(struct en50221_stdcam_hlci)); ++ if (hlci == NULL) { ++ return NULL; ++ } ++ memset(hlci, 0, sizeof(struct en50221_stdcam_hlci)); ++ ++ // create the sendfuncs ++ hlci->sendfuncs.arg = hlci; ++ hlci->sendfuncs.send_data = hlci_send_data; ++ hlci->sendfuncs.send_datav = hlci_send_datav; ++ ++ // create the resources (NOTE: we just use fake session numbers here) ++ hlci->stdcam.ai_resource = en50221_app_ai_create(&hlci->sendfuncs); ++ hlci->stdcam.ai_session_number = 0; ++ hlci->stdcam.ca_resource = en50221_app_ca_create(&hlci->sendfuncs); ++ hlci->stdcam.ca_session_number = 1; ++// hlci->stdcam.mmi_resource = en50221_app_mmi_create(&hlci->sendfuncs); ++ hlci->stdcam.mmi_session_number = -1; ++ ++ // done ++ hlci->stdcam.destroy = en50221_stdcam_hlci_destroy; ++ hlci->stdcam.poll = en50221_stdcam_hlci_poll; ++ hlci->slotnum = slotnum; ++ hlci->cafd = cafd; ++ return &hlci->stdcam; ++} ++ ++static void en50221_stdcam_hlci_destroy(struct en50221_stdcam *stdcam, int closefd) ++{ ++ struct en50221_stdcam_hlci *hlci = (struct en50221_stdcam_hlci *) stdcam; ++ ++ if (hlci->stdcam.ai_resource) ++ en50221_app_ai_destroy(hlci->stdcam.ai_resource); ++ if (hlci->stdcam.ca_resource) ++ en50221_app_ca_destroy(hlci->stdcam.ca_resource); ++ if (hlci->stdcam.mmi_resource) ++ en50221_app_mmi_destroy(hlci->stdcam.mmi_resource); ++ ++ if (closefd) ++ close(hlci->cafd); ++ ++ free(hlci); ++} ++ ++static enum en50221_stdcam_status en50221_stdcam_hlci_poll(struct en50221_stdcam *stdcam) ++{ ++ struct en50221_stdcam_hlci *hlci = (struct en50221_stdcam_hlci *) stdcam; ++ ++ switch(dvbca_get_cam_state(hlci->cafd, hlci->slotnum)) { ++ case DVBCA_CAMSTATE_MISSING: ++ hlci->initialised = 0; ++ break; ++ ++ case DVBCA_CAMSTATE_READY: ++ case DVBCA_CAMSTATE_INITIALISING: ++ if (!hlci->initialised) ++ hlci_cam_added(hlci); ++ break; ++ } ++ ++ // delay to prevent busy loop ++ usleep(10); ++ ++ if (!hlci->initialised) { ++ return EN50221_STDCAM_CAM_NONE; ++ } ++ return EN50221_STDCAM_CAM_OK; ++} ++ ++ ++ ++static int hlci_cam_added(struct en50221_stdcam_hlci *hlci) ++{ ++ uint8_t buf[256]; ++ int size; ++ ++ // get application information ++ if (en50221_app_ai_enquiry(hlci->stdcam.ai_resource, 0)) { ++ return -EIO; ++ } ++ if ((size = dvbca_hlci_read(hlci->cafd, TAG_APP_INFO, buf, sizeof(buf))) < 0) { ++ return size; ++ } ++ if (en50221_app_ai_message(hlci->stdcam.ai_resource, 0, 0, EN50221_APP_AI_RESOURCEID, buf, size)) { ++ return -EIO; ++ } ++ ++ // we forge a fake CA_INFO here so the main app works - since it will expect a CA_INFO ++ // this will be replaced with a proper call (below) when the driver support is there ++ buf[0] = TAG_CA_INFO >> 16; ++ buf[1] = (uint8_t) (TAG_CA_INFO >> 8); ++ buf[2] = (uint8_t) TAG_CA_INFO; ++ buf[3] = 0; ++ if (en50221_app_ca_message(hlci->stdcam.ca_resource, 0, 0, EN50221_APP_CA_RESOURCEID, buf, 4)) { ++ return -EIO; ++ } ++ ++ /* ++ // get CA information ++ if (en50221_app_ca_info_enq(ca_resource, 0)) { ++ fprintf(stderr, "Failed to send CA INFO enquiry\n"); ++ cafd = -1; ++ return -1; ++ } ++ if ((size = dvbca_hlci_read(cafd, TAG_CA_INFO, buf, sizeof(buf))) < 0) { ++ fprintf(stderr, "Failed to read CA INFO\n"); ++ cafd = -1; ++ return -1; ++ } ++ if (en50221_app_ca_message(ca_resource, 0, 0, EN50221_APP_CA_RESOURCEID, buf, size)) { ++ fprintf(stderr, "Failed to parse CA INFO\n"); ++ cafd = -1; ++ return -1; ++ } ++ */ ++ ++ // done ++ hlci->initialised = 1; ++ return 0; ++} ++ ++static int hlci_send_data(void *arg, uint16_t session_number, ++ uint8_t * data, uint16_t data_length) ++{ ++ (void) session_number; ++ struct en50221_stdcam_hlci *hlci = arg; ++ ++ return dvbca_hlci_write(hlci->cafd, data, data_length); ++} ++ ++static int hlci_send_datav(void *arg, uint16_t session_number, ++ struct iovec *vector, int iov_count) ++{ ++ (void) session_number; ++ struct en50221_stdcam_hlci *hlci = arg; ++ ++ // calculate the total length of the data to send ++ uint32_t data_size = 0; ++ int i; ++ for (i = 0; i < iov_count; i++) { ++ data_size += vector[i].iov_len; ++ } ++ ++ // allocate memory for it ++ uint8_t *buf = malloc(data_size); ++ if (buf == NULL) { ++ return -1; ++ } ++ // merge the iovecs ++ uint32_t pos = 0; ++ for (i = 0; i < iov_count; i++) { ++ memcpy(buf + pos, vector[i].iov_base, vector[i].iov_len); ++ pos += vector[i].iov_len; ++ } ++ ++ // sendit and cleanup ++ int status = dvbca_hlci_write(hlci->cafd, buf, data_size); ++ free(buf); ++ return status; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_stdcam_llci.c dvb-apps/lib/libdvben50221/en50221_stdcam_llci.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_stdcam_llci.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_stdcam_llci.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,437 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "en50221_app_rm.h" ++#include "en50221_app_datetime.h" ++#include "en50221_app_utils.h" ++#include "en50221_app_tags.h" ++#include "en50221_stdcam.h" ++ ++#define LLCI_RESPONSE_TIMEOUT_MS 1000 ++#define LLCI_POLL_DELAY_MS 100 ++ ++/* resource IDs we support */ ++static uint32_t resource_ids[] = ++{ EN50221_APP_RM_RESOURCEID, ++ EN50221_APP_CA_RESOURCEID, ++ EN50221_APP_AI_RESOURCEID, ++ EN50221_APP_MMI_RESOURCEID, ++ EN50221_APP_DATETIME_RESOURCEID, ++}; ++#define RESOURCE_IDS_COUNT sizeof(resource_ids)/4 ++ ++struct llci_resource { ++ struct en50221_app_public_resource_id resid; ++ uint32_t binary_resource_id; ++ en50221_sl_resource_callback callback; ++ void *arg; ++}; ++ ++struct en50221_stdcam_llci { ++ struct en50221_stdcam stdcam; ++ ++ int cafd; ++ int slotnum; ++ int state; ++ ++ struct llci_resource resources[RESOURCE_IDS_COUNT]; ++ ++ struct en50221_transport_layer *tl; ++ struct en50221_session_layer *sl; ++ struct en50221_app_send_functions sendfuncs; ++ int tl_slot_id; ++ ++ struct en50221_app_rm *rm_resource; ++ ++ struct en50221_app_datetime *datetime_resource; ++ int datetime_session_number; ++ uint8_t datetime_response_interval; ++ time_t datetime_next_send; ++ time_t datetime_dvbtime; ++}; ++ ++static enum en50221_stdcam_status en50221_stdcam_llci_poll(struct en50221_stdcam *stdcam); ++static void en50221_stdcam_llci_dvbtime(struct en50221_stdcam *stdcam, time_t dvbtime); ++static void en50221_stdcam_llci_destroy(struct en50221_stdcam *stdcam, int closefd); ++static void llci_cam_added(struct en50221_stdcam_llci *llci); ++static void llci_cam_in_reset(struct en50221_stdcam_llci *llci); ++static void llci_cam_removed(struct en50221_stdcam_llci *llci); ++ ++ ++static int llci_lookup_callback(void *arg, uint8_t _slot_id, uint32_t requested_resource_id, ++ en50221_sl_resource_callback *callback_out, void **arg_out, ++ uint32_t *connected_resource_id); ++static int llci_session_callback(void *arg, int reason, uint8_t _slot_id, uint16_t session_number, uint32_t resource_id); ++static int llci_rm_enq_callback(void *arg, uint8_t _slot_id, uint16_t session_number); ++static int llci_rm_reply_callback(void *arg, uint8_t _slot_id, uint16_t session_number, uint32_t resource_id_count, uint32_t *_resource_ids); ++static int llci_rm_changed_callback(void *arg, uint8_t _slot_id, uint16_t session_number); ++ ++static int llci_datetime_enquiry_callback(void *arg, uint8_t _slot_id, uint16_t session_number, uint8_t response_interval); ++ ++ ++struct en50221_stdcam *en50221_stdcam_llci_create(int cafd, int slotnum, ++ struct en50221_transport_layer *tl, ++ struct en50221_session_layer *sl) ++{ ++ // try and allocate space for the LLCI stdcam ++ struct en50221_stdcam_llci *llci = ++ malloc(sizeof(struct en50221_stdcam_llci)); ++ if (llci == NULL) { ++ return NULL; ++ } ++ memset(llci, 0, sizeof(struct en50221_stdcam_llci)); ++ ++ // create the sendfuncs ++ llci->sendfuncs.arg = sl; ++ llci->sendfuncs.send_data = (en50221_send_data) en50221_sl_send_data; ++ llci->sendfuncs.send_datav = (en50221_send_datav) en50221_sl_send_datav; ++ ++ // create the resource manager resource ++ int resource_idx = 0; ++ llci->rm_resource = en50221_app_rm_create(&llci->sendfuncs); ++ en50221_app_decode_public_resource_id(&llci->resources[resource_idx].resid, EN50221_APP_RM_RESOURCEID); ++ llci->resources[resource_idx].binary_resource_id = EN50221_APP_RM_RESOURCEID; ++ llci->resources[resource_idx].callback = (en50221_sl_resource_callback) en50221_app_rm_message; ++ llci->resources[resource_idx].arg = llci->rm_resource; ++ en50221_app_rm_register_enq_callback(llci->rm_resource, llci_rm_enq_callback, llci); ++ en50221_app_rm_register_reply_callback(llci->rm_resource, llci_rm_reply_callback, llci); ++ en50221_app_rm_register_changed_callback(llci->rm_resource, llci_rm_changed_callback, llci); ++ resource_idx++; ++ ++ // create the datetime resource ++ llci->datetime_resource = en50221_app_datetime_create(&llci->sendfuncs); ++ en50221_app_decode_public_resource_id(&llci->resources[resource_idx].resid, EN50221_APP_DATETIME_RESOURCEID); ++ llci->resources[resource_idx].binary_resource_id = EN50221_APP_DATETIME_RESOURCEID; ++ llci->resources[resource_idx].callback = (en50221_sl_resource_callback) en50221_app_datetime_message; ++ llci->resources[resource_idx].arg = llci->datetime_resource; ++ en50221_app_datetime_register_enquiry_callback(llci->datetime_resource, llci_datetime_enquiry_callback, llci); ++ resource_idx++; ++ llci->datetime_session_number = -1; ++ llci->datetime_response_interval = 0; ++ llci->datetime_next_send = 0; ++ llci->datetime_dvbtime = 0; ++ ++ // create the application information resource ++ llci->stdcam.ai_resource = en50221_app_ai_create(&llci->sendfuncs); ++ en50221_app_decode_public_resource_id(&llci->resources[resource_idx].resid, EN50221_APP_AI_RESOURCEID); ++ llci->resources[resource_idx].binary_resource_id = EN50221_APP_AI_RESOURCEID; ++ llci->resources[resource_idx].callback = (en50221_sl_resource_callback) en50221_app_ai_message; ++ llci->resources[resource_idx].arg = llci->stdcam.ai_resource; ++ llci->stdcam.ai_session_number = -1; ++ resource_idx++; ++ ++ // create the CA resource ++ llci->stdcam.ca_resource = en50221_app_ca_create(&llci->sendfuncs); ++ en50221_app_decode_public_resource_id(&llci->resources[resource_idx].resid, EN50221_APP_CA_RESOURCEID); ++ llci->resources[resource_idx].binary_resource_id = EN50221_APP_CA_RESOURCEID; ++ llci->resources[resource_idx].callback = (en50221_sl_resource_callback) en50221_app_ca_message; ++ llci->resources[resource_idx].arg = llci->stdcam.ca_resource; ++ llci->stdcam.ca_session_number = -1; ++ resource_idx++; ++ ++ // create the MMI resource ++ llci->stdcam.mmi_resource = en50221_app_mmi_create(&llci->sendfuncs); ++ en50221_app_decode_public_resource_id(&llci->resources[resource_idx].resid, EN50221_APP_MMI_RESOURCEID); ++ llci->resources[resource_idx].binary_resource_id = EN50221_APP_MMI_RESOURCEID; ++ llci->resources[resource_idx].callback = (en50221_sl_resource_callback) en50221_app_mmi_message; ++ llci->resources[resource_idx].arg = llci->stdcam.mmi_resource; ++ llci->stdcam.mmi_session_number = -1; ++ resource_idx++; ++ ++ // register session layer callbacks ++ en50221_sl_register_lookup_callback(sl, llci_lookup_callback, llci); ++ en50221_sl_register_session_callback(sl, llci_session_callback, llci); ++ ++ // done ++ llci->stdcam.destroy = en50221_stdcam_llci_destroy; ++ llci->stdcam.poll = en50221_stdcam_llci_poll; ++ llci->stdcam.dvbtime = en50221_stdcam_llci_dvbtime; ++ llci->cafd = cafd; ++ llci->slotnum = slotnum; ++ llci->tl = tl; ++ llci->sl = sl; ++ llci->tl_slot_id = -1; ++ llci->state = EN50221_STDCAM_CAM_NONE; ++ return &llci->stdcam; ++} ++ ++static void en50221_stdcam_llci_dvbtime(struct en50221_stdcam *stdcam, time_t dvbtime) ++{ ++ struct en50221_stdcam_llci *llci = (struct en50221_stdcam_llci *) stdcam; ++ ++ llci->datetime_dvbtime = dvbtime; ++} ++ ++static void en50221_stdcam_llci_destroy(struct en50221_stdcam *stdcam, int closefd) ++{ ++ struct en50221_stdcam_llci *llci = (struct en50221_stdcam_llci *) stdcam; ++ ++ // "remove" the cam ++ llci_cam_removed(llci); ++ ++ // destroy resources ++ if (llci->rm_resource) ++ en50221_app_rm_destroy(llci->rm_resource); ++ if (llci->datetime_resource) ++ en50221_app_datetime_destroy(llci->datetime_resource); ++ if (llci->stdcam.ai_resource) ++ en50221_app_ai_destroy(llci->stdcam.ai_resource); ++ if (llci->stdcam.ca_resource) ++ en50221_app_ca_destroy(llci->stdcam.ca_resource); ++ if (llci->stdcam.mmi_resource) ++ en50221_app_mmi_destroy(llci->stdcam.mmi_resource); ++ ++ if (closefd) ++ close(llci->cafd); ++ ++ free(llci); ++} ++ ++ ++ ++ ++static enum en50221_stdcam_status en50221_stdcam_llci_poll(struct en50221_stdcam *stdcam) ++{ ++ struct en50221_stdcam_llci *llci = (struct en50221_stdcam_llci *) stdcam; ++ ++ switch(dvbca_get_cam_state(llci->cafd, llci->slotnum)) { ++ case DVBCA_CAMSTATE_MISSING: ++ if (llci->state != EN50221_STDCAM_CAM_NONE) ++ llci_cam_removed(llci); ++ break; ++ ++ case DVBCA_CAMSTATE_READY: ++ if (llci->state == EN50221_STDCAM_CAM_NONE) ++ llci_cam_added(llci); ++ else if (llci->state == EN50221_STDCAM_CAM_INRESET) ++ llci_cam_in_reset(llci); ++ break; ++ } ++ ++ // poll the stack ++ int error; ++ if ((error = en50221_tl_poll(llci->tl)) != 0) { ++ print(LOG_LEVEL, ERROR, 1, "Error reported by stack:%i\n", en50221_tl_get_error(llci->tl)); ++ } ++ ++ // send date/time response ++ if (llci->datetime_session_number != -1) { ++ time_t cur_time = time(NULL); ++ if (llci->datetime_response_interval && (cur_time > llci->datetime_next_send)) { ++ en50221_app_datetime_send(llci->datetime_resource, ++ llci->datetime_session_number, ++ llci->datetime_dvbtime, 0); ++ llci->datetime_next_send = cur_time + llci->datetime_response_interval; ++ } ++ } ++ ++ return llci->state; ++} ++ ++static void llci_cam_added(struct en50221_stdcam_llci *llci) ++{ ++ // clear down any old structures ++ if (llci->tl_slot_id != -1) { ++ llci_cam_removed(llci); ++ } ++ ++ // reset the CAM ++ dvbca_reset(llci->cafd, llci->slotnum); ++ llci->state = EN50221_STDCAM_CAM_INRESET; ++} ++ ++static void llci_cam_in_reset(struct en50221_stdcam_llci *llci) ++{ ++ if (dvbca_get_cam_state(llci->cafd, llci->slotnum) != DVBCA_CAMSTATE_READY) { ++ return; ++ } ++ ++ // register the slot ++ if ((llci->tl_slot_id = en50221_tl_register_slot(llci->tl, llci->cafd, llci->slotnum, ++ LLCI_RESPONSE_TIMEOUT_MS, LLCI_POLL_DELAY_MS)) < 0) { ++ llci->state = EN50221_STDCAM_CAM_BAD; ++ return; ++ } ++ ++ // create a new connection on the slot ++ if (en50221_tl_new_tc(llci->tl, llci->tl_slot_id) < 0) { ++ llci->state = EN50221_STDCAM_CAM_BAD; ++ llci->tl_slot_id = -1; ++ en50221_tl_destroy_slot(llci->tl, llci->tl_slot_id); ++ return; ++ } ++ ++ llci->state = EN50221_STDCAM_CAM_OK; ++} ++ ++static void llci_cam_removed(struct en50221_stdcam_llci *llci) ++{ ++ if (llci->tl_slot_id != -1) { ++ en50221_tl_destroy_slot(llci->tl, llci->tl_slot_id); ++ llci->tl_slot_id = -1; ++ llci->datetime_session_number = -1; ++ llci->stdcam.ai_session_number = -1; ++ llci->stdcam.ca_session_number = -1; ++ llci->stdcam.mmi_session_number = -1; ++ } ++ llci->state = EN50221_STDCAM_CAM_NONE; ++} ++ ++ ++ ++static int llci_lookup_callback(void *arg, uint8_t _slot_id, uint32_t requested_resource_id, ++ en50221_sl_resource_callback *callback_out, void **arg_out, ++ uint32_t *connected_resource_id) ++{ ++ struct en50221_app_public_resource_id resid; ++ struct en50221_stdcam_llci *llci = (struct en50221_stdcam_llci *) arg; ++ (void) _slot_id; ++ ++ // decode the resource id ++ if (!en50221_app_decode_public_resource_id(&resid, requested_resource_id)) { ++ return -1; ++ } ++ ++ // try and find an instance of the resource ++ uint32_t i; ++ for(i=0; iresources[i].resid.resource_class) && ++ (resid.resource_type == llci->resources[i].resid.resource_type)) { ++ ++ // limit sessions to certain resources ++ switch(requested_resource_id) { ++ case EN50221_APP_DATETIME_RESOURCEID: ++ if (llci->datetime_session_number != -1) ++ return -3; ++ break; ++ case EN50221_APP_AI_RESOURCEID: ++ if (llci->stdcam.ai_session_number != -1) ++ return -3; ++ break; ++ case EN50221_APP_CA_RESOURCEID: ++ if (llci->stdcam.ca_session_number != -1) ++ return -3; ++ break; ++ case EN50221_APP_MMI_RESOURCEID: ++ if (llci->stdcam.mmi_session_number != -1) ++ return -3; ++ break; ++ } ++ ++ // resource is ok. ++ *callback_out = llci->resources[i].callback; ++ *arg_out = llci->resources[i].arg; ++ *connected_resource_id = llci->resources[i].binary_resource_id; ++ return 0; ++ } ++ } ++ ++ return -1; ++} ++ ++static int llci_session_callback(void *arg, int reason, uint8_t _slot_id, uint16_t session_number, uint32_t resource_id) ++{ ++ struct en50221_stdcam_llci *llci = (struct en50221_stdcam_llci *) arg; ++ (void) _slot_id; ++ ++ switch(reason) { ++ case S_SCALLBACK_REASON_CAMCONNECTED: ++ if (resource_id == EN50221_APP_RM_RESOURCEID) { ++ en50221_app_rm_enq(llci->rm_resource, session_number); ++ } else if (resource_id == EN50221_APP_DATETIME_RESOURCEID) { ++ llci->datetime_session_number = session_number; ++ } else if (resource_id == EN50221_APP_AI_RESOURCEID) { ++ en50221_app_ai_enquiry(llci->stdcam.ai_resource, session_number); ++ llci->stdcam.ai_session_number = session_number; ++ } else if (resource_id == EN50221_APP_CA_RESOURCEID) { ++ en50221_app_ca_info_enq(llci->stdcam.ca_resource, session_number); ++ llci->stdcam.ca_session_number = session_number; ++ } else if (resource_id == EN50221_APP_MMI_RESOURCEID) { ++ llci->stdcam.mmi_session_number = session_number; ++ } ++ ++ break; ++ case S_SCALLBACK_REASON_CLOSE: ++ if (resource_id == EN50221_APP_MMI_RESOURCEID) { ++ llci->stdcam.mmi_session_number = -1; ++ } ++ ++ break; ++ } ++ return 0; ++} ++ ++static int llci_rm_enq_callback(void *arg, uint8_t _slot_id, uint16_t session_number) ++{ ++ struct en50221_stdcam_llci *llci = (struct en50221_stdcam_llci *) arg; ++ (void) _slot_id; ++ ++ if (en50221_app_rm_reply(llci->rm_resource, session_number, RESOURCE_IDS_COUNT, resource_ids)) { ++ print(LOG_LEVEL, ERROR, 1, "Failed to send RM ENQ on slot %02x\n", _slot_id); ++ } ++ return 0; ++} ++ ++static int llci_rm_reply_callback(void *arg, uint8_t _slot_id, uint16_t session_number, uint32_t resource_id_count, uint32_t *_resource_ids) ++{ ++ struct en50221_stdcam_llci *llci = (struct en50221_stdcam_llci *) arg; ++ (void) _slot_id; ++ (void) resource_id_count; ++ (void) _resource_ids; ++ ++ if (en50221_app_rm_changed(llci->rm_resource, session_number)) { ++ print(LOG_LEVEL, ERROR, 1, "Failed to send RM REPLY on slot %02x\n", _slot_id); ++ } ++ return 0; ++} ++ ++static int llci_rm_changed_callback(void *arg, uint8_t _slot_id, uint16_t session_number) ++{ ++ struct en50221_stdcam_llci *llci = (struct en50221_stdcam_llci *) arg; ++ (void) _slot_id; ++ ++ if (en50221_app_rm_enq(llci->rm_resource, session_number)) { ++ print(LOG_LEVEL, ERROR, 1, "Failed to send RM CHANGED on slot %02x\n", _slot_id); ++ } ++ return 0; ++} ++ ++static int llci_datetime_enquiry_callback(void *arg, uint8_t _slot_id, uint16_t session_number, uint8_t response_interval) ++{ ++ struct en50221_stdcam_llci *llci = (struct en50221_stdcam_llci *) arg; ++ (void) _slot_id; ++ ++ llci->datetime_response_interval = response_interval; ++ llci->datetime_next_send = 0; ++ if (response_interval) { ++ llci->datetime_next_send = time(NULL) + response_interval; ++ } ++ en50221_app_datetime_send(llci->datetime_resource, session_number, llci->datetime_dvbtime, 0); ++ ++ return 0; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_transport.c dvb-apps/lib/libdvben50221/en50221_transport.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_transport.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_transport.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,1296 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "en50221_errno.h" ++#include "en50221_transport.h" ++#include "asn_1.h" ++ ++// these are the Transport Tags, like ++// described in EN50221, Annex A.4.1.13 (pg70) ++#define T_SB 0x80 // sb primitive h<--m ++#define T_RCV 0x81 // receive primitive h-->m ++#define T_CREATE_T_C 0x82 // create transport connection primitive h-->m ++#define T_C_T_C_REPLY 0x83 // ctc reply primitive h<--m ++#define T_DELETE_T_C 0x84 // delete tc primitive h<->m ++#define T_D_T_C_REPLY 0x85 // dtc reply primitive h<->m ++#define T_REQUEST_T_C 0x86 // request transport connection primitive h<--m ++#define T_NEW_T_C 0x87 // new tc / reply to t_request primitive h-->m ++#define T_T_C_ERROR 0x77 // error creating tc primitive h-->m ++#define T_DATA_LAST 0xA0 // convey data from higher constructed h<->m ++ // layers ++#define T_DATA_MORE 0xA1 // convey data from higher constructed h<->m ++ // layers ++ ++struct en50221_message { ++ struct en50221_message *next; ++ uint32_t length; ++ uint8_t data[0]; ++}; ++ ++struct en50221_connection { ++ uint32_t state; // the current state: idle/in_delete/in_create/active ++ struct timeval tx_time; // time last request was sent from host->module, or 0 if ok ++ struct timeval last_poll_time; // time of last poll transmission ++ uint8_t *chain_buffer; // used to save parts of chained packets ++ uint32_t buffer_length; ++ ++ struct en50221_message *send_queue; ++ struct en50221_message *send_queue_tail; ++}; ++ ++struct en50221_slot { ++ int ca_hndl; ++ uint8_t slot; // CAM slot ++ struct en50221_connection *connections; ++ ++ pthread_mutex_t slot_lock; ++ ++ uint32_t response_timeout; ++ uint32_t poll_delay; ++}; ++ ++struct en50221_transport_layer { ++ uint8_t max_slots; ++ uint8_t max_connections_per_slot; ++ struct en50221_slot *slots; ++ struct pollfd *slot_pollfds; ++ int slots_changed; ++ ++ pthread_mutex_t global_lock; ++ pthread_mutex_t setcallback_lock; ++ ++ int error; ++ int error_slot; ++ ++ en50221_tl_callback callback; ++ void *callback_arg; ++}; ++ ++static int en50221_tl_process_data(struct en50221_transport_layer *tl, ++ uint8_t slot_id, uint8_t * data, ++ uint32_t data_length); ++static int en50221_tl_poll_tc(struct en50221_transport_layer *tl, ++ uint8_t slot_id, uint8_t connection_id); ++static int en50221_tl_alloc_new_tc(struct en50221_transport_layer *tl, ++ uint8_t slot_id); ++static void queue_message(struct en50221_transport_layer *tl, ++ uint8_t slot_id, uint8_t connection_id, ++ struct en50221_message *msg); ++static int en50221_tl_handle_create_tc_reply(struct en50221_transport_layer ++ *tl, uint8_t slot_id, ++ uint8_t connection_id); ++static int en50221_tl_handle_delete_tc(struct en50221_transport_layer *tl, ++ uint8_t slot_id, ++ uint8_t connection_id); ++static int en50221_tl_handle_delete_tc_reply(struct en50221_transport_layer ++ *tl, uint8_t slot_id, ++ uint8_t connection_id); ++static int en50221_tl_handle_request_tc(struct en50221_transport_layer *tl, ++ uint8_t slot_id, ++ uint8_t connection_id); ++static int en50221_tl_handle_data_more(struct en50221_transport_layer *tl, ++ uint8_t slot_id, ++ uint8_t connection_id, ++ uint8_t * data, ++ uint32_t data_length); ++static int en50221_tl_handle_data_last(struct en50221_transport_layer *tl, ++ uint8_t slot_id, ++ uint8_t connection_id, ++ uint8_t * data, ++ uint32_t data_length); ++static int en50221_tl_handle_sb(struct en50221_transport_layer *tl, ++ uint8_t slot_id, uint8_t connection_id, ++ uint8_t * data, uint32_t data_length); ++ ++ ++struct en50221_transport_layer *en50221_tl_create(uint8_t max_slots, ++ uint8_t ++ max_connections_per_slot) ++{ ++ struct en50221_transport_layer *tl = NULL; ++ int i; ++ int j; ++ ++ // setup structure ++ tl = (struct en50221_transport_layer *) ++ malloc(sizeof(struct en50221_transport_layer)); ++ if (tl == NULL) ++ goto error_exit; ++ tl->max_slots = max_slots; ++ tl->max_connections_per_slot = max_connections_per_slot; ++ tl->slots = NULL; ++ tl->slot_pollfds = NULL; ++ tl->slots_changed = 1; ++ tl->callback = NULL; ++ tl->callback_arg = NULL; ++ tl->error_slot = 0; ++ tl->error = 0; ++ pthread_mutex_init(&tl->global_lock, NULL); ++ pthread_mutex_init(&tl->setcallback_lock, NULL); ++ ++ // create the slots ++ tl->slots = malloc(sizeof(struct en50221_slot) * max_slots); ++ if (tl->slots == NULL) ++ goto error_exit; ++ ++ // set them up ++ for (i = 0; i < max_slots; i++) { ++ tl->slots[i].ca_hndl = -1; ++ ++ // create the connections for this slot ++ tl->slots[i].connections = ++ malloc(sizeof(struct en50221_connection) * max_connections_per_slot); ++ if (tl->slots[i].connections == NULL) ++ goto error_exit; ++ ++ // create a mutex for the slot ++ pthread_mutex_init(&tl->slots[i].slot_lock, NULL); ++ ++ // set them up ++ for (j = 0; j < max_connections_per_slot; j++) { ++ tl->slots[i].connections[j].state = T_STATE_IDLE; ++ tl->slots[i].connections[j].tx_time.tv_sec = 0; ++ tl->slots[i].connections[j].last_poll_time.tv_sec = 0; ++ tl->slots[i].connections[j].last_poll_time.tv_usec = 0; ++ tl->slots[i].connections[j].chain_buffer = NULL; ++ tl->slots[i].connections[j].buffer_length = 0; ++ tl->slots[i].connections[j].send_queue = NULL; ++ tl->slots[i].connections[j].send_queue_tail = NULL; ++ } ++ } ++ ++ // create the pollfds ++ tl->slot_pollfds = malloc(sizeof(struct pollfd) * max_slots); ++ if (tl->slot_pollfds == NULL) { ++ goto error_exit; ++ } ++ memset(tl->slot_pollfds, 0, sizeof(struct pollfd) * max_slots); ++ ++ return tl; ++ ++ error_exit: ++ en50221_tl_destroy(tl); ++ return NULL; ++} ++ ++// Destroy an instance of the transport layer ++void en50221_tl_destroy(struct en50221_transport_layer *tl) ++{ ++ int i, j; ++ ++ if (tl) { ++ if (tl->slots) { ++ for (i = 0; i < tl->max_slots; i++) { ++ if (tl->slots[i].connections) { ++ for (j = 0; j < tl->max_connections_per_slot; j++) { ++ if (tl->slots[i].connections[j].chain_buffer) { ++ free(tl->slots[i].connections[j].chain_buffer); ++ } ++ ++ struct en50221_message *cur_msg = ++ tl->slots[i].connections[j].send_queue; ++ while (cur_msg) { ++ struct en50221_message *next_msg = cur_msg->next; ++ free(cur_msg); ++ cur_msg = next_msg; ++ } ++ tl->slots[i].connections[j].send_queue = NULL; ++ tl->slots[i].connections[j].send_queue_tail = NULL; ++ } ++ free(tl->slots[i].connections); ++ pthread_mutex_destroy(&tl->slots[i].slot_lock); ++ } ++ } ++ free(tl->slots); ++ } ++ if (tl->slot_pollfds) { ++ free(tl->slot_pollfds); ++ } ++ pthread_mutex_destroy(&tl->setcallback_lock); ++ pthread_mutex_destroy(&tl->global_lock); ++ free(tl); ++ } ++} ++ ++// this can be called from the user-space app to ++// register new slots that we should work with ++int en50221_tl_register_slot(struct en50221_transport_layer *tl, ++ int ca_hndl, uint8_t slot, ++ uint32_t response_timeout, ++ uint32_t poll_delay) ++{ ++ // lock ++ pthread_mutex_lock(&tl->global_lock); ++ ++ // we browse through the array of slots ++ // to look for the first unused one ++ int i; ++ int16_t slot_id = -1; ++ for (i = 0; i < tl->max_slots; i++) { ++ if (tl->slots[i].ca_hndl == -1) { ++ slot_id = i; ++ break; ++ } ++ } ++ if (slot_id == -1) { ++ tl->error = EN50221ERR_OUTOFSLOTS; ++ pthread_mutex_unlock(&tl->global_lock); ++ return -1; ++ } ++ // set up the slot struct ++ pthread_mutex_lock(&tl->slots[slot_id].slot_lock); ++ tl->slots[slot_id].ca_hndl = ca_hndl; ++ tl->slots[slot_id].slot = slot; ++ tl->slots[slot_id].response_timeout = response_timeout; ++ tl->slots[slot_id].poll_delay = poll_delay; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ ++ tl->slots_changed = 1; ++ pthread_mutex_unlock(&tl->global_lock); ++ return slot_id; ++} ++ ++void en50221_tl_destroy_slot(struct en50221_transport_layer *tl, ++ uint8_t slot_id) ++{ ++ int i; ++ ++ if (slot_id >= tl->max_slots) ++ return; ++ ++ // lock ++ pthread_mutex_lock(&tl->global_lock); ++ ++ // clear the slot ++ pthread_mutex_lock(&tl->slots[slot_id].slot_lock); ++ tl->slots[slot_id].ca_hndl = -1; ++ for (i = 0; i < tl->max_connections_per_slot; i++) { ++ tl->slots[slot_id].connections[i].state = T_STATE_IDLE; ++ tl->slots[slot_id].connections[i].tx_time.tv_sec = 0; ++ tl->slots[slot_id].connections[i].last_poll_time.tv_sec = 0; ++ tl->slots[slot_id].connections[i].last_poll_time.tv_usec = 0; ++ if (tl->slots[slot_id].connections[i].chain_buffer) { ++ free(tl->slots[slot_id].connections[i]. ++ chain_buffer); ++ } ++ tl->slots[slot_id].connections[i].chain_buffer = NULL; ++ tl->slots[slot_id].connections[i].buffer_length = 0; ++ ++ struct en50221_message *cur_msg = ++ tl->slots[slot_id].connections[i].send_queue; ++ while (cur_msg) { ++ struct en50221_message *next_msg = cur_msg->next; ++ free(cur_msg); ++ cur_msg = next_msg; ++ } ++ tl->slots[slot_id].connections[i].send_queue = NULL; ++ tl->slots[slot_id].connections[i].send_queue_tail = NULL; ++ } ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ ++ // tell upper layers ++ pthread_mutex_lock(&tl->setcallback_lock); ++ en50221_tl_callback cb = tl->callback; ++ void *cb_arg = tl->callback_arg; ++ pthread_mutex_unlock(&tl->setcallback_lock); ++ if (cb) ++ cb(cb_arg, T_CALLBACK_REASON_SLOTCLOSE, NULL, 0, slot_id, 0); ++ ++ tl->slots_changed = 1; ++ pthread_mutex_unlock(&tl->global_lock); ++} ++ ++int en50221_tl_poll(struct en50221_transport_layer *tl) ++{ ++ uint8_t data[4096]; ++ int slot_id; ++ int j; ++ ++ // make up pollfds if the slots have changed ++ pthread_mutex_lock(&tl->global_lock); ++ if (tl->slots_changed) { ++ for (slot_id = 0; slot_id < tl->max_slots; slot_id++) { ++ if (tl->slots[slot_id].ca_hndl != -1) { ++ tl->slot_pollfds[slot_id].fd = tl->slots[slot_id].ca_hndl; ++ tl->slot_pollfds[slot_id].events = POLLIN | POLLPRI | POLLERR; ++ tl->slot_pollfds[slot_id].revents = 0; ++ } else { ++ tl->slot_pollfds[slot_id].fd = 0; ++ tl->slot_pollfds[slot_id].events = 0; ++ tl->slot_pollfds[slot_id].revents = 0; ++ } ++ } ++ tl->slots_changed = 0; ++ } ++ pthread_mutex_unlock(&tl->global_lock); ++ ++ // anything happened? ++ if (poll(tl->slot_pollfds, tl->max_slots, 10) < 0) { ++ tl->error_slot = -1; ++ tl->error = EN50221ERR_CAREAD; ++ return -1; ++ } ++ // go through all slots (even though poll may not have reported any events ++ for (slot_id = 0; slot_id < tl->max_slots; slot_id++) { ++ ++ // check if this slot is still used and get its handle ++ pthread_mutex_lock(&tl->slots[slot_id].slot_lock); ++ if (tl->slots[slot_id].ca_hndl == -1) { ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ continue; ++ } ++ int ca_hndl = tl->slots[slot_id].ca_hndl; ++ ++ if (tl->slot_pollfds[slot_id].revents & (POLLPRI | POLLIN)) { ++ // read data ++ uint8_t r_slot_id; ++ uint8_t connection_id; ++ int readcnt = dvbca_link_read(ca_hndl, &r_slot_id, ++ &connection_id, ++ data, sizeof(data)); ++ if (readcnt < 0) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_CAREAD; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ // process it if we got some ++ if (readcnt > 0) { ++ if (tl->slots[slot_id].slot != r_slot_id) { ++ // this message is for an other CAM of the same CA ++ int new_slot_id; ++ for (new_slot_id = 0; new_slot_id < tl->max_slots; new_slot_id++) { ++ if ((tl->slots[new_slot_id].ca_hndl == ca_hndl) && ++ (tl->slots[new_slot_id].slot == r_slot_id)) ++ break; ++ } ++ if (new_slot_id != tl->max_slots) { ++ // we found the requested CAM ++ pthread_mutex_lock(&tl->slots[new_slot_id].slot_lock); ++ if (en50221_tl_process_data(tl, new_slot_id, data, readcnt)) { ++ pthread_mutex_unlock(&tl->slots[new_slot_id].slot_lock); ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ pthread_mutex_unlock(&tl->slots[new_slot_id].slot_lock); ++ } else { ++ tl->error = EN50221ERR_BADSLOTID; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ } else ++ if (en50221_tl_process_data(tl, slot_id, data, readcnt)) { ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ } ++ } else if (tl->slot_pollfds[slot_id].revents & POLLERR) { ++ // an error was reported ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_CAREAD; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ // poll the connections on this slot + check for timeouts ++ for (j = 0; j < tl->max_connections_per_slot; j++) { ++ // ignore connection if idle ++ if (tl->slots[slot_id].connections[j].state == T_STATE_IDLE) { ++ continue; ++ } ++ // send queued data ++ if (tl->slots[slot_id].connections[j].state & ++ (T_STATE_IN_CREATION | T_STATE_ACTIVE | T_STATE_ACTIVE_DELETEQUEUED)) { ++ // send data if there is some to go and we're not waiting for a response already ++ if (tl->slots[slot_id].connections[j].send_queue && ++ (tl->slots[slot_id].connections[j].tx_time.tv_sec == 0)) { ++ ++ // get the message ++ struct en50221_message *msg = ++ tl->slots[slot_id].connections[j].send_queue; ++ if (msg->next != NULL) { ++ tl->slots[slot_id].connections[j].send_queue = msg->next; ++ } else { ++ tl->slots[slot_id].connections[j].send_queue = NULL; ++ tl->slots[slot_id].connections[j].send_queue_tail = NULL; ++ } ++ ++ // send the message ++ if (dvbca_link_write(tl->slots[slot_id].ca_hndl, ++ tl->slots[slot_id].slot, ++ j, ++ msg->data, msg->length) < 0) { ++ free(msg); ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_CAWRITE; ++ print(LOG_LEVEL, ERROR, 1, "CAWrite failed"); ++ return -1; ++ } ++ gettimeofday(&tl->slots[slot_id].connections[j].tx_time, 0); ++ ++ // fixup connection state for T_DELETE_T_C ++ if (msg->length && (msg->data[0] == T_DELETE_T_C)) { ++ tl->slots[slot_id].connections[j].state = T_STATE_IN_DELETION; ++ if (tl->slots[slot_id].connections[j].chain_buffer) { ++ free(tl->slots[slot_id].connections[j].chain_buffer); ++ } ++ tl->slots[slot_id].connections[j].chain_buffer = NULL; ++ tl->slots[slot_id].connections[j].buffer_length = 0; ++ } ++ ++ free(msg); ++ } ++ } ++ // poll it if we're not expecting a reponse and the poll time has elapsed ++ if (tl->slots[slot_id].connections[j].state & T_STATE_ACTIVE) { ++ if ((tl->slots[slot_id].connections[j].tx_time.tv_sec == 0) && ++ (time_after(tl->slots[slot_id].connections[j].last_poll_time, ++ tl->slots[slot_id].poll_delay))) { ++ ++ gettimeofday(&tl->slots[slot_id].connections[j].last_poll_time, 0); ++ if (en50221_tl_poll_tc(tl, slot_id, j)) { ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ } ++ } ++ ++ // check for timeouts - in any state ++ if (tl->slots[slot_id].connections[j].tx_time.tv_sec && ++ (time_after(tl->slots[slot_id].connections[j].tx_time, ++ tl->slots[slot_id].response_timeout))) { ++ ++ if (tl->slots[slot_id].connections[j].state & ++ (T_STATE_IN_CREATION |T_STATE_IN_DELETION)) { ++ tl->slots[slot_id].connections[j].state = T_STATE_IDLE; ++ } else if (tl->slots[slot_id].connections[j].state & ++ (T_STATE_ACTIVE | T_STATE_ACTIVE_DELETEQUEUED)) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_TIMEOUT; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ } ++ } ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ } ++ ++ return 0; ++} ++ ++void en50221_tl_register_callback(struct en50221_transport_layer *tl, ++ en50221_tl_callback callback, void *arg) ++{ ++ pthread_mutex_lock(&tl->setcallback_lock); ++ tl->callback = callback; ++ tl->callback_arg = arg; ++ pthread_mutex_unlock(&tl->setcallback_lock); ++} ++ ++int en50221_tl_get_error_slot(struct en50221_transport_layer *tl) ++{ ++ return tl->error_slot; ++} ++ ++int en50221_tl_get_error(struct en50221_transport_layer *tl) ++{ ++ return tl->error; ++} ++ ++int en50221_tl_send_data(struct en50221_transport_layer *tl, ++ uint8_t slot_id, uint8_t connection_id, ++ uint8_t * data, uint32_t data_size) ++{ ++#ifdef DEBUG_TXDATA ++ printf("[[[[[[[[[[[[[[[[[[[[\n"); ++ uint32_t ii = 0; ++ for (ii = 0; ii < data_size; ii++) { ++ printf("%02x: %02x\n", ii, data[ii]); ++ } ++ printf("]]]]]]]]]]]]]]]]]]]]\n"); ++#endif ++ ++ if (slot_id >= tl->max_slots) { ++ tl->error = EN50221ERR_BADSLOTID; ++ return -1; ++ } ++ ++ pthread_mutex_lock(&tl->slots[slot_id].slot_lock); ++ if (tl->slots[slot_id].ca_hndl == -1) { ++ tl->error = EN50221ERR_BADSLOTID; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ if (connection_id >= tl->max_connections_per_slot) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_BADCONNECTIONID; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ if (tl->slots[slot_id].connections[connection_id].state != T_STATE_ACTIVE) { ++ tl->error = EN50221ERR_BADCONNECTIONID; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ // allocate msg structure ++ struct en50221_message *msg = ++ malloc(sizeof(struct en50221_message) + data_size + 10); ++ if (msg == NULL) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_OUTOFMEMORY; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ // make up data to send ++ int length_field_len; ++ msg->data[0] = T_DATA_LAST; ++ if ((length_field_len = asn_1_encode(data_size + 1, msg->data + 1, 3)) < 0) { ++ free(msg); ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_ASNENCODE; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ msg->data[1 + length_field_len] = connection_id; ++ memcpy(msg->data + 1 + length_field_len + 1, data, data_size); ++ msg->length = 1 + length_field_len + 1 + data_size; ++ ++ // queue it for transmission ++ queue_message(tl, slot_id, connection_id, msg); ++ ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return 0; ++} ++ ++int en50221_tl_send_datav(struct en50221_transport_layer *tl, ++ uint8_t slot_id, uint8_t connection_id, ++ struct iovec *vector, int iov_count) ++{ ++#ifdef DEBUG_TXDATA ++ printf("[[[[[[[[[[[[[[[[[[[[\n"); ++ uint32_t ii = 0; ++ uint32_t iipos = 0; ++ for (ii = 0; ii < (uint32_t) iov_count; ii++) { ++ uint32_t jj; ++ for (jj = 0; jj < vector[ii].iov_len; jj++) { ++ printf("%02x: %02x\n", jj + iipos, ++ *((uint8_t *) (vector[ii].iov_base) + jj)); ++ } ++ iipos += vector[ii].iov_len; ++ } ++ printf("]]]]]]]]]]]]]]]]]]]]\n"); ++#endif ++ ++ if (slot_id >= tl->max_slots) { ++ tl->error = EN50221ERR_BADSLOTID; ++ return -1; ++ } ++ ++ pthread_mutex_lock(&tl->slots[slot_id].slot_lock); ++ if (tl->slots[slot_id].ca_hndl == -1) { ++ tl->error = EN50221ERR_BADSLOTID; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ if (connection_id >= tl->max_connections_per_slot) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_BADCONNECTIONID; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ if (tl->slots[slot_id].connections[connection_id].state != T_STATE_ACTIVE) { ++ tl->error = EN50221ERR_BADCONNECTIONID; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ // calculate the total length of the data to send ++ uint32_t data_size = 0; ++ int i; ++ for (i = 0; i < iov_count; i++) { ++ data_size += vector[i].iov_len; ++ } ++ ++ // allocate msg structure ++ struct en50221_message *msg = ++ malloc(sizeof(struct en50221_message) + data_size + 10); ++ if (msg == NULL) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_OUTOFMEMORY; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ // make up data to send ++ int length_field_len; ++ msg->data[0] = T_DATA_LAST; ++ if ((length_field_len = asn_1_encode(data_size + 1, msg->data + 1, 3)) < 0) { ++ free(msg); ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_ASNENCODE; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ msg->data[1 + length_field_len] = connection_id; ++ msg->length = 1 + length_field_len + 1 + data_size; ++ msg->next = NULL; ++ ++ // merge the iovecs ++ uint32_t pos = 1 + length_field_len + 1; ++ for (i = 0; i < iov_count; i++) { ++ memcpy(msg->data + pos, vector[i].iov_base, ++ vector[i].iov_len); ++ pos += vector[i].iov_len; ++ } ++ ++ // queue it for transmission ++ queue_message(tl, slot_id, connection_id, msg); ++ ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return 0; ++} ++ ++int en50221_tl_new_tc(struct en50221_transport_layer *tl, uint8_t slot_id) ++{ ++ // check ++ if (slot_id >= tl->max_slots) { ++ tl->error = EN50221ERR_BADSLOTID; ++ return -1; ++ } ++ ++ pthread_mutex_lock(&tl->slots[slot_id].slot_lock); ++ if (tl->slots[slot_id].ca_hndl == -1) { ++ tl->error = EN50221ERR_BADSLOTID; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ // allocate a new connection if possible ++ int conid = en50221_tl_alloc_new_tc(tl, slot_id); ++ if (conid == -1) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_OUTOFCONNECTIONS; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ // allocate msg structure ++ struct en50221_message *msg = ++ malloc(sizeof(struct en50221_message) + 3); ++ if (msg == NULL) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_OUTOFMEMORY; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ // make up the data to send ++ msg->data[0] = T_CREATE_T_C; ++ msg->data[1] = 1; ++ msg->data[2] = conid; ++ msg->length = 3; ++ msg->next = NULL; ++ ++ // queue it for transmission ++ queue_message(tl, slot_id, conid, msg); ++ ++ // done ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return conid; ++} ++ ++int en50221_tl_del_tc(struct en50221_transport_layer *tl, uint8_t slot_id, ++ uint8_t connection_id) ++{ ++ // check ++ if (slot_id >= tl->max_slots) { ++ tl->error = EN50221ERR_BADSLOTID; ++ return -1; ++ } ++ ++ pthread_mutex_lock(&tl->slots[slot_id].slot_lock); ++ if (tl->slots[slot_id].ca_hndl == -1) { ++ tl->error = EN50221ERR_BADSLOTID; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ if (connection_id >= tl->max_connections_per_slot) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_BADCONNECTIONID; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ if (!(tl->slots[slot_id].connections[connection_id].state & ++ (T_STATE_ACTIVE | T_STATE_IN_DELETION))) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_BADSTATE; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ // allocate msg structure ++ struct en50221_message *msg = ++ malloc(sizeof(struct en50221_message) + 3); ++ if (msg == NULL) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_OUTOFMEMORY; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ // make up the data to send ++ msg->data[0] = T_DELETE_T_C; ++ msg->data[1] = 1; ++ msg->data[2] = connection_id; ++ msg->length = 3; ++ msg->next = NULL; ++ ++ // queue it for transmission ++ queue_message(tl, slot_id, connection_id, msg); ++ tl->slots[slot_id].connections[connection_id].state = ++ T_STATE_ACTIVE_DELETEQUEUED; ++ ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return 0; ++} ++ ++int en50221_tl_get_connection_state(struct en50221_transport_layer *tl, ++ uint8_t slot_id, uint8_t connection_id) ++{ ++ if (slot_id >= tl->max_slots) { ++ tl->error = EN50221ERR_BADSLOTID; ++ return -1; ++ } ++ ++ pthread_mutex_lock(&tl->slots[slot_id].slot_lock); ++ if (tl->slots[slot_id].ca_hndl == -1) { ++ tl->error = EN50221ERR_BADSLOTID; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ if (connection_id >= tl->max_connections_per_slot) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_BADCONNECTIONID; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ return -1; ++ } ++ int state = tl->slots[slot_id].connections[connection_id].state; ++ pthread_mutex_unlock(&tl->slots[slot_id].slot_lock); ++ ++ return state; ++} ++ ++ ++ ++ ++// ask the module for new data ++static int en50221_tl_poll_tc(struct en50221_transport_layer *tl, ++ uint8_t slot_id, uint8_t connection_id) ++{ ++ gettimeofday(&tl->slots[slot_id].connections[connection_id]. ++ tx_time, 0); ++ ++ // send command ++ uint8_t hdr[3]; ++ hdr[0] = T_DATA_LAST; ++ hdr[1] = 1; ++ hdr[2] = connection_id; ++ if (dvbca_link_write(tl->slots[slot_id].ca_hndl, ++ tl->slots[slot_id].slot, ++ connection_id, hdr, 3) < 0) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_CAWRITE; ++ return -1; ++ } ++ return 0; ++} ++ ++// handle incoming data ++static int en50221_tl_process_data(struct en50221_transport_layer *tl, ++ uint8_t slot_id, uint8_t * data, ++ uint32_t data_length) ++{ ++ int result; ++ ++#ifdef DEBUG_RXDATA ++ printf("-------------------\n"); ++ uint32_t ii = 0; ++ for (ii = 0; ii < data_length; ii++) { ++ printf("%02x: %02x\n", ii, data[ii]); ++ } ++ printf("+++++++++++++++++++\n"); ++#endif ++ ++ // process the received data ++ while (data_length) { ++ // parse the header ++ uint8_t tpdu_tag = data[0]; ++ uint16_t asn_data_length; ++ int length_field_len; ++ if ((length_field_len = asn_1_decode(&asn_data_length, data + 1, data_length - 1)) < 0) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received data with invalid asn from module on slot %02x\n", ++ slot_id); ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_BADCAMDATA; ++ return -1; ++ } ++ if ((asn_data_length < 1) || ++ (asn_data_length > (data_length - (1 + length_field_len)))) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received data with invalid length from module on slot %02x\n", ++ slot_id); ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_BADCAMDATA; ++ return -1; ++ } ++ uint8_t connection_id = data[1 + length_field_len]; ++ data += 1 + length_field_len + 1; ++ data_length -= (1 + length_field_len + 1); ++ asn_data_length--; ++ ++ // check the connection_id ++ if (connection_id >= tl->max_connections_per_slot) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received bad connection id %02x from module on slot %02x\n", ++ connection_id, slot_id); ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_BADCONNECTIONID; ++ return -1; ++ } ++ // process the TPDUs ++ switch (tpdu_tag) { ++ case T_C_T_C_REPLY: ++ if ((result = en50221_tl_handle_create_tc_reply(tl, slot_id, connection_id)) < 0) { ++ return -1; ++ } ++ break; ++ case T_DELETE_T_C: ++ if ((result = en50221_tl_handle_delete_tc(tl, slot_id, connection_id)) < 0) { ++ return -1; ++ } ++ break; ++ case T_D_T_C_REPLY: ++ if ((result = en50221_tl_handle_delete_tc_reply(tl, slot_id, connection_id)) < 0) { ++ return -1; ++ } ++ break; ++ case T_REQUEST_T_C: ++ if ((result = en50221_tl_handle_request_tc(tl, slot_id, connection_id)) < 0) { ++ return -1; ++ } ++ break; ++ case T_DATA_MORE: ++ if ((result = en50221_tl_handle_data_more(tl, slot_id, ++ connection_id, ++ data, ++ asn_data_length)) < 0) { ++ return -1; ++ } ++ break; ++ case T_DATA_LAST: ++ if ((result = en50221_tl_handle_data_last(tl, slot_id, ++ connection_id, ++ data, ++ asn_data_length)) < 0) { ++ return -1; ++ } ++ break; ++ case T_SB: ++ if ((result = en50221_tl_handle_sb(tl, slot_id, ++ connection_id, ++ data, ++ asn_data_length)) < 0) { ++ return -1; ++ } ++ break; ++ default: ++ print(LOG_LEVEL, ERROR, 1, ++ "Recieved unexpected TPDU tag %02x from module on slot %02x\n", ++ tpdu_tag, slot_id); ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_BADCAMDATA; ++ return -1; ++ } ++ ++ // skip over the consumed data ++ data += asn_data_length; ++ data_length -= asn_data_length; ++ } ++ ++ return 0; ++} ++ ++static int en50221_tl_handle_create_tc_reply(struct en50221_transport_layer ++ *tl, uint8_t slot_id, ++ uint8_t connection_id) ++{ ++ // set this connection to state active ++ if (tl->slots[slot_id].connections[connection_id].state == T_STATE_IN_CREATION) { ++ tl->slots[slot_id].connections[connection_id].state = T_STATE_ACTIVE; ++ tl->slots[slot_id].connections[connection_id].tx_time.tv_sec = 0; ++ ++ // tell upper layers ++ pthread_mutex_lock(&tl->setcallback_lock); ++ en50221_tl_callback cb = tl->callback; ++ void *cb_arg = tl->callback_arg; ++ pthread_mutex_unlock(&tl->setcallback_lock); ++ if (cb) ++ cb(cb_arg, T_CALLBACK_REASON_CONNECTIONOPEN, NULL, 0, slot_id, connection_id); ++ } else { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received T_C_T_C_REPLY for connection not in " ++ "T_STATE_IN_CREATION from module on slot %02x\n", ++ slot_id); ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_BADCAMDATA; ++ return -1; ++ } ++ ++ return 0; ++} ++ ++static int en50221_tl_handle_delete_tc(struct en50221_transport_layer *tl, ++ uint8_t slot_id, ++ uint8_t connection_id) ++{ ++ // immediately delete this connection and send D_T_C_REPLY ++ if (tl->slots[slot_id].connections[connection_id].state & ++ (T_STATE_ACTIVE | T_STATE_IN_DELETION)) { ++ // clear down the slot ++ tl->slots[slot_id].connections[connection_id].state = T_STATE_IDLE; ++ if (tl->slots[slot_id].connections[connection_id].chain_buffer) { ++ free(tl->slots[slot_id].connections[connection_id].chain_buffer); ++ } ++ tl->slots[slot_id].connections[connection_id].chain_buffer = NULL; ++ tl->slots[slot_id].connections[connection_id].buffer_length = 0; ++ ++ // send the reply ++ uint8_t hdr[3]; ++ hdr[0] = T_D_T_C_REPLY; ++ hdr[1] = 1; ++ hdr[2] = connection_id; ++ if (dvbca_link_write(tl->slots[slot_id].ca_hndl, ++ tl->slots[slot_id].slot, ++ connection_id, hdr, 3) < 0) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_CAWRITE; ++ return -1; ++ } ++ // tell upper layers ++ pthread_mutex_lock(&tl->setcallback_lock); ++ en50221_tl_callback cb = tl->callback; ++ void *cb_arg = tl->callback_arg; ++ pthread_mutex_unlock(&tl->setcallback_lock); ++ if (cb) ++ cb(cb_arg, T_CALLBACK_REASON_CONNECTIONCLOSE, NULL, 0, slot_id, connection_id); ++ } else { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received T_DELETE_T_C for inactive connection from module on slot %02x\n", ++ slot_id); ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_BADCAMDATA; ++ return -1; ++ } ++ ++ return 0; ++} ++ ++static int en50221_tl_handle_delete_tc_reply(struct en50221_transport_layer ++ *tl, uint8_t slot_id, ++ uint8_t connection_id) ++{ ++ // delete this connection, should be in T_STATE_IN_DELETION already ++ if (tl->slots[slot_id].connections[connection_id].state == T_STATE_IN_DELETION) { ++ tl->slots[slot_id].connections[connection_id].state = T_STATE_IDLE; ++ } else { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received T_D_T_C_REPLY received for connection not in " ++ "T_STATE_IN_DELETION from module on slot %02x\n", ++ slot_id); ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_BADCAMDATA; ++ return -1; ++ } ++ ++ return 0; ++} ++ ++static int en50221_tl_handle_request_tc(struct en50221_transport_layer *tl, ++ uint8_t slot_id, ++ uint8_t connection_id) ++{ ++ // allocate a new connection if possible ++ int conid = en50221_tl_alloc_new_tc(tl, slot_id); ++ int ca_hndl = tl->slots[slot_id].ca_hndl; ++ if (conid == -1) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Too many connections requested by module on slot %02x\n", ++ slot_id); ++ ++ // send the error ++ uint8_t hdr[4]; ++ hdr[0] = T_T_C_ERROR; ++ hdr[1] = 2; ++ hdr[2] = connection_id; ++ hdr[3] = 1; ++ if (dvbca_link_write(ca_hndl, tl->slots[slot_id].slot, connection_id, hdr, 4) < 0) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_CAWRITE; ++ return -1; ++ } ++ tl->slots[slot_id].connections[connection_id].tx_time. ++ tv_sec = 0; ++ } else { ++ // send the NEW_T_C on the connection we received it on ++ uint8_t hdr[4]; ++ hdr[0] = T_NEW_T_C; ++ hdr[1] = 2; ++ hdr[2] = connection_id; ++ hdr[3] = conid; ++ if (dvbca_link_write(ca_hndl, tl->slots[slot_id].slot, connection_id, hdr, 4) < 0) { ++ tl->slots[slot_id].connections[conid].state = T_STATE_IDLE; ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_CAWRITE; ++ return -1; ++ } ++ tl->slots[slot_id].connections[connection_id].tx_time.tv_sec = 0; ++ ++ // send the CREATE_T_C on the new connnection ++ hdr[0] = T_CREATE_T_C; ++ hdr[1] = 1; ++ hdr[2] = conid; ++ if (dvbca_link_write(ca_hndl, tl->slots[slot_id].slot, conid, hdr, 3) < 0) { ++ tl->slots[slot_id].connections[conid].state = T_STATE_IDLE; ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_CAWRITE; ++ return -1; ++ } ++ gettimeofday(&tl->slots[slot_id].connections[conid].tx_time, 0); ++ ++ // tell upper layers ++ pthread_mutex_lock(&tl->setcallback_lock); ++ en50221_tl_callback cb = tl->callback; ++ void *cb_arg = tl->callback_arg; ++ pthread_mutex_unlock(&tl->setcallback_lock); ++ if (cb) ++ cb(cb_arg, T_CALLBACK_REASON_CAMCONNECTIONOPEN, NULL, 0, slot_id, conid); ++ } ++ ++ return 0; ++} ++ ++static int en50221_tl_handle_data_more(struct en50221_transport_layer *tl, ++ uint8_t slot_id, ++ uint8_t connection_id, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ // connection in correct state? ++ if (tl->slots[slot_id].connections[connection_id].state != T_STATE_ACTIVE) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received T_DATA_MORE for connection not in " ++ "T_STATE_ACTIVE from module on slot %02x\n", ++ slot_id); ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_BADCAMDATA; ++ return -1; ++ } ++ // a chained data packet is coming in, save ++ // it to the buffer and wait for more ++ tl->slots[slot_id].connections[connection_id].tx_time.tv_sec = 0; ++ int new_data_length = ++ tl->slots[slot_id].connections[connection_id].buffer_length + data_length; ++ uint8_t *new_data_buffer = ++ realloc(tl->slots[slot_id].connections[connection_id].chain_buffer, new_data_length); ++ if (new_data_buffer == NULL) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_OUTOFMEMORY; ++ return -1; ++ } ++ tl->slots[slot_id].connections[connection_id].chain_buffer = new_data_buffer; ++ ++ memcpy(tl->slots[slot_id].connections[connection_id].chain_buffer + ++ tl->slots[slot_id].connections[connection_id].buffer_length, ++ data, data_length); ++ tl->slots[slot_id].connections[connection_id].buffer_length = new_data_length; ++ ++ return 0; ++} ++ ++static int en50221_tl_handle_data_last(struct en50221_transport_layer *tl, ++ uint8_t slot_id, ++ uint8_t connection_id, ++ uint8_t * data, ++ uint32_t data_length) ++{ ++ // connection in correct state? ++ if (tl->slots[slot_id].connections[connection_id].state != T_STATE_ACTIVE) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received T_DATA_LAST received for connection not in " ++ "T_STATE_ACTIVE from module on slot %02x\n", ++ slot_id); ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_BADCAMDATA; ++ return -1; ++ } ++ // last package of a chain or single package comes in ++ tl->slots[slot_id].connections[connection_id].tx_time.tv_sec = 0; ++ if (tl->slots[slot_id].connections[connection_id].chain_buffer == NULL) { ++ // single package => dispatch immediately ++ pthread_mutex_lock(&tl->setcallback_lock); ++ en50221_tl_callback cb = tl->callback; ++ void *cb_arg = tl->callback_arg; ++ pthread_mutex_unlock(&tl->setcallback_lock); ++ ++ if (cb && data_length) { ++ pthread_mutex_unlock(&tl->slots[slot_id]. ++ slot_lock); ++ cb(cb_arg, T_CALLBACK_REASON_DATA, data, data_length, slot_id, connection_id); ++ pthread_mutex_lock(&tl->slots[slot_id].slot_lock); ++ } ++ } else { ++ int new_data_length = ++ tl->slots[slot_id].connections[connection_id].buffer_length + data_length; ++ uint8_t *new_data_buffer = ++ realloc(tl->slots[slot_id].connections[connection_id].chain_buffer, new_data_length); ++ if (new_data_buffer == NULL) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_OUTOFMEMORY; ++ return -1; ++ } ++ ++ memcpy(new_data_buffer + ++ tl->slots[slot_id].connections[connection_id]. ++ buffer_length, data, data_length); ++ ++ // clean the buffer position ++ tl->slots[slot_id].connections[connection_id].chain_buffer = NULL; ++ tl->slots[slot_id].connections[connection_id].buffer_length = 0; ++ ++ // tell the upper layers ++ pthread_mutex_lock(&tl->setcallback_lock); ++ en50221_tl_callback cb = tl->callback; ++ void *cb_arg = tl->callback_arg; ++ pthread_mutex_unlock(&tl->setcallback_lock); ++ if (cb && data_length) { ++ pthread_mutex_unlock(&tl->slots[slot_id]. ++ slot_lock); ++ cb(cb_arg, T_CALLBACK_REASON_DATA, new_data_buffer, ++ new_data_length, slot_id, connection_id); ++ pthread_mutex_lock(&tl->slots[slot_id].slot_lock); ++ } ++ ++ free(new_data_buffer); ++ } ++ ++ return 0; ++} ++ ++static int en50221_tl_handle_sb(struct en50221_transport_layer *tl, ++ uint8_t slot_id, uint8_t connection_id, ++ uint8_t * data, uint32_t data_length) ++{ ++ // is the connection id ok? ++ if (tl->slots[slot_id].connections[connection_id].state != T_STATE_ACTIVE) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Received T_SB for connection not in T_STATE_ACTIVE from module on slot %02x\n", ++ slot_id); ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_BADCAMDATA; ++ return -1; ++ } ++ // did we get enough data in the T_SB? ++ if (data_length != 1) { ++ print(LOG_LEVEL, ERROR, 1, ++ "Recieved T_SB with invalid length from module on slot %02x\n", ++ slot_id); ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_BADCAMDATA; ++ return -1; ++ } ++ // tell it to send the data if it says there is some ++ if (data[0] & 0x80) { ++ int ca_hndl = tl->slots[slot_id].ca_hndl; ++ ++ // send the RCV ++ uint8_t hdr[3]; ++ hdr[0] = T_RCV; ++ hdr[1] = 1; ++ hdr[2] = connection_id; ++ if (dvbca_link_write(ca_hndl, tl->slots[slot_id].slot, connection_id, hdr, 3) < 0) { ++ tl->error_slot = slot_id; ++ tl->error = EN50221ERR_CAWRITE; ++ return -1; ++ } ++ gettimeofday(&tl->slots[slot_id].connections[connection_id].tx_time, 0); ++ ++ } else { ++ // no data - indicate not waiting for anything now ++ tl->slots[slot_id].connections[connection_id].tx_time.tv_sec = 0; ++ } ++ ++ return 0; ++} ++ ++static int en50221_tl_alloc_new_tc(struct en50221_transport_layer *tl, ++ uint8_t slot_id) ++{ ++ // we browse through the array of connection ++ // types, to look for the first unused one ++ int i, conid = -1; ++ for (i = 1; i < tl->max_connections_per_slot; i++) { ++ if (tl->slots[slot_id].connections[i].state == T_STATE_IDLE) { ++ conid = i; ++ break; ++ } ++ } ++ if (conid == -1) { ++ print(LOG_LEVEL, ERROR, 1, ++ "CREATE_T_C failed: no more connections available\n"); ++ return -1; ++ } ++ // set up the connection struct ++ tl->slots[slot_id].connections[conid].state = T_STATE_IN_CREATION; ++ tl->slots[slot_id].connections[conid].chain_buffer = NULL; ++ tl->slots[slot_id].connections[conid].buffer_length = 0; ++ ++ return conid; ++} ++ ++static void queue_message(struct en50221_transport_layer *tl, ++ uint8_t slot_id, uint8_t connection_id, ++ struct en50221_message *msg) ++{ ++ msg->next = NULL; ++ if (tl->slots[slot_id].connections[connection_id].send_queue_tail) { ++ tl->slots[slot_id].connections[connection_id].send_queue_tail->next = msg; ++ tl->slots[slot_id].connections[connection_id].send_queue_tail = msg; ++ } else { ++ tl->slots[slot_id].connections[connection_id].send_queue = msg; ++ tl->slots[slot_id].connections[connection_id].send_queue_tail = msg; ++ } ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_transport.h dvb-apps/lib/libdvben50221/en50221_transport.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/en50221_transport.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/en50221_transport.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,234 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 session layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++ ++#ifndef __EN50221_TRANSPORT_H__ ++#define __EN50221_TRANSPORT_H__ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * Callback reasons. ++ */ ++#define T_CALLBACK_REASON_CONNECTIONOPEN 0x00 // A connection we opened _to_ the cam has been ACKed ++#define T_CALLBACK_REASON_CAMCONNECTIONOPEN 0x01 // The cam has opened a connection to _us_. ++#define T_CALLBACK_REASON_DATA 0x02 // Data received ++#define T_CALLBACK_REASON_CONNECTIONCLOSE 0x03 // The cam has told us to close a connection. ++#define T_CALLBACK_REASON_SLOTCLOSE 0x04 // The cam in the supplied slot id has been removed. ++ ++// these are the states a TC can be in ++#define T_STATE_IDLE 0x01 // this transport connection is not in use ++#define T_STATE_ACTIVE 0x02 // this transport connection is in use ++#define T_STATE_ACTIVE_DELETEQUEUED 0x04 // this transport connection is about to be deleted ++#define T_STATE_IN_CREATION 0x08 // this transport waits for a T_C_T_C_REPLY to become active ++#define T_STATE_IN_DELETION 0x10 // this transport waits for T_D_T_C_REPLY to become idle again ++ ++/** ++ * Opaque type representing a transport layer. ++ */ ++struct en50221_transport_layer; ++ ++/** ++ * Type definition for callback function - used when events are received from a module. ++ * ++ * **IMPORTANT** For all callback reasons except T_CALLBACK_REASON_DATA, an internal lock is held in the ++ * transport layer. Therefore, to avoid deadlock, you *must not* call back into the transport layer for ++ * these reasons. ++ * ++ * However, for T_CALLBACK_REASON_DATA, the internal lock is not held, so calling back into the transport ++ * layer is fine in this case. ++ * ++ * @param arg Private data. ++ * @param reason One of the T_CALLBACK_REASON_* values. ++ * @param data The data. ++ * @param data_length Length of the data. ++ * @param slot_id Slot_id the data was received from. ++ * @param connection_id Connection_id the data was received from. ++ */ ++typedef void (*en50221_tl_callback) (void *arg, int reason, ++ uint8_t * data, ++ uint32_t data_length, ++ uint8_t slot_id, ++ uint8_t connection_id); ++ ++ ++/** ++ * Construct a new instance of the transport layer. ++ * ++ * @param max_slots Maximum number of slots to support. ++ * @param max_connections_per_slot Maximum connections per slot. ++ * @return The en50221_transport_layer instance, or NULL on error. ++ */ ++extern struct en50221_transport_layer *en50221_tl_create(uint8_t max_slots, ++ uint8_t max_connections_per_slot); ++ ++/** ++ * Destroy an instance of the transport layer. ++ * ++ * @param tl The en50221_transport_layer instance. ++ */ ++extern void en50221_tl_destroy(struct en50221_transport_layer *tl); ++ ++/** ++ * Register a new slot with the library. ++ * ++ * @param tl The en50221_transport_layer instance. ++ * @param ca_hndl FD for talking to the slot. ++ * @param slot CAM slot where the requested CAM of the CA is in. ++ * @param response_timeout Maximum timeout in ms to a response we send before signalling a timeout. ++ * @param poll_delay Interval between polls in ms. ++ * @return slot_id on sucess, or -1 on error. ++ */ ++extern int en50221_tl_register_slot(struct en50221_transport_layer *tl, ++ int ca_hndl, uint8_t slot, ++ uint32_t response_timeout, ++ uint32_t poll_delay); ++ ++/** ++ * Destroy a registered slot - e.g. if a CAM is removed, or an error occurs. Does ++ * not attempt to reset the CAM. ++ * ++ * @param tl The en50221_transport_layer instance. ++ * @param slot_id Slot to destroy. ++ */ ++extern void en50221_tl_destroy_slot(struct en50221_transport_layer *tl, uint8_t slot_id); ++ ++/** ++ * Performs one iteration of the transport layer poll - ++ * checking for incoming data furthermore it will handle ++ * the timeouts of certain commands like T_DELETE_T_C it ++ * should be called by the application regularly, generally ++ * faster than the poll delay. ++ * ++ * @param tl The en50221_transport_layer instance. ++ * @return 0 on succes, or -1 if there was an error of some sort. ++ */ ++extern int en50221_tl_poll(struct en50221_transport_layer *tl); ++ ++/** ++ * Register the callback for data reception. ++ * ++ * @param tl The en50221_transport_layer instance. ++ * @param callback The callback. Set to NULL to remove the callback completely. ++ * @param arg Private data passed as arg0 of the callback. ++ */ ++extern void en50221_tl_register_callback(struct en50221_transport_layer *tl, ++ en50221_tl_callback callback, void *arg); ++ ++/** ++ * Gets the ID of the slot an error occurred on. ++ * ++ * @param tl The en50221_transport_layer instance. ++ * @return The offending slot id. ++ */ ++extern int en50221_tl_get_error_slot(struct en50221_transport_layer *tl); ++ ++/** ++ * Gets the last error. ++ * ++ * @param tl The en50221_transport_layer instance. ++ * @return One of the EN50221ERR_* values. ++ */ ++extern int en50221_tl_get_error(struct en50221_transport_layer *tl); ++ ++/** ++ * This function is used to take a data-block, pack into ++ * into a TPDU (DATA_LAST) and send it to the device ++ * ++ * @param tl The en50221_transport_layer instance. ++ * @param slot_id ID of the slot. ++ * @param connection_id Connection id. ++ * @param data Data to send. ++ * @param data_length Number of bytes to send. ++ * @return 0 on success, or -1 on error. ++ */ ++extern int en50221_tl_send_data(struct en50221_transport_layer *tl, ++ uint8_t slot_id, ++ uint8_t connection_id, ++ uint8_t * data, ++ uint32_t data_length); ++ ++/** ++ * This function is used to take a data-block, pack into ++ * into a TPDU (DATA_LAST) and send it to the device ++ * ++ * @param tl The en50221_transport_layer instance. ++ * @param slot_id ID of the slot. ++ * @param connection_id Connection id. ++ * @param vector iov to send. ++ * @param io_count Number of elements in vector. ++ * @return 0 on success, or -1 on error. ++ */ ++extern int en50221_tl_send_datav(struct en50221_transport_layer *tl, ++ uint8_t slot_id, uint8_t connection_id, ++ struct iovec *vector, int iov_count); ++ ++/** ++ * Create a new transport connection to the cam. ++ * ++ * **IMPORTANT** When this function returns, it means the request to create a connection ++ * has been submitted. You will need to poll using en50221_tl_get_connection_state() to find out ++ * if/when the connection is established. A callback with T_CALLBACK_REASON_CONNECTIONOPEN reason ++ * will also be sent when it is acked by the CAM. ++ * ++ * @param tl The en50221_transport_layer instance. ++ * @param slot_id ID of the slot. ++ * @return The allocated connection id on success, or -1 on error. ++ */ ++extern int en50221_tl_new_tc(struct en50221_transport_layer *tl, uint8_t slot_id); ++ ++/** ++ * Deallocates a transport connection. ++ * ++ * **IMPORTANT** When this function returns, it means the request to destroy a connection ++ * has been submitted. You will need to poll using en50221_tl_get_connection_state() to find out ++ * if/when the connection is destroyed. ++ * ++ * @param tl The en50221_transport_layer instance. ++ * @param slot_id ID of the slot. ++ * @param connection_id Connection id to send the request _on_. ++ * @return 0 on success, or -1 on error. ++ */ ++extern int en50221_tl_del_tc(struct en50221_transport_layer *tl, uint8_t slot_id, uint8_t connection_id); ++ ++/** ++ * Checks the state of a connection. ++ * ++ * @param tl The en50221_transport_layer instance. ++ * @param slot_id ID of the slot. ++ * @param connection_id Connection id to send the request _on_. ++ * @return One of the T_STATE_* values. ++ */ ++extern int en50221_tl_get_connection_state(struct en50221_transport_layer *tl, ++ uint8_t slot_id, uint8_t connection_id); ++ ++#ifdef __cplusplus ++} ++#endif ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvben50221/Makefile dvb-apps/lib/libdvben50221/Makefile +--- linuxtv-dvb-apps-1.1.1/lib/libdvben50221/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvben50221/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,49 @@ ++# Makefile for linuxtv.org dvb-apps/lib/libdvben50221 ++ ++includes = asn_1.h \ ++ en50221_app_ai.h \ ++ en50221_app_auth.h \ ++ en50221_app_ca.h \ ++ en50221_app_datetime.h \ ++ en50221_app_dvb.h \ ++ en50221_app_epg.h \ ++ en50221_app_lowspeed.h \ ++ en50221_app_mmi.h \ ++ en50221_app_rm.h \ ++ en50221_app_smartcard.h \ ++ en50221_app_tags.h \ ++ en50221_app_teletext.h \ ++ en50221_app_utils.h \ ++ en50221_errno.h \ ++ en50221_session.h \ ++ en50221_stdcam.h \ ++ en50221_transport.h ++ ++objects = asn_1.o \ ++ en50221_app_ai.o \ ++ en50221_app_auth.o \ ++ en50221_app_ca.o \ ++ en50221_app_datetime.o \ ++ en50221_app_dvb.o \ ++ en50221_app_epg.o \ ++ en50221_app_lowspeed.o \ ++ en50221_app_mmi.o \ ++ en50221_app_rm.o \ ++ en50221_app_smartcard.o \ ++ en50221_app_teletext.o \ ++ en50221_app_utils.o \ ++ en50221_session.o \ ++ en50221_stdcam.o \ ++ en50221_stdcam_hlci.o \ ++ en50221_stdcam_llci.o \ ++ en50221_transport.o ++ ++lib_name = libdvben50221 ++ ++CPPFLAGS += -I../../lib -DLOG_LEVEL=1 # FIXME ++ ++.PHONY: all ++ ++all: library ++ ++include ../../Make.rules +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbmisc/dvbmisc.h dvb-apps/lib/libdvbmisc/dvbmisc.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvbmisc/dvbmisc.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbmisc/dvbmisc.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,72 @@ ++/* ++ libdvbmisc - DVB miscellaneous library ++ ++ Copyright (C) 2005 Manu Abraham ++ ++ This library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ This library 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 ++ Lesser General Public License for more details. ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++*/ ++ ++#ifndef DVB_MISC_H ++#define DVB_MISC_H ++ ++#include ++#include ++#include ++#include ++ ++#define ERROR 0 ++#define NOTICE 1 ++#define INFO 2 ++#define DEBUG 3 ++ ++#define print(x, y, z, fmt, arg...) do { \ ++ if (z) { \ ++ if ((x > ERROR) && (x > y)) \ ++ vprint("%s: " fmt "\n", __func__ , ##arg); \ ++ else if ((x > NOTICE) && (x > y)) \ ++ vprint("%s: " fmt "\n",__func__ , ##arg); \ ++ else if ((x > INFO) && (x > y)) \ ++ vprint("%s: " fmt "\n", __func__ , ##arg); \ ++ else if ((x > DEBUG) && (x > y)) \ ++ vprint("%s: " fmt "\n", __func__ , ##arg); \ ++ } else { \ ++ if (x > y) \ ++ vprint(fmt, ##arg); \ ++ } \ ++} while(0) ++ ++static inline void vprint(char *fmt, ...) ++{ ++ va_list args; ++ ++ va_start(args, fmt); ++ vfprintf(stderr, fmt, args); ++ va_end(args); ++} ++ ++static inline int time_after(struct timeval oldtime, uint32_t delta_ms) ++{ ++ // calculate the oldtime + add on the delta ++ uint64_t oldtime_ms = (oldtime.tv_sec * 1000) + (oldtime.tv_usec / 1000); ++ oldtime_ms += delta_ms; ++ ++ // calculate the nowtime ++ struct timeval nowtime; ++ gettimeofday(&nowtime, 0); ++ uint64_t nowtime_ms = (nowtime.tv_sec * 1000) + (nowtime.tv_usec / 1000); ++ ++ // check ++ return nowtime_ms > oldtime_ms; ++} ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbsec/dvbsec_api.c dvb-apps/lib/libdvbsec/dvbsec_api.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvbsec/dvbsec_api.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbsec/dvbsec_api.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,951 @@ ++/* ++ libdvbsec - an SEC library ++ ++ Copyright (C) 2005 Manu Abraham ++ Copyright (C) 2006 Andrew de Quincey ++ ++ This library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ This library 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 ++ Lesser General Public License for more details. ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++*/ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "dvbsec_api.h" ++ ++// uncomment this to make dvbsec_command print out debug instead of talking to a frontend ++// #define TEST_SEC_COMMAND 1 ++ ++int dvbsec_set(struct dvbfe_handle *fe, ++ struct dvbsec_config *sec_config, ++ enum dvbsec_diseqc_polarization polarization, ++ enum dvbsec_diseqc_switch sat_pos, ++ enum dvbsec_diseqc_switch switch_option, ++ struct dvbfe_parameters *params, ++ int timeout) ++{ ++ int tmp; ++ struct dvbfe_parameters localparams; ++ struct dvbfe_parameters *topass = params; ++ ++ // perform SEC ++ if (sec_config != NULL) { ++ switch(sec_config->config_type) { ++ case DVBSEC_CONFIG_NONE: ++ break; ++ ++ case DVBSEC_CONFIG_POWER: ++ dvbfe_set_voltage(fe, DVBFE_SEC_VOLTAGE_13); ++ break; ++ ++ case DVBSEC_CONFIG_STANDARD: ++ { ++ // calculate the correct oscillator value ++ enum dvbsec_diseqc_oscillator osc = DISEQC_OSCILLATOR_LOW; ++ if (sec_config->switch_frequency && (sec_config->switch_frequency < params->frequency)) ++ osc = DISEQC_OSCILLATOR_HIGH; ++ ++ if ((tmp = dvbsec_std_sequence(fe, ++ osc, ++ polarization, ++ sat_pos, ++ switch_option)) < 0) ++ return tmp; ++ break; ++ } ++ ++ case DVBSEC_CONFIG_ADVANCED: ++ { ++ // are we high or not? ++ int high = 0; ++ if (sec_config->switch_frequency && (sec_config->switch_frequency < params->frequency)) ++ high = 1; ++ ++ // determine correct string ++ char *cmd = NULL; ++ switch(polarization) { ++ case DISEQC_POLARIZATION_H: ++ if (!high) ++ cmd = sec_config->adv_cmd_lo_h; ++ else ++ cmd = sec_config->adv_cmd_hi_h; ++ break; ++ case DISEQC_POLARIZATION_V: ++ if (!high) ++ cmd = sec_config->adv_cmd_lo_v; ++ else ++ cmd = sec_config->adv_cmd_hi_v; ++ break; ++ case DISEQC_POLARIZATION_L: ++ if (!high) ++ cmd = sec_config->adv_cmd_lo_l; ++ else ++ cmd = sec_config->adv_cmd_hi_l; ++ break; ++ case DISEQC_POLARIZATION_R: ++ if (!high) ++ cmd = sec_config->adv_cmd_lo_r; ++ else ++ cmd = sec_config->adv_cmd_hi_r; ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ // do it ++ if (cmd) ++ if ((tmp = dvbsec_command(fe, cmd)) < 0) ++ return tmp; ++ break; ++ } ++ } ++ ++ // work out the correct LOF value ++ uint32_t lof = 0; ++ if ((sec_config->switch_frequency == 0) || (params->frequency < sec_config->switch_frequency)) { ++ // LOW band ++ switch(polarization) { ++ case DISEQC_POLARIZATION_H: ++ lof = sec_config->lof_lo_h; ++ break; ++ case DISEQC_POLARIZATION_V: ++ lof = sec_config->lof_lo_v; ++ break; ++ case DISEQC_POLARIZATION_L: ++ lof = sec_config->lof_lo_l; ++ break; ++ case DISEQC_POLARIZATION_R: ++ lof = sec_config->lof_lo_r; ++ break; ++ case DISEQC_POLARIZATION_UNCHANGED: ++ break; ++ } ++ } else { ++ // HIGH band ++ switch(polarization) { ++ case DISEQC_POLARIZATION_H: ++ lof = sec_config->lof_hi_h; ++ break; ++ case DISEQC_POLARIZATION_V: ++ lof = sec_config->lof_hi_v; ++ break; ++ case DISEQC_POLARIZATION_L: ++ lof = sec_config->lof_hi_l; ++ break; ++ case DISEQC_POLARIZATION_R: ++ lof = sec_config->lof_hi_r; ++ break; ++ case DISEQC_POLARIZATION_UNCHANGED: ++ break; ++ } ++ } ++ ++ // do frequency adjustment ++ if (lof) { ++ memcpy(&localparams, params, sizeof(struct dvbfe_parameters)); ++ int tmpfreq = localparams.frequency - lof; ++ ++ if (tmpfreq < 0) ++ tmpfreq *= -1; ++ localparams.frequency = (uint32_t) tmpfreq; ++ topass = &localparams; ++ } ++ } ++ ++ // set the frontend! ++ return dvbfe_set(fe, topass, timeout); ++} ++ ++int dvbsec_std_sequence(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_oscillator oscillator, ++ enum dvbsec_diseqc_polarization polarization, ++ enum dvbsec_diseqc_switch sat_pos, ++ enum dvbsec_diseqc_switch switch_option) ++{ ++ dvbfe_set_22k_tone(fe, DVBFE_SEC_TONE_OFF); ++ ++ switch(polarization) { ++ case DISEQC_POLARIZATION_V: ++ case DISEQC_POLARIZATION_R: ++ dvbfe_set_voltage(fe, DVBFE_SEC_VOLTAGE_13); ++ break; ++ case DISEQC_POLARIZATION_H: ++ case DISEQC_POLARIZATION_L: ++ dvbfe_set_voltage(fe, DVBFE_SEC_VOLTAGE_18); ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ dvbsec_diseqc_set_committed_switches(fe, ++ DISEQC_ADDRESS_ANY_DEVICE, ++ oscillator, ++ polarization, ++ sat_pos, ++ switch_option); ++ ++ usleep(15000); ++ ++ switch(sat_pos) { ++ case DISEQC_SWITCH_A: ++ dvbfe_set_tone_data_burst(fe, DVBFE_SEC_MINI_A); ++ break; ++ case DISEQC_SWITCH_B: ++ dvbfe_set_tone_data_burst(fe, DVBFE_SEC_MINI_B); ++ break; ++ default: ++ break; ++ } ++ ++ if (sat_pos != DISEQC_SWITCH_UNCHANGED) ++ usleep(15000); ++ ++ switch(oscillator) { ++ case DISEQC_OSCILLATOR_LOW: ++ dvbfe_set_22k_tone(fe, DVBFE_SEC_TONE_OFF); ++ break; ++ case DISEQC_OSCILLATOR_HIGH: ++ dvbfe_set_22k_tone(fe, DVBFE_SEC_TONE_ON); ++ break; ++ default: ++ break; ++ } ++ ++ return 0; ++} ++ ++int dvbsec_diseqc_set_reset(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ enum dvbsec_diseqc_reset state) ++{ ++ uint8_t data[] = { DISEQC_FRAMING_MASTER_NOREPLY, address, 0x00 }; ++ ++ if (state == DISEQC_RESET_CLEAR) ++ data[2] = 0x01; ++ ++ return dvbfe_do_diseqc_command(fe, data, sizeof(data)); ++} ++ ++int dvbsec_diseqc_set_power(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ enum dvbsec_diseqc_power state) ++{ ++ uint8_t data[] = { DISEQC_FRAMING_MASTER_NOREPLY, address, 0x02 }; ++ ++ if (state == DISEQC_POWER_ON) ++ data[2] = 0x03; ++ ++ return dvbfe_do_diseqc_command(fe, data, sizeof(data)); ++} ++ ++int dvbsec_diseqc_set_listen(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ enum dvbsec_diseqc_listen state) ++{ ++ uint8_t data[] = { DISEQC_FRAMING_MASTER_NOREPLY, address, 0x30 }; ++ ++ if (state == DISEQC_LISTEN_AWAKE) ++ data[2] = 0x31; ++ ++ return dvbfe_do_diseqc_command(fe, data, sizeof(data)); ++} ++ ++int dvbsec_diseqc_set_committed_switches(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ enum dvbsec_diseqc_oscillator oscillator, ++ enum dvbsec_diseqc_polarization polarization, ++ enum dvbsec_diseqc_switch sat_pos, ++ enum dvbsec_diseqc_switch switch_option) ++{ ++ uint8_t data[] = { DISEQC_FRAMING_MASTER_NOREPLY, address, 0x38, 0x00 }; ++ ++ switch(oscillator) { ++ case DISEQC_OSCILLATOR_LOW: ++ data[3] |= 0x10; ++ break; ++ case DISEQC_OSCILLATOR_HIGH: ++ data[3] |= 0x11; ++ break; ++ case DISEQC_OSCILLATOR_UNCHANGED: ++ break; ++ } ++ switch(polarization) { ++ case DISEQC_POLARIZATION_V: ++ case DISEQC_POLARIZATION_R: ++ data[3] |= 0x20; ++ break; ++ case DISEQC_POLARIZATION_H: ++ case DISEQC_POLARIZATION_L: ++ data[3] |= 0x22; ++ break; ++ default: ++ break; ++ } ++ switch(sat_pos) { ++ case DISEQC_SWITCH_A: ++ data[3] |= 0x40; ++ break; ++ case DISEQC_SWITCH_B: ++ data[3] |= 0x44; ++ break; ++ case DISEQC_SWITCH_UNCHANGED: ++ break; ++ } ++ switch(switch_option) { ++ case DISEQC_SWITCH_A: ++ data[3] |= 0x80; ++ break; ++ case DISEQC_SWITCH_B: ++ data[3] |= 0x88; ++ break; ++ case DISEQC_SWITCH_UNCHANGED: ++ break; ++ } ++ ++ if (data[3] == 0) ++ return 0; ++ ++ return dvbfe_do_diseqc_command(fe, data, sizeof(data)); ++} ++ ++int dvbsec_diseqc_set_uncommitted_switches(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ enum dvbsec_diseqc_switch s1, ++ enum dvbsec_diseqc_switch s2, ++ enum dvbsec_diseqc_switch s3, ++ enum dvbsec_diseqc_switch s4) ++{ ++ uint8_t data[] = { DISEQC_FRAMING_MASTER_NOREPLY, address, 0x39, 0x00 }; ++ ++ switch(s1) { ++ case DISEQC_SWITCH_A: ++ data[3] |= 0x10; ++ break; ++ case DISEQC_SWITCH_B: ++ data[3] |= 0x11; ++ break; ++ case DISEQC_SWITCH_UNCHANGED: ++ break; ++ } ++ switch(s2) { ++ case DISEQC_SWITCH_A: ++ data[3] |= 0x20; ++ break; ++ case DISEQC_SWITCH_B: ++ data[3] |= 0x22; ++ break; ++ case DISEQC_SWITCH_UNCHANGED: ++ break; ++ } ++ switch(s3) { ++ case DISEQC_SWITCH_A: ++ data[3] |= 0x40; ++ break; ++ case DISEQC_SWITCH_B: ++ data[3] |= 0x44; ++ break; ++ case DISEQC_SWITCH_UNCHANGED: ++ break; ++ } ++ switch(s4) { ++ case DISEQC_SWITCH_A: ++ data[3] |= 0x80; ++ break; ++ case DISEQC_SWITCH_B: ++ data[3] |= 0x88; ++ break; ++ case DISEQC_SWITCH_UNCHANGED: ++ break; ++ } ++ ++ if (data[3] == 0) ++ return 0; ++ ++ return dvbfe_do_diseqc_command(fe, data, sizeof(data)); ++} ++ ++int dvbsec_diseqc_set_analog_value(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ enum dvbsec_diseqc_analog_id id, ++ uint8_t value) ++{ ++ uint8_t data[] = { DISEQC_FRAMING_MASTER_NOREPLY, address, 0x48, value }; ++ ++ if (id == DISEQC_ANALOG_ID_A1) ++ data[2] = 0x49; ++ ++ return dvbfe_do_diseqc_command(fe, data, sizeof(data)); ++} ++ ++int dvbsec_diseqc_set_frequency(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ uint32_t frequency) ++{ ++ uint8_t data[] = { DISEQC_FRAMING_MASTER_NOREPLY, address, 0x58, 0x00, 0x00, 0x00 }; ++ int len = 5; ++ ++ uint32_t bcdval = 0; ++ int i; ++ for(i=0; i<=24;i+=4) { ++ bcdval |= ((frequency % 10) << i); ++ frequency /= 10; ++ } ++ ++ data[3] = bcdval >> 16; ++ data[4] = bcdval >> 8; ++ if (bcdval & 0xff) { ++ data[5] = bcdval; ++ len++; ++ } ++ ++ return dvbfe_do_diseqc_command(fe, data, len); ++} ++ ++int dvbsec_diseqc_set_channel(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ uint16_t channel) ++{ ++ uint8_t data[] = { DISEQC_FRAMING_MASTER_NOREPLY, address, 0x59, 0x00, 0x00}; ++ ++ data[3] = channel >> 8; ++ data[4] = channel; ++ ++ return dvbfe_do_diseqc_command(fe, data, sizeof(data)); ++} ++ ++int dvbsec_diseqc_halt_satpos(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address) ++{ ++ uint8_t data[] = { DISEQC_FRAMING_MASTER_NOREPLY, address, 0x60}; ++ ++ return dvbfe_do_diseqc_command(fe, data, sizeof(data)); ++} ++ ++int dvbsec_diseqc_disable_satpos_limits(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address) ++{ ++ uint8_t data[] = { DISEQC_FRAMING_MASTER_NOREPLY, address, 0x63}; ++ ++ return dvbfe_do_diseqc_command(fe, data, sizeof(data)); ++} ++ ++int dvbsec_diseqc_set_satpos_limit(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ enum dvbsec_diseqc_direction direction) ++{ ++ uint8_t data[] = { DISEQC_FRAMING_MASTER_NOREPLY, address, 0x66}; ++ ++ if (direction == DISEQC_DIRECTION_WEST) ++ data[2] = 0x67; ++ ++ return dvbfe_do_diseqc_command(fe, data, sizeof(data)); ++} ++ ++int dvbsec_diseqc_drive_satpos_motor(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ enum dvbsec_diseqc_direction direction, ++ enum dvbsec_diseqc_drive_mode mode, ++ uint8_t value) ++{ ++ uint8_t data[] = { DISEQC_FRAMING_MASTER_NOREPLY, address, 0x68, 0x00}; ++ ++ if (direction == DISEQC_DIRECTION_WEST) ++ data[2] = 0x69; ++ ++ switch(mode) { ++ case DISEQC_DRIVE_MODE_STEPS: ++ data[3] = (value & 0x7f) | 0x80; ++ break; ++ case DISEQC_DRIVE_MODE_TIMEOUT: ++ data[3] = value & 0x7f; ++ break; ++ } ++ ++ return dvbfe_do_diseqc_command(fe, data, sizeof(data)); ++} ++ ++int dvbsec_diseqc_store_satpos_preset(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ uint8_t id) ++{ ++ uint8_t data[] = { DISEQC_FRAMING_MASTER_NOREPLY, address, 0x6A, id}; ++ ++ return dvbfe_do_diseqc_command(fe, data, sizeof(data)); ++} ++ ++int dvbsec_diseqc_goto_satpos_preset(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ uint8_t id) ++{ ++ uint8_t data[] = { DISEQC_FRAMING_MASTER_NOREPLY, address, 0x6B, id}; ++ ++ return dvbfe_do_diseqc_command(fe, data, sizeof(data)); ++} ++ ++int dvbsec_diseqc_recalculate_satpos_positions(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ int val1, ++ int val2) ++{ ++ uint8_t data[] = { DISEQC_FRAMING_MASTER_NOREPLY, address, 0x6F, 0x00, 0x00}; ++ int len = 3; ++ ++ if (val1 != -1) { ++ data[3] = val1; ++ len++; ++ } ++ if (val2 != -1) { ++ data[4] = val2; ++ len = 5; ++ } ++ ++ return dvbfe_do_diseqc_command(fe, data, len); ++} ++ ++int dvbsec_diseqc_goto_rotator_bearing(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ float angle) ++{ ++ int integer = (int) angle; ++ uint8_t data[] = { DISEQC_FRAMING_MASTER_NOREPLY, address, 0x6e, 0x00, 0x00}; ++ ++ // transform the fraction into the correct representation ++ int fraction = (int) (((angle - integer) * 16.0) + 0.9) & 0x0f; ++ switch(fraction) { ++ case 1: ++ case 4: ++ case 7: ++ case 9: ++ case 12: ++ case 15: ++ fraction--; ++ break; ++ } ++ ++ // generate the command ++ if (integer < -256) { ++ return -EINVAL; ++ } else if (integer < 0) { ++ integer = -integer; ++ data[3] = 0xf0; ++ } else if (integer < 256) { ++ data[3] = 0x00; ++ } else if (integer < 512) { ++ integer -= 256; ++ data[3] = 0x10; ++ } else { ++ return -EINVAL; ++ } ++ data[3] |= ((integer / 16) & 0x0f); ++ integer = integer % 16; ++ data[4] |= ((integer & 0x0f) << 4) | fraction; ++ ++ return dvbfe_do_diseqc_command(fe, data, sizeof(data)); ++} ++ ++static int skipwhite(char **line, char *end) ++{ ++ while(**line) { ++ if (end && (*line >= end)) ++ return -1; ++ if (!isspace(**line)) ++ return 0; ++ (*line)++; ++ } ++ ++ return -1; ++} ++ ++static int getstringupto(char **line, char *end, char *matches, char **ptrdest, int *ptrlen) ++{ ++ char *start = *line; ++ ++ while(**line) { ++ if (end && (*line >= end)) ++ break; ++ if (strchr(matches, **line)) { ++ *ptrdest = start; ++ *ptrlen = *line - start; ++ return 0; ++ } ++ (*line)++; ++ } ++ ++ *ptrdest = start; ++ *ptrlen = *line - start; ++ return 0; ++} ++ ++static int parsefunction(char **line, ++ char **nameptr, int *namelen, ++ char **argsptr, int *argslen) ++{ ++ if (skipwhite(line, NULL)) ++ return -1; ++ ++ if (getstringupto(line, NULL, "(", nameptr, namelen)) ++ return -1; ++ if ((*line) == 0) ++ return -1; ++ (*line)++; // skip the '(' ++ if (getstringupto(line, NULL, ")", argsptr, argslen)) ++ return -1; ++ if ((*line) == 0) ++ return -1; ++ (*line)++; // skip the ')' ++ ++ return 0; ++} ++ ++static int parseintarg(char **args, char *argsend, int *result) ++{ ++ char tmp[32]; ++ char *arg; ++ int arglen; ++ ++ // skip whitespace ++ if (skipwhite(args, argsend)) ++ return -1; ++ ++ // get the arg ++ if (getstringupto(args, argsend, ",", &arg, &arglen)) ++ return -1; ++ if ((**args) == ',') ++ (*args)++; // skip the ',' if present ++ if (arglen > 31) ++ arglen = 31; ++ strncpy(tmp, arg, arglen); ++ tmp[arglen] = 0; ++ ++ if (sscanf(tmp, "%i", result) != 1) ++ return -1; ++ ++ return 0; ++} ++ ++static int parsechararg(char **args, char *argsend, int *result) ++{ ++ char *arg; ++ int arglen; ++ ++ // skip whitespace ++ if (skipwhite(args, argsend)) ++ return -1; ++ ++ // get the arg ++ if (getstringupto(args, argsend, ",", &arg, &arglen)) ++ return -1; ++ if ((**args) == ',') ++ (*args)++; // skip the ',' if present ++ if (arglen > 0) ++ *result = arg[0]; ++ ++ return 0; ++} ++ ++static int parsefloatarg(char **args, char *argsend, float *result) ++{ ++ char tmp[32]; ++ char *arg; ++ int arglen; ++ ++ // skip whitespace ++ if (skipwhite(args, argsend)) ++ return -1; ++ ++ // get the arg ++ if (getstringupto(args, argsend, ",", &arg, &arglen)) ++ return -1; ++ if ((**args) == ',') ++ (*args)++; // skip the ',' if present ++ if (arglen > 31) ++ arglen = 31; ++ strncpy(tmp, arg, arglen); ++ arg[arglen] = 0; ++ ++ if (sscanf(tmp, "%f", result) != 1) ++ return -1; ++ ++ return 0; ++} ++ ++static enum dvbsec_diseqc_switch parse_switch(int c) ++{ ++ switch(toupper(c)) { ++ case 'A': ++ return DISEQC_SWITCH_A; ++ case 'B': ++ return DISEQC_SWITCH_B; ++ default: ++ return DISEQC_SWITCH_UNCHANGED; ++ } ++} ++ ++int dvbsec_command(struct dvbfe_handle *fe, char *command) ++{ ++ char *name; ++ char *args; ++ int namelen; ++ int argslen; ++ int address; ++ int iarg; ++ int iarg2; ++ int iarg3; ++ int iarg4; ++ float farg; ++ ++ while(!parsefunction(&command, &name, &namelen, &args, &argslen)) { ++ char *argsend = args+argslen; ++ ++ if (!strncasecmp(name, "tone", namelen)) { ++ if (parsechararg(&args, argsend, &iarg)) ++ return -1; ++ ++#ifdef TEST_SEC_COMMAND ++ printf("tone: %c\n", iarg); ++#else ++ if (toupper(iarg) == 'B') { ++ dvbfe_set_22k_tone(fe, DVBFE_SEC_TONE_ON); ++ } else { ++ dvbfe_set_22k_tone(fe, DVBFE_SEC_TONE_OFF); ++ } ++#endif ++ } else if (!strncasecmp(name, "voltage", namelen)) { ++ if (parseintarg(&args, argsend, &iarg)) ++ return -1; ++ ++#ifdef TEST_SEC_COMMAND ++ printf("voltage: %i\n", iarg); ++#else ++ switch(iarg) { ++ case 0: ++ dvbfe_set_voltage(fe, DVBFE_SEC_VOLTAGE_OFF); ++ break; ++ case 13: ++ dvbfe_set_voltage(fe, DVBFE_SEC_VOLTAGE_13); ++ break; ++ case 18: ++ dvbfe_set_voltage(fe, DVBFE_SEC_VOLTAGE_18); ++ break; ++ default: ++ return -1; ++ } ++#endif ++ } else if (!strncasecmp(name, "toneburst", namelen)) { ++ if (parsechararg(&args, argsend, &iarg)) ++ return -1; ++ ++#ifdef TEST_SEC_COMMAND ++ printf("toneburst: %c\n", iarg); ++#else ++ if (toupper(iarg) == 'B') { ++ dvbfe_set_tone_data_burst(fe, DVBFE_SEC_MINI_B); ++ } else { ++ dvbfe_set_tone_data_burst(fe, DVBFE_SEC_MINI_A); ++ } ++#endif ++ } else if (!strncasecmp(name, "highvoltage", namelen)) { ++ if (parseintarg(&args, argsend, &iarg)) ++ return -1; ++ ++#ifdef TEST_SEC_COMMAND ++ printf("highvoltage: %i\n", iarg); ++#else ++ dvbfe_set_high_lnb_voltage(fe, iarg ? 1 : 0); ++#endif ++ } else if (!strncasecmp(name, "dishnetworks", namelen)) { ++ if (parseintarg(&args, argsend, &iarg)) ++ return -1; ++ ++#ifdef TEST_SEC_COMMAND ++ printf("dishnetworks: %i\n", iarg); ++#else ++ dvbfe_do_dishnetworks_legacy_command(fe, iarg); ++#endif ++ } else if (!strncasecmp(name, "wait", namelen)) { ++ if (parseintarg(&args, argsend, &iarg)) ++ return -1; ++ ++#ifdef TEST_SEC_COMMAND ++ printf("wait: %i\n", iarg); ++#else ++ if (iarg) ++ usleep(iarg * 1000); ++#endif ++ } else if (!strncasecmp(name, "Dreset", namelen)) { ++ if (parseintarg(&args, argsend, &address)) ++ return -1; ++ if (parseintarg(&args, argsend, &iarg)) ++ return -1; ++ ++#ifdef TEST_SEC_COMMAND ++ printf("Dreset: %i %i\n", address, iarg); ++#else ++ if (iarg) { ++ dvbsec_diseqc_set_reset(fe, address, DISEQC_RESET); ++ } else { ++ dvbsec_diseqc_set_reset(fe, address, DISEQC_RESET_CLEAR); ++ } ++#endif ++ } else if (!strncasecmp(name, "Dpower", namelen)) { ++ if (parseintarg(&args, argsend, &address)) ++ return -1; ++ if (parseintarg(&args, argsend, &iarg)) ++ return -1; ++ ++#ifdef TEST_SEC_COMMAND ++ printf("Dpower: %i %i\n", address, iarg); ++#else ++ if (iarg) { ++ dvbsec_diseqc_set_power(fe, address, DISEQC_POWER_ON); ++ } else { ++ dvbsec_diseqc_set_power(fe, address, DISEQC_POWER_OFF); ++ } ++#endif ++ } else if (!strncasecmp(name, "Dcommitted", namelen)) { ++ if (parseintarg(&args, argsend, &address)) ++ return -1; ++ if (parsechararg(&args, argsend, &iarg)) ++ return -1; ++ if (parsechararg(&args, argsend, &iarg2)) ++ return -1; ++ if (parsechararg(&args, argsend, &iarg3)) ++ return -1; ++ if (parsechararg(&args, argsend, &iarg4)) ++ return -1; ++ ++ enum dvbsec_diseqc_oscillator oscillator; ++ switch(toupper(iarg)) { ++ case 'H': ++ oscillator = DISEQC_OSCILLATOR_HIGH; ++ break; ++ case 'L': ++ oscillator = DISEQC_OSCILLATOR_LOW; ++ break; ++ default: ++ oscillator = DISEQC_OSCILLATOR_UNCHANGED; ++ break; ++ } ++ ++ int polarization = -1; ++ switch(toupper(iarg2)) { ++ case 'H': ++ polarization = DISEQC_POLARIZATION_H; ++ break; ++ case 'V': ++ polarization = DISEQC_POLARIZATION_V; ++ break; ++ case 'L': ++ polarization = DISEQC_POLARIZATION_L; ++ break; ++ case 'R': ++ polarization = DISEQC_POLARIZATION_R; ++ break; ++ default: ++ polarization = -1; ++ break; ++ } ++ ++#ifdef TEST_SEC_COMMAND ++ printf("Dcommitted: %i %i %i %i %i\n", address, ++ oscillator, ++ polarization, ++ parse_switch(iarg3), ++ parse_switch(iarg4)); ++#else ++ dvbsec_diseqc_set_committed_switches(fe, address, ++ oscillator, ++ polarization, ++ parse_switch(iarg3), ++ parse_switch(iarg4)); ++#endif ++ } else if (!strncasecmp(name, "Duncommitted", namelen)) { ++ if (parsechararg(&args, argsend, &address)) ++ return -1; ++ if (parsechararg(&args, argsend, &iarg)) ++ return -1; ++ if (parsechararg(&args, argsend, &iarg2)) ++ return -1; ++ if (parsechararg(&args, argsend, &iarg3)) ++ return -1; ++ if (parsechararg(&args, argsend, &iarg4)) ++ return -1; ++ ++#ifdef TEST_SEC_COMMAND ++ printf("Duncommitted: %i %i %i %i %i\n", address, ++ parse_switch(iarg), ++ parse_switch(iarg2), ++ parse_switch(iarg3), ++ parse_switch(iarg4)); ++#else ++ dvbsec_diseqc_set_uncommitted_switches(fe, address, ++ parse_switch(iarg), ++ parse_switch(iarg2), ++ parse_switch(iarg3), ++ parse_switch(iarg4)); ++#endif ++ } else if (!strncasecmp(name, "Dfrequency", namelen)) { ++ if (parseintarg(&args, argsend, &address)) ++ return -1; ++ if (parseintarg(&args, argsend, &iarg)) ++ return -1; ++ ++#ifdef TEST_SEC_COMMAND ++ printf("Dfrequency: %i %i\n", address, iarg); ++#else ++ dvbsec_diseqc_set_frequency(fe, address, iarg); ++#endif ++ } else if (!strncasecmp(name, "Dchannel", namelen)) { ++ if (parseintarg(&args, argsend, &address)) ++ return -1; ++ if (parseintarg(&args, argsend, &iarg)) ++ return -1; ++ ++#ifdef TEST_SEC_COMMAND ++ printf("Dchannel: %i %i\n", address, iarg); ++#else ++ dvbsec_diseqc_set_channel(fe, address, iarg); ++#endif ++ } else if (!strncasecmp(name, "Dgotopreset", namelen)) { ++ if (parseintarg(&args, argsend, &address)) ++ return -1; ++ if (parseintarg(&args, argsend, &iarg)) ++ return -1; ++ ++#ifdef TEST_SEC_COMMAND ++ printf("Dgotopreset: %i %i\n", address, iarg); ++#else ++ dvbsec_diseqc_goto_satpos_preset(fe, address, iarg); ++#endif ++ } else if (!strncasecmp(name, "Dgotobearing", namelen)) { ++ if (parseintarg(&args, argsend, &address)) ++ return -1; ++ if (parsefloatarg(&args, argsend, &farg)) ++ return -1; ++ ++#ifdef TEST_SEC_COMMAND ++ printf("Dgotobearing: %i %f\n", address, farg); ++#else ++ dvbsec_diseqc_goto_rotator_bearing(fe, address, farg); ++#endif ++ } else { ++ return -1; ++ } ++ } ++ ++ return 0; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbsec/dvbsec_api.h dvb-apps/lib/libdvbsec/dvbsec_api.h +--- linuxtv-dvb-apps-1.1.1/lib/libdvbsec/dvbsec_api.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbsec/dvbsec_api.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,436 @@ ++/* ++ libdvbsec - an SEC library ++ ++ Copyright (C) 2005 Manu Abraham ++ Copyright (C) 2006 Andrew de Quincey ++ ++ This library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ This library 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 ++ Lesser General Public License for more details. ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++*/ ++ ++#ifndef DVBSEC_API_H ++#define DVBSEC_API_H 1 ++ ++#include ++ ++struct dvbfe_handle; ++struct dvbfe_parameters; ++ ++enum dvbsec_diseqc_framing { ++ DISEQC_FRAMING_MASTER_NOREPLY = 0xE0, ++ DISEQC_FRAMING_MASTER_NOREPLY_REPEAT = 0xE1, ++ DISEQC_FRAMING_MASTER_REPLY = 0xE2, ++ DISEQC_FRAMING_MASTER_REPLY_REPEAT = 0xE3, ++ DISEQC_FRAMING_SLAVE_OK = 0xE4, ++ DISEQC_FRAMING_SLAVE_UNSUPPORTED = 0xE5, ++ DISEQC_FRAMING_SLAVE_PARITY_ERROR = 0xE6, ++ DISEQC_FRAMING_SLAVE_UNRECOGNISED = 0xE7, ++}; ++ ++enum dvbsec_diseqc_address { ++ DISEQC_ADDRESS_ANY_DEVICE = 0x00, ++ ++ DISEQC_ADDRESS_ANY_LNB_SWITCHER_SMATV = 0x10, ++ DISEQC_ADDRESS_LNB = 0x11, ++ DISEQC_ADDRESS_LNB_WITH_LOOP = 0x12, ++ DISEQC_ADDRESS_SWITCHER = 0x14, ++ DISEQC_ADDRESS_SWITCHER_WITH_LOOP = 0x15, ++ DISEQC_ADDRESS_SMATV = 0x18, ++ ++ DISEQC_ADDRESS_ANY_POLARISER = 0x20, ++ DISEQC_ADDRESS_LINEAR_POLARISER = 0x21, ++ ++ DISEQC_ADDRESS_ANY_POSITIONER = 0x30, ++ DISEQC_ADDRESS_POLAR_AZIMUTH_POSITIONER = 0x31, ++ DISEQC_ADDRESS_ELEVATION_POSITIONER = 0x32, ++ ++ DISEQC_ADDRESS_ANY_INSTALLER_AID = 0x40, ++ DISEQC_ADDRESS_SIGNAL_STRENGTH = 0x41, ++ ++ DISEQC_ADDRESS_ANY_INTERFACE = 0x70, ++ DISEQC_ADDRESS_HEADEND_INTERFACE = 0x71, ++ ++ DISEQC_ADDRESS_REALLOC_BASE = 0x60, ++ DISEQC_ADDRESS_OEM_BASE = 0xf0, ++}; ++ ++enum dvbsec_diseqc_reset { ++ DISEQC_RESET, ++ DISEQC_RESET_CLEAR, ++}; ++ ++enum dvbsec_diseqc_power { ++ DISEQC_POWER_OFF, ++ DISEQC_POWER_ON, ++}; ++ ++enum dvbsec_diseqc_listen { ++ DISEQC_LISTEN_SLEEP, ++ DISEQC_LISTEN_AWAKE, ++}; ++ ++enum dvbsec_diseqc_polarization { ++ DISEQC_POLARIZATION_UNCHANGED = 0, ++ DISEQC_POLARIZATION_H = 'h', ++ DISEQC_POLARIZATION_V = 'v', ++ DISEQC_POLARIZATION_L = 'l', ++ DISEQC_POLARIZATION_R = 'r', ++}; ++ ++enum dvbsec_diseqc_oscillator { ++ DISEQC_OSCILLATOR_UNCHANGED = 0, ++ DISEQC_OSCILLATOR_LOW, ++ DISEQC_OSCILLATOR_HIGH, ++}; ++ ++enum dvbsec_diseqc_switch { ++ DISEQC_SWITCH_UNCHANGED = 0, ++ DISEQC_SWITCH_A, ++ DISEQC_SWITCH_B, ++}; ++ ++enum dvbsec_diseqc_analog_id { ++ DISEQC_ANALOG_ID_A0, ++ DISEQC_ANALOG_ID_A1, ++}; ++ ++enum dvbsec_diseqc_drive_mode { ++ DISEQC_DRIVE_MODE_STEPS, ++ DISEQC_DRIVE_MODE_TIMEOUT, ++}; ++ ++enum dvbsec_diseqc_direction { ++ DISEQC_DIRECTION_EAST, ++ DISEQC_DIRECTION_WEST, ++}; ++ ++enum dvbsec_config_type { ++ DVBSEC_CONFIG_NONE = 0, ++ DVBSEC_CONFIG_POWER, ++ DVBSEC_CONFIG_STANDARD, ++ DVBSEC_CONFIG_ADVANCED, ++}; ++ ++ ++#define MAX_SEC_CMD_LEN 100 ++ ++struct dvbsec_config ++{ ++ char id[32]; /* ID of this SEC config structure */ ++ uint32_t switch_frequency; /* switching frequency - supply 0 for none. */ ++ uint32_t lof_lo_v; /* frequency to subtract for V + LOW band channels - or for switch_frequency == 0 */ ++ uint32_t lof_lo_h; /* frequency to subtract for H + LOW band channels - or for switch_frequency == 0 */ ++ uint32_t lof_lo_l; /* frequency to subtract for L + LOW band channels - or for switch_frequency == 0 */ ++ uint32_t lof_lo_r; /* frequency to subtract for R + LOW band channels - or for switch_frequency == 0 */ ++ uint32_t lof_hi_v; /* frequency to subtract for V + HIGH band channels */ ++ uint32_t lof_hi_h; /* frequency to subtract for H + HIGH band channels */ ++ uint32_t lof_hi_l; /* frequency to subtract for L + HIGH band channels */ ++ uint32_t lof_hi_r; /* frequency to subtract for R + HIGH band channels */ ++ ++ /** ++ * The SEC control to be used depends on the type: ++ * ++ * NONE - no SEC commands will be issued. (Frequency adjustment will still be performed). ++ * ++ * POWER - only the SEC power will be turned on. ++ * ++ * STANDARD - the standard DISEQC back compatable sequence is used. ++ * ++ * ADVANCED - SEC strings are supplied by the user describing the exact sequence ++ * of operations to use. ++ */ ++ enum dvbsec_config_type config_type; ++ ++ /* stuff for type == dvbsec_config_ADVANCED */ ++ char adv_cmd_lo_h[MAX_SEC_CMD_LEN]; /* ADVANCED SEC command to use for LOW/H. */ ++ char adv_cmd_lo_v[MAX_SEC_CMD_LEN]; /* ADVANCED SEC command to use for LOW/V. */ ++ char adv_cmd_lo_l[MAX_SEC_CMD_LEN]; /* ADVANCED SEC command to use for LOW/L. */ ++ char adv_cmd_lo_r[MAX_SEC_CMD_LEN]; /* ADVANCED SEC command to use for LOW/R. */ ++ char adv_cmd_hi_h[MAX_SEC_CMD_LEN]; /* ADVANCED SEC command to use for HI/H. */ ++ char adv_cmd_hi_v[MAX_SEC_CMD_LEN]; /* ADVANCED SEC command to use for HI/V. */ ++ char adv_cmd_hi_l[MAX_SEC_CMD_LEN]; /* ADVANCED SEC command to use for HI/L. */ ++ char adv_cmd_hi_r[MAX_SEC_CMD_LEN]; /* ADVANCED SEC command to use for HI/R. */ ++}; ++ ++/** ++ * Helper function for tuning adapters with SEC support. This function will do ++ * everything required, including frequency adjustment based on the parameters ++ * in sec_config. ++ * ++ * Note: Since the SEC configuration structure can be set to disable any SEC ++ * operations, this function can be reused for ALL DVB style devices (just ++ * set all LOF=0,type=dvbsec_config_NONE for devices which do not require ++ * SEC control). ++ * ++ * The sec configuration structures can be looked up using the dvbcfg_sec library. ++ * ++ * @param fe Frontend concerned. ++ * @param sec_config SEC configuration structure. May be NULL to disable SEC/frequency adjustment. ++ * @param polarization Polarization of signal. ++ * @param sat_pos Satellite position - only used if type == DISEQC_SEC_CONFIG_STANDARD. ++ * @param switch_option Switch option - only used if type == DISEQC_SEC_CONFIG_STANDARD. ++ * @param params Tuning parameters. ++ * @param timeout <0 => wait forever for lock. 0=>return immediately, >0=> ++ * number of milliseconds to wait for a lock. ++ * @return 0 on locked (or if timeout==0 and everything else worked), or ++ * nonzero on failure (including no lock). ++ */ ++extern int dvbsec_set(struct dvbfe_handle *fe, ++ struct dvbsec_config *sec_config, ++ enum dvbsec_diseqc_polarization polarization, ++ enum dvbsec_diseqc_switch sat_pos, ++ enum dvbsec_diseqc_switch switch_option, ++ struct dvbfe_parameters *params, ++ int timeout); ++ ++/** ++ * This will issue the standardised back-compatable DISEQC/SEC command ++ * sequence as defined in the DISEQC spec: ++ * ++ * i.e. tone off, set voltage, wait15, DISEQC, wait15, toneburst, wait15, set tone. ++ * ++ * @param fe Frontend concerned. ++ * @param oscillator Value to set the lo/hi switch to. ++ * @param polarization Value to set the polarisation switch to. ++ * @param sat_pos Value to set the satellite position switch to. ++ * @param switch_option Value to set the "swtch option" switch to. ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_std_sequence(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_oscillator oscillator, ++ enum dvbsec_diseqc_polarization polarization, ++ enum dvbsec_diseqc_switch sat_pos, ++ enum dvbsec_diseqc_switch switch_option); ++ ++/** ++ * Execute an SEC command string on the provided frontend. Please see the documentation ++ * in dvbsec_cfg.h on the command format, ++ * ++ * @param fe Frontend concerned. ++ * @param command The command to execute. ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_command(struct dvbfe_handle *fe, char *command); ++ ++/** ++ * Control the reset status of an attached DISEQC device. ++ * ++ * @param fe Frontend concerned. ++ * @param address Address of the device. ++ * @param state The state to set. ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_diseqc_set_reset(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ enum dvbsec_diseqc_reset state); ++ ++/** ++ * Control the power status of an attached DISEQC peripheral. ++ * ++ * @param fe Frontend concerned. ++ * @param address Address of the device. ++ * @param state The state to set. ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_diseqc_set_power(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ enum dvbsec_diseqc_power state); ++ ++/** ++ * Control the listening status of an attached DISEQC peripheral. ++ * ++ * @param fe Frontend concerned. ++ * @param address Address of the device. ++ * @param state The state to set. ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_diseqc_set_listen(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ enum dvbsec_diseqc_listen state); ++ ++/** ++ * Set the state of the committed switches of a DISEQC device. ++ * These are switches which are defined to have a standard name. ++ * ++ * @param fe Frontend concerned. ++ * @param address Address of the device. ++ * @param oscillator Value to set the lo/hi switch to. ++ * @param polarization Value to set the polarization switch to. ++ * @param sat_pos Value to set the satellite position switch to. ++ * @param switch_option Value to set the switch option switch to. ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_diseqc_set_committed_switches(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ enum dvbsec_diseqc_oscillator oscillator, ++ enum dvbsec_diseqc_polarization polarization, ++ enum dvbsec_diseqc_switch sat_pos, ++ enum dvbsec_diseqc_switch switch_option); ++ ++/** ++ * Set the state of the uncommitted switches of a DISEQC device. ++ * These provide another four switching possibilities. ++ * ++ * @param fe Frontend concerned. ++ * @param address Address of the device. ++ * @param s1 Value to set the S1 switch to. ++ * @param s2 Value to set the S2 switch to. ++ * @param s3 Value to set the S3 switch to. ++ * @param s3 Value to set the S4 switch to. ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_diseqc_set_uncommitted_switches(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ enum dvbsec_diseqc_switch s1, ++ enum dvbsec_diseqc_switch s2, ++ enum dvbsec_diseqc_switch s3, ++ enum dvbsec_diseqc_switch s4); ++ ++/** ++ * Set an analogue value. ++ * ++ * @param fe Frontend concerned. ++ * @param address Address of the device. ++ * @param id The id of the analogue value to set. ++ * @param value The value to set. ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_diseqc_set_analog_value(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ enum dvbsec_diseqc_analog_id id, ++ uint8_t value); ++ ++/** ++ * Set the desired frequency. ++ * ++ * @param fe Frontend concerned. ++ * @param address Address of the device. ++ * @param frequency The frequency to set in GHz. ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_diseqc_set_frequency(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ uint32_t frequency); ++ ++/** ++ * Set the desired channel. ++ * ++ * @param fe Frontend concerned. ++ * @param address Address of the device. ++ * @param channel ID of the channel to set. ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_diseqc_set_channel(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ uint16_t channel); ++ ++/** ++ * Halt the satellite positioner. ++ * ++ * @param fe Frontend concerned. ++ * @param address Address of the device. ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_diseqc_halt_satpos(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address); ++ ++/** ++ * Disable satellite positioner limits. ++ * ++ * @param fe Frontend concerned. ++ * @param address Address of the device. ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_diseqc_disable_satpos_limits(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address); ++ ++/** ++ * Set satellite positioner limits. ++ * ++ * @param fe Frontend concerned. ++ * @param address Address of the device. ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_diseqc_set_satpos_limit(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ enum dvbsec_diseqc_direction direction); ++ ++/** ++ * Drive satellite positioner motor. ++ * ++ * @param fe Frontend concerned. ++ * @param address Address of the device. ++ * @param direction Direction to drive in. ++ * @param mode Drive mode to use ++ * (TIMEOUT=>value is a timeout in seconds, or STEPS=>value is a count of steps to use) ++ * @param value Value associated with the drive mode (range 0->127) ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_diseqc_drive_satpos_motor(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ enum dvbsec_diseqc_direction direction, ++ enum dvbsec_diseqc_drive_mode mode, ++ uint8_t value); ++ ++/** ++ * Store satellite positioner preset id at current position. ++ * ++ * @param fe Frontend concerned. ++ * @param address Address of the device. ++ * @param id ID of the preset. ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_diseqc_store_satpos_preset(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ uint8_t id); ++ ++/** ++ * Send a satellite positioner to a pre-set position. ++ * ++ * @param fe Frontend concerned. ++ * @param address Address of the device. ++ * @param id ID of the preset. ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_diseqc_goto_satpos_preset(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ uint8_t id); ++ ++/** ++ * Recalculate satellite positions based on the current position, using ++ * magic positioner specific values. ++ * ++ * @param fe Frontend concerned. ++ * @param address Address of the device. ++ * @param val1 value1 (range 0->255, pass -1 to ignore). ++ * @param val2 value2 (range 0->255, pass -1 to ignore). ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_diseqc_recalculate_satpos_positions(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ int val1, ++ int val2); ++ ++/** ++ * Send a terrestrial aerial rotator to a particular bearing ++ * (0 degrees = north, fractional angles allowed). ++ * ++ * @param fe Frontend concerned. ++ * @param address Address of the device. ++ * @param angle Angle to rotate to (-256.0 -> 512.0) ++ * @return 0 on success, or nonzero on error. ++ */ ++extern int dvbsec_diseqc_goto_rotator_bearing(struct dvbfe_handle *fe, ++ enum dvbsec_diseqc_address address, ++ float angle); ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbsec/dvbsec_cfg.c dvb-apps/lib/libdvbsec/dvbsec_cfg.c +--- linuxtv-dvb-apps-1.1.1/lib/libdvbsec/dvbsec_cfg.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbsec/dvbsec_cfg.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,366 @@ ++/** ++ * dvbsec_cfg (i.e. linuxtv sec format) configuration file support. ++ * ++ * Copyright (c) 2005 by Andrew de Quincey ++ * ++ * ++ * This library is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU Lesser General Public License as ++ * published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ */ ++ ++#define _GNU_SOURCE ++#include ++#include ++#include ++#include ++#include ++#include ++#include "dvbsec_cfg.h" ++ ++int dvbcfg_issection(char* line, char* sectionname) ++{ ++ int len; ++ ++ len = strlen(line); ++ if (len < 2) ++ return 0; ++ ++ if ((line[0] != '[') || (line[len-1] != ']')) ++ return 0; ++ ++ line++; ++ while(isspace(*line)) ++ line++; ++ ++ if (strncmp(line, sectionname, strlen(sectionname))) ++ return 0; ++ ++ return 1; ++} ++ ++char* dvbcfg_iskey(char* line, char* keyname) ++{ ++ int len = strlen(keyname); ++ ++ /* does the key match? */ ++ if (strncmp(line, keyname, len)) ++ return NULL; ++ ++ /* skip keyname & any whitespace */ ++ line += len; ++ while(isspace(*line)) ++ line++; ++ ++ /* should be the '=' sign */ ++ if (*line != '=') ++ return 0; ++ ++ /* more whitespace skipping */ ++ line++; ++ while(isspace(*line)) ++ line++; ++ ++ /* finally, return the value */ ++ return line; ++} ++ ++int dvbsec_cfg_load(FILE *f, ++ void *arg, ++ dvbsec_cfg_callback cb) ++{ ++ struct dvbsec_config tmpsec; ++ char *linebuf = NULL; ++ size_t line_size = 0; ++ int len; ++ int insection = 0; ++ char *value; ++ ++ /* process each line */ ++ while((len = getline(&linebuf, &line_size, f)) > 0) { ++ char *line = linebuf; ++ ++ /* chop any comments */ ++ char *hashpos = strchr(line, '#'); ++ if (hashpos) ++ *hashpos = 0; ++ char *lineend = line + strlen(line); ++ ++ /* trim the line */ ++ while(*line && isspace(*line)) ++ line++; ++ while((lineend != line) && isspace(*(lineend-1))) ++ lineend--; ++ *lineend = 0; ++ ++ /* skip blank lines */ ++ if (*line == 0) ++ continue; ++ ++ if (dvbcfg_issection(line, "sec")) { ++ if (insection) { ++ if (cb(arg, &tmpsec)) ++ return 0; ++ } ++ insection = 1; ++ memset(&tmpsec, 0, sizeof(tmpsec)); ++ ++ } else if ((value = dvbcfg_iskey(line, "name")) != NULL) { ++ strncpy(tmpsec.id, value, sizeof(tmpsec.id)); ++ } else if ((value = dvbcfg_iskey(line, "switch-frequency")) != NULL) { ++ tmpsec.switch_frequency = atoi(value); ++ } else if ((value = dvbcfg_iskey(line, "lof-lo-v")) != NULL) { ++ tmpsec.lof_lo_v = atoi(value); ++ } else if ((value = dvbcfg_iskey(line, "lof-lo-h")) != NULL) { ++ tmpsec.lof_lo_h = atoi(value); ++ } else if ((value = dvbcfg_iskey(line, "lof-lo-l")) != NULL) { ++ tmpsec.lof_lo_l = atoi(value); ++ } else if ((value = dvbcfg_iskey(line, "lof-lo-r")) != NULL) { ++ tmpsec.lof_lo_r = atoi(value); ++ } else if ((value = dvbcfg_iskey(line, "lof-hi-v")) != NULL) { ++ tmpsec.lof_hi_v = atoi(value); ++ } else if ((value = dvbcfg_iskey(line, "lof-hi-h")) != NULL) { ++ tmpsec.lof_hi_h = atoi(value); ++ } else if ((value = dvbcfg_iskey(line, "lof-hi-l")) != NULL) { ++ tmpsec.lof_hi_l = atoi(value); ++ } else if ((value = dvbcfg_iskey(line, "lof-hi-r")) != NULL) { ++ tmpsec.lof_hi_r = atoi(value); ++ } else if ((value = dvbcfg_iskey(line, "config-type")) != NULL) { ++ if (!strcasecmp(value, "none")) { ++ tmpsec.config_type = DVBSEC_CONFIG_NONE; ++ } else if (!strcasecmp(value, "power")) { ++ tmpsec.config_type = DVBSEC_CONFIG_POWER; ++ } else if (!strcasecmp(value, "standard")) { ++ tmpsec.config_type = DVBSEC_CONFIG_STANDARD; ++ } else if (!strcasecmp(value, "advanced")) { ++ tmpsec.config_type = DVBSEC_CONFIG_ADVANCED; ++ } else { ++ insection = 0; ++ } ++ } else if ((value = dvbcfg_iskey(line, "cmd-lo-v")) != NULL) { ++ strncpy(tmpsec.adv_cmd_lo_v, value, sizeof(tmpsec.adv_cmd_lo_v)); ++ } else if ((value = dvbcfg_iskey(line, "cmd-lo-h")) != NULL) { ++ strncpy(tmpsec.adv_cmd_lo_h, value, sizeof(tmpsec.adv_cmd_lo_h)); ++ } else if ((value = dvbcfg_iskey(line, "cmd-lo-r")) != NULL) { ++ strncpy(tmpsec.adv_cmd_lo_r, value, sizeof(tmpsec.adv_cmd_lo_r)); ++ } else if ((value = dvbcfg_iskey(line, "cmd-lo-l")) != NULL) { ++ strncpy(tmpsec.adv_cmd_lo_l, value, sizeof(tmpsec.adv_cmd_lo_l)); ++ } else if ((value = dvbcfg_iskey(line, "cmd-hi-v")) != NULL) { ++ strncpy(tmpsec.adv_cmd_hi_v, value, sizeof(tmpsec.adv_cmd_hi_v)); ++ } else if ((value = dvbcfg_iskey(line, "cmd-hi-h")) != NULL) { ++ strncpy(tmpsec.adv_cmd_hi_h, value, sizeof(tmpsec.adv_cmd_hi_h)); ++ } else if ((value = dvbcfg_iskey(line, "cmd-hi-r")) != NULL) { ++ strncpy(tmpsec.adv_cmd_hi_r, value, sizeof(tmpsec.adv_cmd_hi_r)); ++ } else if ((value = dvbcfg_iskey(line, "cmd-hi-l")) != NULL) { ++ strncpy(tmpsec.adv_cmd_hi_l, value, sizeof(tmpsec.adv_cmd_hi_l)); ++ } else { ++ insection = 0; ++ } ++ } ++ ++ // output the final section if there is one ++ if (insection) { ++ if (cb(arg, &tmpsec)) ++ return 0; ++ } ++ ++ if (linebuf) ++ free(linebuf); ++ return 0; ++} ++ ++static int dvbsec_cfg_find_callback(void *arg, struct dvbsec_config *sec); ++static int dvbsec_cfg_find_default(const char *sec_id, struct dvbsec_config *sec); ++ ++struct findparams { ++ const char *sec_id; ++ struct dvbsec_config *sec_dest; ++}; ++ ++int dvbsec_cfg_find(const char *config_file, ++ const char *sec_id, ++ struct dvbsec_config *sec) ++{ ++ struct findparams findp; ++ ++ // clear the structure ++ memset(sec, 0, sizeof(struct dvbsec_config)); ++ ++ // open the file ++ if (config_file != NULL) { ++ FILE *f = fopen(config_file, "r"); ++ if (f == NULL) ++ return -EIO; ++ ++ // parse each entry ++ findp.sec_id = sec_id; ++ findp.sec_dest = sec; ++ dvbsec_cfg_load(f, &findp, dvbsec_cfg_find_callback); ++ ++ // done ++ fclose(f); ++ ++ // find it? ++ if (sec->id[0]) ++ return 0; ++ } ++ ++ return dvbsec_cfg_find_default(sec_id, sec); ++} ++ ++static int dvbsec_cfg_find_callback(void *arg, struct dvbsec_config *sec) ++{ ++ struct findparams *findp = arg; ++ ++ if (strcmp(findp->sec_id, sec->id)) ++ return 0; ++ ++ memcpy(findp->sec_dest, sec, sizeof(struct dvbsec_config)); ++ return 1; ++} ++ ++int dvbsec_cfg_save(FILE *f, ++ struct dvbsec_config *secs, ++ int count) ++{ ++ int i; ++ ++ for(i=0; i ++ * ++ * This library is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU Lesser General Public License as ++ * published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ */ ++ ++/** ++ * This library allows SEC (Satellite Equipment Control) configurations ++ * to be retrieved. Each configuration is identified by a unique satellite_id. ++ * ++ * In order to make things as easy as possible for users, there are a set of ++ * defaults hardcoded into the library covering the majority of LNB types. When ++ * these are used, the standard back-compatable sequence defined in the DISEQC ++ * standard will be used - this will suffice for _most_ situations. ++ * ++ * UNIVERSAL - Europe, 10800 to 11800 MHz and 11600 to 12700 Mhz, Dual LO, loband 9750, hiband 10600 MHz. ++ * DBS - Expressvu, North America, 12200 to 12700 MHz, Single LO, 11250 MHz. ++ * STANDARD - 10945 to 11450 Mhz, Single LO, 10000Mhz. ++ * ENHANCED - Astra, 10700 to 11700 MHz, Single LO, 9750MHz. ++ * C-BAND - Big Dish, 3700 to 4200 MHz, Single LO, 5150Mhz. ++ * C-MULTI - Big Dish - Multipoint LNBf, 3700 to 4200 MHz, Dual LO, H:5150MHz, V:5750MHz. ++ * ++ * However, for the power user with a more complex setup, these simple defaults ++ * are not enough. Therefore, it is also possible to define additional SEC ++ * configurations in an external configuration file. This file consists of multiple ++ * entries in the following format: ++ * ++ * [sec] ++ * name= ++ * switch-frequency= ++ * lof-lo-v= ++ * lof-lo-h= ++ * lof-lo-l= ++ * lof-lo-r= ++ * lof-hi-v= ++ * lof-hi-h= ++ * lof-hi-l= ++ * lof-hi-r= ++ * config-type= ++ * cmd-lo-v= ++ * cmd-lo-h= ++ * cmd-lo-r= ++ * cmd-lo-l= ++ * cmd-hi-v= ++ * cmd-hi-h= ++ * cmd-hi-r= ++ * cmd-hi-l= ++ * ++ * The sec_id is whatever unique value you wish. If it is the same as one of the hardcoded defaults, the configuration ++ * details from the file will be used instead of the hardcoded ones. ++ * The switch-frequency (or SLOF) indicates the point seperating low band frequencies from high band frequencies. ++ * Set this value to 0 if there is only one frequency band. ++ * The lof-lo-v is the frequency adjustment for V + low band (i.e. less than SLOF), or is used if switch-frequency==0. ++ * The lof-lo-h is the frequency adjustment for H + low band (i.e. less than SLOF), or is used if switch-frequency==0. ++ * The lof-lo-l is the frequency adjustment for L + low band (i.e. less than SLOF), or is used if switch-frequency==0. ++ * The lof-lo-r is the frequency adjustment for R + low band (i.e. less than SLOF), or is used if switch-frequency==0. ++ * The lof-hi-v is the frequency adjustment for V + high band (unused if switch-frequency==0). ++ * The lof-hi-h is the frequency adjustment for H + high band (unused if switch-frequency==0). ++ * The lof-hi-l is the frequency adjustment for L + high band (unused if switch-frequency==0). ++ * The lof-hi-r is the frequency adjustment for R + high band (unused if switch-frequency==0). ++ * ++ * config-type indicates the desired type of SEC command to use, it may be: ++ * none - No SEC commands will be issued (frequency adjustment will still be performed). ++ * power - Only the SEC power is turned on. ++ * standard - The standard DISEQC back compatable sequence will be issued. ++ * advanced - The DISEQC sequence described in the appropriate sec cmd string will be used. ++ * ++ * The cmd-- describes the SEC cmd string to use in advanced mode for each of the possible combinations of ++ * frequency band and polarisation. If a certain combination is not required, it may be omitted. It consists of a ++ * space seperated combination of commands - those available are as follows: ++ * ++ * tone(<0|1>) - control the 22kHz tone 0:off, 1:on ++ * voltage(<0|13|18>) - control the LNB voltage 0v, 13v, or 18v ++ * toneburst() - issue a toneburst (mini command) for position A or B. ++ * highvoltage(<0|1>) - control high lnb voltage for long cable runs 0: normal, 1:add 1v to LNB voltage. ++ * dishnetworks() - issue a dishnetworks legacy command. ++ * wait() - wait for the given number of milliseconds. ++ * Dreset(
, <0|1>) - control the reset state of a DISEC device, 0:disable reset, 1:enable reset. ++ * Dpower(
, <0|1>) - control the power of a DISEC device, 0:off, 1:on. ++ * Dcommitted(
, , , , ) - Write to the committed switches of a DISEC device. ++ * The parameters are for band, polarisation, satelliteposition, switchoption: ++ * band - h:high band, l:low band ++ * polarisation - v: vertical, h:horizontal,r:right,l:left ++ * satelliteposition - a:position A, b: position B ++ * switchoption - a:position A, b: position B ++ * The special value 'x' means "no change to this switch". ++ * ++ * Duncommitted(
, , , , ) - Write to the uncommitted switches of the a DISEC device. ++ * The parameters are for switch1, switch2, switch3, switch4, and may be set to position a or b. ++ * The special value 'x' means "no change to this switch". ++ * ++ * Dfrequency(
, ) - set the frequency of a DISEC device. ++ * Dchannel(
, ) - set the desired channel id of a DISEC device. ++ * Dgotopreset(
, ) - tell a DISEC satellite positioner to move to the given preset id. ++ * Dgotobearing(
, ) - tell a DISEQC terrestrial rotator to go to the ++ * given bearing (range -256.0 -> 512.0 degrees, fractions allowed). ++ * ++ * In the above DISEQC commands,
is the integer (normally in hex format) address of the ++ * diseqc device to communicate with. A list of possiblities is as follows: ++ * ++ * DISEQC_ADDRESS_ANY_DEVICE = 0x00 ++ * ++ * DISEQC_ADDRESS_ANY_LNB_SWITCHER_SMATV = 0x10 ++ * DISEQC_ADDRESS_LNB = 0x11 ++ * DISEQC_ADDRESS_LNB_WITH_LOOP = 0x12 ++ * DISEQC_ADDRESS_SWITCHER = 0x14 ++ * DISEQC_ADDRESS_SWITCHER_WITH_LOOP = 0x15 ++ * DISEQC_ADDRESS_SMATV = 0x18 ++ * ++ * DISEQC_ADDRESS_ANY_POLARISER = 0x20 ++ * DISEQC_ADDRESS_LINEAR_POLARISER = 0x21 ++ * ++ * DISEQC_ADDRESS_ANY_POSITIONER = 0x30 ++ * DISEQC_ADDRESS_POLAR_AZIMUTH_POSITIONER = 0x31 ++ * DISEQC_ADDRESS_ELEVATION_POSITIONER = 0x32 ++ * ++ * DISEQC_ADDRESS_ANY_INSTALLER_AID = 0x40 ++ * DISEQC_ADDRESS_SIGNAL_STRENGTH = 0x41 ++ * ++ * DISEQC_ADDRESS_ANY_INTERFACE = 0x70 ++ * DISEQC_ADDRESS_HEADEND_INTERFACE = 0x71 ++ * ++ * DISEQC_ADDRESS_REALLOC_BASE = 0x60 ++ * DISEQC_ADDRESS_OEM_BASE = 0xf0 ++ */ ++ ++#ifndef DVBSEC_CFG_H ++#define DVBSEC_CFG_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * Callback function used in dvbsec_cfg_load(). ++ * ++ * @param arg Private information to caller. ++ * @param channel The current channel details. ++ * @return 0 to continue, 1 to stop loading. ++ */ ++typedef int (*dvbsec_cfg_callback)(void *arg, struct dvbsec_config *sec); ++ ++/** ++ * Load an SEC file. ++ * ++ * @param f File to load from. ++ * @param arg Value to pass to 'arg' in callback above. ++ * @param cb Callback function called for each sec loaded from the file. ++ * @return 0 on success, or nonzero error code on failure. ++ */ ++extern int dvbsec_cfg_load(FILE *f, void *arg, ++ dvbsec_cfg_callback cb); ++ ++/** ++ * Convenience function to parse an SEC config file. This will also consult the set ++ * of hardcoded defaults if no config file was supplied, or a match was not found in ++ * the config file. ++ * ++ * @param config_file Config filename to load, or NULL to just check defaults. ++ * @param sec_id ID of SEC configuration. ++ * @param sec Where to put the details if found. ++ * @return 0 on success, nonzero on error. ++ */ ++extern int dvbsec_cfg_find(const char *config_file, ++ const char *sec_id, ++ struct dvbsec_config *sec); ++ ++/** ++ * Save SEC format config file. ++ * ++ * @param f File to save to. ++ * @param secs Pointer to array of SECs to save. ++ * @param count Number of entries in the above array. ++ * @return 0 on success, or nonzero error code on failure. ++ */ ++extern int dvbsec_cfg_save(FILE *f, ++ struct dvbsec_config *secs, ++ int count); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libdvbsec/Makefile dvb-apps/lib/libdvbsec/Makefile +--- linuxtv-dvb-apps-1.1.1/lib/libdvbsec/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libdvbsec/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,17 @@ ++# Makefile for linuxtv.org dvb-apps/lib/libdvbsec ++ ++includes = dvbsec_api.h \ ++ dvbsec_cfg.h ++ ++objects = dvbsec_api.o \ ++ dvbsec_cfg.o ++ ++lib_name = libdvbsec ++ ++CPPFLAGS += -I../../lib ++ ++.PHONY: all ++ ++all: library ++ ++include ../../Make.rules +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/bootstrap/access_descriptor.c dvb-apps/lib/libesg/bootstrap/access_descriptor.c +--- linuxtv-dvb-apps-1.1.1/lib/libesg/bootstrap/access_descriptor.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/bootstrap/access_descriptor.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,115 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++ ++#include ++ ++struct esg_access_descriptor *esg_access_descriptor_decode(uint8_t *buffer, uint32_t size) { ++ uint32_t pos; ++ struct esg_access_descriptor *access_descriptor; ++ struct esg_entry *entry; ++ struct esg_entry *last_entry; ++ uint32_t entry_length; ++ uint16_t entry_index; ++ uint8_t ip_index; ++ ++ if ((buffer == NULL) || (size <= 2)) { ++ return NULL; ++ } ++ ++ pos = 0; ++ ++ access_descriptor = (struct esg_access_descriptor *) malloc(sizeof(struct esg_access_descriptor)); ++ memset(access_descriptor, 0, sizeof(struct esg_access_descriptor)); ++ access_descriptor->entry_list = NULL; ++ ++ access_descriptor->n_o_entries = (buffer[pos] << 8) | buffer[pos+1]; ++ pos += 2; ++ ++ last_entry = NULL; ++ for (entry_index = 0; entry_index < access_descriptor->n_o_entries; entry_index++) { ++ entry = (struct esg_entry *) malloc(sizeof(struct esg_entry)); ++ memset(entry, 0, sizeof(struct esg_entry)); ++ entry->_next = NULL; ++ ++ if (last_entry == NULL) { ++ access_descriptor->entry_list = entry; ++ } else { ++ last_entry->_next = entry; ++ } ++ last_entry = entry; ++ ++ entry->version = buffer[pos]; ++ pos += 1; ++ ++ pos += vluimsbf8(buffer + pos, size - pos, &entry_length); ++ ++ if (size < pos + entry_length) { ++ esg_access_descriptor_free(access_descriptor); ++ return NULL; ++ } ++ ++ entry->multiple_stream_transport = (buffer[pos] & 0x80) ? 1 : 0; ++ entry->ip_version_6 = (buffer[pos] & 0x40) ? 1 : 0; ++ pos += 1; ++ ++ entry->provider_id = (buffer[pos] << 8) | buffer[pos+1]; ++ pos += 2; ++ ++ if (entry->ip_version_6) { ++ for (ip_index = 0; ip_index < 16; ip_index++) { ++ entry->source_ip.ipv6[ip_index] = buffer[pos+ip_index]; ++ entry->destination_ip.ipv6[ip_index] = buffer[pos+16+ip_index]; ++ } ++ pos += 32; ++ } else { ++ for (ip_index = 0; ip_index < 4; ip_index++) { ++ entry->source_ip.ipv4[ip_index] = buffer[pos+ip_index]; ++ entry->destination_ip.ipv4[ip_index] = buffer[pos+4+ip_index]; ++ } ++ pos += 8; ++ } ++ entry->port = (buffer[pos] << 8) | buffer[pos+1]; ++ pos += 2; ++ ++ entry->tsi = (buffer[pos] << 8) | buffer[pos+1]; ++ pos += 2; ++ } ++ ++ return access_descriptor; ++} ++ ++void esg_access_descriptor_free(struct esg_access_descriptor *access_descriptor) { ++ struct esg_entry *entry; ++ struct esg_entry *next_entry; ++ ++ if (access_descriptor == NULL) { ++ return; ++ } ++ ++ for(entry = access_descriptor->entry_list; entry; entry = next_entry) { ++ next_entry = entry->_next; ++ free(entry); ++ } ++ ++ free(access_descriptor); ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/bootstrap/access_descriptor.h dvb-apps/lib/libesg/bootstrap/access_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libesg/bootstrap/access_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/bootstrap/access_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,86 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _ESG_BOOTSTRAP_ACCESS_DESCRIPTOR_H ++#define _ESG_BOOTSTRAP_ACCESS_DESCRIPTOR_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * esg_entry structure. ++ */ ++struct esg_entry { ++ uint8_t version; ++ uint8_t multiple_stream_transport; ++ uint8_t ip_version_6; ++ uint16_t provider_id; ++ union esg_ip_address source_ip; ++ union esg_ip_address destination_ip; ++ uint16_t port; ++ uint16_t tsi; ++ ++ struct esg_entry *_next; ++}; ++ ++/** ++ * esg_access_descriptor structure. ++ */ ++struct esg_access_descriptor { ++ uint16_t n_o_entries; ++ struct esg_entry *entry_list; ++}; ++ ++/** ++ * Process an esg_access_descriptor. ++ * ++ * @param buffer Binary buffer to decode. ++ * @param size Binary buffer size. ++ * @return Pointer to an esg_access_descriptor structure, or NULL on error. ++ */ ++extern struct esg_access_descriptor *esg_access_descriptor_decode(uint8_t *buffer, uint32_t size); ++ ++/** ++ * Free an esg_access_descriptor. ++ * ++ * @param esg Pointer to an esg_access_descriptor structure. ++ */ ++extern void esg_access_descriptor_free(struct esg_access_descriptor *access_descriptor); ++ ++/** ++ * Convenience iterator for esg_entry_list field of an esg_access_descriptor. ++ * ++ * @param access_descriptor The esg_access_descriptor pointer. ++ * @param entry Variable holding a pointer to the current esg_entry. ++ */ ++#define esg_access_descriptor_entry_list_for_each(access_descriptor, entry) \ ++ for ((entry) = (access_descriptor)->entry_list; \ ++ (entry); \ ++ (entry) = (entry)->_next) ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/bootstrap/Makefile dvb-apps/lib/libesg/bootstrap/Makefile +--- linuxtv-dvb-apps-1.1.1/lib/libesg/bootstrap/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/bootstrap/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,24 @@ ++# Makefile for linuxtv.org dvb-apps/lib/libesg/bootstrap ++ ++.PHONY: sub-error-bootstrap ++ ++sub-error-bootstrap: ++ $(error You can't use this makefile directly.) ++ ++ifneq ($(lib_name),) ++ ++objects += bootstrap/access_descriptor.o \ ++ bootstrap/provider_discovery_descriptor.o ++ ++sub-install += bootstrap ++ ++else ++ ++includes = access_descriptor.h \ ++ provider_discovery_descriptor.h ++ ++include ../../../Make.rules ++ ++lib_name = libesg/bootstrap ++ ++endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/bootstrap/provider_discovery_descriptor.c dvb-apps/lib/libesg/bootstrap/provider_discovery_descriptor.c +--- linuxtv-dvb-apps-1.1.1/lib/libesg/bootstrap/provider_discovery_descriptor.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/bootstrap/provider_discovery_descriptor.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,50 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++ ++#include ++ ++struct esg_provider_discovery_descriptor *esg_esg_provider_discovery_descriptor_decode(uint8_t *buffer, uint32_t size) { ++ struct esg_provider_discovery_descriptor *provider; ++ ++ provider = (struct esg_provider_discovery_descriptor *) malloc(sizeof(struct esg_provider_discovery_descriptor)); ++ memset(provider, 0, sizeof(struct esg_provider_discovery_descriptor)); ++ ++ provider->xml = (uint8_t *) malloc(size); ++ memcpy(provider->xml, buffer, size); ++ ++ provider->size = size; ++ ++ return provider; ++} ++ ++void esg_provider_discovery_descriptor_free(struct esg_provider_discovery_descriptor *provider) { ++ if (provider == NULL) { ++ return; ++ } ++ ++ if (provider->xml) { ++ free(provider->xml); ++ } ++ ++ free(provider); ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/bootstrap/provider_discovery_descriptor.h dvb-apps/lib/libesg/bootstrap/provider_discovery_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libesg/bootstrap/provider_discovery_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/bootstrap/provider_discovery_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,59 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _ESG_BOOTSTRAP_PROVIDER_DISCOVERY_DESCRIPTOR_H ++#define _ESG_BOOTSTRAP_PROVIDER_DISCOVERY_DESCRIPTOR_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * esg_provider_discovery_descriptor structure. ++ */ ++struct esg_provider_discovery_descriptor { ++ uint8_t *xml; ++ uint32_t size; ++}; ++ ++/** ++ * Process an esg_provider_discovery_descriptor. ++ * ++ * @param buffer Binary buffer to decode. ++ * @param size Binary buffer size. ++ * @return Pointer to an esg_provider_discovery_descriptor structure, or NULL on error. ++ */ ++extern struct esg_provider_discovery_descriptor *esg_esg_provider_discovery_descriptor_decode(uint8_t *buffer, uint32_t size); ++ ++/** ++ * Free an esg_provider_discovery_descriptor. ++ * ++ * @param esg Pointer to an esg_provider_discovery_descriptor structure. ++ */ ++extern void esg_provider_discovery_descriptor_free(struct esg_provider_discovery_descriptor *provider); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/auxiliary_data.h dvb-apps/lib/libesg/encapsulation/auxiliary_data.h +--- linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/auxiliary_data.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/encapsulation/auxiliary_data.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,62 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _ESG_ENCAPSULATION_AUXILIARY_DATA_H ++#define _ESG_ENCAPSULATION_AUXILIARY_DATA_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * esg_any_attribute structure. ++ */ ++struct esg_any_attribute { ++ uint8_t version_id; ++ uint8_t *extension; ++ ++ struct esg_any_attribure *_next; ++}; ++ ++/** ++ * esg_binary_header structure. ++ */ ++struct esg_binary_header { ++ uint16_t encoding_metadatauri_mimetype; ++ struct esg_any_attribute *any_attribute_list; ++}; ++ ++/** ++ * esg_encapsulated_aux_data struct. ++ */ ++struct esg_encapsulated_aux_data { ++ struct esg_binary_header *binary_header; ++ uint32_t aux_data_length; ++ uint8_t aux_data; ++}; ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/container.c dvb-apps/lib/libesg/encapsulation/container.c +--- linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/container.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/encapsulation/container.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,206 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++struct esg_container *esg_container_decode(uint8_t *buffer, uint32_t size) { ++ uint32_t pos; ++ struct esg_container *container; ++ struct esg_container_structure *structure; ++ struct esg_container_structure *last_structure; ++ uint8_t structure_index; ++ ++ if ((buffer == NULL) || (size <= 1)) { ++ return NULL; ++ } ++ ++ pos = 0; ++ ++ container = (struct esg_container *) malloc(sizeof(struct esg_container)); ++ memset(container, 0, sizeof(struct esg_container)); ++ ++ // Container header ++ container->header = (struct esg_container_header *) malloc(sizeof(struct esg_container_header)); ++ memset(container->header, 0, sizeof(struct esg_container_header)); ++ ++ container->header->num_structures = buffer[pos]; ++ pos += 1; ++ ++ if (size < pos + (container->header->num_structures * 8)) { ++ esg_container_free(container); ++ return NULL; ++ } ++ ++ last_structure = NULL; ++ for (structure_index = 0; structure_index < container->header->num_structures; structure_index++) { ++ structure = (struct esg_container_structure *) malloc(sizeof(struct esg_container_structure)); ++ memset(structure, 0, sizeof(struct esg_container_structure)); ++ structure->_next = NULL; ++ ++ if (last_structure == NULL) { ++ container->header->structure_list = structure; ++ } else { ++ last_structure->_next = structure; ++ } ++ last_structure = structure; ++ ++ structure->type = buffer[pos]; ++ pos += 1; ++ ++ structure->id = buffer[pos]; ++ pos += 1; ++ ++ structure->ptr = (buffer[pos] << 16) | (buffer[pos+1] << 8) | buffer[pos+2]; ++ pos += 3; ++ ++ structure->length = (buffer[pos] << 16) | (buffer[pos+1] << 8) | buffer[pos+2]; ++ pos += 3; ++ ++ if (size < (structure->ptr + structure->length)) { ++ esg_container_free(container); ++ return NULL; ++ } ++ ++ // Decode structure ++ switch (structure->type) { ++ case 0x01: { ++ switch (structure->id) { ++ case 0x00: { ++ structure->data = (void *) esg_encapsulation_structure_decode(buffer + structure->ptr, structure->length); ++ break; ++ } ++ default: { ++ esg_container_free(container); ++ return NULL; ++ } ++ } ++ break; ++ } ++ case 0x02: { ++ switch (structure->id) { ++ case 0x00: { ++ structure->data = (void *) esg_string_repository_decode(buffer + structure->ptr, structure->length); ++ break; ++ } ++ default: { ++ esg_container_free(container); ++ return NULL; ++ } ++ } ++ break; ++ } ++ case 0x03: { ++ //TODO ++ break; ++ } ++ case 0x04: { ++ //TODO ++ break; ++ } ++ case 0x05: { ++ //TODO ++ break; ++ } ++ case 0xE0: { ++ switch (structure->id) { ++ case 0x00: { ++ structure->data = (void *) esg_data_repository_decode(buffer + structure->ptr, structure->length); ++ break; ++ } ++ default: { ++ esg_container_free(container); ++ return NULL; ++ } ++ } ++ break; ++ } ++ case 0xE1: { ++ switch (structure->id) { ++ case 0xFF: { ++ structure->data = (void *) esg_session_partition_declaration_decode(buffer + structure->ptr, structure->length); ++ break; ++ } ++ default: { ++ esg_container_free(container); ++ return NULL; ++ } ++ } ++ break; ++ } ++ case 0xE2: { ++ switch (structure->id) { ++ case 0x00: { ++ structure->data = (void *) esg_init_message_decode(buffer + structure->ptr, structure->length); ++ break; ++ } ++ default: { ++ esg_container_free(container); ++ return NULL; ++ } ++ } ++ break; ++ } ++ default: { ++ esg_container_free(container); ++ return NULL; ++ } ++ } ++ } ++ ++ // Container structure body ++ container->structure_body_ptr = pos; ++ container->structure_body_length = size - pos; ++ container->structure_body = (uint8_t *) malloc(size - pos); ++ memcpy(container->structure_body, buffer + pos, size - pos); ++ ++ return container; ++} ++ ++void esg_container_free(struct esg_container *container) { ++ struct esg_container_structure *structure; ++ struct esg_container_structure *next_structure; ++ ++ if (container == NULL) { ++ return; ++ } ++ ++ if (container->header) { ++ for(structure = container->header->structure_list; structure; structure = next_structure) { ++ next_structure = structure->_next; ++ free(structure); ++ } ++ ++ free(container->header); ++ } ++ ++ if (container->structure_body) { ++ free(container->structure_body); ++ } ++ ++ free(container); ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/container.h dvb-apps/lib/libesg/encapsulation/container.h +--- linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/container.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/encapsulation/container.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,94 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _ESG_ENCAPSULATION_CONTAINER_H ++#define _ESG_ENCAPSULATION_CONTAINER_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * esg_container_structure structure. ++ */ ++struct esg_container_structure { ++ uint8_t type; ++ uint8_t id; ++ uint32_t ptr; ++ uint32_t length; ++ ++ void *data; ++ ++ struct esg_container_structure *_next; ++}; ++ ++/** ++ * esg_container_header structure. ++ */ ++struct esg_container_header { ++ uint8_t num_structures; ++ struct esg_container_structure *structure_list; ++}; ++ ++/** ++ * esg_container structure ++ */ ++struct esg_container { ++ struct esg_container_header *header; ++ uint32_t structure_body_ptr; ++ uint32_t structure_body_length; ++ uint8_t *structure_body; ++}; ++ ++/** ++ * Process an esg_container. ++ * ++ * @param buffer Binary buffer to decode. ++ * @param size Binary buffer size. ++ * @return Pointer to an esg_container structure, or NULL on error. ++ */ ++extern struct esg_container *esg_container_decode(uint8_t *buffer, uint32_t size); ++ ++/** ++ * Free an esg_container. ++ * ++ * @param container Pointer to an esg_container structure. ++ */ ++extern void esg_container_free(struct esg_container *container); ++ ++/** ++ * Convenience iterator for structure_list field of an esg_container_header. ++ * ++ * @param container The esg_container_header pointer. ++ * @param structure Variable holding a pointer to the current esg_container_structure. ++ */ ++#define esg_container_header_structure_list_for_each(header, structure) \ ++ for ((structure) = (header)->structure_list; \ ++ (structure); \ ++ (structure) = (structure)->_next) ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/data_repository.c dvb-apps/lib/libesg/encapsulation/data_repository.c +--- linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/data_repository.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/encapsulation/data_repository.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,53 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++ ++#include ++ ++struct esg_data_repository *esg_data_repository_decode(uint8_t *buffer, uint32_t size) { ++ struct esg_data_repository *data_repository; ++ ++ if ((buffer == NULL) || (size <= 0)) { ++ return NULL; ++ } ++ ++ data_repository = (struct esg_data_repository *) malloc(sizeof(struct esg_data_repository)); ++ memset(data_repository, 0, sizeof(struct esg_data_repository)); ++ ++ data_repository->length = size; ++ data_repository->data = (uint8_t *) malloc(size); ++ memcpy(data_repository->data, buffer, size); ++ ++ return data_repository; ++} ++ ++void esg_data_repository_free(struct esg_data_repository *data_repository) { ++ if (data_repository == NULL) { ++ return; ++ } ++ ++ if (data_repository->data) { ++ free(data_repository->data); ++ } ++ ++ free(data_repository); ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/data_repository.h dvb-apps/lib/libesg/encapsulation/data_repository.h +--- linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/data_repository.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/encapsulation/data_repository.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,59 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _ESG_ENCAPSULATION_DATA_REPOSITORY_H ++#define _ESG_ENCAPSULATION_DATA_REPOSITORY_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * esg_data_repository structure. ++ */ ++struct esg_data_repository { ++ uint32_t length; ++ uint8_t *data; ++}; ++ ++/** ++ * Process an esg_data_repository. ++ * ++ * @param buffer Binary buffer to decode. ++ * @param size Binary buffer size. ++ * @return Pointer to an esg_data_repository structure, or NULL on error. ++ */ ++extern struct esg_data_repository *esg_data_repository_decode(uint8_t *buffer, uint32_t size); ++ ++/** ++ * Free an esg_data_repository. ++ * ++ * @param data_repository Pointer to an esg_data_repository structure. ++ */ ++extern void esg_data_repository_free(struct esg_data_repository *data_repository); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/fragment_management_information.c dvb-apps/lib/libesg/encapsulation/fragment_management_information.c +--- linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/fragment_management_information.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/encapsulation/fragment_management_information.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,118 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++ ++#include ++ ++struct esg_encapsulation_structure *esg_encapsulation_structure_decode(uint8_t *buffer, uint32_t size) { ++ uint32_t pos; ++ struct esg_encapsulation_structure *structure; ++ struct esg_encapsulation_entry *entry; ++ struct esg_encapsulation_entry *last_entry; ++ ++ if ((buffer == NULL) || (size <= 2)) { ++ return NULL; ++ } ++ ++ pos = 0; ++ ++ structure = (struct esg_encapsulation_structure *) malloc(sizeof(struct esg_encapsulation_structure)); ++ memset(structure, 0, sizeof(struct esg_encapsulation_structure)); ++ structure->entry_list = NULL; ++ ++ // Encapsulation header ++ structure->header = (struct esg_encapsulation_header *) malloc(sizeof(struct esg_encapsulation_header)); ++ // buffer[pos] reserved ++ structure->header->fragment_reference_format = buffer[pos+1]; ++ pos += 2; ++ ++ // Encapsulation entry list ++ last_entry = NULL; ++ while (size > pos) { ++ entry = (struct esg_encapsulation_entry *) malloc(sizeof(struct esg_encapsulation_entry)); ++ memset(entry, 0, sizeof(struct esg_encapsulation_entry)); ++ entry->_next = NULL; ++ ++ if (last_entry == NULL) { ++ structure->entry_list = entry; ++ } else { ++ last_entry->_next = entry; ++ } ++ last_entry = entry; ++ ++ // Fragment reference ++ switch (structure->header->fragment_reference_format) { ++ case 0x21: { ++ entry->fragment_reference = (struct esg_fragment_reference *) malloc(sizeof(struct esg_fragment_reference)); ++ memset(entry->fragment_reference, 0, sizeof(struct esg_fragment_reference)); ++ ++ entry->fragment_reference->fragment_type = buffer[pos]; ++ pos += 1; ++ ++ entry->fragment_reference->data_repository_offset = (buffer[pos] << 16) | (buffer[pos+1] << 8) | buffer[pos+2]; ++ pos += 3; ++ ++ break; ++ } ++ default: { ++ esg_encapsulation_structure_free(structure); ++ return NULL; ++ } ++ } ++ ++ // Fragment version & id ++ entry->fragment_version = buffer[pos]; ++ pos += 1; ++ ++ entry->fragment_id = (buffer[pos] << 16) | (buffer[pos+1] << 8) | buffer[pos+2]; ++ pos += 3; ++ } ++ ++ return structure; ++} ++ ++void esg_encapsulation_structure_free(struct esg_encapsulation_structure *structure) { ++ struct esg_encapsulation_entry *entry; ++ struct esg_encapsulation_entry *next_entry; ++ ++ if (structure == NULL) { ++ return; ++ } ++ ++ if (structure->header) { ++ free(structure->header); ++ } ++ ++ if (structure->entry_list) { ++ for(entry = structure->entry_list; entry; entry = next_entry) { ++ next_entry = entry->_next; ++ if (entry->fragment_reference) { ++ free(entry->fragment_reference); ++ } ++ free(entry); ++ } ++ ++ free(structure->entry_list); ++ } ++ ++ free(structure); ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/fragment_management_information.h dvb-apps/lib/libesg/encapsulation/fragment_management_information.h +--- linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/fragment_management_information.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/encapsulation/fragment_management_information.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,96 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _ESG_ENCAPSULATION_FRAGMENT_MANAGEMENT_INFORMATION_H ++#define _ESG_ENCAPSULATION_FRAGMENT_MANAGEMENT_INFORMATION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * esg_encapsulation_header structure. ++ */ ++struct esg_encapsulation_header { ++ uint8_t fragment_reference_format; ++}; ++ ++/** ++ * esg_fragment_reference structure. ++ */ ++struct esg_fragment_reference { ++ uint8_t fragment_type; ++ uint32_t data_repository_offset; ++}; ++ ++/** ++ * esg_encapsulation_entry structure. ++ */ ++struct esg_encapsulation_entry { ++ struct esg_fragment_reference *fragment_reference; ++ uint8_t fragment_version; ++ uint32_t fragment_id; ++ ++ struct esg_encapsulation_entry *_next; ++}; ++ ++/** ++ * esg_encapsulation_structure structure. ++ */ ++struct esg_encapsulation_structure { ++ struct esg_encapsulation_header *header; ++ struct esg_encapsulation_entry *entry_list; ++}; ++ ++/** ++ * Process an esg_encapsulation_structure. ++ * ++ * @param buffer Binary buffer to decode. ++ * @param size Binary buffer size. ++ * @return Pointer to an esg_encapsulation_structure structure, or NULL on error. ++ */ ++extern struct esg_encapsulation_structure *esg_encapsulation_structure_decode(uint8_t *buffer, uint32_t size); ++ ++/** ++ * Free an esg_encapsulation_structure. ++ * ++ * @param container Pointer to an esg_container structure. ++ */ ++extern void esg_encapsulation_structure_free(struct esg_encapsulation_structure *structure); ++ ++/** ++ * Convenience iterator for entry_list field of an esg_encapsulation_structure. ++ * ++ * @param structure The esg_encapsulation_structure pointer. ++ * @param entry Variable holding a pointer to the current esg_encapsulation_entry. ++ */ ++#define esg_encapsulation_structure_entry_list_for_each(structure, entry) \ ++ for ((entry) = (structure)->entry_list; \ ++ (entry); \ ++ (entry) = (entry)->_next) ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/Makefile dvb-apps/lib/libesg/encapsulation/Makefile +--- linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/encapsulation/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,28 @@ ++# Makefile for linuxtv.org dvb-apps/lib/libesg/encapsulation ++ ++.PHONY: sub-error-encapsulation ++ ++sub-error-encapsulation: ++ $(error You can't use this makefile directly.) ++ ++ifneq ($(lib_name),) ++ ++objects += encapsulation/container.o \ ++ encapsulation/fragment_management_information.o \ ++ encapsulation/data_repository.o \ ++ encapsulation/string_repository.o ++ ++sub-install += encapsulation ++ ++else ++ ++includes = container.h \ ++ fragment_management_information.h \ ++ data_repository.h \ ++ string_repository.h ++ ++include ../../../Make.rules ++ ++lib_name = libesg/encapsulation ++ ++endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/string_repository.c dvb-apps/lib/libesg/encapsulation/string_repository.c +--- linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/string_repository.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/encapsulation/string_repository.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,54 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++ ++#include ++ ++struct esg_string_repository *esg_string_repository_decode(uint8_t *buffer, uint32_t size) { ++ struct esg_string_repository *string_repository; ++ ++ if ((buffer == NULL) || (size <= 1)) { ++ return NULL; ++ } ++ ++ string_repository = (struct esg_string_repository *) malloc(sizeof(struct esg_string_repository)); ++ memset(string_repository, 0, sizeof(struct esg_string_repository)); ++ ++ string_repository->encoding_type = buffer[0]; ++ string_repository->length = size-1; ++ string_repository->data = (uint8_t *) malloc(size-1); ++ memcpy(string_repository->data, buffer+1, size-1); ++ ++ return string_repository; ++} ++ ++void esg_string_repository_free(struct esg_string_repository *string_repository) { ++ if (string_repository == NULL) { ++ return; ++ } ++ ++ if (string_repository->data) { ++ free(string_repository->data); ++ } ++ ++ free(string_repository); ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/string_repository.h dvb-apps/lib/libesg/encapsulation/string_repository.h +--- linuxtv-dvb-apps-1.1.1/lib/libesg/encapsulation/string_repository.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/encapsulation/string_repository.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,60 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _ESG_ENCAPSULATION_STRING_REPOSITORY_H ++#define _ESG_ENCAPSULATION_STRING_REPOSITORY_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * esg_string_repository structure. ++ */ ++struct esg_string_repository { ++ uint8_t encoding_type; ++ uint32_t length; ++ uint8_t *data; ++}; ++ ++/** ++ * Process an esg_string_repository. ++ * ++ * @param buffer Binary buffer to decode. ++ * @param size Binary buffer size. ++ * @return Pointer to an esg_string_repository structure, or NULL on error. ++ */ ++extern struct esg_string_repository *esg_string_repository_decode(uint8_t *buffer, uint32_t size); ++ ++/** ++ * Free an esg_string_repository. ++ * ++ * @param data_repository Pointer to an esg_string_repository structure. ++ */ ++extern void esg_string_repository_free(struct esg_string_repository *string_repository); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/Makefile dvb-apps/lib/libesg/Makefile +--- linuxtv-dvb-apps-1.1.1/lib/libesg/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,27 @@ ++# Makefile for linuxtv.org dvb-apps/lib/libesg ++ ++includes = types.h ++ ++objects = types.o ++ ++lib_name = libesg ++ ++CPPFLAGS += -I../../lib ++ ++.PHONY: all ++ ++all: library ++ ++include bootstrap/Makefile ++include encapsulation/Makefile ++include representation/Makefile ++include transport/Makefile ++ ++.PHONY: $(sub-install) ++ ++install:: $(sub-install) ++ ++$(sub-install): ++ $(MAKE) -C $@ install ++ ++include ../../Make.rules +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/representation/bim_decoder_init.h dvb-apps/lib/libesg/representation/bim_decoder_init.h +--- linuxtv-dvb-apps-1.1.1/lib/libesg/representation/bim_decoder_init.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/representation/bim_decoder_init.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,40 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _ESG_REPRESENTATION_BIM_DECODER_INIT_H ++#define _ESG_REPRESENTATION_BIM_DECODER_INIT_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++/** ++ * esg_bim_decoder_init structure. ++ */ ++struct esg_bim_decoder_init { ++// TODO ++}; ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/representation/encapsulated_bim_esg_xml_fragment.h dvb-apps/lib/libesg/representation/encapsulated_bim_esg_xml_fragment.h +--- linuxtv-dvb-apps-1.1.1/lib/libesg/representation/encapsulated_bim_esg_xml_fragment.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/representation/encapsulated_bim_esg_xml_fragment.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,40 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _ESG_REPRESENTATION_ENCAPSULATED_BIM_ESG_XML_FRAGMENT_H ++#define _ESG_REPRESENTATION_ENCAPSULATED_BIM_ESG_XML_FRAGMENT_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++/** ++ * esg_encapsulated_bim_esg_xml_fragment structure. ++ */ ++struct esg_encapsulated_bim_esg_xml_fragment { ++ //TODO ++}; ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/representation/encapsulated_textual_esg_xml_fragment.c dvb-apps/lib/libesg/representation/encapsulated_textual_esg_xml_fragment.c +--- linuxtv-dvb-apps-1.1.1/lib/libesg/representation/encapsulated_textual_esg_xml_fragment.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/representation/encapsulated_textual_esg_xml_fragment.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,70 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++ ++#include ++#include ++ ++struct esg_encapsulated_textual_esg_xml_fragment *esg_encapsulated_textual_esg_xml_fragment_decode(uint8_t *buffer, uint32_t size) { ++ struct esg_encapsulated_textual_esg_xml_fragment *esg_xml_fragment; ++ uint32_t pos; ++ uint32_t length; ++ uint8_t offset_pos; ++ ++ if ((buffer == NULL) || (size <= 0)) { ++ return NULL; ++ } ++ ++ pos = 0; ++ ++ esg_xml_fragment = (struct esg_encapsulated_textual_esg_xml_fragment *) malloc(sizeof(struct esg_encapsulated_textual_esg_xml_fragment)); ++ memset(esg_xml_fragment, 0, sizeof(struct esg_encapsulated_textual_esg_xml_fragment)); ++ ++ offset_pos = vluimsbf8(buffer+pos+2, size-pos-2, &length); ++ ++ if (size-pos-2 < offset_pos+length) { ++ esg_encapsulated_textual_esg_xml_fragment_free(esg_xml_fragment); ++ return NULL; ++ } ++ ++ esg_xml_fragment->esg_xml_fragment_type = (buffer[pos] << 8) | buffer[pos+1]; ++ pos += 2+offset_pos; ++ ++ esg_xml_fragment->data_length = length; ++ esg_xml_fragment->data = (uint8_t *) malloc(length); ++ memcpy(esg_xml_fragment->data, buffer+pos, length); ++ pos += length; ++ ++ return esg_xml_fragment; ++} ++ ++void esg_encapsulated_textual_esg_xml_fragment_free(struct esg_encapsulated_textual_esg_xml_fragment *esg_xml_fragment) { ++ if (esg_xml_fragment == NULL) { ++ return; ++ } ++ ++ if (esg_xml_fragment->data) { ++ free(esg_xml_fragment->data); ++ } ++ ++ free(esg_xml_fragment); ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/representation/encapsulated_textual_esg_xml_fragment.h dvb-apps/lib/libesg/representation/encapsulated_textual_esg_xml_fragment.h +--- linuxtv-dvb-apps-1.1.1/lib/libesg/representation/encapsulated_textual_esg_xml_fragment.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/representation/encapsulated_textual_esg_xml_fragment.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,60 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _ESG_REPRESENTATION_ENCAPSULATED_TEXTUAL_ESG_XML_FRAGMENT_H ++#define _ESG_REPRESENTATION_ENCAPSULATED_TEXTUAL_ESG_XML_FRAGMENT_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * esg_encapsulated_textual_esg_xml_fragment structure. ++ */ ++struct esg_encapsulated_textual_esg_xml_fragment { ++ uint16_t esg_xml_fragment_type; ++ uint32_t data_length; ++ uint8_t *data; ++}; ++ ++/** ++ * Process an esg_encapsulated_textual_esg_xml_fragment. ++ * ++ * @param buffer Binary buffer to decode. ++ * @param size Binary buffer size. ++ * @return Pointer to an esg_encapsulated_textual_esg_xml_fragment structure, or NULL on error. ++ */ ++extern struct esg_encapsulated_textual_esg_xml_fragment *esg_encapsulated_textual_esg_xml_fragment_decode(uint8_t *buffer, uint32_t size); ++ ++/** ++ * Free an esg_encapsulated_textual_esg_xml_fragment. ++ * ++ * @param data_repository Pointer to an esg_encapsulated_textual_esg_xml_fragment structure. ++ */ ++extern void esg_encapsulated_textual_esg_xml_fragment_free(struct esg_encapsulated_textual_esg_xml_fragment *esg_xml_fragment); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/representation/init_message.c dvb-apps/lib/libesg/representation/init_message.c +--- linuxtv-dvb-apps-1.1.1/lib/libesg/representation/init_message.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/representation/init_message.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,112 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++ ++#include ++#include ++#include ++ ++struct esg_init_message *esg_init_message_decode(uint8_t *buffer, uint32_t size) { ++ uint32_t pos; ++ struct esg_init_message *init_message; ++ ++ if ((buffer == NULL) || (size <= 3)) { ++ return NULL; ++ } ++ ++ pos = 0; ++ ++ init_message = (struct esg_init_message *) malloc(sizeof(struct esg_init_message)); ++ memset(init_message, 0, sizeof(struct esg_init_message)); ++ ++ init_message->encoding_version = buffer[pos]; ++ pos += 1; ++ ++ init_message->indexing_flag = (buffer[pos] & 0x80) >> 7; ++ pos += 1; ++ ++ init_message->decoder_init_ptr = buffer[pos]; ++ pos += 1; ++ ++ if (init_message->indexing_flag) { ++ init_message->indexing_version = buffer[pos]; ++ pos += 1; ++ } ++ ++ switch (init_message->encoding_version) { ++ case 0xF1: { ++ struct esg_bim_encoding_parameters *encoding_parameters = (struct esg_bim_encoding_parameters *) malloc(sizeof(struct esg_bim_encoding_parameters)); ++ memset(encoding_parameters, 0, sizeof(struct esg_bim_encoding_parameters)); ++ init_message->encoding_parameters = (void *) encoding_parameters; ++ ++ encoding_parameters->buffer_size_flag = (buffer[pos] & 0x80) >> 7; ++ encoding_parameters->position_code_flag = (buffer[pos] & 0x40) >> 6; ++ pos += 1; ++ ++ encoding_parameters->character_encoding = buffer[pos]; ++ pos += 1; ++ ++ if (encoding_parameters->buffer_size_flag) { ++ encoding_parameters->buffer_size = (buffer[pos] << 16) | (buffer[pos+1] << 8) | buffer[pos+2]; ++ pos += 3; ++ } ++ ++// TODO ++// init_message->decoder_init = (void *) esg_bim_decoder_init_decode(buffer + init_message->decoder_init_ptr, size - init_message->decoder_init_ptr); ++ break; ++ } ++ case 0xF2: ++ case 0xF3: { ++ struct esg_textual_encoding_parameters *encoding_parameters = (struct esg_textual_encoding_parameters *) malloc(sizeof(struct esg_textual_encoding_parameters)); ++ memset(encoding_parameters, 0, sizeof(struct esg_textual_encoding_parameters)); ++ init_message->encoding_parameters = (void *) encoding_parameters; ++ ++ encoding_parameters->character_encoding = buffer[pos]; ++ pos += 1; ++ ++ init_message->decoder_init = (void *) esg_textual_decoder_init_decode(buffer + init_message->decoder_init_ptr, size - init_message->decoder_init_ptr); ++ break; ++ } ++ default: { ++ esg_init_message_free(init_message); ++ return NULL; ++ } ++ } ++ ++ return init_message; ++} ++ ++void esg_init_message_free(struct esg_init_message *init_message) { ++ if (init_message == NULL) { ++ return; ++ } ++ ++ if (init_message->encoding_parameters) { ++ free(init_message->encoding_parameters); ++ } ++ ++ if (init_message->decoder_init) { ++ free(init_message->decoder_init); ++ } ++ ++ free(init_message); ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/representation/init_message.h dvb-apps/lib/libesg/representation/init_message.h +--- linuxtv-dvb-apps-1.1.1/lib/libesg/representation/init_message.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/representation/init_message.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,80 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _ESG_REPRESENTATION_INIT_MESSAGE_H ++#define _ESG_REPRESENTATION_INIT_MESSAGE_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * esg_textual_encoding_parameters structure. ++ */ ++struct esg_textual_encoding_parameters { ++ uint8_t character_encoding; ++}; ++ ++/** ++ * esg_bim_encoding_parameters structure. ++ */ ++struct esg_bim_encoding_parameters { ++ uint8_t buffer_size_flag; ++ uint8_t position_code_flag; ++ uint8_t character_encoding; ++ uint32_t buffer_size; // if buffer_size_flag ++}; ++ ++/** ++ * esg_init_message structure. ++ */ ++struct esg_init_message { ++ uint8_t encoding_version; ++ uint8_t indexing_flag; ++ uint8_t decoder_init_ptr; ++ uint8_t indexing_version; // if indexing_flag ++ void *encoding_parameters; ++ void *decoder_init; ++}; ++ ++/** ++ * Process an esg_init_message. ++ * ++ * @param buffer Binary buffer to decode. ++ * @param size Binary buffer size. ++ * @return Pointer to an esg_string_repository structure, or NULL on error. ++ */ ++extern struct esg_init_message *esg_init_message_decode(uint8_t *buffer, uint32_t size); ++ ++/** ++ * Free an esg_init_message. ++ * ++ * @param init_message Pointer to an esg_init_message structure. ++ */ ++extern void esg_init_message_free(struct esg_init_message *init_message); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/representation/Makefile dvb-apps/lib/libesg/representation/Makefile +--- linuxtv-dvb-apps-1.1.1/lib/libesg/representation/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/representation/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,26 @@ ++# Makefile for linuxtv.org dvb-apps/lib/libesg/representation ++ ++.PHONY: sub-error-representation ++ ++sub-error-representation: ++ $(error You can't use this makefile directly.) ++ ++ifneq ($(lib_name),) ++ ++objects += representation/encapsulated_textual_esg_xml_fragment.o \ ++ representation/init_message.o \ ++ representation/textual_decoder_init.o ++ ++sub-install += representation ++ ++else ++ ++includes = encapsulated_textual_esg_xml_fragment.h \ ++ init_message.h \ ++ textual_decoder_init.h ++ ++include ../../../Make.rules ++ ++lib_name = libesg/representation ++ ++endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/representation/textual_decoder_init.c dvb-apps/lib/libesg/representation/textual_decoder_init.c +--- linuxtv-dvb-apps-1.1.1/lib/libesg/representation/textual_decoder_init.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/representation/textual_decoder_init.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,128 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++ ++#include ++#include ++ ++struct esg_textual_decoder_init *esg_textual_decoder_init_decode(uint8_t *buffer, uint32_t size) { ++ uint32_t pos; ++ struct esg_textual_decoder_init *decoder_init; ++ struct esg_namespace_prefix *namespace_prefix; ++ struct esg_namespace_prefix *last_namespace_prefix; ++ struct esg_xml_fragment_type *xml_fragment_type; ++ struct esg_xml_fragment_type *last_xml_fragment_type; ++ uint32_t decoder_init_length; ++ uint8_t num_index; ++ ++ if ((buffer == NULL) || (size <= 1)) { ++ return NULL; ++ } ++ ++ pos = 0; ++ ++ decoder_init = (struct esg_textual_decoder_init *) malloc(sizeof(struct esg_textual_decoder_init)); ++ memset(decoder_init, 0, sizeof(struct esg_textual_decoder_init)); ++ decoder_init->namespace_prefix_list = NULL; ++ decoder_init->xml_fragment_type_list = NULL; ++ ++ decoder_init->version = buffer[pos]; ++ pos += 1; ++ ++ pos += vluimsbf8(buffer+pos, size-pos, &decoder_init_length); ++ ++ if (size < pos + decoder_init_length) { ++ esg_textual_decoder_init_free(decoder_init); ++ return NULL; ++ } ++ ++ decoder_init->num_namespace_prefixes = buffer[pos]; ++ pos += 1; ++ ++ last_namespace_prefix = NULL; ++ for (num_index = 0; num_index < decoder_init->num_namespace_prefixes; num_index++) { ++ namespace_prefix = (struct esg_namespace_prefix *) malloc(sizeof(struct esg_namespace_prefix)); ++ memset(namespace_prefix, 0, sizeof(struct esg_namespace_prefix)); ++ namespace_prefix->_next = NULL; ++ ++ if (last_namespace_prefix == NULL) { ++ decoder_init->namespace_prefix_list = namespace_prefix; ++ } else { ++ last_namespace_prefix->_next = namespace_prefix; ++ } ++ last_namespace_prefix = namespace_prefix; ++ ++ namespace_prefix->prefix_string_ptr = (buffer[pos] << 8) | buffer[pos+1]; ++ pos += 2; ++ ++ namespace_prefix->namespace_uri_ptr = (buffer[pos] << 8) | buffer[pos+1]; ++ pos += 2; ++ } ++ ++ decoder_init->num_fragment_types = buffer[pos]; ++ pos += 1; ++ ++ last_xml_fragment_type = NULL; ++ for (num_index = 0; num_index < decoder_init->num_fragment_types; num_index++) { ++ xml_fragment_type = (struct esg_xml_fragment_type *) malloc(sizeof(struct esg_xml_fragment_type)); ++ memset(xml_fragment_type, 0, sizeof(struct esg_xml_fragment_type)); ++ xml_fragment_type->_next = NULL; ++ ++ if (last_xml_fragment_type == NULL) { ++ decoder_init->xml_fragment_type_list = xml_fragment_type; ++ } else { ++ last_xml_fragment_type->_next = xml_fragment_type; ++ } ++ last_xml_fragment_type = xml_fragment_type; ++ ++ xml_fragment_type->xpath_ptr = (buffer[pos] << 8) | buffer[pos+1]; ++ pos += 2; ++ ++ xml_fragment_type->xml_fragment_type = (buffer[pos] << 8) | buffer[pos+1]; ++ pos += 2; ++ } ++ ++ return decoder_init; ++} ++ ++void esg_textual_decoder_init_free(struct esg_textual_decoder_init *decoder_init) { ++ struct esg_namespace_prefix *namespace_prefix; ++ struct esg_namespace_prefix *next_namespace_prefix; ++ struct esg_xml_fragment_type *xml_fragment_type; ++ struct esg_xml_fragment_type *next_xml_fragment_type; ++ ++ if (decoder_init == NULL) { ++ return; ++ } ++ ++ for(namespace_prefix = decoder_init->namespace_prefix_list; namespace_prefix; namespace_prefix = next_namespace_prefix) { ++ next_namespace_prefix = namespace_prefix->_next; ++ free(namespace_prefix); ++ } ++ ++ for(xml_fragment_type = decoder_init->xml_fragment_type_list; xml_fragment_type; xml_fragment_type = next_xml_fragment_type) { ++ next_xml_fragment_type = xml_fragment_type->_next; ++ free(xml_fragment_type); ++ } ++ ++ free(decoder_init); ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/representation/textual_decoder_init.h dvb-apps/lib/libesg/representation/textual_decoder_init.h +--- linuxtv-dvb-apps-1.1.1/lib/libesg/representation/textual_decoder_init.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/representation/textual_decoder_init.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,104 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _ESG_REPRESENTATION_TEXTUAL_DECODER_INIT_H ++#define _ESG_REPRESENTATION_TEXTUAL_DECODER_INIT_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * esg_namespace_prefix structure. ++ */ ++struct esg_namespace_prefix { ++ uint16_t prefix_string_ptr; ++ uint16_t namespace_uri_ptr; ++ ++ struct esg_namespace_prefix *_next; ++}; ++ ++/** ++ * esg_fragment_type structure. ++ */ ++struct esg_xml_fragment_type { ++ uint16_t xpath_ptr; ++ uint16_t xml_fragment_type; ++ ++ struct esg_xml_fragment_type *_next; ++}; ++ ++/** ++ * esg_textual_decoder_init structure. ++ */ ++struct esg_textual_decoder_init { ++ uint8_t version; ++ uint8_t num_namespace_prefixes; ++ struct esg_namespace_prefix *namespace_prefix_list; ++ uint8_t num_fragment_types; ++ struct esg_xml_fragment_type *xml_fragment_type_list; ++}; ++ ++/** ++ * Process an esg_textual_decoder_init. ++ * ++ * @param buffer Binary buffer to decode. ++ * @param size Binary buffer size. ++ * @return Pointer to an esg_textual_decoder_init structure, or NULL on error. ++ */ ++extern struct esg_textual_decoder_init *esg_textual_decoder_init_decode(uint8_t *buffer, uint32_t size); ++ ++/** ++ * Free an esg_textual_decoder_init. ++ * ++ * @param decoder_init Pointer to an esg_textual_decoder_init structure. ++ */ ++extern void esg_textual_decoder_init_free(struct esg_textual_decoder_init *decoder_init); ++ ++/** ++ * Convenience iterator for namespace_prefix_list field of an esg_textual_decoder_init. ++ * ++ * @param decoder_init The esg_textual_decoder_init pointer. ++ * @param namespace_prefix Variable holding a pointer to the current esg_namespace_prefix. ++ */ ++#define esg_textual_decoder_namespace_prefix_list_for_each(decoder_init, namespace_prefix) \ ++ for ((namespace_prefix) = (decoder_init)->namespace_prefix_list; \ ++ (namespace_prefix); \ ++ (namespace_prefix) = (namespace_prefix)->_next) ++ ++/** ++ * Convenience iterator for xml_fragment_type_list field of an esg_textual_decoder_init. ++ * ++ * @param decoder_init The esg_textual_decoder_init pointer. ++ * @param xml_fragment_type Variable holding a pointer to the current esg_xml_fragment_type. ++ */ ++#define esg_textual_decoder_xml_fragment_type_list_for_each(decoder_init, xml_fragment_type) \ ++ for ((xml_fragment_type) = (decoder_init)->xml_fragment_type_list; \ ++ (xml_fragment_type); \ ++ (xml_fragment_type) = (xml_fragment_type)->_next) ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/TODO dvb-apps/lib/libesg/TODO +--- linuxtv-dvb-apps-1.1.1/lib/libesg/TODO 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/TODO 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,18 @@ ++*** General ++- Add enums for constants ++ ++*** EncodingVersion ++- GZIP : use zlib ++- BiM : ??? ++ ++*** BOOTSTRAP ++- ESGProviderDiscoveryDescriptor : XML parsing with libexpat ? ++ ++*** TRANSPORT ++- Indexation ++ ++*** ENCAPSULATION ++- Auxiliary Data ++ ++*** REPRESENTATION ++- BiM Decoder Init +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/transport/Makefile dvb-apps/lib/libesg/transport/Makefile +--- linuxtv-dvb-apps-1.1.1/lib/libesg/transport/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/transport/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,22 @@ ++# Makefile for linuxtv.org dvb-apps/lib/libesg/transport ++ ++.PHONY: sub-error-transport ++ ++sub-error-transport: ++ $(error You can't use this makefile directly.) ++ ++ifneq ($(lib_name),) ++ ++objects += transport/session_partition_declaration.o ++ ++sub-install += transport ++ ++else ++ ++includes = session_partition_declaration.h ++ ++include ../../../Make.rules ++ ++lib_name = libesg/transport ++ ++endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/transport/session_partition_declaration.c dvb-apps/lib/libesg/transport/session_partition_declaration.c +--- linuxtv-dvb-apps-1.1.1/lib/libesg/transport/session_partition_declaration.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/transport/session_partition_declaration.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,253 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++ ++#include ++ ++struct esg_session_partition_declaration *esg_session_partition_declaration_decode(uint8_t *buffer, uint32_t size) { ++ uint32_t pos; ++ struct esg_session_partition_declaration *partition; ++ struct esg_session_field *field; ++ struct esg_session_field *last_field; ++ uint8_t field_index; ++ struct esg_session_ip_stream *ip_stream; ++ struct esg_session_ip_stream *last_ip_stream; ++ uint8_t ip_stream_index; ++ uint8_t ip_index; ++ struct esg_session_ip_stream_field *ip_stream_field; ++ struct esg_session_ip_stream_field *last_ip_stream_field; ++ uint8_t *field_buffer; ++ uint32_t field_length; ++ union esg_session_ip_stream_field_value *field_value; ++ ++ if ((buffer == NULL) || (size <= 2)) { ++ return NULL; ++ } ++ ++ pos = 0; ++ ++ partition = (struct esg_session_partition_declaration *) malloc(sizeof(struct esg_session_partition_declaration)); ++ memset(partition, 0, sizeof(struct esg_session_partition_declaration)); ++ partition->field_list = NULL; ++ partition->ip_stream_list = NULL; ++ ++ partition->num_fields = buffer[pos]; ++ pos += 1; ++ ++ partition->overlapping = (buffer[pos] & 0x80) ? 1 : 0; ++ pos += 1; ++ ++ if (size < (pos + 5*(partition->num_fields))) { ++ esg_session_partition_declaration_free(partition); ++ return NULL; ++ } ++ ++ last_field = NULL; ++ for (field_index = 0; field_index < partition->num_fields; field_index++) { ++ field = (struct esg_session_field *) malloc(sizeof(struct esg_session_field)); ++ memset(field, 0, sizeof(struct esg_session_field)); ++ field->_next = NULL; ++ ++ if (last_field == NULL) { ++ partition->field_list = field; ++ } else { ++ last_field->_next = field; ++ } ++ last_field = field; ++ ++ field->identifier = (buffer[pos] << 8) | buffer[pos+1]; ++ pos += 2; ++ ++ field->encoding = (buffer[pos] << 8) | buffer[pos+1]; ++ pos += 2; ++ ++ field->length = buffer[pos]; ++ pos += 1; ++ } ++ ++ partition->n_o_ip_streams = buffer[pos]; ++ pos += 1; ++ ++ partition->ip_version_6 = (buffer[pos] & 0x80) ? 1 : 0; ++ pos += 1; ++ ++ last_ip_stream = NULL; ++ for (ip_stream_index = 0; ip_stream_index < partition->n_o_ip_streams; ip_stream_index++) { ++ ip_stream = (struct esg_session_ip_stream *) malloc(sizeof(struct esg_session_ip_stream)); ++ memset(ip_stream, 0, sizeof(struct esg_session_ip_stream)); ++ ip_stream->_next = NULL; ++ ++ if (last_ip_stream == NULL) { ++ partition->ip_stream_list = ip_stream; ++ } else { ++ last_ip_stream->_next = ip_stream; ++ } ++ last_ip_stream = ip_stream; ++ ++ ip_stream->id = buffer[pos]; ++ pos += 1; ++ ++ if (partition->ip_version_6) { ++ for (ip_index = 0; ip_index < 16; ip_index++) { ++ ip_stream->source_ip.ipv6[ip_index] = buffer[pos+ip_index]; ++ ip_stream->destination_ip.ipv6[ip_index] = buffer[pos+16+ip_index]; ++ } ++ pos += 32; ++ } else { ++ for (ip_index = 0; ip_index < 4; ip_index++) { ++ ip_stream->source_ip.ipv4[ip_index] = buffer[pos+ip_index]; ++ ip_stream->destination_ip.ipv4[ip_index] = buffer[pos+4+ip_index]; ++ } ++ pos += 8; ++ } ++ ip_stream->port = (buffer[pos] << 8) | buffer[pos+1]; ++ pos += 2; ++ ++ ip_stream->session_id = (buffer[pos] << 8) | buffer[pos+1]; ++ pos += 2; ++ ++ last_ip_stream_field = NULL; ++ esg_session_partition_declaration_field_list_for_each(partition, field) { ++ ip_stream_field = (struct esg_session_ip_stream_field *) malloc(sizeof(struct esg_session_ip_stream_field)); ++ memset(ip_stream_field, 0, sizeof(struct esg_session_ip_stream_field)); ++ ip_stream_field->_next = NULL; ++ ip_stream_field->start_field_value = NULL; ++ ip_stream_field->end_field_value = NULL; ++ ++ if (last_ip_stream_field == NULL) { ++ ip_stream->field_list = ip_stream_field; ++ } else { ++ last_ip_stream_field->_next = ip_stream_field; ++ } ++ last_ip_stream_field = ip_stream_field; ++ ++ field_length = field->length; ++ if (field->length != 0) { ++ field_length = field->length; ++ } else { ++ pos += vluimsbf8(buffer + pos, size - pos, &field_length); ++ } ++ ++ switch (field->encoding) { ++ case 0x0000: { ++ if (partition->overlapping == 1) { ++ field_value = (union esg_session_ip_stream_field_value *) malloc(sizeof(union esg_session_ip_stream_field_value)); ++ memset(field_value, 0, sizeof(union esg_session_ip_stream_field_value)); ++ ip_stream_field->start_field_value = field_value; ++ ++ field_buffer = (uint8_t *) malloc(field_length); ++ memset(field_buffer, 0, field_length); ++ memcpy(field_buffer, buffer + pos, field_length); ++ ++ ip_stream_field->start_field_value->string = field_buffer; ++ pos += field_length; ++ } ++ field_value = (union esg_session_ip_stream_field_value *) malloc(sizeof(union esg_session_ip_stream_field_value)); ++ memset(field_value, 0, sizeof(union esg_session_ip_stream_field_value)); ++ ip_stream_field->end_field_value = field_value; ++ ++ field_buffer = (uint8_t *) malloc(field_length); ++ memset(field_buffer, 0, field_length); ++ memcpy(field_buffer, buffer + pos, field_length); ++ ++ ip_stream_field->end_field_value->string = field_buffer; ++ pos += field_length; ++ ++ break; ++ } ++ case 0x0101: { ++ if (partition->overlapping == 1) { ++ field_value = (union esg_session_ip_stream_field_value *) malloc(sizeof(union esg_session_ip_stream_field_value)); ++ memset(field_value, 0, sizeof(union esg_session_ip_stream_field_value)); ++ ip_stream_field->start_field_value = field_value; ++ ++ ip_stream_field->start_field_value->unsigned_short = (buffer[pos] << 8) | buffer[pos+1]; ++ pos += field_length; ++ } ++ field_value = (union esg_session_ip_stream_field_value *) malloc(sizeof(union esg_session_ip_stream_field_value)); ++ memset(field_value, 0, sizeof(union esg_session_ip_stream_field_value)); ++ ip_stream_field->end_field_value = field_value; ++ ++ ip_stream_field->end_field_value->unsigned_short = (buffer[pos] << 8) | buffer[pos+1]; ++ pos += field_length; ++ ++ break; ++ } ++ default: { ++ esg_session_partition_declaration_free(partition); ++ return NULL; ++ } ++ } ++ } ++ } ++ ++ return partition; ++} ++ ++void esg_session_partition_declaration_free(struct esg_session_partition_declaration *partition) { ++ struct esg_session_field *field; ++ struct esg_session_field *next_field; ++ struct esg_session_ip_stream *ip_stream; ++ struct esg_session_ip_stream *next_ip_stream; ++ struct esg_session_ip_stream_field *ip_stream_field; ++ struct esg_session_ip_stream_field *next_ip_stream_field; ++ ++ if (partition == NULL) { ++ return; ++ } ++ ++ for(ip_stream = partition->ip_stream_list; ip_stream; ip_stream = next_ip_stream) { ++ next_ip_stream = ip_stream->_next; ++ ++ field = partition->field_list; ++ for(ip_stream_field = next_ip_stream->field_list; ip_stream_field; ip_stream_field = next_ip_stream_field) { ++ next_ip_stream_field = ip_stream_field->_next; ++ ++ switch (field->encoding) { ++ case 0x0000: { ++ if (ip_stream_field->start_field_value != NULL) { ++ free(ip_stream_field->start_field_value->string); ++ } ++ free(ip_stream_field->end_field_value->string); ++ break; ++ } ++ case 0x0101: { ++ // Nothing to free ++ break; ++ } ++ } ++ ++ free(ip_stream_field); ++ ++ field = field->_next; ++ } ++ ++ free(ip_stream); ++ } ++ ++ for(field = partition->field_list; field; field = next_field) { ++ next_field = field->_next; ++ free(field); ++ } ++ ++ free(partition); ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/transport/session_partition_declaration.h dvb-apps/lib/libesg/transport/session_partition_declaration.h +--- linuxtv-dvb-apps-1.1.1/lib/libesg/transport/session_partition_declaration.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/transport/session_partition_declaration.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,139 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _ESG_TRANSPORT_SESSION_PARTITION_DECLARATION_H ++#define _ESG_TRANSPORT_SESSION_PARTITION_DECLARATION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * esg_session_field structure. ++ */ ++struct esg_session_field { ++ uint16_t identifier; ++ uint16_t encoding; ++ uint8_t length; ++ ++ struct esg_session_field *_next; ++}; ++ ++/** ++ * esg_session_ip_stream_field_value union. ++ */ ++union esg_session_ip_stream_field_value { ++ uint8_t *string; ++ uint16_t unsigned_short; ++}; ++ ++/** ++ * esg_session_ip_stream_field structure. ++ */ ++struct esg_session_ip_stream_field { ++ union esg_session_ip_stream_field_value *start_field_value; ++ union esg_session_ip_stream_field_value *end_field_value; ++ ++ struct esg_session_ip_stream_field *_next; ++}; ++ ++/** ++ * esg_session_ip_stream structure. ++ */ ++struct esg_session_ip_stream { ++ uint8_t id; ++ union esg_ip_address source_ip; ++ union esg_ip_address destination_ip; ++ uint16_t port; ++ uint16_t session_id; ++ struct esg_session_ip_stream_field *field_list; ++ ++ struct esg_session_ip_stream *_next; ++}; ++ ++/** ++ * esg_session_partition_declaration structure. ++ */ ++struct esg_session_partition_declaration { ++ uint8_t num_fields; ++ uint8_t overlapping; ++ struct esg_session_field *field_list; ++ uint8_t n_o_ip_streams; ++ uint8_t ip_version_6; ++ struct esg_session_ip_stream *ip_stream_list; ++}; ++ ++/** ++ * Process an esg_session_partition_declaration. ++ * ++ * @param buffer Binary buffer to decode. ++ * @param size Binary buffer size. ++ * @return Pointer to an esg_session_partition_declaration structure, or NULL on error. ++ */ ++extern struct esg_session_partition_declaration *esg_session_partition_declaration_decode(uint8_t *buffer, uint32_t size); ++ ++/** ++ * Free an esg_session_partition_declaration. ++ * ++ * @param esg Pointer to an esg_session_partition_declaration structure. ++ */ ++extern void esg_session_partition_declaration_free(struct esg_session_partition_declaration *partition); ++ ++/** ++ * Convenience iterator for field_list field of an esg_session_partition_declaration. ++ * ++ * @param partition The esg_session_partition_declaration pointer. ++ * @param field Variable holding a pointer to the current esg_session_field. ++ */ ++#define esg_session_partition_declaration_field_list_for_each(partition, field) \ ++ for ((field) = (partition)->field_list; \ ++ (field); \ ++ (field) = (field)->_next) ++ ++/** ++ * Convenience iterator for ip_stream_list field of an esg_session_partition_declaration. ++ * ++ * @param partition The esg_session_partition_declaration pointer. ++ * @param ip_stream Variable holding a pointer to the current esg_session_ip_stream. ++ */ ++#define esg_session_partition_declaration_ip_stream_list_for_each(partition, ip_stream) \ ++ for ((ip_stream) = (partition)->ip_stream_list; \ ++ (ip_stream); \ ++ (ip_stream) = (ip_stream)->_next) ++ ++/** ++ * Convenience iterator for field_list field of an esg_session_ip_stream. ++ * ++ * @param ip_stream The esg_session_ip_stream pointer. ++ * @param field Variable holding a pointer to the current esg_session_ip_stream. ++ */ ++#define esg_session_ip_stream_field_list_for_each(ip_stream, field) \ ++ for ((field) = (ip_stream)->field_list; \ ++ (field); \ ++ (field) = (field)->_next) ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/types.c dvb-apps/lib/libesg/types.c +--- linuxtv-dvb-apps-1.1.1/lib/libesg/types.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/types.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,37 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++uint8_t vluimsbf8(uint8_t *buffer, uint32_t size, uint32_t *length) { ++ uint8_t offset = 0; ++ *length = 0; ++ ++ do { ++ if (size < offset) { ++ offset = 0; ++ *length = 0; ++ break; ++ } ++ *length = (*length << 7) + (buffer[offset] & 0x7F); ++ } while (buffer[offset++] & 0x80); ++ ++ return offset; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/types.h dvb-apps/lib/libesg/types.h +--- linuxtv-dvb-apps-1.1.1/lib/libesg/types.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/types.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,53 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _ESG_TYPES_H ++#define _ESG_TYPES_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * esg_ip_address ++ */ ++union esg_ip_address { ++ uint8_t ipv4[4]; ++ uint8_t ipv6[16]; ++}; ++ ++/** ++ * Process a vluimsbf8 length. ++ * ++ * @param buffer Binary buffer to decode. ++ * @param size Binary buffer size. ++ * @param length Read length value ++ * @return vluimsbf8 size ++ */ ++extern uint8_t vluimsbf8(uint8_t *buffer, uint32_t size, uint32_t *length); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libesg/xml/provider_discovery_descriptor.xsd dvb-apps/lib/libesg/xml/provider_discovery_descriptor.xsd +--- linuxtv-dvb-apps-1.1.1/lib/libesg/xml/provider_discovery_descriptor.xsd 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libesg/xml/provider_discovery_descriptor.xsd 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,22 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/ac3_descriptor.h dvb-apps/lib/libucsi/atsc/ac3_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/ac3_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/ac3_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,112 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_atsc@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_AC3_DESCRIPTOR ++#define _UCSI_ATSC_AC3_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++enum atsc_ac3_channels { ++ ATSC_AC3_CHANNELS_1_PLUS_1 = 0x0, ++ ATSC_AC3_CHANNELS_1_0 = 0x1, ++ ATSC_AC3_CHANNELS_2_0 = 0x2, ++ ATSC_AC3_CHANNELS_3_0 = 0x3, ++ ATSC_AC3_CHANNELS_2_1 = 0x4, ++ ATSC_AC3_CHANNELS_3_1 = 0x5, ++ ATSC_AC3_CHANNELS_2_2 = 0x6, ++ ATSC_AC3_CHANNELS_3_2 = 0x7, ++ ATSC_AC3_CHANNELS_1 = 0x8, ++ ATSC_AC3_CHANNELS_LTEQ_2 = 0x9, ++ ATSC_AC3_CHANNELS_LTEQ_3 = 0xa, ++ ATSC_AC3_CHANNELS_LTEQ_4 = 0xb, ++ ATSC_AC3_CHANNELS_LTEQ_5 = 0xc, ++ ATSC_AC3_CHANNELS_LTEQ_6 = 0xd, ++}; ++ ++/** ++ * atsc_ac3_descriptor structure. ++ */ ++struct atsc_ac3_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint8_t sample_rate_code : 3; , ++ uint8_t bsid : 5; ); ++ EBIT2(uint8_t bit_rate_code : 6; , ++ uint8_t surround_mode : 2; ); ++ EBIT3(uint8_t bsmod : 3; , ++ uint8_t num_channels : 4; , ++ uint8_t full_svc : 1; ); ++ /* uint8_t additional_info[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an atsc_ac3_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return atsc_ac3_descriptor pointer, or NULL on error. ++ */ ++static inline struct atsc_ac3_descriptor* ++ atsc_ac3_descriptor_codec(struct descriptor* d) ++{ ++ int pos = 0; ++ ++ if (d->len < (pos+4)) ++ return NULL; ++ pos += 4; ++ ++ return (struct atsc_ac3_descriptor*) d; ++} ++ ++/** ++ * Retrieve pointer to additional_info field of a atsc_ac3_descriptor. ++ * ++ * @param d atsc_ac3_descriptor pointer. ++ * @return Pointer to additional_info field. ++ */ ++static inline uint8_t *atsc_ac3_descriptor_additional_info(struct atsc_ac3_descriptor *d) ++{ ++ int pos = sizeof(struct atsc_ac3_descriptor); ++ ++ return ((uint8_t *) d) + pos; ++} ++ ++/** ++ * Determine length of additional_info field of a atsc_ac3_descriptor. ++ * ++ * @param d atsc_ac3_descriptor pointer. ++ * @return Length of field in bytes. ++ */ ++static inline int atsc_ac3_descriptor_additional_info_length(struct atsc_ac3_descriptor* d) ++{ ++ return d->d.len - 3; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/atsc_text.c dvb-apps/lib/libucsi/atsc/atsc_text.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/atsc_text.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/atsc_text.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,743 @@ ++/* ++* section and descriptor parser ++* ++* Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++* ++* This library is free software; you can redistribute it and/or ++* modify it under the terms of the GNU Lesser General Public ++* License as published by the Free Software Foundation; either ++* version 2.1 of the License, or (at your option) any later version. ++* ++* This library 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 ++* Lesser General Public License for more details. ++* ++* You should have received a copy of the GNU Lesser General Public ++* License along with this library; if not, write to the Free Software ++* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++*/ ++ ++#include ++#include ++#include ++#include ++#include "libucsi/endianops.h" ++#include "libucsi/atsc/types.h" ++ ++#define HUFFTREE_LITERAL_MASK 0x80 ++#define HUFFSTRING_END 0x00 ++#define HUFFSTRING_ESCAPE 0x1b ++ ++#define DEST_ALLOC_DELTA 20 ++ ++struct hufftree_entry { ++ uint8_t left_idx; ++ uint8_t right_idx; ++} __ucsi_packed; ++ ++struct huffbuff { ++ uint8_t *buf; ++ uint32_t buf_len; ++ ++ uint32_t cur_byte; ++ uint8_t cur_bit; ++}; ++ ++ ++static struct hufftree_entry program_description_hufftree[][128] = { ++ { {0x14, 0x15}, {0x9b, 0xd6}, {0xc9, 0xcf}, {0xd7, 0xc7}, {0x01, 0xa2}, ++ {0xce, 0xcb}, {0x02, 0x03}, {0xc5, 0xcc}, {0xc6, 0xc8}, {0x04, 0xc4}, ++ {0x05, 0xc2}, {0x06, 0xc3}, {0xd2, 0x07}, {0xd3, 0x08}, {0xca, 0xd4}, ++ {0x09, 0xcd}, {0xd0, 0x0a}, {0xc1, 0x0b}, {0x0c, 0x0d}, {0x0e, 0x0f}, ++ {0x10, 0x11}, {0x12, 0x13}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x38, 0x39}, {0xad, 0xaf}, {0xb7, 0xda}, {0xa8, 0xb3}, {0xb5, 0x01}, ++ {0x02, 0x9b}, {0xb4, 0xf1}, {0xa2, 0xd5}, {0xd6, 0xd9}, {0x03, 0x04}, ++ {0x05, 0xcf}, {0x06, 0xc9}, {0xf9, 0xea}, {0xeb, 0xf5}, {0xf6, 0x07}, ++ {0x08, 0x09}, {0xb2, 0xc5}, {0xc6, 0xb1}, {0x0a, 0xee}, {0xcb, 0x0b}, ++ {0xd4, 0x0c}, {0xc4, 0xc8}, {0xd2, 0x0d}, {0x0e, 0x0f}, {0xc7, 0xca}, ++ {0xce, 0xd0}, {0xd7, 0x10}, {0xc2, 0x11}, {0xcc, 0xec}, {0xe5, 0xe7}, ++ {0x12, 0xcd}, {0x13, 0x14}, {0xc3, 0x15}, {0x16, 0x17}, {0xed, 0x18}, ++ {0x19, 0xf2}, {0x1a, 0xd3}, {0x1b, 0x1c}, {0xe4, 0x1d}, {0xc1, 0xe3}, ++ {0x1e, 0xe9}, {0xf0, 0xe2}, {0xf7, 0x1f}, {0xf3, 0xe6}, {0x20, 0x21}, ++ {0x22, 0xe8}, {0xef, 0x23}, {0x24, 0x25}, {0x26, 0x27}, {0x28, 0x29}, ++ {0x2a, 0xf4}, {0x2b, 0x2c}, {0x2d, 0x2e}, {0x2f, 0xe1}, {0x30, 0x31}, ++ {0x32, 0x33}, {0x34, 0x35}, {0x36, 0x37}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x03, 0x04}, {0x80, 0xae}, {0xc8, 0xd4}, {0x01, 0x02}, {0x9b, 0xa0}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x02, 0xf3}, {0xa0, 0xf4}, {0x9b, 0x01}, }, ++ { {0x9b, 0x9b}, }, ++ { {0xac, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x01, 0xa0}, {0x9b, 0xa2}, }, ++ { {0x07, 0x08}, {0xe2, 0xe4}, {0xe5, 0xe6}, {0xa0, 0xf2}, {0xe1, 0x01}, ++ {0x02, 0xf3}, {0xe3, 0x03}, {0x04, 0x05}, {0x9b, 0x06}, }, ++ { {0x04, 0x80}, {0xca, 0xd3}, {0xa2, 0x01}, {0x9b, 0x02}, {0x03, 0xa0}, }, ++ { {0x9b, 0xa0}, }, ++ { {0x03, 0x04}, {0x9b, 0xb7}, {0xf4, 0xa0}, {0xb0, 0xf3}, {0x01, 0x02}, }, ++ { {0xb9, 0x02}, {0xb8, 0x9b}, {0xa0, 0x01}, }, ++ { {0xae, 0x02}, {0xb6, 0x9b}, {0x01, 0xa0}, }, ++ { {0xa0, 0x01}, {0x9b, 0xb0}, }, ++ { {0xae, 0x01}, {0x9b, 0xa0}, }, ++ { {0xae, 0x01}, {0xa0, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x01}, {0xac, 0xae}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x02, 0x03}, {0x9b, 0xa0}, {0xb5, 0xb6}, {0xb8, 0x01}, }, ++ { {0x9b, 0xa0}, }, ++ { {0x9b, 0xa0}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0xa0}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x08, 0x09}, {0xe6, 0xf5}, {0xf3, 0xf4}, {0x9b, 0xe4}, {0x01, 0xed}, ++ {0x02, 0x03}, {0x04, 0xf2}, {0x05, 0x06}, {0xec, 0xee}, {0x07, 0xa0}, }, ++ { {0x05, 0x06}, {0x9b, 0xec}, {0xf5, 0x01}, {0x02, 0xe1}, {0xef, 0xe5}, ++ {0xe9, 0xf2}, {0x03, 0x04}, }, ++ { {0x06, 0x07}, {0x9b, 0xe9}, {0xf9, 0xf2}, {0xf5, 0x01}, {0x02, 0x03}, ++ {0xec, 0xef}, {0xe1, 0x04}, {0xe8, 0x05}, }, ++ { {0x05, 0x06}, {0xf9, 0xf2}, {0xf5, 0x9b}, {0xe5, 0xef}, {0x01, 0x02}, ++ {0xe9, 0xe1}, {0x03, 0x04}, }, ++ { {0x06, 0x07}, {0xe1, 0xe9}, {0xee, 0xf6}, {0xe4, 0xec}, {0xf3, 0x01}, ++ {0x02, 0xf2}, {0x03, 0x04}, {0x9b, 0x05}, }, ++ { {0x02, 0x03}, {0xe5, 0xec}, {0x9b, 0xef}, {0x01, 0xf2}, }, ++ { {0x05, 0x06}, {0xf5, 0xef}, {0x9b, 0xec}, {0xe9, 0x01}, {0xe1, 0xf2}, ++ {0x02, 0xe5}, {0x03, 0x04}, }, ++ { {0x03, 0x04}, {0x9b, 0xe5}, {0xe9, 0xf5}, {0xe1, 0x01}, {0xef, 0x02}, }, ++ { {0x04, 0x05}, {0xa0, 0xc9}, {0xf3, 0x9b}, {0xae, 0xf2}, {0x01, 0x02}, ++ {0x03, 0xee}, }, ++ { {0xef, 0x05}, {0x9b, 0xae}, {0xe9, 0xe5}, {0x01, 0xf5}, {0x02, 0xe1}, ++ {0x03, 0x04}, }, ++ { {0xe5, 0x03}, {0xe1, 0xe9}, {0xf2, 0x9b}, {0x01, 0x02}, }, ++ { {0x03, 0x04}, {0x9b, 0xe9}, {0xf5, 0x01}, {0xe5, 0x02}, {0xef, 0xe1}, }, ++ { {0xe1, 0x05}, {0x9b, 0xe3}, {0xef, 0x01}, {0xf5, 0xe5}, {0x02, 0x03}, ++ {0xe9, 0x04}, }, ++ { {0xe5, 0x03}, {0x9b, 0xe9}, {0x01, 0xe1}, {0xef, 0x02}, }, ++ { {0x03, 0x04}, {0xa7, 0xee}, {0xec, 0xf2}, {0xf3, 0x01}, {0x9b, 0x02}, }, ++ { {0xe1, 0x06}, {0x9b, 0xe8}, {0xe9, 0x01}, {0xf2, 0xec}, {0x02, 0xef}, ++ {0x03, 0xe5}, {0x04, 0x05}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x03, 0x04}, {0x9b, 0xae}, {0x01, 0xe9}, {0x02, 0xe1}, {0xe5, 0xef}, }, ++ { {0x09, 0x0a}, {0xf6, 0xf9}, {0x01, 0xae}, {0xe3, 0xe9}, {0xf5, 0x9b}, ++ {0xe5, 0xef}, {0x02, 0x03}, {0xe1, 0x04}, {0xe8, 0x05}, {0x06, 0xf4}, ++ {0x07, 0x08}, }, ++ { {0xe8, 0x07}, {0xe5, 0xf7}, {0xd6, 0xe1}, {0x9b, 0xe9}, {0xf2, 0x01}, ++ {0x02, 0x03}, {0x04, 0xef}, {0x05, 0x06}, }, ++ { {0xae, 0x01}, {0x9b, 0xee}, }, ++ { {0xe9, 0x02}, {0xe5, 0x9b}, {0xa0, 0x01}, }, ++ { {0x03, 0x04}, {0x9b, 0xe8}, {0xe5, 0xe1}, {0xef, 0x01}, {0xe9, 0x02}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0xef}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x18, 0x19}, {0xe8, 0xef}, {0xf8, 0x9b}, {0xa7, 0xf7}, {0xfa, 0x01}, ++ {0x02, 0x03}, {0x04, 0xe5}, {0xae, 0x05}, {0xe6, 0xe2}, {0x06, 0xf6}, ++ {0xeb, 0xf5}, {0xe9, 0x07}, {0xf0, 0xf9}, {0xe7, 0x08}, {0x09, 0xe4}, ++ {0x0a, 0xe3}, {0x0b, 0xed}, {0x0c, 0xf3}, {0x0d, 0x0e}, {0x0f, 0xec}, ++ {0x10, 0xf4}, {0x11, 0x12}, {0xf2, 0xa0}, {0x13, 0x14}, {0x15, 0xee}, ++ {0x16, 0x17}, }, ++ { {0x0b, 0x0c}, {0xe4, 0xf3}, {0x9b, 0xae}, {0xe2, 0x01}, {0x02, 0x03}, ++ {0xec, 0xa0}, {0x04, 0xe9}, {0xf2, 0xf5}, {0x05, 0xf9}, {0xe1, 0x06}, ++ {0xef, 0x07}, {0xe5, 0x08}, {0x09, 0x0a}, }, ++ { {0x0f, 0x10}, {0xf1, 0xae}, {0xc4, 0xf9}, {0xac, 0x01}, {0xe3, 0x02}, ++ {0x9b, 0xf2}, {0x03, 0x04}, {0xa0, 0xec}, {0xf5, 0x05}, {0x06, 0xe9}, ++ {0x07, 0xeb}, {0x08, 0xf4}, {0x09, 0xe5}, {0x0a, 0xef}, {0xe1, 0xe8}, ++ {0x0b, 0x0c}, {0x0d, 0x0e}, }, ++ { {0x13, 0x14}, {0xa7, 0xbb}, {0xe6, 0xed}, {0xf7, 0xe7}, {0xf6, 0x01}, ++ {0x02, 0x9b}, {0xee, 0x03}, {0x04, 0xec}, {0x05, 0xf5}, {0x06, 0xac}, ++ {0xe4, 0xf9}, {0xf2, 0x07}, {0x08, 0x09}, {0xae, 0x0a}, {0xef, 0x0b}, ++ {0xe1, 0xf3}, {0x0c, 0xe9}, {0x0d, 0x0e}, {0x0f, 0x10}, {0xe5, 0x11}, ++ {0x12, 0xa0}, }, ++ { {0x1d, 0x1e}, {0xa9, 0xe8}, {0xf5, 0x9b}, {0x01, 0xad}, {0xbb, 0xeb}, ++ {0xfa, 0x02}, {0xa7, 0xe6}, {0xe2, 0xe7}, {0x03, 0x04}, {0x05, 0x06}, ++ {0xe9, 0xf8}, {0x07, 0xac}, {0xef, 0xf0}, {0x08, 0xed}, {0xf6, 0xf9}, ++ {0x09, 0xf7}, {0x0a, 0x0b}, {0xae, 0x0c}, {0xe3, 0x0d}, {0xe5, 0xf4}, ++ {0x0e, 0x0f}, {0xe4, 0x10}, {0xec, 0x11}, {0xe1, 0x12}, {0x13, 0x14}, ++ {0x15, 0x16}, {0xee, 0xf3}, {0x17, 0x18}, {0xf2, 0xa0}, {0x19, 0x1a}, ++ {0x1b, 0x1c}, }, ++ { {0x09, 0x0a}, {0xae, 0x9b}, {0xec, 0x01}, {0xf5, 0x02}, {0xf4, 0xe6}, ++ {0x03, 0xe1}, {0xe5, 0xe9}, {0x04, 0xf2}, {0xef, 0x05}, {0x06, 0x07}, ++ {0xa0, 0x08}, }, ++ { {0x0e, 0x0f}, {0xad, 0xe7}, {0x9b, 0xa7}, {0xf9, 0x01}, {0xec, 0x02}, ++ {0xac, 0xf2}, {0x03, 0xae}, {0xf3, 0xf5}, {0x04, 0x05}, {0xef, 0x06}, ++ {0x07, 0xe9}, {0xe1, 0x08}, {0x09, 0xe8}, {0x0a, 0x0b}, {0xe5, 0x0c}, ++ {0xa0, 0x0d}, }, ++ { {0x0d, 0x0e}, {0xa7, 0xac}, {0xf3, 0xad}, {0x01, 0x02}, {0x9b, 0xf9}, ++ {0xf5, 0xae}, {0x03, 0xee}, {0x04, 0xf2}, {0x05, 0x06}, {0xf4, 0x07}, ++ {0x08, 0x09}, {0xef, 0xe1}, {0xa0, 0x0a}, {0xe9, 0x0b}, {0x0c, 0xe5}, }, ++ { {0x14, 0x15}, {0xac, 0xe2}, {0xf8, 0x9b}, {0xae, 0xfa}, {0x01, 0xeb}, ++ {0x02, 0xa0}, {0x03, 0x04}, {0xf0, 0x05}, {0x06, 0xe6}, {0xf6, 0x07}, ++ {0xe4, 0xed}, {0xe7, 0x08}, {0xe1, 0xef}, {0xf2, 0x09}, {0x0a, 0x0b}, ++ {0xec, 0x0c}, {0xe5, 0xe3}, {0x0d, 0xf4}, {0x0e, 0xf3}, {0x0f, 0x10}, ++ {0x11, 0xee}, {0x12, 0x13}, }, ++ { {0x03, 0xef}, {0x9b, 0xe1}, {0xe5, 0xf5}, {0x01, 0x02}, }, ++ { {0x08, 0x09}, {0xec, 0xf9}, {0xa7, 0xee}, {0x01, 0xac}, {0x9b, 0xae}, ++ {0x02, 0x03}, {0x04, 0xf3}, {0x05, 0xe9}, {0x06, 0xa0}, {0x07, 0xe5}, }, ++ { {0x16, 0x17}, {0xa7, 0xad}, {0xee, 0xe3}, {0xeb, 0xf2}, {0x9b, 0xe2}, ++ {0x01, 0x02}, {0xf5, 0x03}, {0xf4, 0xac}, {0x04, 0x05}, {0xe6, 0xed}, ++ {0xf6, 0x06}, {0xae, 0xf0}, {0x07, 0x08}, {0xf3, 0x09}, {0x0a, 0xe4}, ++ {0x0b, 0x0c}, {0xf9, 0x0d}, {0xef, 0x0e}, {0xe1, 0x0f}, {0x10, 0xe9}, ++ {0xec, 0x11}, {0xa0, 0xe5}, {0x12, 0x13}, {0x14, 0x15}, }, ++ { {0x0c, 0x0d}, {0xa7, 0xbb}, {0x9b, 0x01}, {0xf9, 0xae}, {0xe2, 0x02}, ++ {0xed, 0xf3}, {0x03, 0xf5}, {0xef, 0xf0}, {0x04, 0x05}, {0xe9, 0x06}, ++ {0x07, 0x08}, {0x09, 0xa0}, {0xe1, 0xe5}, {0x0a, 0x0b}, }, ++ { {0x19, 0x1a}, {0xad, 0xbb}, {0xe2, 0xea}, {0xed, 0xf2}, {0xfa, 0xe6}, ++ {0xec, 0x01}, {0x02, 0x03}, {0x9b, 0xf5}, {0x04, 0xa7}, {0xf6, 0xf9}, ++ {0x05, 0x06}, {0xeb, 0xef}, {0x07, 0x08}, {0x09, 0x0a}, {0xac, 0x0b}, ++ {0x0c, 0xe3}, {0xae, 0x0d}, {0xee, 0xe9}, {0x0e, 0xe1}, {0x0f, 0xf3}, ++ {0x10, 0x11}, {0xf4, 0x12}, {0xe7, 0xe5}, {0x13, 0x14}, {0xe4, 0x15}, ++ {0x16, 0x17}, {0xa0, 0x18}, }, ++ { {0x1a, 0x1b}, {0xc2, 0x9b}, {0xad, 0xac}, {0xf8, 0x01}, {0xae, 0x02}, ++ {0x03, 0xe5}, {0xe7, 0xe8}, {0xf9, 0xe9}, {0xeb, 0x04}, {0xe3, 0xe1}, ++ {0x05, 0xf6}, {0x06, 0xe4}, {0x07, 0xe2}, {0xf0, 0x08}, {0x09, 0xf3}, ++ {0xf4, 0xf7}, {0xef, 0x0a}, {0x0b, 0x0c}, {0x0d, 0xec}, {0x0e, 0x0f}, ++ {0x10, 0xf5}, {0xed, 0x11}, {0xe6, 0xa0}, {0x12, 0xf2}, {0x13, 0x14}, ++ {0x15, 0xee}, {0x16, 0x17}, {0x18, 0x19}, }, ++ { {0x0e, 0x0f}, {0xad, 0xed}, {0xf9, 0x9b}, {0xae, 0x01}, {0xf3, 0x02}, ++ {0x03, 0xf5}, {0xf4, 0xf0}, {0x04, 0xef}, {0x05, 0xe9}, {0x06, 0xe8}, ++ {0xa0, 0xe1}, {0xec, 0x07}, {0xf2, 0x08}, {0xe5, 0x09}, {0x0a, 0x0b}, ++ {0x0c, 0x0d}, }, ++ { {0x9b, 0xf5}, }, ++ { {0x19, 0x1a}, {0xa9, 0xbb}, {0xf6, 0xe6}, {0x01, 0x9b}, {0xad, 0xe2}, ++ {0xf0, 0x02}, {0xa7, 0x03}, {0x04, 0x05}, {0xf5, 0xe3}, {0xac, 0xe7}, ++ {0xf2, 0x06}, {0xeb, 0x07}, {0xec, 0xed}, {0xee, 0xf9}, {0x08, 0xae}, ++ {0x09, 0x0a}, {0xe4, 0x0b}, {0x0c, 0xf4}, {0x0d, 0xf3}, {0x0e, 0x0f}, ++ {0x10, 0xe1}, {0xef, 0x11}, {0xe9, 0x12}, {0x13, 0xe5}, {0x14, 0xa0}, ++ {0x15, 0x16}, {0x17, 0x18}, }, ++ { {0xa0, 0x16}, {0xa2, 0xa7}, {0xe2, 0xeb}, {0xed, 0xee}, {0x9b, 0xf7}, ++ {0x01, 0x02}, {0x03, 0xbb}, {0xf9, 0xf0}, {0x04, 0x05}, {0xec, 0x06}, ++ {0x07, 0x08}, {0xf5, 0xe1}, {0x09, 0xac}, {0xe3, 0x0a}, {0xe8, 0x0b}, ++ {0xe9, 0x0c}, {0xef, 0xf3}, {0xae, 0x0d}, {0x0e, 0xe5}, {0x0f, 0x10}, ++ {0x11, 0xf4}, {0x12, 0x13}, {0x14, 0x15}, }, ++ { {0x14, 0x15}, {0xbb, 0xe2}, {0xad, 0xed}, {0x01, 0x9b}, {0xa7, 0xe3}, ++ {0xac, 0xec}, {0xee, 0x02}, {0xf7, 0x03}, {0x04, 0xf9}, {0x05, 0x06}, ++ {0x07, 0x08}, {0xf4, 0xae}, {0xf5, 0x09}, {0x0a, 0xf2}, {0xe1, 0xf3}, ++ {0x0b, 0x0c}, {0x0d, 0xe9}, {0x0e, 0x0f}, {0xef, 0xe5}, {0x10, 0xa0}, ++ {0xe8, 0x11}, {0x12, 0x13}, }, ++ { {0x11, 0x12}, {0xef, 0xf6}, {0x9b, 0xeb}, {0xf9, 0x01}, {0xa0, 0xe2}, ++ {0x02, 0xe1}, {0x03, 0xed}, {0x04, 0xe3}, {0xe9, 0x05}, {0xe4, 0xe5}, ++ {0xe7, 0x06}, {0xec, 0xf0}, {0x07, 0x08}, {0x09, 0x0a}, {0x0b, 0xf3}, ++ {0x0c, 0xf4}, {0xee, 0x0d}, {0xf2, 0x0e}, {0x0f, 0x10}, }, ++ { {0x05, 0xe5}, {0xf3, 0xf9}, {0x9b, 0x01}, {0xef, 0x02}, {0x03, 0xe1}, ++ {0x04, 0xe9}, }, ++ { {0x0a, 0x0b}, {0xae, 0x9b}, {0xec, 0xed}, {0x01, 0x02}, {0xf3, 0xee}, ++ {0xf2, 0x03}, {0xe5, 0x04}, {0xe8, 0xa0}, {0xe1, 0x05}, {0xef, 0x06}, ++ {0x07, 0x08}, {0xe9, 0x09}, }, ++ { {0x05, 0x06}, {0xa0, 0xac}, {0xad, 0xf4}, {0xe9, 0x01}, {0x02, 0xe1}, ++ {0xe5, 0x03}, {0x9b, 0x04}, }, ++ { {0x11, 0xa0}, {0xbf, 0xe1}, {0xe2, 0xe6}, {0xed, 0xe4}, {0xe9, 0xf7}, ++ {0xa7, 0x01}, {0x02, 0xbb}, {0x03, 0x04}, {0xec, 0x05}, {0x9b, 0xee}, ++ {0x06, 0xef}, {0x07, 0xac}, {0xe5, 0xf3}, {0x08, 0x09}, {0x0a, 0xae}, ++ {0x0b, 0x0c}, {0x0d, 0x0e}, {0x0f, 0x10}, }, ++ { {0x06, 0x07}, {0xa0, 0xae}, {0xe1, 0xe5}, {0xec, 0xfa}, {0x9b, 0xef}, ++ {0xe9, 0x01}, {0x02, 0x03}, {0x04, 0x05}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++}; ++ ++static struct hufftree_entry program_title_hufftree[][128] = { ++ { {0x1b, 0x1c}, {0xb4, 0xa4}, {0xb2, 0xb7}, {0xda, 0x01}, {0xd1, 0x02}, ++ {0x03, 0x9b}, {0x04, 0xd5}, {0xd9, 0x05}, {0xcb, 0xd6}, {0x06, 0xcf}, ++ {0x07, 0x08}, {0xca, 0x09}, {0xc9, 0xc5}, {0xc6, 0x0a}, {0xd2, 0xc4}, ++ {0xc7, 0xcc}, {0xd0, 0xc8}, {0xd7, 0xce}, {0x0b, 0xc1}, {0x0c, 0xc2}, ++ {0xcd, 0xc3}, {0x0d, 0x0e}, {0x0f, 0x10}, {0xd3, 0x11}, {0xd4, 0x12}, ++ {0x13, 0x14}, {0x15, 0x16}, {0x17, 0x18}, {0x19, 0x1a}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x29, 0x2a}, {0xd8, 0xe5}, {0xb9, 0x01}, {0xa7, 0xb1}, {0xec, 0xd1}, ++ {0x02, 0xad}, {0xb2, 0xda}, {0xe3, 0xb3}, {0x03, 0xe4}, {0xe6, 0x04}, ++ {0x9b, 0xe2}, {0x05, 0x06}, {0x07, 0x08}, {0x09, 0xd5}, {0x0a, 0xd6}, ++ {0x0b, 0xd9}, {0x0c, 0xa6}, {0xe9, 0xcb}, {0xc5, 0xcf}, {0x0d, 0x0e}, ++ {0xca, 0xc9}, {0x0f, 0xc7}, {0x10, 0x11}, {0xe1, 0x12}, {0x13, 0xc6}, ++ {0xd2, 0xc8}, {0xce, 0xc1}, {0xc4, 0xd0}, {0xcc, 0x14}, {0x15, 0xef}, ++ {0xc2, 0xd7}, {0x16, 0xcd}, {0x17, 0xf4}, {0xd4, 0x18}, {0x19, 0x1a}, ++ {0xc3, 0xd3}, {0x1b, 0x1c}, {0x1d, 0x1e}, {0x1f, 0x20}, {0x21, 0x22}, ++ {0x23, 0x24}, {0x25, 0x26}, {0x27, 0x28}, }, ++ { {0x01, 0x80}, {0xa0, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0xb1, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0xa0}, }, ++ { {0x04, 0xf3}, {0xe4, 0xb9}, {0x01, 0xf4}, {0xa0, 0x9b}, {0x02, 0x03}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x01, 0x02}, {0x9b, 0xc1}, {0xc8, 0xd3}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0xa0}, }, ++ { {0x07, 0x08}, {0xb1, 0xd2}, {0xd3, 0xd4}, {0xd5, 0xad}, {0xcd, 0xc1}, ++ {0x01, 0x02}, {0x03, 0xa0}, {0x04, 0x9b}, {0x05, 0x06}, }, ++ { {0xa0, 0x05}, {0xc9, 0xd7}, {0xd3, 0x01}, {0x02, 0x9b}, {0xae, 0x80}, ++ {0x03, 0x04}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x02, 0x03}, {0xad, 0x9b}, {0x01, 0x80}, {0xa0, 0xb0}, }, ++ { {0x04, 0x05}, {0x80, 0x9b}, {0xb1, 0xb2}, {0xa0, 0xb0}, {0xb9, 0x01}, ++ {0x02, 0x03}, }, ++ { {0x02, 0x03}, {0xb1, 0xba}, {0x01, 0xb0}, {0x9b, 0x80}, }, ++ { {0x80, 0x01}, {0xb0, 0x9b}, }, ++ { {0x9b, 0xb8}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0xb0}, }, ++ { {0x9b, 0xa0}, }, ++ { {0x02, 0x03}, {0xb1, 0xb3}, {0xb9, 0xb0}, {0x01, 0x9b}, }, ++ { {0x9b, 0xa0}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x80}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x13, 0x14}, {0xaa, 0xad}, {0xae, 0xf6}, {0xe7, 0xf4}, {0xe2, 0xe9}, ++ {0x01, 0x02}, {0xc2, 0xf0}, {0x9b, 0xf3}, {0xe3, 0xe6}, {0xf7, 0x03}, ++ {0xf5, 0x04}, {0x05, 0x06}, {0xf2, 0x07}, {0x08, 0x09}, {0x0a, 0x0b}, ++ {0x0c, 0xe4}, {0xa0, 0x0d}, {0xec, 0xee}, {0x0e, 0xed}, {0x0f, 0x10}, ++ {0x11, 0x12}, }, ++ { {0x08, 0x09}, {0xc1, 0xd3}, {0x9b, 0x01}, {0xc3, 0x02}, {0xe9, 0xec}, ++ {0x03, 0xf2}, {0xf5, 0x04}, {0xef, 0xe1}, {0x05, 0xe5}, {0x06, 0x07}, }, ++ { {0x0b, 0x0c}, {0xc1, 0xf9}, {0x01, 0xc2}, {0xcf, 0xe5}, {0xf5, 0x9b}, ++ {0xe9, 0x02}, {0xa0, 0x03}, {0x04, 0x05}, {0xf2, 0x06}, {0xec, 0x07}, ++ {0xe1, 0x08}, {0x09, 0xe8}, {0x0a, 0xef}, }, ++ { {0x05, 0x06}, {0xf9, 0x9b}, {0x01, 0xf5}, {0x02, 0xf2}, {0xe9, 0xe5}, ++ {0xef, 0x03}, {0xe1, 0x04}, }, ++ { {0x0a, 0x0b}, {0xf1, 0xf5}, {0xf3, 0x01}, {0xed, 0xf9}, {0xc3, 0x02}, ++ {0xec, 0xee}, {0xe4, 0xf8}, {0x03, 0x9b}, {0xf6, 0x04}, {0x05, 0xe1}, ++ {0x06, 0x07}, {0x08, 0x09}, }, ++ { {0x07, 0x08}, {0xa0, 0x9b}, {0xcc, 0x01}, {0xe5, 0x02}, {0xec, 0xf5}, ++ {0xef, 0x03}, {0xe9, 0xf2}, {0x04, 0x05}, {0xe1, 0x06}, }, ++ { {0x09, 0x0a}, {0xae, 0xec}, {0xf9, 0xc1}, {0xe8, 0x01}, {0x9b, 0x02}, ++ {0x03, 0x04}, {0xe1, 0xf5}, {0xe9, 0x05}, {0xe5, 0x06}, {0xf2, 0xef}, ++ {0x07, 0x08}, }, ++ { {0xef, 0x05}, {0x80, 0x9b}, {0xf5, 0x01}, {0x02, 0xe9}, {0xe1, 0x03}, ++ {0xe5, 0x04}, }, ++ { {0xee, 0x0b}, {0xba, 0xd4}, {0xae, 0xf2}, {0xe3, 0x01}, {0xa0, 0x02}, ++ {0x80, 0x9b}, {0xed, 0x03}, {0xc9, 0xf3}, {0xf4, 0x04}, {0x05, 0x06}, ++ {0x07, 0x08}, {0x09, 0x0a}, }, ++ { {0x02, 0x03}, {0x9b, 0xf5}, {0x01, 0xe1}, {0xef, 0xe5}, }, ++ { {0x05, 0xe9}, {0xe1, 0xef}, {0xf5, 0xee}, {0x9b, 0xe5}, {0x01, 0x02}, ++ {0x03, 0x04}, }, ++ { {0x04, 0x05}, {0xa0, 0x9b}, {0x01, 0xf5}, {0x02, 0xe5}, {0xef, 0x03}, ++ {0xe1, 0xe9}, }, ++ { {0x08, 0x09}, {0xaa, 0xd4}, {0x01, 0x9b}, {0xe3, 0x02}, {0xf2, 0x03}, ++ {0xe5, 0x04}, {0xf5, 0xf9}, {0xe9, 0x05}, {0xef, 0x06}, {0x07, 0xe1}, }, ++ { {0xe5, 0x08}, {0xce, 0xa0}, {0xc6, 0xf5}, {0x01, 0x02}, {0x9b, 0xc2}, ++ {0x03, 0xe1}, {0x04, 0xef}, {0x05, 0xe9}, {0x06, 0x07}, }, ++ { {0x09, 0x0a}, {0xe4, 0xf3}, {0xe6, 0xf6}, {0xf7, 0xf0}, {0xf2, 0x01}, ++ {0xec, 0x02}, {0x03, 0xa0}, {0x9b, 0x04}, {0x05, 0xf5}, {0x06, 0x07}, ++ {0xee, 0x08}, }, ++ { {0x0b, 0x0c}, {0xa0, 0xf3}, {0xf9, 0xae}, {0xd2, 0xc7}, {0x01, 0x9b}, ++ {0x02, 0xf5}, {0x03, 0x04}, {0x05, 0xe9}, {0xec, 0x06}, {0xe5, 0x07}, ++ {0xef, 0x08}, {0xe1, 0x09}, {0xf2, 0x0a}, }, ++ { {0x01, 0xf5}, {0x9b, 0xd6}, }, ++ { {0x04, 0x05}, {0xe8, 0x9b}, {0x01, 0xf5}, {0x02, 0xe1}, {0xe9, 0xef}, ++ {0x03, 0xe5}, }, ++ { {0x10, 0x11}, {0xaa, 0xec}, {0xf1, 0xae}, {0xa0, 0xf7}, {0xed, 0xee}, ++ {0x01, 0x02}, {0x9b, 0xeb}, {0x03, 0x04}, {0x05, 0x06}, {0xe3, 0x07}, ++ {0xef, 0x08}, {0xe9, 0xf5}, {0x09, 0xe1}, {0xe5, 0xf0}, {0xe8, 0x0a}, ++ {0x0b, 0x0c}, {0x0d, 0xf4}, {0x0e, 0x0f}, }, ++ { {0xe8, 0x0a}, {0xad, 0xce}, {0x9b, 0x01}, {0xd6, 0x02}, {0xf5, 0xf7}, ++ {0x03, 0x04}, {0xe1, 0xe5}, {0xe9, 0x05}, {0xf2, 0x06}, {0xef, 0x07}, ++ {0x08, 0x09}, }, ++ { {0xee, 0x03}, {0xec, 0xae}, {0x01, 0x9b}, {0x02, 0xf0}, }, ++ { {0x06, 0xe9}, {0xa0, 0xc3}, {0xef, 0x9b}, {0xe5, 0x01}, {0x80, 0x02}, ++ {0x03, 0xe1}, {0x04, 0x05}, }, ++ { {0x06, 0x07}, {0xc6, 0xd7}, {0x01, 0x9b}, {0xf2, 0x02}, {0x03, 0xe8}, ++ {0xe5, 0xe1}, {0x04, 0xe9}, {0xef, 0x05}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x02, 0xef}, {0xe1, 0x9b}, {0x01, 0xe5}, }, ++ { {0x01, 0xef}, {0x9b, 0xe1}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x19, 0x1a}, {0x9b, 0xba}, {0xe5, 0xea}, {0xf8, 0x01}, {0x02, 0xe6}, ++ {0xa7, 0x03}, {0xfa, 0xe8}, {0x04, 0xf7}, {0x05, 0xf5}, {0xe2, 0x06}, ++ {0xeb, 0x07}, {0xf0, 0x08}, {0x80, 0xf6}, {0xe7, 0x09}, {0xe4, 0x0a}, ++ {0xa0, 0xe9}, {0x0b, 0xe3}, {0xf9, 0x0c}, {0x0d, 0xed}, {0x0e, 0x0f}, ++ {0xf3, 0x10}, {0x11, 0xec}, {0x12, 0xf4}, {0xf2, 0x13}, {0xee, 0x14}, ++ {0x15, 0x16}, {0x17, 0x18}, }, ++ { {0x0a, 0x0b}, {0xf3, 0x9b}, {0xf5, 0xe2}, {0x01, 0x80}, {0xa0, 0x02}, ++ {0xe5, 0xf2}, {0xe9, 0x03}, {0xec, 0x04}, {0xf9, 0x05}, {0xef, 0x06}, ++ {0xe1, 0x07}, {0x08, 0x09}, }, ++ { {0x10, 0x11}, {0xc3, 0xcc}, {0xc7, 0x9b}, {0xe3, 0x01}, {0x80, 0xec}, ++ {0xf9, 0x02}, {0xf3, 0x03}, {0xf5, 0x04}, {0x05, 0xf2}, {0x06, 0xe9}, ++ {0xa0, 0x07}, {0x08, 0xef}, {0xf4, 0x09}, {0x0a, 0xe1}, {0x0b, 0xe8}, ++ {0xeb, 0xe5}, {0x0c, 0x0d}, {0x0e, 0x0f}, }, ++ { {0x0e, 0x0f}, {0xae, 0xf5}, {0xf7, 0x01}, {0xec, 0x02}, {0xe4, 0xe7}, ++ {0xf2, 0x03}, {0x9b, 0xef}, {0x04, 0xf6}, {0x05, 0x06}, {0xf9, 0xf3}, ++ {0x07, 0xe9}, {0xe1, 0x08}, {0x09, 0x80}, {0x0a, 0x0b}, {0xe5, 0x0c}, ++ {0x0d, 0xa0}, }, ++ { {0x1e, 0x1f}, {0x9b, 0xa1}, {0xad, 0xe8}, {0xea, 0xf1}, {0xf5, 0xfa}, ++ {0x01, 0x02}, {0x03, 0x04}, {0xba, 0xf8}, {0xa7, 0xe2}, {0xe9, 0x05}, ++ {0x06, 0x07}, {0xe6, 0xed}, {0xe7, 0xeb}, {0x08, 0x09}, {0xf6, 0xf0}, ++ {0x0a, 0xef}, {0x0b, 0xe3}, {0x0c, 0x0d}, {0x0e, 0xf9}, {0x0f, 0xe4}, ++ {0xec, 0x10}, {0xe5, 0x11}, {0xf4, 0xf7}, {0x12, 0x13}, {0xe1, 0x14}, ++ {0x15, 0x16}, {0xee, 0xf3}, {0x17, 0x80}, {0x18, 0x19}, {0xf2, 0x1a}, ++ {0x1b, 0xa0}, {0x1c, 0x1d}, }, ++ { {0xa0, 0x0b}, {0xf5, 0x9b}, {0x01, 0xec}, {0xf3, 0xf2}, {0x80, 0xe1}, ++ {0x02, 0x03}, {0xf4, 0xe9}, {0xef, 0xe6}, {0x04, 0x05}, {0x06, 0x07}, ++ {0xe5, 0x08}, {0x09, 0x0a}, }, ++ { {0x0f, 0x10}, {0xba, 0xf9}, {0xa7, 0xf4}, {0x9b, 0x01}, {0xe7, 0xec}, ++ {0x02, 0xee}, {0x03, 0xef}, {0xf5, 0x04}, {0xf2, 0x05}, {0x06, 0xe9}, ++ {0x07, 0xf3}, {0xe1, 0x08}, {0x09, 0x0a}, {0x0b, 0xe5}, {0x80, 0x0c}, ++ {0xe8, 0xa0}, {0x0d, 0x0e}, }, ++ { {0xe5, 0x0d}, {0xe2, 0xf5}, {0xf7, 0x9b}, {0xec, 0x01}, {0xf9, 0xee}, ++ {0x02, 0x03}, {0x04, 0xf2}, {0x05, 0x80}, {0x06, 0xa0}, {0xe1, 0xef}, ++ {0x07, 0xf4}, {0xe9, 0x08}, {0x09, 0x0a}, {0x0b, 0x0c}, }, ++ { {0x15, 0x16}, {0xa1, 0xf8}, {0xe9, 0xeb}, {0x01, 0x80}, {0x9b, 0xfa}, ++ {0xe2, 0x02}, {0x03, 0x04}, {0xa0, 0xf0}, {0x05, 0x06}, {0x07, 0xe1}, ++ {0x08, 0xe6}, {0xf2, 0xed}, {0xf6, 0x09}, {0xe4, 0x0a}, {0xef, 0xf4}, ++ {0xec, 0xf3}, {0xe7, 0xe5}, {0x0b, 0xe3}, {0x0c, 0x0d}, {0x0e, 0x0f}, ++ {0x10, 0x11}, {0x12, 0x13}, {0xee, 0x14}, }, ++ { {0xef, 0x01}, {0x9b, 0xe1}, }, ++ { {0x0b, 0x0c}, {0xd4, 0xef}, {0xe6, 0xec}, {0xf7, 0xe1}, {0x01, 0xba}, ++ {0x02, 0x9b}, {0xf9, 0x03}, {0x04, 0x05}, {0xf3, 0x06}, {0x07, 0x08}, ++ {0xe9, 0xa0}, {0x09, 0x80}, {0xe5, 0x0a}, }, ++ { {0x15, 0x16}, {0xa7, 0xba}, {0xe3, 0xf7}, {0xf2, 0xad}, {0xe2, 0x01}, ++ {0x02, 0x9b}, {0xe6, 0x03}, {0xed, 0xf6}, {0x04, 0xeb}, {0x05, 0xf4}, ++ {0x06, 0x07}, {0x08, 0xf3}, {0x09, 0xf5}, {0x0a, 0xef}, {0x0b, 0x0c}, ++ {0x80, 0xf9}, {0xe1, 0x0d}, {0xe4, 0xe9}, {0xa0, 0x0e}, {0x0f, 0xec}, ++ {0xe5, 0x10}, {0x11, 0x12}, {0x13, 0x14}, }, ++ { {0x0a, 0x0b}, {0xf9, 0x9b}, {0xf5, 0xf3}, {0x01, 0x02}, {0xe2, 0xed}, ++ {0x80, 0x03}, {0xf0, 0xef}, {0x04, 0xa0}, {0x05, 0xe9}, {0x06, 0xe1}, ++ {0x07, 0x08}, {0x09, 0xe5}, }, ++ { {0x18, 0x19}, {0xe2, 0xea}, {0xf2, 0xe8}, {0xec, 0xed}, {0xfa, 0x9b}, ++ {0x01, 0xf5}, {0x02, 0x03}, {0xf6, 0x04}, {0xba, 0xe6}, {0x05, 0x06}, ++ {0xeb, 0xef}, {0x07, 0xa7}, {0xf9, 0x08}, {0x09, 0x0a}, {0x0b, 0xe3}, ++ {0x0c, 0xee}, {0xe1, 0x0d}, {0xf3, 0x0e}, {0xe9, 0x0f}, {0x10, 0xf4}, ++ {0x80, 0xe4}, {0xe5, 0x11}, {0x12, 0xe7}, {0xa0, 0x13}, {0x14, 0x15}, ++ {0x16, 0x17}, }, ++ { {0x1b, 0x1c}, {0xae, 0xfa}, {0xbf, 0x01}, {0xa7, 0x9b}, {0x02, 0xe9}, ++ {0xf8, 0xf9}, {0x03, 0xe5}, {0xe8, 0x04}, {0xe1, 0xeb}, {0x05, 0xe2}, ++ {0x06, 0x07}, {0xe3, 0x08}, {0xe7, 0xf4}, {0x09, 0x80}, {0xf6, 0xf0}, ++ {0x0a, 0xe4}, {0x0b, 0xf3}, {0xf7, 0x0c}, {0x0d, 0xef}, {0xec, 0xa0}, ++ {0x0e, 0x0f}, {0xed, 0xe6}, {0x10, 0xf5}, {0x11, 0x12}, {0x13, 0x14}, ++ {0x15, 0xf2}, {0x16, 0xee}, {0x17, 0x18}, {0x19, 0x1a}, }, ++ { {0x0e, 0x0f}, {0xed, 0xa7}, {0x9b, 0xe4}, {0x01, 0xf9}, {0xf3, 0xf2}, ++ {0xf4, 0x02}, {0xe8, 0x03}, {0xec, 0xf0}, {0x04, 0xe1}, {0xe9, 0x05}, ++ {0x06, 0x80}, {0xa0, 0x07}, {0x08, 0x09}, {0x0a, 0xe5}, {0xef, 0x0b}, ++ {0x0c, 0x0d}, }, ++ { {0x9b, 0xf5}, }, ++ { {0x18, 0x19}, {0xba, 0xac}, {0xf6, 0x9b}, {0xf0, 0xe2}, {0x01, 0xe6}, ++ {0x02, 0xa7}, {0xae, 0xe7}, {0x03, 0xe3}, {0xf5, 0x04}, {0xed, 0x05}, ++ {0x06, 0x07}, {0xeb, 0x08}, {0x09, 0xee}, {0xf2, 0x0a}, {0xe4, 0x0b}, ++ {0xf9, 0xec}, {0x0c, 0x0d}, {0xf4, 0x80}, {0x0e, 0xef}, {0xf3, 0xa0}, ++ {0xe1, 0x0f}, {0xe9, 0x10}, {0x11, 0xe5}, {0x12, 0x13}, {0x14, 0x15}, ++ {0x16, 0x17}, }, ++ { {0x19, 0x1a}, {0xa7, 0xac}, {0xbf, 0xc3}, {0xc8, 0xe4}, {0xe6, 0xed}, ++ {0xf2, 0xae}, {0xec, 0xee}, {0xf9, 0x01}, {0x02, 0x03}, {0x04, 0xba}, ++ {0x05, 0x9b}, {0xf5, 0x06}, {0x07, 0x08}, {0x09, 0xeb}, {0xf0, 0x0a}, ++ {0x0b, 0x0c}, {0xe1, 0xe3}, {0x0d, 0xe8}, {0x0e, 0x0f}, {0xef, 0x10}, ++ {0x11, 0xf3}, {0x12, 0xe9}, {0x13, 0xe5}, {0x14, 0x15}, {0xf4, 0x16}, ++ {0x17, 0xa0}, {0x18, 0x80}, }, ++ { {0x14, 0x15}, {0xba, 0xbf}, {0xe4, 0xf7}, {0x9b, 0xa7}, {0x01, 0xee}, ++ {0x02, 0x03}, {0x04, 0xe3}, {0xe2, 0xed}, {0x05, 0xf9}, {0x06, 0xf4}, ++ {0x07, 0xec}, {0x08, 0xf5}, {0xf2, 0x09}, {0xe1, 0xf3}, {0x0a, 0xef}, ++ {0x0b, 0x0c}, {0x0d, 0xe9}, {0x80, 0xe5}, {0x0e, 0xa0}, {0x0f, 0xe8}, ++ {0x10, 0x11}, {0x12, 0x13}, }, ++ { {0x11, 0x12}, {0xeb, 0xfa}, {0x80, 0xe6}, {0x9b, 0x01}, {0xa0, 0x02}, ++ {0x03, 0xe9}, {0xe1, 0x04}, {0xe4, 0xf0}, {0xed, 0xe2}, {0xe3, 0xe7}, ++ {0xec, 0x05}, {0xe5, 0x06}, {0x07, 0x08}, {0x09, 0xf4}, {0x0a, 0x0b}, ++ {0x0c, 0xf3}, {0xee, 0x0d}, {0x0e, 0xf2}, {0x0f, 0x10}, }, ++ { {0x04, 0xe5}, {0xf3, 0xef}, {0x9b, 0x01}, {0xe1, 0x02}, {0x03, 0xe9}, }, ++ { {0x0b, 0x0c}, {0xa7, 0xe2}, {0xec, 0xe3}, {0xf2, 0x01}, {0x9b, 0x02}, ++ {0x03, 0x04}, {0xe9, 0xef}, {0xee, 0xe5}, {0xe1, 0x80}, {0x05, 0xa0}, ++ {0x06, 0x07}, {0x08, 0x09}, {0xf3, 0x0a}, }, ++ { {0x05, 0x06}, {0x9b, 0xa0}, {0xe1, 0xe5}, {0xe9, 0x01}, {0x80, 0xf0}, ++ {0x02, 0xf4}, {0x03, 0x04}, }, ++ { {0xa0, 0x13}, {0xe3, 0xad}, {0xe4, 0xe9}, {0xee, 0xef}, {0xf0, 0xf4}, ++ {0xf6, 0xa1}, {0xe1, 0xed}, {0x01, 0xe2}, {0x02, 0x03}, {0x04, 0xa7}, ++ {0x05, 0x06}, {0xf7, 0x07}, {0x9b, 0xec}, {0x08, 0xe5}, {0x09, 0x0a}, ++ {0x0b, 0x0c}, {0x0d, 0x0e}, {0xf3, 0x0f}, {0x10, 0x11}, {0x80, 0x12}, }, ++ { {0x05, 0x06}, {0xe5, 0xfa}, {0xa0, 0xf9}, {0x9b, 0x01}, {0x80, 0xe9}, ++ {0x02, 0xe1}, {0x03, 0x04}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++ { {0x9b, 0x9b}, }, ++}; ++ ++ ++ ++static inline void huffbuff_init(struct huffbuff *hbuf, uint8_t *buf, uint32_t buf_len) ++{ ++ memset(hbuf, 0, sizeof(struct huffbuff)); ++ hbuf->buf = buf; ++ hbuf->buf_len = buf_len; ++} ++ ++static inline int huffbuff_bits(struct huffbuff *hbuf, uint8_t nbits) ++{ ++ uint8_t result = 0; ++ ++ if (nbits > 8) ++ return -1; ++ ++ while(nbits--) { ++ if (hbuf->cur_byte >= hbuf->buf_len) { ++ return -1; ++ } ++ ++ result <<= 1; ++ if (hbuf->buf[hbuf->cur_byte] & (0x80 >> hbuf->cur_bit)) ++ result |= 1; ++ ++ if (++hbuf->cur_bit > 7) { ++ hbuf->cur_byte++; ++ hbuf->cur_bit = 0; ++ } ++ } ++ ++ return result; ++} ++ ++static inline int append_unicode_char(uint8_t **destbuf, size_t *destbuflen, size_t *destbufpos, ++ uint32_t c) ++{ ++ uint8_t tmp[3]; ++ int tmplen = 0; ++ ++ // encode the unicode character first of all ++ if (c < 0x80) { ++ tmp[0] = c; ++ tmplen = 1; ++ } else if (c < 0x800) { ++ tmp[0] = 0xc0 | ((c >> 6) & 0x1f); ++ tmp[1] = 0x80 | (c & 0x3f); ++ tmplen = 2; ++ } else if (c < 0x10000) { ++ tmp[0] = 0xe0 | ((c >> 12) & 0x0f); ++ tmp[1] = 0x80 | ((c >> 6) & 0x3f); ++ tmp[2] = 0x80 | (c & 0x3f); ++ tmplen = 3; ++ } else { ++ return -1; ++ } ++ ++ // do we have enough buffer space? ++ if ((*destbufpos + tmplen) >= *destbuflen) { ++ uint8_t *new_dest = realloc(*destbuf, *destbuflen + DEST_ALLOC_DELTA); ++ if (new_dest == NULL) ++ return -ENOMEM; ++ *destbuf = new_dest; ++ *destbuflen += DEST_ALLOC_DELTA; ++ } ++ ++ // copy it into position ++ memcpy(*destbuf + *destbufpos, tmp, tmplen); ++ *destbufpos += tmplen; ++ ++ return 0; ++} ++ ++static inline int unicode_decode(uint8_t *srcbuf, size_t srcbuflen, int mode, ++ uint8_t **destbuf, size_t *destbuflen, size_t *destbufpos) ++{ ++ size_t i; ++ uint32_t msb = mode << 8; ++ ++ for(i=0; i< srcbuflen; i++) { ++ if (append_unicode_char(destbuf, destbuflen, destbufpos, msb + srcbuf[i])) ++ return -1; ++ } ++ ++ return *destbufpos; ++} ++ ++static int huffman_decode_uncompressed(struct huffbuff *hbuf, ++ uint8_t **destbuf, size_t *destbuflen, size_t *destbufpos) ++{ ++ int c; ++ ++ while(hbuf->cur_byte < hbuf->buf_len) { ++ // get next byte ++ if ((c = huffbuff_bits(hbuf, 8)) < 0) ++ return -1; ++ ++ switch(c) { ++ case HUFFSTRING_END: ++ return 0; ++ ++ case HUFFSTRING_ESCAPE: ++ return HUFFSTRING_ESCAPE; ++ ++ default: ++ if (append_unicode_char(destbuf, destbuflen, destbufpos, c)) ++ return -1; ++ ++ // if it is 7 bit, we swap back to the compressed context ++ if ((c & 0x80) == 0) ++ return c; ++ ++ // characters following an 8 bit uncompressed char are uncompressed as well ++ break; ++ } ++ } ++ ++ // ran out of string; pretend we saw an end of string char ++ return HUFFSTRING_END; ++} ++ ++static int huffman_decode(uint8_t *src, size_t srclen, ++ uint8_t **destbuf, size_t *destbuflen, size_t *destbufpos, ++ struct hufftree_entry hufftree[][128]) ++{ ++ struct huffbuff hbuf; ++ int bit; ++ struct hufftree_entry *tree = hufftree[0]; ++ uint8_t treeidx = 0; ++ uint8_t treeval; ++ int tmp; ++ ++ huffbuff_init(&hbuf, src, srclen); ++ ++ while(hbuf.cur_byte < hbuf.buf_len) { ++ // get the next bit ++ if ((bit = huffbuff_bits(&hbuf, 1)) < 0) ++ return *destbufpos; ++ ++ if (!bit) { ++ treeval = tree[treeidx].left_idx; ++ } else { ++ treeval = tree[treeidx].right_idx; ++ } ++ ++ if (treeval & HUFFTREE_LITERAL_MASK) { ++ switch(treeval & ~HUFFTREE_LITERAL_MASK) { ++ case HUFFSTRING_END: ++ return 0; ++ ++ case HUFFSTRING_ESCAPE: ++ if ((tmp = ++ huffman_decode_uncompressed(&hbuf, ++ destbuf, destbuflen, destbufpos)) < 0) ++ return tmp; ++ if (tmp == 0) ++ return *destbufpos; ++ ++ tree = hufftree[tmp]; ++ treeidx = 0; ++ break; ++ ++ default: ++ // stash it ++ if (append_unicode_char(destbuf, destbuflen, destbufpos, ++ treeval & ~HUFFTREE_LITERAL_MASK)) ++ return -1; ++ tree = hufftree[treeval & ~HUFFTREE_LITERAL_MASK]; ++ treeidx = 0; ++ break; ++ } ++ } else { ++ treeidx = treeval; ++ } ++ } ++ ++ return *destbufpos; ++} ++ ++int atsc_text_segment_decode(struct atsc_text_string_segment *segment, ++ uint8_t **destbuf, size_t *destbufsize, size_t *destbufpos) ++{ ++ if (segment->mode > ATSC_TEXT_SEGMENT_MODE_UNICODE_RANGE_MAX) ++ return -1; ++ ++ // mode==0 MUST be used for compressed text ++ if ((segment->mode) && (segment->compression_type)) ++ return -1; ++ ++ uint8_t *buf = atsc_text_string_segment_bytes(segment); ++ ++ switch(segment->compression_type) { ++ case ATSC_TEXT_COMPRESS_NONE: ++ return unicode_decode(buf, segment->number_bytes, segment->mode, ++ destbuf, destbufsize, destbufpos); ++ ++ case ATSC_TEXT_COMPRESS_PROGRAM_TITLE: ++ return huffman_decode(buf, segment->number_bytes, ++ destbuf, destbufsize, destbufpos, ++ program_title_hufftree); ++ ++ case ATSC_TEXT_COMPRESS_PROGRAM_DESCRIPTION: ++ return huffman_decode(buf, segment->number_bytes, ++ destbuf, destbufsize, destbufpos, ++ program_description_hufftree); ++ } ++ ++ return -1; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/caption_service_descriptor.h dvb-apps/lib/libucsi/atsc/caption_service_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/caption_service_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/caption_service_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,137 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_CAPTION_SERVICE_DESCRIPTOR ++#define _UCSI_ATSC_CAPTION_SERVICE_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * atsc_caption_service_descriptor structure. ++ */ ++struct atsc_caption_service_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint8_t reserved : 3; , ++ uint8_t number_of_services : 5; ); ++ /* struct atsc_caption_service_entry entries[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the entries field of a atsc_caption_service_descriptor. ++ */ ++struct atsc_caption_service_entry { ++ iso639lang_t language_code; ++ EBIT3(uint8_t digital_cc : 1; , ++ uint8_t reserved : 1; , ++ uint8_t value : 6; ); ++ EBIT3(uint16_t easy_reader : 1; , ++ uint16_t wide_aspect_ratio : 1; , ++ uint16_t reserved1 :14; ); ++} __ucsi_packed; ++ ++/** ++ * Process an atsc_caption_service_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return atsc_caption_service_descriptor pointer, or NULL on error. ++ */ ++static inline struct atsc_caption_service_descriptor* ++ atsc_caption_service_descriptor_codec(struct descriptor* d) ++{ ++ struct atsc_caption_service_descriptor *ret = ++ (struct atsc_caption_service_descriptor *) d; ++ uint8_t *buf = (uint8_t*) d + 2; ++ int pos = 0; ++ int idx; ++ ++ if (d->len < 1) ++ return NULL; ++ pos++; ++ ++ for(idx = 0; idx < ret->number_of_services; idx++) { ++ if (d->len < (pos + sizeof(struct atsc_caption_service_entry))) ++ return NULL; ++ ++ bswap16(buf+pos+4); ++ ++ pos += sizeof(struct atsc_caption_service_entry); ++ } ++ ++ return (struct atsc_caption_service_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries field of a atsc_caption_service_descriptor. ++ * ++ * @param d atsc_caption_service_descriptor pointer. ++ * @param pos Variable holding a pointer to the current atsc_caption_service_entry. ++ * @param idx Field iterator integer. ++ */ ++#define atsc_caption_service_descriptor_entries_for_each(d, pos, idx) \ ++ for ((pos) = atsc_caption_service_descriptor_entries_first(d), idx=0; \ ++ (pos); \ ++ (pos) = atsc_caption_service_descriptor_entries_next(d, pos, ++idx)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct atsc_caption_service_entry* ++ atsc_caption_service_descriptor_entries_first(struct atsc_caption_service_descriptor *d) ++{ ++ if (d->number_of_services == 0) ++ return NULL; ++ ++ return (struct atsc_caption_service_entry *) ++ ((uint8_t*) d + sizeof(struct atsc_caption_service_descriptor)); ++} ++ ++static inline struct atsc_caption_service_entry* ++ atsc_caption_service_descriptor_entries_next(struct atsc_caption_service_descriptor *d, ++ struct atsc_caption_service_entry *pos, ++ int idx) ++{ ++ if (idx >= d->number_of_services) ++ return NULL; ++ ++ return (struct atsc_caption_service_entry *) ++ ((uint8_t *) pos + sizeof(struct atsc_caption_service_entry)); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/component_name_descriptor.h dvb-apps/lib/libucsi/atsc/component_name_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/component_name_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/component_name_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,92 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_COMPONENT_NAME_DESCRIPTOR ++#define _UCSI_ATSC_COMPONENT_NAME_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++#include ++ ++/** ++ * atsc_component_name_descriptor structure. ++ */ ++struct atsc_component_name_descriptor { ++ struct descriptor d; ++ ++ /* struct atsc_text text[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an atsc_component_name_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return atsc_component_name_descriptor pointer, or NULL on error. ++ */ ++static inline struct atsc_component_name_descriptor* ++ atsc_component_name_descriptor_codec(struct descriptor* d) ++{ ++ uint8_t *txt = ((uint8_t*) d) + sizeof(struct atsc_component_name_descriptor); ++ ++ if (atsc_text_validate(txt, d->len)) ++ return NULL; ++ ++ return (struct atsc_component_name_descriptor*) d; ++} ++ ++/** ++ * Accessor for the text field of an atsc_component_name_descriptor. ++ * ++ * @param d atsc_component_name_descriptor pointer. ++ * @return Pointer to the atsc_text data, or NULL on error. ++ */ ++static inline struct atsc_text* ++ atsc_component_name_descriptor_text(struct atsc_component_name_descriptor *d) ++{ ++ uint8_t *txt = ((uint8_t*) d) + sizeof(struct atsc_component_name_descriptor); ++ ++ return (struct atsc_text*) txt; ++} ++ ++/** ++ * Accessor for the length of the text field of an atsc_component_name_descriptor_text. ++ * ++ * @param d atsc_component_name_descriptor pointer. ++ * @return The length in bytes. ++ */ ++static inline int ++ atsc_component_name_descriptor_text_length(struct atsc_component_name_descriptor *d) ++{ ++ return d->d.len; ++} ++ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/content_advisory_descriptor.h dvb-apps/lib/libucsi/atsc/content_advisory_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/content_advisory_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/content_advisory_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,235 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_CONTENT_ADVISORY_DESCRIPTOR ++#define _UCSI_ATSC_CONTENT_ADVISORY_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * atsc_content_advisory_descriptor structure. ++ */ ++struct atsc_content_advisory_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint8_t reserved : 2; , ++ uint8_t rating_region_count : 6; ); ++ /* struct atsc_content_advisory_entry entries[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the entries field of a atsc_content_advisory_descriptor. ++ */ ++struct atsc_content_advisory_entry { ++ uint8_t rating_region; ++ uint8_t rated_dimensions; ++ /* struct atsc_content_advisory_entry_dimension dimensions[] */ ++ /* struct atsc_content_advisory_entry_part2 part2 */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the entries field of a atsc_content_advisory_descriptor. ++ */ ++struct atsc_content_advisory_entry_dimension { ++ uint8_t rating_dimension_j; ++ EBIT2(uint8_t reserved : 4; , ++ uint8_t rating_value : 4; ); ++} __ucsi_packed; ++ ++/** ++ * Part2 of an atsc_content_advisory_entry. ++ */ ++struct atsc_content_advisory_entry_part2 { ++ uint8_t rating_description_length; ++ /* struct atsc_text description */ ++} __ucsi_packed; ++ ++/** ++ * Process an atsc_content_advisory_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return atsc_content_advisory_descriptor pointer, or NULL on error. ++ */ ++static inline struct atsc_content_advisory_descriptor* ++ atsc_content_advisory_descriptor_codec(struct descriptor* d) ++{ ++ struct atsc_content_advisory_descriptor *ret = ++ (struct atsc_content_advisory_descriptor *) d; ++ uint8_t *buf = (uint8_t*) d + 2; ++ int pos = 0; ++ int idx; ++ ++ if (d->len < 1) ++ return NULL; ++ pos++; ++ ++ for(idx = 0; idx < ret->rating_region_count; idx++) { ++ if (d->len < (pos + sizeof(struct atsc_content_advisory_entry))) ++ return NULL; ++ struct atsc_content_advisory_entry *entry = ++ (struct atsc_content_advisory_entry *) (buf + pos); ++ pos += sizeof(struct atsc_content_advisory_entry); ++ ++ if (d->len < (pos + (sizeof(struct atsc_content_advisory_entry_dimension) * ++ entry->rated_dimensions))) ++ return NULL; ++ pos += sizeof(struct atsc_content_advisory_entry_dimension) * entry->rated_dimensions; ++ ++ if (d->len < (pos + sizeof(struct atsc_content_advisory_entry_part2))) ++ return NULL; ++ struct atsc_content_advisory_entry_part2 *part2 = ++ (struct atsc_content_advisory_entry_part2 *) (buf + pos); ++ pos += sizeof(struct atsc_content_advisory_entry_part2); ++ ++ if (d->len < (pos + part2->rating_description_length)) ++ return NULL; ++ ++ if (atsc_text_validate(buf+pos, part2->rating_description_length)) ++ return NULL; ++ ++ pos += part2->rating_description_length; ++ } ++ ++ return (struct atsc_content_advisory_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries field of a atsc_content_advisory_descriptor. ++ * ++ * @param d atsc_content_advisory_descriptor pointer. ++ * @param pos Variable holding a pointer to the current atsc_content_advisory_entry. ++ * @param idx Integer used to count which entry we are in. ++ */ ++#define atsc_content_advisory_descriptor_entries_for_each(d, pos, idx) \ ++ for ((pos) = atsc_content_advisory_descriptor_entries_first(d), idx=0; \ ++ (pos); \ ++ (pos) = atsc_content_advisory_descriptor_entries_next(d, pos, ++idx)) ++ ++/** ++ * Iterator for dimensions field of a atsc_content_advisory_entry. ++ * ++ * @param d atsc_content_advisory_entry pointer. ++ * @param pos Variable holding a pointer to the current atsc_content_advisory_entry_dimension. ++ * @param idx Integer used to count which dimension we are in. ++ */ ++#define atsc_content_advisory_entry_dimensions_for_each(d, pos, idx) \ ++ for ((pos) = atsc_content_advisory_entry_dimensions_first(d), idx=0; \ ++ (pos); \ ++ (pos) = atsc_content_advisory_entry_dimensions_next(d, pos, ++idx)) ++ ++/** ++ * Accessor for the part2 field of an atsc_content_advisory_entry. ++ * ++ * @param entry atsc_content_advisory_entry pointer. ++ * @return struct atsc_content_advisory_entry_part2 pointer. ++ */ ++static inline struct atsc_content_advisory_entry_part2 * ++ atsc_content_advisory_entry_part2(struct atsc_content_advisory_entry *entry) ++{ ++ int pos = sizeof(struct atsc_content_advisory_entry); ++ pos += entry->rated_dimensions * sizeof(struct atsc_content_advisory_entry_dimension); ++ ++ return (struct atsc_content_advisory_entry_part2 *) (((uint8_t*) entry) + pos); ++} ++ ++ ++/** ++ * Accessor for the description field of an atsc_content_advisory_entry_part2. ++ * ++ * @param part2 atsc_content_advisory_entry_part2 pointer. ++ * @return Pointer to the atsc_text data, or NULL on error. ++ */ ++static inline struct atsc_text* ++ atsc_content_advisory_entry_part2_description(struct atsc_content_advisory_entry_part2 *part2) ++{ ++ uint8_t *txt = ((uint8_t*) part2) + sizeof(struct atsc_content_advisory_entry_part2); ++ ++ return (struct atsc_text *) txt; ++} ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct atsc_content_advisory_entry* ++ atsc_content_advisory_descriptor_entries_first(struct atsc_content_advisory_descriptor *d) ++{ ++ if (d->rating_region_count == 0) ++ return NULL; ++ ++ return (struct atsc_content_advisory_entry *) ++ ((uint8_t*) d + sizeof(struct atsc_content_advisory_descriptor)); ++} ++ ++static inline struct atsc_content_advisory_entry* ++ atsc_content_advisory_descriptor_entries_next(struct atsc_content_advisory_descriptor *d, ++ struct atsc_content_advisory_entry *pos, ++ int idx) ++{ ++ if (idx >= d->rating_region_count) ++ return NULL; ++ struct atsc_content_advisory_entry_part2 *part2 = ++ atsc_content_advisory_entry_part2(pos); ++ ++ return (struct atsc_content_advisory_entry *) ++ ((uint8_t *) part2 + ++ sizeof(struct atsc_content_advisory_entry_part2) + ++ part2->rating_description_length); ++} ++ ++static inline struct atsc_content_advisory_entry_dimension* ++ atsc_content_advisory_entry_dimensions_first(struct atsc_content_advisory_entry *e) ++{ ++ if (e->rated_dimensions == 0) ++ return NULL; ++ ++ return (struct atsc_content_advisory_entry_dimension *) ++ ((uint8_t*) e + sizeof(struct atsc_content_advisory_entry)); ++} ++ ++static inline struct atsc_content_advisory_entry_dimension* ++ atsc_content_advisory_entry_dimensions_next(struct atsc_content_advisory_entry *e, ++ struct atsc_content_advisory_entry_dimension *pos, ++ int idx) ++{ ++ uint8_t *next = (uint8_t *) pos + sizeof(struct atsc_content_advisory_entry_dimension); ++ ++ if (idx >= e->rated_dimensions) ++ return NULL; ++ return (struct atsc_content_advisory_entry_dimension *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/cvct_section.c dvb-apps/lib/libucsi/atsc/cvct_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/cvct_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/cvct_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,77 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct atsc_cvct_section *atsc_cvct_section_codec(struct atsc_section_psip *psip) ++{ ++ uint8_t * buf = (uint8_t *) psip; ++ size_t pos = sizeof(struct atsc_section_psip); ++ size_t len = section_ext_length(&(psip->ext_head)); ++ int idx; ++ ++ if (len < sizeof(struct atsc_cvct_section)) ++ return NULL; ++ struct atsc_cvct_section *cvct = (struct atsc_cvct_section *) psip; ++ ++ pos++; ++ for(idx =0; idx < cvct->num_channels_in_section; idx++) { ++ if ((pos + sizeof(struct atsc_cvct_channel)) > len) ++ return NULL; ++ struct atsc_cvct_channel *channel = (struct atsc_cvct_channel *) (buf+pos); ++ ++ pos += 7*2; ++ ++ bswap32(buf+pos); ++ bswap32(buf+pos+4); ++ bswap16(buf+pos+8); ++ bswap16(buf+pos+10); ++ bswap16(buf+pos+12); ++ bswap16(buf+pos+14); ++ bswap16(buf+pos+16); ++ pos+=18; ++ ++ if ((pos + channel->descriptors_length) > len) ++ return NULL; ++ if (verify_descriptors(buf + pos, channel->descriptors_length)) ++ return NULL; ++ ++ pos += channel->descriptors_length; ++ } ++ ++ if ((pos + sizeof(struct atsc_cvct_section_part2)) > len) ++ return NULL; ++ struct atsc_cvct_section_part2 *part2 = (struct atsc_cvct_section_part2 *) (buf+pos); ++ ++ bswap16(buf+pos); ++ pos+=2; ++ ++ if ((pos + part2->descriptors_length) > len) ++ return NULL; ++ if (verify_descriptors(buf + pos, part2->descriptors_length)) ++ return NULL; ++ ++ pos += part2->descriptors_length; ++ if (pos != len) ++ return NULL; ++ ++ return (struct atsc_cvct_section *) psip; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/cvct_section.h dvb-apps/lib/libucsi/atsc/cvct_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/cvct_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/cvct_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,228 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_CVCT_SECTION_H ++#define _UCSI_ATSC_CVCT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * atsc_cvct_section structure. ++ */ ++struct atsc_cvct_section { ++ struct atsc_section_psip head; ++ ++ uint8_t num_channels_in_section; ++ /* struct atsc_cvct_channel channels[] */ ++ /* struct atsc_cvct_channel_part2 part2 */ ++} __ucsi_packed; ++ ++struct atsc_cvct_channel { ++ uint16_t short_name[7]; // UTF-16 network ordered ++ EBIT4(uint32_t reserved : 4; , ++ uint32_t major_channel_number :10; , ++ uint32_t minor_channel_number :10; , ++ uint32_t modulation_mode : 8; ); ++ uint32_t carrier_frequency; ++ uint16_t channel_TSID; ++ uint16_t program_number; ++ EBIT8(uint16_t ETM_location : 2; , ++ uint16_t access_controlled : 1; , ++ uint16_t hidden : 1; , ++ uint16_t path_select : 1; , ++ uint16_t out_of_band : 1; , ++ uint16_t hide_guide : 1; , ++ uint16_t reserved2 : 3; , ++ uint16_t service_type : 6; ); ++ uint16_t source_id; ++ EBIT2(uint16_t reserved3 : 6; , ++ uint16_t descriptors_length :10; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++struct atsc_cvct_section_part2 { ++ EBIT2(uint16_t reserved : 6; , ++ uint16_t descriptors_length :10; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++static inline struct atsc_cvct_channel *atsc_cvct_section_channels_first(struct atsc_cvct_section *cvct); ++static inline struct atsc_cvct_channel * ++ atsc_cvct_section_channels_next(struct atsc_cvct_section *cvct, struct atsc_cvct_channel *pos, int idx); ++ ++/** ++ * Process a atsc_cvct_section. ++ * ++ * @param section Pointer to anj atsc_section_psip structure. ++ * @return atsc_cvct_section pointer, or NULL on error. ++ */ ++struct atsc_cvct_section *atsc_cvct_section_codec(struct atsc_section_psip *section); ++ ++/** ++ * Accessor for the transport_stream_id field of a CVCT. ++ * ++ * @param cvdt CVDT pointer. ++ * @return The transport_stream_id. ++ */ ++static inline uint16_t atsc_cvct_section_transport_stream_id(struct atsc_cvct_section *cvct) ++{ ++ return cvct->head.ext_head.table_id_ext; ++} ++ ++/** ++ * Iterator for the tables field in an atsc_cvct_section. ++ * ++ * @param mgt atsc_cvct_section pointer. ++ * @param pos Variable containing a pointer to the current atsc_cvct_channel. ++ * @param idx Integer used to count which table we in. ++ */ ++#define atsc_cvct_section_channels_for_each(mgt, pos, idx) \ ++ for ((pos) = atsc_cvct_section_channels_first(mgt), idx=0; \ ++ (pos); \ ++ (pos) = atsc_cvct_section_channels_next(mgt, pos, ++idx)) ++ ++/** ++ * Iterator for the descriptors field in a atsc_cvct_channel structure. ++ * ++ * @param table atsc_cvct_channel pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define atsc_cvct_channel_descriptors_for_each(table, pos) \ ++ for ((pos) = atsc_cvct_channel_descriptors_first(table); \ ++ (pos); \ ++ (pos) = atsc_cvct_channel_descriptors_next(table, pos)) ++ ++/** ++ * Accessor for the second part of an atsc_cvct_section. ++ * ++ * @param mgt atsc_cvct_section pointer. ++ * @return atsc_cvct_section_part2 pointer. ++ */ ++static inline struct atsc_cvct_section_part2 * ++ atsc_cvct_section_part2(struct atsc_cvct_section *mgt) ++{ ++ int pos = sizeof(struct atsc_cvct_section); ++ ++ struct atsc_cvct_channel *cur_table; ++ int idx; ++ atsc_cvct_section_channels_for_each(mgt, cur_table, idx) { ++ pos += sizeof(struct atsc_cvct_channel); ++ pos += cur_table->descriptors_length; ++ } ++ ++ return (struct atsc_cvct_section_part2 *) (((uint8_t*) mgt) + pos); ++} ++ ++/** ++ * Iterator for the descriptors field in a atsc_cvct_section structure. ++ * ++ * @param part2 atsc_cvct_section_part2 pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define atsc_cvct_section_part2_descriptors_for_each(part2, pos) \ ++ for ((pos) = atsc_cvct_section_part2_descriptors_first(part2); \ ++ (pos); \ ++ (pos) = atsc_cvct_section_part2_descriptors_next(part2, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct atsc_cvct_channel * ++ atsc_cvct_section_channels_first(struct atsc_cvct_section *cvct) ++{ ++ size_t pos = sizeof(struct atsc_cvct_section); ++ ++ if (cvct->num_channels_in_section == 0) ++ return NULL; ++ ++ return (struct atsc_cvct_channel*) (((uint8_t *) cvct) + pos); ++} ++ ++static inline struct atsc_cvct_channel * ++ atsc_cvct_section_channels_next(struct atsc_cvct_section *cvct, ++ struct atsc_cvct_channel *pos, ++ int idx) ++{ ++ if (idx >= cvct->num_channels_in_section) ++ return NULL; ++ ++ return (struct atsc_cvct_channel *) ++ (((uint8_t*) pos) + sizeof(struct atsc_cvct_channel) + pos->descriptors_length); ++} ++ ++static inline struct descriptor * ++ atsc_cvct_channel_descriptors_first(struct atsc_cvct_channel *table) ++{ ++ size_t pos = sizeof(struct atsc_cvct_channel); ++ ++ if (table->descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor*) (((uint8_t *) table) + pos); ++} ++ ++static inline struct descriptor * ++ atsc_cvct_channel_descriptors_next(struct atsc_cvct_channel *table, ++ struct descriptor *pos) ++{ ++ return next_descriptor((uint8_t*) table + sizeof(struct atsc_cvct_channel), ++ table->descriptors_length, ++ pos); ++} ++ ++static inline struct descriptor * ++ atsc_cvct_section_part2_descriptors_first(struct atsc_cvct_section_part2 *part2) ++{ ++ size_t pos = sizeof(struct atsc_cvct_section_part2); ++ ++ if (part2->descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor*) (((uint8_t *) part2) + pos); ++} ++ ++static inline struct descriptor * ++ atsc_cvct_section_part2_descriptors_next(struct atsc_cvct_section_part2 *part2, ++ struct descriptor *pos) ++{ ++ return next_descriptor((uint8_t*) part2 + sizeof(struct atsc_cvct_section_part2), ++ part2->descriptors_length, ++ pos); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/dcc_arriving_request_descriptor.h dvb-apps/lib/libucsi/atsc/dcc_arriving_request_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/dcc_arriving_request_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/dcc_arriving_request_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,107 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_DCC_ARRIVING_REQUEST_DESCRIPTOR ++#define _UCSI_ATSC_DCC_ARRIVING_REQUEST_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++enum atsc_dcc_arriving_request_type { ++ DCC_ARRIVAL_TYPE_DEFER_10SEC = 0x01, ++ DCC_ARRIVAL_TYPE_DEFER = 0x02, ++}; ++ ++/** ++ * atsc_dcc_arriving_request_descriptor structure. ++ */ ++struct atsc_dcc_arriving_request_descriptor { ++ struct descriptor d; ++ ++ uint8_t dcc_arriving_request_type; ++ uint8_t dcc_arriving_request_text_length; ++ /* struct atsc_text text[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an atsc_dcc_arriving_request_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return atsc_dcc_arriving_request_descriptor pointer, or NULL on error. ++ */ ++static inline struct atsc_dcc_arriving_request_descriptor* ++ atsc_dcc_arriving_request_descriptor_codec(struct descriptor* d) ++{ ++ struct atsc_dcc_arriving_request_descriptor *ret = ++ (struct atsc_dcc_arriving_request_descriptor *) d; ++ ++ if (d->len < 2) ++ return NULL; ++ ++ if (d->len != 2 + ret->dcc_arriving_request_text_length) ++ return NULL; ++ ++ if (atsc_text_validate((uint8_t*) d + sizeof(struct atsc_dcc_arriving_request_descriptor), ++ ret->dcc_arriving_request_text_length)) ++ return NULL; ++ ++ return (struct atsc_dcc_arriving_request_descriptor*) d; ++} ++ ++/** ++ * Accessor for the text field of an atsc_dcc_arriving_request_descriptor. ++ * ++ * @param d atsc_dcc_arriving_request_descriptor pointer. ++ * @return Pointer to the atsc_text data, or NULL on error. ++ */ ++static inline struct atsc_text* ++ atsc_dcc_arriving_request_descriptor_text(struct atsc_dcc_arriving_request_descriptor *d) ++{ ++ uint8_t *txt = ((uint8_t*) d) + sizeof(struct atsc_dcc_arriving_request_descriptor); ++ ++ return (struct atsc_text*) txt; ++} ++ ++/** ++ * Accessor for the length of the text field of an atsc_dcc_arriving_request_descriptor. ++ * ++ * @param d atsc_dcc_arriving_request_descriptor pointer. ++ * @return The length in bytes. ++ */ ++static inline int ++ atsc_dcc_arriving_request_descriptor_text_length(struct ++ atsc_dcc_arriving_request_descriptor *d) ++{ ++ return d->d.len - 2; ++} ++ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/dcc_departing_request_descriptor.h dvb-apps/lib/libucsi/atsc/dcc_departing_request_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/dcc_departing_request_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/dcc_departing_request_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,108 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_DCC_DEPARTING_REQUEST_DESCRIPTOR ++#define _UCSI_ATSC_DCC_DEPARTING_REQUEST_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++enum atsc_dcc_departing_request_type { ++ DCC_DEPART_TYPE_IMMEDIATE = 0x01, ++ DCC_DEPART_TYPE_DEFER_10SEC = 0x02, ++ DCC_DEPART_TYPE_DEFER = 0x03, ++}; ++ ++/** ++ * atsc_dcc_departing_request_descriptor structure. ++ */ ++struct atsc_dcc_departing_request_descriptor { ++ struct descriptor d; ++ ++ uint8_t dcc_departing_request_type; ++ uint8_t dcc_departing_request_text_length; ++ /* struct atsc_text text[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an atsc_dcc_departing_request_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return atsc_dcc_departing_request_descriptor pointer, or NULL on error. ++ */ ++static inline struct atsc_dcc_departing_request_descriptor* ++ atsc_dcc_departing_request_descriptor_codec(struct descriptor* d) ++{ ++ struct atsc_dcc_departing_request_descriptor *ret = ++ (struct atsc_dcc_departing_request_descriptor *) d; ++ ++ if (d->len < 2) ++ return NULL; ++ ++ if (d->len != 2 + ret->dcc_departing_request_text_length) ++ return NULL; ++ ++ if (atsc_text_validate(((uint8_t*) d) + sizeof(struct atsc_dcc_departing_request_descriptor), ++ ret->dcc_departing_request_text_length)) ++ return NULL; ++ ++ return (struct atsc_dcc_departing_request_descriptor*) d; ++} ++ ++/** ++ * Accessor for the text field of an atsc_dcc_departing_request_descriptor. ++ * ++ * @param d atsc_dcc_departing_request_descriptor pointer. ++ * @return Pointer to the atsc_text data, or NULL on error. ++ */ ++static inline struct atsc_text* ++ atsc_dcc_departing_request_descriptor_text(struct atsc_dcc_departing_request_descriptor *d) ++{ ++ uint8_t *txt = ((uint8_t*) d) + sizeof(struct atsc_dcc_departing_request_descriptor); ++ ++ return (struct atsc_text*) txt; ++} ++ ++/** ++ * Accessor for the length of the text field of an atsc_dcc_departing_request_descriptor. ++ * ++ * @param d atsc_dcc_departing_request_descriptor pointer. ++ * @return The length in bytes. ++ */ ++static inline int ++ atsc_dcc_departing_request_descriptor_text_length(struct ++ atsc_dcc_departing_request_descriptor *d) ++{ ++ return d->d.len - 2; ++} ++ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/dccsct_section.c dvb-apps/lib/libucsi/atsc/dccsct_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/dccsct_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/dccsct_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,109 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct atsc_dccsct_section *atsc_dccsct_section_codec(struct atsc_section_psip *psip) ++{ ++ uint8_t * buf = (uint8_t *) psip; ++ size_t pos = 0; ++ size_t len = section_ext_length(&(psip->ext_head)); ++ int idx; ++ ++ if (len < sizeof(struct atsc_dccsct_section)) ++ return NULL; ++ struct atsc_dccsct_section *dccsct = (struct atsc_dccsct_section *) psip; ++ ++ pos += sizeof(struct atsc_dccsct_section); ++ for(idx =0; idx < dccsct->updates_defined; idx++) { ++ if (len < (pos + sizeof(struct atsc_dccsct_update))) ++ return NULL; ++ struct atsc_dccsct_update *update = (struct atsc_dccsct_update *) (buf+pos); ++ ++ pos += sizeof(struct atsc_dccsct_update); ++ if (len < (pos + update->update_data_length)) ++ return NULL; ++ ++ switch(update->update_type) { ++ case ATSC_DCCST_UPDATE_NEW_GENRE: { ++ int sublen = sizeof(struct atsc_dccsct_update_new_genre); ++ if (update->update_data_length < sublen) ++ return NULL; ++ ++ if (atsc_text_validate(buf+pos+sublen, update->update_data_length - sublen)) ++ return NULL; ++ break; ++ } ++ case ATSC_DCCST_UPDATE_NEW_STATE: { ++ int sublen = sizeof(struct atsc_dccsct_update_new_state); ++ if (update->update_data_length < sublen) ++ return NULL; ++ ++ if (atsc_text_validate(buf+pos+sublen, update->update_data_length - sublen)) ++ return NULL; ++ break; ++ } ++ case ATSC_DCCST_UPDATE_NEW_COUNTY: { ++ int sublen = sizeof(struct atsc_dccsct_update_new_county); ++ if (update->update_data_length < sublen) ++ return NULL; ++ bswap16(buf+pos+1); ++ ++ if (atsc_text_validate(buf+pos+sublen, update->update_data_length - sublen)) ++ return NULL; ++ break; ++ } ++ } ++ ++ pos += update->update_data_length; ++ if (len < (pos + sizeof(struct atsc_dccsct_update_part2))) ++ return NULL; ++ struct atsc_dccsct_update_part2 *part2 = (struct atsc_dccsct_update_part2 *) buf + pos; ++ ++ bswap16(buf+pos); ++ ++ pos += sizeof(struct atsc_dccsct_update_part2); ++ if (len < (pos + part2->descriptors_length)) ++ return NULL; ++ if (verify_descriptors(buf + pos, part2->descriptors_length)) ++ return NULL; ++ ++ pos += part2->descriptors_length; ++ } ++ ++ if (len < (pos + sizeof(struct atsc_dccsct_section_part2))) ++ return NULL; ++ struct atsc_dccsct_section_part2 *part2 = (struct atsc_dccsct_section_part2 *) (buf+pos); ++ ++ bswap16(buf+pos); ++ ++ pos += sizeof(struct atsc_dccsct_section_part2); ++ if (len < (pos + part2->descriptors_length)) ++ return NULL; ++ if (verify_descriptors(buf + pos, part2->descriptors_length)) ++ return NULL; ++ ++ pos += part2->descriptors_length; ++ if (pos != len) ++ return NULL; ++ ++ return (struct atsc_dccsct_section *) psip; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/dccsct_section.h dvb-apps/lib/libucsi/atsc/dccsct_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/dccsct_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/dccsct_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,327 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_DCCSCT_SECTION_H ++#define _UCSI_ATSC_DCCSCT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++enum atsc_dccst_update_types { ++ ATSC_DCCST_UPDATE_NEW_GENRE = 0x01, ++ ATSC_DCCST_UPDATE_NEW_STATE = 0x02, ++ ATSC_DCCST_UPDATE_NEW_COUNTY = 0x03, ++}; ++ ++/** ++ * atsc_dccsct_section structure. ++ */ ++struct atsc_dccsct_section { ++ struct atsc_section_psip head; ++ ++ uint8_t updates_defined; ++ /* struct atsc_dccsct_update updates */ ++ /* struct atsc_dccsct_section_part2 part2 */ ++} __ucsi_packed; ++ ++struct atsc_dccsct_update { ++ uint8_t update_type; ++ uint8_t update_data_length; ++ /* struct atsc_dccsct_update_XXX data -- depends on update_type */ ++ /* struct atsc_dccsct_update_part2 part2 */ ++} __ucsi_packed; ++ ++struct atsc_dccsct_update_new_genre { ++ uint8_t genre_category_code; ++ /* atsc_text name */ ++} __ucsi_packed; ++ ++struct atsc_dccsct_update_new_state { ++ uint8_t dcc_state_location_code; ++ /* atsc_text name */ ++} __ucsi_packed; ++ ++struct atsc_dccsct_update_new_county { ++ uint8_t state_code; ++ EBIT2(uint16_t reserved : 6; , ++ uint16_t dcc_county_location_code :10; ); ++ /* atsc_text name */ ++} __ucsi_packed; ++ ++struct atsc_dccsct_update_part2 { ++ EBIT2(uint16_t reserved : 6; , ++ uint16_t descriptors_length :10; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++struct atsc_dccsct_section_part2 { ++ EBIT2(uint16_t reserved : 6; , ++ uint16_t descriptors_length :10; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an atsc_dccsct_section. ++ * ++ * @param section Pointer to an atsc_section_psip structure. ++ * @return atsc_dccsct_section pointer, or NULL on error. ++ */ ++struct atsc_dccsct_section *atsc_dccsct_section_codec(struct atsc_section_psip *section); ++ ++/** ++ * Accessor for the dccsct_type field of a dccsct. ++ * ++ * @param dccsct dccsct pointer. ++ * @return The dccsct_type. ++ */ ++static inline uint16_t atsc_dccsct_section_dccsct_type(struct atsc_dccsct_section *dccsct) ++{ ++ return dccsct->head.ext_head.table_id_ext; ++} ++ ++/** ++ * Iterator for the updates field in an atsc_dccsct_section. ++ * ++ * @param dccsct atsc_dccsct_section pointer. ++ * @param pos Variable containing a pointer to the current atsc_dccsct_update. ++ * @param idx Integer used to count which test we are in. ++ */ ++#define atsc_dccsct_section_updates_for_each(dccsct, pos, idx) \ ++ for ((pos) = atsc_dccsct_section_updates_first(dccsct), idx=0; \ ++ (pos); \ ++ (pos) = atsc_dccsct_section_updates_next(dccsct, pos, ++idx)) ++ ++/** ++ * Accessor for the data field of a new genre atsc_dccsct_update. ++ * ++ * @param update atsc_dccsct_update pointer. ++ * @return struct atsc_dccsct_update_new_genre pointer. ++ */ ++static inline struct atsc_dccsct_update_new_genre *atsc_dccsct_update_new_genre(struct atsc_dccsct_update *update) ++{ ++ if (update->update_type != ATSC_DCCST_UPDATE_NEW_GENRE) ++ return NULL; ++ ++ return (struct atsc_dccsct_update_new_genre *) ++ (((uint8_t*) update) + sizeof(struct atsc_dccsct_update)); ++} ++ ++/** ++ * Accessor for the name field of an atsc_dccsct_update_new_genre. ++ * ++ * @param update atsc_dccsct_update_new_genre pointer. ++ * @return text pointer. ++ */ ++static inline struct atsc_text *atsc_dccsct_update_new_genre_name(struct atsc_dccsct_update *update) ++{ ++ if ((update->update_data_length - 1) == 0) ++ return NULL; ++ ++ return (struct atsc_text *) ++ (((uint8_t*) update) + sizeof(struct atsc_dccsct_update_new_genre)); ++} ++ ++/** ++ * Accessor for the data field of a new state atsc_dccsct_update. ++ * ++ * @param update atsc_dccsct_update pointer. ++ * @return struct atsc_dccsct_update_new_state pointer. ++ */ ++static inline struct atsc_dccsct_update_new_state * ++ atsc_dccsct_update_new_state(struct atsc_dccsct_update *update) ++{ ++ if (update->update_type != ATSC_DCCST_UPDATE_NEW_STATE) ++ return NULL; ++ ++ return (struct atsc_dccsct_update_new_state *) ++ (((uint8_t*) update) + sizeof(struct atsc_dccsct_update)); ++} ++ ++/** ++ * Accessor for the name field of an atsc_dccsct_update_new_state. ++ * ++ * @param update atsc_dccsct_update_new_state pointer. ++ * @return text pointer. ++ */ ++static inline struct atsc_text *atsc_dccsct_update_new_state_name(struct atsc_dccsct_update *update) ++{ ++ if ((update->update_data_length - 1) == 0) ++ return NULL; ++ ++ return (struct atsc_text *) ++ (((uint8_t*) update) + sizeof(struct atsc_dccsct_update_new_state)); ++} ++ ++/** ++ * Accessor for the data field of a new county atsc_dccsct_update. ++ * ++ * @param update atsc_dccsct_update pointer. ++ * @return struct atsc_dccsct_update_new_county pointer. ++ */ ++static inline struct atsc_dccsct_update_new_county * ++ atsc_dccsct_update_new_county(struct atsc_dccsct_update *update) ++{ ++ if (update->update_type != ATSC_DCCST_UPDATE_NEW_COUNTY) ++ return NULL; ++ ++ return (struct atsc_dccsct_update_new_county *) ++ (((uint8_t*) update) + sizeof(struct atsc_dccsct_update)); ++} ++ ++/** ++ * Accessor for the name field of an atsc_dccsct_update_new_county. ++ * ++ * @param update atsc_dccsct_update_new_county pointer. ++ * @return text pointer. ++ */ ++static inline struct atsc_text *atsc_dccsct_update_new_county_name(struct atsc_dccsct_update *update) ++{ ++ if ((update->update_data_length - 3) == 0) ++ return NULL; ++ ++ return (struct atsc_text*) ++ (((uint8_t*) update) + sizeof(struct atsc_dccsct_update_new_county)); ++} ++ ++/** ++ * Accessor for the part2 field of an atsc_dccsct_update. ++ * ++ * @param update atsc_dccsct_update pointer. ++ * @return struct atsc_dccsct_test_part2 pointer. ++ */ ++static inline struct atsc_dccsct_update_part2 *atsc_dccsct_update_part2(struct atsc_dccsct_update *update) ++{ ++ int pos = sizeof(struct atsc_dccsct_update); ++ pos += update->update_data_length; ++ ++ return (struct atsc_dccsct_update_part2 *) (((uint8_t*) update) + pos); ++} ++ ++/** ++ * Iterator for the descriptors field in an atsc_dccsct_update_part2 structure. ++ * ++ * @param part2 atsc_dccsct_update_part2 pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define atsc_dccsct_update_part2_descriptors_for_each(part2, pos) \ ++ for ((pos) = atsc_dccsct_update_part2_descriptors_first(part2); \ ++ (pos); \ ++ (pos) = atsc_dccsct_update_part2_descriptors_next(part2, pos)) ++ ++/** ++ * Iterator for the descriptors field in a atsc_dccsct_section_part2 structure. ++ * ++ * @param part2 atsc_dccsct_section_part2 pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define atsc_dccsct_section_part2_descriptors_for_each(part2, pos) \ ++ for ((pos) = atsc_dccsct_section_part2_descriptors_first(part2); \ ++ (pos); \ ++ (pos) = atsc_dccsct_section_part2_descriptors_next(part2, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct atsc_dccsct_update * ++ atsc_dccsct_section_updates_first(struct atsc_dccsct_section *dccsct) ++{ ++ size_t pos = sizeof(struct atsc_dccsct_section); ++ ++ if (dccsct->updates_defined == 0) ++ return NULL; ++ ++ return (struct atsc_dccsct_update*) (((uint8_t *) dccsct) + pos); ++} ++ ++static inline struct atsc_dccsct_update* ++ atsc_dccsct_section_updates_next(struct atsc_dccsct_section *dccsct, ++ struct atsc_dccsct_update *pos, ++ int idx) ++{ ++ if (idx >= dccsct->updates_defined) ++ return NULL; ++ ++ struct atsc_dccsct_update_part2 *part2 = atsc_dccsct_update_part2(pos); ++ int len = sizeof(struct atsc_dccsct_update_part2); ++ len += part2->descriptors_length; ++ ++ return (struct atsc_dccsct_update *) (((uint8_t*) part2) + len); ++} ++ ++static inline struct descriptor * ++ atsc_dccsct_update_part2_descriptors_first(struct atsc_dccsct_update_part2 *part2) ++{ ++ size_t pos = sizeof(struct atsc_dccsct_update_part2); ++ ++ if (part2->descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor*) (((uint8_t *) part2) + pos); ++} ++ ++static inline struct descriptor * ++ atsc_dccsct_update_part2_descriptors_next(struct atsc_dccsct_update_part2 *part2, ++ struct descriptor *pos) ++{ ++ return next_descriptor((uint8_t*) part2 + sizeof(struct atsc_dccsct_update_part2), ++ part2->descriptors_length, ++ pos); ++} ++ ++static inline struct descriptor * ++ atsc_dccsct_section_part2_descriptors_first(struct atsc_dccsct_section_part2 *part2) ++{ ++ size_t pos = sizeof(struct atsc_dccsct_section_part2); ++ ++ if (part2->descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor*) (((uint8_t *) part2) + pos); ++} ++ ++static inline struct descriptor * ++ atsc_dccsct_section_part2_descriptors_next(struct atsc_dccsct_section_part2 *part2, ++ struct descriptor *pos) ++{ ++ return next_descriptor((uint8_t*) part2 + sizeof(struct atsc_dccsct_section_part2), ++ part2->descriptors_length, ++ pos); ++} ++ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/dcct_section.c dvb-apps/lib/libucsi/atsc/dcct_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/dcct_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/dcct_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,96 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct atsc_dcct_section *atsc_dcct_section_codec(struct atsc_section_psip *psip) ++{ ++ uint8_t * buf = (uint8_t *) psip; ++ size_t pos = 0; ++ size_t len = section_ext_length(&(psip->ext_head)); ++ int testidx; ++ int termidx; ++ ++ if (len < sizeof(struct atsc_dcct_section)) ++ return NULL; ++ struct atsc_dcct_section *dcct = (struct atsc_dcct_section *) psip; ++ ++ pos += sizeof(struct atsc_dcct_section); ++ for(testidx =0; testidx < dcct->dcc_test_count; testidx++) { ++ if (len < (pos + sizeof(struct atsc_dcct_test))) ++ return NULL; ++ struct atsc_dcct_test *test = (struct atsc_dcct_test *) (buf+pos); ++ ++ bswap24(buf+pos); ++ bswap24(buf+pos+3); ++ bswap32(buf+pos+6); ++ bswap32(buf+pos+10); ++ ++ pos += sizeof(struct atsc_dcct_test); ++ for(termidx =0; termidx < test->dcc_term_count; termidx++) { ++ if (len < (pos + sizeof(struct atsc_dcct_term))) ++ return NULL; ++ struct atsc_dcct_term *term = (struct atsc_dcct_term *) (buf+pos); ++ ++ bswap64(buf+pos+1); ++ bswap16(buf+pos+9); ++ ++ pos += sizeof(struct atsc_dcct_term); ++ if (len < (pos + term->descriptors_length)) ++ return NULL; ++ if (verify_descriptors(buf + pos, term->descriptors_length)) ++ return NULL; ++ ++ pos += term->descriptors_length; ++ } ++ ++ if (len < (pos + sizeof(struct atsc_dcct_test_part2))) ++ return NULL; ++ struct atsc_dcct_test_part2 *part2 = (struct atsc_dcct_test_part2 *) (buf+pos); ++ ++ bswap16(buf+pos); ++ ++ pos += sizeof(struct atsc_dcct_test_part2); ++ if (len < (pos + part2->descriptors_length)) ++ return NULL; ++ if (verify_descriptors(buf + pos, part2->descriptors_length)) ++ return NULL; ++ pos += part2->descriptors_length; ++ } ++ ++ if (len < (pos + sizeof(struct atsc_dcct_section_part2))) ++ return NULL; ++ struct atsc_dcct_section_part2 *part2 = (struct atsc_dcct_section_part2 *) (buf+pos); ++ ++ bswap16(buf+pos); ++ ++ pos += sizeof(struct atsc_dcct_section_part2); ++ if (len < (pos + part2->descriptors_length)) ++ return NULL; ++ if (verify_descriptors(buf + pos, part2->descriptors_length)) ++ return NULL; ++ ++ pos += part2->descriptors_length; ++ if (pos != len) ++ return NULL; ++ ++ return (struct atsc_dcct_section *) psip; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/dcct_section.h dvb-apps/lib/libucsi/atsc/dcct_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/dcct_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/dcct_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,380 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_DCCT_SECTION_H ++#define _UCSI_ATSC_DCCT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++enum atsc_dcc_context { ++ ATSC_DCC_CONTEXT_TEMPORARY_RETUNE = 0, ++ ATSC_DCC_CONTEXT_CHANNEL_REDIRECT = 1, ++}; ++ ++enum atsc_dcc_selection_type { ++ ATSC_DCC_SELECTION_UNCONDITIONAL_CHANNEL_CHANGE = 0x00, ++ ATSC_DCC_SELECTION_NUMERIC_POSTAL_CODE_INCLUSION = 0x01, ++ ATSC_DCC_SELECTION_ALPHANUMERIC_POSTAL_CODE_INCLUSION = 0x02, ++ ATSC_DCC_SELECTION_DEMOGRAPHIC_CATEGORY_ONE_OR_MORE = 0x05, ++ ATSC_DCC_SELECTION_DEMOGRAPHIC_CATEGORY_ALL = 0x06, ++ ATSC_DCC_SELECTION_GENRE_CATEGORY_ONE_OR_MORE = 0x07, ++ ATSC_DCC_SELECTION_GENRE_CATEGORY_ALL = 0x08, ++ ATSC_DCC_SELECTION_CANNOT_BE_AUTHORIZED = 0x09, ++ ATSC_DCC_SELECTION_GEOGRAPHIC_LOCATION_INCLUSION = 0x0c, ++ ATSC_DCC_SELECTION_RATING_BLOCKED = 0x0d, ++ ATSC_DCC_SELECTION_RETURN_TO_ORIGINAL_CHANNEL = 0x0f, ++ ATSC_DCC_SELECTION_NUMERIC_POSTAL_CODE_EXCLUSION = 0x11, ++ ATSC_DCC_SELECTION_ALPHANUMERIC_POSTAL_CODE_EXCLUSION = 0x12, ++ ATSC_DCC_SELECTION_DEMOGRAPHIC_CATEGORY_NOT_ONE_OR_MORE = 0x15, ++ ATSC_DCC_SELECTION_DEMOGRAPHIC_CATEGORY_NOT_ALL = 0x16, ++ ATSC_DCC_SELECTION_GENRE_CATEGORY_NOT_ONE_OR_MORE = 0x17, ++ ATSC_DCC_SELECTION_GENRE_CATEGORY_NOT_ALL = 0x18, ++ ATSC_DCC_SELECTION_GEOGRAPHIC_LOCATION_EXCLUSION = 0x1c, ++ ATSC_DCC_SELECTION_VIEWER_DIRECT_SELECT_A = 0x20, ++ ATSC_DCC_SELECTION_VIEWER_DIRECT_SELECT_B = 0x21, ++ ATSC_DCC_SELECTION_VIEWER_DIRECT_SELECT_C = 0x22, ++ ATSC_DCC_SELECTION_VIEWER_DIRECT_SELECT_D = 0x23, ++}; ++ ++/** ++ * atsc_dcct_section structure. ++ */ ++struct atsc_dcct_section { ++ struct atsc_section_psip head; ++ ++ uint8_t dcc_test_count; ++ /* struct atsc_dcct_test tests */ ++ /* struct atsc_dcct_section_part2 part2 */ ++} __ucsi_packed; ++ ++struct atsc_dcct_test { ++ EBIT4(uint32_t dcc_context : 1; , ++ uint32_t reserved : 3; , ++ uint32_t dcc_from_major_channel_number :10; , ++ uint32_t dcc_from_minor_channel_number :10; ); ++ EBIT3(uint32_t reserved1 : 4; , ++ uint32_t dcc_to_major_channel_number :10; , ++ uint32_t dcc_to_minor_channel_number :10; ); ++ atsctime_t start_time; ++ atsctime_t end_time; ++ uint8_t dcc_term_count; ++ /* struct atsc_dcct_term terms */ ++ /* struct atsc_dcct_test_part2 part2 */ ++} __ucsi_packed; ++ ++struct atsc_dcct_term { ++ uint8_t dcc_selection_type; ++ uint64_t dcc_selection_id; ++ EBIT2(uint16_t reserved : 6; , ++ uint16_t descriptors_length :10; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++struct atsc_dcct_test_part2 { ++ EBIT2(uint16_t reserved : 6; , ++ uint16_t descriptors_length :10; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++struct atsc_dcct_section_part2 { ++ EBIT2(uint16_t reserved : 6; , ++ uint16_t descriptors_length :10; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++static inline struct atsc_dcct_test * ++ atsc_dcct_section_tests_first(struct atsc_dcct_section *dcct); ++static inline struct atsc_dcct_test * ++ atsc_dcct_section_tests_next(struct atsc_dcct_section *dcct, ++ struct atsc_dcct_test *pos, ++ int idx); ++static inline struct atsc_dcct_term * ++ atsc_dcct_test_terms_first(struct atsc_dcct_test *test); ++static inline struct atsc_dcct_term * ++ atsc_dcct_test_terms_next(struct atsc_dcct_test *test, ++ struct atsc_dcct_term *pos, ++ int idx); ++ ++ ++/** ++ * Process an atsc_dcct_section. ++ * ++ * @param section Pointer to an atsc_section_psip structure. ++ * @return atsc_dcct_section pointer, or NULL on error. ++ */ ++struct atsc_dcct_section *atsc_dcct_section_codec(struct atsc_section_psip *section); ++ ++/** ++ * Accessor for the dcc_subtype field of a dcct. ++ * ++ * @param dcct dcct pointer. ++ * @return The dcc_subtype. ++ */ ++static inline uint8_t atsc_dcct_section_dcc_subtype(struct atsc_dcct_section *dcct) ++{ ++ return dcct->head.ext_head.table_id_ext >> 8; ++} ++ ++/** ++ * Accessor for the dcc_id field of a dcct. ++ * ++ * @param dcct dcct pointer. ++ * @return The dcc_id. ++ */ ++static inline uint8_t atsc_dcct_section_dcc_id(struct atsc_dcct_section *dcct) ++{ ++ return dcct->head.ext_head.table_id_ext & 0xff; ++} ++ ++/** ++ * Iterator for the tests field in an atsc_dcct_section. ++ * ++ * @param dcct atsc_dcct_section pointer. ++ * @param pos Variable containing a pointer to the current atsc_dcct_test. ++ * @param idx Integer used to count which test we are in. ++ */ ++#define atsc_dcct_section_tests_for_each(dcct, pos, idx) \ ++ for ((pos) = atsc_dcct_section_tests_first(dcct), idx=0; \ ++ (pos); \ ++ (pos) = atsc_dcct_section_tests_next(dcct, pos, ++idx)) ++ ++/** ++ * Iterator for the terms field in an atsc_dcct_test. ++ * ++ * @param test atsc_dcct_test pointer. ++ * @param pos Variable containing a pointer to the current atsc_dcct_term. ++ * @param idx Integer used to count which test we are in. ++ */ ++#define atsc_dcct_test_terms_for_each(test, pos, idx) \ ++ for ((pos) = atsc_dcct_test_terms_first(test), idx=0; \ ++ (pos); \ ++ (pos) = atsc_dcct_test_terms_next(test, pos, ++idx)) ++ ++/** ++ * Iterator for the descriptors field in a atsc_dcct_term structure. ++ * ++ * @param term atsc_dcct_term pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define atsc_dcct_term_descriptors_for_each(term, pos) \ ++ for ((pos) = atsc_dcct_term_descriptors_first(term); \ ++ (pos); \ ++ (pos) = atsc_dcct_term_descriptors_next(term, pos)) ++ ++/** ++ * Accessor for the part2 field of an atsc_dcct_test. ++ * ++ * @param test atsc_dcct_test pointer. ++ * @return struct atsc_dcct_test_part2 pointer. ++ */ ++static inline struct atsc_dcct_test_part2 *atsc_dcct_test_part2(struct atsc_dcct_test *test) ++{ ++ int pos = sizeof(struct atsc_dcct_test); ++ ++ struct atsc_dcct_term *cur_term; ++ int idx; ++ atsc_dcct_test_terms_for_each(test, cur_term, idx) { ++ pos += sizeof(struct atsc_dcct_term); ++ pos += cur_term->descriptors_length; ++ } ++ ++ return (struct atsc_dcct_test_part2 *) (((uint8_t*) test) + pos); ++} ++ ++/** ++ * Iterator for the descriptors field in a atsc_dcct_test_part2 structure. ++ * ++ * @param term atsc_dcct_test_part2 pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define atsc_dcct_test_part2_descriptors_for_each(part2, pos) \ ++ for ((pos) = atsc_dcct_test_part2_descriptors_first(part2); \ ++ (pos); \ ++ (pos) = atsc_dcct_test_part2_descriptors_next(part2, pos)) ++ ++/** ++ * Accessor for the part2 field of an atsc_dcct_section. ++ * ++ * @param dcct atsc_dcct_section pointer. ++ * @return struct atsc_dcct_section_part2 pointer. ++ */ ++static inline struct atsc_dcct_section_part2 *atsc_dcct_section_part2(struct atsc_dcct_section *dcct) ++{ ++ int pos = sizeof(struct atsc_dcct_section); ++ ++ struct atsc_dcct_test *cur_test; ++ int testidx; ++ atsc_dcct_section_tests_for_each(dcct, cur_test, testidx) { ++ struct atsc_dcct_test_part2 *part2 = atsc_dcct_test_part2(cur_test); ++ pos += ((uint8_t*) part2 - (uint8_t*) cur_test); ++ ++ pos += sizeof(struct atsc_dcct_test_part2); ++ pos += part2->descriptors_length; ++ } ++ ++ return (struct atsc_dcct_section_part2 *) (((uint8_t*) dcct) + pos); ++} ++ ++/** ++ * Iterator for the descriptors field in a atsc_dcct_section_part2 structure. ++ * ++ * @param part2 atsc_dcct_section_part2 pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define atsc_dcct_section_part2_descriptors_for_each(part2, pos) \ ++ for ((pos) = atsc_dcct_section_part2_descriptors_first(part2); \ ++ (pos); \ ++ (pos) = atsc_dcct_section_part2_descriptors_next(part2, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct atsc_dcct_test * ++ atsc_dcct_section_tests_first(struct atsc_dcct_section *dcct) ++{ ++ size_t pos = sizeof(struct atsc_dcct_section); ++ ++ if (dcct->dcc_test_count == 0) ++ return NULL; ++ ++ return (struct atsc_dcct_test*) (((uint8_t *) dcct) + pos); ++} ++ ++static inline struct atsc_dcct_test * ++ atsc_dcct_section_tests_next(struct atsc_dcct_section *dcct, ++ struct atsc_dcct_test *pos, ++ int idx) ++{ ++ if (idx >= dcct->dcc_test_count) ++ return NULL; ++ ++ struct atsc_dcct_test_part2 *part2 = atsc_dcct_test_part2(pos); ++ int len = sizeof(struct atsc_dcct_test_part2); ++ len += part2->descriptors_length; ++ ++ return (struct atsc_dcct_test *) (((uint8_t*) part2) + len); ++} ++ ++static inline struct atsc_dcct_term * ++ atsc_dcct_test_terms_first(struct atsc_dcct_test *test) ++{ ++ size_t pos = sizeof(struct atsc_dcct_test); ++ ++ if (test->dcc_term_count == 0) ++ return NULL; ++ ++ return (struct atsc_dcct_term*) (((uint8_t *) test) + pos); ++} ++ ++static inline struct atsc_dcct_term * ++ atsc_dcct_test_terms_next(struct atsc_dcct_test *test, ++ struct atsc_dcct_term *pos, ++ int idx) ++{ ++ if (idx >= test->dcc_term_count) ++ return NULL; ++ ++ int len = sizeof(struct atsc_dcct_term); ++ len += pos->descriptors_length; ++ ++ return (struct atsc_dcct_term *) (((uint8_t*) pos) + len); ++} ++ ++static inline struct descriptor * ++ atsc_dcct_term_descriptors_first(struct atsc_dcct_term *term) ++{ ++ size_t pos = sizeof(struct atsc_dcct_term); ++ ++ if (term->descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor*) (((uint8_t *) term) + pos); ++} ++ ++static inline struct descriptor * ++ atsc_dcct_term_descriptors_next(struct atsc_dcct_term *term, ++ struct descriptor *pos) ++{ ++ return next_descriptor((uint8_t*) term + sizeof(struct atsc_dcct_term), ++ term->descriptors_length, ++ pos); ++} ++ ++static inline struct descriptor * ++ atsc_dcct_test_part2_descriptors_first(struct atsc_dcct_test_part2 *part2) ++{ ++ size_t pos = sizeof(struct atsc_dcct_test_part2); ++ ++ if (part2->descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor*) (((uint8_t *) part2) + pos); ++} ++ ++static inline struct descriptor * ++ atsc_dcct_test_part2_descriptors_next(struct atsc_dcct_test_part2 *part2, ++ struct descriptor *pos) ++{ ++ return next_descriptor((uint8_t*) part2 + sizeof(struct atsc_dcct_test_part2), ++ part2->descriptors_length, ++ pos); ++} ++ ++static inline struct descriptor * ++ atsc_dcct_section_part2_descriptors_first(struct atsc_dcct_section_part2 *part2) ++{ ++ size_t pos = sizeof(struct atsc_dcct_section_part2); ++ ++ if (part2->descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor*) (((uint8_t *) part2) + pos); ++} ++ ++static inline struct descriptor * ++ atsc_dcct_section_part2_descriptors_next(struct atsc_dcct_section_part2 *part2, ++ struct descriptor *pos) ++{ ++ return next_descriptor((uint8_t*) part2 + sizeof(struct atsc_dcct_section_part2), ++ part2->descriptors_length, ++ pos); ++} ++ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/descriptor.h dvb-apps/lib/libucsi/atsc/descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,68 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_DESCRIPTOR_H ++#define _UCSI_ATSC_DESCRIPTOR_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/** ++ * Enumeration of ATSC descriptor tags. ++ */ ++enum atsc_descriptor_tag { ++ dtag_atsc_stuffing = 0x80, ++ dtag_atsc_ac3_audio = 0x81, ++ dtag_atsc_caption_service = 0x86, ++ dtag_atsc_content_advisory = 0x87, ++ dtag_atsc_extended_channel_name = 0xa0, ++ dtag_atsc_service_location = 0xa1, ++ dtag_atsc_time_shifted_service = 0xa2, ++ dtag_atsc_component_name = 0xa3, ++ dtag_atsc_dcc_departing_request = 0xa8, ++ dtag_atsc_dcc_arriving_request = 0xa9, ++ dtag_atsc_redistribution_control = 0xaa, ++ dtag_atsc_private_information = 0xad, ++ dtag_atsc_content_identifier = 0xb6, ++ dtag_atsc_genre = 0xab, ++}; ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/eit_section.c dvb-apps/lib/libucsi/atsc/eit_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/eit_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/eit_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,71 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct atsc_eit_section *atsc_eit_section_codec(struct atsc_section_psip *psip) ++{ ++ uint8_t * buf = (uint8_t *) psip; ++ size_t pos = 0; ++ size_t len = section_ext_length(&(psip->ext_head)); ++ int idx; ++ ++ if (len < sizeof(struct atsc_eit_section)) ++ return NULL; ++ struct atsc_eit_section *eit = (struct atsc_eit_section *) psip; ++ ++ pos += sizeof(struct atsc_eit_section); ++ for(idx =0; idx < eit->num_events_in_section; idx++) { ++ if (len < (pos + sizeof(struct atsc_eit_event))) ++ return NULL; ++ struct atsc_eit_event *event = (struct atsc_eit_event *) (buf+pos); ++ ++ bswap16(buf+pos); ++ bswap32(buf+pos+2); ++ bswap32(buf+pos+6); ++ ++ pos += sizeof(struct atsc_eit_event); ++ if (len < (pos + event->title_length)) ++ return NULL; ++ if (atsc_text_validate(buf+pos, event->title_length)) ++ return NULL; ++ ++ pos += event->title_length; ++ if (len < (pos + sizeof(struct atsc_eit_event_part2))) ++ return NULL; ++ struct atsc_eit_event_part2 *part2 = (struct atsc_eit_event_part2 *) (buf+pos); ++ ++ bswap16(buf+pos); ++ ++ pos += sizeof(struct atsc_eit_event_part2); ++ if (len < (pos + part2->descriptors_length)) ++ return NULL; ++ ++ if (verify_descriptors(buf + pos, part2->descriptors_length)) ++ return NULL; ++ pos += part2->descriptors_length; ++ } ++ ++ if (pos != len) ++ return NULL; ++ ++ return (struct atsc_eit_section *) psip; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/eit_section.h dvb-apps/lib/libucsi/atsc/eit_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/eit_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/eit_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,191 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_EIT_SECTION_H ++#define _UCSI_ATSC_EIT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * atsc_eit_section structure. ++ */ ++struct atsc_eit_section { ++ struct atsc_section_psip head; ++ ++ uint8_t num_events_in_section; ++ /* struct atsc_eit_event events[] */ ++} __ucsi_packed; ++ ++struct atsc_eit_event { ++ EBIT2(uint16_t reserved : 2; , ++ uint16_t event_id :14; ); ++ atsctime_t start_time; ++ EBIT4(uint32_t reserved1 : 2; , ++ uint32_t ETM_location : 2; , ++ uint32_t length_in_seconds :20; , ++ uint32_t title_length : 8; ); ++ /* struct atsc_text title_text */ ++ /* struct atsc_eit_event_part2 part2 */ ++} __ucsi_packed; ++ ++struct atsc_eit_event_part2 { ++ EBIT2(uint16_t reserved : 4; , ++ uint16_t descriptors_length :12; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++ ++/** ++ * Process a atsc_eit_section. ++ * ++ * @param section Pointer to an atsc_section_psip structure. ++ * @return atsc_eit_section pointer, or NULL on error. ++ */ ++struct atsc_eit_section *atsc_eit_section_codec(struct atsc_section_psip *section); ++ ++/** ++ * Accessor for the source_id field of an EIT. ++ * ++ * @param eit EIT pointer. ++ * @return The source_id . ++ */ ++static inline uint16_t atsc_eit_section_source_id(struct atsc_eit_section *eit) ++{ ++ return eit->head.ext_head.table_id_ext; ++} ++ ++/** ++ * Iterator for the events field in an atsc_eit_section. ++ * ++ * @param eit atsc_eit_section pointer. ++ * @param pos Variable containing a pointer to the current atsc_eit_event. ++ * @param idx Integer used to count which event we are in. ++ */ ++#define atsc_eit_section_events_for_each(eit, pos, idx) \ ++ for ((pos) = atsc_eit_section_events_first(eit), idx=0; \ ++ (pos); \ ++ (pos) = atsc_eit_section_events_next(eit, pos, ++idx)) ++ ++/** ++ * Accessor for the title_text field of an atsc_eit_event. ++ * ++ * @param event atsc_eit_event pointer. ++ * @return struct atsc_text pointer, or NULL on error. ++ */ ++static inline struct atsc_text *atsc_eit_event_name_title_text(struct atsc_eit_event *event) ++{ ++ if (event->title_length == 0) ++ return NULL; ++ ++ return (struct atsc_text*)(((uint8_t*) event) + sizeof(struct atsc_eit_event)); ++} ++ ++/** ++ * Accessor for the part2 field of an atsc_eit_event. ++ * ++ * @param event atsc_eit_event pointer. ++ * @return struct atsc_eit_event_part2 pointer. ++ */ ++static inline struct atsc_eit_event_part2 *atsc_eit_event_part2(struct atsc_eit_event *event) ++{ ++ return (struct atsc_eit_event_part2 *) ++ (((uint8_t*) event) + sizeof(struct atsc_eit_event) + event->title_length); ++} ++ ++/** ++ * Iterator for the descriptors field in a atsc_eit_section structure. ++ * ++ * @param part2 atsc_eit_event_part2 pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define atsc_eit_event_part2_descriptors_for_each(part2, pos) \ ++ for ((pos) = atsc_eit_event_part2_descriptors_first(part2); \ ++ (pos); \ ++ (pos) = atsc_eit_event_part2_descriptors_next(part2, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct atsc_eit_event * ++ atsc_eit_section_events_first(struct atsc_eit_section *eit) ++{ ++ size_t pos = sizeof(struct atsc_eit_section); ++ ++ if (eit->num_events_in_section == 0) ++ return NULL; ++ ++ return (struct atsc_eit_event*) (((uint8_t *) eit) + pos); ++} ++ ++static inline struct atsc_eit_event * ++ atsc_eit_section_events_next(struct atsc_eit_section *eit, ++ struct atsc_eit_event *pos, ++ int idx) ++{ ++ if (idx >= eit->num_events_in_section) ++ return NULL; ++ ++ struct atsc_eit_event_part2 *part2 = atsc_eit_event_part2(pos); ++ int len = sizeof(struct atsc_eit_event_part2); ++ len += part2->descriptors_length; ++ ++ return (struct atsc_eit_event *) (((uint8_t*) part2) + len); ++} ++ ++static inline struct descriptor * ++ atsc_eit_event_part2_descriptors_first(struct atsc_eit_event_part2 *part2) ++{ ++ size_t pos = sizeof(struct atsc_eit_event_part2); ++ ++ if (part2->descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor*) (((uint8_t *) part2) + pos); ++} ++ ++static inline struct descriptor * ++ atsc_eit_event_part2_descriptors_next(struct atsc_eit_event_part2 *part2, ++ struct descriptor *pos) ++{ ++ return next_descriptor((uint8_t*) part2 + sizeof(struct atsc_eit_event_part2), ++ part2->descriptors_length, ++ pos); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/ett_section.c dvb-apps/lib/libucsi/atsc/ett_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/ett_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/ett_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,42 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++ ++struct atsc_ett_section *atsc_ett_section_codec(struct atsc_section_psip *psip) ++{ ++ uint8_t * buf = (uint8_t *) psip; ++ size_t pos = sizeof(struct atsc_section_psip); ++ size_t len = section_ext_length(&(psip->ext_head)); ++ ++ if (len < sizeof(struct atsc_ett_section)) ++ return NULL; ++ ++ bswap32(buf + pos); ++ pos += 4; ++ ++ if (atsc_text_validate(buf + pos, ++ section_ext_length(&psip->ext_head) - sizeof(struct atsc_ett_section))) ++ return NULL; ++ ++ return (struct atsc_ett_section *) psip; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/ett_section.h dvb-apps/lib/libucsi/atsc/ett_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/ett_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/ett_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,91 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_ETT_SECTION_H ++#define _UCSI_ATSC_ETT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++enum atsc_etm_type { ++ ATSC_ETM_CHANNEL = 0x00, ++ ATSC_ETM_EVENT = 0x02, ++}; ++ ++/** ++ * atsc_ett_section structure. ++ */ ++struct atsc_ett_section { ++ struct atsc_section_psip head; ++ ++ EBIT3(uint32_t ETM_source_id :16; , ++ uint32_t ETM_sub_id :14; , ++ uint32_t ETM_type : 2; ); ++ /* struct atsc_text extended_text_message */ ++} __ucsi_packed; ++ ++/** ++ * Process a atsc_ett_section. ++ * ++ * @param section Pointer to an atsc_section_psip structure. ++ * @return atsc_ett_section pointer, or NULL on error. ++ */ ++struct atsc_ett_section *atsc_ett_section_codec(struct atsc_section_psip *section); ++ ++/** ++ * Accessor for the extended_text_message part of an atsc_ett_section. ++ * ++ * @param ett atsc_ett_section pointer. ++ * @return atsc_text pointer, or NULL on error. ++ */ ++static inline struct atsc_text* ++ atsc_ett_section_extended_text_message(struct atsc_ett_section *ett) ++{ ++ int pos = sizeof(struct atsc_ett_section); ++ int len = section_ext_length(&ett->head.ext_head) - sizeof(struct atsc_ett_section); ++ ++ if (len == 0) ++ return NULL; ++ ++ return (struct atsc_text*)(((uint8_t*) ett) + pos); ++} ++ ++/** ++ * Accessor for the extended_text_message part of an atsc_ett_section. ++ * ++ * @param ett atsc_ett_section pointer. ++ * @return The length. ++ */ ++static inline int ++ atsc_ett_section_extended_text_message_length(struct atsc_ett_section *ett) ++{ ++ return section_ext_length(&ett->head.ext_head) - sizeof(struct atsc_ett_section); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/extended_channel_name_descriptor.h dvb-apps/lib/libucsi/atsc/extended_channel_name_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/extended_channel_name_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/extended_channel_name_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,92 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_EXTENDED_CHANNEL_NAME_DESCRIPTOR ++#define _UCSI_ATSC_EXTENDED_CHANNEL_NAME_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++#include ++ ++/** ++ * atsc_extended_channel_name_descriptor structure. ++ */ ++struct atsc_extended_channel_name_descriptor { ++ struct descriptor d; ++ ++ /* struct atsc_text text[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an atsc_extended_channel_name_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return atsc_extended_channel_name_descriptor pointer, or NULL on error. ++ */ ++static inline struct atsc_extended_channel_name_descriptor* ++ atsc_extended_channel_name_descriptor_codec(struct descriptor* d) ++{ ++ if (atsc_text_validate(((uint8_t*) d) + sizeof(struct atsc_extended_channel_name_descriptor), ++ d->len)) ++ return NULL; ++ ++ return (struct atsc_extended_channel_name_descriptor*) d; ++} ++ ++/** ++ * Accessor for the text field of an atsc_extended_channel_name_descriptor. ++ * ++ * @param d atsc_extended_channel_name_descriptor pointer. ++ * @return Pointer to the atsc_text data, or NULL on error. ++ */ ++static inline struct atsc_text* ++ atsc_extended_channel_name_descriptor_text(struct atsc_extended_channel_name_descriptor *d) ++{ ++ uint8_t *txt = ((uint8_t*) d) + sizeof(struct atsc_extended_channel_name_descriptor); ++ ++ return (struct atsc_text*) txt; ++} ++ ++/** ++ * Accessor for the length of the text field of an atsc_extended_channel_name_descriptor. ++ * ++ * @param d atsc_extended_channel_name_descriptor pointer. ++ * @return The length in bytes. ++ */ ++static inline int ++ atsc_extended_channel_name_descriptor_text_length(struct ++ atsc_extended_channel_name_descriptor *d) ++{ ++ return d->d.len; ++} ++ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/genre_descriptor.h dvb-apps/lib/libucsi/atsc/genre_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/genre_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/genre_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,82 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_GENRE_DESCRIPTOR ++#define _UCSI_ATSC_GENRE_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * atsc_genre_descriptor structure. ++ */ ++struct atsc_genre_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint8_t reserved : 3; , ++ uint8_t attribute_count : 5; ); ++ /* uint8_t attributes[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an atsc_genre_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return atsc_genre_descriptor pointer, or NULL on error. ++ */ ++static inline struct atsc_genre_descriptor* ++ atsc_genre_descriptor_codec(struct descriptor* d) ++{ ++ struct atsc_genre_descriptor *ret = ++ (struct atsc_genre_descriptor *) d; ++ ++ if (d->len < 1) ++ return NULL; ++ ++ if (d->len != (1 + ret->attribute_count)) ++ return NULL; ++ ++ return (struct atsc_genre_descriptor*) d; ++} ++ ++/** ++ * Accessor for the attributes field of an atsc_genre_descriptor. ++ * ++ * @param d atsc_genre_descriptor pointer. ++ * @return Pointer to the attributes. ++ */ ++static inline uint8_t* ++ atsc_genre_descriptor_attributes(struct atsc_genre_descriptor *d) ++{ ++ return ((uint8_t*) d) + sizeof(struct atsc_genre_descriptor); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/Makefile dvb-apps/lib/libucsi/atsc/Makefile +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,55 @@ ++# Makefile for linuxtv.org dvb-apps/lib/libucsi/atsc ++ ++.PHONY: sub-error-atsc ++ ++sub-error-atsc: ++ $(error You can't use this makefile directly.) ++ ++ifneq ($(lib_name),) ++ ++objects += atsc/atsc_text.o \ ++ atsc/cvct_section.o \ ++ atsc/dccsct_section.o \ ++ atsc/dcct_section.o \ ++ atsc/eit_section.o \ ++ atsc/ett_section.o \ ++ atsc/mgt_section.o \ ++ atsc/rrt_section.o \ ++ atsc/stt_section.o \ ++ atsc/tvct_section.o \ ++ atsc/types.o ++ ++sub-install += atsc ++ ++else ++ ++includes = ac3_descriptor.h \ ++ caption_service_descriptor.h \ ++ component_name_descriptor.h \ ++ content_advisory_descriptor.h \ ++ cvct_section.h \ ++ dcc_arriving_request_descriptor.h \ ++ dcc_departing_request_descriptor.h \ ++ dccsct_section.h \ ++ dcct_section.h \ ++ descriptor.h \ ++ eit_section.h \ ++ ett_section.h \ ++ extended_channel_name_descriptor.h \ ++ genre_descriptor.h \ ++ mgt_section.h \ ++ rc_descriptor.h \ ++ rrt_section.h \ ++ section.h \ ++ service_location_descriptor.h \ ++ stt_section.h \ ++ stuffing_descriptor.h \ ++ time_shifted_service_descriptor.h \ ++ tvct_section.h \ ++ types.h ++ ++include ../../../Make.rules ++ ++lib_name = libucsi/atsc ++ ++endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/mgt_section.c dvb-apps/lib/libucsi/atsc/mgt_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/mgt_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/mgt_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,76 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct atsc_mgt_section *atsc_mgt_section_codec(struct atsc_section_psip *psip) ++{ ++ uint8_t * buf = (uint8_t *) psip; ++ size_t pos = sizeof(struct atsc_section_psip); ++ size_t len = section_ext_length(&(psip->ext_head)); ++ struct atsc_mgt_section *mgt = (struct atsc_mgt_section *) psip; ++ int i; ++ ++ if (len < sizeof(struct atsc_mgt_section)) ++ return NULL; ++ ++ bswap16(buf + pos); ++ pos += 2; ++ ++ // we cannot use the tables_defined value here because of the braindead ATSC spec! ++ for(i=0; i < mgt->tables_defined; i++) { ++ // we think we're still in the tables - process as normal ++ if ((pos + sizeof(struct atsc_mgt_table)) > len) ++ return NULL; ++ struct atsc_mgt_table *table = (struct atsc_mgt_table *) (buf+pos); ++ ++ bswap16(buf+pos); ++ bswap16(buf+pos+2); ++ bswap32(buf+pos+5); ++ bswap16(buf+pos+9); ++ ++ pos += sizeof(struct atsc_mgt_table); ++ if ((pos + table->table_type_descriptors_length) > len) ++ return NULL; ++ if (verify_descriptors(buf + pos, table->table_type_descriptors_length)) ++ return NULL; ++ ++ pos += table->table_type_descriptors_length; ++ } ++ ++ if ((pos + sizeof(struct atsc_mgt_section_part2)) > len) ++ return NULL; ++ struct atsc_mgt_section_part2 *part2 = (struct atsc_mgt_section_part2 *) (buf+pos); ++ ++ bswap16(buf+pos); ++ ++ pos += sizeof(struct atsc_mgt_section_part2); ++ if ((pos + part2->descriptors_length) > len) ++ return NULL; ++ if (verify_descriptors(buf + pos, part2->descriptors_length)) ++ return NULL; ++ pos += part2->descriptors_length; ++ ++ if (pos != len) ++ return NULL; ++ ++ return (struct atsc_mgt_section *) psip; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/mgt_section.h dvb-apps/lib/libucsi/atsc/mgt_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/mgt_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/mgt_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,215 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_MGT_SECTION_H ++#define _UCSI_ATSC_MGT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++enum atsc_mgt_section_table_type { ++ ATSC_MGT_TABLE_TYPE_TVCT_CURRENT = 0, ++ ATSC_MGT_TABLE_TYPE_TVCT_NEXT = 1, ++ ATSC_MGT_TABLE_TYPE_CVCT_CURRENT = 2, ++ ATSC_MGT_TABLE_TYPE_CVCT_NEXT = 3, ++ ATSC_MGT_TABLE_TYPE_CHANNEL_ETT = 4, ++ ATSC_MGT_TABLE_TYPE_DCCSCT = 5, ++}; ++ ++/** ++ * atsc_mgt_section structure. ++ */ ++struct atsc_mgt_section { ++ struct atsc_section_psip head; ++ ++ uint16_t tables_defined; ++ /* struct atsc_mgt_table tables[] */ ++ /* struct atsc_mgt_section_part2 part2 */ ++} __ucsi_packed; ++ ++struct atsc_mgt_table { ++ uint16_t table_type; ++ EBIT2(uint16_t reserved : 3; , ++ uint16_t table_type_PID :13; ); ++ EBIT2(uint8_t reserved1 : 3; , ++ uint8_t table_type_version_number : 5; ); ++ uint32_t number_bytes; ++ EBIT2(uint16_t reserved2 : 4; , ++ uint16_t table_type_descriptors_length :12; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++struct atsc_mgt_section_part2 { ++ EBIT2(uint16_t reserved : 4; , ++ uint16_t descriptors_length :12; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++static inline struct atsc_mgt_table * atsc_mgt_section_tables_first(struct atsc_mgt_section *mgt); ++static inline struct atsc_mgt_table * ++ atsc_mgt_section_tables_next(struct atsc_mgt_section *mgt, struct atsc_mgt_table *pos, int idx); ++ ++/** ++ * Process a atsc_mgt_section. ++ * ++ * @param section Pointer to an atsc_section_psip structure. ++ * @return atsc_mgt_section pointer, or NULL on error. ++ */ ++struct atsc_mgt_section *atsc_mgt_section_codec(struct atsc_section_psip *section); ++ ++/** ++ * Iterator for the tables field in an atsc_mgt_section. ++ * ++ * @param mgt atsc_mgt_section pointer. ++ * @param pos Variable containing a pointer to the current atsc_mgt_table. ++ * @param idx Integer used to count which table we in. ++ */ ++#define atsc_mgt_section_tables_for_each(mgt, pos, idx) \ ++ for ((pos) = atsc_mgt_section_tables_first(mgt), idx=0; \ ++ (pos); \ ++ (pos) = atsc_mgt_section_tables_next(mgt, pos, ++idx)) ++ ++/** ++ * Iterator for the descriptors field in a atsc_mgt_table structure. ++ * ++ * @param table atsc_mgt_table pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define atsc_mgt_table_descriptors_for_each(table, pos) \ ++ for ((pos) = atsc_mgt_table_descriptors_first(table); \ ++ (pos); \ ++ (pos) = atsc_mgt_table_descriptors_next(table, pos)) ++ ++/** ++ * Accessor for the second part of an atsc_mgt_section. ++ * ++ * @param mgt atsc_mgt_section pointer. ++ * @return atsc_mgt_section_part2 pointer. ++ */ ++static inline struct atsc_mgt_section_part2 * ++ atsc_mgt_section_part2(struct atsc_mgt_section *mgt) ++{ ++ int pos = sizeof(struct atsc_mgt_section); ++ ++ struct atsc_mgt_table *cur_table; ++ int idx; ++ atsc_mgt_section_tables_for_each(mgt, cur_table, idx) { ++ pos += sizeof(struct atsc_mgt_table); ++ pos += cur_table->table_type_descriptors_length; ++ } ++ ++ return (struct atsc_mgt_section_part2 *) (((uint8_t*) mgt) + pos); ++} ++ ++/** ++ * Iterator for the descriptors field in a atsc_mgt_section structure. ++ * ++ * @param part2 atsc_mgt_section_part2 pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define atsc_mgt_section_part2_descriptors_for_each(part2, pos) \ ++ for ((pos) = atsc_mgt_section_part2_descriptors_first(part2); \ ++ (pos); \ ++ (pos) = atsc_mgt_section_part2_descriptors_next(part2, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct atsc_mgt_table * ++ atsc_mgt_section_tables_first(struct atsc_mgt_section *mgt) ++{ ++ size_t pos = sizeof(struct atsc_mgt_section); ++ ++ if (mgt->tables_defined == 0) ++ return NULL; ++ ++ return (struct atsc_mgt_table*) (((uint8_t *) mgt) + pos); ++} ++ ++static inline struct atsc_mgt_table * ++ atsc_mgt_section_tables_next(struct atsc_mgt_section *mgt, ++ struct atsc_mgt_table *pos, ++ int idx) ++{ ++ if (idx >= mgt->tables_defined) ++ return NULL; ++ ++ return (struct atsc_mgt_table *) ++ (((uint8_t*) pos) + sizeof(struct atsc_mgt_table) + pos->table_type_descriptors_length); ++} ++ ++static inline struct descriptor * ++ atsc_mgt_table_descriptors_first(struct atsc_mgt_table *table) ++{ ++ size_t pos = sizeof(struct atsc_mgt_table); ++ ++ if (table->table_type_descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor*) (((uint8_t *) table) + pos); ++} ++ ++static inline struct descriptor * ++ atsc_mgt_table_descriptors_next(struct atsc_mgt_table *table, ++ struct descriptor *pos) ++{ ++ return next_descriptor((uint8_t*) table + sizeof(struct atsc_mgt_table), ++ table->table_type_descriptors_length, ++ pos); ++} ++ ++static inline struct descriptor * ++ atsc_mgt_section_part2_descriptors_first(struct atsc_mgt_section_part2 *part2) ++{ ++ size_t pos = sizeof(struct atsc_mgt_section_part2); ++ ++ if (part2->descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor*) (((uint8_t *) part2) + pos); ++} ++ ++static inline struct descriptor * ++ atsc_mgt_section_part2_descriptors_next(struct atsc_mgt_section_part2 *part2, ++ struct descriptor *pos) ++{ ++ return next_descriptor((uint8_t*) part2 + sizeof(struct atsc_mgt_section_part2), ++ part2->descriptors_length, ++ pos); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/rc_descriptor.h dvb-apps/lib/libucsi/atsc/rc_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/rc_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/rc_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,83 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_RC_DESCRIPTOR ++#define _UCSI_ATSC_RC_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * atsc_rc_descriptor structure. ++ */ ++struct atsc_rc_descriptor { ++ struct descriptor d; ++ ++ /* uint8_t info[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an atsc_rc_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return atsc_rc_descriptor pointer, or NULL on error. ++ */ ++static inline struct atsc_rc_descriptor* ++ atsc_rc_descriptor_codec(struct descriptor* d) ++{ ++ return (struct atsc_rc_descriptor*) d; ++} ++ ++/** ++ * Accessor for the info field of an atsc_rc_descriptor. ++ * ++ * @param d atsc_rc_descriptor pointer. ++ * @return Pointer to the atsc_text data. ++ */ ++static inline uint8_t* ++ atsc_rc_descriptor_info(struct atsc_rc_descriptor *d) ++{ ++ return ((uint8_t*) d) + sizeof(struct atsc_rc_descriptor); ++} ++ ++/** ++ * Accessor for the length of the info field of an atsc_rc_descriptor. ++ * ++ * @param d atsc_rc_descriptor pointer. ++ * @return The length ++ */ ++static inline int ++ atsc_rc_descriptor_info_length(struct atsc_rc_descriptor *d) ++{ ++ return d->d.len; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/rrt_section.c dvb-apps/lib/libucsi/atsc/rrt_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/rrt_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/rrt_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,108 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct atsc_rrt_section *atsc_rrt_section_codec(struct atsc_section_psip *psip) ++{ ++ uint8_t * buf = (uint8_t *) psip; ++ size_t pos = 0; ++ size_t len = section_ext_length(&(psip->ext_head)); ++ int idx; ++ int vidx; ++ struct atsc_rrt_section *rrt = (struct atsc_rrt_section *) psip; ++ ++ if (len < sizeof(struct atsc_rrt_section)) ++ return NULL; ++ pos += sizeof(struct atsc_rrt_section); ++ ++ if (len < (pos + rrt->rating_region_name_length)) ++ return NULL; ++ if (atsc_text_validate(buf+pos, rrt->rating_region_name_length)) ++ return NULL; ++ ++ pos += rrt->rating_region_name_length; ++ if (len < (pos + sizeof(struct atsc_rrt_section_part2))) ++ return NULL; ++ struct atsc_rrt_section_part2 *rrtpart2 = (struct atsc_rrt_section_part2 *) (buf+pos); ++ ++ pos += sizeof(struct atsc_rrt_section_part2); ++ for(idx =0; idx < rrtpart2->dimensions_defined; idx++) { ++ if (len < (pos + sizeof(struct atsc_rrt_dimension))) ++ return NULL; ++ struct atsc_rrt_dimension *dimension = (struct atsc_rrt_dimension *) (buf+pos); ++ ++ pos += sizeof(struct atsc_rrt_dimension); ++ if (len < (pos + dimension->dimension_name_length)) ++ return NULL; ++ if (atsc_text_validate(buf+pos, dimension->dimension_name_length)) ++ return NULL; ++ ++ pos += dimension->dimension_name_length; ++ if (len < (pos + sizeof(struct atsc_rrt_dimension_part2))) ++ return NULL; ++ struct atsc_rrt_dimension_part2 *dpart2 = (struct atsc_rrt_dimension_part2 *) (buf+pos); ++ ++ pos += sizeof(struct atsc_rrt_dimension_part2); ++ for(vidx =0; vidx < dpart2->values_defined; vidx++) { ++ if (len < (pos + sizeof(struct atsc_rrt_dimension_value))) ++ return NULL; ++ struct atsc_rrt_dimension_value *value = (struct atsc_rrt_dimension_value *) (buf+pos); ++ ++ pos += sizeof(struct atsc_rrt_dimension_value); ++ if (len < (pos + value->abbrev_rating_value_length)) ++ return NULL; ++ if (atsc_text_validate(buf+pos, value->abbrev_rating_value_length)) ++ return NULL; ++ ++ pos += value->abbrev_rating_value_length; ++ if (len < (pos + sizeof(struct atsc_rrt_dimension_value_part2))) ++ return NULL; ++ struct atsc_rrt_dimension_value_part2 *vpart2 = ++ (struct atsc_rrt_dimension_value_part2 *) (buf+pos); ++ ++ pos += sizeof(struct atsc_rrt_dimension_value_part2); ++ if (len < (pos + vpart2->rating_value_length)) ++ return NULL; ++ if (atsc_text_validate(buf+pos, vpart2->rating_value_length)) ++ return NULL; ++ ++ pos+= vpart2->rating_value_length; ++ } ++ } ++ ++ if (len < (pos + sizeof(struct atsc_rrt_section_part3))) ++ return NULL; ++ struct atsc_rrt_section_part3 *part3 = (struct atsc_rrt_section_part3 *) (buf+pos); ++ ++ pos += sizeof(struct atsc_rrt_section_part3); ++ if (len < (pos + part3->descriptors_length)) ++ return NULL; ++ ++ if (verify_descriptors(buf + pos, part3->descriptors_length)) ++ return NULL; ++ ++ pos += part3->descriptors_length; ++ if (pos != len) ++ return NULL; ++ ++ return (struct atsc_rrt_section *) psip; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/rrt_section.h dvb-apps/lib/libucsi/atsc/rrt_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/rrt_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/rrt_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,379 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_RRT_SECTION_H ++#define _UCSI_ATSC_RRT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * atsc_rrt_section structure. ++ */ ++struct atsc_rrt_section { ++ struct atsc_section_psip head; ++ ++ uint8_t rating_region_name_length; ++ /* struct atsc_text rating_region_name_text */ ++ /* struct atsc_rrt_section_part2 part2 */ ++} __ucsi_packed; ++ ++struct atsc_rrt_section_part2 { ++ uint8_t dimensions_defined; ++ /* struct atsc_rrt_dimension dimensions[] */ ++ /* struct atsc_rrt_section_part3 part3 */ ++} __ucsi_packed; ++ ++struct atsc_rrt_dimension { ++ uint8_t dimension_name_length; ++ /* struct atsc_text dimension_name_text */ ++ /* struct atsc_rrt_dimension_part2 part2 */ ++} __ucsi_packed; ++ ++struct atsc_rrt_dimension_part2 { ++ EBIT3(uint8_t reserved : 3; , ++ uint8_t graduated_scale : 1; , ++ uint8_t values_defined : 4; ); ++ /* struct atsc_rrt_dimension_value values[] */ ++} __ucsi_packed; ++ ++struct atsc_rrt_dimension_value { ++ uint8_t abbrev_rating_value_length; ++ /* struct atsc_text abbrev_rating_value_text */ ++ /* struct atsc_rrt_dimension_value_part2 */ ++} __ucsi_packed; ++ ++struct atsc_rrt_dimension_value_part2 { ++ uint8_t rating_value_length; ++ /* struct atsc_text rating_value_text */ ++} __ucsi_packed; ++ ++struct atsc_rrt_section_part3 { ++ EBIT2(uint16_t reserved : 6; , ++ uint16_t descriptors_length :10; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++ ++static inline struct atsc_rrt_dimension * ++ atsc_rrt_section_dimensions_first(struct atsc_rrt_section_part2 *part2); ++static inline struct atsc_rrt_dimension * ++ atsc_rrt_section_dimensions_next(struct atsc_rrt_section_part2 *part2, ++ struct atsc_rrt_dimension *pos, ++ int idx); ++static inline struct atsc_rrt_dimension_value * ++ atsc_rrt_dimension_part2_values_first(struct atsc_rrt_dimension_part2 *part2); ++static inline struct atsc_rrt_dimension_value * ++ atsc_rrt_dimension_part2_values_next(struct atsc_rrt_dimension_part2 *part2, ++ struct atsc_rrt_dimension_value *pos, ++ int idx); ++ ++/** ++ * Process a atsc_rrt_section. ++ * ++ * @param section Pointer to anj atsc_section_psip structure. ++ * @return atsc_rrt_section pointer, or NULL on error. ++ */ ++struct atsc_rrt_section *atsc_rrt_section_codec(struct atsc_section_psip *section); ++ ++/** ++ * Accessor for the rating_region field of an RRT. ++ * ++ * @param rrt RRT pointer. ++ * @return The transport_stream_id. ++ */ ++static inline uint8_t atsc_rrt_section_rating_region(struct atsc_rrt_section *rrt) ++{ ++ return rrt->head.ext_head.table_id_ext & 0xff; ++} ++ ++/** ++ * Accessor for the rating_region_name_text field of an RRT. ++ * ++ * @param rrt RRT pointer. ++ * @return struct atsc_text pointer, or NULL. ++ */ ++static inline struct atsc_text *atsc_rrt_section_rating_region_name_text(struct atsc_rrt_section *rrt) ++{ ++ if (rrt->rating_region_name_length == 0) ++ return NULL; ++ ++ return (struct atsc_text*)(((uint8_t*) rrt) + sizeof(struct atsc_rrt_section)); ++} ++ ++/** ++ * Accessor for the part2 field of an RRT. ++ * ++ * @param rrt RRT pointer. ++ * @return struct atsc_rrt_section_part2 pointer. ++ */ ++static inline struct atsc_rrt_section_part2 *atsc_rrt_section_part2(struct atsc_rrt_section *rrt) ++{ ++ return (struct atsc_rrt_section_part2 *) ++ (((uint8_t*) rrt) + sizeof(struct atsc_rrt_section) + ++ rrt->rating_region_name_length); ++} ++ ++/** ++ * Iterator for the dimensions field in an atsc_rrt_section_part2. ++ * ++ * @param rrt atsc_rrt_section pointer. ++ * @param pos Variable containing a pointer to the current atsc_rrt_dimension. ++ * @param idx Integer used to count which dimension we are in. ++ */ ++#define atsc_rrt_section_dimensions_for_each(rrt, pos, idx) \ ++ for ((pos) = atsc_rrt_section_dimensions_first(rrt), idx=0; \ ++ (pos); \ ++ (pos) = atsc_rrt_section_dimensions_next(rrt, pos, ++idx)) ++ ++/** ++ * Accessor for the dimension_name_text field of an atsc_rrt_dimension. ++ * ++ * @param dimension atsc_rrt_dimension pointer. ++ * @return struct atsc_text pointer, or NULL on error. ++ */ ++static inline struct atsc_text *atsc_rrt_dimension_name_text(struct atsc_rrt_dimension *dimension) ++{ ++ if (dimension->dimension_name_length == 0) ++ return NULL; ++ ++ return (struct atsc_text*)(((uint8_t*) dimension) + sizeof(struct atsc_rrt_dimension)); ++} ++ ++/** ++ * Accessor for the part2 field of an atsc_rrt_dimension. ++ * ++ * @param dimension atsc_rrt_dimension pointer. ++ * @return struct atsc_rrt_dimension_part2 pointer. ++ */ ++static inline struct atsc_rrt_dimension_part2 *atsc_rrt_dimension_part2(struct atsc_rrt_dimension *dimension) ++{ ++ return (struct atsc_rrt_dimension_part2 *) ++ (((uint8_t*) dimension) + ++ sizeof(struct atsc_rrt_dimension) + ++ dimension->dimension_name_length); ++} ++ ++/** ++ * Iterator for the values field in a atsc_rrt_dimension_part2 structure. ++ * ++ * @param part2 atsc_rrt_dimension_part2 pointer. ++ * @param pos Variable containing a pointer to the current value. ++ * @param idx Integer used to count which value we are in ++ */ ++#define atsc_rrt_dimension_part2_values_for_each(part2, pos, idx) \ ++ for ((pos) = atsc_rrt_dimension_part2_values_first(part2), idx=0; \ ++ (pos); \ ++ (pos) = atsc_rrt_dimension_part2_values_next(part2, pos, ++idx)) ++ ++/** ++ * Accessor for the dimension_name_text field of an atsc_rrt_dimension. ++ * ++ * @param dimension atsc_rrt_dimension pointer. ++ * @return struct atsc_text pointer. ++ */ ++static inline struct atsc_text * ++ atsc_rrt_dimension_value_abbrev_rating_value_text(struct atsc_rrt_dimension_value *value) ++{ ++ if (value->abbrev_rating_value_length == 0) ++ return NULL; ++ ++ return (struct atsc_text*)(((uint8_t*) value) + sizeof(struct atsc_rrt_dimension_value)); ++} ++ ++/** ++ * Accessor for the part2 field of an atsc_rrt_dimension_value. ++ * ++ * @param value atsc_rrt_dimension_value pointer. ++ * @return struct atsc_rrt_dimension_value_part2 pointer. ++ */ ++static inline struct atsc_rrt_dimension_value_part2 *atsc_rrt_dimension_value_part2(struct atsc_rrt_dimension_value *value) ++{ ++ return (struct atsc_rrt_dimension_value_part2 *) ++ (((uint8_t*) value) + ++ sizeof(struct atsc_rrt_dimension_value) + ++ value->abbrev_rating_value_length); ++} ++ ++/** ++ * Accessor for the rating_value_text field of an atsc_rrt_dimension_value_part2. ++ * ++ * @param part2 atsc_rrt_dimension_value_part2 pointer. ++ * @return struct atsc_text pointer. ++ */ ++static inline struct atsc_text *atsc_rrt_dimension_value_part2_rating_value_text(struct atsc_rrt_dimension_value_part2 *part2) ++{ ++ if (part2->rating_value_length == 0) ++ return NULL; ++ ++ return (struct atsc_text*)(((uint8_t*) part2) + sizeof(struct atsc_rrt_dimension_value_part2)); ++} ++ ++/** ++ * Accessor for the third part of an atsc_rrt_section. ++ * ++ * @param part2 atsc_rrt_section_part2 pointer. ++ * @return atsc_rrt_section_part3 pointer. ++ */ ++static inline struct atsc_rrt_section_part3 * ++ atsc_rrt_section_part3(struct atsc_rrt_section_part2 *part2) ++{ ++ int pos = sizeof(struct atsc_rrt_section_part2); ++ ++ struct atsc_rrt_dimension *cur_dimension; ++ int idx; ++ atsc_rrt_section_dimensions_for_each(part2, cur_dimension, idx) { ++ pos += sizeof(struct atsc_rrt_dimension); ++ pos += cur_dimension->dimension_name_length; ++ pos += sizeof(struct atsc_rrt_dimension_part2); ++ ++ // now we need to iterate over the values. yuck ++ struct atsc_rrt_dimension_part2 *dpart2 = atsc_rrt_dimension_part2(cur_dimension); ++ struct atsc_rrt_dimension_value *cur_value; ++ int vidx; ++ atsc_rrt_dimension_part2_values_for_each(dpart2, cur_value, vidx) { ++ pos += sizeof(struct atsc_rrt_dimension_value); ++ pos += cur_value->abbrev_rating_value_length; ++ ++ struct atsc_rrt_dimension_value_part2 *vpart2 = atsc_rrt_dimension_value_part2(cur_value); ++ pos += sizeof(struct atsc_rrt_dimension_value_part2); ++ pos += vpart2->rating_value_length; ++ } ++ } ++ ++ return (struct atsc_rrt_section_part3 *) (((uint8_t*) part2) + pos); ++} ++ ++/** ++ * Iterator for the descriptors field in a atsc_rrt_section structure. ++ * ++ * @param part3 atsc_rrt_section_part3 pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define atsc_rrt_section_part3_descriptors_for_each(part3, pos) \ ++ for ((pos) = atsc_rrt_section_part3_descriptors_first(part3); \ ++ (pos); \ ++ (pos) = atsc_rrt_section_part3_descriptors_next(part3, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct atsc_rrt_dimension * ++ atsc_rrt_section_dimensions_first(struct atsc_rrt_section_part2 *part2) ++{ ++ size_t pos = sizeof(struct atsc_rrt_section_part2); ++ ++ if (part2->dimensions_defined == 0) ++ return NULL; ++ ++ return (struct atsc_rrt_dimension*) (((uint8_t *) part2) + pos); ++} ++ ++static inline struct atsc_rrt_dimension * ++ atsc_rrt_section_dimensions_next(struct atsc_rrt_section_part2 *part2, ++ struct atsc_rrt_dimension *pos, ++ int idx) ++{ ++ if (idx >= part2->dimensions_defined) ++ return NULL; ++ ++ struct atsc_rrt_dimension_part2 *dpart2 = atsc_rrt_dimension_part2(pos); ++ int len = sizeof(struct atsc_rrt_dimension_part2); ++ ++ // now we need to iterate over the values. yuck ++ struct atsc_rrt_dimension_value *cur_value; ++ int vidx; ++ atsc_rrt_dimension_part2_values_for_each(dpart2, cur_value, vidx) { ++ len += sizeof(struct atsc_rrt_dimension_value); ++ len += cur_value->abbrev_rating_value_length; ++ ++ struct atsc_rrt_dimension_value_part2 *vpart2 = atsc_rrt_dimension_value_part2(cur_value); ++ len += sizeof(struct atsc_rrt_dimension_value_part2); ++ len += vpart2->rating_value_length; ++ } ++ ++ return (struct atsc_rrt_dimension *) (((uint8_t*) dpart2) + len); ++} ++ ++static inline struct atsc_rrt_dimension_value * ++ atsc_rrt_dimension_part2_values_first(struct atsc_rrt_dimension_part2 *part2) ++{ ++ size_t pos = sizeof(struct atsc_rrt_dimension_part2); ++ ++ if (part2->values_defined == 0) ++ return NULL; ++ ++ return (struct atsc_rrt_dimension_value*) (((uint8_t *) part2) + pos); ++} ++ ++static inline struct atsc_rrt_dimension_value * ++ atsc_rrt_dimension_part2_values_next(struct atsc_rrt_dimension_part2 *part2, ++ struct atsc_rrt_dimension_value *pos, ++ int idx) ++{ ++ if (idx >= part2->values_defined) ++ return NULL; ++ ++ struct atsc_rrt_dimension_value_part2 *vpart2 = atsc_rrt_dimension_value_part2(pos); ++ int len = sizeof(struct atsc_rrt_dimension_value_part2); ++ len += vpart2->rating_value_length; ++ ++ return (struct atsc_rrt_dimension_value *) (((uint8_t*) vpart2) + len); ++} ++ ++static inline struct descriptor * ++ atsc_rrt_section_part3_descriptors_first(struct atsc_rrt_section_part3 *part3) ++{ ++ size_t pos = sizeof(struct atsc_rrt_section_part3); ++ ++ if (part3->descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor*) (((uint8_t *) part3) + pos); ++} ++ ++static inline struct descriptor * ++ atsc_rrt_section_part3_descriptors_next(struct atsc_rrt_section_part3 *part3, ++ struct descriptor *pos) ++{ ++ return next_descriptor((uint8_t*) part3 + sizeof(struct atsc_rrt_section_part3), ++ part3->descriptors_length, ++ pos); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/section.h dvb-apps/lib/libucsi/atsc/section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,84 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#ifndef _UCSI_ATSC_SECTION_H ++#define _UCSI_ATSC_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#define ATSC_BASE_PID 0x1ffb ++ ++/** ++ * Enumeration of ATSC section tags. ++ */ ++enum atsc_section_tag { ++ stag_atsc_master_guide = 0xc7, ++ stag_atsc_terrestrial_virtual_channel = 0xc8, ++ stag_atsc_cable_virtual_channel = 0xc9, ++ stag_atsc_rating_region = 0xca, ++ stag_atsc_event_information = 0xcb, ++ stag_atsc_extended_text = 0xcc, ++ stag_atsc_system_time = 0xcd, ++}; ++ ++/** ++ * ATSC specific PSIP section structure. ++ */ ++struct atsc_section_psip { ++ struct section_ext ext_head; ++ uint8_t protocol_version; ++} __ucsi_packed; ++ ++/** ++ * Decode a PSIP section structure. ++ * ++ * @param section_ext Pointer to the processed section_ext structure. ++ * @return Pointer to the parsed section_psip structure, or NULL if invalid. ++ */ ++static inline struct atsc_section_psip *atsc_section_psip_decode(struct section_ext *section_ext) ++{ ++ size_t len = section_ext_length(section_ext); ++ if (len < sizeof(struct atsc_section_psip)) { ++ return NULL; ++ } ++ ++ return (struct atsc_section_psip *) section_ext; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/service_location_descriptor.h dvb-apps/lib/libucsi/atsc/service_location_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/service_location_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/service_location_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,141 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_SERVICE_LOCATION_DESCRIPTOR ++#define _UCSI_ATSC_SERVICE_LOCATION_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++enum atsc_stream_types { ++ ATSC_STREAM_TYPE_VIDEO = 0x02, ++ ATSC_STREAM_TYPE_AUDIO = 0x81, ++}; ++ ++/** ++ * atsc_service_location_descriptor structure. ++ */ ++struct atsc_service_location_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint16_t reserved : 3; , ++ uint16_t PCR_PID :13; ); ++ uint8_t number_elements; ++ /* struct atsc_service_location_element elements[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the elements field of an atsc_service_location_descriptor. ++ */ ++struct atsc_caption_service_location_element { ++ uint8_t stream_type; ++ EBIT2(uint16_t reserved : 3; , ++ uint16_t elementary_PID :13; ); ++ iso639lang_t language_code; ++} __ucsi_packed; ++ ++/** ++ * Process an atsc_service_location_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return atsc_service_location_descriptor pointer, or NULL on error. ++ */ ++static inline struct atsc_service_location_descriptor* ++ atsc_service_location_descriptor_codec(struct descriptor* d) ++{ ++ struct atsc_service_location_descriptor *ret = ++ (struct atsc_service_location_descriptor *) d; ++ uint8_t *buf = (uint8_t*) d + 2; ++ int pos = 0; ++ int idx; ++ ++ if (d->len < 3) ++ return NULL; ++ bswap16(buf + pos); ++ pos+=3; ++ ++ for(idx = 0; idx < ret->number_elements; idx++) { ++ if (d->len < (pos + sizeof(struct atsc_caption_service_entry))) ++ return NULL; ++ ++ bswap16(buf+pos+1); ++ ++ pos += sizeof(struct atsc_caption_service_entry); ++ } ++ ++ return (struct atsc_service_location_descriptor*) d; ++} ++ ++/** ++ * Iterator for elements field of a atsc_service_location_descriptor. ++ * ++ * @param d atsc_service_location_descriptor pointer. ++ * @param pos Variable holding a pointer to the current atsc_service_location_element. ++ * @param idx Integer used to count which dimension we are in. ++ */ ++#define atsc_service_location_descriptor_elements_for_each(d, pos, idx) \ ++ for ((pos) = atsc_service_location_descriptor_elements_first(d), idx=0; \ ++ (pos); \ ++ (pos) = atsc_service_location_descriptor_elements_next(d, pos, ++idx)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct atsc_caption_service_location_element* ++ atsc_service_location_descriptor_elements_first(struct atsc_service_location_descriptor *d) ++{ ++ if (d->number_elements == 0) ++ return NULL; ++ ++ return (struct atsc_caption_service_location_element *) ++ ((uint8_t*) d + sizeof(struct atsc_service_location_descriptor)); ++} ++ ++static inline struct atsc_caption_service_location_element* ++ atsc_service_location_descriptor_elements_next(struct atsc_service_location_descriptor *d, ++ struct atsc_caption_service_location_element *pos, ++ int idx) ++{ ++ uint8_t *next = (uint8_t *) pos + sizeof(struct atsc_caption_service_location_element); ++ ++ if (idx >= d->number_elements) ++ return NULL; ++ return (struct atsc_caption_service_location_element *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/stt_section.c dvb-apps/lib/libucsi/atsc/stt_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/stt_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/stt_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,42 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct atsc_stt_section *atsc_stt_section_codec(struct atsc_section_psip *psip) ++{ ++ uint8_t *buf = (uint8_t *) psip; ++ size_t pos = sizeof(struct atsc_section_psip); ++ size_t len = section_ext_length(&(psip->ext_head)); ++ ++ if (len < sizeof(struct atsc_stt_section)) ++ return NULL; ++ ++ bswap32(buf + pos); ++ pos += 5; ++ bswap16(buf + pos); ++ pos += 2; ++ ++ if (verify_descriptors(buf + pos, len - sizeof(struct atsc_stt_section))) ++ return NULL; ++ ++ return (struct atsc_stt_section *) psip; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/stt_section.h dvb-apps/lib/libucsi/atsc/stt_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/stt_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/stt_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,105 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_STT_SECTION_H ++#define _UCSI_ATSC_STT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * atsc_stt_section structure. ++ */ ++struct atsc_stt_section { ++ struct atsc_section_psip head; ++ ++ atsctime_t system_time; ++ uint8_t gps_utc_offset; ++ EBIT4(uint16_t DS_status : 1; , ++ uint16_t reserved : 2; , ++ uint16_t DS_day_of_month : 5; , ++ uint16_t DS_hour : 8; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a atsc_stt_section. ++ * ++ * @param section Pointer to an atsc_section_psip structure. ++ * @return atsc_stt_section pointer, or NULL on error. ++ */ ++struct atsc_stt_section *atsc_stt_section_codec(struct atsc_section_psip *section); ++ ++/** ++ * Iterator for the services field in a atsc_stt_section. ++ * ++ * @param stt atsc_stt_section pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define atsc_stt_section_descriptors_for_each(stt, pos) \ ++ for ((pos) = atsc_stt_section_descriptors_first(stt); \ ++ (pos); \ ++ (pos) = atsc_stt_section_descriptors_next(stt, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct descriptor * ++ atsc_stt_section_descriptors_first(struct atsc_stt_section *stt) ++{ ++ size_t pos = sizeof(struct atsc_stt_section); ++ ++ if (pos >= section_ext_length(&stt->head.ext_head)) ++ return NULL; ++ ++ return (struct descriptor*) ((uint8_t *) stt + pos); ++} ++ ++static inline struct descriptor * ++ atsc_stt_section_descriptors_next(struct atsc_stt_section *stt, ++ struct descriptor *pos) ++{ ++ int len = section_ext_length(&stt->head.ext_head); ++ len -= sizeof(struct atsc_stt_section); ++ ++ return next_descriptor((uint8_t*) stt + sizeof(struct atsc_stt_section), ++ len, ++ pos); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/stuffing_descriptor.h dvb-apps/lib/libucsi/atsc/stuffing_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/stuffing_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/stuffing_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,82 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_atsc@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_STUFFING_DESCRIPTOR ++#define _UCSI_ATSC_STUFFING_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * atsc_stuffing_descriptor. ++ */ ++struct atsc_stuffing_descriptor { ++ struct descriptor d; ++ ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a atsc_stuffing_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return atsc_stuffing_descriptor pointer, or NULL on error. ++ */ ++static inline struct atsc_stuffing_descriptor* ++ atsc_stuffing_descriptor_codec(struct descriptor* d) ++{ ++ return (struct atsc_stuffing_descriptor*) d; ++} ++ ++/** ++ * Retrieve a pointer to the data field of a atsc_stuffing_descriptor. ++ * ++ * @param d atsc_stuffing_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ atsc_stuffing_descriptor_data(struct atsc_stuffing_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct atsc_stuffing_descriptor); ++} ++ ++/** ++ * Calculate length of the data field of a atsc_stuffing_descriptor. ++ * ++ * @param d atsc_stuffing_descriptor pointer. ++ * @return The length in bytes. ++ */ ++static inline int ++ atsc_stuffing_descriptor_data_length(struct atsc_stuffing_descriptor *d) ++{ ++ return d->d.len; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/time_shifted_service_descriptor.h dvb-apps/lib/libucsi/atsc/time_shifted_service_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/time_shifted_service_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/time_shifted_service_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,136 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_TIME_SHIFTED_SERVICE_DESCRIPTOR ++#define _UCSI_ATSC_TIME_SHIFTED_SERVICE_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * atsc_time_shifted_service_descriptor structure. ++ */ ++struct atsc_time_shifted_service_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint8_t reserved : 3; , ++ uint8_t number_of_services : 5; ); ++ /* struct atsc_time_shifted_service services[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the services field of an atsc_time_shifted_service_descriptor. ++ */ ++struct atsc_time_shifted_service { ++ EBIT2(uint16_t reserved : 6; , ++ uint16_t time_shift :10; ); ++ EBIT3(uint32_t reserved2 : 4; , ++ uint32_t major_channel_number :10; , ++ uint32_t minor_channel_number :10; ); ++} __ucsi_packed; ++ ++/** ++ * Process an atsc_time_shifted_service_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return atsc_time_shifted_service_descriptor pointer, or NULL on error. ++ */ ++static inline struct atsc_time_shifted_service_descriptor* ++ atsc_time_shifted_service_descriptor_codec(struct descriptor* d) ++{ ++ struct atsc_time_shifted_service_descriptor *ret = ++ (struct atsc_time_shifted_service_descriptor *) d; ++ uint8_t *buf = (uint8_t*) d + 2; ++ int pos = 0; ++ int idx; ++ ++ if (d->len < 1) ++ return NULL; ++ pos++; ++ ++ for(idx = 0; idx < ret->number_of_services; idx++) { ++ if (d->len < (pos + sizeof(struct atsc_time_shifted_service))) ++ return NULL; ++ ++ bswap16(buf+pos); ++ bswap24(buf+pos+2); ++ ++ pos += sizeof(struct atsc_time_shifted_service); ++ } ++ ++ return (struct atsc_time_shifted_service_descriptor*) d; ++} ++ ++/** ++ * Iterator for services field of a atsc_time_shifted_service_descriptor. ++ * ++ * @param d atsc_time_shifted_service_descriptor pointer. ++ * @param pos Variable holding a pointer to the current atsc_service_location_element. ++ * @param idx Integer used to count which service we are in. ++ */ ++#define atsc_time_shifted_service_descriptor_services_for_each(d, pos, idx) \ ++ for ((pos) = atsc_time_shifted_service_descriptor_services_first(d), idx=0; \ ++ (pos); \ ++ (pos) = atsc_time_shifted_service_descriptor_services_next(d, pos, ++idx)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct atsc_time_shifted_service* ++ atsc_time_shifted_service_descriptor_services_first(struct atsc_time_shifted_service_descriptor *d) ++{ ++ if (d->number_of_services == 0) ++ return NULL; ++ ++ return (struct atsc_time_shifted_service *) ++ ((uint8_t*) d + sizeof(struct atsc_time_shifted_service_descriptor)); ++} ++ ++static inline struct atsc_time_shifted_service* ++ atsc_time_shifted_service_descriptor_services_next(struct atsc_time_shifted_service_descriptor *d, ++ struct atsc_time_shifted_service *pos, ++ int idx) ++{ ++ uint8_t *next = (uint8_t *) pos + sizeof(struct atsc_time_shifted_service); ++ ++ if (idx >= d->number_of_services) ++ return NULL; ++ return (struct atsc_time_shifted_service *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/tvct_section.c dvb-apps/lib/libucsi/atsc/tvct_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/tvct_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/tvct_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,81 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct atsc_tvct_section *atsc_tvct_section_codec(struct atsc_section_psip *psip) ++{ ++ uint8_t * buf = (uint8_t *) psip; ++ size_t pos = sizeof(struct atsc_section_psip); ++ size_t len = section_ext_length(&(psip->ext_head)); ++ int idx; ++ struct atsc_tvct_section *tvct = (struct atsc_tvct_section *) psip; ++ ++ if (len < sizeof(struct atsc_tvct_section)) ++ return NULL; ++ ++ pos++; ++ ++ for(idx =0; idx < tvct->num_channels_in_section; idx++) { ++ ++ if ((pos + sizeof(struct atsc_tvct_channel)) > len) ++ return NULL; ++ struct atsc_tvct_channel *channel = (struct atsc_tvct_channel *) (buf+pos); ++ ++ pos += 7*2; ++ ++ bswap32(buf+pos); ++ bswap32(buf+pos+4); ++ bswap16(buf+pos+8); ++ bswap16(buf+pos+10); ++ bswap16(buf+pos+12); ++ bswap16(buf+pos+14); ++ bswap16(buf+pos+16); ++ pos+=18; ++ ++ if ((pos + channel->descriptors_length) > len) ++ return NULL; ++ if (verify_descriptors(buf + pos, channel->descriptors_length)) ++ return NULL; ++ ++ pos += channel->descriptors_length; ++ } ++ ++ if ((pos + sizeof(struct atsc_tvct_section_part2)) > len) ++ return NULL; ++ struct atsc_tvct_section_part2 *part2 = (struct atsc_tvct_section_part2 *) (buf+pos); ++ ++ bswap16(buf+pos); ++ pos+=2; ++ ++ if ((pos + part2->descriptors_length) > len) ++ return NULL; ++ ++ if (verify_descriptors(buf + pos, part2->descriptors_length)) ++ return NULL; ++ ++ pos += part2->descriptors_length; ++ ++ if (pos != len) ++ return NULL; ++ ++ return (struct atsc_tvct_section *) psip; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/tvct_section.h dvb-apps/lib/libucsi/atsc/tvct_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/tvct_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/tvct_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,227 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_TVCT_SECTION_H ++#define _UCSI_ATSC_TVCT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * atsc_tvct_section structure. ++ */ ++struct atsc_tvct_section { ++ struct atsc_section_psip head; ++ ++ uint8_t num_channels_in_section; ++ /* struct atsc_tvct_channel channels[] */ ++ /* struct atsc_tvct_channel_part2 part2 */ ++} __ucsi_packed; ++ ++struct atsc_tvct_channel { ++ uint16_t short_name[7]; // UTF-16 network ordered ++ EBIT4(uint32_t reserved : 4; , ++ uint32_t major_channel_number :10; , ++ uint32_t minor_channel_number :10; , ++ uint32_t modulation_mode : 8; ); ++ uint32_t carrier_frequency; ++ uint16_t channel_TSID; ++ uint16_t program_number; ++ EBIT7(uint16_t ETM_location : 2; , ++ uint16_t access_controlled : 1; , ++ uint16_t hidden : 1; , ++ uint16_t reserved1 : 2; , ++ uint16_t hide_guide : 1; , ++ uint16_t reserved2 : 3; , ++ uint16_t service_type : 6; ); ++ uint16_t source_id; ++ EBIT2(uint16_t reserved3 : 6; , ++ uint16_t descriptors_length :10; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++struct atsc_tvct_section_part2 { ++ EBIT2(uint16_t reserved : 6; , ++ uint16_t descriptors_length :10; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++static inline struct atsc_tvct_channel *atsc_tvct_section_channels_first(struct atsc_tvct_section *tvct); ++static inline struct atsc_tvct_channel * ++ atsc_tvct_section_channels_next(struct atsc_tvct_section *tvct, struct atsc_tvct_channel *pos, int idx); ++ ++/** ++ * Process a atsc_tvct_section. ++ * ++ * @param section Pointer to an atsc_section_psip structure. ++ * @return atsc_tvct_section pointer, or NULL on error. ++ */ ++struct atsc_tvct_section *atsc_tvct_section_codec(struct atsc_section_psip *section); ++ ++/** ++ * Accessor for the transport_stream_id field of a TVCT. ++ * ++ * @param tvct TVCT pointer. ++ * @return The transport_stream_id. ++ */ ++static inline uint16_t atsc_tvct_section_transport_stream_id(struct atsc_tvct_section *tvct) ++{ ++ return tvct->head.ext_head.table_id_ext; ++} ++ ++/** ++ * Iterator for the channels field in an atsc_tvct_section. ++ * ++ * @param mgt atsc_tvct_section pointer. ++ * @param pos Variable containing a pointer to the current atsc_tvct_channel. ++ * @param idx Integer used to count which channel we in. ++ */ ++#define atsc_tvct_section_channels_for_each(mgt, pos, idx) \ ++ for ((pos) = atsc_tvct_section_channels_first(mgt), idx=0; \ ++ (pos); \ ++ (pos) = atsc_tvct_section_channels_next(mgt, pos, ++idx)) ++ ++/** ++ * Iterator for the descriptors field in a atsc_tvct_channel structure. ++ * ++ * @param channel atsc_tvct_channel pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define atsc_tvct_channel_descriptors_for_each(channel, pos) \ ++ for ((pos) = atsc_tvct_channel_descriptors_first(channel); \ ++ (pos); \ ++ (pos) = atsc_tvct_channel_descriptors_next(channel, pos)) ++ ++/** ++ * Accessor for the second part of an atsc_tvct_section. ++ * ++ * @param mgt atsc_tvct_section pointer. ++ * @return atsc_tvct_section_part2 pointer. ++ */ ++static inline struct atsc_tvct_section_part2 * ++ atsc_tvct_section_part2(struct atsc_tvct_section *mgt) ++{ ++ int pos = sizeof(struct atsc_tvct_section); ++ ++ struct atsc_tvct_channel *cur_channel; ++ int idx; ++ atsc_tvct_section_channels_for_each(mgt, cur_channel, idx) { ++ pos += sizeof(struct atsc_tvct_channel); ++ pos += cur_channel->descriptors_length; ++ } ++ ++ return (struct atsc_tvct_section_part2 *) (((uint8_t*) mgt) + pos); ++} ++ ++/** ++ * Iterator for the descriptors field in a atsc_tvct_section structure. ++ * ++ * @param part2 atsc_tvct_section_part2 pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define atsc_tvct_section_part2_descriptors_for_each(part2, pos) \ ++ for ((pos) = atsc_tvct_section_part2_descriptors_first(part2); \ ++ (pos); \ ++ (pos) = atsc_tvct_section_part2_descriptors_next(part2, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct atsc_tvct_channel * ++ atsc_tvct_section_channels_first(struct atsc_tvct_section *tvct) ++{ ++ size_t pos = sizeof(struct atsc_tvct_section); ++ ++ if (tvct->num_channels_in_section == 0) ++ return NULL; ++ ++ return (struct atsc_tvct_channel*) (((uint8_t *) tvct) + pos); ++} ++ ++static inline struct atsc_tvct_channel * ++ atsc_tvct_section_channels_next(struct atsc_tvct_section *tvct, ++ struct atsc_tvct_channel *pos, ++ int idx) ++{ ++ if (idx >= tvct->num_channels_in_section) ++ return NULL; ++ ++ return (struct atsc_tvct_channel *) ++ (((uint8_t*) pos) + sizeof(struct atsc_tvct_channel) + pos->descriptors_length); ++} ++ ++static inline struct descriptor * ++ atsc_tvct_channel_descriptors_first(struct atsc_tvct_channel *channel) ++{ ++ size_t pos = sizeof(struct atsc_tvct_channel); ++ ++ if (channel->descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor*) (((uint8_t *) channel) + pos); ++} ++ ++static inline struct descriptor * ++ atsc_tvct_channel_descriptors_next(struct atsc_tvct_channel *channel, ++ struct descriptor *pos) ++{ ++ return next_descriptor((uint8_t*) channel + sizeof(struct atsc_tvct_channel), ++ channel->descriptors_length, ++ pos); ++} ++ ++static inline struct descriptor * ++ atsc_tvct_section_part2_descriptors_first(struct atsc_tvct_section_part2 *part2) ++{ ++ size_t pos = sizeof(struct atsc_tvct_section_part2); ++ ++ if (part2->descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor*) (((uint8_t *) part2) + pos); ++} ++ ++static inline struct descriptor * ++ atsc_tvct_section_part2_descriptors_next(struct atsc_tvct_section_part2 *part2, ++ struct descriptor *pos) ++{ ++ return next_descriptor((uint8_t*) part2 + sizeof(struct atsc_tvct_section_part2), ++ part2->descriptors_length, ++ pos); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/types.c dvb-apps/lib/libucsi/atsc/types.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/types.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/types.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,71 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include "libucsi/atsc/types.h" ++ ++/* GPS epoch == unix time_t at 06/Jan/1980 */ ++#define GPS_EPOCH 315964800 ++ ++ ++int atsc_text_validate(uint8_t *buf, int len) ++{ ++ int i; ++ int j; ++ int number_strings; ++ int number_segments; ++ int number_bytes; ++ int pos = 0; ++ ++ if (len == 0) ++ return 0; ++ number_strings = buf[pos]; ++ pos++; ++ ++ for(i=0; i< number_strings; i++) { ++ if (len < (pos+4)) ++ return -1; ++ number_segments = buf[pos+3]; ++ pos+=4; ++ ++ for(j=0; j < number_segments; j++) { ++ if (len < (pos+3)) ++ return -1; ++ number_bytes = buf[pos+2]; ++ pos+=3; ++ ++ if (len < (pos + number_bytes)) ++ return -1; ++ pos += number_bytes; ++ } ++ } ++ ++ return 0; ++} ++ ++time_t atsctime_to_unixtime(atsctime_t atsc) ++{ ++ return atsc + GPS_EPOCH; ++} ++ ++atsctime_t unixtime_to_atsctime(time_t t) ++{ ++ return t - GPS_EPOCH; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/types.h dvb-apps/lib/libucsi/atsc/types.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/atsc/types.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/atsc/types.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,227 @@ ++ /* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_ATSC_TYPES_H ++#define _UCSI_ATSC_TYPES_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++enum atsc_vct_modulation { ++ ATSC_VCT_MODULATION_ANALOG = 0x01, ++ ATSC_VCT_MODULATION_SCTE_MODE1 = 0x02, ++ ATSC_VCT_MODULATION_SCTE_MODE2 = 0x03, ++ ATSC_VCT_MODULATION_8VSB = 0x04, ++ ATSC_VCT_MODULATION_16VSB = 0x05, ++}; ++ ++enum atsc_vct_service_type { ++ ATSC_VCT_SERVICE_TYPE_ANALOG = 0x01, ++ ATSC_VCT_SERVICE_TYPE_TV = 0x02, ++ ATSC_VCT_SERVICE_TYPE_AUDIO = 0x03, ++ ATSC_VCT_SERVICE_TYPE_DATA = 0x04, ++}; ++ ++enum atsc_etm_location { ++ ATSC_VCT_ETM_NONE = 0x00, ++ ATSC_VCT_ETM_IN_THIS_PTC = 0x01, ++ ATSC_VCT_ETM_IN_CHANNEL_TSID = 0x02, ++}; ++ ++enum atsc_text_compress_type { ++ ATSC_TEXT_COMPRESS_NONE = 0x00, ++ ATSC_TEXT_COMPRESS_PROGRAM_TITLE = 0x01, ++ ATSC_TEXT_COMPRESS_PROGRAM_DESCRIPTION = 0x02, ++}; ++ ++enum atsc_text_segment_mode { ++ ATSC_TEXT_SEGMENT_MODE_UNICODE_RANGE_MIN = 0x00, ++ ATSC_TEXT_SEGMENT_MODE_UNICODE_RANGE_MAX = 0x33, ++ ATSC_TEXT_SEGMENT_MODE_SCSU = 0x3e, ++ ATSC_TEXT_SEGMENT_MODE_UTF16 = 0x3f, ++ ATSC_TEXT_SEGMENT_MODE_TAIWAN_BITMAP = 0x40, ++ ATSC_TEXT_SEGMENT_MODE_TAIWAN_CODEWORD_BITMAP = 0x41, ++}; ++ ++typedef uint32_t atsctime_t; ++ ++struct atsc_text { ++ uint8_t number_strings; ++ /* struct atsc_text_string strings[] */ ++}; ++ ++struct atsc_text_string { ++ iso639lang_t language_code; ++ uint8_t number_segments; ++ /* struct atsc_text_string_segment segments[] */ ++}; ++ ++struct atsc_text_string_segment { ++ uint8_t compression_type; ++ uint8_t mode; ++ uint8_t number_bytes; ++ /* uint8_t bytes[] */ ++}; ++ ++/** ++ * Iterator for strings field of an atsc_text structure. ++ * ++ * @param txt atsc_text pointer. ++ * @param pos Variable holding a pointer to the current atsc_text_string. ++ * @param idx Iterator variable. ++ */ ++#define atsc_text_strings_for_each(txt, pos, idx) \ ++ for ((pos) = atsc_text_strings_first(txt), idx=0; \ ++ (pos); \ ++ (pos) = atsc_text_strings_next(txt, pos, ++idx)) ++ ++/** ++ * Iterator for segments field of an atsc_text_string structure. ++ * ++ * @param str atsc_text_string pointer. ++ * @param pos Variable holding a pointer to the current atsc_text_string_segment. ++ * @param idx Iterator variable. ++ */ ++#define atsc_text_string_segments_for_each(str, pos, idx) \ ++ for ((pos) = atsc_text_string_segments_first(str), idx=0; \ ++ (pos); \ ++ (pos) = atsc_text_string_segments_next(str, pos, ++idx)) ++ ++/** ++ * Accessor for the bytes field of an atsc_text_string_segment. ++ * ++ * @param seg atsc_text_string_segment pointer. ++ * @return Pointer to the bytes. ++ */ ++static inline uint8_t* ++ atsc_text_string_segment_bytes(struct atsc_text_string_segment *d) ++{ ++ return ((uint8_t*) d) + sizeof(struct atsc_text_string_segment); ++} ++ ++/** ++ * Validate a buffer containing an atsc_text structure. ++ * ++ * @param buf Start of the atsc_text structure. ++ * @param len Length in bytes of the buffer. ++ * @return 0 if valid, nonzero if not. ++ */ ++extern int atsc_text_validate(uint8_t *buf, int len); ++ ++/** ++ * Decodes an atsc_text_segment with mode < 0x3e. Decompression of the ATSC text encoding IS ++ * supported. The output text will be in the UTF-8 encoding. ++ * ++ * @param segment Pointer to the segment to decode. ++ * @param destbuf Pointer to the malloc()ed buffer to append text to (pass NULL if none). ++ * @param destbufsize Size of destbuf in bytes. ++ * @param destbufpos Position within destbuf. This will be updated to point after the end of the ++ * string on exit. ++ * @return New value of destbufpos, or < 0 on error. ++ */ ++extern int atsc_text_segment_decode(struct atsc_text_string_segment *segment, ++ uint8_t **destbuf, size_t *destbufsize, size_t *destbufpos); ++ ++/** ++ * Convert from ATSC time to unix time_t. ++ * ++ * @param atsc ATSC time. ++ * @return The time value. ++ */ ++extern time_t atsctime_to_unixtime(atsctime_t atsc); ++ ++/** ++ * Convert from unix time_t to atsc time. ++ * ++ * @param t unix time_t. ++ * @return The atsc time value. ++ */ ++extern atsctime_t unixtime_to_atsctime(time_t t); ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct atsc_text_string* ++ atsc_text_strings_first(struct atsc_text *txt) ++{ ++ if (txt->number_strings == 0) ++ return NULL; ++ ++ return (struct atsc_text_string *) ++ ((uint8_t*) txt + sizeof(struct atsc_text)); ++} ++ ++static inline struct atsc_text_string* ++ atsc_text_strings_next(struct atsc_text *txt, struct atsc_text_string *pos, int idx) ++{ ++ int i; ++ uint8_t *buf; ++ ++ if (idx >= txt->number_strings) ++ return NULL; ++ ++ buf = ((uint8_t*) pos) + sizeof(struct atsc_text_string); ++ for(i=0; i < pos->number_segments; i++) { ++ struct atsc_text_string_segment *seg = ++ (struct atsc_text_string_segment *) buf; ++ ++ buf += sizeof(struct atsc_text_string_segment); ++ buf += seg->number_bytes; ++ } ++ ++ return (struct atsc_text_string *) buf; ++} ++ ++static inline struct atsc_text_string_segment* ++ atsc_text_string_segments_first(struct atsc_text_string *str) ++{ ++ if (str->number_segments == 0) ++ return NULL; ++ ++ return (struct atsc_text_string_segment *) ++ ((uint8_t*) str + sizeof(struct atsc_text_string)); ++} ++ ++static inline struct atsc_text_string_segment* ++ atsc_text_string_segments_next(struct atsc_text_string *str, ++ struct atsc_text_string_segment *pos, int idx) ++{ ++ if (idx >= str->number_segments) ++ return NULL; ++ ++ return (struct atsc_text_string_segment *) ++ (((uint8_t*) pos) + sizeof(struct atsc_text_string_segment) + pos->number_bytes); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/crc32.c dvb-apps/lib/libucsi/crc32.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/crc32.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/crc32.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,89 @@ ++/** ++ * crc32 calculation routines. ++ * ++ * Copyright (c) 2005 by Andrew de Quincey ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++uint32_t crc32tbl[] = ++{ ++ 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, ++ 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, ++ 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, ++ 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, ++ 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, ++ 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75, ++ 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, ++ 0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd, ++ 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, ++ 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, ++ 0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81, ++ 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d, ++ 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, ++ 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95, ++ 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, ++ 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, ++ 0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae, ++ 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072, ++ 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, ++ 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, ++ 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, ++ 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, ++ 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066, ++ 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, ++ 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, ++ 0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692, ++ 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, ++ 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, ++ 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, ++ 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, ++ 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, ++ 0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a, ++ 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, ++ 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, ++ 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, ++ 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53, ++ 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, ++ 0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b, ++ 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, ++ 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, ++ 0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, ++ 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b, ++ 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, ++ 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3, ++ 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, ++ 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, ++ 0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f, ++ 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3, ++ 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, ++ 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c, ++ 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, ++ 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, ++ 0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30, ++ 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec, ++ 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, ++ 0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654, ++ 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, ++ 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, ++ 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, ++ 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, ++ 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, ++ 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c, ++ 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, ++ 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 ++}; +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/crc32.h dvb-apps/lib/libucsi/crc32.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/crc32.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/crc32.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,58 @@ ++/** ++ * crc32 calculation routines. ++ * ++ * Copyright (c) 2005 by Andrew de Quincey ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_CRC32_H ++#define _UCSI_CRC32_H 1 ++ ++#include ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#define CRC32_INIT (~0) ++ ++extern uint32_t crc32tbl[]; ++ ++/** ++ * Calculate a CRC32 over a piece of data. ++ * ++ * @param crc Current CRC value (use CRC32_INIT for first call). ++ * @param buf Buffer to calculate over. ++ * @param len Number of bytes. ++ * @return Calculated CRC. ++ */ ++static inline uint32_t crc32(uint32_t crc, uint8_t* buf, size_t len) ++{ ++ size_t i; ++ ++ for (i=0; i< len; i++) { ++ crc = (crc << 8) ^ crc32tbl[((crc >> 24) ^ buf[i]) & 0xff]; ++ } ++ ++ return crc; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/descriptor.h dvb-apps/lib/libucsi/descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,129 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DESCRIPTOR_H ++#define _UCSI_DESCRIPTOR_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * Generic descriptor header. ++ */ ++struct descriptor { ++ uint8_t tag; ++ uint8_t len; ++} __ucsi_packed; ++ ++/** ++ * Retreive pointer to the next descriptor structure. ++ * ++ * @param buf The buffer of descriptors. ++ * @param len Size of the buffer. ++ * @param pos Current descriptor. ++ * @return Pointer to next descriptor, or NULL if there are none. ++ */ ++static inline struct descriptor * ++ next_descriptor(uint8_t * buf, size_t len, struct descriptor * pos) ++{ ++ uint8_t* next; ++ ++ if (pos == NULL) ++ return NULL; ++ ++ next = (uint8_t*) pos + 2 + pos->len; ++ if (next >= buf + len) ++ return NULL; ++ ++ return (struct descriptor *) next; ++} ++ ++ ++/** ++ * The unknown descriptor. ++ */ ++struct unknown_descriptor { ++ struct descriptor d; ++ ++ /* uint8_t data [] */ ++} __ucsi_packed; ++ ++/** ++ * Retrieve pointer to the unknown descriptor's data field. ++ * ++ * @param d The descriptor. ++ * @return Pointer to the data field. ++ */ ++static inline uint8_t * ++ unknown_descriptor_data(struct unknown_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct unknown_descriptor); ++} ++ ++/** ++ * Retrieve size of unknown descriptor's data field. ++ * ++ * @param d The descriptor. ++ * @return Size of data field in bytes. ++ */ ++static inline int ++ unknown_descriptor_data_size(struct unknown_descriptor *d) ++{ ++ return d->d.len; ++} ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline int verify_descriptors(uint8_t * buf, size_t len) ++{ ++ size_t pos = 0; ++ ++ while (pos < len) { ++ if ((pos + 2) > len) ++ return -1; ++ ++ pos += 2 + buf[pos+1]; ++ } ++ ++ if (pos != len) ++ return -1; ++ ++ return 0; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ac3_descriptor.h dvb-apps/lib/libucsi/dvb/ac3_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ac3_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/ac3_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,88 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_AC3_DESCRIPTOR ++#define _UCSI_DVB_AC3_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_ac3_descriptor structure. ++ */ ++struct dvb_ac3_descriptor { ++ struct descriptor d; ++ ++ EBIT5(uint8_t ac3_type_flag : 1; , ++ uint8_t bsid_flag : 1; , ++ uint8_t mainid_flag : 1; , ++ uint8_t asvc_flag : 1; , ++ uint8_t reserved : 4; ); ++ /* uint8_t additional_info[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_ac3_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return dvb_ac3_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_ac3_descriptor* ++ dvb_ac3_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len < (sizeof(struct dvb_ac3_descriptor) - 2)) ++ return NULL; ++ ++ return (struct dvb_ac3_descriptor*) d; ++} ++ ++/** ++ * Retrieve pointer to additional_info field of a dvb_ac3_descriptor. ++ * ++ * @param d dvb_ac3_descriptor pointer. ++ * @return Pointer to additional_info field. ++ */ ++static inline uint8_t *dvb_ac3_descriptor_additional_info(struct dvb_ac3_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_ac3_descriptor); ++} ++ ++/** ++ * Determine length of additional_info field of a dvb_ac3_descriptor. ++ * ++ * @param d dvb_ac3_descriptor pointer. ++ * @return Length of field in bytes. ++ */ ++static inline int dvb_ac3_descriptor_additional_info_length(struct dvb_ac3_descriptor *d) ++{ ++ return d->d.len - 1; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/adaptation_field_data_descriptor.h dvb-apps/lib/libucsi/dvb/adaptation_field_data_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/adaptation_field_data_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/adaptation_field_data_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,62 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_ADAPTATION_FIELD_DATA_DESCRIPTOR ++#define _UCSI_DVB_ADAPTATION_FIELD_DATA_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_adaptation_field_data_descriptor structure. ++ */ ++struct dvb_adaptation_field_data_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint8_t reserved : 7; , ++ uint8_t announcement_switching_data : 1; ); ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_adaptation_field_data_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return Pointer to dvb_adaptation_field_data_descriptor, or NULL on error. ++ */ ++static inline struct dvb_adaptation_field_data_descriptor* ++ dvb_adaptation_field_data_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct dvb_adaptation_field_data_descriptor) - 2)) ++ return NULL; ++ ++ return (struct dvb_adaptation_field_data_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ait_application_descriptor.h dvb-apps/lib/libucsi/dvb/ait_application_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ait_application_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/ait_application_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,204 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_AIT_APPLICATION_DESCRIPTOR ++#define _UCSI_DVB_AIT_APPLICATION_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * Possible values for the visibility field. ++ */ ++enum { ++ AVB_AIT_APPLICATION_VISIBILITY_HIDDEN = 0x00, ++ AVB_AIT_APPLICATION_VISIBILITY_APPSONLY = 0x01, ++ AVB_AIT_APPLICATION_VISIBILITY_VISIBLE = 0x03, ++}; ++ ++/** ++ * dvb_ait_application_descriptor structure. ++ */ ++struct dvb_ait_application_descriptor { ++ struct descriptor d; ++ ++ uint8_t application_profiles_length; ++ /* struct dvb_ait_application_profile profiles [] */ ++ /* struct dvb_ait_application_descriptor_part2 part2 */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the profiles field of a dvb_ait_application_descriptor. ++ */ ++struct dvb_ait_application_profile { ++ uint16_t application_profile; ++ uint8_t version_major; ++ uint8_t version_minor; ++ uint8_t version_micro; ++} __ucsi_packed; ++ ++/** ++ * Second part of a dvb_ait_application_descriptor structure. ++ */ ++struct dvb_ait_application_descriptor_part2 { ++ EBIT3(uint8_t service_bound_flag : 1; , ++ uint8_t visibility : 2; , ++ uint8_t reserved : 5; ); ++ uint8_t application_priority; ++ /* uint8_t transport_protocol_label[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_ait_application_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_ait_application_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_ait_application_descriptor* ++ dvb_ait_application_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t pos = 0; ++ uint32_t pos2 = 0; ++ uint32_t len = d->len + 2; ++ uint8_t* buf = (uint8_t*) d; ++ struct dvb_ait_application_descriptor *ret = ++ (struct dvb_ait_application_descriptor*) d; ++ ++ if (len < sizeof(struct dvb_ait_application_descriptor)) ++ return NULL; ++ ++ if (len < (sizeof(struct dvb_ait_application_descriptor) + ret->application_profiles_length)) ++ return NULL; ++ ++ if (ret->application_profiles_length % sizeof(struct dvb_ait_application_profile)) ++ return NULL; ++ ++ pos += sizeof(struct dvb_ait_application_descriptor); ++ pos2 = 0; ++ while(pos2 < ret->application_profiles_length) { ++ bswap16(buf + pos + pos2); ++ pos2 += sizeof(struct dvb_ait_application_descriptor); ++ } ++ pos += pos2; ++ ++ if (len < (pos + sizeof(struct dvb_ait_application_descriptor_part2))) ++ return NULL; ++ ++ return ret; ++} ++ ++/** ++ * Iterator for the profiles field of a dvb_ait_application_descriptor. ++ * ++ * @param d dvb_ait_application_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_ait_application_profile. ++ */ ++#define dvb_ait_application_descriptor_profiles_for_each(d, pos) \ ++ for ((pos) = dvb_ait_application_descriptor_profiles_first(d); \ ++ (pos); \ ++ (pos) = dvb_ait_application_descriptor_profiles_next(d, pos)) ++ ++/** ++ * Accessor for the part2 field of a dvb_ait_application_descriptor. ++ * ++ * @param d dvb_ait_application_descriptor pointer. ++ * @return dvb_ait_application_descriptor_part2 pointer. ++ */ ++static inline struct dvb_ait_application_descriptor_part2* ++ dvb_ait_application_descriptor_part2(struct dvb_ait_application_descriptor* d) ++{ ++ return (struct dvb_ait_application_descriptor_part2*) ++ ((uint8_t*) d + ++ sizeof(struct dvb_ait_application_descriptor) + ++ d->application_profiles_length); ++} ++ ++/** ++ * Accessor for the transport_protocol_label field of a dvb_ait_application_descriptor_part2. ++ * ++ * @param d dvb_ait_application_descriptor_part2 pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t* ++ dvb_ait_application_descriptor_part2_transport_protocol_label(struct dvb_ait_application_descriptor_part2* d) ++{ ++ return (uint8_t*) d + ++ sizeof(struct dvb_ait_application_descriptor_part2); ++} ++ ++/** ++ * Calculate the number of bytes in the transport_protocol_label field of a dvb_ait_application_descriptor_part2. ++ * ++ * @param d dvb_ait_application_descriptor pointer. ++ * @param part2 dvb_ait_application_descriptor_part2 pointer. ++ * @return Number of bytes. ++ */ ++static inline int ++ dvb_ait_application_descriptor_part2_transport_protocol_label_length(struct dvb_ait_application_descriptor *d, ++ struct dvb_ait_application_descriptor_part2* part2) ++{ ++ uint8_t *ptr = (uint8_t*) part2 + sizeof(struct dvb_ait_application_descriptor_part2); ++ uint8_t *end = (uint8_t*) d + d->d.len + 2; ++ ++ return (int) (end - ptr); ++} ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_ait_application_profile* ++ dvb_ait_application_descriptor_profiles_first(struct dvb_ait_application_descriptor *d) ++{ ++ if (d->application_profiles_length == 0) ++ return NULL; ++ ++ return (struct dvb_ait_application_profile *) ++ ((uint8_t*) d + sizeof(struct dvb_ait_application_descriptor)); ++} ++ ++static inline struct dvb_ait_application_profile* ++ dvb_ait_application_descriptor_profiles_next(struct dvb_ait_application_descriptor *d, ++ struct dvb_ait_application_profile *pos) ++{ ++ uint8_t *end = (uint8_t*) d + ++ sizeof(struct dvb_ait_application_descriptor) + ++ d->application_profiles_length; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_ait_application_profile); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_ait_application_profile *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ait_application_icons_descriptor.h dvb-apps/lib/libucsi/dvb/ait_application_icons_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ait_application_icons_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/ait_application_icons_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,157 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_AIT_APPLICATION_ICONS_DESCRIPTOR ++#define _UCSI_DVB_AIT_APPLICATION_ICONS_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * Possible values for the icon_flags field. ++ */ ++enum { ++ AIT_APPLICATION_ICON_FLAG_32_32 = 0x001, ++ AIT_APPLICATION_ICON_FLAG_32_32_43 = 0x002, ++ AIT_APPLICATION_ICON_FLAG_24_32_169 = 0x004, ++ ++ AIT_APPLICATION_ICON_FLAG_64_64 = 0x008, ++ AIT_APPLICATION_ICON_FLAG_64_64_43 = 0x010, ++ AIT_APPLICATION_ICON_FLAG_48_64_169 = 0x020, ++ ++ AIT_APPLICATION_ICON_FLAG_128_128 = 0x040, ++ AIT_APPLICATION_ICON_FLAG_128_128_43 = 0x080, ++ AIT_APPLICATION_ICON_FLAG_96_128_169 = 0x100, ++}; ++ ++/** ++ * dvb_ait_application_icons_descriptor structure. ++ */ ++struct dvb_ait_application_icons_descriptor { ++ struct descriptor d; ++ ++ uint8_t icon_locator_length; ++ /* uint8_t icon_locator[] */ ++ /* struct dvb_ait_application_icons_descriptor_part2 */ ++} __ucsi_packed; ++ ++/** ++ * Second part of a dvb_ait_application_icons_descriptor. ++ */ ++struct dvb_ait_application_icons_descriptor_part2 { ++ uint16_t icon_flags; ++ /* uint8_t reserved[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_ait_application_icons_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_ait_application_icons_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_ait_application_icons_descriptor* ++ dvb_ait_application_icons_descriptor_codec(struct descriptor* d) ++{ ++ uint8_t* buf = (uint8_t*) d; ++ uint32_t pos = 0; ++ uint32_t len = d->len + 2; ++ struct dvb_ait_application_icons_descriptor *ret = ++ (struct dvb_ait_application_icons_descriptor *) d; ++ ++ if (len < sizeof(struct dvb_ait_application_icons_descriptor)) ++ return NULL; ++ if (len < (sizeof(struct dvb_ait_application_icons_descriptor) + ret->icon_locator_length)) ++ return NULL; ++ ++ pos += sizeof(struct dvb_ait_application_icons_descriptor) + ret->icon_locator_length; ++ ++ if ((len - pos) < sizeof(struct dvb_ait_application_icons_descriptor_part2)) ++ return NULL; ++ bswap16(buf + pos); ++ ++ return ret; ++} ++/** ++ * Accessor for the icon_locator field of a dvb_ait_application_icons_descriptor. ++ * ++ * @param e dvb_ait_application_icons_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_ait_application_icons_descriptor_icon_locator(struct dvb_ait_application_icons_descriptor *e) ++{ ++ return (uint8_t *) e + sizeof(struct dvb_ait_application_icons_descriptor); ++} ++ ++/** ++ * Accessor for the part2 field of a dvb_ait_application_icons_descriptor. ++ * ++ * @param e dvb_ait_application_icons_descriptor Pointer. ++ * @return dvb_ait_application_icons_descriptor_part2 pointer. ++ */ ++static inline struct dvb_ait_application_icons_descriptor_part2 * ++ dvb_ait_application_icons_descriptor_part2(struct dvb_ait_application_icons_descriptor *e) ++{ ++ return (struct dvb_ait_application_icons_descriptor_part2 *) ++ ((uint8_t *) e + sizeof(struct dvb_ait_application_icons_descriptor) + ++ e->icon_locator_length); ++} ++ ++/** ++ * Accessor for the reserved field of a dvb_ait_application_icons_descriptor_part2. ++ * ++ * @param e dvb_ait_application_icons_part2 pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_ait_application_icons_descriptor_part2_reserved(struct dvb_ait_application_icons_descriptor_part2 *e) ++{ ++ return (uint8_t *) e + sizeof(struct dvb_ait_application_icons_descriptor_part2); ++} ++ ++/** ++ * Calculate the number of bytes in the reserved field of a dvb_ait_application_icons_descriptor_part2. ++ * ++ * @param d dvb_ait_application_icons_descriptorpointer. ++ * @param part2 dvb_ait_application_icons_descriptor_part2 pointer. ++ * @return Number of bytes. ++ */ ++static inline int ++ dvb_ait_application_icons_descriptor_part2_reserved_length(struct dvb_ait_application_icons_descriptor *d, ++ struct dvb_ait_application_icons_descriptor_part2* part2) ++{ ++ uint8_t *ptr = (uint8_t*) part2 + sizeof(struct dvb_ait_application_icons_descriptor_part2); ++ uint8_t *end = (uint8_t*) d + d->d.len + 2; ++ ++ return (int) (end - ptr); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ait_application_name_descriptor.h dvb-apps/lib/libucsi/dvb/ait_application_name_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ait_application_name_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/ait_application_name_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,145 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_AIT_APPLICATION_NAME_DESCRIPTOR ++#define _UCSI_DVB_AIT_APPLICATION_NAME_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * dvb_ait_application_name_descriptor structure. ++ */ ++struct dvb_ait_application_name_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_ait_application_name names[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the names field of a dvb_ait_application_name_descriptor. ++ */ ++struct dvb_ait_application_name { ++ iso639lang_t language_code; ++ uint8_t application_name_length; ++ /* uint8_t name[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_ait_application_name_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_ait_application_name_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_ait_application_name_descriptor* ++ dvb_ait_application_name_descriptor_codec(struct descriptor* d) ++{ ++ uint8_t* buf = (uint8_t*) d + 2; ++ uint32_t pos = 0; ++ uint32_t len = d->len; ++ ++ while(pos < len) { ++ struct dvb_ait_application_name *e = ++ (struct dvb_ait_application_name*) (buf + pos); ++ ++ pos += sizeof(struct dvb_ait_application_name); ++ ++ if (pos > len) ++ return NULL; ++ ++ pos += e->application_name_length; ++ ++ if (pos > len) ++ return NULL; ++ } ++ ++ return (struct dvb_ait_application_name_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries in the names field of a dvb_ait_application_name_descriptor. ++ * ++ * @param d dvb_ait_application_name_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_ait_application_name. ++ */ ++#define dvb_ait_application_name_descriptor_names_for_each(d, pos) \ ++ for ((pos) = dvb_ait_application_name_descriptor_names_first(d); \ ++ (pos); \ ++ (pos) = dvb_ait_application_name_descriptor_names_next(d, pos)) ++ ++/** ++ * Accessor for the name field of a dvb_ait_application_name. ++ * ++ * @param e dvb_ait_application_name pointer. ++ * @return Pointer to the name field. ++ */ ++static inline uint8_t * ++ dvb_ait_application_name_name(struct dvb_ait_application_name *e) ++{ ++ return (uint8_t *) e + sizeof(struct dvb_ait_application_name); ++} ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_ait_application_name* ++ dvb_ait_application_name_descriptor_names_first(struct dvb_ait_application_name_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_ait_application_name *) ++ ((uint8_t*) d + sizeof(struct dvb_ait_application_name_descriptor)); ++} ++ ++static inline struct dvb_ait_application_name* ++ dvb_ait_application_name_descriptor_names_next(struct dvb_ait_application_name_descriptor *d, ++ struct dvb_ait_application_name *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + ++ sizeof(struct dvb_ait_application_name) + ++ pos->application_name_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_ait_application_name *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ait_external_application_authorisation_descriptor.h dvb-apps/lib/libucsi/dvb/ait_external_application_authorisation_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ait_external_application_authorisation_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/ait_external_application_authorisation_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,125 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_AIT_EXTERNAL_APPLICATION_AUTHORISATION_DESCRIPTOR ++#define _UCSI_DVB_AIT_EXTERNAL_APPLICATION_AUTHORISATION_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * dvb_ait_external_application_authorisation_descriptor structure. ++ */ ++struct dvb_ait_external_application_authorisation_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_ait_external_application_authorisation auths[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the auths field of a dvb_ait_external_application_authorisation_descriptor. ++ */ ++struct dvb_ait_external_application_authorisation { ++ uint32_t organization_id; ++ uint16_t application_id; ++ uint8_t application_priority; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_ait_external_application_authorisation_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_ait_external_application_authorisation_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_ait_external_application_authorisation_descriptor* ++ dvb_ait_external_application_authorisation_descriptor_codec(struct descriptor* d) ++{ ++ uint8_t* buf = (uint8_t*) d + 2; ++ uint32_t pos = 0; ++ uint32_t len = d->len; ++ ++ if (len % sizeof(struct dvb_ait_external_application_authorisation)) ++ return NULL; ++ ++ while(pos < len) { ++ bswap32(buf + pos); ++ bswap32(buf + pos + 4); ++ pos += sizeof(struct dvb_ait_external_application_authorisation); ++ } ++ ++ return (struct dvb_ait_external_application_authorisation_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries in the auths field of a dvb_ait_external_application_authorisation_descriptor. ++ * ++ * @param d dvb_ait_external_application_authorisation_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_ait_external_application_authorisation. ++ */ ++#define dvb_ait_external_application_authorisation_descriptor_auths_for_each(d, pos) \ ++ for ((pos) = dvb_ait_external_application_authorisation_descriptor_auths_first(d); \ ++ (pos); \ ++ (pos) = dvb_ait_external_application_authorisation_descriptor_auths_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_ait_external_application_authorisation* ++ dvb_ait_external_application_authorisation_descriptor_auths_first(struct dvb_ait_external_application_authorisation_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_ait_external_application_authorisation *) ++ ((uint8_t*) d + sizeof(struct dvb_ait_external_application_authorisation_descriptor)); ++} ++ ++static inline struct dvb_ait_external_application_authorisation* ++ dvb_ait_external_application_authorisation_descriptor_auths_next(struct dvb_ait_external_application_authorisation_descriptor *d, ++ struct dvb_ait_external_application_authorisation *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + ++ sizeof(struct dvb_ait_external_application_authorisation); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_ait_external_application_authorisation *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ancillary_data_descriptor.h dvb-apps/lib/libucsi/dvb/ancillary_data_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ancillary_data_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/ancillary_data_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,67 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_ANCILLARY_DATA_DESCRIPTOR ++#define _UCSI_DVB_ANCILLARY_DATA_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_ancillary_data_descriptor structure. ++ */ ++struct dvb_ancillary_data_descriptor { ++ struct descriptor d; ++ EBIT8(uint8_t reserved : 1; , ++ uint8_t rds_via_udcp : 1; , ++ uint8_t mpeg4_ancillary_data : 1; , ++ uint8_t scale_factor_error_check : 1; , ++ uint8_t dab_ancillary_data : 1; , ++ uint8_t announcement_switching_data : 1; , ++ uint8_t extended_ancillary_data : 1; , ++ uint8_t dvd_video_ancillary_data : 1; ); ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_ancillary_data_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_ancillary_data_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_ancillary_data_descriptor* ++ dvb_ancillary_data_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct dvb_ancillary_data_descriptor) - 2)) ++ return NULL; ++ ++ return (struct dvb_ancillary_data_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/announcement_support_descriptor.h dvb-apps/lib/libucsi/dvb/announcement_support_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/announcement_support_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/announcement_support_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,219 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_ANNOUNCEMENT_SUPPORT_DESCRIPTOR ++#define _UCSI_DVB_ANNOUNCEMENT_SUPPORT_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * Possible values for announcement_support_indicator. ++ */ ++enum { ++ DVB_ANNOUNCEMENT_SUPPORT_EMERGENCY = 0x01, ++ DVB_ANNOUNCEMENT_SUPPORT_ROAD_TRAFFIC_FLASH = 0x02, ++ DVB_ANNOUNCEMENT_SUPPORT_PUBLIC_TRANSPORT_FLASH = 0x04, ++ DVB_ANNOUNCEMENT_SUPPORT_WARNING_MESSAGE = 0x08, ++ DVB_ANNOUNCEMENT_SUPPORT_NEWS_FLASH = 0x10, ++ DVB_ANNOUNCEMENT_SUPPORT_WEATHER_FLASH = 0x20, ++ DVB_ANNOUNCEMENT_SUPPORT_EVENT_ANNOUNCEMENT = 0x40, ++ DVB_ANNOUNCEMENT_SUPPORT_PERSONAL_CALL = 0x80, ++}; ++ ++/** ++ * Possible values for announcement_type. ++ */ ++enum { ++ DVB_ANNOUNCEMENT_TYPE_EMERGENCY = 0x00, ++ DVB_ANNOUNCEMENT_TYPE_ROAD_TRAFFIC_FLASH = 0x01, ++ DVB_ANNOUNCEMENT_TYPE_PUBLIC_TRANSPORT_FLASH = 0x02, ++ DVB_ANNOUNCEMENT_TYPE_WARNING_MESSAGE = 0x03, ++ DVB_ANNOUNCEMENT_TYPE_NEWS_FLASH = 0x04, ++ DVB_ANNOUNCEMENT_TYPE_WEATHER_FLASH = 0x05, ++ DVB_ANNOUNCEMENT_TYPE_EVENT_ANNOUNCEMENT = 0x06, ++ DVB_ANNOUNCEMENT_TYPE_PERSONAL_CALL = 0x07, ++}; ++ ++/** ++ * Possible values for reference_type. ++ */ ++enum { ++ DVB_REFERENCE_TYPE_AUDIO = 0x00, ++ DVB_REFERENCE_TYPE_OTHER_AUDIO = 0x01, ++ DVB_REFERENCE_TYPE_OTHER_SERVICE = 0x02, ++ DVB_REFERENCE_TYPE_OTHER_TS = 0x03, ++}; ++ ++/** ++ * dvb_announcement_support_descriptor structure. ++ */ ++struct dvb_announcement_support_descriptor { ++ struct descriptor d; ++ uint16_t announcement_support_indicator; ++ /* struct dvb_announcement_support_entry entries[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the entries field of a dvb_announcement_support_descriptor. ++ */ ++struct dvb_announcement_support_entry { ++ EBIT3(uint8_t announcement_type : 4; , ++ uint8_t reserved : 1; , ++ uint8_t reference_type : 3; ); ++ /* Only if reference_type == 1, 2 or 3: ++ * struct dvb_announcement_support_reference reference */ ++} __ucsi_packed; ++ ++/** ++ * The optional reference field only present in a dvb_announcement_support_descriptor if ++ * its reference_type field is 1,2 or 3. ++ */ ++struct dvb_announcement_support_reference { ++ uint16_t original_network_id; ++ uint16_t transport_stream_id; ++ uint16_t service_id; ++ uint8_t component_tag; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_announcement_support_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_announcement_support_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_announcement_support_descriptor* ++ dvb_announcement_support_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t pos = 0; ++ uint8_t* buf = (uint8_t*) d + 2; ++ uint32_t len = d->len; ++ ++ if (len < (sizeof(struct dvb_announcement_support_descriptor) - 2)) ++ return NULL; ++ ++ bswap16(buf+pos); ++ ++ pos += 2; ++ ++ while(pos < len) { ++ struct dvb_announcement_support_entry *e = ++ (struct dvb_announcement_support_entry*) (buf+pos); ++ ++ pos += sizeof(struct dvb_announcement_support_entry); ++ ++ if (pos > len) ++ return NULL; ++ ++ if ((e->reference_type == 1) || ++ (e->reference_type == 2) || ++ (e->reference_type == 3)) { ++ if ((pos + sizeof(struct dvb_announcement_support_reference)) > len) ++ return NULL; ++ ++ bswap16(buf+pos); ++ bswap16(buf+pos+2); ++ bswap16(buf+pos+4); ++ ++ pos += sizeof(struct dvb_announcement_support_reference); ++ } ++ } ++ ++ return (struct dvb_announcement_support_descriptor*) d; ++} ++ ++/** ++ * Iterator for the entries field of a dvb_announcement_support_descriptor. ++ * ++ * @param d dvb_announcement_support_descriptor pointer. ++ * @param pod Variable holding a pointer to the current dvb_announcement_support_entry. ++ */ ++#define dvb_announcement_support_descriptor_entries_for_each(d, pos) \ ++ for ((pos) = dvb_announcement_support_descriptor_entries_first(d); \ ++ (pos); \ ++ (pos) = dvb_announcement_support_descriptor_entries_next(d, pos)) ++ ++/** ++ * Accessor for the reference field of a dvb_announcement_support_entry if present. ++ * ++ * @param entry dvb_announcement_support_entry pointer. ++ * @return dvb_announcement_support_reference pointer, or NULL on error. ++ */ ++static inline struct dvb_announcement_support_reference* ++ dvb_announcement_support_entry_reference(struct dvb_announcement_support_entry* entry) ++{ ++ if ((entry->reference_type != 0x01) && ++ (entry->reference_type != 0x02) && ++ (entry->reference_type != 0x03)) ++ return NULL; ++ ++ return (struct dvb_announcement_support_reference*) ++ ((uint8_t*) entry + sizeof(struct dvb_announcement_support_entry)); ++} ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_announcement_support_entry* ++ dvb_announcement_support_descriptor_entries_first(struct dvb_announcement_support_descriptor *d) ++{ ++ if (d->d.len == 2) ++ return NULL; ++ ++ return (struct dvb_announcement_support_entry *) ++ ((uint8_t*) d + sizeof(struct dvb_announcement_support_descriptor)); ++} ++ ++static inline struct dvb_announcement_support_entry* ++ dvb_announcement_support_descriptor_entries_next(struct dvb_announcement_support_descriptor *d, ++ struct dvb_announcement_support_entry *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t* next = (uint8_t*) pos + sizeof(struct dvb_announcement_support_entry); ++ struct dvb_announcement_support_reference* reference = ++ dvb_announcement_support_entry_reference(pos); ++ ++ if (reference) ++ next += sizeof(struct dvb_announcement_support_reference); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_announcement_support_entry *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/application_signalling_descriptor.h dvb-apps/lib/libucsi/dvb/application_signalling_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/application_signalling_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/application_signalling_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,124 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_APPLICATION_SIGNALLING_DESCRIPTOR ++#define _UCSI_DVB_APPLICATION_SIGNALLING_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_application_signalling_descriptor structure. ++ */ ++struct dvb_application_signalling_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_application_signalling_entry entries[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the entries field of a dvb_application_signalling_descriptor. ++ */ ++struct dvb_application_signalling_entry { ++ uint16_t application_type; ++ EBIT2(uint8_t reserved : 3; , ++ uint8_t AIT_version_number : 5; ); ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_application_signalling_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_application_signalling_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_application_signalling_descriptor* ++ dvb_application_signalling_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t pos = 0; ++ uint32_t len = d->len; ++ uint8_t* buf = (uint8_t*) d + 2; ++ ++ pos += sizeof(struct dvb_application_signalling_descriptor) - 2; ++ if (len % sizeof(struct dvb_application_signalling_entry)) ++ return NULL; ++ ++ while(pos < len) { ++ bswap16(buf+pos); ++ pos+=3; ++ } ++ ++ return (struct dvb_application_signalling_descriptor*) d; ++} ++ ++/** ++ * Iterator for the entries field of a dvb_application_signalling_descriptor. ++ * ++ * @param d dvb_application_signalling_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_application_signalling_entry. ++ */ ++#define dvb_application_signalling_descriptor_entries_for_each(d, pos) \ ++ for ((pos) = dvb_application_signalling_descriptor_entries_first(d); \ ++ (pos); \ ++ (pos) = dvb_application_signalling_descriptor_entries_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_application_signalling_entry* ++ dvb_application_signalling_descriptor_entries_first(struct dvb_application_signalling_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_application_signalling_entry *) ++ ((uint8_t*) d + sizeof(struct dvb_application_signalling_descriptor)); ++} ++ ++static inline struct dvb_application_signalling_entry* ++ dvb_application_signalling_descriptor_entries_next(struct dvb_application_signalling_descriptor *d, ++ struct dvb_application_signalling_entry *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_application_signalling_entry); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_application_signalling_entry *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/bat_section.c dvb-apps/lib/libucsi/dvb/bat_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/bat_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/bat_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,77 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct dvb_bat_section * dvb_bat_section_codec(struct section_ext * ext) ++{ ++ uint8_t * buf = (uint8_t *) ext; ++ size_t pos = sizeof(struct section_ext); ++ size_t len = section_ext_length(ext); ++ struct dvb_bat_section * ret = (struct dvb_bat_section *) ext; ++ ++ if (len < sizeof(struct dvb_bat_section)) ++ return NULL; ++ ++ bswap16(buf + pos); ++ pos += 2; ++ ++ if ((pos + ret->bouquet_descriptors_length) > len) ++ return NULL; ++ ++ if (verify_descriptors(buf + pos, ret->bouquet_descriptors_length)) ++ return NULL; ++ pos += ret->bouquet_descriptors_length; ++ ++ if ((pos + sizeof(struct dvb_bat_section_part2)) > len) ++ return NULL; ++ ++ bswap16(buf + pos); ++ pos += sizeof(struct dvb_bat_section_part2); ++ ++ while (pos < len) { ++ struct dvb_bat_transport * transport = ++ (struct dvb_bat_transport *) (buf + pos); ++ ++ if ((pos + sizeof(struct dvb_bat_transport)) > len) ++ return NULL; ++ ++ bswap16(buf + pos); ++ bswap16(buf + pos + 2); ++ bswap16(buf + pos + 4); ++ ++ pos += sizeof(struct dvb_bat_transport); ++ ++ if ((pos + transport->transport_descriptors_length) > len) ++ return NULL; ++ ++ if (verify_descriptors(buf + pos, ++ transport->transport_descriptors_length)) ++ return NULL; ++ ++ pos += transport->transport_descriptors_length; ++ } ++ ++ if (pos != len) ++ return NULL; ++ ++ return ret; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/bat_section.h dvb-apps/lib/libucsi/dvb/bat_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/bat_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/bat_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,211 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_BAT_SECTION_H ++#define _UCSI_DVB_BAT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * dvb_bat_section structure. ++ */ ++struct dvb_bat_section { ++ struct section_ext head; ++ ++ EBIT2(uint16_t reserved_1 : 4; , ++ uint16_t bouquet_descriptors_length :12; ); ++ /* struct descriptor descriptors[] */ ++ /* struct dvb_bat_section_part2 part2 */ ++}; ++ ++/** ++ * Second part of a dvb_bat_section, following the variable length descriptors field. ++ */ ++struct dvb_bat_section_part2 { ++ EBIT2(uint16_t reserved_2 : 4; , ++ uint16_t transport_stream_loop_length :12; ); ++ /* struct dvb_bat_transport transports[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the transports field of a dvb_bat_section_part2. ++ */ ++struct dvb_bat_transport { ++ uint16_t transport_stream_id; ++ uint16_t original_network_id; ++ EBIT2(uint16_t reserved : 4; , ++ uint16_t transport_descriptors_length :12; ); ++ /* struct descriptor descriptors[] */ ++}; ++ ++/** ++ * Process a dvb_bat_section. ++ * ++ * @param section Generic section pointer. ++ * @return dvb_bat_section pointer, or NULL on error. ++ */ ++struct dvb_bat_section *dvb_bat_section_codec(struct section_ext *section); ++ ++/** ++ * Accessor for the bouquet_id field of a BAT. ++ * ++ * @param bat BAT pointer. ++ * @return The bouquet_id. ++ */ ++static inline uint16_t dvb_bat_section_bouquet_id(struct dvb_bat_section *bat) ++{ ++ return bat->head.table_id_ext; ++} ++ ++/** ++ * Iterator for the descriptors field in a dvb_bat_section. ++ * ++ * @param bat dvb_bat_section pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define dvb_bat_section_descriptors_for_each(bat, pos) \ ++ for ((pos) = dvb_bat_section_descriptors_first(bat); \ ++ (pos); \ ++ (pos) = dvb_bat_section_descriptors_next(bat, pos)) ++ ++/** ++ * Accessor for the second part of a dvb_bat_section. ++ * ++ * @param bat dvb_bat_section pointer. ++ * @return dvb_bat_section_part2 pointer. ++ */ ++static inline struct dvb_bat_section_part2 * ++ dvb_bat_section_part2(struct dvb_bat_section *bat) ++{ ++ return (struct dvb_bat_section_part2 *) ++ ((uint8_t*) bat + ++ sizeof(struct dvb_bat_section) + ++ bat->bouquet_descriptors_length); ++ ++} ++ ++/** ++ * Iterator for the transports field of a dvb_bat_section_part2. ++ * ++ * @param part2 dvb_bat_section_part2 pointer. ++ * @param pos Variable containing a pointer to the current dvb_bat_transport. ++ */ ++#define dvb_bat_section_transports_for_each(part2, pos) \ ++ for ((pos) = dvb_bat_section_transports_first(part2); \ ++ (pos); \ ++ (pos) = dvb_bat_section_transports_next(part2, pos)) ++ ++/** ++ * Iterator for the descriptors field of a dvb_bat_transport. ++ * ++ * @param transport dvb_bat_transport pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define dvb_bat_transport_descriptors_for_each(transport, pos) \ ++ for ((pos) = dvb_bat_transport_descriptors_first(transport); \ ++ (pos); \ ++ (pos) = dvb_bat_transport_descriptors_next(transport, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct descriptor * ++ dvb_bat_section_descriptors_first(struct dvb_bat_section *bat) ++{ ++ if (bat->bouquet_descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor *) ++ ((uint8_t *) bat + sizeof(struct dvb_bat_section)); ++} ++ ++static inline struct descriptor * ++ dvb_bat_section_descriptors_next(struct dvb_bat_section *bat, ++ struct descriptor* pos) ++{ ++ return next_descriptor((uint8_t*) bat + sizeof(struct dvb_bat_section), ++ bat->bouquet_descriptors_length, ++ pos); ++} ++ ++static inline struct dvb_bat_transport * ++ dvb_bat_section_transports_first(struct dvb_bat_section_part2 *part2) ++{ ++ if (part2->transport_stream_loop_length == 0) ++ return NULL; ++ ++ return (struct dvb_bat_transport *) ++ ((uint8_t *) part2 + sizeof(struct dvb_bat_section_part2)); ++} ++ ++static inline struct dvb_bat_transport * ++ dvb_bat_section_transports_next(struct dvb_bat_section_part2 *part2, ++ struct dvb_bat_transport *pos) ++{ ++ uint8_t *end = (uint8_t*) part2 + sizeof(struct dvb_bat_section_part2) + ++ part2->transport_stream_loop_length; ++ uint8_t *next = (uint8_t*) pos + sizeof(struct dvb_bat_transport) + ++ pos->transport_descriptors_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_bat_transport *) next; ++} ++ ++static inline struct descriptor * ++ dvb_bat_transport_descriptors_first(struct dvb_bat_transport *t) ++{ ++ if (t->transport_descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor *) ++ ((uint8_t*)t + sizeof(struct dvb_bat_transport)); ++} ++ ++static inline struct descriptor * ++ dvb_bat_transport_descriptors_next(struct dvb_bat_transport *t, ++ struct descriptor* pos) ++{ ++ return next_descriptor((uint8_t*) t + sizeof(struct dvb_bat_transport), ++ t->transport_descriptors_length, ++ pos); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/bouquet_name_descriptor.h dvb-apps/lib/libucsi/dvb/bouquet_name_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/bouquet_name_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/bouquet_name_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,82 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_BOUQUET_NAME_DESCRIPTOR ++#define _UCSI_DVB_BOUQUET_NAME_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_bouquet_name_descriptor structure. ++ */ ++struct dvb_bouquet_name_descriptor { ++ struct descriptor d; ++ ++ /* uint8_t name[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_bouquet_name_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_bouquet_name_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_bouquet_name_descriptor* ++ dvb_bouquet_name_descriptor_codec(struct descriptor* d) ++{ ++ return (struct dvb_bouquet_name_descriptor*) d; ++} ++ ++/** ++ * Accessor for the name field of a dvb_bouquet_name_descriptor. ++ * ++ * @param d dvb_bouquet_name_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_bouquet_name_descriptor_name(struct dvb_bouquet_name_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_bouquet_name_descriptor); ++} ++ ++/** ++ * Determine the length of the name field of a dvb_bouquet_name_descriptor in bytes. ++ * ++ * @param d dvb_bouquet_name_descriptor pointer. ++ * @return Length of the field in bytes. ++ */ ++static inline int ++ dvb_bouquet_name_descriptor_name_length(struct dvb_bouquet_name_descriptor *d) ++{ ++ return d->d.len; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/cable_delivery_descriptor.h dvb-apps/lib/libucsi/dvb/cable_delivery_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/cable_delivery_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/cable_delivery_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,70 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_CABLE_DELIVERY_DESCRIPTOR ++#define _UCSI_DVB_CABLE_DELIVERY_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_cable_delivery_descriptor structure. ++ */ ++struct dvb_cable_delivery_descriptor { ++ struct descriptor d; ++ ++ uint32_t frequency; // BCD, units 100Hz ++ EBIT2(uint16_t reserved : 12; , ++ uint16_t fec_outer : 4; ); ++ uint8_t modulation; ++ EBIT2(uint32_t symbol_rate : 28; , // BCD, units 100Hz ++ uint32_t fec_inner : 4; ); ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_cable_delivery_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_cable_delivery_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_cable_delivery_descriptor* ++ dvb_cable_delivery_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct dvb_cable_delivery_descriptor) - 2)) ++ return NULL; ++ ++ bswap32((uint8_t*) d + 2); ++ bswap16((uint8_t*) d + 6); ++ bswap32((uint8_t*) d + 9); ++ ++ return (struct dvb_cable_delivery_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ca_identifier_descriptor.h dvb-apps/lib/libucsi/dvb/ca_identifier_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ca_identifier_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/ca_identifier_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,94 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_CA_IDENTIFIER_DESCRIPTOR ++#define _UCSI_DVB_CA_IDENTIFIER_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_ca_identifier_descriptor structure. ++ */ ++struct dvb_ca_identifier_descriptor { ++ struct descriptor d; ++ ++ /* uint16_t ca_system_ids[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_ca_identifier_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_ca_identifier_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_ca_identifier_descriptor* ++ dvb_ca_identifier_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t len = d->len; ++ uint8_t *buf = (uint8_t*) d + 2; ++ uint32_t pos = 0; ++ ++ if (len % 2) ++ return NULL; ++ ++ while(pos < len) { ++ bswap16(buf+pos); ++ pos+=2; ++ } ++ ++ return (struct dvb_ca_identifier_descriptor*) d; ++} ++ ++/** ++ * Accessor for the ca_system_ids field of a dvb_ca_identifier_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint16_t * ++ dvb_ca_identifier_descriptor_ca_system_ids(struct dvb_ca_identifier_descriptor *d) ++{ ++ return (uint16_t *) ((uint8_t *) d + sizeof(struct dvb_ca_identifier_descriptor)); ++} ++ ++/** ++ * Calculate the number of entries in the ca_system_ids field of a dvb_ca_identifier_descriptor. ++ * ++ * @param d dvb_ca_identifier_descriptor pointer. ++ * @return Number of entries. ++ */ ++static inline int ++ dvb_ca_identifier_descriptor_ca_system_ids_count(struct dvb_ca_identifier_descriptor *d) ++{ ++ return d->d.len >> 1; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/cell_frequency_link_descriptor.h dvb-apps/lib/libucsi/dvb/cell_frequency_link_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/cell_frequency_link_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/cell_frequency_link_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,190 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_CELL_FREQUENCY_LINK_DESCRIPTOR ++#define _UCSI_DVB_CELL_FREQUENCY_LINK_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_cell_frequency_link_descriptor structure. ++ */ ++struct dvb_cell_frequency_link_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_cell_frequency_link_cell cells[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the cells field of a dvb_cell_frequency_link_descriptor. ++ */ ++struct dvb_cell_frequency_link_cell { ++ uint16_t cell_id; ++ uint32_t frequency; ++ uint8_t subcell_loop_info_length; ++ /* struct dvb_cell_frequency_link_subcell subcells[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the subcells field of a dvb_cell_frequency_link_cell. ++ */ ++struct dvb_cell_frequency_link_cell_subcell { ++ uint8_t cell_id_extension; ++ uint32_t transposer_frequency; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_cell_frequency_link_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_cell_frequency_link_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_cell_frequency_link_descriptor* ++ dvb_cell_frequency_link_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t pos = 0; ++ uint32_t pos2 = 0; ++ uint8_t* buf = (uint8_t*) d + 2; ++ uint32_t len = d->len; ++ ++ while(pos < len) { ++ struct dvb_cell_frequency_link_cell *e = ++ (struct dvb_cell_frequency_link_cell*) (buf+pos); ++ ++ if ((pos + sizeof(struct dvb_cell_frequency_link_cell)) > len) ++ return NULL; ++ ++ bswap16(buf+pos); ++ bswap32(buf+pos+2); ++ ++ pos += sizeof(struct dvb_cell_frequency_link_cell); ++ ++ if ((pos + e->subcell_loop_info_length) > len) ++ return NULL; ++ ++ if (e->subcell_loop_info_length % sizeof(struct dvb_cell_frequency_link_cell_subcell)) ++ return NULL; ++ ++ pos2 = 0; ++ while(pos2 < e->subcell_loop_info_length) { ++ bswap32(buf+pos+pos2+1); ++ ++ pos2 += sizeof(struct dvb_cell_frequency_link_cell_subcell); ++ } ++ ++ pos += e->subcell_loop_info_length; ++ } ++ ++ return (struct dvb_cell_frequency_link_descriptor*) d; ++} ++ ++/** ++ * Iterator for the cells field of a dvb_cell_frequency_link_descriptor. ++ * ++ * @param d dvb_cell_frequency_link_descriptor pointer. ++ * @param pos Variable holding a pointer to the current dvb_cell_frequency_link_cell. ++ */ ++#define dvb_cell_frequency_link_descriptor_cells_for_each(d, pos) \ ++ for ((pos) = dvb_cell_frequency_link_descriptor_cells_first(d); \ ++ (pos); \ ++ (pos) = dvb_cell_frequency_link_descriptor_cells_next(d, pos)) ++ ++/** ++ * Iterator for the subcells field of a dvb_cell_frequency_link_cell. ++ * ++ * @param cell dvb_cell_frequency_link_cell pointer. ++ * @param pos Variable holding a pointer to the current dvb_cell_frequency_link_cell_subcell. ++ */ ++#define dvb_cell_frequency_link_cell_subcells_for_each(cell, pos) \ ++ for ((pos) = dvb_cell_frequency_link_cell_subcells_first(cell); \ ++ (pos); \ ++ (pos) = dvb_cell_frequency_link_cell_subcells_next(cell, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_cell_frequency_link_cell* ++ dvb_cell_frequency_link_descriptor_cells_first(struct dvb_cell_frequency_link_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_cell_frequency_link_cell *) ++ ((uint8_t*) d + sizeof(struct dvb_cell_frequency_link_descriptor)); ++} ++ ++static inline struct dvb_cell_frequency_link_cell* ++ dvb_cell_frequency_link_descriptor_cells_next(struct dvb_cell_frequency_link_descriptor *d, ++ struct dvb_cell_frequency_link_cell *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + ++ sizeof(struct dvb_cell_frequency_link_cell) + ++ pos->subcell_loop_info_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_cell_frequency_link_cell *) next; ++} ++ ++static inline struct dvb_cell_frequency_link_cell_subcell* ++ dvb_cell_frequency_link_cell_subcells_first(struct dvb_cell_frequency_link_cell *d) ++{ ++ if (d->subcell_loop_info_length == 0) ++ return NULL; ++ ++ return (struct dvb_cell_frequency_link_cell_subcell*) ++ ((uint8_t*) d + sizeof(struct dvb_cell_frequency_link_cell)); ++} ++ ++static inline struct dvb_cell_frequency_link_cell_subcell* ++ dvb_cell_frequency_link_cell_subcells_next(struct dvb_cell_frequency_link_cell *cell, ++ struct dvb_cell_frequency_link_cell_subcell *pos) ++{ ++ uint8_t *end = (uint8_t*) cell + cell->subcell_loop_info_length; ++ uint8_t *next = (uint8_t*) pos + ++ sizeof(struct dvb_cell_frequency_link_cell_subcell); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_cell_frequency_link_cell_subcell *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/cell_list_descriptor.h dvb-apps/lib/libucsi/dvb/cell_list_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/cell_list_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/cell_list_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,201 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_CELL_LIST_DESCRIPTOR ++#define _UCSI_DVB_CELL_LIST_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_cell_list_descriptor structure. ++ */ ++struct dvb_cell_list_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_cell_list_entry cells[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the cells field of a dvb_cell_list_descriptor. ++ */ ++struct dvb_cell_list_entry { ++ uint16_t cell_id; ++ uint16_t cell_latitude; ++ uint16_t cell_longitude; ++ EBIT3(uint32_t cell_extend_of_latitude :12; , ++ uint32_t cell_extend_of_longitude :12; , ++ uint32_t subcell_info_loop_length : 8; ); ++ /* struct dvb_subcell_list_entry subcells[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the subcells field of a dvb_cell_list_entry. ++ */ ++struct dvb_subcell_list_entry { ++ uint8_t cell_id_extension; ++ uint16_t subcell_latitude; ++ uint16_t subcell_longitude; ++ EBIT2(uint32_t subcell_extend_of_latitude :12; , ++ uint32_t subcell_extend_of_longitude :12; ); ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_cell_list_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_cell_list_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_cell_list_descriptor* ++ dvb_cell_list_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t pos = 0; ++ uint32_t pos2 = 0; ++ uint8_t* buf = (uint8_t*) d + 2; ++ uint32_t len = d->len; ++ ++ while(pos < len) { ++ struct dvb_cell_list_entry *e = ++ (struct dvb_cell_list_entry*) (buf+pos); ++ ++ if ((pos + sizeof(struct dvb_cell_list_entry)) > len) ++ return NULL; ++ ++ bswap16(buf+pos); ++ bswap16(buf+pos+2); ++ bswap16(buf+pos+4); ++ bswap32(buf+pos+6); ++ ++ pos += sizeof(struct dvb_cell_list_entry); ++ ++ if ((pos + e->subcell_info_loop_length) > len) ++ return NULL; ++ ++ if (e->subcell_info_loop_length % sizeof(struct dvb_subcell_list_entry)) ++ return NULL; ++ ++ pos2 = 0; ++ while(pos2 < e->subcell_info_loop_length) { ++ bswap16(buf+pos+pos2+1); ++ bswap16(buf+pos+pos2+3); ++ bswap24(buf+pos+pos2+5); ++ ++ pos2 += sizeof(struct dvb_subcell_list_entry); ++ } ++ ++ pos += e->subcell_info_loop_length; ++ } ++ ++ return (struct dvb_cell_list_descriptor*) d; ++} ++ ++/** ++ * Iterator for the cells field of a dvb_cell_list_descriptor. ++ * ++ * @param d dvb_cell_list_descriptor pointer. ++ * @param pos Variable holding a pointer to the current dvb_cell_list_entry. ++ */ ++#define dvb_cell_list_descriptor_cells_for_each(d, pos) \ ++ for ((pos) = dvb_cell_list_descriptor_cells_first(d); \ ++ (pos); \ ++ (pos) = dvb_cell_list_descriptor_cells_next(d, pos)) ++ ++/** ++ * Iterator for the subcells field of a dvb_cell_list_entry. ++ * ++ * @param cell dvb_cell_list_entry pointer. ++ * @param pos Variable holding a pointer to the current dvb_subcell_list_entry. ++ */ ++#define dvb_cell_list_entry_subcells_for_each(cell, pos) \ ++ for ((pos) = dvb_cell_list_entry_subcells_first(cell); \ ++ (pos); \ ++ (pos) = dvb_cell_list_entry_subcells_next(cell, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_cell_list_entry* ++ dvb_cell_list_descriptor_cells_first(struct dvb_cell_list_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_cell_list_entry *) ++ ((uint8_t*) d + sizeof(struct dvb_cell_list_descriptor)); ++} ++ ++static inline struct dvb_cell_list_entry* ++ dvb_cell_list_descriptor_cells_next(struct dvb_cell_list_descriptor *d, ++ struct dvb_cell_list_entry *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + ++ sizeof(struct dvb_cell_list_entry) + ++ pos->subcell_info_loop_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_cell_list_entry *) next; ++} ++ ++static inline struct dvb_subcell_list_entry* ++ dvb_cell_list_entry_subcells_first(struct dvb_cell_list_entry *d) ++{ ++ if (d->subcell_info_loop_length == 0) ++ return NULL; ++ ++ return (struct dvb_subcell_list_entry*) ++ ((uint8_t*) d + sizeof(struct dvb_cell_list_entry)); ++} ++ ++static inline struct dvb_subcell_list_entry* ++ dvb_cell_list_entry_subcells_next(struct dvb_cell_list_entry *d, ++ struct dvb_subcell_list_entry *pos) ++{ ++ uint8_t *next = (uint8_t*) pos + sizeof(struct dvb_subcell_list_entry); ++ uint8_t *end = (uint8_t*) d + ++ sizeof(struct dvb_cell_list_entry) + ++ d->subcell_info_loop_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_subcell_list_entry *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/component_descriptor.h dvb-apps/lib/libucsi/dvb/component_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/component_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/component_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,147 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_COMPONENT_DESCRIPTOR ++#define _UCSI_DVB_COMPONENT_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * Possible values for stream_content. ++ */ ++enum { ++ DVB_STREAM_CONTENT_VIDEO = 0x01, ++ DVB_STREAM_CONTENT_AUDIO = 0x02, ++ DVB_STREAM_CONTENT_SUBTITLE = 0x03, ++ DVB_STREAM_CONTENT_AC3 = 0x04, ++}; ++ ++/** ++ * Possible values for component_type. ++ */ ++enum { ++ DVB_COMPONENT_TYPE_VIDEO_43_25Hz = 0x01, ++ DVB_COMPONENT_TYPE_VIDEO_169_PAN_25Hz = 0x02, ++ DVB_COMPONENT_TYPE_VIDEO_169_NOPAN_25Hz = 0x03, ++ DVB_COMPONENT_TYPE_VIDEO_GT169_25Hz = 0x04, ++ ++ DVB_COMPONENT_TYPE_VIDEO_43_30Hz = 0x05, ++ DVB_COMPONENT_TYPE_VIDEO_169_PAN_30Hz = 0x06, ++ DVB_COMPONENT_TYPE_VIDEO_169_NOPAN_30Hz = 0x07, ++ DVB_COMPONENT_TYPE_VIDEO_GT169_30Hz = 0x08, ++ ++ DVB_COMPONENT_TYPE_HDVIDEO_43_25Hz = 0x09, ++ DVB_COMPONENT_TYPE_HDVIDEO_169_PAN_25Hz = 0x0a, ++ DVB_COMPONENT_TYPE_HDVIDEO_169_NOPAN_25Hz = 0x0b, ++ DVB_COMPONENT_TYPE_HDVIDEO_GT169_25Hz = 0x0c, ++ ++ DVB_COMPONENT_TYPE_HDVIDEO_43_30Hz = 0x0d, ++ DVB_COMPONENT_TYPE_HDVIDEO_169_PAN_30Hz = 0x0e, ++ DVB_COMPONENT_TYPE_HDVIDEO_169_NOPAN_30Hz = 0x0f, ++ DVB_COMPONENT_TYPE_HDVIDEO_GT169_30Hz = 0x10, ++ ++ DVB_COMPONENT_TYPE_AUDIO_SINGLE_MONO = 0x01, ++ DVB_COMPONENT_TYPE_AUDIO_DUAL_MONO = 0x02, ++ DVB_COMPONENT_TYPE_AUDIO_STEREO = 0x03, ++ DVB_COMPONENT_TYPE_AUDIO_MULTI_LINGUAL_MULTI_CHAN= 0x04, ++ DVB_COMPONENT_TYPE_AUDIO_SURROUND = 0x05, ++ DVB_COMPONENT_TYPE_AUDIO_VISUAL_IMPAIRED = 0x40, ++ DVB_COMPONENT_TYPE_AUDIO_HARDHEAR = 0x41, ++ DVB_COMPONENT_TYPE_AUDIO_SUPPLEMENTARY = 0x42, ++ ++ DVB_COMPONENT_TYPE_SUBTITLE_TELETEXT = 0x01, ++ DVB_COMPONENT_TYPE_SUBTITLE_ASSOC_TELETEXT = 0x02, ++ DVB_COMPONENT_TYPE_SUBTITLE_VBI = 0x03, ++ DVB_COMPONENT_TYPE_SUBTITLE_DVB = 0x10, ++ DVB_COMPONENT_TYPE_SUBTITLE_DVB_43 = 0x11, ++ DVB_COMPONENT_TYPE_SUBTITLE_DVB_169 = 0x12, ++ DVB_COMPONENT_TYPE_SUBTITLE_DVB_2211 = 0x13, ++ DVB_COMPONENT_TYPE_SUBTITLE_DVB_HARDHEAR = 0x20, ++ DVB_COMPONENT_TYPE_SUBTITLE_DVB_HARDHEAR_43 = 0x21, ++ DVB_COMPONENT_TYPE_SUBTITLE_DVB_HARDHEAR_169 = 0x22, ++ DVB_COMPONENT_TYPE_SUBTITLE_DVB_HARDHEAR_2211 = 0x23, ++}; ++ ++/** ++ * dvb_component_descriptor structure. ++ */ ++struct dvb_component_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint8_t reserved : 4; , ++ uint8_t stream_content : 4; ); ++ uint8_t component_type; ++ uint8_t component_tag; ++ iso639lang_t language_code; ++ /* uint8_t text[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_component_descriptor. ++ * ++ * @param d Pointer to a generic descriptor. ++ * @return dvb_component_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_component_descriptor* ++ dvb_component_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len < (sizeof(struct dvb_component_descriptor) - 2)) ++ return NULL; ++ ++ return (struct dvb_component_descriptor*) d; ++} ++ ++/** ++ * Accessor for the text field of a dvb_component_descriptor. ++ * ++ * @param d dvb_component_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_component_descriptor_text(struct dvb_component_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_component_descriptor); ++} ++ ++/** ++ * Determine the length of the text field of a dvb_component_descriptor. ++ * ++ * @param d dvb_component_descriptor pointer. ++ * @return Length of the field in bytes. ++ */ ++static inline int ++ dvb_component_descriptor_text_length(struct dvb_component_descriptor *d) ++{ ++ return d->d.len - 6; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/content_descriptor.h dvb-apps/lib/libucsi/dvb/content_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/content_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/content_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,116 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_CONTENT_DESCRIPTOR ++#define _UCSI_DVB_CONTENT_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++// FIXME: the nibbles ++ ++/** ++ * dvb_content_descriptor structure. ++ */ ++struct dvb_content_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_content_nibble nibbles[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the nibbles field of a dvb_content_descriptor. ++ */ ++struct dvb_content_nibble { ++ EBIT2(uint8_t content_nibble_level_1 : 4; , ++ uint8_t content_nibble_level_2 : 4; ); ++ EBIT2(uint8_t user_nibble_1 : 4; , ++ uint8_t user_nibble_2 : 4; ); ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_content_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_content_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_content_descriptor* ++ dvb_content_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len % sizeof(struct dvb_content_nibble)) ++ return NULL; ++ ++ return (struct dvb_content_descriptor*) d; ++} ++ ++/** ++ * Iterator for the nibbles field of a dvb_content_descriptor. ++ * ++ * @param d dvb_content_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_content_nibble. ++ */ ++#define dvb_content_descriptor_nibbles_for_each(d, pos) \ ++ for ((pos) = dvb_content_descriptor_nibbles_first(d); \ ++ (pos); \ ++ (pos) = dvb_content_descriptor_nibbles_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_content_nibble* ++ dvb_content_descriptor_nibbles_first(struct dvb_content_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_content_nibble *) ++ ((uint8_t*) d + sizeof(struct dvb_content_descriptor)); ++} ++ ++static inline struct dvb_content_nibble* ++ dvb_content_descriptor_nibbles_next(struct dvb_content_descriptor *d, ++ struct dvb_content_nibble *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_content_nibble); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_content_nibble *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/content_identifier_descriptor.h dvb-apps/lib/libucsi/dvb/content_identifier_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/content_identifier_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/content_identifier_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,233 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_CONTENT_IDENTIFIER_DESCRIPTOR ++#define _UCSI_DVB_CONTENT_IDENTIFIER_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++ ++/** ++ * Possible values for the crid_type. ++ */ ++enum { ++ DVB_CRID_TYPE_NONE = 0x00, ++ DVB_CRID_TYPE_ITEM = 0x01, ++ DVB_CRID_TYPE_SERIES = 0x02, ++ DVB_CRID_TYPE_RECOMMENDATION = 0x03, ++}; ++ ++/** ++ * Possible values for the crid_location. ++ */ ++enum { ++ DVB_CRID_LOCATION_THIS_DESCRIPTOR = 0x00, ++ DVB_CRID_LOCATION_CIT = 0x01, ++}; ++ ++/** ++ * dvb_content_identifier_descriptor structure. ++ */ ++struct dvb_content_identifier_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_content_identifier_entry entries[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the entries field of a dvb_content_identifier_descriptor. ++ */ ++struct dvb_content_identifier_entry { ++ EBIT2(uint8_t crid_type : 6; , ++ uint8_t crid_location : 2; ); ++ /* struct dvb_content_identifier_data_00 data0 */ ++ /* struct dvb_content_identifier_data_01 data1 */ ++} __ucsi_packed; ++ ++/** ++ * The data if crid_location == 0 ++ */ ++struct dvb_content_identifier_entry_data_0 { ++ uint8_t crid_length; ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++/** ++ * The data if crid_location == 1 ++ */ ++struct dvb_content_identifier_entry_data_1 { ++ uint16_t crid_ref; ++} __ucsi_packed; ++ ++ ++/** ++ * Process a dvb_content_identifier_descriptor. ++ * ++ * @param d Generic descriptor. ++ * @return dvb_content_identifier_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_content_identifier_descriptor* ++ dvb_content_identifier_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t len = d->len + 2; ++ uint32_t pos = 2; ++ uint8_t *buf = (uint8_t*) d; ++ ++ while(pos < len) { ++ struct dvb_content_identifier_entry *e = ++ (struct dvb_content_identifier_entry*) (buf + pos); ++ ++ if (len < (pos+1)) ++ return NULL; ++ pos++; ++ ++ switch(e->crid_location) { ++ case 0: ++ if (len < (pos + 1)) ++ return NULL; ++ if (len < (pos + 1 + buf[pos])) ++ return NULL; ++ pos += 1 + buf[pos]; ++ break; ++ ++ case 1: ++ if (len < (pos+2)) ++ return NULL; ++ bswap16(buf+pos); ++ break; ++ } ++ } ++ ++ if (pos != len) ++ return NULL; ++ ++ return (struct dvb_content_identifier_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries field of a dvb_content_identifier_descriptor. ++ * ++ * @param d dvb_content_identifier_descriptor pointer. ++ * @param pos Variable holding a pointer to the current dvb_content_identifier_entry. ++ */ ++#define dvb_content_identifier_descriptor_entries_for_each(d, pos) \ ++ for ((pos) = dvb_content_identifier_descriptor_entries_first(d); \ ++ (pos); \ ++ (pos) = dvb_content_identifier_descriptor_entries_next(d, pos)) ++ ++/** ++ * Accessor for the data0 field of a dvb_content_identifier_entry. ++ * ++ * @param d dvb_content_identifier_entry pointer. ++ * @return Pointer, or NULL on error. ++ */ ++static inline struct dvb_content_identifier_entry_data_0* ++ dvb_content_identifier_entry_data_0(struct dvb_content_identifier_entry *d) ++{ ++ if (d->crid_location != 0) ++ return NULL; ++ return (struct dvb_content_identifier_entry_data_0*) ++ ((uint8_t*) d + sizeof(struct dvb_content_identifier_entry)); ++} ++/** ++ * Accessor for the data field of a dvb_content_identifier_entry_data_0. ++ * ++ * @param d dvb_content_identifier_entry_data_0 pointer. ++ * @return Pointer, or NULL on error. ++ */ ++static inline uint8_t* ++ dvb_content_identifier_entry_data_0_data(struct dvb_content_identifier_entry_data_0 *d) ++{ ++ return ((uint8_t*) d + sizeof(struct dvb_content_identifier_entry_data_0)); ++} ++ ++/** ++ * Accessor for the data1 field of a dvb_content_identifier_entry. ++ * ++ * @param d dvb_content_identifier_entry pointer. ++ * @return Pointer, or NULL on error. ++ */ ++static inline struct dvb_content_identifier_entry_data_1* ++ dvb_content_identifier_entry_data_1(struct dvb_content_identifier_entry *d) ++{ ++ if (d->crid_location != 1) ++ return NULL; ++ return (struct dvb_content_identifier_entry_data_1*) ++ ((uint8_t*) d + sizeof(struct dvb_content_identifier_entry)); ++} ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_content_identifier_entry* ++ dvb_content_identifier_descriptor_entries_first(struct dvb_content_identifier_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_content_identifier_entry *) ++ ((uint8_t*) d + sizeof(struct dvb_content_identifier_descriptor)); ++} ++ ++static inline struct dvb_content_identifier_entry* ++ dvb_content_identifier_descriptor_entries_next(struct dvb_content_identifier_descriptor *d, ++ struct dvb_content_identifier_entry *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_content_identifier_entry); ++ ++ if (next >= end) ++ return NULL; ++ ++ switch(pos->crid_location) { ++ case 0: ++ if ((next+2) >= end) ++ return NULL; ++ if ((next+2+next[1]) >= end) ++ return NULL; ++ break; ++ ++ case 1: ++ if ((next+3) >= end) ++ return NULL; ++ break; ++ } ++ ++ return (struct dvb_content_identifier_entry*) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/country_availability_descriptor.h dvb-apps/lib/libucsi/dvb/country_availability_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/country_availability_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/country_availability_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,120 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_COUNTRY_AVAILABILITY_DESCRIPTOR ++#define _UCSI_DVB_COUNTRY_AVAILABILITY_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * dvb_country_availability_descriptor structure. ++ */ ++struct dvb_country_availability_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint8_t country_availability_flag : 1; , ++ uint8_t reserved : 7; ); ++ /* struct dvb_country_availability_entry countries[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the countries field of a dvb_country_availability_descriptor. ++ */ ++struct dvb_country_availability_entry { ++ iso639country_t country_code; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_country_availability_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_country_availability_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_country_availability_descriptor* ++ dvb_country_availability_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t len = d->len; ++ ++ if (len < (sizeof(struct dvb_country_availability_descriptor) - 2)) ++ return NULL; ++ ++ if ((len - 1) % sizeof(struct dvb_country_availability_entry)) ++ return NULL; ++ ++ return (struct dvb_country_availability_descriptor*) d; ++} ++ ++/** ++ * Iterator for the countries field of a dvb_country_availability_descriptor. ++ * ++ * @param d dvb_country_availability_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_country_availability_entry. ++ */ ++#define dvb_country_availability_descriptor_countries_for_each(d, pos) \ ++ for ((pos) = dvb_country_availability_descriptor_countries_first(d); \ ++ (pos); \ ++ (pos) = dvb_country_availability_descriptor_countries_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_country_availability_entry* ++ dvb_country_availability_descriptor_countries_first(struct dvb_country_availability_descriptor *d) ++{ ++ if (d->d.len == 1) ++ return NULL; ++ ++ return (struct dvb_country_availability_entry *) ++ ((uint8_t*) d + sizeof(struct dvb_country_availability_descriptor)); ++} ++ ++static inline struct dvb_country_availability_entry* ++ dvb_country_availability_descriptor_countries_next(struct dvb_country_availability_descriptor *d, ++ struct dvb_country_availability_entry *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_country_availability_entry); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_country_availability_entry *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/data_broadcast_descriptor.h dvb-apps/lib/libucsi/dvb/data_broadcast_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/data_broadcast_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/data_broadcast_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,139 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_DATA_BROADCAST_DESCRIPTOR ++#define _UCSI_DVB_DATA_BROADCAST_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * dvb_data_broadcast_descriptor structure. ++ */ ++struct dvb_data_broadcast_descriptor { ++ struct descriptor d; ++ ++ uint16_t data_broadcast_id; ++ uint8_t component_tag; ++ uint8_t selector_length; ++ /* uint8_t selector[] */ ++ /* struct dvb_data_broadcast_descriptor_part2 part2 */ ++} __ucsi_packed; ++ ++/** ++ * Second part of a dvb_data_broadcast_descriptor following the variable length selector field. ++ */ ++struct dvb_data_broadcast_descriptor_part2 { ++ iso639lang_t language_code; ++ uint8_t text_length; ++ /* uint8_t text[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_data_broadcast_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_data_broadcast_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_data_broadcast_descriptor* ++ dvb_data_broadcast_descriptor_codec(struct descriptor* d) ++{ ++ struct dvb_data_broadcast_descriptor *p = ++ (struct dvb_data_broadcast_descriptor *) d; ++ struct dvb_data_broadcast_descriptor_part2 *p2; ++ uint8_t* buf = (uint8_t*) d + 2; ++ uint32_t pos = sizeof(struct dvb_data_broadcast_descriptor) - 2; ++ uint32_t len = d->len; ++ ++ if (pos > len) ++ return NULL; ++ ++ bswap16(buf + 2); ++ ++ pos += p->selector_length; ++ ++ if (pos > len) ++ return NULL; ++ ++ p2 = (struct dvb_data_broadcast_descriptor_part2*) (buf + 2 + pos); ++ ++ pos += sizeof(struct dvb_data_broadcast_descriptor_part2); ++ ++ if (pos > len) ++ return NULL; ++ ++ pos += p2->text_length; ++ ++ if (pos != len) ++ return NULL; ++ ++ return p; ++} ++ ++/** ++ * Accessor for the selector field of a dvb_data_broadcast_descriptor. ++ * ++ * @param d dvb_data_broadcast_descriptor pointer. ++ * @return pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_data_broadcast_descriptor_selector(struct dvb_data_broadcast_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_data_broadcast_descriptor); ++} ++ ++/** ++ * Accessor for the second part of a dvb_data_broadcast_descriptor. ++ * ++ * @param d dvb_data_broadcast_descriptor pointer. ++ * @return dvb_data_broadcast_descriptor_part2 pointer. ++ */ ++static inline struct dvb_data_broadcast_descriptor_part2 * ++ dvb_data_broadcast_descriptor_part2(struct dvb_data_broadcast_descriptor *d) ++{ ++ return (struct dvb_data_broadcast_descriptor_part2*) ++ ((uint8_t*) d + sizeof(struct dvb_data_broadcast_descriptor) + ++ d->selector_length); ++} ++ ++/** ++ * Accessor for the text field in a dvb_data_broadcast_descriptor_part2. ++ * ++ * @param d dvb_data_broadcast_descriptor_part2 pointer. ++ * @return pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_data_broadcast_descriptor_part2_text(struct dvb_data_broadcast_descriptor_part2 *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_data_broadcast_descriptor_part2); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/data_broadcast_id_descriptor.h dvb-apps/lib/libucsi/dvb/data_broadcast_id_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/data_broadcast_id_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/data_broadcast_id_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,221 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_DATA_BROADCAST_ID_DESCRIPTOR ++#define _UCSI_DVB_DATA_BROADCAST_ID_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * Possible values for data_broadcast_id. ++ */ ++enum { ++ DVB_BROADCAST_ID_DATA_PIPE = 0X0001, ++ DVB_BROADCAST_ID_ASYNCHRONOUS_DATA_STREAM = 0X0002, ++ DVB_BROADCAST_ID_SYNCHRONOUS_DATA_STREAM = 0X0003, ++ DVB_BROADCAST_ID_SYNCHRONISED_DATA_STREAM = 0X0004, ++ DVB_BROADCAST_ID_MULTI_PROTOCOL_ENCAPSULATION = 0X0005, ++ DVB_BROADCAST_ID_DATA_CAROUSEL = 0X0006, ++ DVB_BROADCAST_ID_OBJECT_CAROUSEL = 0X0007, ++ DVB_BROADCAST_ID_DVB_ATM_STREAMS = 0X0008, ++ DVB_BROADCAST_ID_HIGHER_PROTOCOLS = 0X0009, ++ DVB_BROADCAST_ID_SOFTWARE_UPDATE = 0x000A, ++ DVB_BROADCAST_ID_IP_MAC_NOTIFICATION_TABLE = 0x000B, ++}; ++ ++/** ++ * dvb_data_broadcast_id_descriptor structure. ++ */ ++struct dvb_data_broadcast_id_descriptor { ++ struct descriptor d; ++ ++ uint16_t data_broadcast_id; ++ /* uint8_t id_selector_byte[] */ ++} __ucsi_packed; ++ ++/** ++ * id_selector_byte for 0x000b data_broadcast_id (IP/MAC Notification Table). ++ */ ++struct dvb_id_selector_byte_000b { ++ uint8_t platform_id_data_length; ++ /* struct dvb_ip_mac_notification_info infos[] */ ++ /* uint8_t private_data[] */ ++} __ucsi_packed; ++ ++/** ++ * Entries in the infos field of a dvb_id_selector_byte_0b. ++ */ ++struct dvb_ip_mac_notification_info { ++ EBIT2(uint32_t platform_id : 24; , ++ uint8_t action_type : 8; ); ++ EBIT3(uint8_t reserved : 2; , ++ uint8_t INT_versioning_flag : 1; , ++ uint8_t INT_version : 5; ); ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_data_broadcast_id_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return dvb_data_broadcast_id_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_data_broadcast_id_descriptor* ++ dvb_data_broadcast_id_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len < (sizeof(struct dvb_data_broadcast_id_descriptor) - 2)) ++ return NULL; ++ ++ bswap16((uint8_t*) d + 2); ++ ++ return (struct dvb_data_broadcast_id_descriptor*) d; ++} ++ ++/** ++ * Accessor for the selector_byte field of a dvb_data_broadcast_id_descriptor. ++ * ++ * @param d dvb_data_broadcast_id_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_data_broadcast_id_descriptor_id_selector_byte(struct dvb_data_broadcast_id_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_data_broadcast_id_descriptor); ++} ++ ++/** ++ * Determine the length of the selector_byte field of a dvb_data_broadcast_id_descriptor. ++ * ++ * @param d dvb_data_broadcast_id_descriptor pointer. ++ * @return Length of the field in bytes. ++ */ ++static inline int ++ dvb_data_broadcast_id_descriptor_id_selector_byte_length(struct dvb_data_broadcast_id_descriptor *d) ++{ ++ return d->d.len - 2; ++} ++ ++/** ++ * Accessor for a dvb_id_selector_byte_000b pointer. ++ * ++ * @param d dvb_data_broadcast_id_descriptor pointer. ++ * @return Pointer to the data field. ++ */ ++static inline struct dvb_id_selector_byte_000b * ++ dvb_id_selector_byte_000b(struct dvb_data_broadcast_id_descriptor *d) ++{ ++ if (d->data_broadcast_id != DVB_BROADCAST_ID_IP_MAC_NOTIFICATION_TABLE) ++ return NULL; ++ return (struct dvb_id_selector_byte_000b *) dvb_data_broadcast_id_descriptor_id_selector_byte(d); ++} ++ ++/** ++ * Iterator for the dvb_ip_mac_notification_info field of a dvb_id_selector_byte_000b. ++ * ++ * @param id_selector_byte dvb_id_selector_byte_000b pointer. ++ * @param pos Variable containing a pointer to the current dvb_ip_mac_notification_info. ++ */ ++#define dvb_id_selector_byte_000b_ip_mac_notification_info_for_each(id_selector_byte, pos) \ ++ for ((pos) = dvb_ip_mac_notification_info_first(id_selector_byte); \ ++ (pos); \ ++ (pos) = dvb_ip_mac_notification_info_next(id_selector_byte, pos)) ++ ++/** ++ * Length of the private_data field of a dvb_id_selector_byte_000b. ++ * ++ * @param d descriptor pointer. ++ * @param i dvb_id_selector_byte_000b pointer. ++ * @return Length of the field. ++ */ ++static inline uint8_t ++ dvb_id_selector_byte_000b_private_data_length(struct descriptor *d, ++ struct dvb_id_selector_byte_000b *i) ++{ ++ return (uint8_t) (d->len - ++ sizeof(struct descriptor) - ++ i->platform_id_data_length - ++ sizeof(struct dvb_id_selector_byte_000b)); ++} ++ ++/** ++ * Accessor for the private_data field of a dvb_id_selector_byte_000b. ++ * ++ * @param d descriptor pointer. ++ * @param i dvb_id_selector_byte_000b pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_id_selector_byte_000b_private_data(struct descriptor *d, ++ struct dvb_id_selector_byte_000b *i) ++{ ++ if (dvb_id_selector_byte_000b_private_data_length(d, i) <= 0) ++ return NULL; ++ ++ return (uint8_t *) i + i->platform_id_data_length + sizeof(struct dvb_id_selector_byte_000b); ++} ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_ip_mac_notification_info * ++ dvb_ip_mac_notification_info_first(struct dvb_id_selector_byte_000b *d) ++{ ++ if (d->platform_id_data_length == 0) ++ return NULL; ++ ++ bswap32((uint8_t *) d + sizeof(struct dvb_id_selector_byte_000b)); ++ ++ return (struct dvb_ip_mac_notification_info *) ((uint8_t *) d + sizeof(struct dvb_id_selector_byte_000b)); ++} ++ ++static inline struct dvb_ip_mac_notification_info * ++ dvb_ip_mac_notification_info_next(struct dvb_id_selector_byte_000b *d, ++ struct dvb_ip_mac_notification_info *pos) ++{ ++ uint8_t *end = (uint8_t *) d + d->platform_id_data_length; ++ uint8_t *next = (uint8_t *) pos + ++ sizeof(struct dvb_id_selector_byte_000b) + ++ sizeof(struct dvb_ip_mac_notification_info); ++ ++ if (next >= end) ++ return NULL; ++ ++ bswap32(next); ++ ++ return (struct dvb_ip_mac_notification_info *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif ++ ++#include +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/default_authority_descriptor.h dvb-apps/lib/libucsi/dvb/default_authority_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/default_authority_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/default_authority_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,82 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_DEFAULT_AUTHORITY_DESCRIPTOR ++#define _UCSI_DVB_DEFAULT_AUTHORITY_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_default_authority_descriptor structure. ++ */ ++struct dvb_default_authority_descriptor { ++ struct descriptor d; ++ ++ /* char name[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_default_authority_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_default_authority_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_default_authority_descriptor* ++ dvb_default_authority_descriptor_codec(struct descriptor* d) ++{ ++ return (struct dvb_default_authority_descriptor*) d; ++} ++ ++/** ++ * Accessor for the name field in a dvb_default_authority_descriptor. ++ * ++ * @param d dvb_default_authority_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_default_authority_descriptor_name(struct dvb_default_authority_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_default_authority_descriptor); ++} ++ ++/** ++ * Calculate the length of the name field in a dvb_default_authority_descriptor. ++ * ++ * @param d dvb_default_authority_descriptor pointer. ++ * @return Length of the field in bytes. ++ */ ++static inline int ++ dvb_default_authority_descriptor_name_length(struct dvb_default_authority_descriptor *d) ++{ ++ return d->d.len; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/descriptor.h dvb-apps/lib/libucsi/dvb/descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,230 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_DESCRIPTOR_H ++#define _UCSI_DVB_DESCRIPTOR_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/** ++ * The following are disabled because support is incomplete just now. ++ */ ++/* ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++*/ ++ ++/** ++ * The following are not implemented just now ++ */ ++/* ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++*/ ++ ++/** ++ * Enumeration of DVB descriptor tags. ++ */ ++enum dvb_descriptor_tag { ++ dtag_dvb_network_name = 0x40, ++ dtag_dvb_service_list = 0x41, ++ dtag_dvb_stuffing = 0x42, ++ dtag_dvb_satellite_delivery_system = 0x43, ++ dtag_dvb_cable_delivery_system = 0x44, ++ dtag_dvb_vbi_data = 0x45, ++ dtag_dvb_vbi_teletext = 0x46, ++ dtag_dvb_bouquet_name = 0x47, ++ dtag_dvb_service = 0x48, ++ dtag_dvb_country_availability = 0x49, ++ dtag_dvb_linkage = 0x4a, ++ dtag_dvb_nvod_reference = 0x4b, ++ dtag_dvb_time_shifted_service = 0x4c, ++ dtag_dvb_short_event = 0x4d, ++ dtag_dvb_extended_event = 0x4e, ++ dtag_dvb_time_shifted_event = 0x4f, ++ dtag_dvb_component = 0x50, ++ dtag_dvb_mosaic = 0x51, ++ dtag_dvb_stream_identifier = 0x52, ++ dtag_dvb_ca_identifier = 0x53, ++ dtag_dvb_content = 0x54, ++ dtag_dvb_parental_rating = 0x55, ++ dtag_dvb_teletext = 0x56, ++ dtag_dvb_telephone = 0x57, ++ dtag_dvb_local_time_offset = 0x58, ++ dtag_dvb_subtitling = 0x59, ++ dtag_dvb_terrestial_delivery_system = 0x5a, ++ dtag_dvb_multilingual_network_name = 0x5b, ++ dtag_dvb_multilingual_bouquet_name = 0x5c, ++ dtag_dvb_multilingual_service_name = 0x5d, ++ dtag_dvb_multilingual_component = 0x5e, ++ dtag_dvb_private_data_specifier = 0x5f, ++ dtag_dvb_service_move = 0x60, ++ dtag_dvb_short_smoothing_buffer = 0x61, ++ dtag_dvb_frequency_list = 0x62, ++ dtag_dvb_partial_transport_stream = 0x63, ++ dtag_dvb_data_broadcast = 0x64, ++ dtag_dvb_scrambling = 0x65, ++ dtag_dvb_data_broadcast_id = 0x66, ++ dtag_dvb_transport_stream = 0x67, ++ dtag_dvb_dsng = 0x68, ++ dtag_dvb_pdc = 0x69, ++ dtag_dvb_ac3 = 0x6a, ++ dtag_dvb_ancillary_data = 0x6b, ++ dtag_dvb_cell_list = 0x6c, ++ dtag_dvb_cell_frequency_link = 0x6d, ++ dtag_dvb_announcement_support = 0x6e, ++ dtag_dvb_application_signalling = 0x6f, ++ dtag_dvb_adaptation_field_data = 0x70, ++ dtag_dvb_service_identifier = 0x71, ++ dtag_dvb_service_availability = 0x72, ++ dtag_dvb_default_authority = 0x73, ++ dtag_dvb_related_content = 0x74, ++ dtag_dvb_tva_id = 0x75, ++ dtag_dvb_content_identifier = 0x76, ++ dtag_dvb_time_slice_fec_identifier = 0x77, ++ dtag_dvb_ecm_repetition_rate = 0x78, ++ dtag_dvb_s2_satellite_delivery_descriptor= 0x79, ++ dtag_dvb_enhanced_ac3_descriptor = 0x7a, ++ dtag_dvb_dts_descriptor = 0x7b, ++ dtag_dvb_aac_descriptor = 0x7c, ++ dtag_dvb_extension_descriptor = 0x7f, ++ ++ /* descriptors which may only appear in an RNT */ ++ dtag_dvb_rnt_rar_over_dvb_stream = 0x40, ++ dtag_dvb_rnt_rar_over_ip = 0x41, ++ dtag_dvb_rnt_rnt_scan = 0x42, ++ ++ /* descriptors which may only appear in an AIT */ ++ dtag_dvb_ait_application = 0x00, ++ dtag_dvb_ait_application_name = 0x01, ++ dtag_dvb_ait_transport_protocol = 0x02, ++ dtag_dvb_ait_dvb_j_application = 0x03, ++ dtag_dvb_ait_dvb_j_application_location = 0x04, ++ dtag_dvb_ait_external_application_authorisation = 0x05, ++ dtag_dvb_ait_dvb_html_application = 0x08, ++ dtag_dvb_ait_dvb_html_application_location = 0x09, ++ dtab_dvb_ait_dvb_html_application_boundary = 0x0a, ++ dtag_dvb_ait_application_icons = 0x0b, ++ dtag_dvb_ait_prefetch = 0x0c, ++ dtag_dvb_ait_dii_location = 0x0d, ++ dtag_dvb_ait_ip_signalling = 0x11, ++ ++ /* descriptors which may only appear in INT */ ++ dtag_dvb_target_ip_address = 0x09, ++ dtag_dvb_target_ipv6_address = 0x0a, ++ dtag_dvb_ip_mac_platform_name = 0x0c, ++ dtag_dvb_ip_mac_platform_provider_name = 0x0d, ++ dtag_dvb_target_ip_slash = 0x0f, ++ dtag_dvb_target_ip_source_slash = 0x10, ++ dtag_dvb_target_ipv6_slash = 0x11, ++ dtag_dvb_target_ipv6_source_slash = 0x12, ++ dtag_dvb_ip_mac_stream_location = 0x13, ++ ++}; ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/dit_section.c dvb-apps/lib/libucsi/dvb/dit_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/dit_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/dit_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,32 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct dvb_dit_section * dvb_dit_section_codec(struct section * section) ++{ ++ struct dvb_dit_section * ret = (struct dvb_dit_section *)section; ++ ++ if (section->length < 1) ++ return NULL; ++ ++ return ret; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/dit_section.h dvb-apps/lib/libucsi/dvb/dit_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/dit_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/dit_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,54 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_DIT_SECTION_H ++#define _UCSI_DVB_DIT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * dvb_dit_section structure. ++ */ ++struct dvb_dit_section { ++ struct section head; ++ ++ EBIT2(uint8_t transition_flag : 1; , ++ uint8_t reserved : 7; ); ++}; ++ ++/** ++ * Process a dvb_dit_section. ++ * ++ * @param section Pointer to a generic section header. ++ * @return Pointer to a dvb_dit_section, or NULL on error. ++ */ ++struct dvb_dit_section * dvb_dit_section_codec(struct section *section); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/dsng_descriptor.h dvb-apps/lib/libucsi/dvb/dsng_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/dsng_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/dsng_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,80 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_DSNG_DESCRIPTOR ++#define _UCSI_DVB_DSNG_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_dsng_descriptor structure. ++ */ ++struct dvb_dsng_descriptor { ++ struct descriptor d; ++ ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_dsng_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return Pointer to a dvb_dsng_descriptor, or NULL on error. ++ */ ++static inline struct dvb_dsng_descriptor* ++ dvb_dsng_descriptor_codec(struct descriptor* d) ++{ ++ return (struct dvb_dsng_descriptor*) d; ++} ++ ++/** ++ * Accessor for the data field in a dvb_dsng_descriptor. ++ * ++ * @param d dvb_dsng_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t *dvb_dsng_descriptor_data(struct dvb_dsng_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_dsng_descriptor); ++} ++ ++/** ++ * Determine the length of the data field in a dvb_dsng_descriptor. ++ * ++ * @param d dvb_dsng_descriptor pointer. ++ * @return Length of the field in bytes. ++ */ ++static inline int dvb_dsng_descriptor_data_length(struct dvb_dsng_descriptor *d) ++{ ++ return d->d.len; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/eit_section.c dvb-apps/lib/libucsi/dvb/eit_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/eit_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/eit_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,63 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct dvb_eit_section *dvb_eit_section_codec(struct section_ext * ext) ++{ ++ uint8_t * buf = (uint8_t *) ext; ++ size_t pos = sizeof(struct section_ext); ++ size_t len = section_ext_length(ext); ++ ++ if (len < sizeof(struct dvb_eit_section)) ++ return NULL; ++ ++ bswap16(buf + pos); ++ pos += 2; ++ bswap16(buf + pos); ++ pos += 4; ++ ++ while (pos < len) { ++ struct dvb_eit_event * event = ++ (struct dvb_eit_event *) (buf + pos); ++ ++ if ((pos + sizeof(struct dvb_eit_event)) > len) ++ return NULL; ++ ++ bswap16(buf + pos); ++ bswap16(buf + pos + 10); ++ ++ pos += sizeof(struct dvb_eit_event); ++ ++ if ((pos + event->descriptors_loop_length) > len) ++ return NULL; ++ ++ if (verify_descriptors(buf + pos, event->descriptors_loop_length)) ++ return NULL; ++ ++ pos += event->descriptors_loop_length; ++ } ++ ++ if (pos != len) ++ return NULL; ++ ++ return (struct dvb_eit_section *) ext; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/eit_section.h dvb-apps/lib/libucsi/dvb/eit_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/eit_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/eit_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,160 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_EIT_SECTION_H ++#define _UCSI_DVB_EIT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++ ++/** ++ * dvb_eit_section structure. ++ */ ++struct dvb_eit_section { ++ struct section_ext head; ++ ++ uint16_t transport_stream_id; ++ uint16_t original_network_id; ++ uint8_t segment_last_section_number; ++ uint8_t last_table_id; ++ /* struct eit_event events[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the events field of a dvb_eit_section. ++ */ ++struct dvb_eit_event { ++ uint16_t event_id; ++ dvbdate_t start_time; ++ dvbduration_t duration; ++ EBIT3(uint16_t running_status : 3; , ++ uint16_t free_ca_mode : 1; , ++ uint16_t descriptors_loop_length:12; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_eit_section. ++ * ++ * @param section Pointer to a generic section_ext structure. ++ * @return Pointer to a dvb_eit_section, or NULL on error. ++ */ ++struct dvb_eit_section *dvb_eit_section_codec(struct section_ext *section); ++ ++/** ++ * Accessor for the service_id field of an EIT. ++ * ++ * @param eit EIT pointer. ++ * @return The service_id. ++ */ ++static inline uint16_t dvb_eit_section_service_id(struct dvb_eit_section *eit) ++{ ++ return eit->head.table_id_ext; ++} ++ ++/** ++ * Iterator for the events field of a dvb_eit_section. ++ * ++ * @param eit dvb_eit_section pointer. ++ * @param pos Variable containing a pointer to the current dvb_eit_event. ++ */ ++#define dvb_eit_section_events_for_each(eit, pos) \ ++ for ((pos) = dvb_eit_section_events_first(eit); \ ++ (pos); \ ++ (pos) = dvb_eit_section_events_next(eit, pos)) ++ ++/** ++ * Iterator for the descriptors field of a dvb_eit_event. ++ * ++ * @param eit dvb_eit_event pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define dvb_eit_event_descriptors_for_each(event, pos) \ ++ for ((pos) = dvb_eit_event_descriptors_first(event); \ ++ (pos); \ ++ (pos) = dvb_eit_event_descriptors_next(event, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_eit_event * ++ dvb_eit_section_events_first(struct dvb_eit_section *eit) ++{ ++ size_t pos = sizeof(struct dvb_eit_section); ++ ++ if (pos >= section_ext_length(&eit->head)) ++ return NULL; ++ ++ return (struct dvb_eit_event*) ((uint8_t *) eit + pos); ++} ++ ++static inline struct dvb_eit_event * ++ dvb_eit_section_events_next(struct dvb_eit_section *eit, ++ struct dvb_eit_event *pos) ++{ ++ uint8_t *end = (uint8_t*) eit + section_ext_length(&eit->head); ++ uint8_t *next = (uint8_t *) pos + ++ sizeof(struct dvb_eit_event) + ++ pos->descriptors_loop_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_eit_event *) next; ++} ++ ++static inline struct descriptor * ++ dvb_eit_event_descriptors_first(struct dvb_eit_event * t) ++{ ++ if (t->descriptors_loop_length == 0) ++ return NULL; ++ ++ return (struct descriptor *) ++ ((uint8_t *) t + sizeof(struct dvb_eit_event)); ++} ++ ++static inline struct descriptor * ++ dvb_eit_event_descriptors_next(struct dvb_eit_event * t, ++ struct descriptor* pos) ++{ ++ return next_descriptor((uint8_t*) t + sizeof(struct dvb_eit_event), ++ t->descriptors_loop_length, ++ pos); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/extended_event_descriptor.h dvb-apps/lib/libucsi/dvb/extended_event_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/extended_event_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/extended_event_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,232 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_EXTENDED_EVENT_DESCRIPTOR ++#define _UCSI_DVB_EXTENDED_EVENT_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * dvb_extended_event_descriptor structure. ++ */ ++struct dvb_extended_event_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint8_t descriptor_number : 4; , ++ uint8_t last_descriptor_number : 4; ); ++ iso639lang_t language_code; ++ uint8_t length_of_items; ++ /* struct dvb_extended_event_item items[] */ ++ /* struct dvb_extended_event_descriptor_part2 part2 */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the items field of a dvb_extended_event_descriptor. ++ */ ++struct dvb_extended_event_item { ++ uint8_t item_description_length; ++ /* uint8_t item_description[] */ ++ /* struct dvb_extended_event_item_part2 part2 */ ++} __ucsi_packed; ++ ++/** ++ * The second part of a dvb_extended_event_item, following the variable length ++ * description field. ++ */ ++struct dvb_extended_event_item_part2 { ++ uint8_t item_length; ++ /* uint8_t item[] */ ++} __ucsi_packed; ++ ++/** ++ * The second part of a dvb_extended_event_descriptor, following the variable ++ * length items field. ++ */ ++struct dvb_extended_event_descriptor_part2 { ++ uint8_t text_length; ++ /* uint8_t text[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_extended_event_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return dvb_extended_event_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_extended_event_descriptor* ++ dvb_extended_event_descriptor_codec(struct descriptor* d) ++{ ++ uint8_t* buf = (uint8_t*) d + 2; ++ uint32_t pos = 0; ++ uint32_t len = d->len; ++ struct dvb_extended_event_descriptor * p = ++ (struct dvb_extended_event_descriptor *) d; ++ struct dvb_extended_event_descriptor_part2 *p2; ++ ++ pos += sizeof(struct dvb_extended_event_descriptor) - 2; ++ ++ if (pos > len) ++ return NULL; ++ ++ pos += p->length_of_items; ++ ++ if (pos > len) ++ return NULL; ++ ++ p2 = (struct dvb_extended_event_descriptor_part2*) (buf+pos); ++ ++ pos += sizeof(struct dvb_extended_event_descriptor_part2); ++ ++ if (pos > len) ++ return NULL; ++ ++ pos += p2->text_length; ++ ++ if (pos != len) ++ return NULL; ++ ++ return p; ++} ++ ++/** ++ * Iterator for the items field of a dvb_extended_event_descriptor. ++ * ++ * @param d dvb_extended_event_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_extended_event_item. ++ */ ++#define dvb_extended_event_descriptor_items_for_each(d, pos) \ ++ for ((pos) = dvb_extended_event_descriptor_items_first(d); \ ++ (pos); \ ++ (pos) = dvb_extended_event_descriptor_items_next(d, pos)) ++ ++/** ++ * Accessor for the description field of a dvb_extended_event_item. ++ * ++ * @param d dvb_extended_event_item pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t* ++ dvb_extended_event_item_description(struct dvb_extended_event_item *d) ++{ ++ return (uint8_t*) d + sizeof(struct dvb_extended_event_item); ++} ++ ++/** ++ * Accessor for the second part of a dvb_extended_event_item. ++ * ++ * @param dvb_extended_event_item pointer. ++ * @return dvb_extended_event_item_part2 pointer. ++ */ ++static inline struct dvb_extended_event_item_part2* ++ dvb_extended_event_item_part2(struct dvb_extended_event_item *d) ++{ ++ return (struct dvb_extended_event_item_part2*) ++ ((uint8_t*) d + sizeof(struct dvb_extended_event_item) + ++ d->item_description_length); ++} ++ ++/** ++ * Accessor for the item field of a dvb_extended_event_item_part2. ++ * ++ * @param d dvb_extended_event_item_part2 pointer. ++ * @return Pointer to the item field. ++ */ ++static inline uint8_t* ++ dvb_extended_event_item_part2_item(struct dvb_extended_event_item_part2 *d) ++{ ++ return (uint8_t*) d + sizeof(struct dvb_extended_event_item_part2); ++} ++ ++/** ++ * Accessor for the second part of a dvb_extended_event_descriptor. ++ * ++ * @param d dvb_extended_event_descriptor pointer. ++ * @return dvb_extended_event_descriptor_part2 pointer. ++ */ ++static inline struct dvb_extended_event_descriptor_part2* ++ dvb_extended_event_descriptor_part2(struct dvb_extended_event_descriptor *d) ++{ ++ return (struct dvb_extended_event_descriptor_part2*) ++ ((uint8_t*) d + sizeof(struct dvb_extended_event_descriptor) + ++ d->length_of_items); ++} ++ ++/** ++ * Accessor for the text field of an dvb_extended_event_descriptor_part2. ++ * ++ * @param d dvb_extended_event_descriptor_part2 pointer. ++ * @return Pointer to the text field. ++ */ ++static inline uint8_t* ++ dvb_extended_event_descriptor_part2_text(struct dvb_extended_event_descriptor_part2 *d) ++{ ++ return (uint8_t*) ++ ((uint8_t*) d + sizeof(struct dvb_extended_event_descriptor_part2)); ++} ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_extended_event_item* ++ dvb_extended_event_descriptor_items_first(struct dvb_extended_event_descriptor *d) ++{ ++ if (d->length_of_items == 0) ++ return NULL; ++ ++ return (struct dvb_extended_event_item *) ++ ((uint8_t*) d + sizeof(struct dvb_extended_event_descriptor)); ++} ++ ++static inline struct dvb_extended_event_item* ++ dvb_extended_event_descriptor_items_next(struct dvb_extended_event_descriptor *d, ++ struct dvb_extended_event_item *pos) ++{ ++ struct dvb_extended_event_item_part2* part2 = ++ dvb_extended_event_item_part2(pos); ++ uint8_t *end = (uint8_t*) d + sizeof(struct dvb_extended_event_descriptor) + d->length_of_items; ++ uint8_t *next = (uint8_t *) part2 + ++ sizeof(struct dvb_extended_event_item_part2) + ++ part2->item_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_extended_event_item *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/frequency_list_descriptor.h dvb-apps/lib/libucsi/dvb/frequency_list_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/frequency_list_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/frequency_list_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,107 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_FREQUENCY_LIST_DESCRIPTOR ++#define _UCSI_DVB_FREQUENCY_LIST_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * Possible values for coding_type. ++ */ ++enum { ++ DVB_CODING_TYPE_SATELLITE = 0x01, ++ DVB_CODING_TYPE_CABLE = 0x02, ++ DVB_CODING_TYPE_TERRESTRIAL = 0x03, ++}; ++ ++/** ++ * dvb_frequency_list_descriptor structure. ++ */ ++struct dvb_frequency_list_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint8_t reserved : 6; , ++ uint8_t coding_type : 2; ); ++ /* uint32_t centre_frequencies [] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_frequency_list_descriptor. ++ * ++ * @param d Pointer to a generic descriptor structure. ++ * @return dvb_frequency_list_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_frequency_list_descriptor* ++ dvb_frequency_list_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t pos = 0; ++ uint8_t* buf = (uint8_t*) d + 2; ++ uint32_t len = d->len; ++ ++ pos += sizeof(struct dvb_frequency_list_descriptor) - 2; ++ ++ if ((len - pos) % 4) ++ return NULL; ++ ++ while(pos < len) { ++ bswap32(buf+pos); ++ pos += 4; ++ } ++ ++ return (struct dvb_frequency_list_descriptor*) d; ++} ++ ++/** ++ * Accessor for the centre_frequencies field of a dvb_frequency_list_descriptor. ++ * ++ * @param d dvb_frequency_list_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint32_t * ++ dvb_frequency_list_descriptor_centre_frequencies(struct dvb_frequency_list_descriptor *d) ++{ ++ return (uint32_t *) ((uint8_t *) d + sizeof(struct dvb_frequency_list_descriptor)); ++} ++ ++/** ++ * Determine the number of entries in the centre_frequencies field of a dvb_frequency_list_descriptor. ++ * ++ * @param d dvb_frequency_list_descriptor pointer. ++ * @return The number of entries. ++ */ ++static inline int ++ dvb_frequency_list_descriptor_centre_frequencies_count(struct dvb_frequency_list_descriptor *d) ++{ ++ return (d->d.len - 1) >> 2; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/int_section.c dvb-apps/lib/libucsi/dvb/int_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/int_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/int_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,79 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * Copyright (C) 2005 Patrick Boettcher (pb@linuxtv.org) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct dvb_int_section * dvb_int_section_codec(struct section_ext *ext) ++{ ++ uint8_t *buf = (uint8_t *) ext; ++ struct dvb_int_section *in = (struct dvb_int_section *) ext; ++ size_t pos = sizeof(struct section_ext); ++ size_t len = section_ext_length(ext); ++ ++ if (len < sizeof(struct dvb_int_section)) ++ return NULL; ++ ++ bswap32(buf+8); ++ bswap16(buf+12); ++ pos += 6; ++ ++ if (len - pos < in->platform_descriptors_length) ++ return NULL; ++ ++ if (verify_descriptors(buf + pos, in->platform_descriptors_length)) ++ return NULL; ++ ++ pos += in->platform_descriptors_length; ++ ++ while (pos < len) { ++ struct dvb_int_target *s2 = (struct dvb_int_target *) (buf + pos); ++ struct dvb_int_operational_loop *s3; ++ ++ bswap16(buf + pos); /* target_descriptor_loop_length swap */ ++ ++ if (len - pos < s2->target_descriptors_length) ++ return NULL; ++ ++ pos += sizeof(struct dvb_int_target); ++ ++ if (verify_descriptors(buf + pos, s2->target_descriptors_length)) ++ return NULL; ++ ++ pos += s2->target_descriptors_length; ++ ++ s3 = (struct dvb_int_operational_loop *) (buf + pos); ++ ++ bswap16(buf + pos); /* operational_descriptor_loop_length swap */ ++ ++ if (len - pos < s3->operational_descriptors_length) ++ return NULL; ++ ++ pos += sizeof(struct dvb_int_operational_loop); ++ ++ if (verify_descriptors(buf + pos, s3->operational_descriptors_length)) ++ return NULL; ++ ++ pos += s3->operational_descriptors_length; ++ } ++ ++ return (struct dvb_int_section *) ext; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/int_section.h dvb-apps/lib/libucsi/dvb/int_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/int_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/int_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,245 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * Copyright (C) 2005 Patrick Boettcher (pb@linuxtv.org) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++#ifndef _UCSI_DVB_INT_SECTION_H ++#define _UCSI_DVB_INT_SECTION_H ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * dvb_int_section structure - IP/MAC notification section. ++ */ ++struct dvb_int_section { ++ struct section_ext head; ++ ++ EBIT2(uint32_t platform_id :24; , ++ uint32_t processing_order : 8; ); ++ EBIT2(uint16_t reserved2 : 4; , ++ uint16_t platform_descriptors_length :12; ); ++ /* struct descriptor platform_descriptors[] */ ++ /* struct dvb_int_target target_loop[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the target_loop field of a dvb_int_section. ++ */ ++struct dvb_int_target { ++ EBIT2(uint16_t reserved3 : 4; , ++ uint16_t target_descriptors_length :12; ); ++ /* struct descriptor target_descriptors[] */ ++ /* struct dvb_int_operational_loop operational_loop */ ++} __ucsi_packed; ++ ++/** ++ * The operational_loop field in a dvb_int_target. ++ */ ++struct dvb_int_operational_loop { ++ EBIT2(uint16_t reserved4 : 4; , ++ uint16_t operational_descriptors_length :12; ); ++ /* struct descriptor operational_descriptors[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_int_section. ++ * ++ * @param section Generic section_ext pointer. ++ * @return dvb_int_section pointer, or NULL on error. ++ */ ++extern struct dvb_int_section * dvb_int_section_codec(struct section_ext *section); ++ ++/** ++ * Accessor for the action_type field of an INT. ++ * ++ * @param intp INT pointer. ++ * @return The action_type. ++ */ ++static inline uint8_t dvb_int_section_action_type(struct dvb_int_section *intp) ++{ ++ return intp->head.table_id_ext >> 8; ++} ++ ++/** ++ * Accessor for the platform_id_hash field of an INT. ++ * ++ * @param intp INT pointer. ++ * @return The platform_id_hash. ++ */ ++static inline uint8_t dvb_int_section_platform_id_hash(struct dvb_int_section *intp) ++{ ++ return intp->head.table_id_ext & 0xff; ++} ++ ++/** ++ * Iterator for platform_descriptors field in a dvb_int_section. ++ * ++ * @param intp dvb_int_section pointer. ++ * @param pos Variable holding a pointer to the current descriptor. ++ */ ++#define dvb_int_section_platform_descriptors_for_each(intp, pos) \ ++ for ((pos) = dvb_int_section_platform_descriptors_first(intp); \ ++ (pos); \ ++ (pos) = dvb_int_section_platform_descriptors_next(intp, pos)) ++ ++/** ++ * Iterator for the target_loop field in a dvb_int_section. ++ * ++ * @param intp dvb_int_section pointer. ++ * @param pos Variable holding a pointer to the current dvb_int_target. ++ */ ++#define dvb_int_section_target_loop_for_each(intp,pos) \ ++ for ((pos) = dvb_int_section_target_loop_first(intp); \ ++ (pos); \ ++ (pos) = dvb_int_section_target_loop_next(intp, pos)) ++ ++/** ++ * Iterator for the target_descriptors field in a dvb_int_target. ++ * ++ * @param target dvb_int_target pointer. ++ * @param pos Variable holding a pointer to the current descriptor. ++ */ ++#define dvb_int_target_target_descriptors_for_each(target, pos) \ ++ for ((pos) = dvb_int_target_target_descriptors_first(target); \ ++ (pos); \ ++ (pos) = dvb_int_target_target_descriptors_next(target, pos)) ++ ++/** ++ * Accessor for the operational_loop field of a dvb_int_target. ++ * ++ * @param target dvb_int_target pointer. ++ * @return Pointer to a dvb_int_operational_loop. ++ */ ++static inline struct dvb_int_operational_loop * ++ dvb_int_target_operational_loop(struct dvb_int_target *target) ++{ ++ return (struct dvb_int_operational_loop *) ++ ((uint8_t *) target + sizeof(struct dvb_int_target) + target->target_descriptors_length); ++} ++ ++/** ++ * Iterator for the operational_descriptors field in a dvb_int_operational_loop. ++ * ++ * @param oploop dvb_int_operational_loop pointer. ++ * @param pos Variable holding a pointer to the current descriptor. ++ */ ++#define dvb_int_operational_loop_operational_descriptors_for_each(oploop, pos) \ ++ for ((pos) = dvb_int_operational_loop_operational_descriptors_first(oploop); \ ++ (pos); \ ++ (pos) = dvb_int_operational_loop_operational_descriptors_next(oploop, pos)) ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct descriptor * ++ dvb_int_section_platform_descriptors_first(struct dvb_int_section *in) ++{ ++ if (in->platform_descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor *) ++ ((uint8_t *) in + sizeof(struct dvb_int_section)); ++} ++ ++static inline struct descriptor * ++ dvb_int_section_platform_descriptors_next(struct dvb_int_section *in, ++ struct descriptor* pos) ++{ ++ return next_descriptor((uint8_t*) in + sizeof(struct dvb_int_section), ++ in->platform_descriptors_length, ++ pos); ++} ++ ++static inline struct dvb_int_target * ++ dvb_int_section_target_loop_first(struct dvb_int_section *in) ++{ ++ if (sizeof(struct dvb_int_section) + in->platform_descriptors_length >= (uint32_t) section_ext_length((struct section_ext *) in)) ++ return NULL; ++ ++ return (struct dvb_int_target *) ++ ((uint8_t *) in + sizeof(struct dvb_int_section) + in->platform_descriptors_length); ++} ++ ++static inline struct dvb_int_target * ++ dvb_int_section_target_loop_next(struct dvb_int_section *in, ++ struct dvb_int_target *pos) ++{ ++ struct dvb_int_operational_loop *ol = dvb_int_target_operational_loop(pos); ++ struct dvb_int_target *next = ++ (struct dvb_int_target *) ( (uint8_t *) pos + ++ sizeof(struct dvb_int_target) + pos->target_descriptors_length + ++ sizeof(struct dvb_int_operational_loop) + ol->operational_descriptors_length); ++ struct dvb_int_target *end = ++ (struct dvb_int_target *) ((uint8_t *) in + section_ext_length((struct section_ext *) in) ); ++ ++ if (next >= end) ++ return 0; ++ return next; ++} ++ ++static inline struct descriptor * ++ dvb_int_target_target_descriptors_first(struct dvb_int_target *tl) ++{ ++ if (tl->target_descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor *) ++ ((uint8_t *) tl + sizeof(struct dvb_int_target)); ++} ++ ++static inline struct descriptor * ++ dvb_int_target_target_descriptors_next(struct dvb_int_target *tl, ++ struct descriptor* pos) ++{ ++ return next_descriptor((uint8_t*) tl + sizeof(struct dvb_int_target), ++ tl->target_descriptors_length, ++ pos); ++} ++ ++static inline struct descriptor * ++ dvb_int_operational_loop_operational_descriptors_first(struct dvb_int_operational_loop *ol) ++{ ++ if (ol->operational_descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor *) ++ ((uint8_t *) ol + sizeof(struct dvb_int_operational_loop)); ++} ++ ++static inline struct descriptor * ++ dvb_int_operational_loop_operational_descriptors_next(struct dvb_int_operational_loop *ol, ++ struct descriptor* pos) ++{ ++ return next_descriptor((uint8_t*) ol + sizeof(struct dvb_int_operational_loop), ++ ol->operational_descriptors_length, ++ pos); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ip_mac_platform_name_descriptor.h dvb-apps/lib/libucsi/dvb/ip_mac_platform_name_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ip_mac_platform_name_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/ip_mac_platform_name_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,87 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_IP_MAC_PLATFORM_NAME_DESCRIPTOR ++#define _UCSI_DVB_IP_MAC_PLATFORM_NAME_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_ip_platform_name_descriptor structure. ++ */ ++struct dvb_ip_platform_name_descriptor { ++ struct descriptor d; ++ ++ iso639lang_t language_code; ++ /* uint8_t text[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_ip_platform_name_descriptor. ++ * ++ * @param d Pointer to a generic descriptor. ++ * @return dvb_ip_platform_name_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_ip_platform_name_descriptor* ++ dvb_ip_platform_name_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len < (sizeof(struct dvb_ip_platform_name_descriptor) - 2)) ++ return NULL; ++ ++ return (struct dvb_ip_platform_name_descriptor*) d; ++} ++ ++/** ++ * Accessor for the text field of a dvb_ip_platform_name_descriptor. ++ * ++ * @param d dvb_ip_platform_name_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_ip_platform_name_descriptor_text(struct dvb_ip_platform_name_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_ip_platform_name_descriptor); ++} ++ ++/** ++ * Determine the length of the text field of a dvb_ip_platform_name_descriptor. ++ * ++ * @param d dvb_ip_platform_name_descriptor pointer. ++ * @return Length of the field in bytes. ++ */ ++static inline int ++ dvb_ip_platform_name_descriptor_text_length(struct dvb_ip_platform_name_descriptor *d) ++{ ++ return d->d.len - 3; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ip_mac_platform_provider_name_descriptor.h dvb-apps/lib/libucsi/dvb/ip_mac_platform_provider_name_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ip_mac_platform_provider_name_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/ip_mac_platform_provider_name_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,87 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_IP_MAC_PLATFORM_PROVIDER_NAME_DESCRIPTOR ++#define _UCSI_DVB_IP_MAC_PLATFORM_PROVIDER_NAME_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_ip_platform_provider_name_descriptor structure. ++ */ ++struct dvb_ip_platform_provider_name_descriptor { ++ struct descriptor d; ++ ++ iso639lang_t language_code; ++ /* uint8_t text[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_ip_platform_provider_name_descriptor. ++ * ++ * @param d Pointer to a generic descriptor. ++ * @return dvb_ip_platform_provider_name_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_ip_platform_provider_name_descriptor* ++ dvb_ip_platform_provider_name_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len < (sizeof(struct dvb_ip_platform_provider_name_descriptor) - 2)) ++ return NULL; ++ ++ return (struct dvb_ip_platform_provider_name_descriptor*) d; ++} ++ ++/** ++ * Accessor for the text field of a dvb_ip_platform_provider_name_descriptor. ++ * ++ * @param d dvb_ip_platform_provider_name_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_ip_platform_provider_name_descriptor_text(struct dvb_ip_platform_provider_name_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_ip_platform_provider_name_descriptor); ++} ++ ++/** ++ * Determine the length of the text field of a dvb_ip_platform_provider_name_descriptor. ++ * ++ * @param d dvb_ip_platform_provider_name_descriptor pointer. ++ * @return Length of the field in bytes. ++ */ ++static inline int ++ dvb_ip_platform_provider_name_descriptor_text_length(struct dvb_ip_platform_provider_name_descriptor *d) ++{ ++ return d->d.len - 3; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ip_mac_stream_location_descriptor.h dvb-apps/lib/libucsi/dvb/ip_mac_stream_location_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/ip_mac_stream_location_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/ip_mac_stream_location_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,73 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_IP_MAC_STREAM_LOCATION_DESCRIPTOR ++#define _UCSI_DVB_IP_MAC_PLATFORM_PROVIDER_NAME_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_ip_mac_stream_location_descriptor structure. ++ */ ++struct dvb_ip_mac_stream_location_descriptor { ++ struct descriptor d; ++ ++ uint16_t network_id; ++ uint16_t original_network_id; ++ uint16_t transport_stream_id; ++ uint16_t service_id; ++ uint8_t component_tag; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_ip_mac_stream_location_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_ip_mac_stream_location_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_ip_mac_stream_location_descriptor* ++ dvb_ip_mac_stream_location_descriptor_codec(struct descriptor* d) ++{ ++ uint8_t* buf = (uint8_t*) d + 2; ++ ++ if (d->len != (sizeof(struct dvb_ip_mac_stream_location_descriptor) - 2)) ++ return NULL; ++ ++ bswap16(buf); ++ bswap16(buf+2); ++ bswap16(buf+4); ++ bswap16(buf+6); ++ ++ return (struct dvb_ip_mac_stream_location_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/linkage_descriptor.h dvb-apps/lib/libucsi/dvb/linkage_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/linkage_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/linkage_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,480 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_LINKAGE_DESCRIPTOR ++#define _UCSI_DVB_LINKAGE_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * Possible values for linkage_type. ++ */ ++enum { ++ DVB_LINKAGE_TYPE_INFORMATION = 0x01, ++ DVB_LINKAGE_TYPE_EPG = 0x02, ++ DVB_LINKAGE_TYPE_CA_REPLACEMENT = 0x03, ++ DVB_LINKAGE_TYPE_TS_WITH_BAT_NIT = 0x04, ++ DVB_LINKAGE_TYPE_SERVICE_REPLACMENT = 0x05, ++ DVB_LINKAGE_TYPE_DATA_BCAST = 0x06, ++ DVB_LINKAGE_TYPE_RCS_MAP = 0x07, ++ DVB_LINKAGE_TYPE_MOBILE_HANDOVER = 0x08, ++ DVB_LINKAGE_TYPE_SOFTWARE_UPDATE = 0x09, ++ DVB_LINKAGE_TYPE_TS_WITH_SSU_BAT_NIT = 0x0a, ++ DVB_LINKAGE_TYPE_IP_MAC_NOTIFICATION = 0x0b, ++ DVB_LINKAGE_TYPE_TS_WITH_INT_BAT_NIT = 0x0c, ++}; ++ ++/** ++ * Possible values for hand_over_type. ++ */ ++enum { ++ DVB_HAND_OVER_TYPE_IDENTICAL_NEIGHBOURING_COUNTRY = 0x01, ++ DVB_HAND_OVER_TYPE_LOCAL_VARIATION = 0x02, ++ DVB_HAND_OVER_TYPE_ASSOCIATED_SERVICE = 0x03, ++}; ++ ++/** ++ * Possible values for origin_type. ++ */ ++enum { ++ DVB_ORIGIN_TYPE_NIT = 0x00, ++ DVB_ORIGIN_TYPE_SDT = 0x01, ++}; ++ ++/** ++ * dvb_linkage_descriptor structure. ++ */ ++struct dvb_linkage_descriptor { ++ struct descriptor d; ++ ++ uint16_t transport_stream_id; ++ uint16_t original_network_id; ++ uint16_t service_id; ++ uint8_t linkage_type; ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++/** ++ * Data for a linkage_type of 0x08. ++ */ ++struct dvb_linkage_data_08 { ++ EBIT3(uint8_t hand_over_type : 4; , ++ uint8_t reserved : 3; , ++ uint8_t origin_type : 1; ); ++ /* uint16_t network_id if hand_over_type == 1,2,3 */ ++ /* uint16_t initial_service_id if origin_type = 0 */ ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++/** ++ * Data for an linkage_type of 0x0b (IP/MAC Notification Table). ++ */ ++struct dvb_linkage_data_0b { ++ uint8_t platform_id_data_length; ++ /* struct platform_id ids[] */ ++} __ucsi_packed; ++ ++/** ++ * Entries in the ids field of a dvb_linkage_data_0b. ++ */ ++struct dvb_platform_id { ++ EBIT2(uint32_t platform_id : 24; , ++ uint8_t platform_name_loop_length : 8; ); ++ /* struct platform_name names[] */ ++} __ucsi_packed; ++ ++/** ++ * Entries in the names field of a dvb_platform_id. ++ */ ++struct dvb_platform_name { ++ iso639lang_t language_code; ++ uint8_t platform_name_length; ++ /* uint8_t text[] */ ++} __ucsi_packed; ++ ++/** ++ * Data for a linkage_type of 0x0c (IP/MAC Notification Table). ++ */ ++struct dvb_linkage_data_0c { ++ uint8_t table_type; ++ /* uint16_t bouquet_id if table_type == 0x02 */ ++} __ucsi_packed; ++ ++ ++/** ++ * Process a dvb_linkage_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_linkage_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_linkage_descriptor* ++ dvb_linkage_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t pos = 0; ++ uint8_t* buf = (uint8_t*) d + 2; ++ uint32_t len = d->len; ++ struct dvb_linkage_descriptor *p = ++ (struct dvb_linkage_descriptor*) d; ++ ++ if (len < (sizeof(struct dvb_linkage_descriptor) - 2)) ++ return NULL; ++ ++ bswap16(buf); ++ bswap16(buf+2); ++ bswap16(buf+4); ++ ++ pos += sizeof(struct dvb_linkage_descriptor) - 2; ++ ++ if (p->linkage_type == 0x08) { ++ struct dvb_linkage_data_08 *d08; ++ ++ if ((len - pos) < sizeof(struct dvb_linkage_data_08)) ++ return NULL; ++ d08 = (struct dvb_linkage_data_08 *) (buf+pos); ++ pos += sizeof(struct dvb_linkage_data_08); ++ ++ switch(d08->hand_over_type) { ++ case 1: ++ case 2: ++ case 3: ++ if ((len - pos) < 2) ++ return NULL; ++ bswap16(buf+pos); ++ pos += 2; ++ break; ++ } ++ if (d08->origin_type == 0) { ++ if ((len - pos) < 2) ++ return NULL; ++ bswap16(buf+pos); ++ pos+=2; ++ } ++ ++ } else if (p->linkage_type == 0x0b) { ++ uint32_t pos2=0; ++ struct dvb_linkage_data_0b *l_0b = (struct dvb_linkage_data_0b *) (buf + pos); ++ ++ if ((len - pos) < sizeof(struct dvb_linkage_data_0b)) ++ return NULL; ++ ++ pos += sizeof(struct dvb_linkage_data_0b); ++ if ((len - pos) < l_0b->platform_id_data_length) ++ return NULL; ++ ++ while (pos2 < l_0b->platform_id_data_length) { ++ bswap32(buf + pos + pos2); ++ ++ struct dvb_platform_id *p_id = (struct dvb_platform_id *) (buf + pos + pos2); ++ if ((len - pos - pos2) < p_id->platform_name_loop_length) ++ return NULL; ++ ++ pos2 += sizeof(struct dvb_platform_id) + p_id->platform_name_loop_length; ++ } ++ ++ pos += pos2; ++ } else if (p->linkage_type == 0x0c) { ++ struct dvb_linkage_data_0c *l_0c = (struct dvb_linkage_data_0c *) (buf + pos); ++ ++ if ((len - pos) < sizeof(struct dvb_linkage_data_0c)) ++ return NULL; ++ pos += sizeof(struct dvb_linkage_data_0c); ++ ++ if (l_0c->table_type == 0x02) { ++ if ((len - pos) < 2) ++ return NULL; ++ bswap16(buf+pos); ++ } ++ } ++ ++ return (struct dvb_linkage_descriptor*) d; ++} ++ ++/** ++ * Accessor for the data field of a dvb_linkage_descriptor. ++ * ++ * @param d dvb_linkage_descriptor pointer. ++ * @return Pointer to the data field. ++ */ ++static inline uint8_t * ++ dvb_linkage_descriptor_data(struct dvb_linkage_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_linkage_descriptor); ++} ++ ++/** ++ * Determine the length of the data field of a dvb_linkage_descriptor. ++ * ++ * @param d dvb_linkage_descriptor pointer. ++ * @return Length of the field in bytes. ++ */ ++static inline int ++ dvb_linkage_descriptor_data_length(struct dvb_linkage_descriptor *d) ++{ ++ return d->d.len - 7; ++} ++ ++/** ++ * Accessor for a dvb_linkage_data_08 pointer. ++ * ++ * @param d dvb_linkage_descriptor pointer. ++ * @return Pointer to the data field. ++ */ ++static inline struct dvb_linkage_data_08 * ++ dvb_linkage_data_08(struct dvb_linkage_descriptor *d) ++{ ++ if (d->linkage_type != 0x08) ++ return NULL; ++ return (struct dvb_linkage_data_08 *) dvb_linkage_descriptor_data(d); ++} ++ ++/** ++ * Accessor for the network_id field of a dvb_linkage_data_08. ++ * ++ * @param d dvb_linkage_descriptor pointer ++ * @param d08 dvb_linkage_data_08 pointer. ++ * @return network_id, or -1 if not present ++ */ ++static inline int ++ dvb_linkage_data_08_network_id(struct dvb_linkage_descriptor *d, struct dvb_linkage_data_08 *d08) ++{ ++ if (d->linkage_type != 0x08) ++ return -1; ++ ++ switch(d08->hand_over_type) { ++ case 1: ++ case 2: ++ case 3: ++ return *((uint16_t*) ((uint8_t*) d08 + sizeof(struct dvb_linkage_data_08))); ++ } ++ ++ return -1; ++} ++ ++/** ++ * Accessor for the initial_service_id field of a dvb_linkage_data_08. ++ * ++ * @param d dvb_linkage_descriptor pointer ++ * @param d08 dvb_linkage_data_08 pointer. ++ * @return initial_service_id, or -1 if not present ++ */ ++static inline int ++ dvb_linkage_data_08_initial_service_id(struct dvb_linkage_descriptor *d, struct dvb_linkage_data_08 *d08) ++{ ++ uint8_t *pos; ++ ++ if (d->linkage_type != 0x08) ++ return -1; ++ if (d08->origin_type != 0) ++ return -1; ++ ++ pos = ((uint8_t*) d08) + sizeof(struct dvb_linkage_data_08); ++ switch(d08->hand_over_type) { ++ case 1: ++ case 2: ++ case 3: ++ pos +=2; ++ break; ++ } ++ ++ return *((uint16_t*) pos); ++} ++ ++/** ++ * Accessor for the data field of a dvb_linkage_data_08. ++ * ++ * @param d dvb_linkage_descriptor pointer ++ * @param d08 dvb_linkage_data_08 pointer. ++ * @param length Pointer to int destination for data length. ++ * @return Pointer to the data field, or NULL if invalid ++ */ ++static inline uint8_t * ++ dvb_linkage_data_08_data(struct dvb_linkage_descriptor *d, struct dvb_linkage_data_08 *d08, int *length) ++{ ++ uint8_t *pos; ++ int used = 0; ++ ++ if (d->linkage_type != 0x08) { ++ *length = 0; ++ return NULL; ++ } ++ ++ pos = ((uint8_t*) d08) + sizeof(struct dvb_linkage_data_08); ++ switch(d08->hand_over_type) { ++ case 1: ++ case 2: ++ case 3: ++ pos += 2; ++ used += 2; ++ break; ++ } ++ if (d08->origin_type == 0) { ++ pos+=2; ++ used+=2; ++ } ++ ++ *length = dvb_linkage_descriptor_data_length(d) - (sizeof(struct dvb_linkage_data_08) + used); ++ return pos; ++} ++ ++/** ++ * Accessor for a dvb_linkage_data_0b pointer. ++ * ++ * @param d dvb_linkage_descriptor pointer. ++ * @return Pointer to the data field. ++ */ ++static inline struct dvb_linkage_data_0b * ++ dvb_linkage_data_0b(struct dvb_linkage_descriptor *d) ++{ ++ if (d->linkage_type != 0x0b) ++ return NULL; ++ return (struct dvb_linkage_data_0b *) dvb_linkage_descriptor_data(d); ++} ++ ++/** ++ * Iterator for the platform_id field of a dvb_linkage_data_0b. ++ * ++ * @param linkage dvb_linkage_data_0b pointer. ++ * @param pos Variable containing a pointer to the current dvb_platform_id. ++ */ ++#define dvb_linkage_data_0b_platform_id_for_each(linkage, pos) \ ++ for ((pos) = dvb_platform_id_first(linkage); \ ++ (pos); \ ++ (pos) = dvb_platform_id_next(linkage, pos)) ++ ++/** ++ * Iterator for the platform_name field of a dvb_platform_id. ++ * ++ * @param platid dvb_platform_id pointer. ++ * @param pos Variable containing a pointer to the current dvb_platform_name. ++ */ ++#define dvb_platform_id_platform_name_for_each(platid, pos) \ ++ for ((pos) = dvb_platform_name_first(platid); \ ++ (pos); \ ++ (pos) = dvb_platform_name_next(platid, pos)) ++ ++/** ++ * Accessor for the text field of a dvb_platform_name. ++ * ++ * @param p dvb_platform_name pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_platform_name_text(struct dvb_platform_name *p) ++{ ++ return (uint8_t *) p + sizeof(struct dvb_platform_name); ++} ++ ++/** ++ * Accessor for a dvb_linkage_data_0c pointer. ++ * ++ * @param d dvb_linkage_descriptor pointer. ++ * @return Pointer to the data field. ++ */ ++static inline struct dvb_linkage_data_0c * ++ dvb_linkage_data_0c(struct dvb_linkage_descriptor *d) ++{ ++ if (d->linkage_type != 0x0c) ++ return NULL; ++ return (struct dvb_linkage_data_0c *) dvb_linkage_descriptor_data(d); ++} ++ ++/** ++ * Accessor for the bouquet_id field of a dvb_linkage_data_0c if table_id == 0x02. ++ * ++ * @param l_0c dvb_linkage_data_0c pointer. ++ * @return The bouquet field, or -1 on error. ++ */ ++static inline int ++ dvb_linkage_data_0c_bouquet_id(struct dvb_linkage_data_0c *l_0c) ++{ ++ if (l_0c->table_type != 0x02) ++ return -1; ++ ++ return *((uint16_t *) ((uint8_t*) l_0c + 1)); ++} ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_platform_id * ++ dvb_platform_id_first(struct dvb_linkage_data_0b *d) ++{ ++ if (d->platform_id_data_length == 0) ++ return NULL; ++ ++ return (struct dvb_platform_id *) ((uint8_t *) d + sizeof(struct dvb_linkage_data_0b)); ++} ++ ++static inline struct dvb_platform_id * ++ dvb_platform_id_next(struct dvb_linkage_data_0b *d, ++ struct dvb_platform_id *pos) ++{ ++ uint8_t *end = (uint8_t *) d + d->platform_id_data_length; ++ uint8_t *next = (uint8_t *) pos + ++ sizeof(struct dvb_platform_id) + ++ pos->platform_name_loop_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_platform_id *) next; ++} ++ ++static inline struct dvb_platform_name * ++ dvb_platform_name_first(struct dvb_platform_id *p) ++{ ++ if (p->platform_name_loop_length == 0) ++ return NULL; ++ ++ return (struct dvb_platform_name *) ((uint8_t *) p + sizeof(struct dvb_platform_id)); ++} ++ ++static inline struct dvb_platform_name * ++ dvb_platform_name_next(struct dvb_platform_id *p, ++ struct dvb_platform_name *pos) ++{ ++ uint8_t *end = (uint8_t *) p + p->platform_name_loop_length; ++ uint8_t *next = (uint8_t *) pos + ++ sizeof(struct dvb_platform_name) + ++ pos->platform_name_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_platform_name *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/local_time_offset_descriptor.h dvb-apps/lib/libucsi/dvb/local_time_offset_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/local_time_offset_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/local_time_offset_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,127 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_LOCAL_TIME_OFFSET_DESCRIPTOR ++#define _UCSI_DVB_LOCAL_TIME_OFFSET_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++#include ++ ++/** ++ * dvb_local_time_offset_descriptor parameter. ++ */ ++struct dvb_local_time_offset_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_local_time_offset offsets[] */ ++} __ucsi_packed; ++ ++/** ++ * Entry in the offsets field of dvb_local_time_offset_descriptor. ++ */ ++struct dvb_local_time_offset { ++ iso639country_t country_code; ++ EBIT3(uint8_t country_region_id : 6; , ++ uint8_t reserved : 1; , ++ uint8_t local_time_offset_polarity : 1; ); ++ dvbhhmm_t local_time_offset; ++ dvbdate_t time_of_change; ++ dvbhhmm_t next_time_offset; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_local_time_offset_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_local_time_offset_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_local_time_offset_descriptor* ++ dvb_local_time_offset_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t len = d->len; ++ uint32_t pos = 0; ++ ++ if (len % sizeof(struct dvb_local_time_offset)) ++ return NULL; ++ ++ while(pos < len) { ++ pos += sizeof(struct dvb_local_time_offset); ++ } ++ ++ return (struct dvb_local_time_offset_descriptor*) d; ++} ++ ++/** ++ * Iterator for the offsets field of a dvb_local_time_offset_descriptor. ++ * ++ * @param d dvb_local_time_offset_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_local_time_offset. ++ */ ++#define dvb_local_time_offset_descriptor_offsets_for_each(d, pos) \ ++ for ((pos) = dvb_local_time_offset_descriptor_offsets_first(d); \ ++ (pos); \ ++ (pos) = dvb_local_time_offset_descriptor_offsets_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_local_time_offset* ++ dvb_local_time_offset_descriptor_offsets_first(struct dvb_local_time_offset_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_local_time_offset *) ++ ((uint8_t*) d + sizeof(struct dvb_local_time_offset_descriptor)); ++} ++ ++static inline struct dvb_local_time_offset* ++ dvb_local_time_offset_descriptor_offsets_next(struct dvb_local_time_offset_descriptor *d, ++ struct dvb_local_time_offset *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_local_time_offset); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_local_time_offset *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/Makefile dvb-apps/lib/libucsi/dvb/Makefile +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,123 @@ ++# Makefile for linuxtv.org dvb-apps/lib/libucsi/dvb ++ ++.PHONY: sub-error-dvb ++ ++sub-error-dvb: ++ $(error You can't use this makefile directly.) ++ ++ifneq ($(lib_name),) ++ ++objects += dvb/bat_section.o \ ++ dvb/dit_section.o \ ++ dvb/eit_section.o \ ++ dvb/int_section.o \ ++ dvb/nit_section.o \ ++ dvb/rst_section.o \ ++ dvb/sdt_section.o \ ++ dvb/sit_section.o \ ++ dvb/st_section.o \ ++ dvb/tdt_section.o \ ++ dvb/tot_section.o \ ++ dvb/tva_container_section.o \ ++ dvb/types.o ++ ++sub-install += dvb ++ ++else ++ ++includes = ac3_descriptor.h \ ++ adaptation_field_data_descriptor.h \ ++ ait_application_descriptor.h \ ++ ait_application_icons_descriptor.h \ ++ ait_application_name_descriptor.h \ ++ ait_external_application_authorisation_descriptor.h \ ++ ancillary_data_descriptor.h \ ++ announcement_support_descriptor.h \ ++ application_signalling_descriptor.h \ ++ bat_section.h \ ++ bouquet_name_descriptor.h \ ++ ca_identifier_descriptor.h \ ++ cable_delivery_descriptor.h \ ++ cell_frequency_link_descriptor.h \ ++ cell_list_descriptor.h \ ++ component_descriptor.h \ ++ content_descriptor.h \ ++ content_identifier_descriptor.h \ ++ country_availability_descriptor.h \ ++ data_broadcast_descriptor.h \ ++ data_broadcast_id_descriptor.h \ ++ default_authority_descriptor.h \ ++ descriptor.h \ ++ dit_section.h \ ++ dsng_descriptor.h \ ++ eit_section.h \ ++ extended_event_descriptor.h \ ++ frequency_list_descriptor.h \ ++ int_section.h \ ++ ip_mac_platform_name_descriptor.h \ ++ ip_mac_platform_provider_name_descriptor.h \ ++ ip_mac_stream_location_descriptor.h \ ++ linkage_descriptor.h \ ++ local_time_offset_descriptor.h \ ++ mhp_data_broadcast_id_descriptor.h \ ++ mosaic_descriptor.h \ ++ mpe_fec_section.h \ ++ multilingual_bouquet_name_descriptor.h \ ++ multilingual_component_descriptor.h \ ++ multilingual_network_name_descriptor.h \ ++ multilingual_service_name_descriptor.h \ ++ network_name_descriptor.h \ ++ nit_section.h \ ++ nvod_reference_descriptor.h \ ++ parental_rating_descriptor.h \ ++ partial_transport_stream_descriptor.h \ ++ pdc_descriptor.h \ ++ private_data_specifier_descriptor.h \ ++ related_content_descriptor.h \ ++ rnt_rar_over_dvb_stream_descriptor.h \ ++ rnt_rar_over_ip_descriptor.h \ ++ rnt_rnt_scan_descriptor.h \ ++ rst_section.h \ ++ s2_satellite_delivery_descriptor.h \ ++ satellite_delivery_descriptor.h \ ++ scrambling_descriptor.h \ ++ sdt_section.h \ ++ section.h \ ++ service_availability_descriptor.h \ ++ service_descriptor.h \ ++ service_identifier_descriptor.h \ ++ service_list_descriptor.h \ ++ service_move_descriptor.h \ ++ short_event_descriptor.h \ ++ short_smoothing_buffer_descriptor.h \ ++ sit_section.h \ ++ st_section.h \ ++ stream_identifier_descriptor.h \ ++ stuffing_descriptor.h \ ++ subtitling_descriptor.h \ ++ target_ip_address_descriptor.h \ ++ target_ipv6_address_descriptor.h \ ++ target_ip_slash_descriptor.h \ ++ target_ip_source_slash_descriptor.h \ ++ target_ipv6_slash_descriptor.h \ ++ target_ipv6_source_slash_descriptor.h \ ++ tdt_section.h \ ++ telephone_descriptor.h \ ++ teletext_descriptor.h \ ++ terrestrial_delivery_descriptor.h \ ++ time_shifted_event_descriptor.h \ ++ time_shifted_service_descriptor.h \ ++ time_slice_fec_identifier_descriptor.h \ ++ tot_section.h \ ++ transport_stream_descriptor.h \ ++ tva_container_section.h \ ++ tva_id_descriptor.h \ ++ types.h \ ++ vbi_data_descriptor.h \ ++ vbi_teletext_descriptor.h ++ ++include ../../../Make.rules ++ ++lib_name = libucsi/dvb ++ ++endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/mhp_data_broadcast_id_descriptor.h dvb-apps/lib/libucsi/dvb/mhp_data_broadcast_id_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/mhp_data_broadcast_id_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/mhp_data_broadcast_id_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,110 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_MHP_DATA_BROADCAST_ID_DESCRIPTOR ++#define _UCSI_DVB_MHP_DATA_BROADCAST_ID_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#ifndef _UCSI_DVB_DATA_BROADCAST_ID_DESCRIPTOR ++#error Must include dvb/data_broadcast_id_descriptor.h first ++#endif ++ ++/** ++ * Broadcast IDs for MHP. ++ */ ++enum { ++ DVB_BROADCAST_ID_MHP_OBJECT_CAROUSEL = 0x00f0, ++ DVB_BROADCAST_ID_MHP_MPE = 0x00f1, ++}; ++ ++/** ++ * dvb_mhp_data_broadcast_id_descriptor structure. ++ */ ++struct dvb_mhp_data_broadcast_id_descriptor { ++ struct dvb_data_broadcast_id_descriptor d; ++ /* uint16_t application_type[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_mhp_data_broadcast_id_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return dvb_mhp_data_broadcast_id_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_mhp_data_broadcast_id_descriptor* ++ dvb_mhp_data_broadcast_id_descriptor_codec(struct dvb_data_broadcast_id_descriptor* d) ++{ ++ uint8_t * buf; ++ int len; ++ int pos = 0; ++ struct dvb_mhp_data_broadcast_id_descriptor *res = ++ (struct dvb_mhp_data_broadcast_id_descriptor *) d; ++ ++ if ((res->d.data_broadcast_id < 0xf0) || (res->d.data_broadcast_id > 0xfe)) ++ return NULL; ++ ++ buf = dvb_data_broadcast_id_descriptor_id_selector_byte(d); ++ len = dvb_data_broadcast_id_descriptor_id_selector_byte_length(d); ++ ++ if (len % 2) ++ return NULL; ++ ++ while(pos < len) { ++ bswap16(buf+pos); ++ pos+=2; ++ } ++ ++ return res; ++} ++ ++/** ++ * Accessor for the application_type field of a dvb_mhp_data_broadcast_id_descriptor. ++ * ++ * @param d dvb_mhp_data_broadcast_id_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint16_t * ++ dvb_mhp_data_broadcast_id_descriptor_id_application_type(struct dvb_mhp_data_broadcast_id_descriptor *d) ++{ ++ return (uint16_t *) dvb_data_broadcast_id_descriptor_id_selector_byte((struct dvb_data_broadcast_id_descriptor*) d); ++} ++ ++/** ++ * Determine the number of entries in the application_type field of a dvb_mhp_data_broadcast_id_descriptor. ++ * ++ * @param d dvb_data_broadcast_id_descriptor pointer. ++ * @return Length of the field in bytes. ++ */ ++static inline int ++ dvb_mhp_data_broadcast_id_descriptor_id_application_type_count(struct dvb_mhp_data_broadcast_id_descriptor *d) ++{ ++ return dvb_data_broadcast_id_descriptor_id_selector_byte_length((struct dvb_data_broadcast_id_descriptor*) d) >> 1; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/mosaic_descriptor.h dvb-apps/lib/libucsi/dvb/mosaic_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/mosaic_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/mosaic_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,324 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_MOSAIC_DESCRIPTOR ++#define _UCSI_DVB_MOSAIC_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_mosaic_descriptor structure. ++ */ ++struct dvb_mosaic_descriptor { ++ struct descriptor d; ++ ++ EBIT4(uint8_t mosaic_entry_point : 1; , ++ uint8_t number_of_horiz_elementary_cells: 3; , ++ uint8_t reserved : 1; , ++ uint8_t number_of_vert_elementary_cells : 3; ); ++ /* struct dvb_mosaic_info infos[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the infos field of a dvb_mosaic_descriptor. ++ */ ++struct dvb_mosaic_info { ++ EBIT3(uint16_t logical_cell_id : 6; , ++ uint16_t reserved : 7; , ++ uint16_t logical_cell_presentation_info : 3; ); ++ uint8_t elementary_cell_field_length; ++ /* struct dvb_mosaic_elementary_cell_field fields[] */ ++ /* struct dvb_mosaic_info_part2 part2 */ ++ /* struct dvb_mosaic_linkage linkage */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the fields field of a dvb_mosaic_info. ++ */ ++struct dvb_mosaic_elementary_cell_field { ++ EBIT2(uint8_t reserved : 2; , ++ uint8_t elementary_cell_id : 6; ); ++} __ucsi_packed; ++ ++/** ++ * Part2 of dvb_mosaic_info, following the variable length fields field. ++ */ ++struct dvb_mosaic_info_part2 { ++ uint8_t cell_linkage_info; ++} __ucsi_packed; ++ ++struct dvb_mosaic_linkage_01 { ++ uint16_t bouquet_id; ++} __ucsi_packed; ++ ++struct dvb_mosaic_linkage_02 { ++ uint16_t original_network_id; ++ uint16_t transport_stream_id; ++ uint16_t service_id; ++} __ucsi_packed; ++ ++struct dvb_mosaic_linkage_03 { ++ uint16_t original_network_id; ++ uint16_t transport_stream_id; ++ uint16_t service_id; ++} __ucsi_packed; ++ ++struct dvb_mosaic_linkage_04 { ++ uint16_t original_network_id; ++ uint16_t transport_stream_id; ++ uint16_t service_id; ++ uint16_t event_id; ++} __ucsi_packed; ++ ++/** ++ * Structure describing the linkage field of a dvb_mosaic_info ++ */ ++struct dvb_mosaic_linkage { ++ union { ++ struct dvb_mosaic_linkage_01 linkage_01; ++ struct dvb_mosaic_linkage_02 linkage_02; ++ struct dvb_mosaic_linkage_03 linkage_03; ++ struct dvb_mosaic_linkage_04 linkage_04; ++ } u; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_mosaic_descriptor. ++ * ++ * @param d Pointer to a generic descriptor structure. ++ */ ++static inline struct dvb_mosaic_descriptor* ++ dvb_mosaic_descriptor_codec(struct descriptor* d) ++{ ++ uint8_t* buf = (uint8_t*) d + 2; ++ uint32_t pos = 0; ++ uint32_t len = d->len; ++ struct dvb_mosaic_descriptor * p = ++ (struct dvb_mosaic_descriptor *) d; ++ ++ pos += (sizeof(struct dvb_mosaic_descriptor) - 2); ++ ++ if (pos > len) ++ return NULL; ++ ++ while(pos < len) { ++ struct dvb_mosaic_info *e = ++ (struct dvb_mosaic_info*) (buf+pos); ++ struct dvb_mosaic_info_part2 *e2; ++ struct dvb_mosaic_linkage *linkage; ++ ++ if ((pos + sizeof(struct dvb_mosaic_info)) > len) ++ return NULL; ++ ++ bswap16(buf + pos); ++ ++ pos += sizeof(struct dvb_mosaic_info) + ++ e->elementary_cell_field_length; ++ ++ if (pos > len) ++ return NULL; ++ ++ e2 = (struct dvb_mosaic_info_part2*) (buf+pos); ++ ++ pos += sizeof(struct dvb_mosaic_info_part2); ++ ++ if (pos > len) ++ return NULL; ++ ++ linkage = (struct dvb_mosaic_linkage*) (buf+pos); ++ ++ switch(e2->cell_linkage_info) { ++ case 0x01: ++ if ((pos + sizeof(struct dvb_mosaic_linkage_01)) > len) ++ return NULL; ++ bswap16(buf+pos); ++ pos += sizeof(struct dvb_mosaic_linkage_01); ++ break; ++ ++ case 0x02: ++ if ((pos + sizeof(struct dvb_mosaic_linkage_02)) > len) ++ return NULL; ++ bswap16(buf+pos); ++ bswap16(buf+pos+2); ++ bswap16(buf+pos+4); ++ pos += sizeof(struct dvb_mosaic_linkage_02); ++ break; ++ ++ case 0x03: ++ if ((pos + sizeof(struct dvb_mosaic_linkage_03)) > len) ++ return NULL; ++ bswap16(buf+pos); ++ bswap16(buf+pos+2); ++ bswap16(buf+pos+4); ++ pos += sizeof(struct dvb_mosaic_linkage_03); ++ break; ++ ++ case 0x04: ++ if ((pos + sizeof(struct dvb_mosaic_linkage_04)) > len) ++ return NULL; ++ bswap16(buf+pos); ++ bswap16(buf+pos+2); ++ bswap16(buf+pos+4); ++ bswap16(buf+pos+6); ++ pos += sizeof(struct dvb_mosaic_linkage_04); ++ break; ++ } ++ } ++ ++ return p; ++} ++ ++/** ++ * Iterator over the infos field of a dvb_mosaic_descriptor. ++ * ++ * @param d dvb_mosaic_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_mosaic_info. ++ */ ++#define dvb_mosaic_descriptor_infos_for_each(d, pos) \ ++ for ((pos) = dvb_mosaic_descriptor_infos_first(d); \ ++ (pos); \ ++ (pos) = dvb_mosaic_descriptor_infos_next(d, pos)) ++ ++/** ++ * Iterator over the fields field of a dvb_mosaic_info. ++ * ++ * @param info dvb_mosaic_info pointer. ++ * @param pos Variable containing a pointer to the current dvb_mosaic_elementary_cell_field. ++ */ ++#define dvb_mosaic_info_fields_for_each(info, pos) \ ++ for ((pos) = dvb_mosaic_info_fields_first(info); \ ++ (pos); \ ++ (pos) = dvb_mosaic_info_fields_next(info, pos)) ++ ++/** ++ * Accessor for the second part of the dvb_mosaic_info structure. ++ * ++ * @param entry dvb_mosaic_info pointer. ++ * @return dvb_mosaic_info_part2 pointer. ++ */ ++static inline struct dvb_mosaic_info_part2* ++ dvb_mosaic_info_part2(struct dvb_mosaic_info* entry) ++{ ++ return (struct dvb_mosaic_info_part2*) ++ ((uint8_t*) entry + sizeof(struct dvb_mosaic_info) + ++ entry->elementary_cell_field_length); ++} ++ ++/** ++ * Accessor for the linkage field a dvb_mosaic_info structure. ++ * ++ * @param entry dvb_mosaic_info_part2 pointer. ++ * @return dvb_mosaic_linkage pointer, or NULL on error. ++ */ ++static inline struct dvb_mosaic_linkage* ++ dvb_mosaic_linkage(struct dvb_mosaic_info_part2* entry) ++{ ++ if ((entry->cell_linkage_info != 0x01) && ++ (entry->cell_linkage_info != 0x02) && ++ (entry->cell_linkage_info != 0x03) && ++ (entry->cell_linkage_info != 0x04)) ++ return NULL; ++ ++ return (struct dvb_mosaic_linkage*) ++ ((uint8_t*) entry + sizeof(struct dvb_mosaic_info_part2)); ++} ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_mosaic_info* ++ dvb_mosaic_descriptor_infos_first(struct dvb_mosaic_descriptor *d) ++{ ++ if (d->d.len == 1) ++ return NULL; ++ ++ return (struct dvb_mosaic_info *) ++ ((uint8_t*) d + sizeof(struct dvb_mosaic_descriptor)); ++} ++ ++static inline struct dvb_mosaic_info* ++ dvb_mosaic_descriptor_infos_next(struct dvb_mosaic_descriptor *d, ++ struct dvb_mosaic_info *pos) ++{ ++ struct dvb_mosaic_info_part2* part2 = dvb_mosaic_info_part2(pos); ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_mosaic_info) + ++ pos->elementary_cell_field_length + ++ sizeof(struct dvb_mosaic_info_part2); ++ ++ if (part2->cell_linkage_info == 0x01) ++ next += sizeof(struct dvb_mosaic_linkage_01); ++ else if (part2->cell_linkage_info == 0x02) ++ next += sizeof(struct dvb_mosaic_linkage_02); ++ else if (part2->cell_linkage_info == 0x03) ++ next += sizeof(struct dvb_mosaic_linkage_03); ++ else if (part2->cell_linkage_info == 0x04) ++ next += sizeof(struct dvb_mosaic_linkage_04); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_mosaic_info *) next; ++} ++ ++static inline struct dvb_mosaic_elementary_cell_field* ++ dvb_mosaic_info_fields_first(struct dvb_mosaic_info *d) ++{ ++ if (d->elementary_cell_field_length == 0) ++ return NULL; ++ ++ return (struct dvb_mosaic_elementary_cell_field*) ++ ((uint8_t*) d + sizeof(struct dvb_mosaic_info)); ++} ++ ++static inline struct dvb_mosaic_elementary_cell_field* ++ dvb_mosaic_info_fields_next(struct dvb_mosaic_info *d, ++ struct dvb_mosaic_elementary_cell_field* pos) ++{ ++ uint8_t *end = (uint8_t*) d + sizeof(struct dvb_mosaic_info) + ++ d->elementary_cell_field_length; ++ uint8_t *next = (uint8_t *) pos + ++ sizeof(struct dvb_mosaic_elementary_cell_field); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_mosaic_elementary_cell_field *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/mpe_fec_section.h dvb-apps/lib/libucsi/dvb/mpe_fec_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/mpe_fec_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/mpe_fec_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,73 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * Copyright (C) 2008 Patrick Boettcher (pb@linuxtv.org) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_MPE_FEC_SECTION_H ++#define _UCSI_DVB_MPE_FEC_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * mpe_fec_section structure. TODO ++ */ ++struct mpe_fec_section { ++ struct section head; ++}; ++ ++ ++/** ++ * real_time_paramters ++ * can also be found in datagram_section in MAC4-1-bytes */ ++struct real_time_parameters { ++ EBIT4(uint32_t delta_t : 12; , ++ uint32_t table_boundary : 1; , ++ uint32_t frame_boundary : 1; , ++ uint32_t address : 18; ) ++}; ++ ++ ++static inline struct real_time_parameters * datagram_section_real_time_parameters_codec(struct datagram_section *d) ++{ ++ struct real_time_parameters *rt = (struct real_time_parameters *) &d->MAC_address_4; ++ uint8_t b[4]; ++ b[0] = d->MAC_address_4; ++ b[1] = d->MAC_address_3; ++ b[2] = d->MAC_address_2; ++ b[3] = d->MAC_address_1; ++ ++ rt->delta_t = (b[0] << 4) | ((b[1] >> 4) & 0x0f); ++ rt->table_boundary = (b[1] >> 3) & 0x1; ++ rt->frame_boundary = (b[1] >> 2) & 0x1; ++ rt->address = ((b[1] & 0x3) << 16) | (b[2] << 8) | b[3]; ++ ++ return rt; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/multilingual_bouquet_name_descriptor.h dvb-apps/lib/libucsi/dvb/multilingual_bouquet_name_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/multilingual_bouquet_name_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/multilingual_bouquet_name_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,145 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_MULTILINGUAL_BOUQUET_NAME_DESCRIPTOR ++#define _UCSI_DVB_MULTILINGUAL_BOUQUET_NAME_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * dvb_multilingual_bouquet_name_descriptor structure. ++ */ ++struct dvb_multilingual_bouquet_name_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_multilingual_bouquet_name names[]*/ ++} __ucsi_packed; ++ ++/** ++ * An entry in the names field of a dvb_multilingual_bouquet_name_descriptor. ++ */ ++struct dvb_multilingual_bouquet_name { ++ iso639lang_t language_code; ++ uint8_t bouquet_name_length; ++ /* uint8_t name[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_multilingual_bouquet_name_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_multilingual_bouquet_name_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_multilingual_bouquet_name_descriptor* ++ dvb_multilingual_bouquet_name_descriptor_codec(struct descriptor* d) ++{ ++ uint8_t* buf = (uint8_t*) d + 2; ++ uint32_t pos = 0; ++ uint32_t len = d->len; ++ ++ while(pos < len) { ++ struct dvb_multilingual_bouquet_name *e = ++ (struct dvb_multilingual_bouquet_name*) (buf+pos); ++ ++ pos += sizeof(struct dvb_multilingual_bouquet_name); ++ ++ if (pos > len) ++ return NULL; ++ ++ pos += e->bouquet_name_length; ++ ++ if (pos > len) ++ return NULL; ++ } ++ ++ return (struct dvb_multilingual_bouquet_name_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries in the names field of a dvb_multilingual_bouquet_name_descriptor. ++ * ++ * @param d dvb_multilingual_bouquet_name_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_multilingual_bouquet_name. ++ */ ++#define dvb_multilingual_bouquet_name_descriptor_names_for_each(d, pos) \ ++ for ((pos) = dvb_multilingual_bouquet_name_descriptor_names_first(d); \ ++ (pos); \ ++ (pos) = dvb_multilingual_bouquet_name_descriptor_names_next(d, pos)) ++ ++/** ++ * Accessor for the name field of a dvb_multilingual_bouquet_name. ++ * ++ * @param e dvb_multilingual_bouquet_name pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_multilingual_bouquet_name_name(struct dvb_multilingual_bouquet_name *e) ++{ ++ return (uint8_t *) e + sizeof(struct dvb_multilingual_bouquet_name); ++} ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_multilingual_bouquet_name* ++ dvb_multilingual_bouquet_name_descriptor_names_first(struct dvb_multilingual_bouquet_name_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_multilingual_bouquet_name *) ++ ((uint8_t*) d + sizeof(struct dvb_multilingual_bouquet_name_descriptor)); ++} ++ ++static inline struct dvb_multilingual_bouquet_name* ++ dvb_multilingual_bouquet_name_descriptor_names_next(struct dvb_multilingual_bouquet_name_descriptor *d, ++ struct dvb_multilingual_bouquet_name *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + ++ sizeof(struct dvb_multilingual_bouquet_name) + ++ pos->bouquet_name_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_multilingual_bouquet_name *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/multilingual_component_descriptor.h dvb-apps/lib/libucsi/dvb/multilingual_component_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/multilingual_component_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/multilingual_component_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,149 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_MULTILINGUAL_COMPONENT_DESCRIPTOR ++#define _UCSI_DVB_MULTILINGUAL_COMPONENT_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * dvb_multilingual_component_descriptor structure. ++ */ ++struct dvb_multilingual_component_descriptor { ++ struct descriptor d; ++ ++ uint8_t component_tag; ++ /* struct dvb_multilingual_component components[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the components field of a dvb_multilingual_component_descriptor. ++ */ ++struct dvb_multilingual_component { ++ iso639lang_t language_code; ++ uint8_t text_description_length; ++ /* uint8_t text_char[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_multilingual_component_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_multilingual_component_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_multilingual_component_descriptor* ++ dvb_multilingual_component_descriptor_codec(struct descriptor* d) ++{ ++ uint8_t* buf = (uint8_t*) d + 2; ++ uint32_t pos = sizeof(struct dvb_multilingual_component_descriptor) - 2; ++ uint32_t len = d->len; ++ ++ if (pos > len) ++ return NULL; ++ ++ while(pos < len) { ++ struct dvb_multilingual_component *e = ++ (struct dvb_multilingual_component*) (buf+pos); ++ ++ pos += sizeof(struct dvb_multilingual_component); ++ ++ if (pos > len) ++ return NULL; ++ ++ pos += e->text_description_length; ++ ++ if (pos > len) ++ return NULL; ++ } ++ ++ return (struct dvb_multilingual_component_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries in the components field of a dvb_multilingual_component_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_multilingual_component. ++ */ ++#define dvb_multilingual_component_descriptor_components_for_each(d, pos) \ ++ for ((pos) = dvb_multilingual_component_descriptor_components_first(d); \ ++ (pos); \ ++ (pos) = dvb_multilingual_component_descriptor_components_next(d, pos)) ++ ++/** ++ * Accessor for the text_char field in a dvb_multilingual_component. ++ * ++ * @param e dvb_multilingual_component pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_multilingual_component_text_char(struct dvb_multilingual_component *e) ++{ ++ return (uint8_t *) e + sizeof(struct dvb_multilingual_component); ++} ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_multilingual_component* ++ dvb_multilingual_component_descriptor_components_first(struct dvb_multilingual_component_descriptor *d) ++{ ++ if (d->d.len == 1) ++ return NULL; ++ ++ return (struct dvb_multilingual_component *) ++ ((uint8_t*) d + sizeof(struct dvb_multilingual_component_descriptor)); ++} ++ ++static inline struct dvb_multilingual_component* ++ dvb_multilingual_component_descriptor_components_next(struct dvb_multilingual_component_descriptor *d, ++ struct dvb_multilingual_component *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + ++ sizeof(struct dvb_multilingual_component) + ++ pos->text_description_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_multilingual_component *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/multilingual_network_name_descriptor.h dvb-apps/lib/libucsi/dvb/multilingual_network_name_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/multilingual_network_name_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/multilingual_network_name_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,145 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_MULTILINGUAL_NETWORK_NAME_DESCRIPTOR ++#define _UCSI_DVB_MULTILINGUAL_NETWORK_NAME_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * dvb_multilingual_network_name_descriptor structure. ++ */ ++struct dvb_multilingual_network_name_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_multilingual_network_name names[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the names field of a dvb_multilingual_network_name_descriptor. ++ */ ++struct dvb_multilingual_network_name { ++ iso639lang_t language_code; ++ uint8_t network_name_length; ++ /* uint8_t name[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_multilingual_network_name_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_multilingual_network_name_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_multilingual_network_name_descriptor* ++ dvb_multilingual_network_name_descriptor_codec(struct descriptor* d) ++{ ++ uint8_t* buf = (uint8_t*) d + 2; ++ uint32_t pos = 0; ++ uint32_t len = d->len; ++ ++ while(pos < len) { ++ struct dvb_multilingual_network_name *e = ++ (struct dvb_multilingual_network_name*) (buf + pos); ++ ++ pos += sizeof(struct dvb_multilingual_network_name); ++ ++ if (pos > len) ++ return NULL; ++ ++ pos += e->network_name_length; ++ ++ if (pos > len) ++ return NULL; ++ } ++ ++ return (struct dvb_multilingual_network_name_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries in the names field of a dvb_multilingual_network_name_descriptor. ++ * ++ * @param d dvb_multilingual_network_name_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_multilingual_network_name. ++ */ ++#define dvb_multilingual_network_name_descriptor_names_for_each(d, pos) \ ++ for ((pos) = dvb_multilingual_network_name_descriptor_names_first(d); \ ++ (pos); \ ++ (pos) = dvb_multilingual_network_name_descriptor_names_next(d, pos)) ++ ++/** ++ * Accessor for the name field of a dvb_multilingual_network_name. ++ * ++ * @param e dvb_multilingual_network_name pointer. ++ * @return Pointer to the name field. ++ */ ++static inline uint8_t * ++ dvb_multilingual_network_name_name(struct dvb_multilingual_network_name *e) ++{ ++ return (uint8_t *) e + sizeof(struct dvb_multilingual_network_name); ++} ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_multilingual_network_name* ++ dvb_multilingual_network_name_descriptor_names_first(struct dvb_multilingual_network_name_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_multilingual_network_name *) ++ ((uint8_t*) d + sizeof(struct dvb_multilingual_network_name_descriptor)); ++} ++ ++static inline struct dvb_multilingual_network_name* ++ dvb_multilingual_network_name_descriptor_names_next(struct dvb_multilingual_network_name_descriptor *d, ++ struct dvb_multilingual_network_name *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + ++ sizeof(struct dvb_multilingual_network_name) + ++ pos->network_name_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_multilingual_network_name *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/multilingual_service_name_descriptor.h dvb-apps/lib/libucsi/dvb/multilingual_service_name_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/multilingual_service_name_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/multilingual_service_name_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,197 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_MULTILINGUAL_SERVICE_NAME_DESCRIPTOR ++#define _UCSI_DVB_MULTILINGUAL_SERVICE_NAME_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * dvb_multilingual_service_name_descriptor structure. ++ */ ++struct dvb_multilingual_service_name_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_multilingual_service_name names[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the service_names field of a dvb_multilingual_service_name_descriptor. ++ */ ++struct dvb_multilingual_service_name { ++ iso639lang_t language_code; ++ uint8_t service_provider_name_length; ++ /* uint8_t service_provider_name[] */ ++ /* struct dvb_multilingual_service_name_part2 part2 */ ++} __ucsi_packed; ++ ++/** ++ * Second part of a dvb_multilingual_service_name following the variable length ++ * service_provider_name. ++ */ ++struct dvb_multilingual_service_name_part2 { ++ uint8_t service_name_length; ++ /* uint8_t service_name[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_multilingual_service_name_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_multilingual_service_name_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_multilingual_service_name_descriptor* ++ dvb_multilingual_service_name_descriptor_codec(struct descriptor* d) ++{ ++ uint8_t* buf = (uint8_t*) d + 2; ++ uint32_t pos = 0; ++ uint32_t len = d->len; ++ ++ while(pos < len) { ++ struct dvb_multilingual_service_name *e = ++ (struct dvb_multilingual_service_name*) (buf+pos); ++ struct dvb_multilingual_service_name_part2 *e2; ++ ++ pos += sizeof(struct dvb_multilingual_service_name); ++ ++ if (pos > len) ++ return NULL; ++ ++ pos += e->service_provider_name_length; ++ ++ if (pos > len) ++ return NULL; ++ ++ e2 = (struct dvb_multilingual_service_name_part2*) (buf+pos); ++ ++ pos += sizeof(struct dvb_multilingual_service_name_part2); ++ ++ if (pos > len) ++ return NULL; ++ ++ pos += e2->service_name_length; ++ ++ if (pos > len) ++ return NULL; ++ } ++ ++ return (struct dvb_multilingual_service_name_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries in the service_name field of a dvb_multilingual_service_name_descriptor. ++ * ++ * @param d dvb_multilingual_service_name_descriptor pointer, ++ * @param pos Variable containing pointer to the current dvb_multilingual_service_name. ++ */ ++#define dvb_multilingual_service_name_descriptor_names_for_each(d, pos) \ ++ for ((pos) = dvb_multilingual_service_name_descriptor_names_first(d); \ ++ (pos); \ ++ (pos) = dvb_multilingual_service_name_descriptor_names_next(d, pos)) ++ ++/** ++ * Accessor for the service_provider_name field of a dvb_multilingual_service_name. ++ * ++ * @param e dvb_multilingual_service_name pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_multilingual_service_name_service_provider_name(struct dvb_multilingual_service_name *e) ++{ ++ return (uint8_t *) e + sizeof(struct dvb_multilingual_service_name); ++} ++ ++/** ++ * Accessor for the dvb_multilingual_service_name_part2 - second part of a ++ * dvb_multilingual_service_name following the service_name field. ++ * ++ * @param e dvb_multilingual_service_name Pointer. ++ * @return dvb_multilingual_service_name_part2 pointer. ++ */ ++static inline struct dvb_multilingual_service_name_part2 * ++ dvb_multilingual_service_name_part2(struct dvb_multilingual_service_name *e) ++{ ++ return (struct dvb_multilingual_service_name_part2 *) ++ ((uint8_t *) e + sizeof(struct dvb_multilingual_service_name) + ++ e->service_provider_name_length); ++} ++ ++/** ++ * Accessor for the service_name field of a dvb_multilingual_service_name_part2. ++ * ++ * @param e dvb_multilingual_service_name_part2 pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_multilingual_service_name_service_name(struct dvb_multilingual_service_name_part2 *e) ++{ ++ return (uint8_t *) e + sizeof(struct dvb_multilingual_service_name_part2); ++} ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_multilingual_service_name* ++ dvb_multilingual_service_name_descriptor_names_first(struct dvb_multilingual_service_name_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_multilingual_service_name *) ++ ((uint8_t*) d + sizeof(struct dvb_multilingual_service_name_descriptor)); ++} ++ ++static inline struct dvb_multilingual_service_name* ++ dvb_multilingual_service_name_descriptor_names_next(struct dvb_multilingual_service_name_descriptor *d, ++ struct dvb_multilingual_service_name *pos) ++{ ++ struct dvb_multilingual_service_name_part2 * part2 = ++ dvb_multilingual_service_name_part2(pos); ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) part2+ ++ sizeof(struct dvb_multilingual_service_name_part2) + ++ part2->service_name_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_multilingual_service_name *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/network_name_descriptor.h dvb-apps/lib/libucsi/dvb/network_name_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/network_name_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/network_name_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,82 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_NETWORK_NAME_DESCRIPTOR ++#define _UCSI_DVB_NETWORK_NAME_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_network_name_descriptor structure. ++ */ ++struct dvb_network_name_descriptor { ++ struct descriptor d; ++ ++ /* char name[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_network_name_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_network_name_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_network_name_descriptor* ++ dvb_network_name_descriptor_codec(struct descriptor* d) ++{ ++ return (struct dvb_network_name_descriptor*) d; ++} ++ ++/** ++ * Accessor for the name field in a dvb_network_name_descriptor. ++ * ++ * @param d dvb_network_name_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_network_name_descriptor_name(struct dvb_network_name_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_network_name_descriptor); ++} ++ ++/** ++ * Calculate the length of the name field in a dvb_network_name_descriptor. ++ * ++ * @param d dvb_network_name_descriptor pointer. ++ * @return Length of the field in bytes. ++ */ ++static inline int ++ dvb_network_name_descriptor_name_length(struct dvb_network_name_descriptor *d) ++{ ++ return d->d.len; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/nit_section.c dvb-apps/lib/libucsi/dvb/nit_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/nit_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/nit_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,78 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct dvb_nit_section *dvb_nit_section_codec(struct section_ext * ext) ++{ ++ uint8_t * buf = (uint8_t *) ext; ++ struct dvb_nit_section * ret = (struct dvb_nit_section *) ext; ++ size_t pos = sizeof(struct section_ext); ++ size_t len = section_ext_length(ext); ++ ++ if (len < sizeof(struct dvb_nit_section)) ++ return NULL; ++ ++ bswap16(buf + pos); ++ pos += 2; ++ ++ if ((pos + ret->network_descriptors_length) > len) ++ return NULL; ++ ++ if (verify_descriptors(buf + pos, ret->network_descriptors_length)) ++ return NULL; ++ ++ pos += ret->network_descriptors_length; ++ ++ if ((pos + sizeof(struct dvb_nit_section_part2)) > len) ++ return NULL; ++ ++ bswap16(buf + pos); ++ pos += 2; ++ ++ while (pos < len) { ++ struct dvb_nit_transport *transport = ++ (struct dvb_nit_transport *)(buf + pos); ++ ++ if ((pos + sizeof(struct dvb_nit_transport)) > len) ++ return NULL; ++ ++ bswap16(buf + pos); ++ bswap16(buf + pos + 2); ++ bswap16(buf + pos + 4); ++ ++ pos += sizeof(struct dvb_nit_transport); ++ ++ if ((pos + transport->transport_descriptors_length) > len) ++ return NULL; ++ ++ if (verify_descriptors(buf + pos, ++ transport->transport_descriptors_length)) ++ return NULL; ++ ++ pos += transport->transport_descriptors_length; ++ } ++ ++ if (pos != len) ++ return NULL; ++ ++ return ret; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/nit_section.h dvb-apps/lib/libucsi/dvb/nit_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/nit_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/nit_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,207 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_NIT_SECTION_H ++#define _UCSI_DVB_NIT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * dvb_nit_section structure. ++ */ ++struct dvb_nit_section { ++ struct section_ext head; ++ ++ EBIT2(uint16_t reserved_1 : 4; , ++ uint16_t network_descriptors_length :12; ); ++ /* struct descriptor descriptors[] */ ++ /* struct dvb_nit_section_part2 part2 */ ++}; ++ ++/** ++ * Second part of a dvb_nit_section, following the variable length descriptors field. ++ */ ++struct dvb_nit_section_part2 { ++ EBIT2(uint16_t reserved_2 : 4; , ++ uint16_t transport_stream_loop_length :12; ); ++ /* struct dvb_nit_transport transports[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the transports field of a dvb_nit_section_part2 ++ */ ++struct dvb_nit_transport { ++ uint16_t transport_stream_id; ++ uint16_t original_network_id; ++ EBIT2(uint16_t reserved : 4; , ++ uint16_t transport_descriptors_length :12; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_nit_section. ++ * ++ * @param section Generic section_ext pointer. ++ * @return dvb_nit_section pointer, or NULL on error. ++ */ ++struct dvb_nit_section * dvb_nit_section_codec(struct section_ext *section); ++ ++/** ++ * Accessor for the network_id field of a NIT. ++ * ++ * @param nit NIT pointer. ++ * @return The network_id. ++ */ ++static inline uint16_t dvb_nit_section_network_id(struct dvb_nit_section *nit) ++{ ++ return nit->head.table_id_ext; ++} ++ ++/** ++ * Iterator over the descriptors field in a dvb_nit_section. ++ * ++ * @param nit dvb_nit_section pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define dvb_nit_section_descriptors_for_each(nit, pos) \ ++ for ((pos) = dvb_nit_section_descriptors_first(nit); \ ++ (pos); \ ++ (pos) = dvb_nit_section_descriptors_next(nit, pos)) ++ ++/** ++ * Accessor for a pointer to the dvb_nit_section_part2 structure. ++ * ++ * @param nit dvb_nit_section pointer. ++ * @return dvb_nit_section_part2 pointer. ++ */ ++static inline struct dvb_nit_section_part2 *dvb_nit_section_part2(struct dvb_nit_section * nit) ++{ ++ return (struct dvb_nit_section_part2 *) ++ ((uint8_t*) nit + sizeof(struct dvb_nit_section) + ++ nit->network_descriptors_length); ++} ++ ++/** ++ * Iterator over the transports field in a dvb_nit_section_part2. ++ * ++ * @param nit dvb_nit_section pointer. ++ * @param part2 dvb_nit_section_part2 pointer. ++ * @param pos Pointer to the current dvb_nit_transport. ++ */ ++#define dvb_nit_section_transports_for_each(nit, part2, pos) \ ++ for ((pos) = dvb_nit_section_transports_first(part2); \ ++ (pos); \ ++ (pos) = dvb_nit_section_transports_next(part2, pos)) ++ ++/** ++ * Iterator over the descriptors field in a dvb_nit_transport. ++ * ++ * @param transport dvb_nit_transport pointer. ++ * @param pos Pointer to the current descriptor. ++ */ ++#define dvb_nit_transport_descriptors_for_each(transport, pos) \ ++ for ((pos) = dvb_nit_transport_descriptors_first(transport); \ ++ (pos); \ ++ (pos) = dvb_nit_transport_descriptors_next(transport, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct descriptor * ++ dvb_nit_section_descriptors_first(struct dvb_nit_section * nit) ++{ ++ if (nit->network_descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor *) ++ ((uint8_t *) nit + sizeof(struct dvb_nit_section)); ++} ++ ++static inline struct descriptor * ++ dvb_nit_section_descriptors_next(struct dvb_nit_section * nit, ++ struct descriptor* pos) ++{ ++ return next_descriptor((uint8_t*) nit + sizeof(struct dvb_nit_section), ++ nit->network_descriptors_length, ++ pos); ++} ++ ++static inline struct dvb_nit_transport * ++ dvb_nit_section_transports_first(struct dvb_nit_section_part2 *part2) ++{ ++ if (part2->transport_stream_loop_length == 0) ++ return NULL; ++ ++ return (struct dvb_nit_transport *) ++ ((uint8_t *)part2 + sizeof(struct dvb_nit_section_part2)); ++} ++ ++static inline struct dvb_nit_transport * ++ dvb_nit_section_transports_next(struct dvb_nit_section_part2 *part2, ++ struct dvb_nit_transport *pos) ++{ ++ uint8_t *end = (uint8_t*) part2 + sizeof(struct dvb_nit_section_part2) + ++ part2->transport_stream_loop_length; ++ uint8_t *next = (uint8_t*) pos + sizeof(struct dvb_nit_transport) + ++ pos->transport_descriptors_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_nit_transport *) next; ++} ++ ++static inline struct descriptor * ++ dvb_nit_transport_descriptors_first(struct dvb_nit_transport *t) ++{ ++ if (t->transport_descriptors_length == 0) ++ return NULL; ++ ++ return (struct descriptor *) ++ ((uint8_t*) t + sizeof(struct dvb_nit_transport)); ++} ++ ++static inline struct descriptor * ++ dvb_nit_transport_descriptors_next(struct dvb_nit_transport *t, ++ struct descriptor* pos) ++{ ++ return next_descriptor((uint8_t*) t + sizeof(struct dvb_nit_transport), ++ t->transport_descriptors_length, ++ pos); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/nvod_reference_descriptor.h dvb-apps/lib/libucsi/dvb/nvod_reference_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/nvod_reference_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/nvod_reference_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,125 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_NVOD_REFERENCE_DESCRIPTOR ++#define _UCSI_DVB_NVOD_REFERENCE_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_nvod_reference_descriptor structure. ++ */ ++struct dvb_nvod_reference_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_nvod_reference references[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the references field of a dvb_nvod_reference_descriptor. ++ */ ++struct dvb_nvod_reference { ++ uint16_t transport_stream_id; ++ uint16_t original_network_id; ++ uint16_t service_id; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_nvod_reference_descriptor. ++ * ++ * @param d Pointer to a generic descriptor structure pointer. ++ * @return dvb_nvod_reference_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_nvod_reference_descriptor* ++ dvb_nvod_reference_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t pos = 0; ++ uint8_t* buf = (uint8_t*) d + 2; ++ uint32_t len = d->len; ++ ++ if (len % sizeof(struct dvb_nvod_reference)) ++ return NULL; ++ ++ while(pos < len) { ++ bswap16(buf+pos); ++ bswap16(buf+pos+2); ++ bswap16(buf+pos+4); ++ pos += sizeof(struct dvb_nvod_reference); ++ } ++ ++ return (struct dvb_nvod_reference_descriptor*) d; ++} ++ ++/** ++ * Iterator over the references field in a dvb_nvod_reference_descriptor. ++ * ++ * @param d dvb_nvod_reference_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_nvod_reference. ++ */ ++#define dvb_nvod_reference_descriptor_references_for_each(d, pos) \ ++ for ((pos) = dvb_nvod_reference_descriptor_references_first(d); \ ++ (pos); \ ++ (pos) = dvb_nvod_reference_descriptor_references_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_nvod_reference* ++ dvb_nvod_reference_descriptor_references_first(struct dvb_nvod_reference_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_nvod_reference *) ++ ((uint8_t*) d + sizeof(struct dvb_nvod_reference_descriptor)); ++} ++ ++static inline struct dvb_nvod_reference* ++ dvb_nvod_reference_descriptor_references_next(struct dvb_nvod_reference_descriptor *d, ++ struct dvb_nvod_reference *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_nvod_reference); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_nvod_reference *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/parental_rating_descriptor.h dvb-apps/lib/libucsi/dvb/parental_rating_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/parental_rating_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/parental_rating_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,135 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_PARENTAL_RATING_DESCRIPTOR ++#define _UCSI_DVB_PARENTAL_RATING_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * Defined values for the rating field. ++ */ ++enum { ++ DVB_PARENTAL_RATING_MIN_3YEARS = 0x01, ++ DVB_PARENTAL_RATING_MIN_4YEARS = 0x02, ++ DVB_PARENTAL_RATING_MIN_5YEARS = 0x03, ++ DVB_PARENTAL_RATING_MIN_6YEARS = 0x04, ++ DVB_PARENTAL_RATING_MIN_7YEARS = 0x05, ++ DVB_PARENTAL_RATING_MIN_8YEARS = 0x06, ++ DVB_PARENTAL_RATING_MIN_9YEARS = 0x07, ++ DVB_PARENTAL_RATING_MIN_10YEARS = 0x08, ++ DVB_PARENTAL_RATING_MIN_11YEARS = 0x09, ++ DVB_PARENTAL_RATING_MIN_12YEARS = 0x0a, ++ DVB_PARENTAL_RATING_MIN_13YEARS = 0x0b, ++ DVB_PARENTAL_RATING_MIN_14YEARS = 0x0c, ++ DVB_PARENTAL_RATING_MIN_15YEARS = 0x0d, ++ DVB_PARENTAL_RATING_MIN_16YEARS = 0x0e, ++ DVB_PARENTAL_RATING_MIN_17YEARS = 0x0f, ++}; ++ ++/** ++ * dvb_parental_rating_descriptor structure. ++ */ ++struct dvb_parental_rating_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_parental_rating ratings[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the ratings field of a dvb_parental_rating_descriptor. ++ */ ++struct dvb_parental_rating { ++ iso639country_t country_code; ++ uint8_t rating; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_parental_rating_descriptor. ++ * ++ * @param d Generic descriptor structure pointer. ++ * @return dvb_parental_rating_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_parental_rating_descriptor* ++ dvb_parental_rating_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len % sizeof(struct dvb_parental_rating)) ++ return NULL; ++ ++ return (struct dvb_parental_rating_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries in the ratings field of a dvb_parental_rating_descriptor. ++ * ++ * @param d dvb_parental_rating_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_parental_rating. ++ */ ++#define dvb_parental_rating_descriptor_ratings_for_each(d, pos) \ ++ for ((pos) = dvb_parental_rating_descriptor_ratings_first(d); \ ++ (pos); \ ++ (pos) = dvb_parental_rating_descriptor_ratings_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_parental_rating* ++ dvb_parental_rating_descriptor_ratings_first(struct dvb_parental_rating_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_parental_rating *) ++ ((uint8_t*) d + sizeof(struct dvb_parental_rating_descriptor)); ++} ++ ++static inline struct dvb_parental_rating* ++ dvb_parental_rating_descriptor_ratings_next(struct dvb_parental_rating_descriptor *d, ++ struct dvb_parental_rating *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_parental_rating); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_parental_rating *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/partial_transport_stream_descriptor.h dvb-apps/lib/libucsi/dvb/partial_transport_stream_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/partial_transport_stream_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/partial_transport_stream_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,68 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_PARTIAL_TRANSPORT_STREAM_DESCRIPTOR ++#define _UCSI_DVB_PARTIAL_TRANSPORT_STREAM_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_partial_transport_stream_descriptor structure. ++ */ ++struct dvb_partial_transport_stream_descriptor { ++ struct descriptor d; ++ ++ EBIT6(uint64_t reserved : 2; , ++ uint64_t peak_rate :22; , ++ uint64_t reserved_2 : 2; , ++ uint64_t minimum_overall_smoothing_rate :22; , ++ uint64_t reserved_3 : 2; , ++ uint64_t maximum_overall_smoothing_rate :14; ); ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_partial_transport_stream_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_partial_transport_stream_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_partial_transport_stream_descriptor* ++ dvb_partial_transport_stream_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct dvb_partial_transport_stream_descriptor) - 2)) ++ return NULL; ++ ++ bswap64((uint8_t*) d + 2); ++ ++ return (struct dvb_partial_transport_stream_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/pdc_descriptor.h dvb-apps/lib/libucsi/dvb/pdc_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/pdc_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/pdc_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,64 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_PDC_DESCRIPTOR ++#define _UCSI_DVB_PDC_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_pdc_descriptor structure. ++ */ ++struct dvb_pdc_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint32_t reserved : 4; , ++ uint32_t programme_id_label :20; ); ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_pdc_descriptor. ++ * ++ * @param d Pointer to a generic descriptor structure. ++ * @return dvb_pdc_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_pdc_descriptor* ++ dvb_pdc_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct dvb_pdc_descriptor) - 2)) ++ return NULL; ++ ++ bswap24((uint8_t*) d + 2); ++ ++ return (struct dvb_pdc_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/private_data_specifier_descriptor.h dvb-apps/lib/libucsi/dvb/private_data_specifier_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/private_data_specifier_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/private_data_specifier_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,63 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_PRIVATE_DATA_SPECIFIER_DESCRIPTOR ++#define _UCSI_DVB_PRIVATE_DATA_SPECIFIER_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_private_data_specifier_descriptor structure. ++ */ ++struct dvb_private_data_specifier_descriptor { ++ struct descriptor d; ++ ++ uint32_t private_data_specifier; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_private_data_specifier_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return dvb_private_data_specifier_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_private_data_specifier_descriptor* ++ dvb_private_data_specifier_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct dvb_private_data_specifier_descriptor) - 2)) ++ return NULL; ++ ++ bswap32((uint8_t*) d + 2); ++ ++ return (struct dvb_private_data_specifier_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/related_content_descriptor.h dvb-apps/lib/libucsi/dvb/related_content_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/related_content_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/related_content_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,56 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_RELATED_CONTENT_DESCRIPTOR ++#define _UCSI_DVB_RELATED_CONTENT_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_related_content_descriptor structure. ++ */ ++struct dvb_related_content_descriptor { ++ struct descriptor d; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_related_content_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_related_content_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_related_content_descriptor* ++ dvb_related_content_descriptor_codec(struct descriptor* d) ++{ ++ return (struct dvb_related_content_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/rnt_rar_over_dvb_stream_descriptor.h dvb-apps/lib/libucsi/dvb/rnt_rar_over_dvb_stream_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/rnt_rar_over_dvb_stream_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/rnt_rar_over_dvb_stream_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,110 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_RNT_RAR_OVER_DVB_STREAM_DESCRIPTOR ++#define _UCSI_DVB_RNT_RAR_OVER_DVB_STREAM_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_rnt_rar_over_dvb_stream_descriptor structure. ++ */ ++struct dvb_rnt_rar_over_dvb_stream_descriptor { ++ struct descriptor d; ++ ++ dvbdate_t first_valid_date; ++ dvbdate_t last_valid_date; ++ EBIT3(uint8_t weighting : 6; , ++ uint8_t complete_flag : 1; , ++ uint8_t scheduled_flag : 1; ); ++ uint16_t transport_stream_id; ++ uint16_t original_network_id; ++ uint16_t service_id; ++ uint8_t component_tag; ++ /* struct dvb_rnt_rar_over_dvb_stream_descriptor_scheduled_info scheduled_info */ ++} __ucsi_packed; ++ ++/** ++ * The scheduled_info field of a dvb_rnt_rar_over_dvb_stream_descriptor (only appears ++ * if scheduled_flag = 1). ++ */ ++struct dvb_rnt_rar_over_dvb_stream_descriptor_scheduled_info { ++ dvbdate_t download_start_time; ++ uint8_t download_period_duration; ++ uint8_t download_cycle_time; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_rnt_rar_over_dvb_stream_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_rnt_rar_over_dvb_stream_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_rnt_rar_over_dvb_stream_descriptor* ++ dvb_rnt_rar_over_dvb_stream_descriptor_codec(struct descriptor* d) ++{ ++ uint8_t *buf = (uint8_t*) d; ++ uint32_t len = d->len + 2; ++ struct dvb_rnt_rar_over_dvb_stream_descriptor *ret = ++ (struct dvb_rnt_rar_over_dvb_stream_descriptor *) buf; ++ ++ if (len < sizeof(struct dvb_rnt_rar_over_dvb_stream_descriptor)) ++ return NULL; ++ ++ bswap16(buf + 13); ++ bswap16(buf + 15); ++ bswap16(buf + 17); ++ ++ if (ret->scheduled_flag == 1) { ++ if (len < (sizeof(struct dvb_rnt_rar_over_dvb_stream_descriptor)+ ++ sizeof(struct dvb_rnt_rar_over_dvb_stream_descriptor_scheduled_info))) ++ return NULL; ++ } ++ ++ return ret; ++} ++ ++/** ++ * Accessor for the scheduled_info field of a dvb_rnt_rar_over_dvb_stream_descriptor. ++ * ++ * @param d dvb_rnt_rar_over_dvb_stream_descriptor pointer. ++ * @return Pointer, or NULL on error. ++ */ ++static inline struct dvb_rnt_rar_over_dvb_stream_descriptor_scheduled_info* ++ dvb_rnt_rar_over_dvb_stream_descriptor_scheduled_info(struct dvb_rnt_rar_over_dvb_stream_descriptor *d) ++{ ++ if (d->scheduled_flag != 1) ++ return NULL; ++ return (struct dvb_rnt_rar_over_dvb_stream_descriptor_scheduled_info*) ++ ((uint8_t*) d + sizeof(struct dvb_rnt_rar_over_dvb_stream_descriptor)); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/rnt_rar_over_ip_descriptor.h dvb-apps/lib/libucsi/dvb/rnt_rar_over_ip_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/rnt_rar_over_ip_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/rnt_rar_over_ip_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,87 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_RNT_RAR_OVER_IP_DESCRIPTOR ++#define _UCSI_DVB_RNT_RAR_OVER_IP_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_rnt_rar_over_ip_descriptor structure. ++ */ ++struct dvb_rnt_rar_over_ip_descriptor { ++ struct descriptor d; ++ ++ dvbdate_t first_valid_date; ++ dvbdate_t last_valid_date; ++ EBIT3(uint8_t weighting : 6; , ++ uint8_t complete_flag : 1; , ++ uint8_t reserved : 1; ); ++ uint8_t url_length; ++ /* uint8_t url[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_rnt_rar_over_ip_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_rnt_rar_over_ip_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_rnt_rar_over_ip_descriptor* ++ dvb_rnt_rar_over_ip_descriptor_codec(struct descriptor* d) ++{ ++ uint8_t *buf = (uint8_t*) d; ++ uint32_t len = d->len + 2; ++ struct dvb_rnt_rar_over_ip_descriptor *ret = ++ (struct dvb_rnt_rar_over_ip_descriptor *) buf; ++ ++ if (len < sizeof(struct dvb_rnt_rar_over_ip_descriptor)) ++ return NULL; ++ if (len < (sizeof(struct dvb_rnt_rar_over_ip_descriptor) + buf[13])) ++ return NULL; ++ ++ return ret; ++} ++ ++/** ++ * Accessor for the url field of a dvb_rnt_rar_over_ip_descriptor. ++ * ++ * @param d dvb_rnt_rar_over_ip_descriptor pointer. ++ * @return Pointer. ++ */ ++static inline uint8_t* ++ dvb_rnt_rar_over_ip_descriptor_url(struct dvb_rnt_rar_over_ip_descriptor *d) ++{ ++ return (uint8_t*) ++ ((uint8_t*) d + sizeof(struct dvb_rnt_rar_over_ip_descriptor)); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/rnt_rnt_scan_descriptor.h dvb-apps/lib/libucsi/dvb/rnt_rnt_scan_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/rnt_rnt_scan_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/rnt_rnt_scan_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,125 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_RNT_RNT_SCAN_DESCRIPTOR ++#define _UCSI_DVB_RNT_RNT_SCAN_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * dvb_rnt_rnt_scan_descriptor structure. ++ */ ++struct dvb_rnt_rnt_scan_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_rnt_rnt_scan_entry entries[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the entries field of a dvb_rnt_rnt_scan_descriptor. ++ */ ++struct dvb_rnt_rnt_scan_entry { ++ uint16_t transport_stream_id; ++ uint16_t original_network_id; ++ uint8_t scan_weighting; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_rnt_rnt_scan_descriptor. ++ * ++ * @param d Generic descriptor. ++ * @return dvb_rnt_rnt_scan_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_rnt_rnt_scan_descriptor* ++ dvb_rnt_rnt_scan_descriptor_codec(struct descriptor* d) ++{ ++ uint8_t *buf = (uint8_t*) d; ++ uint32_t len = d->len +2; ++ uint32_t pos = 2; ++ ++ if ((len-2) % sizeof(struct dvb_rnt_rnt_scan_entry)) ++ return NULL; ++ ++ while(pos < len) { ++ bswap16(buf+pos); ++ bswap16(buf+pos+2); ++ pos += sizeof(struct dvb_rnt_rnt_scan_entry); ++ } ++ ++ return (struct dvb_rnt_rnt_scan_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries field of a dvb_rnt_rnt_scan_descriptor. ++ * ++ * @param d dvb_rnt_rnt_scan_descriptor pointer. ++ * @param pos Variable holding a pointer to the current dvb_rnt_rnt_scan_entry. ++ */ ++#define dvb_rnt_rnt_scan_descriptor_entries_for_each(d, pos) \ ++ for ((pos) = dvb_rnt_rnt_scan_descriptor_entries_first(d); \ ++ (pos); \ ++ (pos) = dvb_rnt_rnt_scan_descriptor_entries_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_rnt_rnt_scan_entry* ++ dvb_rnt_rnt_scan_descriptor_entries_first(struct dvb_rnt_rnt_scan_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_rnt_rnt_scan_entry *) ++ ((uint8_t*) d + sizeof(struct dvb_rnt_rnt_scan_descriptor)); ++} ++ ++static inline struct dvb_rnt_rnt_scan_entry* ++ dvb_rnt_rnt_scan_descriptor_entries_next(struct dvb_rnt_rnt_scan_descriptor *d, ++ struct dvb_rnt_rnt_scan_entry *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_rnt_rnt_scan_entry); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_rnt_rnt_scan_entry *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/rst_section.c dvb-apps/lib/libucsi/dvb/rst_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/rst_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/rst_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,47 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct dvb_rst_section * dvb_rst_section_codec(struct section *section) ++{ ++ uint8_t * buf = (uint8_t *) section; ++ size_t pos = sizeof(struct section); ++ size_t len = section_length(section); ++ struct dvb_rst_section * ret = (struct dvb_rst_section *) section; ++ ++ while (pos < len) { ++ if ((pos + sizeof(struct dvb_rst_status)) > len) ++ return NULL; ++ ++ bswap16(buf + pos); ++ bswap16(buf + pos + 2); ++ bswap16(buf + pos + 4); ++ bswap16(buf + pos + 6); ++ ++ pos += sizeof(struct dvb_rst_status); ++ } ++ ++ if (pos != len) ++ return NULL; ++ ++ return ret; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/rst_section.h dvb-apps/lib/libucsi/dvb/rst_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/rst_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/rst_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,110 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_RST_SECTION_H ++#define _UCSI_DVB_RST_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * dvb_rst_section structure. ++ */ ++struct dvb_rst_section { ++ struct section head; ++ ++ /* struct dvb_rst_status statuses[] */ ++}; ++ ++/** ++ * An entry in the statuses field of a dvb_rst_section structure. ++ */ ++struct dvb_rst_status { ++ uint16_t transport_stream_id; ++ uint16_t original_network_id; ++ uint16_t service_id; ++ uint16_t event_id; ++ EBIT2(uint8_t reserved : 5; , ++ uint8_t running_status : 3; ); ++}; ++ ++/** ++ * Process a dvb_rst_section. ++ * ++ * @param section Pointer to a generic section strcuture. ++ * @return dvb_rst_section pointer, or NULL on error. ++ */ ++struct dvb_rst_section *dvb_rst_section_codec(struct section *section); ++ ++/** ++ * Iterator for entries in the statuses field of a dvb_rst_section. ++ * ++ * @param rst dvb_rst_section pointer. ++ * @param pos Variable containing a pointer to the current dvb_rst_status. ++ */ ++#define dvb_rst_section_statuses_for_each(rst, pos) \ ++ for ((pos) = dvb_rst_section_statuses_first(rst); \ ++ (pos); \ ++ (pos) = dvb_rst_section_statuses_next(rst, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_rst_status * ++ dvb_rst_section_statuses_first(struct dvb_rst_section *rst) ++{ ++ size_t pos = sizeof(struct dvb_rst_section); ++ ++ if (pos >= section_length(&rst->head)) ++ return NULL; ++ ++ return (struct dvb_rst_status*) ((uint8_t *) rst + pos); ++} ++ ++static inline struct dvb_rst_status * ++ dvb_rst_section_statuses_next(struct dvb_rst_section * rst, ++ struct dvb_rst_status * pos) ++{ ++ uint8_t *end = (uint8_t*) rst + section_length(&rst->head); ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_rst_status); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_rst_status *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/s2_satellite_delivery_descriptor.h dvb-apps/lib/libucsi/dvb/s2_satellite_delivery_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/s2_satellite_delivery_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/s2_satellite_delivery_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,116 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_S2_SATELLITE_DELIVERY_DESCRIPTOR ++#define _UCSI_DVB_S2_SATELLITE_DELIVERY_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_s2_satellite_delivery_descriptor structure. ++ */ ++struct dvb_s2_satellite_delivery_descriptor { ++ struct descriptor d; ++ ++ EBIT4(uint8_t scrambling_sequence_selector : 1; , ++ uint8_t multiple_input_stream : 1; , ++ uint8_t backwards_compatability : 1; , ++ uint8_t reserved : 5; ); ++ /* uint32_t scrambling_sequence_index if scrambling_sequence_selector = 1 */ ++ /* uint8_t input_stream_id if multiple_input_stream = 1 */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_s2_satellite_delivery_descriptor. ++ * ++ * @param d Pointer to a generic descriptor structure. ++ * @return dvb_s2_satellite_delivery_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_s2_satellite_delivery_descriptor* ++ dvb_s2_satellite_delivery_descriptor_codec(struct descriptor* d) ++{ ++ struct dvb_s2_satellite_delivery_descriptor *s2 = ++ (struct dvb_s2_satellite_delivery_descriptor*) d; ++ ++ if (d->len < (sizeof(struct dvb_s2_satellite_delivery_descriptor) - 2)) ++ return NULL; ++ ++ int len = sizeof(struct dvb_s2_satellite_delivery_descriptor); ++ if (s2->scrambling_sequence_selector) { ++ len += 3; ++ } ++ if (s2->multiple_input_stream) { ++ len += 1; ++ } ++ ++ if (d->len < len) ++ return NULL; ++ ++ return s2; ++} ++ ++/** ++ * Accessor for the scrambling_sequence_index field of a dvb_s2_satellite_delivery_descriptor. ++ * ++ * @param s2 dvb_s2_satellite_delivery_descriptor pointer. ++ * @return The scrambling_sequence_index. ++ */ ++static inline uint32_t dvb_s2_satellite_delivery_descriptor_scrambling_sequence_index(struct dvb_s2_satellite_delivery_descriptor *s2) ++{ ++ uint8_t *tmp = (uint8_t*) s2; ++ ++ if (s2->scrambling_sequence_selector) { ++ return ((tmp[4] & 0x03) << 16) | (tmp[5] << 8) | tmp[6]; ++ } ++ return 0; ++} ++ ++/** ++ * Accessor for the input_stream_id field of a dvb_s2_satellite_delivery_descriptor. ++ * ++ * @param s2 dvb_s2_satellite_delivery_descriptor pointer. ++ * @return The input_stream_id. ++ */ ++static inline uint8_t dvb_s2_satellite_delivery_descriptor_input_stream_id(struct dvb_s2_satellite_delivery_descriptor *s2) ++{ ++ uint8_t *tmp = (uint8_t*) s2; ++ ++ if (!s2->multiple_input_stream) ++ return 0; ++ ++ int off = 3; ++ if (s2->scrambling_sequence_selector) { ++ off += 3; ++ } ++ return tmp[off]; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/satellite_delivery_descriptor.h dvb-apps/lib/libucsi/dvb/satellite_delivery_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/satellite_delivery_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/satellite_delivery_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,73 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_SATELLITE_DELIVERY_DESCRIPTOR ++#define _UCSI_DVB_SATELLITE_DELIVERY_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_satellite_delivery_descriptor structure. ++ */ ++struct dvb_satellite_delivery_descriptor { ++ struct descriptor d; ++ ++ uint32_t frequency; // BCD, units 10kHz ++ uint16_t orbital_position; ++ EBIT5(uint8_t west_east_flag : 1; , ++ uint8_t polarization : 2; , ++ uint8_t roll_off : 2; , ++ uint8_t modulation_system : 1; , ++ uint8_t modulation_type : 2; ); ++ EBIT2(uint32_t symbol_rate : 28; , // BCD, units 100Hz ++ uint32_t fec_inner : 4; ); ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_satellite_delivery_descriptor. ++ * ++ * @param d Pointer to a generic descriptor structure. ++ * @return dvb_satellite_delivery_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_satellite_delivery_descriptor* ++ dvb_satellite_delivery_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len < (sizeof(struct dvb_satellite_delivery_descriptor) - 2)) ++ return NULL; ++ ++ bswap32((uint8_t*) d + 2); ++ bswap16((uint8_t*) d + 6); ++ bswap32((uint8_t*) d + 9); ++ ++ return (struct dvb_satellite_delivery_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/scrambling_descriptor.h dvb-apps/lib/libucsi/dvb/scrambling_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/scrambling_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/scrambling_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,61 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_SCRAMBLING_DESCRIPTOR ++#define _UCSI_DVB_SCRAMBLING_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_scrambling_descriptor structure. ++ */ ++struct dvb_scrambling_descriptor { ++ struct descriptor d; ++ ++ uint8_t scrambling_mode; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_scrambling_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return Pointer to dvb_scrambling_descriptor, or NULL on error. ++ */ ++static inline struct dvb_scrambling_descriptor* ++ dvb_scrambling_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct dvb_scrambling_descriptor) - 2)) ++ return NULL; ++ ++ return (struct dvb_scrambling_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/sdt_section.c dvb-apps/lib/libucsi/dvb/sdt_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/sdt_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/sdt_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,60 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct dvb_sdt_section * dvb_sdt_section_codec(struct section_ext * ext) ++{ ++ uint8_t * buf = (uint8_t *) ext; ++ size_t pos = sizeof(struct section_ext); ++ size_t len = section_ext_length(ext); ++ ++ if (len < sizeof(struct dvb_sdt_section)) ++ return NULL; ++ ++ bswap16(buf + pos); ++ pos += 3; ++ ++ while (pos < len) { ++ struct dvb_sdt_service * service = ++ (struct dvb_sdt_service *)(buf + pos); ++ ++ if ((pos + sizeof(struct dvb_sdt_service)) > len) ++ return NULL; ++ ++ bswap16(buf + pos); ++ bswap16(buf + pos + 3); ++ pos += sizeof(struct dvb_sdt_service); ++ ++ if ((pos + service->descriptors_loop_length) > len) ++ return NULL; ++ ++ if (verify_descriptors(buf + pos, service->descriptors_loop_length)) ++ return NULL; ++ ++ pos += service->descriptors_loop_length; ++ } ++ ++ if (pos != len) ++ return NULL; ++ ++ return (struct dvb_sdt_section *) ext; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/sdt_section.h dvb-apps/lib/libucsi/dvb/sdt_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/sdt_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/sdt_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,157 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_SDT_SECTION_H ++#define _UCSI_DVB_SDT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * dvb_sdt_section structure. ++ */ ++struct dvb_sdt_section { ++ struct section_ext head; ++ ++ uint16_t original_network_id; ++ uint8_t reserved; ++ /* struct dvb_sdt_service services[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the services field of a dvb_sdt_section. ++ */ ++struct dvb_sdt_service { ++ uint16_t service_id; ++ EBIT3(uint8_t reserved : 6; , ++ uint8_t eit_schedule_flag : 1; , ++ uint8_t eit_present_following_flag : 1; ); ++ EBIT3(uint16_t running_status : 3; , ++ uint16_t free_ca_mode : 1; , ++ uint16_t descriptors_loop_length :12; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_sdt_section. ++ * ++ * @param section Pointer to a generic section_ext structure. ++ * @return dvb_sdt_section pointer, or NULL on error. ++ */ ++struct dvb_sdt_section * dvb_sdt_section_codec(struct section_ext *section); ++ ++/** ++ * Accessor for the transport_stream_id field of an SDT. ++ * ++ * @param sdt SDT pointer. ++ * @return The transport_stream_id. ++ */ ++static inline uint16_t dvb_sdt_section_transport_stream_id(struct dvb_sdt_section *sdt) ++{ ++ return sdt->head.table_id_ext; ++} ++ ++/** ++ * Iterator for the services field in a dvb_sdt_section. ++ * ++ * @param sdt dvb_sdt_section pointer. ++ * @param pos Variable containing a pointer to the current dvb_sdt_service. ++ */ ++#define dvb_sdt_section_services_for_each(sdt, pos) \ ++ for ((pos) = dvb_sdt_section_services_first(sdt); \ ++ (pos); \ ++ (pos) = dvb_sdt_section_services_next(sdt, pos)) ++ ++/** ++ * Iterator for the descriptors field in a dvb_sdt_service. ++ * ++ * @param service dvb_sdt_service pointer. ++ * @param pos Variable containing a pointer to the current descriptor. ++ */ ++#define dvb_sdt_service_descriptors_for_each(service, pos) \ ++ for ((pos) = dvb_sdt_service_descriptors_first(service); \ ++ (pos); \ ++ (pos) = dvb_sdt_service_descriptors_next(service, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_sdt_service * ++ dvb_sdt_section_services_first(struct dvb_sdt_section * sdt) ++{ ++ size_t pos = sizeof(struct dvb_sdt_section); ++ ++ if (pos >= section_ext_length(&sdt->head)) ++ return NULL; ++ ++ return (struct dvb_sdt_service*) ((uint8_t *) sdt + pos); ++} ++ ++static inline struct dvb_sdt_service * ++ dvb_sdt_section_services_next(struct dvb_sdt_section * sdt, ++ struct dvb_sdt_service * pos) ++{ ++ uint8_t *end = (uint8_t*) sdt + section_ext_length(&sdt->head); ++ uint8_t *next = (uint8_t*) pos + sizeof(struct dvb_sdt_service) + ++ pos->descriptors_loop_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_sdt_service *) next; ++} ++ ++static inline struct descriptor * ++ dvb_sdt_service_descriptors_first(struct dvb_sdt_service *svc) ++{ ++ if (svc->descriptors_loop_length == 0) ++ return NULL; ++ ++ return (struct descriptor *) ++ ((uint8_t*) svc + sizeof(struct dvb_sdt_service)); ++} ++ ++static inline struct descriptor * ++ dvb_sdt_service_descriptors_next(struct dvb_sdt_service *svc, ++ struct descriptor* pos) ++{ ++ return next_descriptor((uint8_t*) svc + sizeof(struct dvb_sdt_service), ++ svc->descriptors_loop_length, ++ pos); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/section.h dvb-apps/lib/libucsi/dvb/section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,108 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_SECTION_H ++#define _UCSI_DVB_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/** ++ * The following are not implemented just now. ++ */ ++/* ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++*/ ++ ++#define TRANSPORT_NIT_PID 0x10 ++#define TRANSPORT_SDT_PID 0x11 ++#define TRANSPORT_BAT_PID 0x11 ++#define TRANSPORT_EIT_PID 0x12 ++#define TRANSPORT_CIT_PID 0x12 ++#define TRANSPORT_RST_PID 0x13 ++#define TRANSPORT_TDT_PID 0x14 ++#define TRANSPORT_TOT_PID 0x14 ++#define TRANSPORT_RNT_PID 0x16 ++#define TRANSPORT_DIT_PID 0x1e ++#define TRANSPORT_SIT_PID 0x1f ++ ++/** ++ * Enumeration of DVB section tags. ++ */ ++enum dvb_section_tag { ++ stag_dvb_network_information_actual = 0x40, ++ stag_dvb_network_information_other = 0x41, ++ ++ stag_dvb_service_description_actual = 0x42, ++ stag_dvb_service_description_other = 0x46, ++ ++ stag_dvb_bouquet_association = 0x4a, ++ stag_dvb_update_notification = 0x4b, /* same syntax as IP_MAC */ ++ stag_dvb_ip_mac_notification = 0x4c, ++ ++ stag_dvb_event_information_nownext_actual = 0x4e, ++ stag_dvb_event_information_nownext_other = 0x4f, ++ stag_dvb_event_information_schedule_actual = 0x50, /* 0x50->0x5f */ ++ stag_dvb_event_information_schedule_other = 0x60, /* 0x60->0x6f */ ++ ++ stag_dvb_time_date = 0x70, ++ stag_dvb_running_status = 0x71, ++ stag_dvb_stuffing = 0x72, ++ stag_dvb_time_offset = 0x73, ++ stag_dvb_application_information = 0x74, ++ stag_dvb_tva_container = 0x75, ++ stag_dvb_tva_related_content = 0x76, ++ stag_dvb_tva_content_identifier = 0x77, ++ stag_dvb_mpe_fec = 0x78, ++ stag_dvb_tva_resolution_provider_notification = 0x79, ++ ++ stag_dvb_discontinuity_information = 0x7e, ++ stag_dvb_selection_information = 0x7f, ++ ++}; ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/service_availability_descriptor.h dvb-apps/lib/libucsi/dvb/service_availability_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/service_availability_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/service_availability_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,98 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_SERVICE_AVAILABILITY_DESCRIPTOR ++#define _UCSI_DVB_SERVICE_AVAILABILITY_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_service_availability_descriptor structure. ++ */ ++struct dvb_service_availability_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint8_t availability_flag : 1; , ++ uint8_t reserved : 7; ); ++ /* uint16_t cell_ids[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_service_availability_descriptor. ++ * ++ * @param d Pointer to a generic descriptor structure. ++ * @return dvb_service_availability_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_service_availability_descriptor* ++ dvb_service_availability_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t pos = 0; ++ uint8_t* buf = (uint8_t*) d + 2; ++ uint32_t len = d->len; ++ ++ pos += sizeof(struct dvb_service_availability_descriptor) - 2; ++ ++ if ((len - pos) % 2) ++ return NULL; ++ ++ while(pos < len) { ++ bswap16(buf+pos); ++ pos += 2; ++ } ++ ++ return (struct dvb_service_availability_descriptor*) d; ++} ++ ++/** ++ * Accessor for the cell_ids field of a dvb_service_availability_descriptor. ++ * ++ * @param d dvb_service_availability_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint16_t * ++ dvb_service_availability_descriptor_cell_ids(struct dvb_service_availability_descriptor *d) ++{ ++ return (uint16_t *) ((uint8_t *) d + sizeof(struct dvb_service_availability_descriptor)); ++} ++ ++/** ++ * Determine the number of entries in the cell_ids field of a dvb_service_availability_descriptor. ++ * ++ * @param d dvb_service_availability_descriptor pointer. ++ * @return The number of entries. ++ */ ++static inline int ++ dvb_service_availability_descriptor_cell_ids_count(struct dvb_service_availability_descriptor *d) ++{ ++ return (d->d.len - 1) >> 1; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/service_descriptor.h dvb-apps/lib/libucsi/dvb/service_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/service_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/service_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,163 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_SERVICE_DESCRIPTOR ++#define _UCSI_DVB_SERVICE_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * Possible values for service_type. ++ */ ++enum { ++ DVB_SERVICE_TYPE_DIGITAL_TV = 0x01, ++ DVB_SERVICE_TYPE_DIGITAL_RADIO = 0x02, ++ DVB_SERVICE_TYPE_TELETEXT = 0x03, ++ DVB_SERVICE_TYPE_NVOD_REF = 0x04, ++ DVB_SERVICE_TYPE_NVOD_TIMESHIFT = 0x05, ++ DVB_SERVICE_TYPE_MOSAIC = 0x06, ++ DVB_SERVICE_TYPE_PAL = 0x07, ++ DVB_SERVICE_TYPE_SECAM = 0x08, ++ DVB_SERVICE_TYPE_D_D2_MAC = 0x09, ++ DVB_SERVICE_TYPE_FM_RADIO = 0x0a, ++ DVB_SERVICE_TYPE_NTSC = 0x0b, ++ DVB_SERVICE_TYPE_DATA_BCAST = 0x0c, ++ DVB_SERVICE_TYPE_EN50221 = 0x0d, ++ DVB_SERVICE_TYPE_RCS_MAP = 0x0e, ++ DVB_SERVICE_TYPE_RCS_FLS = 0x0f, ++ DVB_SERVICE_TYPE_MHP = 0x10, ++ DVB_SERVICE_TYPE_MPEG2_HD_DIGITAL_TV = 0x11, ++ DVB_SERVICE_TYPE_ADVANCED_CODEC_SD_DIGITAL_TV = 0x16, ++ DVB_SERVICE_TYPE_ADVANCED_CODEC_SD_NVOD_TIMESHIFT = 0x17, ++ DVB_SERVICE_TYPE_ADVANCED_CODEC_SD_NVOD_REF = 0x18, ++ DVB_SERVICE_TYPE_ADVANCED_CODEC_HD_DIGITAL_TV = 0x19, ++ DVB_SERVICE_TYPE_ADVANCED_CODEC_HD_NVOD_TIMESHIFT = 0x1a, ++ DVB_SERVICE_TYPE_ADVANCED_CODEC_HD_NVOD_REF = 0x1b, ++}; ++ ++/** ++ * dvb_service_descriptor structure. ++ */ ++struct dvb_service_descriptor { ++ struct descriptor d; ++ ++ uint8_t service_type; ++ uint8_t service_provider_name_length; ++ /* uint8_t service_provider_name[] */ ++ /* struct dvb_service_descriptor_part2 part2 */ ++} __ucsi_packed; ++ ++/** ++ * Second part of a dvb_service_descriptor following the variable length ++ * service_provider_name field. ++ */ ++struct dvb_service_descriptor_part2 { ++ uint8_t service_name_length; ++ /* uint8_t service_name[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_service_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_service_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_service_descriptor* ++ dvb_service_descriptor_codec(struct descriptor* d) ++{ ++ struct dvb_service_descriptor *p = ++ (struct dvb_service_descriptor *) d; ++ struct dvb_service_descriptor_part2 *p2; ++ uint32_t pos = sizeof(struct dvb_service_descriptor) - 2; ++ uint32_t len = d->len; ++ ++ if (pos > len) ++ return NULL; ++ ++ pos += p->service_provider_name_length; ++ ++ if (pos > len) ++ return NULL; ++ ++ p2 = (struct dvb_service_descriptor_part2*) ((uint8_t*) d + 2 + pos); ++ ++ pos += sizeof(struct dvb_service_descriptor_part2); ++ ++ if (pos > len) ++ return NULL; ++ ++ pos += p2->service_name_length; ++ ++ if (pos != len) ++ return NULL; ++ ++ return p; ++} ++ ++/** ++ * Accessor for the service_provider_name field of a dvb_service_descriptor. ++ * ++ * @param d dvb_service_descriptor pointer. ++ * @return Pointer to the service_provider_name field. ++ */ ++static inline uint8_t * ++ dvb_service_descriptor_service_provider_name(struct dvb_service_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_service_descriptor); ++} ++ ++/** ++ * Accessor for the second part of a dvb_service_descriptor. ++ * ++ * @param d dvb_service_descriptor pointer. ++ * @return dvb_service_descriptor_part2 pointer. ++ */ ++static inline struct dvb_service_descriptor_part2 * ++ dvb_service_descriptor_part2(struct dvb_service_descriptor *d) ++{ ++ return (struct dvb_service_descriptor_part2 *) ++ ((uint8_t*) d + sizeof(struct dvb_service_descriptor) + ++ d->service_provider_name_length); ++} ++ ++/** ++ * Accessor for the service_name field of a dvb_service_descriptor_part2. ++ * ++ * @param d dvb_service_descriptor_part2 pointer. ++ * @return Pointer to the service_name field. ++ */ ++static inline uint8_t * ++ dvb_service_descriptor_service_name(struct dvb_service_descriptor_part2 *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_service_descriptor_part2); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/service_identifier_descriptor.h dvb-apps/lib/libucsi/dvb/service_identifier_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/service_identifier_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/service_identifier_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,82 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_SERVICE_IDENTIFIER_DESCRIPTOR ++#define _UCSI_DVB_SERVICE_IDENTIFIER_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_service_identifier_descriptor. ++ */ ++struct dvb_service_identifier_descriptor { ++ struct descriptor d; ++ ++ /* uint8_t identifier[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_service_identifier_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return dvb_service_identifier_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_service_identifier_descriptor* ++ dvb_service_identifier_descriptor_codec(struct descriptor* d) ++{ ++ return (struct dvb_service_identifier_descriptor*) d; ++} ++ ++/** ++ * Retrieve a pointer to the identifier field of a dvb_service_identifier_descriptor. ++ * ++ * @param d dvb_service_identifier_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_service_identifier_descriptor_identifier(struct dvb_service_identifier_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_service_identifier_descriptor); ++} ++ ++/** ++ * Calculate length of the identifier field of a dvb_service_identifier_descriptor. ++ * ++ * @param d dvb_service_identifier_descriptor pointer. ++ * @return The length in bytes. ++ */ ++static inline int ++ dvb_service_identifier_descriptor_identifier_length(struct dvb_service_identifier_descriptor *d) ++{ ++ return d->d.len; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/service_list_descriptor.h dvb-apps/lib/libucsi/dvb/service_list_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/service_list_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/service_list_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,122 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_SERVICE_LIST_DESCRIPTOR ++#define _UCSI_DVB_SERVICE_LIST_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_service_list_descriptor structure. ++ */ ++struct dvb_service_list_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_service_list_service services[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the services field of a dvb_service_list_descriptor. ++ */ ++struct dvb_service_list_service { ++ uint16_t service_id; ++ uint8_t service_type; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_service_list_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return dvb_service_list_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_service_list_descriptor* ++ dvb_service_list_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t pos = 0; ++ uint32_t len = d->len; ++ uint8_t *p = (uint8_t*) d + 2; ++ ++ if (len % sizeof(struct dvb_service_list_service)) ++ return NULL; ++ ++ while(pos < len) { ++ bswap16(p+pos); ++ pos += sizeof(struct dvb_service_list_service); ++ } ++ ++ return (struct dvb_service_list_descriptor*) d; ++} ++ ++/** ++ * Iterator for services field in a dvb_service_list_descriptor. ++ * ++ * @param d dvb_service_list_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_service_list_service. ++ */ ++#define dvb_service_list_descriptor_services_for_each(d, pos) \ ++ for ((pos) = dvb_service_list_descriptor_services_first(d); \ ++ (pos); \ ++ (pos) = dvb_service_list_descriptor_services_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_service_list_service* ++ dvb_service_list_descriptor_services_first(struct dvb_service_list_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_service_list_service *) ++ ((uint8_t*) d + sizeof(struct dvb_service_list_descriptor)); ++} ++ ++static inline struct dvb_service_list_service* ++ dvb_service_list_descriptor_services_next(struct dvb_service_list_descriptor *d, ++ struct dvb_service_list_service *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_service_list_service); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_service_list_service *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/service_move_descriptor.h dvb-apps/lib/libucsi/dvb/service_move_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/service_move_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/service_move_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,67 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_SERVICE_MOVE_DESCRIPTOR ++#define _UCSI_DVB_SERVICE_MOVE_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_service_move_descriptor structure. ++ */ ++struct dvb_service_move_descriptor { ++ struct descriptor d; ++ ++ uint16_t new_original_network_id; ++ uint16_t new_transport_stream_id; ++ uint16_t new_service_id; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_service_move_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return Pointer to dvb_service_move_descriptor, or NULL on error. ++ */ ++static inline struct dvb_service_move_descriptor* ++ dvb_service_move_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct dvb_service_move_descriptor) - 2)) ++ return NULL; ++ ++ bswap16((uint8_t*) d + 2); ++ bswap16((uint8_t*) d + 4); ++ bswap16((uint8_t*) d + 6); ++ ++ return (struct dvb_service_move_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/short_event_descriptor.h dvb-apps/lib/libucsi/dvb/short_event_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/short_event_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/short_event_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,135 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_SHORT_EVENT_DESCRIPTOR ++#define _UCSI_DVB_SHORT_EVENT_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * dvb_short_event_descriptor structure. ++ */ ++struct dvb_short_event_descriptor { ++ struct descriptor d; ++ ++ iso639lang_t language_code; ++ uint8_t event_name_length; ++ /* uint8_t event_name[] */ ++ /* struct dvb_short_event_descriptor_part2 part2 */ ++} __ucsi_packed; ++ ++/** ++ * Second part of a dvb_short_event_descriptor, following the variable length ++ * name field. ++ */ ++struct dvb_short_event_descriptor_part2 { ++ uint8_t text_length; ++ /* uint8_t text[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_short_event_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_short_event_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_short_event_descriptor* ++ dvb_short_event_descriptor_codec(struct descriptor* d) ++{ ++ struct dvb_short_event_descriptor *p = ++ (struct dvb_short_event_descriptor*) d; ++ struct dvb_short_event_descriptor_part2 *p2; ++ uint32_t pos = sizeof(struct dvb_short_event_descriptor) - 2; ++ uint32_t len = d->len; ++ ++ if (pos > len) ++ return NULL; ++ ++ pos += p->event_name_length; ++ ++ if (pos > len) ++ return NULL; ++ ++ p2 = (struct dvb_short_event_descriptor_part2*) ((uint8_t*) d + 2 + pos); ++ ++ pos += sizeof(struct dvb_short_event_descriptor_part2); ++ ++ if (pos > len) ++ return NULL; ++ ++ pos += p2->text_length; ++ ++ if (pos != len) ++ return NULL; ++ ++ return p; ++} ++ ++/** ++ * Accessor for name field in a dvb_short_event_descriptor. ++ * ++ * @param d dvb_short_event_descriptor pointer. ++ * @return Pointer to name field. ++ */ ++static inline uint8_t * ++ dvb_short_event_descriptor_event_name(struct dvb_short_event_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_short_event_descriptor); ++} ++ ++/** ++ * Accessor for second part of a dvb_short_event_descriptor. ++ * ++ * @param d dvb_short_event_descriptor pointer. ++ * @return dvb_short_event_descriptor_part2 pointer. ++ */ ++static inline struct dvb_short_event_descriptor_part2 * ++ dvb_short_event_descriptor_part2(struct dvb_short_event_descriptor *d) ++{ ++ return (struct dvb_short_event_descriptor_part2 *) ++ ((uint8_t*) d + sizeof(struct dvb_short_event_descriptor) + ++ d->event_name_length); ++} ++ ++/** ++ * Accessor for text field in a dvb_short_event_descriptor_part2. ++ * ++ * @param d dvb_short_event_descriptor_part2 pointer. ++ * @return Pointer to text field. ++ */ ++static inline uint8_t * ++ dvb_short_event_descriptor_text(struct dvb_short_event_descriptor_part2 *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_short_event_descriptor_part2); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/short_smoothing_buffer_descriptor.h dvb-apps/lib/libucsi/dvb/short_smoothing_buffer_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/short_smoothing_buffer_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/short_smoothing_buffer_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,87 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_SHORT_SMOOTHING_BUFFER_DESCRIPTOR ++#define _UCSI_DVB_SHORT_SMOOTHING_BUFFER_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_short_smoothing_buffer_descriptor structure. ++ */ ++struct dvb_short_smoothing_buffer_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint8_t sb_size : 2; , ++ uint8_t sb_leak_rate : 6; ); ++ /* uint8_t reserved [] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_short_smoothing_buffer_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return dvb_short_smoothing_buffer_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_short_smoothing_buffer_descriptor* ++ dvb_short_smoothing_buffer_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len < (sizeof(struct dvb_short_smoothing_buffer_descriptor) - 2)) ++ return NULL; ++ ++ return (struct dvb_short_smoothing_buffer_descriptor*) d; ++} ++ ++/** ++ * Accessor for reserved field in a dvb_short_smoothing_buffer_descriptor. ++ * ++ * @param d dvb_short_smoothing_buffer_descriptor pointer. ++ * @return Pointer to reserved field. ++ */ ++static inline uint8_t * ++ dvb_short_smoothing_buffer_descriptor_reserved(struct dvb_short_smoothing_buffer_descriptor *d) ++{ ++ return (uint8_t*) d + sizeof(struct dvb_short_smoothing_buffer_descriptor); ++} ++ ++/** ++ * Calculate length of reserved field in a dvb_short_smoothing_buffer_descriptor. ++ * ++ * @param d dvb_short_smoothing_buffer_descriptor pointer. ++ * @return Length of the field in bytes. ++ */ ++static inline int ++ dvb_short_smoothing_buffer_descriptor_reserved_length(struct dvb_short_smoothing_buffer_descriptor *d) ++{ ++ return d->d.len - 1; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/sit_section.c dvb-apps/lib/libucsi/dvb/sit_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/sit_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/sit_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,69 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct dvb_sit_section * dvb_sit_section_codec(struct section_ext * ext) ++{ ++ uint8_t * buf = (uint8_t *) ext; ++ struct dvb_sit_section * ret = (struct dvb_sit_section *) ext; ++ size_t pos = sizeof(struct section_ext); ++ size_t len = section_ext_length(ext); ++ ++ if (len < sizeof(struct dvb_sit_section)) ++ return NULL; ++ ++ bswap16(buf + pos); ++ pos += 2; ++ ++ if ((pos + ret->transmission_info_loop_length) > len) ++ return NULL; ++ ++ if (verify_descriptors(buf + pos, ret->transmission_info_loop_length)) ++ return NULL; ++ ++ pos += ret->transmission_info_loop_length; ++ ++ while (pos < len) { ++ struct dvb_sit_service * service = (void*)(buf + pos); ++ ++ if ((pos + sizeof(struct dvb_sit_service)) > len) ++ return NULL; ++ ++ bswap16(buf + pos); ++ bswap16(buf + pos + 2); ++ bswap16(buf + pos + 4); ++ pos += sizeof(struct dvb_sit_service); ++ ++ if ((pos + service->service_loop_length) > len) ++ return NULL; ++ ++ if (verify_descriptors(buf + pos, service->service_loop_length)) ++ return NULL; ++ ++ pos += service->service_loop_length; ++ } ++ ++ if (pos != len) ++ return NULL; ++ ++ return ret; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/sit_section.h dvb-apps/lib/libucsi/dvb/sit_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/sit_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/sit_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,173 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_SIT_SECTION_H ++#define _UCSI_DVB_SIT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * dvb_sit_section structure. ++ */ ++struct dvb_sit_section { ++ struct section_ext head; ++ ++ EBIT2(uint16_t reserved : 4; , ++ uint16_t transmission_info_loop_length :12; ); ++ /* struct descriptor descriptors[] */ ++ /* struct dvb_sit_service services[] */ ++}; ++ ++/** ++ * An entry in the services field of a dvb_sit_section. ++ */ ++struct dvb_sit_service { ++ uint16_t service_id; ++ EBIT3(uint16_t reserved : 1; , ++ uint16_t running_status : 3; , ++ uint16_t service_loop_length :12; ); ++ /* struct descriptor descriptors[] */ ++}; ++ ++/** ++ * Process a dvb_sit_section. ++ * ++ * @param section Generic section_ext structure. ++ * @return dvb_sit_section pointer, or NULL on error. ++ */ ++struct dvb_sit_section * dvb_sit_section_codec(struct section_ext *section); ++ ++/** ++ * Iterator for descriptors field in a dvb_sit_section. ++ * ++ * @param sit dvb_sit_section Pointer. ++ * @param pos Variable holding pointer to current descriptor. ++ */ ++#define dvb_sit_section_descriptors_for_each(sit, pos) \ ++ for ((pos) = dvb_sit_section_descriptors_first(sit); \ ++ (pos); \ ++ (pos) = dvb_sit_section_descriptors_first(sit)) ++ ++/** ++ * Iterator for services field in a dvb_sit_section. ++ * ++ * @param sit dvb_sit_section Pointer. ++ * @param pos Variable holding pointer to current dvb_sit_service. ++ */ ++#define dvb_sit_section_services_for_each(sit, pos) \ ++ for ((pos) = dvb_sit_section_services_first(sit); \ ++ (pos); \ ++ (pos) = dvb_sit_section_services_next(sit, pos)) ++ ++/** ++ * Iterator for descriptors field in a dvb_sit_service. ++ * ++ * @param service dvb_sit_service Pointer. ++ * @param pos Variable holding pointer to current descriptor. ++ */ ++#define dvb_sit_service_descriptors_for_each(service, pos) \ ++ for ((pos) = dvb_sit_service_descriptors_first(service); \ ++ (pos); \ ++ (pos) = dvb_sit_service_descriptors_next(service, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct descriptor * ++ dvb_sit_section_descriptors_first(struct dvb_sit_section *sit) ++{ ++ if (sit->transmission_info_loop_length == 0) ++ return NULL; ++ ++ return (struct descriptor *) ++ ((uint8_t *) sit + sizeof(struct dvb_sit_section)); ++} ++ ++static inline struct descriptor * ++ dvb_sit_section_descriptors_next(struct dvb_sit_section *sit, ++ struct descriptor* pos) ++{ ++ return next_descriptor((uint8_t*) sit + sizeof(struct dvb_sit_section), ++ sit->transmission_info_loop_length, ++ pos); ++} ++ ++static inline struct dvb_sit_service * ++ dvb_sit_section_services_first(struct dvb_sit_section *sit) ++{ ++ size_t pos = sizeof(struct dvb_sit_section) + sit->transmission_info_loop_length; ++ ++ if (pos >= section_ext_length(&sit->head)) ++ return NULL; ++ ++ return (struct dvb_sit_service*) ((uint8_t *) sit + pos); ++} ++ ++static inline struct dvb_sit_service * ++ dvb_sit_section_services_next(struct dvb_sit_section *sit, ++ struct dvb_sit_service *pos) ++{ ++ uint8_t *end = (uint8_t*) sit + section_ext_length(&sit->head); ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_sit_service) + ++ pos->service_loop_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_sit_service *) next; ++} ++ ++static inline struct descriptor * ++ dvb_sit_service_descriptors_first(struct dvb_sit_service * t) ++{ ++ if (t->service_loop_length == 0) ++ return NULL; ++ ++ return (struct descriptor *) ++ ((uint8_t *) t + sizeof(struct dvb_sit_service)); ++} ++ ++static inline struct descriptor * ++ dvb_sit_service_descriptors_next(struct dvb_sit_service *t, ++ struct descriptor* pos) ++{ ++ return next_descriptor((uint8_t*) t + sizeof(struct dvb_sit_service), ++ t->service_loop_length, ++ pos); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/stream_identifier_descriptor.h dvb-apps/lib/libucsi/dvb/stream_identifier_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/stream_identifier_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/stream_identifier_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,61 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_STREAM_IDENTIFIER_DESCRIPTOR ++#define _UCSI_DVB_STREAM_IDENTIFIER_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_stream_identifier_descriptor structure. ++ */ ++struct dvb_stream_identifier_descriptor { ++ struct descriptor d; ++ ++ uint8_t component_tag; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_stream_identifier_descriptor. ++ * ++ * @param d Pointer to generic descriptor structure. ++ * @return dvb_stream_identifier_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_stream_identifier_descriptor* ++ dvb_stream_identifier_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct dvb_stream_identifier_descriptor) - 2)) ++ return NULL; ++ ++ return (struct dvb_stream_identifier_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/st_section.c dvb-apps/lib/libucsi/dvb/st_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/st_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/st_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,29 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct dvb_st_section * dvb_st_section_codec(struct section * section) ++{ ++ struct dvb_st_section * ret = (struct dvb_st_section *)section; ++ ++ return ret; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/st_section.h dvb-apps/lib/libucsi/dvb/st_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/st_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/st_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,77 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_ST_SECTION_H ++#define _UCSI_DVB_ST_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * dvb_st_section structure. ++ */ ++struct dvb_st_section { ++ struct section head; ++ ++ /* uint8_t data[] */ ++}; ++ ++/** ++ * Process a dvb_st_section. ++ * ++ * @param section Generic section header. ++ * @return dvb_st_section pointer, or NULL on error. ++ */ ++struct dvb_st_section *dvb_st_section_codec(struct section *section); ++ ++/** ++ * Accessor for data field of dvb_st_section. ++ * ++ * @param st dvb_st_section Pointer. ++ * @return Pointer to field. ++ */ ++static inline uint8_t* ++ dvb_st_section_data(struct dvb_st_section* st) ++{ ++ return (uint8_t*) st + sizeof(struct dvb_st_section); ++} ++ ++/** ++ * Calculate length of data field of dvb_st_section. ++ * ++ * @param st dvb_st_section Pointer. ++ * @return Length in bytes. ++ */ ++static inline int ++ dvb_st_section_data_length(struct dvb_st_section* st) ++{ ++ return st->head.length; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/stuffing_descriptor.h dvb-apps/lib/libucsi/dvb/stuffing_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/stuffing_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/stuffing_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,82 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_STUFFING_DESCRIPTOR ++#define _UCSI_DVB_STUFFING_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_stuffing_descriptor. ++ */ ++struct dvb_stuffing_descriptor { ++ struct descriptor d; ++ ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_stuffing_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return dvb_stuffing_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_stuffing_descriptor* ++ dvb_stuffing_descriptor_codec(struct descriptor* d) ++{ ++ return (struct dvb_stuffing_descriptor*) d; ++} ++ ++/** ++ * Retrieve a pointer to the data field of a dvb_stuffing_descriptor. ++ * ++ * @param d dvb_stuffing_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ dvb_stuffing_descriptor_data(struct dvb_stuffing_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_stuffing_descriptor); ++} ++ ++/** ++ * Calculate length of the data field of a dvb_stuffing_descriptor. ++ * ++ * @param d dvb_stuffing_descriptor pointer. ++ * @return The length in bytes. ++ */ ++static inline int ++ dvb_stuffing_descriptor_data_length(struct dvb_stuffing_descriptor *d) ++{ ++ return d->d.len; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/subtitling_descriptor.h dvb-apps/lib/libucsi/dvb/subtitling_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/subtitling_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/subtitling_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,126 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_SUBTITLING_DESCRIPTOR ++#define _UCSI_DVB_SUBTITLING_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * dvb_subtitling_descriptor structure. ++ */ ++struct dvb_subtitling_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_subtitling_entry subtitles[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the subtitles field of the a dvb_subtitling_descriptor. ++ */ ++struct dvb_subtitling_entry { ++ iso639lang_t language_code; ++ uint8_t subtitling_type; ++ uint16_t composition_page_id; ++ uint16_t ancillary_page_id; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_subtitling_descriptor. ++ * ++ * @param d Generic descriptor. ++ * @return dvb_subtitling_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_subtitling_descriptor* ++ dvb_subtitling_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t pos = 0; ++ uint8_t* ptr = (uint8_t*) d + 2; ++ uint32_t len = d->len; ++ ++ if (len % sizeof(struct dvb_subtitling_entry)) ++ return NULL; ++ ++ while(pos < len) { ++ bswap16(ptr+pos+4); ++ bswap16(ptr+pos+6); ++ pos += sizeof(struct dvb_subtitling_entry); ++ } ++ ++ return (struct dvb_subtitling_descriptor*) d; ++} ++ ++/** ++ * Iterator for subtitles field in dvb_subtitling_descriptor. ++ * ++ * @param d dvb_subtitling_descriptor pointer. ++ * @param pos Variable containing a pointer to current dvb_subtitling_entry. ++ */ ++#define dvb_subtitling_descriptor_subtitles_for_each(d, pos) \ ++ for ((pos) = dvb_subtitling_descriptor_subtitles_first(d); \ ++ (pos); \ ++ (pos) = dvb_subtitling_descriptor_subtitles_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_subtitling_entry* ++ dvb_subtitling_descriptor_subtitles_first(struct dvb_subtitling_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_subtitling_entry *) ++ ((uint8_t*) d + sizeof(struct dvb_subtitling_descriptor)); ++} ++ ++static inline struct dvb_subtitling_entry* ++ dvb_subtitling_descriptor_subtitles_next(struct dvb_subtitling_descriptor *d, ++ struct dvb_subtitling_entry *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_subtitling_entry); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_subtitling_entry *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/target_ip_address_descriptor.h dvb-apps/lib/libucsi/dvb/target_ip_address_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/target_ip_address_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/target_ip_address_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,116 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TARGET_IP_ADDRESS_DESCRIPTOR ++#define _UCSI_DVB_TARGET_IP_ADDRESS_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_target_ip_address_descriptor structure. ++ */ ++struct dvb_target_ip_address_descriptor { ++ struct descriptor d; ++ ++ uint8_t ipv4_addr_mask[4]; ++ /* struct dvb_ipv4_addr ipv4_addr[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the ipv4_addr field of a dvb_target_ip_address_descriptor. ++ */ ++struct dvb_ipv4_addr { ++ uint8_t ipv4_addr[4]; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_target_ip_address_descriptor. ++ * ++ * @param d Generic descriptor structure pointer. ++ * @return dvb_target_ip_address_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_target_ip_address_descriptor* ++ dvb_target_ip_address_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t len = d->len - 4; ++ ++ if (len % sizeof(struct dvb_ipv4_addr)) ++ return NULL; ++ ++ return (struct dvb_target_ip_address_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries in the ipv4_addr field of a dvb_target_ip_address_descriptor. ++ * ++ * @param d dvb_target_ip_address_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_ipv4_addr. ++ */ ++#define dvb_target_ip_address_descriptor_ipv4_addr_for_each(d, pos) \ ++ for ((pos) = dvb_target_ip_address_descriptor_ipv4_addr_first(d); \ ++ (pos); \ ++ (pos) = dvb_target_ip_address_descriptor_ipv4_addr_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_ipv4_addr* ++ dvb_target_ip_address_descriptor_ipv4_addr_first(struct dvb_target_ip_address_descriptor *d) ++{ ++ if (d->d.len == 4) ++ return NULL; ++ ++ return (struct dvb_ipv4_addr *) ++ ((uint8_t*) d + sizeof(struct dvb_target_ip_address_descriptor)); ++} ++ ++static inline struct dvb_ipv4_addr* ++ dvb_target_ip_address_descriptor_ipv4_addr_next(struct dvb_target_ip_address_descriptor *d, ++ struct dvb_ipv4_addr *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len - 4; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_ipv4_addr); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_ipv4_addr *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/target_ip_slash_descriptor.h dvb-apps/lib/libucsi/dvb/target_ip_slash_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/target_ip_slash_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/target_ip_slash_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,116 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TARGET_IP_SLASH_DESCRIPTOR ++#define _UCSI_DVB_TARGET_IP_SLASH_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_target_ip_slash_descriptor structure. ++ */ ++struct dvb_target_ip_slash_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_ipv4_slash ipv4_slash[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the ipv4_slash field of a dvb_target_ip_slash_descriptor. ++ */ ++struct dvb_ipv4_slash { ++ uint8_t ipv4_addr[4]; ++ uint8_t ipv4_slash; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_target_ip_slash_descriptor. ++ * ++ * @param d Generic descriptor structure pointer. ++ * @return dvb_target_ip_slash_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_target_ip_slash_descriptor* ++ dvb_target_ip_slash_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t len = d->len; ++ ++ if (len % sizeof(struct dvb_ipv4_slash)) ++ return NULL; ++ ++ return (struct dvb_target_ip_slash_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries in the ipv4_slash field of a dvb_target_ip_slash_descriptor. ++ * ++ * @param d dvb_target_ip_slash_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_ipv4_slash. ++ */ ++#define dvb_target_ip_slash_descriptor_ipv4_slash_for_each(d, pos) \ ++ for ((pos) = dvb_target_ip_slash_descriptor_ipv4_slash_first(d); \ ++ (pos); \ ++ (pos) = dvb_target_ip_slash_descriptor_ipv4_slash_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_ipv4_slash* ++ dvb_target_ip_slash_descriptor_ipv4_slash_first(struct dvb_target_ip_slash_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_ipv4_slash *) ++ ((uint8_t*) d + sizeof(struct dvb_target_ip_slash_descriptor)); ++} ++ ++static inline struct dvb_ipv4_slash* ++ dvb_target_ip_slash_descriptor_ipv4_slash_next(struct dvb_target_ip_slash_descriptor *d, ++ struct dvb_ipv4_slash *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_ipv4_slash); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_ipv4_slash *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/target_ip_source_slash_descriptor.h dvb-apps/lib/libucsi/dvb/target_ip_source_slash_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/target_ip_source_slash_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/target_ip_source_slash_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,118 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TARGET_IP_SOURCE_SLASH_DESCRIPTOR ++#define _UCSI_DVB_TARGET_IP_SOURCE_SLASH_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_target_ip_source_slash_descriptor structure. ++ */ ++struct dvb_target_ip_source_slash_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_ipv4_source_slash ipv4_source_slash[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the ipv4_source_slash field of a dvb_target_ip_source_slash_descriptor. ++ */ ++struct dvb_ipv4_source_slash { ++ uint8_t ipv4_source_addr[4]; ++ uint8_t ipv4_source_slash; ++ uint8_t ipv4_dest_addr[4]; ++ uint8_t ipv4_dest_slash; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_target_ip_source_slash_descriptor. ++ * ++ * @param d Generic descriptor structure pointer. ++ * @return dvb_target_ip_source_slash_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_target_ip_source_slash_descriptor* ++ dvb_target_ip_source_slash_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t len = d->len; ++ ++ if (len % sizeof(struct dvb_ipv4_source_slash)) ++ return NULL; ++ ++ return (struct dvb_target_ip_source_slash_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries in the ipv4_source_slash field of a dvb_target_ip_source_slash_descriptor. ++ * ++ * @param d dvb_target_ip_source_slash_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_ipv4_source_slash. ++ */ ++#define dvb_target_ip_source_slash_descriptor_ipv4_source_slash_for_each(d, pos) \ ++ for ((pos) = dvb_target_ip_source_slash_descriptor_ipv4_source_slash_first(d); \ ++ (pos); \ ++ (pos) = dvb_target_ip_source_slash_descriptor_ipv4_source_slash_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_ipv4_source_slash* ++ dvb_target_ip_source_slash_descriptor_ipv4_source_slash_first(struct dvb_target_ip_source_slash_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_ipv4_source_slash *) ++ ((uint8_t*) d + sizeof(struct dvb_target_ip_source_slash_descriptor)); ++} ++ ++static inline struct dvb_ipv4_source_slash* ++ dvb_target_ip_source_slash_descriptor_ipv4_source_slash_next(struct dvb_target_ip_source_slash_descriptor *d, ++ struct dvb_ipv4_source_slash *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_ipv4_source_slash); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_ipv4_source_slash *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/target_ipv6_address_descriptor.h dvb-apps/lib/libucsi/dvb/target_ipv6_address_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/target_ipv6_address_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/target_ipv6_address_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,116 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TARGET_IPV6_ADDRESS_DESCRIPTOR ++#define _UCSI_DVB_TARGET_IPV6_ADDRESS_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_target_ipv6_address_descriptor structure. ++ */ ++struct dvb_target_ipv6_address_descriptor { ++ struct descriptor d; ++ ++ uint8_t ipv6_addr_mask[16]; ++ /* struct dvb_ipv6_addr ipv6_addr[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the ipv6_addr field of a dvb_target_ipv6_address_descriptor. ++ */ ++struct dvb_ipv6_addr { ++ uint8_t ipv6_addr[16]; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_target_ipv6_address_descriptor. ++ * ++ * @param d Generic descriptor structure pointer. ++ * @return dvb_target_ipv6_address_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_target_ipv6_address_descriptor* ++ dvb_target_ipv6_address_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t len = d->len - 16; ++ ++ if (len % sizeof(struct dvb_ipv6_addr)) ++ return NULL; ++ ++ return (struct dvb_target_ipv6_address_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries in the ipv6_addr field of a dvb_target_ipv6_address_descriptor. ++ * ++ * @param d dvb_target_ipv6_address_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_ipv6_addr. ++ */ ++#define dvb_target_ipv6_address_descriptor_ipv6_addr_for_each(d, pos) \ ++ for ((pos) = dvb_target_ipv6_address_descriptor_ipv6_addr_first(d); \ ++ (pos); \ ++ (pos) = dvb_target_ipv6_address_descriptor_ipv6_addr_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_ipv6_addr* ++ dvb_target_ipv6_address_descriptor_ipv6_addr_first(struct dvb_target_ipv6_address_descriptor *d) ++{ ++ if (d->d.len == 16) ++ return NULL; ++ ++ return (struct dvb_ipv6_addr *) ++ ((uint8_t*) d + sizeof(struct dvb_target_ipv6_address_descriptor)); ++} ++ ++static inline struct dvb_ipv6_addr* ++ dvb_target_ipv6_address_descriptor_ipv6_addr_next(struct dvb_target_ipv6_address_descriptor *d, ++ struct dvb_ipv6_addr *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len - 16; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_ipv6_addr); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_ipv6_addr *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/target_ipv6_slash_descriptor.h dvb-apps/lib/libucsi/dvb/target_ipv6_slash_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/target_ipv6_slash_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/target_ipv6_slash_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,116 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TARGET_IPV6_SLASH_DESCRIPTOR ++#define _UCSI_DVB_TARGET_IPV6_SLASH_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_target_ipv6_slash_descriptor structure. ++ */ ++struct dvb_target_ipv6_slash_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_ipv6_slash ipv6_slash[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the ipv6_slash field of a dvb_target_ipv6_slash_descriptor. ++ */ ++struct dvb_ipv6_slash { ++ uint8_t ipv6_addr[16]; ++ uint8_t ipv6_slash; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_target_ipv6_slash_descriptor. ++ * ++ * @param d Generic descriptor structure pointer. ++ * @return dvb_target_ipv6_slash_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_target_ipv6_slash_descriptor* ++ dvb_target_ipv6_slash_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t len = d->len; ++ ++ if (len % sizeof(struct dvb_ipv6_slash)) ++ return NULL; ++ ++ return (struct dvb_target_ipv6_slash_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries in the ipv6_slash field of a dvb_target_ipv6_slash_descriptor. ++ * ++ * @param d dvb_target_ipv6_slash_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_ipv6_slash. ++ */ ++#define dvb_target_ipv6_slash_descriptor_ipv6_slash_for_each(d, pos) \ ++ for ((pos) = dvb_target_ipv6_slash_descriptor_ipv6_slash_first(d); \ ++ (pos); \ ++ (pos) = dvb_target_ipv6_slash_descriptor_ipv6_slash_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_ipv6_slash* ++ dvb_target_ipv6_slash_descriptor_ipv6_slash_first(struct dvb_target_ipv6_slash_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_ipv6_slash *) ++ ((uint8_t*) d + sizeof(struct dvb_target_ipv6_slash_descriptor)); ++} ++ ++static inline struct dvb_ipv6_slash* ++ dvb_target_ipv6_slash_descriptor_ipv6_slash_next(struct dvb_target_ipv6_slash_descriptor *d, ++ struct dvb_ipv6_slash *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_ipv6_slash); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_ipv6_slash *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/target_ipv6_source_slash_descriptor.h dvb-apps/lib/libucsi/dvb/target_ipv6_source_slash_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/target_ipv6_source_slash_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/target_ipv6_source_slash_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,118 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TARGET_IPV6_SOURCE_SLASH_DESCRIPTOR ++#define _UCSI_DVB_TARGET_IPV6_SOURCE_SLASH_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_target_ipv6_source_slash_descriptor structure. ++ */ ++struct dvb_target_ipv6_source_slash_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_ipv6_source_slash ipv6_source_slash[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the ipv6_source_slash field of a dvb_target_ipv6_source_slash_descriptor. ++ */ ++struct dvb_ipv6_source_slash { ++ uint8_t ipv6_source_addr[16]; ++ uint8_t ipv6_source_slash; ++ uint8_t ipv6_dest_addr[16]; ++ uint8_t ipv6_dest_slash; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_target_ipv6_source_slash_descriptor. ++ * ++ * @param d Generic descriptor structure pointer. ++ * @return dvb_target_ipv6_source_slash_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_target_ipv6_source_slash_descriptor* ++ dvb_target_ipv6_source_slash_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t len = d->len; ++ ++ if (len % sizeof(struct dvb_ipv6_source_slash)) ++ return NULL; ++ ++ return (struct dvb_target_ipv6_source_slash_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries in the ipv6_source_slash field of a dvb_target_ipv6_source_slash_descriptor. ++ * ++ * @param d dvb_target_ipv6_source_slash_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_ipv6_source_slash. ++ */ ++#define dvb_target_ipv6_source_slash_descriptor_ipv6_source_slash_for_each(d, pos) \ ++ for ((pos) = dvb_target_ipv6_source_slash_descriptor_ipv6_source_slash_first(d); \ ++ (pos); \ ++ (pos) = dvb_target_ipv6_source_slash_descriptor_ipv6_source_slash_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_ipv6_source_slash* ++ dvb_target_ipv6_source_slash_descriptor_ipv6_source_slash_first(struct dvb_target_ipv6_source_slash_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_ipv6_source_slash *) ++ ((uint8_t*) d + sizeof(struct dvb_target_ipv6_source_slash_descriptor)); ++} ++ ++static inline struct dvb_ipv6_source_slash* ++ dvb_target_ipv6_source_slash_descriptor_ipv6_source_slash_next(struct dvb_target_ipv6_source_slash_descriptor *d, ++ struct dvb_ipv6_source_slash *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_ipv6_source_slash); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_ipv6_source_slash *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/tdt_section.c dvb-apps/lib/libucsi/dvb/tdt_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/tdt_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/tdt_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,33 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct dvb_tdt_section * dvb_tdt_section_codec(struct section * section) ++{ ++ size_t len = section_length(section); ++ struct dvb_tdt_section * ret = (struct dvb_tdt_section *) section; ++ ++ if (len != sizeof(struct dvb_tdt_section)) ++ return NULL; ++ ++ return ret; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/tdt_section.h dvb-apps/lib/libucsi/dvb/tdt_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/tdt_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/tdt_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,54 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TDT_SECTION_H ++#define _UCSI_DVB_TDT_SECTION_H ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_tdt_section structure. ++ */ ++struct dvb_tdt_section { ++ struct section head; ++ ++ dvbdate_t utc_time; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_tdt_section. ++ * ++ * @param section Generic section header. ++ * @return dvb_tdt_section pointer, or NULL on error. ++ */ ++struct dvb_tdt_section *dvb_tdt_section_codec(struct section *section); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/telephone_descriptor.h dvb-apps/lib/libucsi/dvb/telephone_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/telephone_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/telephone_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,150 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TELEPHONE_DESCRIPTOR ++#define _UCSI_DVB_TELEPHONE_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_telephone_descriptor stucture. ++ */ ++struct dvb_telephone_descriptor { ++ struct descriptor d; ++ ++ EBIT3(uint8_t reserved_1 : 2; , ++ uint8_t foreign_availability : 1; , ++ uint8_t connection_type : 5; ); ++ EBIT4(uint8_t reserved_2 : 1; , ++ uint8_t country_prefix_length : 2; , ++ uint8_t international_area_code_length : 3; , ++ uint8_t operator_code_length : 2; ); ++ EBIT3(uint8_t reserved_3 : 1; , ++ uint8_t national_area_code_length : 3; , ++ uint8_t core_number_length : 4; ); ++ /* uint8_t country_prefix[] */ ++ /* uint8_t international_area_code[] */ ++ /* uint8_t operator_code[] */ ++ /* uint8_t national_area_code[] */ ++ /* uint8_t core_number[] */ ++} __ucsi_packed; ++ ++ ++/** ++ * Process a dvb_telephone_descriptor. ++ * ++ * @param d Generic descriptor. ++ * @return dvb_telephone_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_telephone_descriptor* ++ dvb_telephone_descriptor_codec(struct descriptor* d) ++{ ++ struct dvb_telephone_descriptor* p = ++ (struct dvb_telephone_descriptor*) d; ++ uint32_t pos = sizeof(struct dvb_telephone_descriptor) - 2; ++ uint32_t len = d->len; ++ ++ if (pos > len) ++ return NULL; ++ ++ pos += p->country_prefix_length + ++ p->international_area_code_length + ++ p->operator_code_length + ++ p->national_area_code_length + ++ p->core_number_length; ++ ++ if (pos != len) ++ return NULL; ++ ++ return p; ++} ++ ++/** ++ * Retrieve pointer to country_prefix field of a dvb_telephone_descriptor. ++ * ++ * @param d dvb_telephone_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t* ++ dvb_telephone_descriptor_country_prefix(struct dvb_telephone_descriptor* d) ++{ ++ return (uint8_t*) d + sizeof(struct dvb_telephone_descriptor); ++} ++ ++/** ++ * Retrieve pointer to international_area_code field of a dvb_telephone_descriptor. ++ * ++ * @param d dvb_telephone_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t* ++ dvb_telephone_descriptor_international_area_code(struct dvb_telephone_descriptor* d) ++{ ++ return dvb_telephone_descriptor_country_prefix(d) + d->country_prefix_length; ++} ++ ++/** ++ * Retrieve pointer to operator_code field of a dvb_telephone_descriptor. ++ * ++ * @param d dvb_telephone_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t* ++ dvb_telephone_descriptor_operator_code(struct dvb_telephone_descriptor* d) ++{ ++ return dvb_telephone_descriptor_international_area_code(d) + d->international_area_code_length; ++} ++ ++/** ++ * Retrieve pointer to national_area_code field of a dvb_telephone_descriptor. ++ * ++ * @param d dvb_telephone_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t* ++ dvb_telephone_descriptor_national_area_code(struct dvb_telephone_descriptor* d) ++{ ++ return dvb_telephone_descriptor_operator_code(d) + d->operator_code_length; ++} ++ ++/** ++ * Retrieve pointer to core_number field of a dvb_telephone_descriptor. ++ * ++ * @param d dvb_telephone_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t* ++ dvb_telephone_descriptor_core_number(struct dvb_telephone_descriptor* d) ++{ ++ return dvb_telephone_descriptor_national_area_code(d) + d->national_area_code_length; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/teletext_descriptor.h dvb-apps/lib/libucsi/dvb/teletext_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/teletext_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/teletext_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,127 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TELETEXT_DESCRIPTOR ++#define _UCSI_DVB_TELETEXT_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * Possible values for the type field. ++ */ ++enum { ++ DVB_TELETEXT_TYPE_INITIAL = 0x01, ++ DVB_TELETEXT_TYPE_SUBTITLE = 0x02, ++ DVB_TELETEXT_TYPE_ADDITIONAL = 0x03, ++ DVB_TELETEXT_TYPE_SCHEDULE = 0x04, ++ DVB_TELETEXT_TYPE_SUBTITLE_HEARING_IMPAIRED= 0x05, ++}; ++ ++/** ++ * dvb_teletext_descriptor structure. ++ */ ++struct dvb_teletext_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_teletext_entry entries[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the entries field of a dvb_teletext_descriptor. ++ */ ++struct dvb_teletext_entry { ++ iso639lang_t language_code; ++ EBIT2(uint8_t type : 5; , ++ uint8_t magazine_number: 3; ); ++ uint8_t page_number; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_teletext_descriptor. ++ * ++ * @param d Generic descriptor. ++ * @return dvb_teletext_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_teletext_descriptor* ++ dvb_teletext_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len % sizeof(struct dvb_teletext_entry)) ++ return NULL; ++ ++ return (struct dvb_teletext_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries field of a dvb_teletext_descriptor. ++ * ++ * @param d dvb_teletext_descriptor pointer. ++ * @param pos Variable holding a pointer to the current dvb_teletext_entry. ++ */ ++#define dvb_teletext_descriptor_entries_for_each(d, pos) \ ++ for ((pos) = dvb_teletext_descriptor_entries_first(d); \ ++ (pos); \ ++ (pos) = dvb_teletext_descriptor_entries_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_teletext_entry* ++ dvb_teletext_descriptor_entries_first(struct dvb_teletext_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_teletext_entry *) ++ ((uint8_t*) d + sizeof(struct dvb_teletext_descriptor)); ++} ++ ++static inline struct dvb_teletext_entry* ++ dvb_teletext_descriptor_entries_next(struct dvb_teletext_descriptor *d, ++ struct dvb_teletext_entry *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_teletext_entry); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_teletext_entry *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/terrestrial_delivery_descriptor.h dvb-apps/lib/libucsi/dvb/terrestrial_delivery_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/terrestrial_delivery_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/terrestrial_delivery_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,77 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TERRESTRIAL_DELIVERY_DESCRIPTOR ++#define _UCSI_DVB_TERRESTRIAL_DELIVERY_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_terrestrial_delivery_descriptor structure. ++ */ ++struct dvb_terrestrial_delivery_descriptor { ++ struct descriptor d; ++ ++ uint32_t centre_frequency; // Normal integer, units 10Hz ++ EBIT5(uint8_t bandwidth : 3; , ++ uint8_t priority : 1; , ++ uint8_t time_slicing_indicator : 1; , ++ uint8_t mpe_fec_indicator : 1; , ++ uint8_t reserved_1 : 2; ); ++ EBIT3(uint8_t constellation : 2; , ++ uint8_t hierarchy_information : 3; , ++ uint8_t code_rate_hp_stream : 3; ); ++ EBIT4(uint8_t code_rate_lp_stream : 3; , ++ uint8_t guard_interval : 2; , ++ uint8_t transmission_mode : 2; , ++ uint8_t other_frequency_flag : 1; ); ++ uint32_t reserved_2; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_terrestrial_delivery_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return dvb_terrestrial_delivery_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_terrestrial_delivery_descriptor* ++ dvb_terrestrial_delivery_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct dvb_terrestrial_delivery_descriptor) - 2)) ++ return NULL; ++ ++ bswap32((uint8_t*) d + 2); ++ bswap32((uint8_t*) d + 9); ++ ++ return (struct dvb_terrestrial_delivery_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/time_shifted_event_descriptor.h dvb-apps/lib/libucsi/dvb/time_shifted_event_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/time_shifted_event_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/time_shifted_event_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,65 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TIME_SHIFTED_EVENT_DESCRIPTOR ++#define _UCSI_DVB_TIME_SHIFTED_EVENT_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_time_shifted_event_descriptor structure. ++ */ ++struct dvb_time_shifted_event_descriptor { ++ struct descriptor d; ++ ++ uint16_t reference_service_id; ++ uint16_t reference_event_id; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_time_shifted_event_descriptor. ++ * ++ * @param d Generic descriptor. ++ * @return dvb_time_shifted_event_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_time_shifted_event_descriptor* ++ dvb_time_shifted_event_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct dvb_time_shifted_event_descriptor) - 2)) ++ return NULL; ++ ++ bswap16((uint8_t*) d + 2); ++ bswap16((uint8_t*) d + 4); ++ ++ return (struct dvb_time_shifted_event_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/time_shifted_service_descriptor.h dvb-apps/lib/libucsi/dvb/time_shifted_service_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/time_shifted_service_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/time_shifted_service_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,63 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TIME_SHIFTED_SERVICE_DESCRIPTOR ++#define _UCSI_DVB_TIME_SHIFTED_SERVICE_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_time_shifted_service_descriptor structure. ++ */ ++struct dvb_time_shifted_service_descriptor { ++ struct descriptor d; ++ ++ uint16_t reference_service_id; ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_time_shifted_service_descriptor. ++ * ++ * @param d Generic descriptor. ++ * @return Pointer to dvb_time_shifted_service_descriptor, or NULL on error. ++ */ ++static inline struct dvb_time_shifted_service_descriptor* ++ dvb_time_shifted_service_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct dvb_time_shifted_service_descriptor) - 2)) ++ return NULL; ++ ++ bswap16((uint8_t*) d + 2); ++ ++ return (struct dvb_time_shifted_service_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/time_slice_fec_identifier_descriptor.h dvb-apps/lib/libucsi/dvb/time_slice_fec_identifier_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/time_slice_fec_identifier_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/time_slice_fec_identifier_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,94 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * Copyright (C) 2008 Patrick Boettcher (pb@linuxtv.org) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TIME_SLICE_FEC_IDENTIFIER_DESCRIPTOR ++#define _UCSI_DVB_TIME_SLICE_FEC_IDENTIFIER_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/* ++ * dvb_time_slice_fec_identifier_descriptor structure. ++ */ ++struct dvb_time_slice_fec_identifier_descriptor { ++ struct descriptor d; ++ ++ EBIT4(uint8_t time_slicing :1; , ++ uint8_t mpe_fec :2; , ++ uint8_t reserved :2; , ++ uint8_t frame_size :3; ); ++ ++ uint8_t max_burst_duration; ++ ++ EBIT2(uint8_t max_average_rate :4; , ++ uint8_t time_slice_fec_id :4; ); ++ /* id_selector_bytes[] */ ++}; ++ ++static inline struct dvb_time_slice_fec_identifier_descriptor * ++ dvb_time_slice_fec_identifier_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len < 3) ++ return NULL; ++ return (struct dvb_time_slice_fec_identifier_descriptor *) d; ++} ++ ++static inline uint8_t dvb_time_slice_fec_identifier_selector_byte_length(struct dvb_time_slice_fec_identifier_descriptor *d) ++{ ++ return d->d.len - 3; ++} ++ ++static inline uint8_t * dvb_time_slice_fec_identifier_selector_bytes(struct dvb_time_slice_fec_identifier_descriptor *d) ++{ ++ if (d->d.len < 3) ++ return NULL; ++ else ++ return ((uint8_t *) d) + 2 + 3; ++} ++ ++static inline uint16_t dvb_time_slice_fec_identifier_max_burst_duration_msec(struct dvb_time_slice_fec_identifier_descriptor *d) ++{ ++ return (d->max_burst_duration + 1) * 20; ++} ++ ++static inline uint16_t dvb_time_slice_fec_identifier_frame_size_kbits(struct dvb_time_slice_fec_identifier_descriptor *d) ++{ ++ if (d->frame_size > 3) ++ return 0; ++ return (d->frame_size+1) * 512; ++} ++ ++static inline uint16_t dvb_time_slice_fec_identifier_frame_size_rows(struct dvb_time_slice_fec_identifier_descriptor *d) ++{ ++ return dvb_time_slice_fec_identifier_frame_size_kbits(d) / 2; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/tot_section.c dvb-apps/lib/libucsi/dvb/tot_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/tot_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/tot_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,50 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct dvb_tot_section *dvb_tot_section_codec(struct section *section) ++{ ++ uint8_t * buf = (uint8_t *)section; ++ size_t pos = sizeof(struct section); ++ size_t len = section_length(section) - CRC_SIZE; ++ struct dvb_tot_section * ret = (struct dvb_tot_section *)section; ++ ++ if (len < sizeof(struct dvb_tot_section)) ++ return NULL; ++ ++ pos += 5; ++ bswap16(buf + pos); ++ pos += 2; ++ ++ if ((pos + ret->descriptors_loop_length) > len) ++ return NULL; ++ ++ if (verify_descriptors(buf + pos, ret->descriptors_loop_length)) ++ return NULL; ++ ++ pos += ret->descriptors_loop_length; ++ ++ if (pos != len) ++ return NULL; ++ ++ return ret; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/tot_section.h dvb-apps/lib/libucsi/dvb/tot_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/tot_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/tot_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,97 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TOT_SECTION_H ++#define _UCSI_DVB_TOT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_tot_section structure. ++ */ ++struct dvb_tot_section { ++ struct section head; ++ ++ dvbdate_t utc_time; ++ EBIT2(uint16_t reserved : 4; , ++ uint16_t descriptors_loop_length:12; ); ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_tot_section. ++ * ++ * @param section Pointer to generic section structure. ++ * @return dvb_tot_section pointer, or NULL on error. ++ */ ++struct dvb_tot_section * dvb_tot_section_codec(struct section *section); ++ ++/** ++ * Iterator for descriptors field of dvb_tot_section. ++ * ++ * @param tot dvb_tot_section pointer. ++ * @param pos Variable holding a pointer to the current descriptor. ++ */ ++#define dvb_tot_section_descriptors_for_each(tot, pos) \ ++ for ((pos) = dvb_tot_section_descriptors_first(tot); \ ++ (pos); \ ++ (pos) = dvb_tot_section_descriptors_next(tot, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct descriptor * ++ dvb_tot_section_descriptors_first(struct dvb_tot_section * tot) ++{ ++ if (tot->descriptors_loop_length == 0) ++ return NULL; ++ ++ return (struct descriptor *) ++ ((uint8_t *) tot + sizeof(struct dvb_tot_section)); ++} ++ ++static inline struct descriptor * ++ dvb_tot_section_descriptors_next(struct dvb_tot_section *tot, ++ struct descriptor* pos) ++{ ++ return next_descriptor((uint8_t *) tot + sizeof(struct dvb_tot_section), ++ tot->descriptors_loop_length, ++ pos); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/transport_stream_descriptor.h dvb-apps/lib/libucsi/dvb/transport_stream_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/transport_stream_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/transport_stream_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,82 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TRANSPORT_STREAM_DESCRIPTOR ++#define _UCSI_DVB_TRANSPORT_STREAM_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_transport_stream_descriptor structure. ++ */ ++struct dvb_transport_stream_descriptor { ++ struct descriptor d; ++ ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++/** ++ * Process dvb_transport_stream_descriptor structure. ++ * ++ * @param d Pointer to generic descriptor. ++ * @return dvb_transport_stream_descriptor structure or NULL on error. ++ */ ++static inline struct dvb_transport_stream_descriptor* ++ dvb_transport_stream_descriptor_codec(struct descriptor* d) ++{ ++ return (struct dvb_transport_stream_descriptor*) d; ++} ++ ++/** ++ * Retrieve a pointer to the data field of a dvb_transport_stream_descriptor. ++ * ++ * @param d dvb_transport_stream_descriptor structure. ++ * @return Pointer to data field. ++ */ ++static inline uint8_t * ++ dvb_transport_stream_descriptor_data(struct dvb_transport_stream_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_transport_stream_descriptor); ++} ++ ++/** ++ * Calculate the length of the data field of a dvb_transport_stream_descriptor. ++ * ++ * @param d dvb_transport_stream_descriptor structure. ++ * @return length of data field in bytes. ++ */ ++static inline int ++ dvb_transport_stream_descriptor_data_length(struct dvb_transport_stream_descriptor *d) ++{ ++ return d->d.len; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/tva_container_section.c dvb-apps/lib/libucsi/dvb/tva_container_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/tva_container_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/tva_container_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,33 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct dvb_tva_container_section *dvb_tva_container_section_codec(struct section_ext *ext) ++{ ++ size_t len = section_ext_length(ext); ++ struct dvb_tva_container_section* ret = (struct dvb_tva_container_section*) ext; ++ ++ if (len < sizeof(struct dvb_tva_container_section)) ++ return NULL; ++ ++ return ret; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/tva_container_section.h dvb-apps/lib/libucsi/dvb/tva_container_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/tva_container_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/tva_container_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,90 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TVA_CONTAINER_SECTION_H ++#define _UCSI_DVB_TVA_CONTAINER_SECTION_H ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_tva_container_section structure. ++ */ ++struct dvb_tva_container_section { ++ struct section_ext head; ++ ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_tva_container_section. ++ * ++ * @param section Generic section header. ++ * @return dvb_tdt_section pointer, or NULL on error. ++ */ ++struct dvb_tva_container_section *dvb_tva_container_section_codec(struct section_ext *ext); ++ ++/** ++ * Accessor for the container_id field of a tva container section. ++ * ++ * @param container dvb_tva_container_section pointer. ++ * @return The container_id. ++ */ ++static inline uint16_t dvb_tva_container_section_container_id(struct dvb_tva_container_section *container) ++{ ++ return container->head.table_id_ext; ++} ++ ++/** ++ * Accessor for the data field of a dvb_data_broadcast_id_descriptor. ++ * ++ * @param d dvb_data_broadcast_id_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++dvb_tva_container_section_data(struct dvb_tva_container_section *s) ++{ ++ return (uint8_t *) s + sizeof(struct dvb_tva_container_section); ++} ++ ++/** ++ * Determine the number of bytes in the data field of a dvb_tva_container_section. ++ * ++ * @param d dvb_tva_container_section pointer. ++ * @return Length of the field in bytes. ++ */ ++static inline int ++dvb_tva_container_section_data_length(struct dvb_tva_container_section *s) ++{ ++ return section_ext_length(&s->head) - sizeof(struct dvb_tva_container_section); ++} ++ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/tva_id_descriptor.h dvb-apps/lib/libucsi/dvb/tva_id_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/tva_id_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/tva_id_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,124 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TVA_ID_DESCRIPTOR ++#define _UCSI_DVB_TVA_ID_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * dvb_tva_id_descriptor structure. ++ */ ++struct dvb_tva_id_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_tva_id_entry entries[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the entries field of a dvb_tva_id_descriptor. ++ */ ++struct dvb_tva_id_entry { ++ uint16_t tva_id; ++ EBIT2(uint8_t reserved : 5; , ++ uint8_t running_status : 3; ); ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_tva_id_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return dvb_tva_id_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_tva_id_descriptor* ++ dvb_tva_id_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t pos = 0; ++ uint32_t len = d->len; ++ uint8_t* buf = (uint8_t*) d + 2; ++ ++ pos += sizeof(struct dvb_tva_id_descriptor) - 2; ++ if (len % sizeof(struct dvb_tva_id_entry)) ++ return NULL; ++ ++ while(pos < len) { ++ bswap16(buf+pos); ++ pos+=3; ++ } ++ ++ return (struct dvb_tva_id_descriptor*) d; ++} ++ ++/** ++ * Iterator for the entries field of a dvb_tva_id_descriptor. ++ * ++ * @param d dvb_tva_id_descriptor pointer. ++ * @param pos Variable containing a pointer to the current dvb_tva_id_entry. ++ */ ++#define dvb_tva_id_descriptor_entries_for_each(d, pos) \ ++ for ((pos) = dvb_tva_id_descriptor_entries_first(d); \ ++ (pos); \ ++ (pos) = dvb_tva_id_descriptor_entries_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_tva_id_entry* ++ dvb_tva_id_descriptor_entries_first(struct dvb_tva_id_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_tva_id_entry *) ++ ((uint8_t*) d + sizeof(struct dvb_tva_id_descriptor)); ++} ++ ++static inline struct dvb_tva_id_entry* ++ dvb_tva_id_descriptor_entries_next(struct dvb_tva_id_descriptor *d, ++ struct dvb_tva_id_entry *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_tva_id_entry); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_tva_id_entry *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/types.c dvb-apps/lib/libucsi/dvb/types.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/types.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/types.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,270 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include "types.h" ++ ++time_t dvbdate_to_unixtime(dvbdate_t dvbdate) ++{ ++ int k = 0; ++ struct tm tm; ++ double mjd; ++ ++ /* check for the undefined value */ ++ if ((dvbdate[0] == 0xff) && ++ (dvbdate[1] == 0xff) && ++ (dvbdate[2] == 0xff) && ++ (dvbdate[3] == 0xff) && ++ (dvbdate[4] == 0xff)) { ++ return -1; ++ } ++ ++ memset(&tm, 0, sizeof(tm)); ++ mjd = (dvbdate[0] << 8) | dvbdate[1]; ++ ++ tm.tm_year = (int) ((mjd - 15078.2) / 365.25); ++ tm.tm_mon = (int) (((mjd - 14956.1) - (int) (tm.tm_year * 365.25)) / 30.6001); ++ tm.tm_mday = (int) mjd - 14956 - (int) (tm.tm_year * 365.25) - (int) (tm.tm_mon * 30.6001); ++ if ((tm.tm_mon == 14) || (tm.tm_mon == 15)) k = 1; ++ tm.tm_year += k; ++ tm.tm_mon = tm.tm_mon - 2 - k * 12; ++ tm.tm_sec = bcd_to_integer(dvbdate[4]); ++ tm.tm_min = bcd_to_integer(dvbdate[3]); ++ tm.tm_hour = bcd_to_integer(dvbdate[2]); ++ ++ return mktime(&tm); ++} ++ ++void unixtime_to_dvbdate(time_t unixtime, dvbdate_t dvbdate) ++{ ++ struct tm tm; ++ double l = 0; ++ int mjd; ++ ++ /* the undefined value */ ++ if (unixtime == -1) { ++ memset(dvbdate, 0xff, 5); ++ return; ++ } ++ ++ gmtime_r(&unixtime, &tm); ++ tm.tm_mon++; ++ if ((tm.tm_mon == 1) || (tm.tm_mon == 2)) l = 1; ++ mjd = 14956 + tm.tm_mday + (int) ((tm.tm_year - l) * 365.25) + (int) ((tm.tm_mon + 1 + l * 12) * 30.6001); ++ ++ dvbdate[0] = (mjd & 0xff00) >> 8; ++ dvbdate[1] = mjd & 0xff; ++ dvbdate[2] = integer_to_bcd(tm.tm_hour); ++ dvbdate[3] = integer_to_bcd(tm.tm_min); ++ dvbdate[4] = integer_to_bcd(tm.tm_sec); ++} ++ ++int dvbduration_to_seconds(dvbduration_t dvbduration) ++{ ++ int seconds = 0; ++ ++ seconds += (bcd_to_integer(dvbduration[0]) * 60 * 60); ++ seconds += (bcd_to_integer(dvbduration[1]) * 60); ++ seconds += bcd_to_integer(dvbduration[2]); ++ ++ return seconds; ++} ++ ++void seconds_to_dvbduration(int seconds, dvbduration_t dvbduration) ++{ ++ int hours, mins; ++ ++ hours = seconds / (60*60); ++ seconds -= (hours * 60 * 60); ++ mins = seconds / 60; ++ seconds -= (mins * 60); ++ ++ dvbduration[0] = integer_to_bcd(hours); ++ dvbduration[1] = integer_to_bcd(mins); ++ dvbduration[2] = integer_to_bcd(seconds); ++} ++ ++int dvbhhmm_to_seconds(dvbhhmm_t dvbhhmm) ++{ ++ int seconds = 0; ++ ++ seconds += (bcd_to_integer(dvbhhmm[0]) * 60 * 60); ++ seconds += (bcd_to_integer(dvbhhmm[1]) * 60); ++ ++ return seconds; ++} ++ ++void seconds_to_dvbhhmm(int seconds, dvbhhmm_t dvbhhmm) ++{ ++ int hours, mins; ++ ++ hours = seconds / (60*60); ++ seconds -= (hours * 60 * 60); ++ mins = seconds / 60; ++ ++ dvbhhmm[0] = integer_to_bcd(hours); ++ dvbhhmm[1] = integer_to_bcd(mins); ++} ++ ++uint32_t integer_to_bcd(uint32_t intval) ++{ ++ uint32_t val = 0; ++ ++ int i; ++ for(i=0; i<=28;i+=4) { ++ val |= ((intval % 10) << i); ++ intval /= 10; ++ } ++ ++ return val; ++} ++ ++uint32_t bcd_to_integer(uint32_t bcdval) ++{ ++ uint32_t val = 0; ++ ++ int i; ++ for(i=28; i>=0;i-=4) { ++ val += ((bcdval >> i) & 0x0f); ++ if (i != 0) val *= 10; ++ } ++ ++ return val; ++} ++ ++const char *dvb_charset(char *dvb_text, int dvb_text_length, int *consumed) ++{ ++ char *charset = "ISO6937"; ++ int used = 0; ++ ++ if (dvb_text_length == 0) ++ goto exit; ++ if (dvb_text[0] >= 32) ++ goto exit; ++ if (dvb_text[0] == 0x10) { ++ if (dvb_text_length < 3) ++ goto exit; ++ ++ used = 3; ++ uint16_t ext = (dvb_text[1] << 8) | dvb_text[2]; ++ switch(ext) { ++ case 0x01: ++ charset = "ISO8859-1"; ++ break; ++ case 0x02: ++ charset = "ISO8859-2"; ++ break; ++ case 0x03: ++ charset = "ISO8859-3"; ++ break; ++ case 0x04: ++ charset = "ISO8859-4"; ++ break; ++ case 0x05: ++ charset = "ISO8859-5"; ++ break; ++ case 0x06: ++ charset = "ISO8859-6"; ++ break; ++ case 0x07: ++ charset = "ISO8859-7"; ++ break; ++ case 0x08: ++ charset = "ISO8859-8"; ++ break; ++ case 0x09: ++ charset = "ISO8859-9"; ++ break; ++ case 0x0a: ++ charset = "ISO8859-10"; ++ break; ++ case 0x0b: ++ charset = "ISO8859-11"; ++ break; ++ case 0x0d: ++ charset = "ISO8859-13"; ++ break; ++ case 0x0e: ++ charset = "ISO8859-14"; ++ break; ++ case 0x0f: ++ charset = "ISO8859-15"; ++ break; ++ default: ++ used = 0; ++ break; ++ } ++ } else { ++ used = 1; ++ switch(dvb_text[0]) { ++ case 0x01: ++ charset = "ISO8859-5"; ++ break; ++ case 0x02: ++ charset = "ISO8859-6"; ++ break; ++ case 0x03: ++ charset = "ISO8859-7"; ++ break; ++ case 0x04: ++ charset = "ISO8859-8"; ++ break; ++ case 0x05: ++ charset = "ISO8859-9"; ++ break; ++ case 0x06: ++ charset = "ISO8859-10"; ++ break; ++ case 0x07: ++ charset = "ISO8859-11"; ++ break; ++ case 0x09: ++ charset = "ISO8859-13"; ++ break; ++ case 0x0a: ++ charset = "ISO8859-14"; ++ break; ++ case 0x0b: ++ charset = "ISO8859-15"; ++ break; ++ case 0x11: ++ charset = "UTF16"; ++ break; ++ case 0x12: ++ charset = "EUC-KR"; ++ break; ++ case 0x13: ++ charset = "GB2312"; ++ break; ++ case 0x14: ++ charset = "GBK"; ++ break; ++ case 0x15: ++ charset = "UTF8"; ++ break; ++ default: ++ used = 0; ++ break; ++ } ++ } ++exit: ++ *consumed = used; ++ return charset; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/types.h dvb-apps/lib/libucsi/dvb/types.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/types.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/types.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,127 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_TYPES_H ++#define _UCSI_DVB_TYPES_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++typedef uint8_t dvbdate_t[5]; ++typedef uint8_t dvbduration_t[3]; ++typedef uint8_t dvbhhmm_t[2]; ++ ++/** ++ * Running status values. ++ */ ++enum { ++ DVB_RUNNING_STATUS_NOT_RUNNING = 0x01, ++ DVB_RUNNING_STATUS_FEW_SECONDS = 0x02, ++ DVB_RUNNING_STATUS_PAUSING = 0x03, ++ DVB_RUNNING_STATUS_RUNNING = 0x04, ++}; ++ ++/** ++ * Convert from a 5 byte DVB UTC date to unix time. ++ * Note: this functions expects the DVB date in network byte order. ++ * ++ * @param d Pointer to DVB date. ++ * @return The unix timestamp, or -1 if the dvbdate was set to the 'undefined' value ++ */ ++extern time_t dvbdate_to_unixtime(dvbdate_t dvbdate); ++ ++/** ++ * Convert from a unix timestemp to a 5 byte DVB UTC date. ++ * Note: this function will always output the DVB date in ++ * network byte order. ++ * ++ * @param unixtime The unix timestamp, or -1 for the 'undefined' value. ++ * @param utc Pointer to 5 byte DVB date. ++ */ ++extern void unixtime_to_dvbdate(time_t unixtime, dvbdate_t dvbdate); ++ ++/** ++ * Convert from a DVB BCD duration to a number of seconds. ++ * ++ * @param dvbduration Pointer to 3 byte DVB duration. ++ * @return Number of seconds. ++ */ ++extern int dvbduration_to_seconds(dvbduration_t dvbduration); ++ ++/** ++ * Convert from a number of seconds to a DVB 3 byte BCD duration. ++ * ++ * @param seconds The number of seconds. ++ * @param dvbduration Pointer to 3 byte DVB duration. ++ */ ++extern void seconds_to_dvbduration(int seconds, dvbduration_t dvbduration); ++ ++/** ++ * Convert from a DVB BCD HHMM to a number of seconds. ++ * ++ * @param dvbduration Pointer to 2 byte DVB HHMM. ++ * @return Number of seconds. ++ */ ++extern int dvbhhmm_to_seconds(dvbhhmm_t dvbhhmm); ++ ++/** ++ * Convert from a number of seconds to a DVB 2 byte BCD HHMM. ++ * ++ * @param seconds The number of seconds. ++ * @param dvbduration Pointer to 2 byte DVB HHMM. ++ */ ++extern void seconds_to_dvbhhmm(int seconds, dvbhhmm_t dvbhhmm); ++ ++/** ++ * Convert a __ucsi_packed BCD value into a normal integer. ++ * ++ * @param bcd The value to convert. ++ * @return The value. ++ */ ++extern uint32_t bcd_to_integer(uint32_t bcd); ++ ++/** ++ * Convert a normal integer into a __ucsi_packed BCD value. ++ * ++ * @param integer The value to convert. ++ * @return The value. ++ */ ++extern uint32_t integer_to_bcd(uint32_t integer); ++ ++/** ++ * Determine the (iconv compatable) character set of a dvb string. ++ * ++ * @param dvb_text DVB text concerned. ++ * @param dvb_text_length Length of text. ++ * @param consumed Out parameter of number of bytes used to encode the character set. ++ * @return Name of the character set. ++ */ ++extern const char *dvb_charset(char *dvb_text, int dvb_text_length, int *consumed); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/vbi_data_descriptor.h dvb-apps/lib/libucsi/dvb/vbi_data_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/vbi_data_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/vbi_data_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,186 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_VBI_DATA_DESCRIPTOR ++#define _UCSI_DVB_VBI_DATA_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * Possible values for the data_service_id field. ++ */ ++enum { ++ DVB_VBI_DATA_SERVICE_ID_EBU = 0x01, ++ DVB_VBI_DATA_SERVICE_ID_INVERTED = 0x02, ++ DVB_VBI_DATA_SERVICE_ID_VPS = 0x04, ++ DVB_VBI_DATA_SERVICE_ID_WSS = 0x05, ++ DVB_VBI_DATA_SERVICE_ID_CC = 0x06, ++ DVB_VBI_DATA_SERVICE_ID_MONO_422 = 0x07, ++}; ++ ++/** ++ * dvb_vbi_data_descriptor structure ++ */ ++struct dvb_vbi_data_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_vbi_data_entry entries[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the dvb_vbi_data_descriptor entries field. ++ */ ++struct dvb_vbi_data_entry { ++ uint8_t data_service_id; ++ uint8_t data_length; ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++/** ++ * Format of the dvb_vbi_data_entry data field, if data_service_id == 1,2,4,5,6,7. ++ */ ++struct dvb_vbi_data_x { ++ EBIT3(uint8_t reserved : 2; , ++ uint8_t field_parity : 1; , ++ uint8_t line_offset : 5; ); ++} __ucsi_packed; ++ ++/** ++ * Process a dvb_vbi_data_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return dvb_vbi_data_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_vbi_data_descriptor* ++ dvb_vbi_data_descriptor_codec(struct descriptor* d) ++{ ++ uint8_t* p = (uint8_t*) d + 2; ++ uint32_t pos = 0; ++ uint32_t len = d->len; ++ ++ while(pos < len) { ++ struct dvb_vbi_data_entry *e = ++ (struct dvb_vbi_data_entry*) (p+pos); ++ ++ pos += sizeof(struct dvb_vbi_data_entry); ++ ++ if (pos > len) ++ return NULL; ++ ++ pos += e->data_length; ++ ++ if (pos > len) ++ return NULL; ++ } ++ ++ return (struct dvb_vbi_data_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries field in a dvb_vbi_data_descriptor structure. ++ * ++ * @param d Pointer to dvb_vbi_data_descriptor structure. ++ * @param pos Variable holding pointer to the current dvb_vbi_data_entry structure. ++ */ ++#define dvb_vbi_data_descriptor_entries_for_each(d, pos) \ ++ for ((pos) = dvb_vbi_data_descriptor_entries_first(d); \ ++ (pos); \ ++ (pos) = dvb_vbi_data_descriptor_entries_next(d, pos)) ++ ++/** ++ * Get a pointer to the data field of a dvb_vbi_data_entry. ++ * ++ * @param d dvb_vbi_data_entry structure. ++ * @return Pointer to the data field. ++ */ ++static inline uint8_t * ++ dvb_vbi_data_entry_data(struct dvb_vbi_data_entry *d) ++{ ++ return (uint8_t *) d + sizeof(struct dvb_vbi_data_entry); ++} ++ ++/** ++ * Get a pointer to the data field of a dvb_vbi_data_x for id 1,2,4,5,6,7. ++ * ++ * @param d dvb_vbi_data_entry structure. ++ * @return Pointer to the data field, or NULL if invalid ++ */ ++static inline struct dvb_vbi_data_x* ++ dvb_vbi_data_entry_data_x(struct dvb_vbi_data_entry *d) ++{ ++ switch(d->data_service_id) { ++ case 1: ++ case 2: ++ case 4: ++ case 5: ++ case 6: ++ case 7: ++ return (struct dvb_vbi_data_x*) ((uint8_t *) d + sizeof(struct dvb_vbi_data_entry)); ++ } ++ ++ return NULL; ++} ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_vbi_data_entry* ++ dvb_vbi_data_descriptor_entries_first(struct dvb_vbi_data_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_vbi_data_entry *) ++ ((uint8_t*) d + sizeof(struct dvb_vbi_data_descriptor)); ++} ++ ++static inline struct dvb_vbi_data_entry* ++ dvb_vbi_data_descriptor_entries_next(struct dvb_vbi_data_descriptor *d, ++ struct dvb_vbi_data_entry *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_vbi_data_entry) + ++ pos->data_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_vbi_data_entry *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/vbi_teletext_descriptor.h dvb-apps/lib/libucsi/dvb/vbi_teletext_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/dvb/vbi_teletext_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/dvb/vbi_teletext_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,116 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_DVB_VBI_TELETEXT_DESCRIPTOR ++#define _UCSI_DVB_VBI_TELETEXT_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * dvb_vbi_teletext_descriptor structure ++ */ ++struct dvb_vbi_teletext_descriptor { ++ struct descriptor d; ++ ++ /* struct dvb_vbi_teletext_entry entries[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in a dvb_vbi_teletext_descriptor structure. ++ */ ++struct dvb_vbi_teletext_entry { ++ iso639lang_t language_code; ++ EBIT2(uint8_t type : 5; , ++ uint8_t magazine_number: 3; ); ++ uint8_t page_number; ++} __ucsi_packed; ++ ++/** ++ * Process an dvb_vbi_teletext_descriptor. ++ * ++ * @param d Generic descriptor. ++ * @return dvb_vbi_teletext_descriptor pointer, or NULL on error. ++ */ ++static inline struct dvb_vbi_teletext_descriptor* ++ dvb_vbi_teletext_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len % sizeof(struct dvb_vbi_teletext_entry)) ++ return NULL; ++ ++ return (struct dvb_vbi_teletext_descriptor*) d; ++} ++ ++/** ++ * Iterator for entries field of a dvb_vbi_teletext_descriptor. ++ * ++ * @param d Pointer to dvb_vbi_teletext_descriptor. ++ * @param pos Variable holding a pointer to the current dvb_vbi_teletext_entry. ++ */ ++#define dvb_vbi_teletext_descriptor_entries_for_each(d, pos) \ ++ for ((pos) = dvb_vbi_teletext_descriptor_entries_first(d); \ ++ (pos); \ ++ (pos) = dvb_vbi_teletext_descriptor_entries_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct dvb_vbi_teletext_entry* ++ dvb_vbi_teletext_descriptor_entries_first(struct dvb_vbi_teletext_descriptor *d) ++{ ++ if (d->d.len == 0) ++ return NULL; ++ ++ return (struct dvb_vbi_teletext_entry *) ++ ((uint8_t*) d + sizeof(struct dvb_vbi_teletext_descriptor)); ++} ++ ++static inline struct dvb_vbi_teletext_entry* ++ dvb_vbi_teletext_descriptor_entries_next(struct dvb_vbi_teletext_descriptor *d, ++ struct dvb_vbi_teletext_entry *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct dvb_vbi_teletext_entry); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct dvb_vbi_teletext_entry *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/endianops.h dvb-apps/lib/libucsi/endianops.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/endianops.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/endianops.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,128 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_COMMON_H ++#define _UCSI_COMMON_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++#define __ucsi_packed __attribute__((packed)) ++ ++ ++ ++ ++#if __BYTE_ORDER == __BIG_ENDIAN ++#define EBIT2(x1,x2) x1 x2 ++#define EBIT3(x1,x2,x3) x1 x2 x3 ++#define EBIT4(x1,x2,x3,x4) x1 x2 x3 x4 ++#define EBIT5(x1,x2,x3,x4,x5) x1 x2 x3 x4 x5 ++#define EBIT6(x1,x2,x3,x4,x5,x6) x1 x2 x3 x4 x5 x6 ++#define EBIT7(x1,x2,x3,x4,x5,x6,x7) x1 x2 x3 x4 x5 x6 x7 ++#define EBIT8(x1,x2,x3,x4,x5,x6,x7,x8) x1 x2 x3 x4 x5 x6 x7 x8 ++ ++static inline void bswap16(uint8_t *buf) { ++ (void) buf; ++} ++ ++static inline void bswap32(uint8_t *buf) { ++ (void) buf; ++} ++ ++static inline void bswap64(uint8_t *buf) { ++ (void) buf; ++} ++ ++static inline void bswap24(uint8_t *buf) { ++ (void) buf; ++} ++ ++static inline void bswap40(uint8_t *buf) { ++ (void) buf; ++} ++ ++static inline void bswap48(uint8_t *buf) { ++ (void) buf; ++} ++ ++#else ++#define EBIT2(x1,x2) x2 x1 ++#define EBIT3(x1,x2,x3) x3 x2 x1 ++#define EBIT4(x1,x2,x3,x4) x4 x3 x2 x1 ++#define EBIT5(x1,x2,x3,x4,x5) x5 x4 x3 x2 x1 ++#define EBIT6(x1,x2,x3,x4,x5,x6) x6 x5 x4 x3 x2 x1 ++#define EBIT7(x1,x2,x3,x4,x5,x6,x7) x7 x6 x5 x4 x3 x2 x1 ++#define EBIT8(x1,x2,x3,x4,x5,x6,x7,x8) x8 x7 x6 x5 x4 x3 x2 x1 ++ ++static inline void bswap16(uint8_t * buf) { ++ *((uint16_t*)buf) = bswap_16((*(uint16_t*)buf)); ++} ++ ++static inline void bswap32(uint8_t * buf) { ++ *((uint32_t*)buf) = bswap_32((*(uint32_t*)buf)); ++} ++ ++static inline void bswap64(uint8_t * buf) { ++ *((uint64_t*)buf) = bswap_64((*(uint64_t*)buf)); ++} ++ ++static inline void bswap24(uint8_t * buf) { ++ uint8_t tmp0 = buf[0]; ++ ++ buf[0] = buf[2]; ++ buf[2] = tmp0; ++} ++ ++static inline void bswap40(uint8_t * buf) { ++ uint8_t tmp0 = buf[0]; ++ uint8_t tmp1 = buf[1]; ++ ++ buf[0] = buf[4]; ++ buf[1] = buf[3]; ++ buf[3] = tmp1; ++ buf[4] = tmp0; ++} ++ ++static inline void bswap48(uint8_t * buf) { ++ uint8_t tmp0 = buf[0]; ++ uint8_t tmp1 = buf[1]; ++ uint8_t tmp2 = buf[2]; ++ ++ buf[0] = buf[5]; ++ buf[1] = buf[4]; ++ buf[2] = buf[3]; ++ buf[3] = tmp2; ++ buf[4] = tmp1; ++ buf[5] = tmp0; ++} ++ ++#endif // __BYTE_ORDER ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/Makefile dvb-apps/lib/libucsi/Makefile +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,34 @@ ++# Makefile for linuxtv.org dvb-apps/lib/libucsi ++ ++includes = crc32.h \ ++ descriptor.h \ ++ endianops.h \ ++ section.h \ ++ section_buf.h \ ++ transport_packet.h \ ++ types.h ++ ++objects = crc32.o \ ++ section_buf.o \ ++ transport_packet.o ++ ++lib_name = libucsi ++ ++CPPFLAGS += -I../../lib ++ ++.PHONY: all ++ ++all: library ++ ++include atsc/Makefile ++include dvb/Makefile ++include mpeg/Makefile ++ ++.PHONY: $(sub-install) ++ ++install:: $(sub-install) ++ ++$(sub-install): ++ $(MAKE) -C $@ install ++ ++include ../../Make.rules +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/audio_stream_descriptor.h dvb-apps/lib/libucsi/mpeg/audio_stream_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/audio_stream_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/audio_stream_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,65 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_AUDIO_STREAM_DESCRIPTOR ++#define _UCSI_MPEG_AUDIO_STREAM_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_audio_stream_descriptor structure ++ */ ++struct mpeg_audio_stream_descriptor { ++ struct descriptor d; ++ ++ EBIT5(uint8_t free_format_flag : 1; , ++ uint8_t id : 1; , ++ uint8_t layer : 2; , ++ uint8_t variable_rate_audio_indicator : 1; , ++ uint8_t reserved : 3; ); ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_audio_stream_descriptor. ++ * ++ * @param d Pointer to the generic descriptor structure. ++ * @return Pointer to the mpeg_audio_stream_descriptor structure, or NULL on error. ++ */ ++static inline struct mpeg_audio_stream_descriptor* ++ mpeg_audio_stream_descriptor_codec(struct descriptor *d) ++{ ++ if (d->len != (sizeof(struct mpeg_audio_stream_descriptor) - 2)) ++ return NULL; ++ ++ return (struct mpeg_audio_stream_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/ca_descriptor.h dvb-apps/lib/libucsi/mpeg/ca_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/ca_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/ca_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,91 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_CA_DESCRIPTOR ++#define _UCSI_MPEG_CA_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_ca_descriptor structure ++ */ ++struct mpeg_ca_descriptor { ++ struct descriptor d; ++ ++ uint16_t ca_system_id; ++ EBIT2(uint16_t reserved : 3; , ++ uint16_t ca_pid : 13; ); ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_ca_descriptor. ++ * ++ * @param d Generic descriptor. ++ * @return Pointer to an mpeg_ca_descriptor, or NULL on error. ++ */ ++static inline struct mpeg_ca_descriptor* ++ mpeg_ca_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len < (sizeof(struct mpeg_ca_descriptor) - 2)) ++ return NULL; ++ ++ bswap16((uint8_t*) d + 2); ++ bswap16((uint8_t*) d + 4); ++ ++ return (struct mpeg_ca_descriptor*) d; ++} ++ ++/** ++ * Accessor for pointer to data field of an mpeg_ca_descriptor. ++ * ++ * @param d The mpeg_ca_descriptor structure. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ mpeg_ca_descriptor_data(struct mpeg_ca_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct mpeg_ca_descriptor); ++} ++ ++/** ++ * Determine length of data field of an mpeg_ca_descriptor. ++ * ++ * @param d The mpeg_ca_descriptor structure. ++ * @return Length of the field in bytes. ++ */ ++static inline int ++ mpeg_ca_descriptor_data_length(struct mpeg_ca_descriptor *d) ++{ ++ return d->d.len - 4; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/cat_section.c dvb-apps/lib/libucsi/mpeg/cat_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/cat_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/cat_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,34 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct mpeg_cat_section * mpeg_cat_section_codec(struct section_ext * ext) ++{ ++ uint8_t * buf = (uint8_t *)ext; ++ size_t pos = sizeof(struct section_ext); ++ ++ if (verify_descriptors(buf + pos, ++ section_ext_length(ext) - sizeof(struct mpeg_cat_section))) ++ return NULL; ++ ++ return (struct mpeg_cat_section *)ext; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/cat_section.h dvb-apps/lib/libucsi/mpeg/cat_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/cat_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/cat_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,94 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_CAT_SECTION_H ++#define _UCSI_MPEG_CAT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * mpeg_cat_section structure. ++ */ ++struct mpeg_cat_section { ++ struct section_ext head; ++ ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_cat_section. ++ * ++ * @param section The generic section_ext structure. ++ * @return Pointer to an mpeg_cat_section structure, or NULL on error. ++ */ ++extern struct mpeg_cat_section *mpeg_cat_section_codec(struct section_ext *section); ++ ++/** ++ * Convenience iterator for descriptors field of an mpeg_cat_section. ++ * ++ * @param cat The mpeg_cat_section pointer. ++ * @param pos Variable holding a pointer to the current descriptor. ++ */ ++#define mpeg_cat_section_descriptors_for_each(cat, pos) \ ++ for ((pos) = mpeg_cat_section_descriptors_first(cat); \ ++ (pos); \ ++ (pos) = mpeg_cat_section_descriptors_next(cat, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct descriptor * ++ mpeg_cat_section_descriptors_first(struct mpeg_cat_section *cat) ++{ ++ size_t pos = sizeof(struct mpeg_cat_section); ++ ++ if (pos >= section_ext_length(&cat->head)) ++ return NULL; ++ ++ return (struct descriptor*)((uint8_t *) cat + pos); ++} ++ ++ ++static inline struct descriptor * ++ mpeg_cat_section_descriptors_next(struct mpeg_cat_section *cat, ++ struct descriptor* pos) ++{ ++ return next_descriptor((uint8_t *) cat + sizeof(struct mpeg_cat_section), ++ section_ext_length(&cat->head) - sizeof(struct mpeg_cat_section), ++ pos); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/content_labelling_descriptor.h dvb-apps/lib/libucsi/mpeg/content_labelling_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/content_labelling_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/content_labelling_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,356 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_CONTENT_LABELLING_DESCRIPTOR ++#define _UCSI_MPEG_CONTENT_LABELLING_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * Possible values for content_time_base_indicator. ++ */ ++enum { ++ MPEG_CONTENT_TIME_BASE_STC = 0x01, ++ MPEG_CONTENT_TIME_BASE_NPT = 0x02, ++}; ++ ++/** ++ * mpeg_content_labelling_descriptor structure. ++ */ ++struct mpeg_content_labelling_descriptor { ++ struct descriptor d; ++ ++ uint16_t metadata_application_format; ++ /* struct mpeg_content_labelling_descriptor_application_format_identifier id */ ++ /* struct mpeg_content_labelling_descriptor_flags flags */ ++ /* struct mpeg_content_labelling_descriptor_reference_id reference_id */ ++ /* struct mpeg_content_labelling_descriptor_time_base time_base */ ++ /* struct mpeg_content_labelling_descriptor_content_id content_id */ ++ /* struct mpeg_content_labelling_descriptor_time_base_association time_base_assoc */ ++ /* uint8_t private_data[] */ ++} __ucsi_packed; ++ ++/** ++ * id field of a content_labelling_descriptor. ++ */ ++struct mpeg_content_labelling_descriptor_application_format_identifier { ++ uint32_t id; ++} __ucsi_packed; ++ ++/** ++ * Flags field of a content_labelling_descriptor ++ */ ++struct mpeg_content_labelling_descriptor_flags { ++ EBIT3(uint8_t content_reference_id_record_flag : 1; , ++ uint8_t content_time_base_indicator : 4; , ++ uint8_t reserved : 3; ); ++} __ucsi_packed; ++ ++/** ++ * Reference_id field of a content_labelling_descriptor. ++ */ ++struct mpeg_content_labelling_descriptor_reference_id { ++ uint8_t content_reference_id_record_length; ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++/** ++ * time_base field of a content_labelling_descriptor. ++ */ ++struct mpeg_content_labelling_descriptor_time_base { ++ EBIT2(uint64_t reserved_1 : 7; , ++ uint64_t content_time_base_value :33; ); ++ EBIT2(uint64_t reserved_2 : 7; , ++ uint64_t metadata_time_base_value :33; ); ++} __ucsi_packed; ++ ++/** ++ * content_id field of a content_labelling_descriptor. ++ */ ++struct mpeg_content_labelling_descriptor_content_id { ++ EBIT2(uint8_t reserved : 1; , ++ uint8_t contentId : 7; ); ++} __ucsi_packed; ++ ++/** ++ * time_base_assoc field of a content_labelling_descriptor. ++ */ ++struct mpeg_content_labelling_descriptor_time_base_association { ++ uint8_t time_base_association_data_length; ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++ ++ ++/** ++ * Process an mpeg_content_labelling_descriptor. ++ * ++ * @param d Generic descriptor. ++ * @return Pointer to an mpeg_content_labelling_descriptor, or NULL on error. ++ */ ++static inline struct mpeg_content_labelling_descriptor* ++ mpeg_content_labelling_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t pos = 2; ++ uint8_t *buf = (uint8_t*) d; ++ uint32_t len = d->len + 2; ++ struct mpeg_content_labelling_descriptor_flags *flags; ++ int id; ++ ++ if (len < sizeof(struct mpeg_content_labelling_descriptor)) ++ return NULL; ++ ++ bswap16(buf + pos); ++ id = *((uint16_t*) (buf+pos)); ++ pos += 2; ++ ++ if (id == 0xffff) { ++ if (len < (pos+4)) ++ return NULL; ++ bswap32(buf+pos); ++ pos += 4; ++ } ++ ++ if (len < (pos + sizeof(struct mpeg_content_labelling_descriptor_flags))) ++ return NULL; ++ flags = (struct mpeg_content_labelling_descriptor_flags*) (buf+pos); ++ pos += sizeof(struct mpeg_content_labelling_descriptor_flags); ++ ++ if (flags->content_reference_id_record_flag == 1) { ++ if (len < (pos+1)) ++ return NULL; ++ if (len < (pos+1+buf[pos])) ++ return NULL; ++ pos += 1 + buf[pos]; ++ } ++ ++ if ((flags->content_time_base_indicator == 1) || ++ (flags->content_time_base_indicator == 2)) { ++ if (len < (pos + sizeof(struct mpeg_content_labelling_descriptor_time_base))) ++ return NULL; ++ bswap40(buf+pos); ++ bswap40(buf+pos+5); ++ pos += sizeof(struct mpeg_content_labelling_descriptor_time_base); ++ } ++ ++ if (flags->content_time_base_indicator == 2) { ++ if (len < (pos + sizeof(struct mpeg_content_labelling_descriptor_content_id))) ++ return NULL; ++ pos += sizeof(struct mpeg_content_labelling_descriptor_content_id); ++ } ++ ++ if (flags->content_time_base_indicator > 2) { ++ if (len < (pos+1)) ++ return NULL; ++ if (len < (pos+1+buf[pos])) ++ return NULL; ++ pos += 1 + buf[pos]; ++ } ++ ++ if (len < pos) ++ return NULL; ++ ++ return (struct mpeg_content_labelling_descriptor*) d; ++} ++ ++/** ++ * Accessor for pointer to id field of an mpeg_content_labelling_descriptor. ++ * ++ * @param d The mpeg_content_labelling_descriptor structure. ++ * @return The pointer, or NULL on error. ++ */ ++static inline struct mpeg_content_labelling_descriptor_application_format_identifier* ++ mpeg_content_labelling_descriptor_id(struct mpeg_content_labelling_descriptor *d) ++{ ++ uint8_t *buf = (uint8_t*) d; ++ ++ if (d->metadata_application_format != 0xffff) ++ return NULL; ++ return (struct mpeg_content_labelling_descriptor_application_format_identifier*) ++ (buf + sizeof(struct mpeg_content_labelling_descriptor)); ++} ++ ++/** ++ * Accessor for pointer to flags field of an mpeg_content_labelling_descriptor. ++ * ++ * @param d The mpeg_content_labelling_descriptor structure. ++ * @return The pointer, or NULL on error. ++ */ ++static inline struct mpeg_content_labelling_descriptor_flags* ++ mpeg_content_labelling_descriptor_flags(struct mpeg_content_labelling_descriptor *d) ++{ ++ uint8_t *buf = (uint8_t*) d + sizeof(struct mpeg_content_labelling_descriptor); ++ ++ if (d->metadata_application_format != 0xffff) ++ buf += 4; ++ ++ return (struct mpeg_content_labelling_descriptor_flags *) buf; ++} ++ ++/** ++ * Accessor for reference_id field of an mpeg_content_labelling_descriptor. ++ * ++ * @param flags Pointer to the mpeg_content_labelling_descriptor_flags. ++ * @return Pointer to the field, or NULL on error. ++ */ ++static inline struct mpeg_content_labelling_descriptor_reference_id* ++ mpeg_content_labelling_descriptor_reference_id(struct mpeg_content_labelling_descriptor_flags *flags) ++{ ++ uint8_t *buf = (uint8_t*) flags + sizeof(struct mpeg_content_labelling_descriptor_flags); ++ ++ if (flags->content_reference_id_record_flag != 1) ++ return NULL; ++ ++ return (struct mpeg_content_labelling_descriptor_reference_id *) buf; ++} ++ ++/** ++ * Accessor for data field of an mpeg_content_reference_id. ++ * ++ * @param d The mpeg_content_reference_id structure. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t* ++ mpeg_content_reference_id_data(struct mpeg_content_labelling_descriptor_reference_id *d) ++{ ++ return (uint8_t*) d + sizeof(struct mpeg_content_labelling_descriptor_reference_id); ++} ++ ++/** ++ * Accessor for time_base field of an mpeg_content_labelling_descriptor. ++ * ++ * @param flags Pointer to the mpeg_content_labelling_descriptor_flags. ++ * @return Pointer to the field, or NULL on error. ++ */ ++static inline struct mpeg_content_labelling_descriptor_time_base* ++ mpeg_content_labelling_descriptor_time_base(struct mpeg_content_labelling_descriptor_flags *flags) ++{ ++ uint8_t *buf = (uint8_t*) flags + sizeof(struct mpeg_content_labelling_descriptor_flags); ++ ++ if ((flags->content_time_base_indicator!=1) && (flags->content_time_base_indicator!=2)) ++ return NULL; ++ ++ if (flags->content_reference_id_record_flag == 1) ++ buf += 1 + buf[1]; ++ ++ return (struct mpeg_content_labelling_descriptor_time_base *) buf; ++} ++ ++/** ++ * Accessor for content_id field of an mpeg_content_labelling_descriptor. ++ * ++ * @param flags Pointer to the mpeg_content_labelling_descriptor_flags. ++ * @return Pointer to the field, or NULL on error. ++ */ ++static inline struct mpeg_content_labelling_descriptor_content_id* ++ mpeg_content_labelling_descriptor_content_id(struct mpeg_content_labelling_descriptor_flags *flags) ++{ ++ uint8_t *buf = (uint8_t*) flags + sizeof(struct mpeg_content_labelling_descriptor_flags); ++ ++ if (flags->content_time_base_indicator!=2) ++ return NULL; ++ ++ if (flags->content_reference_id_record_flag == 1) ++ buf += 1 + buf[1]; ++ if ((flags->content_time_base_indicator==1) || (flags->content_time_base_indicator==2)) ++ buf += sizeof(struct mpeg_content_labelling_descriptor_time_base); ++ ++ return (struct mpeg_content_labelling_descriptor_content_id *) buf; ++} ++ ++/** ++ * Accessor for time_base_association field of an mpeg_content_labelling_descriptor. ++ * ++ * @param flags Pointer to the mpeg_content_labelling_descriptor_flags. ++ * @return Pointer to the field, or NULL on error. ++ */ ++static inline struct mpeg_content_labelling_descriptor_time_base_association* ++ mpeg_content_labelling_descriptor_time_base_assoc(struct mpeg_content_labelling_descriptor_flags *flags) ++{ ++ uint8_t *buf = (uint8_t*) flags + sizeof(struct mpeg_content_labelling_descriptor_flags); ++ ++ if (flags->content_time_base_indicator<3) ++ return NULL; ++ ++ if (flags->content_reference_id_record_flag == 1) ++ buf += 1 + buf[1]; ++ if ((flags->content_time_base_indicator==1) || (flags->content_time_base_indicator==2)) ++ buf += sizeof(struct mpeg_content_labelling_descriptor_time_base); ++ if (flags->content_time_base_indicator==2) ++ buf += sizeof(struct mpeg_content_labelling_descriptor_content_id); ++ ++ return (struct mpeg_content_labelling_descriptor_time_base_association *) buf; ++} ++ ++/** ++ * Accessor for data field of an mpeg_time_base_association. ++ * ++ * @param d The mpeg_time_base_association structure. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t* ++ mpeg_time_base_association_data(struct mpeg_content_labelling_descriptor_time_base_association *d) ++{ ++ return (uint8_t*) d + sizeof(struct mpeg_content_labelling_descriptor_time_base_association); ++} ++ ++ ++/** ++ * Accessor for private_data field of an mpeg_content_labelling_descriptor. ++ * ++ * @param d The mpeg_content_labelling_descriptor structure. ++ * @param flags Pointer to the mpeg_content_labelling_descriptor_flags. ++ * @param length Where the number of bytes in the field should be stored. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t* ++ mpeg_content_labelling_descriptor_data(struct mpeg_content_labelling_descriptor *d, ++ struct mpeg_content_labelling_descriptor_flags *flags, ++ int *length) ++{ ++ uint8_t *buf = (uint8_t*) flags + sizeof(struct mpeg_content_labelling_descriptor_flags); ++ uint8_t *end = (uint8_t*) d + d->d.len + 2; ++ ++ if (flags->content_reference_id_record_flag == 1) ++ buf += 1 + buf[1]; ++ if ((flags->content_time_base_indicator==1) || (flags->content_time_base_indicator==2)) ++ buf += sizeof(struct mpeg_content_labelling_descriptor_time_base); ++ if (flags->content_time_base_indicator==2) ++ buf += sizeof(struct mpeg_content_labelling_descriptor_content_id); ++ if (flags->content_time_base_indicator<3) ++ buf += 1 + buf[1]; ++ ++ *length = end - buf; ++ ++ return buf; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/copyright_descriptor.h dvb-apps/lib/libucsi/mpeg/copyright_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/copyright_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/copyright_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,89 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_COPYRIGHT_DESCRIPTOR ++#define _UCSI_MPEG_COPYRIGHT_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_copyright_descriptor structure. ++ */ ++struct mpeg_copyright_descriptor { ++ struct descriptor d; ++ ++ uint32_t copyright_identifier; ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_copyright_descriptor. ++ * ++ * @param d Generic descriptor. ++ * @return mpeg_copyright_descriptor pointer, or NULL on error. ++ */ ++static inline struct mpeg_copyright_descriptor* ++ mpeg_copyright_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len < (sizeof(struct mpeg_copyright_descriptor) - 2)) ++ return NULL; ++ ++ bswap32((uint8_t*) d + 2); ++ ++ return (struct mpeg_copyright_descriptor*) d; ++} ++ ++/** ++ * Retrieve pointer to data field of an mpeg_copyright_descriptor. ++ * ++ * @param d mpeg_copyright_descriptor pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ mpeg_copyright_descriptor_data(struct mpeg_copyright_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct mpeg_copyright_descriptor); ++} ++ ++ ++/** ++ * Determine length of the data field of an mpeg_copyright_descriptor. ++ * ++ * @param d mpeg_copyright_descriptor pointer. ++ * @return Length of field in bytes. ++ */ ++static inline int ++ mpeg_copyright_descriptor_data_length(struct mpeg_copyright_descriptor *d) ++{ ++ return d->d.len - 4; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/datagram_section.h dvb-apps/lib/libucsi/mpeg/datagram_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/datagram_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/datagram_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,81 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * Copyright (C) 2008 Patrick Boettcher (pb@linuxtv.org) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_DATAGRAM_SECTION_H ++#define _UCSI_MPEG_DATAGRAM_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * datagram_section structure. ++ */ ++struct datagram_section { ++ struct section head; ++ ++ uint8_t MAC_address_6; ++ uint8_t MAC_address_5; ++ EBIT5(uint8_t reserved : 2; , ++ uint8_t payload_scrambling_control : 2; , ++ uint8_t address_scrambling_control : 2; , ++ uint8_t LLC_SNAP_flag : 1; , ++ uint8_t current_next_indicator : 1; ); ++ uint8_t section_number; ++ uint8_t last_section_number; ++ uint8_t MAC_address_4; ++ uint8_t MAC_address_3; ++ uint8_t MAC_address_2; ++ uint8_t MAC_address_1; ++ ++ /* LLC_SNAP or IP-data */ ++ /* if last section stuffing */ ++ /* CRC */ ++} __ucsi_packed; ++ ++/** ++ */ ++static inline struct datagram_section *datagram_section_codec(struct section *section) ++{ ++ /* something to do here ? */ ++ return (struct datagram_section *) section; ++} ++ ++static inline uint8_t *datagram_section_ip_data(struct datagram_section *d) ++{ ++ return (uint8_t *) d + sizeof(struct section) + 2 + 1 + 1 + 1 + 4; ++} ++ ++static inline size_t datagram_section_ip_data_length(struct datagram_section *d) ++{ ++ return section_length(&d->head) - (sizeof(struct section) + 2 + 1 + 1 + 1 + 4) - CRC_SIZE; ++} ++ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/data_stream_alignment_descriptor.h dvb-apps/lib/libucsi/mpeg/data_stream_alignment_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/data_stream_alignment_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/data_stream_alignment_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,73 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_DATA_STREAM_ALIGNMENT_DESCRIPTOR ++#define _UCSI_MPEG_DATA_STREAM_ALIGNMENT_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * Possible values for alignment_type. ++ */ ++enum { ++ MPEG_DATA_STREAM_ALIGNMENT_VIDEO_SLICE_OR_AU = 0x01, ++ MPEG_DATA_STREAM_ALIGNMENT_VIDEO_AU = 0x02, ++ MPEG_DATA_STREAM_ALIGNMENT_VIDEO_GOP_OR_SEQ = 0x03, ++ MPEG_DATA_STREAM_ALIGNMENT_VIDEO_SEQ = 0x04, ++ ++ MPEG_DATA_STREAM_ALIGNMENT_AUDIO_SYNC_WORD = 0x01, ++}; ++ ++/** ++ * mpeg_data_stream_alignment_descriptor structure. ++ */ ++struct mpeg_data_stream_alignment_descriptor { ++ struct descriptor d; ++ ++ uint8_t alignment_type; ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_data_stream_alignment_descriptor. ++ * ++ * @param d Pointer to generic descriptor structure. ++ * @return Pointer to mpeg_data_stream_alignment_descriptor, or NULL on error. ++ */ ++static inline struct mpeg_data_stream_alignment_descriptor* ++ mpeg_data_stream_alignment_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct mpeg_data_stream_alignment_descriptor) - 2)) ++ return NULL; ++ ++ return (struct mpeg_data_stream_alignment_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/descriptor.h dvb-apps/lib/libucsi/mpeg/descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,102 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_DESCRIPTOR_H ++#define _UCSI_MPEG_DESCRIPTOR_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/** ++ * Enumeration of MPEG descriptor tags. ++ */ ++enum mpeg_descriptor_tag { ++ dtag_mpeg_video_stream = 0x02, ++ dtag_mpeg_audio_stream = 0x03, ++ dtag_mpeg_hierarchy = 0x04, ++ dtag_mpeg_registration = 0x05, ++ dtag_mpeg_data_stream_alignment = 0x06, ++ dtag_mpeg_target_background_grid = 0x07, ++ dtag_mpeg_video_window = 0x08, ++ dtag_mpeg_ca = 0x09, ++ dtag_mpeg_iso_639_language = 0x0a, ++ dtag_mpeg_system_clock = 0x0b, ++ dtag_mpeg_multiplex_buffer_utilization = 0x0c, ++ dtag_mpeg_copyright = 0x0d, ++ dtag_mpeg_maximum_bitrate = 0x0e, ++ dtag_mpeg_private_data_indicator = 0x0f, ++ dtag_mpeg_smoothing_buffer = 0x10, ++ dtag_mpeg_std = 0x11, ++ dtag_mpeg_ibp = 0x12, ++ dtag_mpeg_4_video = 0x1b, ++ dtag_mpeg_4_audio = 0x1c, ++ dtag_mpeg_iod = 0x1d, ++ dtag_mpeg_sl = 0x1e, ++ dtag_mpeg_fmc = 0x1f, ++ dtag_mpeg_external_es_id = 0x20, ++ dtag_mpeg_muxcode = 0x21, ++ dtag_mpeg_fmxbuffer_size = 0x22, ++ dtag_mpeg_multiplex_buffer = 0x23, ++ dtag_mpeg_content_labelling = 0x24, ++ dtag_mpeg_metadata_pointer = 0x25, ++ dtag_mpeg_metadata = 0x26, ++ dtag_mpeg_metadata_std = 0x27, ++}; ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/external_es_id_descriptor.h dvb-apps/lib/libucsi/mpeg/external_es_id_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/external_es_id_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/external_es_id_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,63 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_EXTERNAL_ES_ID_DESCRIPTOR ++#define _UCSI_MPEG_EXTERNAL_ES_ID_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_external_es_id_descriptor structure. ++ */ ++struct mpeg_external_es_id_descriptor { ++ struct descriptor d; ++ ++ uint16_t external_es_id; ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_external_es_id_descriptor structure. ++ * ++ * @param d Generic descriptor structure. ++ * @return mpeg_external_es_id_descriptor pointer, or NULL on error. ++ */ ++static inline struct mpeg_external_es_id_descriptor* ++ mpeg_external_es_id_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct mpeg_external_es_id_descriptor) - 2)) ++ return NULL; ++ ++ bswap16((uint8_t*) d + 2); ++ ++ return (struct mpeg_external_es_id_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/fmc_descriptor.h dvb-apps/lib/libucsi/mpeg/fmc_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/fmc_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/fmc_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,122 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_FMC_DESCRIPTOR ++#define _UCSI_MPEG_FMC_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_fmc_descriptor structure. ++ */ ++struct mpeg_fmc_descriptor { ++ struct descriptor d; ++ ++ /* struct mpeg_flex_mux muxes[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the muxes field of an mpeg_fmc_descriptor structure. ++ */ ++struct mpeg_flex_mux { ++ uint16_t es_id; ++ uint8_t flex_mux_channel; ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_fmc_descriptor structure. ++ * ++ * @param d Generic descriptor structure. ++ * @return Pointer to an mpeg_fmc_descriptor structure, or NULL on error. ++ */ ++static inline struct mpeg_fmc_descriptor* ++ mpeg_fmc_descriptor_codec(struct descriptor* d) ++{ ++ uint8_t* buf = (uint8_t*) d + 2; ++ int pos = 0; ++ int len = d->len; ++ ++ if (len % sizeof(struct mpeg_flex_mux)) ++ return NULL; ++ ++ while(pos < len) { ++ bswap16(buf+pos); ++ pos += sizeof(struct mpeg_flex_mux); ++ } ++ ++ return (struct mpeg_fmc_descriptor*) d; ++} ++ ++/** ++ * Convenience iterator for the muxes field of an mpeg_fmc_descriptor structure. ++ * ++ * @param d Generic descriptor structure. ++ * @param pos Variable holding a pointer to the the current entry within the muxes field. ++ */ ++#define mpeg_fmc_descriptor_muxes_for_each(d, pos) \ ++ for ((pos) = mpeg_fmc_descriptor_muxes_first(d); \ ++ (pos); \ ++ (pos) = mpeg_fmc_descriptor_muxes_next(d, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct mpeg_flex_mux* ++ mpeg_fmc_descriptor_muxes_first(struct mpeg_fmc_descriptor *d) ++{ ++ if (d->d.len < sizeof(struct mpeg_flex_mux)) ++ return NULL; ++ ++ return (struct mpeg_flex_mux *) ++ ((uint8_t*) d + sizeof(struct mpeg_fmc_descriptor)); ++} ++ ++static inline struct mpeg_flex_mux* ++ mpeg_fmc_descriptor_muxes_next(struct mpeg_fmc_descriptor *d, ++ struct mpeg_flex_mux *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct mpeg_flex_mux); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct mpeg_flex_mux *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/fmxbuffer_size_descriptor.h dvb-apps/lib/libucsi/mpeg/fmxbuffer_size_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/fmxbuffer_size_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/fmxbuffer_size_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,83 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_FMXBUFFER_SIZE_DESCRIPTOR ++#define _UCSI_MPEG_FMXBUFFER_SIZE_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++ ++/** ++ * mpeg_fmxbuffer_size_descriptor structure. ++ */ ++struct mpeg_fmxbuffer_size_descriptor { ++ struct descriptor d; ++ ++ /* uint8_t descriptors[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_fmxbuffer_size_descriptor structure. ++ * ++ * @param d Pointer to a generic descriptor structure. ++ * @return Pointer to an mpeg_fmxbuffer_size_descriptor structure, or NULL on error. ++ */ ++static inline struct mpeg_fmxbuffer_size_descriptor* ++ mpeg_fmxbuffer_size_descriptor_codec(struct descriptor* d) ++{ ++ return (struct mpeg_fmxbuffer_size_descriptor*) d; ++} ++ ++/** ++ * Retrieve pointer to descriptors field of mpeg_fmxbuffer_size_descriptor structure. ++ * ++ * @param d mpeg_fmxbuffer_size_descriptor structure pointer. ++ * @return Pointer to the descriptors. ++ */ ++static inline uint8_t * ++ mpeg_fmxbuffer_size_descriptor_descriptors(struct mpeg_fmxbuffer_size_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct mpeg_fmxbuffer_size_descriptor); ++} ++ ++/** ++ * Calculate the length of the descriptors field of an mpeg_fmxbuffer_size_descriptor structure. ++ * ++ * @param d mpeg_fmxbuffer_size_descriptor structure pointer. ++ * @return Length of descriptors in bytes. ++ */ ++static inline int ++ mpeg_fmxbuffer_size_descriptor_descriptors_length(struct mpeg_fmxbuffer_size_descriptor *d) ++{ ++ return d->d.len; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/hierarchy_descriptor.h dvb-apps/lib/libucsi/mpeg/hierarchy_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/hierarchy_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/hierarchy_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,83 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_HIERARCHY_DESCRIPTOR ++#define _UCSI_MPEG_HIERARCHY_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * Hierarchy type values. ++ */ ++enum { ++ MPEG_HIERARCHY_TYPE_ISO13818_2_SPATIAL_SCALABILITY = 0x01, ++ MPEG_HIERARCHY_TYPE_ISO13818_2_SNR_SCALABILITY = 0x02, ++ MPEG_HIERARCHY_TYPE_ISO13818_2_TEMPORAL_SCALABILITY = 0x03, ++ MPEG_HIERARCHY_TYPE_ISO13818_2_DATA_PARTITIONING = 0x04, ++ MPEG_HIERARCHY_TYPE_ISO13818_3_EXTENSION_BITSTREAM = 0x05, ++ MPEG_HIERARCHY_TYPE_ISO13818_1_PRIVATE_BITSTREAM = 0x06, ++ MPEG_HIERARCHY_TYPE_ISO13818_2_MULTI_VIEW_PROFILE = 0x07, ++ MPEG_HIERARCHY_TYPE_BASE_LAYER = 0x0f, ++}; ++ ++ ++/** ++ * mpeg_hierarchy_descriptor structure. ++ */ ++struct mpeg_hierarchy_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint8_t reserved_1 : 4; , ++ uint8_t hierarchy_type : 4; ); ++ EBIT2(uint8_t reserved_2 : 2; , ++ uint8_t hierarchy_layer_index : 6; ); ++ EBIT2(uint8_t reserved_3 : 2; , ++ uint8_t hierarchy_embedded_layer_index : 6; ); ++ EBIT2(uint8_t reserved_4 : 2; , ++ uint8_t hierarchy_channel : 6; ); ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_hierarchy_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return Pointer to mpeg_hierarchy_descriptor structure, or NULL on error. ++ */ ++static inline struct mpeg_hierarchy_descriptor* ++ mpeg_hierarchy_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct mpeg_hierarchy_descriptor) - 2)) ++ return NULL; ++ ++ return (struct mpeg_hierarchy_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/ibp_descriptor.h dvb-apps/lib/libucsi/mpeg/ibp_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/ibp_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/ibp_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,65 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_IBP_DESCRIPTOR ++#define _UCSI_MPEG_IBP_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_ibp_descriptor structure. ++ */ ++struct mpeg_ibp_descriptor { ++ struct descriptor d; ++ ++ EBIT3(uint16_t closed_gop_flag : 1; , ++ uint16_t identical_gop_flag : 1; , ++ uint16_t max_gop_length : 14; ); ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_ibp_descriptor structure. ++ * ++ * @param d Generic descriptor structure. ++ * @return Pointer to the mpeg_ibp_descriptor structure, or NULL on error. ++ */ ++static inline struct mpeg_ibp_descriptor* ++ mpeg_ibp_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct mpeg_ibp_descriptor) - 2)) ++ return NULL; ++ ++ bswap16((uint8_t*) d + 2); ++ ++ return (struct mpeg_ibp_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/iod_descriptor.h dvb-apps/lib/libucsi/mpeg/iod_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/iod_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/iod_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,87 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_IOD_DESCRIPTOR ++#define _UCSI_MPEG_IOD_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_iod_descriptor structure. ++ */ ++struct mpeg_iod_descriptor { ++ struct descriptor d; ++ ++ uint8_t scope_of_iod_label; ++ uint8_t iod_label; ++ /* uint8_t iod[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_iod_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return Pointer to an mpeg_iod_descriptor structure, or NULL on error. ++ */ ++static inline struct mpeg_iod_descriptor* ++ mpeg_iod_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len < (sizeof(struct mpeg_iod_descriptor) - 2)) ++ return NULL; ++ ++ return (struct mpeg_iod_descriptor*) d; ++} ++ ++/** ++ * Retrieve pointer to iod field of an mpeg_iod_descriptor structure. ++ * ++ * @param d Pointer to mpeg_iod_descriptor structure. ++ * @return Pointer to the iod field. ++ */ ++static inline uint8_t * ++ mpeg_iod_descriptor_iod(struct mpeg_iod_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct mpeg_iod_descriptor); ++} ++ ++/** ++ * Calculate the length of the iod field of an mpeg_iod_descriptor structure. ++ * ++ * @param d Pointer to mpeg_iod_descriptor structure. ++ * @return The number of bytes. ++ */ ++static inline int ++ mpeg_iod_descriptor_iod_length(struct mpeg_iod_descriptor *d) ++{ ++ return d->d.len - 2; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/iso_639_language_descriptor.h dvb-apps/lib/libucsi/mpeg/iso_639_language_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/iso_639_language_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/iso_639_language_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,124 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_ISO_639_LANGUAGE_DESCRIPTOR ++#define _UCSI_MPEG_ISO_639_LANGUAGE_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++ ++/** ++ * Possible values for audio_type. ++ */ ++enum { ++ MPEG_AUDIO_TYPE_CLEAN_EFFECTS = 0x01, ++ MPEG_AUDIO_TYPE_HEARING_IMPAIRED = 0x02, ++ MPEG_AUDIO_TYPE_VISUAL_IMPAIRED_COMMENTARY = 0x03, ++}; ++ ++/** ++ * mpeg_iso_639_language_descriptor structure. ++ */ ++struct mpeg_iso_639_language_descriptor { ++ struct descriptor d; ++ ++ /* struct mpeg_iso_639_language_code languages[] */ ++} __ucsi_packed; ++ ++/** ++ * An entry in the mpeg_iso_639_language_descriptor languages field. ++ */ ++struct mpeg_iso_639_language_code { ++ iso639lang_t language_code; ++ uint8_t audio_type; ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_iso_639_language_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return Pointer to an mpeg_iso_639_language_descriptor structure, or NULL ++ * on error. ++ */ ++static inline struct mpeg_iso_639_language_descriptor* ++ mpeg_iso_639_language_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len % sizeof(struct mpeg_iso_639_language_code)) ++ return NULL; ++ ++ return (struct mpeg_iso_639_language_descriptor*) d; ++} ++ ++/** ++ * Convenience iterator for the languages field of an mpeg_iso_639_language_descriptor ++ * ++ * @param d Pointer to the mpeg_iso_639_language_descriptor structure. ++ * @param pos Variable holding a pointer to the current entry. ++ */ ++#define mpeg_iso_639_language_descriptor_languages_for_each(_d, _pos) \ ++ for ((_pos) = mpeg_iso_639_language_descriptor_languages_first(_d); \ ++ (_pos); \ ++ (_pos) = mpeg_iso_639_language_descriptor_languages_next(_d, _pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct mpeg_iso_639_language_code* ++ mpeg_iso_639_language_descriptor_languages_first(struct mpeg_iso_639_language_descriptor *d) ++{ ++ if (d->d.len < sizeof(struct mpeg_iso_639_language_code)) ++ return NULL; ++ ++ return (struct mpeg_iso_639_language_code *) ++ ((uint8_t*) d + sizeof(struct mpeg_iso_639_language_descriptor)); ++} ++ ++static inline struct mpeg_iso_639_language_code* ++ mpeg_iso_639_language_descriptor_languages_next(struct mpeg_iso_639_language_descriptor *d, ++ struct mpeg_iso_639_language_code *pos) ++{ ++ uint8_t *end = (uint8_t*) d + 2 + d->d.len; ++ uint8_t *next = (uint8_t *) pos + sizeof(struct mpeg_iso_639_language_code); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct mpeg_iso_639_language_code *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/Makefile dvb-apps/lib/libucsi/mpeg/Makefile +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,66 @@ ++# Makefile for linuxtv.org dvb-apps/lib/libucsi/mpeg ++ ++.PHONY: sub-error-mpeg ++ ++sub-error-mpeg: ++ $(error You can't use this makefile directly.) ++ ++ifneq ($(lib_name),) ++ ++objects += mpeg/cat_section.o \ ++ mpeg/metadata_section.o \ ++ mpeg/odsmt_section.o \ ++ mpeg/pat_section.o \ ++ mpeg/pmt_section.o \ ++ mpeg/tsdt_section.o ++ ++sub-install += mpeg ++ ++else ++ ++includes = audio_stream_descriptor.h \ ++ ca_descriptor.h \ ++ cat_section.h \ ++ content_labelling_descriptor.h \ ++ copyright_descriptor.h \ ++ data_stream_alignment_descriptor.h \ ++ datagram_section.h \ ++ descriptor.h \ ++ external_es_id_descriptor.h \ ++ fmc_descriptor.h \ ++ fmxbuffer_size_descriptor.h \ ++ hierarchy_descriptor.h \ ++ ibp_descriptor.h \ ++ iod_descriptor.h \ ++ iso_639_language_descriptor.h \ ++ maximum_bitrate_descriptor.h \ ++ metadata_descriptor.h \ ++ metadata_pointer_descriptor.h \ ++ metadata_section.h \ ++ metadata_std_descriptor.h \ ++ mpeg4_audio_descriptor.h \ ++ mpeg4_video_descriptor.h \ ++ multiplex_buffer_descriptor.h \ ++ multiplex_buffer_utilization_descriptor.h \ ++ muxcode_descriptor.h \ ++ odsmt_section.h \ ++ pat_section.h \ ++ pmt_section.h \ ++ private_data_indicator_descriptor.h \ ++ registration_descriptor.h \ ++ section.h \ ++ sl_descriptor.h \ ++ smoothing_buffer_descriptor.h \ ++ std_descriptor.h \ ++ system_clock_descriptor.h \ ++ target_background_grid_descriptor.h \ ++ tsdt_section.h \ ++ types.h \ ++ video_stream_descriptor.h \ ++ video_window_descriptor.h ++ ++include ../../../Make.rules ++ ++lib_name = libucsi/mpeg ++ ++endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/maximum_bitrate_descriptor.h dvb-apps/lib/libucsi/mpeg/maximum_bitrate_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/maximum_bitrate_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/maximum_bitrate_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,64 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_MAXIMUM_BITRATE_DESCRIPTOR ++#define _UCSI_MPEG_MAXIMUM_BITRATE_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_maximum_bitrate_descriptor structure. ++ */ ++struct mpeg_maximum_bitrate_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint32_t reserved : 2; , ++ uint32_t maximum_bitrate : 22; ); ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_maximum_bitrate_descriptor. ++ * ++ * @param d Pointer to generic descriptor structure. ++ * @return Pointer to mpeg_maximum_bitrate_descriptor, or NULL on error. ++ */ ++static inline struct mpeg_maximum_bitrate_descriptor* ++ mpeg_maximum_bitrate_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct mpeg_maximum_bitrate_descriptor) - 2)) ++ return NULL; ++ ++ bswap24((uint8_t*) d + 2); ++ ++ return (struct mpeg_maximum_bitrate_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/metadata_descriptor.h dvb-apps/lib/libucsi/mpeg/metadata_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/metadata_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/metadata_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,472 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_METADATA_DESCRIPTOR ++#define _UCSI_MPEG_METADATA_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * Values for the decoder_config_flags field. ++ */ ++enum { ++ MPEG_DECODER_CONFIG_NONE = 0x00, ++ MPEG_DECODER_CONFIG_IN_DECODER_CONFIG = 0x01, ++ MPEG_DECODER_CONFIG_SAME_METADATA_SERVICE = 0x02, ++ MPEG_DECODER_CONFIG_DSMCC = 0x03, ++ MPEG_DECODER_CONFIG_SAME_PROGRAM = 0x04, ++}; ++ ++/** ++ * mpeg_metadata_descriptor structure. ++ */ ++struct mpeg_metadata_descriptor { ++ struct descriptor d; ++ ++ uint16_t metadata_application_format; ++ /* struct mpeg_metadata_descriptor_application_format_identifier appid */ ++ /* uint8_t metadata_format */ ++ /* struct mpeg_metadata_descriptor_format_identifier formid */ ++ /* struct mpeg_metadata_descriptor_flags flags */ ++ /* struct mpeg_metadata_descriptor_service_identifier service_identifier */ ++ /* struct mpeg_metadata_descriptor_decoder_config decoder_config */ ++ /* struct mpeg_metadata_descriptor_decoder_config_id_record decoder_config_id_record */ ++ /* struct mpeg_metadata_descriptor_decoder_config_service_id decoder_config_service_id */ ++ /* struct mpeg_metadata_descriptor_decoder_config_reserved decoder_config_reserved */ ++ /* uint8_t private_data[] */ ++} __ucsi_packed; ++ ++/** ++ * appid field of a metadata_descriptor. ++ */ ++struct mpeg_metadata_descriptor_application_format_identifier { ++ uint32_t id; ++} __ucsi_packed; ++ ++/** ++ * formid field of a metadata_descriptor. ++ */ ++struct mpeg_metadata_descriptor_format_identifier { ++ uint32_t id; ++} __ucsi_packed; ++ ++/** ++ * Flags field of a metadata_descriptor ++ */ ++struct mpeg_metadata_descriptor_flags { ++ uint8_t metadata_service_id; ++ EBIT3(uint8_t decoder_config_flags : 3; , ++ uint8_t dsm_cc_flag : 1; , ++ uint8_t reserved : 4; ); ++} __ucsi_packed; ++ ++/** ++ * service_identifier field of a metadata_descriptor. ++ */ ++struct mpeg_metadata_descriptor_service_identifier { ++ uint8_t service_identification_length; ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++/** ++ * decoder_config field of a metadata_descriptor. ++ */ ++struct mpeg_metadata_descriptor_decoder_config { ++ uint8_t decoder_config_length; ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++/** ++ * decoder_config_id_record field of a metadata_descriptor. ++ */ ++struct mpeg_metadata_descriptor_decoder_config_id_record { ++ uint8_t decoder_config_id_record_length; ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++/** ++ * decoder_config_service_id field of a metadata_descriptor. ++ */ ++struct mpeg_metadata_descriptor_decoder_config_service_id { ++ uint8_t decoder_config_metadata_service_id; ++} __ucsi_packed; ++ ++/** ++ * decoder_config_reserved field of a metadata_descriptor. ++ */ ++struct mpeg_metadata_descriptor_decoder_config_reserved { ++ uint8_t reserved_data_length; ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++ ++ ++ ++/** ++ * Process an mpeg_metadata_descriptor. ++ * ++ * @param d Generic descriptor. ++ * @return Pointer to an mpeg_metadata_descriptor, or NULL on error. ++ */ ++static inline struct mpeg_metadata_descriptor* ++ mpeg_metadata_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t pos = 2; ++ uint8_t *buf = (uint8_t*) d; ++ uint32_t len = d->len + 2; ++ struct mpeg_metadata_descriptor_flags *flags; ++ int id; ++ ++ if (len < sizeof(struct mpeg_metadata_descriptor)) ++ return NULL; ++ ++ bswap16(buf + pos); ++ id = *((uint16_t*) (buf+pos)); ++ pos += 2; ++ ++ if (id == 0xffff) { ++ if (len < (pos+4)) ++ return NULL; ++ bswap32(buf+pos); ++ pos += 4; ++ } ++ ++ if (len < (pos+1)) ++ return NULL; ++ ++ id = buf[pos]; ++ pos++; ++ if (id == 0xff) { ++ if (len < (pos+4)) ++ return NULL; ++ bswap32(buf+pos); ++ pos += 4; ++ } ++ ++ if (len < (pos + sizeof(struct mpeg_metadata_descriptor_flags))) ++ return NULL; ++ flags = (struct mpeg_metadata_descriptor_flags*) (buf+pos); ++ pos += sizeof(struct mpeg_metadata_descriptor_flags); ++ ++ if (flags->dsm_cc_flag == 1) { ++ if (len < (pos+1)) ++ return NULL; ++ if (len < (pos+1+buf[pos])) ++ return NULL; ++ pos += 1 + buf[pos]; ++ } ++ ++ if (flags->decoder_config_flags == 1) { ++ if (len < (pos+1)) ++ return NULL; ++ if (len < (pos+1+buf[pos])) ++ return NULL; ++ pos += 1 + buf[pos]; ++ } ++ ++ if (flags->decoder_config_flags == 3) { ++ if (len < (pos+1)) ++ return NULL; ++ if (len < (pos+1+buf[pos])) ++ return NULL; ++ pos += 1 + buf[pos]; ++ } ++ ++ if (flags->decoder_config_flags == 4) { ++ if (len < (pos+1)) ++ return NULL; ++ pos++; ++ } ++ ++ if ((flags->decoder_config_flags == 5) || ++ (flags->decoder_config_flags == 6)) { ++ if (len < (pos+1)) ++ return NULL; ++ if (len < (pos+1+buf[pos])) ++ return NULL; ++ pos += 1 + buf[pos]; ++ } ++ ++ if (len < pos) ++ return NULL; ++ ++ return (struct mpeg_metadata_descriptor*) d; ++} ++ ++/** ++ * Accessor for pointer to appid field of an mpeg_metadata_descriptor. ++ * ++ * @param d The mpeg_metadata_descriptor structure. ++ * @return The pointer, or NULL on error. ++ */ ++static inline struct mpeg_metadata_descriptor_application_format_identifier* ++ mpeg_metadata_descriptor_appid(struct mpeg_metadata_descriptor *d) ++{ ++ uint8_t *buf = (uint8_t*) d + sizeof(struct mpeg_metadata_descriptor); ++ ++ if (d->metadata_application_format != 0xffff) ++ return NULL; ++ return (struct mpeg_metadata_descriptor_application_format_identifier*) buf; ++} ++ ++/** ++ * Accessor for metadata_format field of an mpeg_metadata_descriptor. ++ * ++ * @param d The mpeg_metadata_descriptor structure. ++ * @return The pointer, or NULL on error. ++ */ ++static inline uint8_t ++ mpeg_metadata_descriptor_metadata_format(struct mpeg_metadata_descriptor *d) ++{ ++ uint8_t *buf = (uint8_t*) d + sizeof(struct mpeg_metadata_descriptor); ++ ++ if (d->metadata_application_format == 0xffff) ++ buf+=4; ++ return *buf; ++} ++ ++/** ++ * Accessor for pointer to formid field of an mpeg_metadata_descriptor. ++ * ++ * @param d The mpeg_metadata_descriptor structure. ++ * @return The pointer, or NULL on error. ++ */ ++static inline struct mpeg_metadata_descriptor_format_identifier* ++ mpeg_metadata_descriptor_formid(struct mpeg_metadata_descriptor *d) ++{ ++ uint8_t *buf = (uint8_t*) d + sizeof(struct mpeg_metadata_descriptor); ++ ++ if (d->metadata_application_format == 0xffff) ++ buf+=4; ++ if (*buf != 0xff) ++ return NULL; ++ ++ return (struct mpeg_metadata_descriptor_format_identifier*) (buf+1); ++} ++ ++/** ++ * Accessor for flags field of an mpeg_metadata_descriptor. ++ * ++ * @param d The mpeg_metadata_descriptor structure. ++ * @return Pointer to the field, or NULL on error. ++ */ ++static inline struct mpeg_metadata_descriptor_flags* ++ mpeg_metadata_descriptor_flags(struct mpeg_metadata_descriptor *d) ++{ ++ uint8_t *buf = (uint8_t*) d + sizeof(struct mpeg_metadata_descriptor); ++ ++ if (d->metadata_application_format == 0xffff) ++ buf+=4; ++ if (*buf == 0xff) ++ buf+=4; ++ ++ return (struct mpeg_metadata_descriptor_flags*) buf; ++} ++ ++ ++/** ++ * Accessor for service_identifier field of an mpeg_metadata_descriptor. ++ * ++ * @param flags Pointer to the mpeg_metadata_descriptor_flags. ++ * @return Pointer to the field, or NULL on error. ++ */ ++static inline struct mpeg_metadata_descriptor_service_identifier* ++ mpeg_metadata_descriptor_sevice_identifier(struct mpeg_metadata_descriptor_flags *flags) ++{ ++ uint8_t *buf = (uint8_t*) flags + sizeof(struct mpeg_metadata_descriptor_flags); ++ ++ if (flags->dsm_cc_flag!=1) ++ return NULL; ++ ++ return (struct mpeg_metadata_descriptor_service_identifier *) buf; ++} ++ ++/** ++ * Accessor for data field of an mpeg_metadata_descriptor_service_identifier. ++ * ++ * @param d The mpeg_metadata_descriptor_service_identifier structure. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t* ++ mpeg_metadata_descriptor_service_identifier_data(struct mpeg_metadata_descriptor_service_identifier *d) ++{ ++ return (uint8_t*) d + sizeof(struct mpeg_metadata_descriptor_service_identifier); ++} ++ ++/** ++ * Accessor for decoder_config field of an mpeg_metadata_descriptor. ++ * ++ * @param flags Pointer to the mpeg_metadata_descriptor_flags. ++ * @return Pointer to the field, or NULL on error. ++ */ ++static inline struct mpeg_metadata_descriptor_decoder_config* ++ mpeg_metadata_descriptor_decoder_config(struct mpeg_metadata_descriptor_flags *flags) ++{ ++ uint8_t *buf = (uint8_t*) flags + sizeof(struct mpeg_metadata_descriptor_flags); ++ ++ if (flags->decoder_config_flags != 1) ++ return NULL; ++ ++ if (flags->dsm_cc_flag==1) ++ buf += 1 + buf[1]; ++ ++ return (struct mpeg_metadata_descriptor_decoder_config*) buf; ++} ++ ++/** ++ * Accessor for data field of an mpeg_metadata_descriptor_service_identifier. ++ * ++ * @param d The mpeg_metadata_descriptor_service_identifier structure. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t* ++ mpeg_metadata_descriptor_decoder_config_data(struct mpeg_metadata_descriptor_decoder_config *d) ++{ ++ return (uint8_t*) d + sizeof(struct mpeg_metadata_descriptor_decoder_config); ++} ++ ++/** ++ * Accessor for decoder_config_id_record field of an mpeg_metadata_descriptor. ++ * ++ * @param flags Pointer to the mpeg_metadata_descriptor_flags. ++ * @return Pointer to the field, or NULL on error. ++ */ ++static inline struct mpeg_metadata_descriptor_decoder_config_id_record* ++ mpeg_metadata_descriptor_decoder_config_id_record(struct mpeg_metadata_descriptor_flags *flags) ++{ ++ uint8_t *buf = (uint8_t*) flags + sizeof(struct mpeg_metadata_descriptor_flags); ++ ++ if (flags->decoder_config_flags != 3) ++ return NULL; ++ ++ if (flags->dsm_cc_flag==1) ++ buf += 1 + buf[1]; ++ ++ return (struct mpeg_metadata_descriptor_decoder_config_id_record *) buf; ++} ++ ++/** ++ * Accessor for data field of an mpeg_metadata_descriptor_decoder_config_id_record. ++ * ++ * @param d The mpeg_metadata_descriptor_decoder_config_id_record structure. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t* ++ mpeg_metadata_descriptor_decoder_config_id_record_data(struct mpeg_metadata_descriptor_decoder_config_id_record *d) ++{ ++ return (uint8_t*) d + sizeof(struct mpeg_metadata_descriptor_decoder_config_id_record); ++} ++ ++/** ++ * Accessor for decoder_config_service_id field of an mpeg_metadata_descriptor. ++ * ++ * @param flags Pointer to the mpeg_metadata_descriptor_flags. ++ * @return Pointer to the field, or NULL on error. ++ */ ++static inline struct mpeg_metadata_descriptor_decoder_config_service_id* ++ mpeg_metadata_descriptor_decoder_config_service_id(struct mpeg_metadata_descriptor_flags *flags) ++{ ++ uint8_t *buf = (uint8_t*) flags + sizeof(struct mpeg_metadata_descriptor_flags); ++ ++ if (flags->decoder_config_flags != 4) ++ return NULL; ++ ++ if (flags->dsm_cc_flag==1) ++ buf += 1 + buf[1]; ++ ++ return (struct mpeg_metadata_descriptor_decoder_config_service_id *) buf; ++} ++ ++/** ++ * Accessor for decoder_config_reserved field of an mpeg_metadata_descriptor. ++ * ++ * @param flags Pointer to the mpeg_metadata_descriptor_flags. ++ * @return Pointer to the field, or NULL on error. ++ */ ++static inline struct mpeg_metadata_descriptor_decoder_config_reserved* ++ mpeg_metadata_descriptor_decoder_config_reserved(struct mpeg_metadata_descriptor_flags *flags) ++{ ++ uint8_t *buf = (uint8_t*) flags + sizeof(struct mpeg_metadata_descriptor_flags); ++ ++ if ((flags->decoder_config_flags != 5) && (flags->decoder_config_flags != 6)) ++ return NULL; ++ ++ if (flags->dsm_cc_flag==1) ++ buf += 1 + buf[1]; ++ ++ return (struct mpeg_metadata_descriptor_decoder_config_reserved *) buf; ++} ++ ++/** ++ * Accessor for data field of an mpeg_metadata_descriptor_decoder_config_reserved. ++ * ++ * @param d The mpeg_metadata_descriptor_decoder_config_reserved structure. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t* ++ mpeg_metadata_descriptor_decoder_config_reserved_data(struct mpeg_metadata_descriptor_decoder_config_reserved *d) ++{ ++ return (uint8_t*) d + sizeof(struct mpeg_metadata_descriptor_decoder_config_reserved); ++} ++ ++/** ++ * Accessor for private_data field of an mpeg_metadata_descriptor. ++ * ++ * @param d The mpeg_metadata_descriptor structure. ++ * @param flags Pointer to the mpeg_metadata_descriptor_flags. ++ * @param length Where the number of bytes in the field should be stored. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t* ++ mpeg_metadata_descriptor_private_data(struct mpeg_metadata_descriptor *d, ++ struct mpeg_metadata_descriptor_flags *flags, ++ int *length) ++{ ++ uint8_t *buf = (uint8_t*) flags + sizeof(struct mpeg_metadata_descriptor_flags); ++ uint8_t *end = (uint8_t*) d + d->d.len + 2; ++ ++ ++ if (flags->dsm_cc_flag==1) ++ buf += 1 + buf[1]; ++ if (flags->decoder_config_flags==1) ++ buf += 1 + buf[1]; ++ if (flags->decoder_config_flags==3) ++ buf += 1 + buf[1]; ++ if (flags->decoder_config_flags==4) ++ buf++; ++ if ((flags->decoder_config_flags==5)||(flags->decoder_config_flags==6)) ++ buf += 1 + buf[1]; ++ ++ *length = end - buf; ++ return buf; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/metadata_pointer_descriptor.h dvb-apps/lib/libucsi/mpeg/metadata_pointer_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/metadata_pointer_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/metadata_pointer_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,360 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_METADATA_POINTER_DESCRIPTOR ++#define _UCSI_MPEG_METADATA_POINTER_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * Possible values for the mpeg_carriage_flags field. ++ */ ++enum { ++ MPEG_CARRIAGE_SAME_TS = 0x00, ++ MPEG_CARRIAGE_DIFFERENT_TS = 0x01, ++ MPEG_CARRIAGE_PS = 0x02, ++ MPEG_CARRIAGE_OTHER = 0x03, ++}; ++ ++/** ++ * mpeg_metadata_pointer_descriptor structure. ++ */ ++struct mpeg_metadata_pointer_descriptor { ++ struct descriptor d; ++ ++ uint16_t metadata_application_format; ++ /* struct mpeg_metadata_pointer_descriptor_application_format_identifier appid */ ++ /* uint8_t metadata_format */ ++ /* struct mpeg_metadata_pointer_descriptor_format_identifier formid */ ++ /* struct mpeg_metadata_pointer_descriptor_flags flags */ ++ /* struct mpeg_metadata_pointer_descriptor_locator locator */ ++ /* struct mpeg_metadata_pointer_descriptor_program_number program_number */ ++ /* struct mpeg_metadata_pointer_descriptor_carriage carriage */ ++ /* uint8_t private_data[] */ ++} __ucsi_packed; ++ ++/** ++ * appid field of a metadata_pointer_descriptor. ++ */ ++struct mpeg_metadata_pointer_descriptor_application_format_identifier { ++ uint32_t id; ++} __ucsi_packed; ++ ++/** ++ * formid field of a metadata_pointer_descriptor. ++ */ ++struct mpeg_metadata_pointer_descriptor_format_identifier { ++ uint32_t id; ++} __ucsi_packed; ++ ++/** ++ * Flags field of a metadata_pointer_descriptor ++ */ ++struct mpeg_metadata_pointer_descriptor_flags { ++ uint8_t metadata_service_id; ++ EBIT3(uint8_t metadata_locator_record_flag : 1; , ++ uint8_t mpeg_carriage_flags : 2; , ++ uint8_t reserved : 5; ); ++} __ucsi_packed; ++ ++/** ++ * Reference_id field of a metadata_pointer_descriptor. ++ */ ++struct mpeg_metadata_pointer_descriptor_locator { ++ uint8_t metadata_locator_record_length; ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++/** ++ * program_number field of a metadata_pointer_descriptor. ++ */ ++struct mpeg_metadata_pointer_descriptor_program_number { ++ uint16_t number; ++} __ucsi_packed; ++ ++/** ++ * carriage field of a metadata_pointer_descriptor. ++ */ ++struct mpeg_metadata_pointer_descriptor_carriage { ++ uint16_t transport_stream_location; ++ uint16_t transport_stream_id; ++} __ucsi_packed; ++ ++ ++ ++ ++/** ++ * Process an mpeg_metadata_pointer_descriptor. ++ * ++ * @param d Generic descriptor. ++ * @return Pointer to an mpeg_metadata_pointer_descriptor, or NULL on error. ++ */ ++static inline struct mpeg_metadata_pointer_descriptor* ++ mpeg_metadata_pointer_descriptor_codec(struct descriptor* d) ++{ ++ uint32_t pos = 2; ++ uint8_t *buf = (uint8_t*) d; ++ uint32_t len = d->len + 2; ++ struct mpeg_metadata_pointer_descriptor_flags *flags; ++ int id; ++ ++ if (len < sizeof(struct mpeg_metadata_pointer_descriptor)) ++ return NULL; ++ ++ bswap16(buf + pos); ++ id = *((uint16_t*) (buf+pos)); ++ pos += 2; ++ ++ if (id == 0xffff) { ++ if (len < (pos+4)) ++ return NULL; ++ bswap32(buf+pos); ++ pos += 4; ++ } ++ ++ if (len < (pos+1)) ++ return NULL; ++ ++ id = buf[pos]; ++ pos++; ++ if (id == 0xff) { ++ if (len < (pos+4)) ++ return NULL; ++ bswap32(buf+pos); ++ pos += 4; ++ } ++ ++ if (len < (pos + sizeof(struct mpeg_metadata_pointer_descriptor_flags))) ++ return NULL; ++ flags = (struct mpeg_metadata_pointer_descriptor_flags*) (buf+pos); ++ pos += sizeof(struct mpeg_metadata_pointer_descriptor_flags); ++ ++ if (flags->metadata_locator_record_flag == 1) { ++ if (len < (pos+1)) ++ return NULL; ++ if (len < (pos+1+buf[pos])) ++ return NULL; ++ pos += 1 + buf[pos]; ++ } ++ ++ if (flags->mpeg_carriage_flags < 3) { ++ if (len < (pos + 2)) ++ return NULL; ++ bswap16(buf+pos); ++ pos += 2; ++ } ++ ++ if (flags->mpeg_carriage_flags == 1) { ++ if (len < (pos + 4)) ++ return NULL; ++ bswap16(buf+pos); ++ bswap16(buf+pos+2); ++ pos += 4; ++ } ++ ++ if (len < pos) ++ return NULL; ++ ++ return (struct mpeg_metadata_pointer_descriptor*) d; ++} ++ ++/** ++ * Accessor for pointer to appid field of an mpeg_metadata_pointer_descriptor. ++ * ++ * @param d The mpeg_metadata_pointer_descriptor structure. ++ * @return The pointer, or NULL on error. ++ */ ++static inline struct mpeg_metadata_pointer_descriptor_application_format_identifier* ++ mpeg_metadata_pointer_descriptor_appid(struct mpeg_metadata_pointer_descriptor *d) ++{ ++ uint8_t *buf = (uint8_t*) d + sizeof(struct mpeg_metadata_pointer_descriptor); ++ ++ if (d->metadata_application_format != 0xffff) ++ return NULL; ++ return (struct mpeg_metadata_pointer_descriptor_application_format_identifier*) buf; ++} ++ ++/** ++ * Accessor for metadata_format field of an mpeg_metadata_pointer_descriptor. ++ * ++ * @param d The mpeg_metadata_pointer_descriptor structure. ++ * @return The pointer, or NULL on error. ++ */ ++static inline uint8_t ++ mpeg_metadata_pointer_descriptor_metadata_format(struct mpeg_metadata_pointer_descriptor *d) ++{ ++ uint8_t *buf = (uint8_t*) d + sizeof(struct mpeg_metadata_pointer_descriptor); ++ ++ if (d->metadata_application_format == 0xffff) ++ buf+=4; ++ return *buf; ++} ++ ++/** ++ * Accessor for pointer to formid field of an mpeg_metadata_pointer_descriptor. ++ * ++ * @param d The mpeg_metadata_pointer_descriptor structure. ++ * @return The pointer, or NULL on error. ++ */ ++static inline struct mpeg_metadata_pointer_descriptor_format_identifier* ++ mpeg_metadata_pointer_descriptor_formid(struct mpeg_metadata_pointer_descriptor *d) ++{ ++ uint8_t *buf = (uint8_t*) d + sizeof(struct mpeg_metadata_pointer_descriptor); ++ ++ if (d->metadata_application_format == 0xffff) ++ buf+=4; ++ if (*buf != 0xff) ++ return NULL; ++ ++ return (struct mpeg_metadata_pointer_descriptor_format_identifier*) (buf+1); ++} ++ ++/** ++ * Accessor for flags field of an mpeg_metadata_pointer_descriptor. ++ * ++ * @param d The mpeg_metadata_pointer_descriptor structure. ++ * @return Pointer to the field, or NULL on error. ++ */ ++static inline struct mpeg_metadata_pointer_descriptor_flags* ++ mpeg_metadata_pointer_descriptor_flags(struct mpeg_metadata_pointer_descriptor *d) ++{ ++ uint8_t *buf = (uint8_t*) d + sizeof(struct mpeg_metadata_pointer_descriptor); ++ ++ if (d->metadata_application_format == 0xffff) ++ buf+=4; ++ if (*buf == 0xff) ++ buf+=4; ++ ++ return (struct mpeg_metadata_pointer_descriptor_flags*) buf; ++} ++ ++ ++/** ++ * Accessor for locator field of an mpeg_metadata_pointer_descriptor. ++ * ++ * @param flags Pointer to the mpeg_metadata_pointer_descriptor_flags. ++ * @return Pointer to the field, or NULL on error. ++ */ ++static inline struct mpeg_metadata_pointer_descriptor_locator* ++ mpeg_metadata_pointer_descriptor_locator(struct mpeg_metadata_pointer_descriptor_flags *flags) ++{ ++ uint8_t *buf = (uint8_t*) flags + sizeof(struct mpeg_metadata_pointer_descriptor_flags); ++ ++ if (flags->metadata_locator_record_flag!=1) ++ return NULL; ++ ++ return (struct mpeg_metadata_pointer_descriptor_locator *) buf; ++} ++ ++/** ++ * Accessor for data field of an mpeg_metadata_pointer_descriptor_locator. ++ * ++ * @param d The mpeg_metadata_pointer_descriptor_locator structure. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t* ++ mpeg_metadata_pointer_descriptor_locator_data(struct mpeg_metadata_pointer_descriptor_locator *d) ++{ ++ return (uint8_t*) d + sizeof(struct mpeg_metadata_pointer_descriptor_locator); ++} ++ ++ ++/** ++ * Accessor for program_number field of an mpeg_metadata_pointer_descriptor. ++ * ++ * @param flags Pointer to the mpeg_metadata_pointer_descriptor_flags. ++ * @return Pointer to the field, or NULL on error. ++ */ ++static inline struct mpeg_metadata_pointer_descriptor_program_number* ++ mpeg_metadata_pointer_descriptor_program_number(struct mpeg_metadata_pointer_descriptor_flags *flags) ++{ ++ uint8_t *buf = (uint8_t*) flags + sizeof(struct mpeg_metadata_pointer_descriptor_flags); ++ ++ if (flags->mpeg_carriage_flags < 3) ++ return NULL; ++ ++ if (flags->metadata_locator_record_flag==1) ++ buf += 1 + buf[1]; ++ ++ return (struct mpeg_metadata_pointer_descriptor_program_number*) buf; ++} ++ ++/** ++ * Accessor for carriage field of an mpeg_metadata_pointer_descriptor. ++ * ++ * @param flags Pointer to the mpeg_metadata_pointer_descriptor_flags. ++ * @return Pointer to the field, or NULL on error. ++ */ ++static inline struct mpeg_metadata_pointer_descriptor_carriage* ++ mpeg_metadata_pointer_descriptor_carriage(struct mpeg_metadata_pointer_descriptor_flags *flags) ++{ ++ uint8_t *buf = (uint8_t*) flags + sizeof(struct mpeg_metadata_pointer_descriptor_flags); ++ ++ if (flags->mpeg_carriage_flags != 1) ++ return NULL; ++ ++ if (flags->metadata_locator_record_flag==1) ++ buf += 1 + buf[1]; ++ if (flags->mpeg_carriage_flags < 3) ++ buf += sizeof(struct mpeg_metadata_pointer_descriptor_program_number); ++ ++ return (struct mpeg_metadata_pointer_descriptor_carriage *) buf; ++} ++ ++/** ++ * Accessor for private_data field of an mpeg_metadata_pointer_descriptor. ++ * ++ * @param d The mpeg_metadata_pointer_descriptor structure. ++ * @param flags Pointer to the mpeg_metadata_pointer_descriptor_flags. ++ * @param length Where the number of bytes in the field should be stored. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t* ++ mpeg_metadata_pointer_descriptor_private_data(struct mpeg_metadata_pointer_descriptor *d, ++ struct mpeg_metadata_pointer_descriptor_flags *flags, ++ int *length) ++{ ++ uint8_t *buf = (uint8_t*) flags + sizeof(struct mpeg_metadata_pointer_descriptor_flags); ++ uint8_t *end = (uint8_t*) d + d->d.len + 2; ++ ++ ++ if (flags->metadata_locator_record_flag==1) ++ buf += 1 + buf[1]; ++ if (flags->mpeg_carriage_flags < 3) ++ buf += sizeof(struct mpeg_metadata_pointer_descriptor_program_number); ++ if (flags->mpeg_carriage_flags != 1) ++ buf += sizeof(struct mpeg_metadata_pointer_descriptor_carriage); ++ ++ *length = end - buf; ++ return buf; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/metadata_section.c dvb-apps/lib/libucsi/mpeg/metadata_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/metadata_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/metadata_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,27 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct mpeg_metadata_section * mpeg_metadata_section_codec(struct section_ext * ext) ++{ ++ return (struct mpeg_metadata_section *)ext; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/metadata_section.h dvb-apps/lib/libucsi/mpeg/metadata_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/metadata_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/metadata_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,122 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_METADATA_SECTION_H ++#define _UCSI_MPEG_METADATA_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * mpeg_metadata_section structure. ++ */ ++struct mpeg_metadata_section { ++ struct section_ext head; ++ ++ /* uint8_t data[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_metadata_section structure. ++ * ++ * @param section Pointer to the section_ext structure. ++ * @return Pointer to the mpeg_metadata_section structure, or NULL on error. ++ */ ++extern struct mpeg_metadata_section *mpeg_metadata_section_codec(struct section_ext *section); ++ ++/** ++ * Accessor for the random_access_indicator field of a metadata section. ++ * ++ * @param metadata metadata section pointer. ++ * @return The random_access_indicator. ++ */ ++static inline uint8_t mpeg_metadata_section_random_access_indicator(struct mpeg_metadata_section *metadata) ++{ ++ return metadata->head.reserved >> 1; ++} ++ ++/** ++ * Accessor for the decoder_config_flag field of a metadata section. ++ * ++ * @param metadata metadata section pointer. ++ * @return The decoder_config_flag. ++ */ ++static inline uint8_t mpeg_metadata_section_decoder_config_flag(struct mpeg_metadata_section *metadata) ++{ ++ return metadata->head.reserved & 1; ++} ++ ++/** ++ * Accessor for the fragment_indicator field of a metadata section. ++ * ++ * @param metadata metadata section pointer. ++ * @return The fragment_indicator. ++ */ ++static inline uint8_t mpeg_metadata_section_fragment_indicator(struct mpeg_metadata_section *metadata) ++{ ++ return metadata->head.reserved1; ++} ++ ++/** ++ * Accessor for the service_id field of a metadata section. ++ * ++ * @param metadata metadata section pointer. ++ * @return The service_id. ++ */ ++static inline uint16_t mpeg_metadata_section_service_id(struct mpeg_metadata_section *metadata) ++{ ++ return metadata->head.table_id_ext >> 8; ++} ++ ++/** ++ * Retrieve pointer to data field of an mpeg_metadata_section. ++ * ++ * @param s mpeg_metadata_section pointer. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ mpeg_metadata_section_data(struct mpeg_metadata_section *s) ++{ ++ return (uint8_t *) s + sizeof(struct mpeg_metadata_section); ++} ++ ++ ++/** ++ * Determine length of the data field of an mpeg_copyright_descriptor. ++ * ++ * @param s mpeg_metadata_section_data pointer. ++ * @return Length of field in bytes. ++ */ ++static inline int ++ mpeg_metadata_section_data_length(struct mpeg_metadata_section *s) ++{ ++ return section_ext_length(&s->head) - sizeof(struct mpeg_metadata_section); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/metadata_std_descriptor.h dvb-apps/lib/libucsi/mpeg/metadata_std_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/metadata_std_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/metadata_std_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,72 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_METADATA_STD_DESCRIPTOR ++#define _UCSI_MPEG_METADATA_STD_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_metadata_std_descriptor structure. ++ */ ++struct mpeg_metadata_std_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint32_t reserved_1 : 2; , ++ uint32_t metadata_input_leak_rate :22; ); ++ EBIT2(uint32_t reserved_2 : 2; , ++ uint32_t metadata_buffer_size :22; ); ++ EBIT2(uint32_t reserved_3 : 2; , ++ uint32_t metadata_output_leak_rate :22; ); ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_metadata_std_descriptor. ++ * ++ * @param d Pointer to the generic descriptor structure. ++ * @return Pointer to the mpeg_metadata_std_descriptor, or NULL on error. ++ */ ++static inline struct mpeg_metadata_std_descriptor* ++ mpeg_metadata_std_descriptor_codec(struct descriptor* d) ++{ ++ uint8_t *buf = (uint8_t*) d; ++ ++ if (d->len != (sizeof(struct mpeg_metadata_std_descriptor) - 2)) ++ return NULL; ++ ++ bswap24(buf + 2); ++ bswap24(buf + 5); ++ bswap24(buf + 8); ++ ++ return (struct mpeg_metadata_std_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/mpeg4_audio_descriptor.h dvb-apps/lib/libucsi/mpeg/mpeg4_audio_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/mpeg4_audio_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/mpeg4_audio_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,61 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG4_AUDIO_DESCRIPTOR ++#define _UCSI_MPEG4_AUDIO_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg4_audio_descriptor structure. ++ */ ++struct mpeg4_audio_descriptor { ++ struct descriptor d; ++ ++ uint8_t mpeg4_audio_profile_and_level; ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg4_audio_descriptor. ++ * ++ * @param d Generic descriptor structure. ++ * @return Pointer to an mpeg4_audio_descriptor structure, or NULL on error. ++ */ ++static inline struct mpeg4_audio_descriptor* ++ mpeg4_audio_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct mpeg4_audio_descriptor) - 2)) ++ return NULL; ++ ++ return (struct mpeg4_audio_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/mpeg4_video_descriptor.h dvb-apps/lib/libucsi/mpeg/mpeg4_video_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/mpeg4_video_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/mpeg4_video_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,61 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG4_VIDEO_DESCRIPTOR ++#define _UCSI_MPEG4_VIDEO_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg4_video_descriptor structure. ++ */ ++struct mpeg4_video_descriptor { ++ struct descriptor d; ++ ++ uint8_t mpeg4_visual_profile_and_level; ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg4_video_descriptor structure. ++ * ++ * @param d Pointer to generic descriptor structure. ++ * @return Pointer to mpeg4_video_descriptor structure, or NULL on error. ++ */ ++static inline struct mpeg4_video_descriptor* ++ mpeg4_video_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct mpeg4_video_descriptor) - 2)) ++ return NULL; ++ ++ return (struct mpeg4_video_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/multiplex_buffer_descriptor.h dvb-apps/lib/libucsi/mpeg/multiplex_buffer_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/multiplex_buffer_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/multiplex_buffer_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,65 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_MULTIPLEX_BUFFER_DESCRIPTOR ++#define _UCSI_MPEG_MULTIPLEX_BUFFER_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_multiplex_buffer_descriptor descriptor. ++ */ ++struct mpeg_multiplex_buffer_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint64_t mb_buffer_size : 24; , ++ uint64_t tb_leak_rate : 24; ); ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_multiplex_buffer_descriptor. ++ * ++ * @param d Pointer to generic descriptor structure. ++ * @return Pointer to an mpeg_multiplex_buffer_descriptor structure, or NULL on ++ * error. ++ */ ++static inline struct mpeg_multiplex_buffer_descriptor* ++ mpeg_multiplex_buffer_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct mpeg_multiplex_buffer_descriptor) - 2)) ++ return NULL; ++ ++ bswap48((uint8_t*) d + 2); ++ ++ return (struct mpeg_multiplex_buffer_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/multiplex_buffer_utilization_descriptor.h dvb-apps/lib/libucsi/mpeg/multiplex_buffer_utilization_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/multiplex_buffer_utilization_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/multiplex_buffer_utilization_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,67 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_MULTIPLEX_BUFFER_UTILIZATION_DESCRIPTOR ++#define _UCSI_MPEG_MULTIPLEX_BUFFER_UTILIZATION_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_multiplex_buffer_utilization_descriptor structure. ++ */ ++struct mpeg_multiplex_buffer_utilization_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint16_t bound_valid_flag : 1; , ++ uint16_t ltw_offset_lower_bound : 15; ); ++ EBIT2(uint16_t reserved : 1; , ++ uint16_t ltw_offset_upper_bound : 15; ); ++} __ucsi_packed; ++ ++/** ++ * Process a mpeg_multiplex_buffer_utilization_descriptor. ++ * ++ * @param d Generic descriptor pointer. ++ * @return mpeg_multiplex_buffer_utilization_descriptor pointer, or NULL on error. ++ */ ++static inline struct mpeg_multiplex_buffer_utilization_descriptor* ++ mpeg_multiplex_buffer_utilization_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct mpeg_multiplex_buffer_utilization_descriptor) - 2)) ++ return NULL; ++ ++ bswap16((uint8_t*) d + 2); ++ bswap16((uint8_t*) d + 4); ++ ++ return (struct mpeg_multiplex_buffer_utilization_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/muxcode_descriptor.h dvb-apps/lib/libucsi/mpeg/muxcode_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/muxcode_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/muxcode_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,82 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_MUXCODE_DESCRIPTOR ++#define _UCSI_MPEG_MUXCODE_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_muxcode_descriptor structure ++ */ ++struct mpeg_muxcode_descriptor { ++ struct descriptor d; ++ ++ /* uint8_t entries[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_muxcode_descriptor. ++ * ++ * @param d Pointer to a generic descriptor structure. ++ * @return Pointer to an mpeg_muxcode_descriptor structure, or NULL on error. ++ */ ++static inline struct mpeg_muxcode_descriptor* ++ mpeg_muxcode_descriptor_codec(struct descriptor* d) ++{ ++ return (struct mpeg_muxcode_descriptor*) d; ++} ++ ++/** ++ * Retrieve pointer to entries field of an mpeg_muxcode_descriptor structure. ++ * ++ * @param d Generic descriptor structure. ++ * @return Pointer to the entries field. ++ */ ++static inline uint8_t * ++ mpeg_muxcode_descriptor_entries(struct mpeg_muxcode_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct mpeg_muxcode_descriptor); ++} ++ ++/** ++ * Determine length of entries field of an mpeg_muxcode_descriptor structure. ++ * ++ * @param d Generic descriptor structure. ++ * @return Number of bytes in the entries field. ++ */ ++static inline int ++ mpeg_muxcode_descriptor_entries_length(struct mpeg_muxcode_descriptor *d) ++{ ++ return d->d.len; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/odsmt_section.c dvb-apps/lib/libucsi/mpeg/odsmt_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/odsmt_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/odsmt_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,80 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct mpeg_odsmt_section *mpeg_odsmt_section_codec(struct section_ext * ext) ++{ ++ struct mpeg_odsmt_section * odsmt = (struct mpeg_odsmt_section *)ext; ++ uint8_t * buf = (uint8_t *)ext; ++ size_t pos = sizeof(struct section_ext); ++ size_t len = section_ext_length(ext); ++ int i; ++ ++ if (len < sizeof(struct mpeg_odsmt_section)) ++ return NULL; ++ ++ pos++; ++ ++ if (odsmt->stream_count == 0) { ++ struct mpeg_odsmt_stream * stream = ++ (struct mpeg_odsmt_stream *) (buf + pos); ++ ++ if ((pos + sizeof(struct mpeg_odsmt_stream_single)) > len) ++ return NULL; ++ ++ bswap16(buf+pos); ++ pos+=3; ++ ++ if ((pos + stream->u.single.es_info_length) >= len) ++ return NULL; ++ ++ if (verify_descriptors(buf + pos, stream->u.single.es_info_length)) ++ return NULL; ++ ++ pos += stream->u.single.es_info_length; ++ } else { ++ for (i=0; i< odsmt->stream_count; i++) { ++ struct mpeg_odsmt_stream * stream = ++ (struct mpeg_odsmt_stream *)(buf + pos); ++ ++ if ((pos + sizeof(struct mpeg_odsmt_stream_multi)) > len) ++ return NULL; ++ ++ bswap16(buf+pos); ++ pos += sizeof(struct mpeg_odsmt_stream_multi); ++ ++ if ((pos + stream->u.multi.es_info_length) > len) ++ return NULL; ++ ++ if (verify_descriptors(buf + pos, ++ stream->u.multi.es_info_length)) ++ return NULL; ++ ++ pos += stream->u.multi.es_info_length; ++ } ++ } ++ ++ if (pos != len) ++ return NULL; ++ ++ return (struct mpeg_odsmt_section *) ext; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/odsmt_section.h dvb-apps/lib/libucsi/mpeg/odsmt_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/odsmt_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/odsmt_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,224 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_ODSMT_SECTION_H ++#define _UCSI_MPEG_ODSMT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * mpeg_odsmt_section structure. ++ */ ++struct mpeg_odsmt_section { ++ struct section_ext head; ++ ++ uint8_t stream_count; ++ /* stream_count==0 => struct mpeg_odsmt_stream_single streams ++ stream_count>0 => struct mpeg_odsmt_stream_multi streams[] */ ++ /* uint8_t object_descriptors[] */ ++} __ucsi_packed; ++ ++struct mpeg_odsmt_stream_single ++{ ++ uint16_t esid; ++ uint8_t es_info_length; ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++struct mpeg_odsmt_stream_multi ++{ ++ uint16_t esid; ++ uint8_t fmc; ++ uint8_t es_info_length; ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++/** ++ * Structure describing the stream information held in an mpeg_odsmt_section. ++ */ ++struct mpeg_odsmt_stream { ++ union { ++ struct mpeg_odsmt_stream_single single; ++ struct mpeg_odsmt_stream_multi multi; ++ } u; ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_odsmt_section. ++ * ++ * @param section Pointer to the generic section_ext structure. ++ * @return Pointer to a mpeg_odsmt_section structure, or NULL on error. ++ */ ++extern struct mpeg_odsmt_section *mpeg_odsmt_section_codec(struct section_ext *section); ++ ++/** ++ * Accessor for the PID field of an ODSMT. ++ * ++ * @param odsmt odsmt pointer. ++ * @return The pid. ++ */ ++static inline uint16_t mpeg_odsmt_section_pid(struct mpeg_odsmt_section *odsmt) ++{ ++ return odsmt->head.table_id_ext & 0x1fff; ++} ++ ++/** ++ * Convenience iterator for the streams field of an mpeg_odsmt_section. ++ * ++ * @param osdmt Pointer to the mpeg_odsmt_section structure. ++ * @param pos Variable holding pointer to the current mpeg_odsmt_stream structure. ++ * @param index Variable holding the stream index. ++ */ ++#define mpeg_odsmt_section_streams_for_each(osdmt, pos, index) \ ++ for (index=0, (pos) = mpeg_odsmt_section_streams_first(odsmt); \ ++ (pos); \ ++ (pos) = mpeg_odsmt_section_streams_next(odsmt, pos, ++index)) ++ ++/** ++ * Convenience iterator for the descriptors field of an mpeg_odsmt_stream. ++ * ++ * @param osdmt Pointer to the mpeg_odsmt_section structure. ++ * @param stream Pointer to the mpeg_odsmt_stream structure. ++ * @param pos Variable holding pointer to the current descriptor structure. ++ */ ++#define mpeg_odsmt_stream_descriptors_for_each(osdmt, stream, pos) \ ++ for ((pos) = mpeg_odsmt_stream_descriptors_first(odsmt, stream); \ ++ (pos); \ ++ (pos) = mpeg_odsmt_stream_descriptors_next(odsmt, stream, pos)) ++ ++/** ++ * Retrieve a pointer to the object_descriptors field of an mpeg_odsmt_section. ++ * ++ * @param osdmt Pointer to the mpeg_odsmt_section structure. ++ * @param len On return, will contain the number of bytes in the object descriptors field. ++ * @return Pointer to the object_descriptors field, or NULL on error. ++ */ ++static inline uint8_t* ++ mpeg_odsmt_section_object_descriptors(struct mpeg_odsmt_section * odsmt, ++ size_t* len); ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct mpeg_odsmt_stream * ++ mpeg_odsmt_section_streams_first(struct mpeg_odsmt_section *odsmt) ++{ ++ size_t pos = sizeof(struct mpeg_odsmt_section); ++ ++ if (pos >= section_ext_length(&odsmt->head)) ++ return NULL; ++ ++ return (struct mpeg_odsmt_stream *) ((uint8_t *) odsmt + pos); ++} ++ ++static inline struct mpeg_odsmt_stream * ++ mpeg_odsmt_section_streams_next(struct mpeg_odsmt_section *odsmt, ++ struct mpeg_odsmt_stream *pos, ++ int _index) ++{ ++ uint8_t *end = (uint8_t*) odsmt + section_ext_length(&odsmt->head); ++ uint8_t *next; ++ ++ if (_index > odsmt->stream_count) ++ return NULL; ++ ++ next = (uint8_t *) pos + sizeof(struct mpeg_odsmt_stream_multi) + ++ pos->u.multi.es_info_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct mpeg_odsmt_stream *) next; ++} ++ ++static inline struct descriptor * ++ mpeg_odsmt_stream_descriptors_first(struct mpeg_odsmt_section *odsmt, ++ struct mpeg_odsmt_stream *stream) ++{ ++ if (odsmt->stream_count == 0) { ++ if (stream->u.single.es_info_length == 0) ++ return NULL; ++ ++ return (struct descriptor *) ++ ((uint8_t*) stream + sizeof(struct mpeg_odsmt_stream_single)); ++ } else { ++ if (stream->u.multi.es_info_length == 0) ++ return NULL; ++ ++ return (struct descriptor *) ++ ((uint8_t*) stream + sizeof(struct mpeg_odsmt_stream_multi)); ++ } ++} ++ ++static inline struct descriptor * ++ mpeg_odsmt_stream_descriptors_next(struct mpeg_odsmt_section *odsmt, ++ struct mpeg_odsmt_stream *stream, ++ struct descriptor* pos) ++{ ++ if (odsmt->stream_count == 0) { ++ return next_descriptor((uint8_t *) stream + sizeof(struct mpeg_odsmt_stream_single), ++ stream->u.single.es_info_length, ++ pos); ++ } else { ++ return next_descriptor((uint8_t *) stream + sizeof(struct mpeg_odsmt_stream_multi), ++ stream->u.multi.es_info_length, ++ pos); ++ } ++} ++ ++static inline uint8_t* ++ mpeg_odsmt_section_object_descriptors(struct mpeg_odsmt_section * odsmt, ++ size_t* len) ++{ ++ struct mpeg_odsmt_stream* pos; ++ size_t size = sizeof(struct mpeg_odsmt_section); ++ int _index; ++ ++ mpeg_odsmt_section_streams_for_each(odsmt, pos, _index) { ++ if (odsmt->stream_count == 0) ++ size += sizeof(struct mpeg_odsmt_stream_single) + ++ pos->u.single.es_info_length; ++ else ++ size += sizeof(struct mpeg_odsmt_stream_multi) + ++ pos->u.multi.es_info_length; ++ } ++ ++ *len = section_ext_length(&odsmt->head) - size; ++ return (uint8_t*) odsmt + size; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/pat_section.c dvb-apps/lib/libucsi/mpeg/pat_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/pat_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/pat_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,46 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct mpeg_pat_section *mpeg_pat_section_codec(struct section_ext * ext) ++{ ++ uint8_t *buf = (uint8_t *)ext; ++ size_t pos = sizeof(struct section_ext); ++ size_t len = section_ext_length(ext); ++ ++ if (len < sizeof(struct mpeg_pat_section)) ++ return NULL; ++ ++ while (pos < len) { ++ if ((pos + 4) > len) ++ return NULL; ++ ++ bswap16(buf + pos); ++ bswap16(buf + pos + 2); ++ pos += 4; ++ } ++ ++ if (pos != len) ++ return NULL; ++ ++ return (struct mpeg_pat_section *)ext; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/pat_section.h dvb-apps/lib/libucsi/mpeg/pat_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/pat_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/pat_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,118 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_PAT_SECTION_H ++#define _UCSI_MPEG_PAT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * mpeg_pat_section structure. ++ */ ++struct mpeg_pat_section { ++ struct section_ext head; /* table_id_ext == transport_stream_id */ ++ ++ /* struct mpeg_pat_program programs[] */ ++} __ucsi_packed; ++ ++/** ++ * A program within an mpeg_pat_section. ++ */ ++struct mpeg_pat_program { ++ uint16_t program_number; ++ EBIT2(uint16_t reserved : 3; , ++ uint16_t pid :13; ); ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_pat_section. ++ * ++ * @param section Pointer to the generic section_ext structure. ++ * @return Pointer to the mpeg_pat_section structure, or NULL on error. ++ */ ++extern struct mpeg_pat_section *mpeg_pat_section_codec(struct section_ext *section); ++ ++/** ++ * Accessor for the transport_stream_id field of a PAT. ++ * ++ * @param pat PAT pointer. ++ * @return The transport_stream_id. ++ */ ++static inline uint16_t mpeg_pat_section_transport_stream_id(struct mpeg_pat_section *pat) ++{ ++ return pat->head.table_id_ext; ++} ++ ++/** ++ * Conveience iterator for the programs field of an mpeg_pat_section. ++ * ++ * @param pat Pointer to the mpeg_pat_section structure. ++ * @param pos Variable holding a pointer to the current mpeg_pat_program structure. ++ */ ++#define mpeg_pat_section_programs_for_each(pat, pos) \ ++ for ((pos) = mpeg_pat_section_programs_first(pat); \ ++ (pos); \ ++ (pos) = mpeg_pat_section_programs_next(pat, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct mpeg_pat_program * ++ mpeg_pat_section_programs_first(struct mpeg_pat_section * pat) ++{ ++ size_t pos = sizeof(struct mpeg_pat_section); ++ ++ if (pos >= section_ext_length(&pat->head)) ++ return NULL; ++ ++ return (struct mpeg_pat_program*)((uint8_t *) pat + pos); ++} ++ ++static inline ++ struct mpeg_pat_program *mpeg_pat_section_programs_next(struct mpeg_pat_section * pat, ++ struct mpeg_pat_program * pos) ++{ ++ uint8_t *end = (uint8_t*) pat + section_ext_length(&pat->head); ++ uint8_t *next= (uint8_t *) pos + sizeof(struct mpeg_pat_program); ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct mpeg_pat_program *) next; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/pmt_section.c dvb-apps/lib/libucsi/mpeg/pmt_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/pmt_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/pmt_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,71 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct mpeg_pmt_section * mpeg_pmt_section_codec(struct section_ext * ext) ++{ ++ uint8_t * buf = (uint8_t *) ext; ++ struct mpeg_pmt_section * pmt = (struct mpeg_pmt_section *) ext; ++ size_t pos = sizeof(struct section_ext); ++ size_t len = section_ext_length(ext); ++ ++ if (len < sizeof(struct mpeg_pmt_section)) ++ return NULL; ++ ++ bswap16(buf + pos); ++ pos += 2; ++ bswap16(buf + pos); ++ pos += 2; ++ ++ if ((pos + pmt->program_info_length) > len) ++ return NULL; ++ ++ if (verify_descriptors(buf + pos, pmt->program_info_length)) ++ return NULL; ++ ++ pos += pmt->program_info_length; ++ ++ while (pos < len) { ++ struct mpeg_pmt_stream * stream = ++ (struct mpeg_pmt_stream *) (buf + pos); ++ ++ if ((pos + sizeof(struct mpeg_pmt_stream)) > len) ++ return NULL; ++ ++ bswap16(buf + pos + 1); ++ bswap16(buf + pos + 3); ++ pos += sizeof(struct mpeg_pmt_stream); ++ ++ if ((pos + stream->es_info_length) > len) ++ return NULL; ++ ++ if (verify_descriptors(buf + pos, stream->es_info_length)) ++ return NULL; ++ ++ pos += stream->es_info_length; ++ } ++ ++ if (pos != len) ++ return NULL; ++ ++ return (struct mpeg_pmt_section *) ext; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/pmt_section.h dvb-apps/lib/libucsi/mpeg/pmt_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/pmt_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/pmt_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,188 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_PMT_SECTION_H ++#define _UCSI_MPEG_PMT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * mpeg_pmt_section structure. ++ */ ++struct mpeg_pmt_section { ++ struct section_ext head; ++ ++ EBIT2(uint16_t reserved_1 : 3; , ++ uint16_t pcr_pid :13; ); ++ EBIT2(uint16_t reserved_2 : 4; , ++ uint16_t program_info_length :12; ); ++ /* struct descriptor descriptors[] */ ++ /* struct mpeg_pmt_stream streams[] */ ++} __ucsi_packed; ++ ++/** ++ * A stream within an mpeg_pmt_section. ++ */ ++struct mpeg_pmt_stream { ++ uint8_t stream_type; ++ EBIT2(uint16_t reserved_1 : 3; , ++ uint16_t pid :13; ); ++ EBIT2(uint16_t reserved_2 : 4; , ++ uint16_t es_info_length :12; ); ++ ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_pmt_section section. ++ * ++ * @param section Pointer to the generic section header. ++ * @return Pointer to the mpeg_pmt_section structure, or NULL on error. ++ */ ++extern struct mpeg_pmt_section *mpeg_pmt_section_codec(struct section_ext *section); ++ ++/** ++ * Accessor for program_number field of a PMT. ++ * ++ * @param pmt PMT pointer. ++ * @return The program_number. ++ */ ++static inline uint16_t mpeg_pmt_section_program_number(struct mpeg_pmt_section *pmt) ++{ ++ return pmt->head.table_id_ext; ++} ++ ++/** ++ * Convenience iterator for the descriptors field of the mpeg_pmt_section structure. ++ * ++ * @param pmt Pointer to the mpeg_pmt_section structure. ++ * @param pos Variable holding a pointer to the current descriptor. ++ */ ++#define mpeg_pmt_section_descriptors_for_each(pmt, pos) \ ++ for ((pos) = mpeg_pmt_section_descriptors_first(pmt); \ ++ (pos); \ ++ (pos) = mpeg_pmt_section_descriptors_next(pmt, pos)) ++ ++/** ++ * Convenience iterator for the streams field of the mpeg_pmt_section structure. ++ * ++ * @param pmt Pointer to the mpeg_pmt_section structure. ++ * @param pos Variable holding a pointer to the current mpeg_pmt_stream. ++ */ ++#define mpeg_pmt_section_streams_for_each(pmt, pos) \ ++ for ((pos) = mpeg_pmt_section_streams_first(pmt); \ ++ (pos); \ ++ (pos) = mpeg_pmt_section_streams_next(pmt, pos)) ++ ++/** ++ * Convenience iterator for the descriptors field of an mpeg_pmt_stream structure. ++ * ++ * @param stream Pointer to the mpeg_pmt_stream structure. ++ * @param pos Variable holding a pointer to the current descriptor. ++ */ ++#define mpeg_pmt_stream_descriptors_for_each(stream, pos) \ ++ for ((pos) = mpeg_pmt_stream_descriptors_first(stream); \ ++ (pos); \ ++ (pos) = mpeg_pmt_stream_descriptors_next(stream, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct descriptor * ++ mpeg_pmt_section_descriptors_first(struct mpeg_pmt_section * pmt) ++{ ++ if (pmt->program_info_length == 0) ++ return NULL; ++ ++ return (struct descriptor *) ++ ((uint8_t *) pmt + sizeof(struct mpeg_pmt_section)); ++} ++ ++static inline struct descriptor * ++ mpeg_pmt_section_descriptors_next(struct mpeg_pmt_section *pmt, ++ struct descriptor* pos) ++{ ++ return next_descriptor((uint8_t *) pmt + sizeof(struct mpeg_pmt_section), ++ pmt->program_info_length, ++ pos); ++} ++ ++static inline struct mpeg_pmt_stream * ++ mpeg_pmt_section_streams_first(struct mpeg_pmt_section * pmt) ++{ ++ size_t pos = sizeof(struct mpeg_pmt_section) + pmt->program_info_length; ++ ++ if (pos >= section_ext_length(&pmt->head)) ++ return NULL; ++ ++ return (struct mpeg_pmt_stream *)((uint8_t *)pmt + pos); ++} ++ ++static inline struct mpeg_pmt_stream * ++ mpeg_pmt_section_streams_next(struct mpeg_pmt_section * pmt, ++ struct mpeg_pmt_stream * pos) ++{ ++ uint8_t *end = (uint8_t*) pmt + section_ext_length(&pmt->head); ++ uint8_t *next = (uint8_t *) pos + sizeof(struct mpeg_pmt_stream) + ++ pos->es_info_length; ++ ++ if (next >= end) ++ return NULL; ++ ++ return (struct mpeg_pmt_stream *) next; ++} ++ ++static inline struct descriptor * ++ mpeg_pmt_stream_descriptors_first(struct mpeg_pmt_stream *stream) ++{ ++ if (stream->es_info_length == 0) ++ return NULL; ++ ++ return (struct descriptor *) ++ ((uint8_t*) stream + sizeof(struct mpeg_pmt_stream)); ++} ++ ++static inline struct descriptor * ++ mpeg_pmt_stream_descriptors_next(struct mpeg_pmt_stream *stream, ++ struct descriptor* pos) ++{ ++ return next_descriptor((uint8_t *) stream + sizeof(struct mpeg_pmt_stream), ++ stream->es_info_length, ++ pos); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/private_data_indicator_descriptor.h dvb-apps/lib/libucsi/mpeg/private_data_indicator_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/private_data_indicator_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/private_data_indicator_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,63 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_PRIVATE_DATA_INDICATOR_DESCRIPTOR ++#define _UCSI_MPEG_PRIVATE_DATA_INDICATOR_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_private_data_indicator_descriptor structure ++ */ ++struct mpeg_private_data_indicator_descriptor { ++ struct descriptor d; ++ ++ uint32_t private_data_indicator; ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_private_data_indicator_descriptor structure. ++ * ++ * @param d Pointer to the generic descriptor structure. ++ * @return Pointer to the mpeg_private_data_indicator_descriptor, or NULL on error. ++ */ ++static inline struct mpeg_private_data_indicator_descriptor* ++ mpeg_private_data_indicator_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct mpeg_private_data_indicator_descriptor) - 2)) ++ return NULL; ++ ++ bswap32((uint8_t*) d + 2); ++ ++ return (struct mpeg_private_data_indicator_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/registration_descriptor.h dvb-apps/lib/libucsi/mpeg/registration_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/registration_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/registration_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,91 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_REGISTRATION_DESCRIPTOR ++#define _UCSI_MPEG_REGISTRATION_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_registration_descriptor structure. ++ */ ++struct mpeg_registration_descriptor { ++ struct descriptor d; ++ ++ uint32_t format_identifier; ++ /* uint8_t additional_id_info[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_registration_descriptor. ++ * ++ * @param d Pointer to the generic descriptor structure. ++ * @return Pointer to the mpeg_registration_descriptor structure, or NULL on error. ++ */ ++static inline struct mpeg_registration_descriptor* ++ mpeg_registration_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len < (sizeof(struct mpeg_registration_descriptor) - 2)) ++ return NULL; ++ ++ bswap32((uint8_t*) d + 2); ++ ++ return (struct mpeg_registration_descriptor*) d; ++} ++ ++/** ++ * Retrieve a pointer to the additional_id_info field of the ++ * mpeg_registration_descriptor structure. ++ * ++ * @param d Pointer to the mpeg_registration_descriptor structure. ++ * @return Pointer to the field. ++ */ ++static inline uint8_t * ++ mpeg_registration_descriptor_additional_id_info(struct mpeg_registration_descriptor *d) ++{ ++ return (uint8_t *) d + sizeof(struct mpeg_registration_descriptor); ++} ++ ++/** ++ * Determine number of bytes in the additional_id_info field of the ++ * mpeg_registration_descriptor structure. ++ * ++ * @param d Pointer to the mpeg_registration_descriptor structure. ++ * @return Number of bytes. ++ */ ++ ++static inline int ++ mpeg_registration_descriptor_additional_id_info_length(struct mpeg_registration_descriptor *d) ++{ ++ return d->d.len - 4; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/section.h dvb-apps/lib/libucsi/mpeg/section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,60 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_SECTION_H ++#define _UCSI_MPEG_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define TRANSPORT_PAT_PID 0x00 ++#define TRANSPORT_CAT_PID 0x01 ++#define TRANSPORT_TSDT_PID 0x02 ++ ++/** ++ * Enumeration of MPEG section tags. ++ */ ++enum mpeg_section_tag { ++ stag_mpeg_program_association = 0x00, ++ stag_mpeg_conditional_access = 0x01, ++ stag_mpeg_program_map = 0x02, ++ stag_mpeg_transport_stream_description = 0x03, ++ stag_mpeg_iso14496_scene_description = 0x04, ++ stag_mpeg_iso14496_object_description = 0x05, ++ stag_mpeg_metadata = 0x06, ++ stag_mpeg_datagram = 0x3e, ++}; ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/sl_descriptor.h dvb-apps/lib/libucsi/mpeg/sl_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/sl_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/sl_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,63 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_SL_DESCRIPTOR ++#define _UCSI_MPEG_SL_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_sl_descriptor structure. ++ */ ++struct mpeg_sl_descriptor { ++ struct descriptor d; ++ ++ uint16_t es_id; ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_sl_descriptor. ++ * ++ * @param d The generic descriptor structure. ++ * @return Pointer to an mpeg_sl_descriptor structure, or NULL on error. ++ */ ++static inline struct mpeg_sl_descriptor* ++ mpeg_sl_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct mpeg_sl_descriptor) - 2)) ++ return NULL; ++ ++ bswap16((uint8_t*) d + 2); ++ ++ return (struct mpeg_sl_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/smoothing_buffer_descriptor.h dvb-apps/lib/libucsi/mpeg/smoothing_buffer_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/smoothing_buffer_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/smoothing_buffer_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,66 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_SMOOTHING_BUFFER_DESCRIPTOR ++#define _UCSI_MPEG_SMOOTHING_BUFFER_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_smoothing_buffer_descriptor structure. ++ */ ++struct mpeg_smoothing_buffer_descriptor { ++ struct descriptor d; ++ ++ EBIT4(uint64_t reserved_1 : 2; , ++ uint64_t sb_leak_rate :22; , ++ uint64_t reserved_2 : 2; , ++ uint64_t sb_size :22; ); ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_smoothing_buffer_descriptor. ++ * ++ * @param d The generic descriptor structure. ++ * @return Pointer to mpeg_smoothing_buffer_descriptor, or NULL on error. ++ */ ++static inline struct mpeg_smoothing_buffer_descriptor* ++ mpeg_smoothing_buffer_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct mpeg_smoothing_buffer_descriptor) - 2)) ++ return NULL; ++ ++ bswap48((uint8_t*) d + 2); ++ ++ return (struct mpeg_smoothing_buffer_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/std_descriptor.h dvb-apps/lib/libucsi/mpeg/std_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/std_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/std_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,62 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_STD_DESCRIPTOR ++#define _UCSI_MPEG_STD_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_std_descriptor structure. ++ */ ++struct mpeg_std_descriptor { ++ struct descriptor d; ++ ++ EBIT2(uint8_t reserved : 7; , ++ uint8_t leak_valid_flag : 1; ); ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_std_descriptor. ++ * ++ * @param d Pointer to the generic descriptor structure. ++ * @return Pointer to the mpeg_std_descriptor, or NULL on error. ++ */ ++static inline struct mpeg_std_descriptor* ++ mpeg_std_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct mpeg_std_descriptor) - 2)) ++ return NULL; ++ ++ return (struct mpeg_std_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/system_clock_descriptor.h dvb-apps/lib/libucsi/mpeg/system_clock_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/system_clock_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/system_clock_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,65 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_SYSTEM_CLOCK_DESCRIPTOR ++#define _UCSI_MPEG_SYSTEM_CLOCK_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_system_clock_descriptor structure. ++ */ ++struct mpeg_system_clock_descriptor { ++ struct descriptor d; ++ ++ EBIT3(uint8_t external_clock_reference_indicator : 1; , ++ uint8_t reserved_1 : 1; , ++ uint8_t clock_accuracy_integer : 6; ); ++ EBIT2(uint8_t clock_accuracy_exponent : 3; , ++ uint8_t reserved_2 : 5; ); ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_system_clock_descriptor. ++ * ++ * @param d The generic descriptor structure. ++ * @return Pointer to a mpeg_system_clock_descriptor structure, or NULL on error. ++ */ ++static inline struct mpeg_system_clock_descriptor* ++ mpeg_system_clock_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct mpeg_system_clock_descriptor) - 2)) ++ return NULL; ++ ++ return (struct mpeg_system_clock_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/target_background_grid_descriptor.h dvb-apps/lib/libucsi/mpeg/target_background_grid_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/target_background_grid_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/target_background_grid_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,66 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_TARGET_BACKGROUND_GRID_DESCRIPTOR ++#define _UCSI_MPEG_TARGET_BACKGROUND_GRID_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * mpeg_target_background_grid_descriptor structure. ++ */ ++struct mpeg_target_background_grid_descriptor { ++ struct descriptor d; ++ ++ EBIT3(uint32_t horizontal_size : 14; , ++ uint32_t vertical_size : 14; , ++ uint32_t aspect_ratio_information : 4; ); ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_target_background_grid_descriptor structure. ++ * ++ * @param d Pointer to the generic descriptor structure. ++ * @return Pointer to the mpeg_target_background_grid_descriptor structure, or ++ * NULL on error. ++ */ ++static inline struct mpeg_target_background_grid_descriptor* ++ mpeg_target_background_grid_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct mpeg_target_background_grid_descriptor) - 2)) ++ return NULL; ++ ++ bswap32((uint8_t*) d + 2); ++ ++ return (struct mpeg_target_background_grid_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/tsdt_section.c dvb-apps/lib/libucsi/mpeg/tsdt_section.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/tsdt_section.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/tsdt_section.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,34 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++ ++struct mpeg_tsdt_section * mpeg_tsdt_section_codec(struct section_ext * ext) ++{ ++ uint8_t * buf = (uint8_t *)ext; ++ size_t pos = sizeof(struct section_ext); ++ ++ if (verify_descriptors(buf + pos, ++ section_ext_length(ext) - sizeof(struct mpeg_tsdt_section))) ++ return NULL; ++ ++ return (struct mpeg_tsdt_section *)ext; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/tsdt_section.h dvb-apps/lib/libucsi/mpeg/tsdt_section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/tsdt_section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/tsdt_section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,94 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_TSDT_SECTION_H ++#define _UCSI_MPEG_TSDT_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * mpeg_tsdt_section structure. ++ */ ++struct mpeg_tsdt_section { ++ struct section_ext head; ++ ++ /* struct descriptor descriptors[] */ ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_tsdt_section structure. ++ * ++ * @param section Pointer to the section_ext structure. ++ * @return Pointer to the mpeg_tsdt_section structure, or NULL on error. ++ */ ++extern struct mpeg_tsdt_section *mpeg_tsdt_section_codec(struct section_ext *section); ++ ++/** ++ * Convenience iterator for descriptors field. ++ * ++ * @param tsdt Pointer to the mpeg_tsdt_section structure. ++ * @param pos Variable holding a pointer to the current descriptor. ++ */ ++#define mpeg_tsdt_section_descriptors_for_each(tsdt, pos) \ ++ for ((pos) = mpeg_tsdt_section_descriptors_first(tsdt); \ ++ (pos); \ ++ (pos) = mpeg_tsdt_section_descriptors_next(tsdt, pos)) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++/******************************** PRIVATE CODE ********************************/ ++static inline struct descriptor * ++ mpeg_tsdt_section_descriptors_first(struct mpeg_tsdt_section * tsdt) ++{ ++ size_t pos = sizeof(struct mpeg_tsdt_section); ++ ++ if (pos >= section_ext_length(&tsdt->head)) ++ return NULL; ++ ++ return (struct descriptor*)((uint8_t *) tsdt + pos); ++} ++ ++static inline struct descriptor * ++ mpeg_tsdt_section_descriptors_next(struct mpeg_tsdt_section *tsdt, ++ struct descriptor* pos) ++{ ++ return next_descriptor((uint8_t *) tsdt + sizeof(struct mpeg_tsdt_section), ++ section_ext_length(&tsdt->head) - sizeof(struct mpeg_tsdt_section), ++ pos); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/types.h dvb-apps/lib/libucsi/mpeg/types.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/types.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/types.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,127 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_TYPES_H ++#define _UCSI_MPEG_TYPES_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++/** ++ * Known stream types. ++ */ ++enum { ++ MPEG_STREAM_TYPE_ISO11172_VIDEO = 0x01, ++ MPEG_STREAM_TYPE_ISO13818_2_VIDEO = 0x02, ++ MPEG_STREAM_TYPE_ISO11172_AUDIO = 0x03, ++ MPEG_STREAM_TYPE_ISO13818_3_AUDIO = 0x04, ++ MPEG_STREAM_TYPE_ISO13818_1_PRIVATE_SECTIONS = 0x05, ++ MPEG_STREAM_TYPE_ISO13818_1_PRIVATE_PES = 0x06, ++ MPEG_STREAM_TYPE_ISO13522_MHEG = 0x07, ++ MPEG_STREAM_TYPE_ISO13818_DSMCC = 0x08, ++ MPEG_STREAM_TYPE_ITUH222_1 = 0x09, ++ MPEG_STREAM_TYPE_ISO13818_6_A = 0x0a, ++ MPEG_STREAM_TYPE_ISO13818_6_B = 0x0b, ++ MPEG_STREAM_TYPE_ISO13818_6_C = 0x0c, ++ MPEG_STREAM_TYPE_ISO13818_6_D = 0x0d, ++ MPEG_STREAM_TYPE_ISO13818_1_AUX = 0x0e, ++ MPEG_STREAM_TYPE_ISO13818_7_AUDIO_ADTS = 0x0f, ++ MPEG_STREAM_TYPE_ISO14496_2_VISUAL = 0x10, ++ MPEG_STREAM_TYPE_ISO14496_3_AUDIO_LATM = 0x11, ++ MPEG_STREAM_TYPE_ISO14496_1_PES = 0x12, ++ MPEG_STREAM_TYPE_ISO14496_1_SECTIONS = 0x13, ++ MPEG_STREAM_TYPE_ISO14496_6_SYNCDOWNLOAD = 0x14, ++ MPEG_STREAM_TYPE_METADATA_PES = 0x15, ++ MPEG_STREAM_TYPE_METADATA_SECTIONS = 0x16, ++ MPEG_STREAM_TYPE_METADATA_DSMCC_DATA = 0x17, ++ MPEG_STREAM_TYPE_METADATA_DSMCC_OBJECT = 0x18, ++ MPEG_STREAM_TYPE_METADATA_SYNCDOWNLOAD = 0x19, ++}; ++ ++/** ++ * Metadata formats ++ */ ++enum { ++ MPEG_METADATA_FORMAT_ISO15938_1_TEM = 0x01, ++ MPEG_METADATA_FORMAT_ISO15938_1_BIM = 0x02, ++ MPEG_METADATA_FORMAT_METADATA_APPLICATION_FORMAT = 0x3F, ++ MPEG_METADATA_FORMAT_METADATA_APPLICATION_FORMAT_ID = 0xFF, ++}; ++ ++/** ++ * MPEG 4 audio profile and levels. ++ */ ++enum { ++ MPEG4_AUDIO_PROFILE_MAIN_LEVEL_1 = 0x10, ++ MPEG4_AUDIO_PROFILE_MAIN_LEVEL_2 = 0x11, ++ MPEG4_AUDIO_PROFILE_MAIN_LEVEL_3 = 0x12, ++ MPEG4_AUDIO_PROFILE_MAIN_LEVEL_4 = 0x13, ++ ++ MPEG4_AUDIO_PROFILE_SCALABLE_LEVEL_1 = 0x18, ++ MPEG4_AUDIO_PROFILE_SCALABLE_LEVEL_2 = 0x19, ++ MPEG4_AUDIO_PROFILE_SCALABLE_LEVEL_3 = 0x1a, ++ MPEG4_AUDIO_PROFILE_SCALABLE_LEVEL_4 = 0x1b, ++ ++ MPEG4_AUDIO_PROFILE_SPEECH_LEVEL_1 = 0x20, ++ MPEG4_AUDIO_PROFILE_SPEECH_LEVEL_2 = 0x21, ++ ++ MPEG4_AUDIO_PROFILE_SYNTHESIS_LEVEL_1 = 0x28, ++ MPEG4_AUDIO_PROFILE_SYNTHESIS_LEVEL_2 = 0x29, ++ MPEG4_AUDIO_PROFILE_SYNTHESIS_LEVEL_3 = 0x2a, ++ ++ MPEG4_AUDIO_PROFILE_HQ_LEVEL_1 = 0x30, ++ MPEG4_AUDIO_PROFILE_HQ_LEVEL_2 = 0x31, ++ MPEG4_AUDIO_PROFILE_HQ_LEVEL_3 = 0x32, ++ MPEG4_AUDIO_PROFILE_HQ_LEVEL_4 = 0x33, ++ MPEG4_AUDIO_PROFILE_HQ_LEVEL_5 = 0x34, ++ MPEG4_AUDIO_PROFILE_HQ_LEVEL_6 = 0x35, ++ MPEG4_AUDIO_PROFILE_HQ_LEVEL_7 = 0x36, ++ MPEG4_AUDIO_PROFILE_HQ_LEVEL_8 = 0x37, ++ ++ MPEG4_AUDIO_PROFILE_LOW_DELAY_LEVEL_1 = 0x38, ++ MPEG4_AUDIO_PROFILE_LOW_DELAY_LEVEL_2 = 0x39, ++ MPEG4_AUDIO_PROFILE_LOW_DELAY_LEVEL_3 = 0x3a, ++ MPEG4_AUDIO_PROFILE_LOW_DELAY_LEVEL_4 = 0x3b, ++ MPEG4_AUDIO_PROFILE_LOW_DELAY_LEVEL_5 = 0x3c, ++ MPEG4_AUDIO_PROFILE_LOW_DELAY_LEVEL_6 = 0x3d, ++ MPEG4_AUDIO_PROFILE_LOW_DELAY_LEVEL_7 = 0x3e, ++ MPEG4_AUDIO_PROFILE_LOW_DELAY_LEVEL_8 = 0x3f, ++ ++ MPEG4_AUDIO_PROFILE_NATURAL_LEVEL_1 = 0x40, ++ MPEG4_AUDIO_PROFILE_NATURAL_LEVEL_2 = 0x41, ++ MPEG4_AUDIO_PROFILE_NATURAL_LEVEL_3 = 0x42, ++ MPEG4_AUDIO_PROFILE_NATURAL_LEVEL_4 = 0x43, ++ ++ MPEG4_AUDIO_PROFILE_MOBILE_LEVEL_1 = 0x48, ++ MPEG4_AUDIO_PROFILE_MOBILE_LEVEL_2 = 0x49, ++ MPEG4_AUDIO_PROFILE_MOBILE_LEVEL_3 = 0x4a, ++ MPEG4_AUDIO_PROFILE_MOBILE_LEVEL_4 = 0x4b, ++ MPEG4_AUDIO_PROFILE_MOBILE_LEVEL_5 = 0x4c, ++ MPEG4_AUDIO_PROFILE_MOBILE_LEVEL_6 = 0x4d, ++}; ++ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/video_stream_descriptor.h dvb-apps/lib/libucsi/mpeg/video_stream_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/video_stream_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/video_stream_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,101 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_VIDEO_STREAM_DESCRIPTOR ++#define _UCSI_MPEG_VIDEO_STREAM_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++ ++/** ++ * The mpeg_video_stream_descriptor structure ++ */ ++struct mpeg_video_stream_descriptor { ++ struct descriptor d; ++ ++ EBIT5(uint8_t multiple_frame_rate_flag : 1; , ++ uint8_t frame_rate_code : 4; , ++ uint8_t mpeg_1_only_flag : 1; , ++ uint8_t constrained_parameter_flag : 1; , ++ uint8_t still_picture_flag : 1; ); ++ /* if (mpeg_1_only_flag == 0) struct mpeg_video_stream_extra extra */ ++} __ucsi_packed; ++ ++/** ++ * The mpeg_video_stream_extra - only present in non-MPEG1-only streams. ++ */ ++struct mpeg_video_stream_extra { ++ uint8_t profile_and_level_indication; ++ EBIT3(uint8_t chroma_format : 2; , ++ uint8_t frame_rate_extension : 1; , ++ uint8_t reserved : 5; ); ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_video_stream_descriptor structure. ++ * ++ * @param d Pointer to the generic descriptor structure. ++ * @return Pointer to the mpeg_video_stream_descriptor, or NULL on error. ++ */ ++static inline struct mpeg_video_stream_descriptor* ++ mpeg_video_stream_descriptor_codec(struct descriptor* d) ++{ ++ struct mpeg_video_stream_descriptor* vsd = ++ (struct mpeg_video_stream_descriptor*) d; ++ ++ if (d->len < (sizeof(struct mpeg_video_stream_descriptor) - 2)) ++ return NULL; ++ ++ if (!vsd->mpeg_1_only_flag) { ++ if (d->len != (sizeof(struct mpeg_video_stream_descriptor) + ++ sizeof(struct mpeg_video_stream_extra) - 2)) ++ return NULL; ++ } ++ ++ return (struct mpeg_video_stream_descriptor*) d; ++} ++ ++/** ++ * Get a pointer to the mpeg_video_stream_extra structure. ++ * ++ * @param d Pointer to the mpeg_video_stream_descriptor structure. ++ * @return Pointer to the mpeg_video_stream_extra structure, or NULL on error. ++ */ ++static inline struct mpeg_video_stream_extra* ++ mpeg_video_stream_descriptor_extra(struct mpeg_video_stream_descriptor* d) ++{ ++ if (d->mpeg_1_only_flag != 0) ++ return NULL; ++ ++ return (struct mpeg_video_stream_extra*) ++ ((uint8_t*) d + sizeof(struct mpeg_video_stream_descriptor)); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/video_window_descriptor.h dvb-apps/lib/libucsi/mpeg/video_window_descriptor.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/mpeg/video_window_descriptor.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/mpeg/video_window_descriptor.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,64 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_MPEG_VIDEO_WINDOW_DESCRIPTOR ++#define _UCSI_MPEG_VIDEO_WINDOW_DESCRIPTOR 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++/** ++ * mpeg_video_window_descriptor structure. ++ */ ++struct mpeg_video_window_descriptor { ++ struct descriptor d; ++ ++ EBIT3(uint32_t horizontal_offset : 14; , ++ uint32_t vertical_offset : 14; , ++ uint32_t window_priority : 4; ); ++} __ucsi_packed; ++ ++/** ++ * Process an mpeg_video_window_descriptor. ++ * ++ * @param d Pointer to the generic descriptor structure. ++ * @return Pointer to the mpeg_video_window_descriptor structure, or NULL on error. ++ */ ++static inline struct mpeg_video_window_descriptor* ++ mpeg_video_window_descriptor_codec(struct descriptor* d) ++{ ++ if (d->len != (sizeof(struct mpeg_video_window_descriptor) - 2)) ++ return NULL; ++ ++ bswap32((uint8_t*) d + 2); ++ ++ return (struct mpeg_video_window_descriptor*) d; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/section_buf.c dvb-apps/lib/libucsi/section_buf.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/section_buf.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/section_buf.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,173 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++#include "section_buf.h" ++ ++#define SECTION_HDR_SIZE 3 ++#define SECTION_PAD 0xff ++ ++int section_buf_init(struct section_buf *section, int max) ++{ ++ if (max < SECTION_HDR_SIZE) ++ return -EINVAL; ++ ++ memset(section, 0, sizeof(struct section_buf)); ++ section->max = max; /* max size of data */ ++ section->len = SECTION_HDR_SIZE; ++ section->wait_pdu = 1; ++ ++ return 0; ++} ++ ++int section_buf_add(struct section_buf *section, uint8_t* frag, int len, int *section_status) ++{ ++ int copy; ++ int used = 0; ++ uint8_t *data; ++ uint8_t *pos = (uint8_t*) section + sizeof(struct section_buf) + section->count; ++ ++ /* have we finished? */ ++ if (section->header && (section->len == section->count)) { ++ *section_status = 1; ++ return 0; ++ } ++ ++ /* skip over section padding bytes */ ++ *section_status = 0; ++ if (section->count == 0) { ++ while(len && (*frag == SECTION_PAD)) { ++ frag++; ++ len--; ++ used++; ++ } ++ ++ if (len == 0) ++ return used; ++ } ++ ++ /* grab the header to get the section length */ ++ if (!section->header) { ++ /* copy the header frag */ ++ copy = SECTION_HDR_SIZE - section->count; ++ if (copy > len) ++ copy = len; ++ memcpy(pos, frag, copy); ++ section->count += copy; ++ pos += copy; ++ frag += copy; ++ used += copy; ++ len -= copy; ++ ++ /* we need 3 bytes for the section header */ ++ if (section->count != SECTION_HDR_SIZE) ++ return used; ++ ++ /* work out the length & check it isn't too big */ ++ data = (uint8_t*) section + sizeof(struct section_buf); ++ section->len = SECTION_HDR_SIZE + (((data[1] & 0x0f) << 8) | data[2]); ++ if (section->len > section->max) { ++ *section_status = -ERANGE; ++ return len + used; ++ } ++ ++ /* update fields */ ++ section->header = 1; ++ } ++ ++ /* accumulate frag */ ++ copy = section->len - section->count; ++ if (copy > len) ++ copy = len; ++ memcpy(pos, frag, copy); ++ section->count += copy; ++ used += copy; ++ ++ /* have we finished? */ ++ if (section->header && (section->len == section->count)) ++ *section_status = 1; ++ ++ /* return number of bytes used */ ++ return used; ++} ++ ++int section_buf_add_transport_payload(struct section_buf *section, ++ uint8_t* payload, int len, ++ int pdu_start, int *section_status) ++{ ++ int used = 0; ++ int tmp; ++ ++ /* have we finished? */ ++ if (section->header && (section->len == section->count)) { ++ *section_status = 1; ++ return 0; ++ } ++ ++ /* don't bother if we're waiting for a PDU */ ++ *section_status = 0; ++ if (section->wait_pdu && (!pdu_start)) ++ return len; ++ ++ /* if we're at a PDU start, we need extra handling for the extra first ++ * byte giving the offset to the start of the next section. */ ++ if (pdu_start) { ++ /* we have received a pdu */ ++ section->wait_pdu = 0; ++ ++ /* work out the offset to the _next_ payload */ ++ int offset = payload[0]; ++ if ((offset+1) > len) { ++ section->wait_pdu = 1; ++ *section_status = -EINVAL; ++ return len; ++ } ++ ++ /* accumulate the end if we need to */ ++ if (section->count != 0) { ++ /* add the final fragment. */ ++ tmp = section_buf_add(section, payload + 1, offset, section_status); ++ ++ /* the stream said this was the final fragment ++ * (PDU START bit) - check that it really was! */ ++ if ((tmp != offset) || section_buf_remaining(section) || (*section_status != 1)) { ++ *section_status = -ERANGE; ++ section->wait_pdu = 1; ++ return 1 + tmp; ++ } ++ ++ /* it is complete - return the number of bytes we used */ ++ return 1 + tmp; ++ } ++ ++ /* otherwise, we skip the end of the previous section, and ++ * start accumulating the new data. */ ++ used = 1 + offset; ++ } ++ ++ /* ok, just accumulate the data as normal */ ++ tmp = section_buf_add(section, payload+used, len - used, section_status); ++ if (*section_status < 0) { ++ section->wait_pdu = 1; ++ } ++ ++ return used + tmp; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/section_buf.h dvb-apps/lib/libucsi/section_buf.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/section_buf.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/section_buf.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,124 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_SECTION_BUF_H ++#define _UCSI_SECTION_BUF_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++ ++#define DVB_MAX_SECTION_BYTES 4096 ++ ++/** ++ * Buffer used to keep track of section fragments. You should allocate an ++ * area of memory of size (sizeof(section_buf) + ), and pass that area ++ * to section_buf_init() to set it up. ++ */ ++struct section_buf { ++ uint32_t max; /* maximum size of section - setup by section_buf_init() */ ++ uint32_t count; /* number of bytes currently accumulated */ ++ uint32_t len; /* total number of bytes expected in the complete section */ ++ uint8_t header:1; /* flag indicating the section header has been commpletely received */ ++ uint8_t wait_pdu:1;/* flag indicating to wait till the next PDU start */ ++ /* uint8_t data[] */ ++}; ++ ++/** ++ * Initialise a section_buf structure. ++ * ++ * @param section The section_buf to initialise. ++ * @param max Maximum number of bytes in section (must be > 3) ++ * @return 0 on success, nonzero on error. ++ */ ++extern int section_buf_init(struct section_buf *section, int max); ++ ++/** ++ * Reset a section_buf structure (e.g. if a discontinuity occurred). The ++ * section_buf will wait for the first PDU start indicator. ++ * ++ * @param section The section_buf to reset. ++ */ ++static inline void section_buf_reset(struct section_buf *section) ++{ ++ int tmp = section->wait_pdu; ++ section_buf_init(section, section->max); ++ section->wait_pdu = tmp; ++} ++ ++/** ++ * Add a data fragment to a section_buf. ++ * ++ * @param section section_buf to add to. ++ * @param frag Pointer to data fragment. ++ * @param len Number of bytes of data. ++ * @param section_status 0: nothing special. 1: section complete. -ERANGE indicates that the ++ * section is larger than section->max. ++ * @return Number of bytes which were consumed. ++ */ ++extern int section_buf_add(struct section_buf *section, uint8_t* frag, int len, int *section_status); ++ ++/** ++ * Add a transport packet PSI payload to a section_buf. This takes into account ++ * the extra byte present in PDU_START flagged packets. ++ * ++ * @param section section_buf to add to. ++ * @param payload Pointer to packet payload data. ++ * @param len Number of bytes of data. ++ * @param pdu_start True if the payload_unit_start_indicator flag was set in the ++ * TS packet. ++ * @param section_status 0: nothing special. 1: section complete. -ERANGE indicates that the ++ * section is larger than section->max. -EINVAL indicates the pointer_field was completely ++ * invalid (too large). ++ */ ++extern int section_buf_add_transport_payload(struct section_buf *section, ++ uint8_t* payload, int len, ++ int pdu_start, int *section_status); ++ ++/** ++ * Get the number of bytes left to be received in a section_buf. ++ * ++ * @param section The section_buf concerned. ++ * @return The number of bytes. ++ */ ++static inline int section_buf_remaining(struct section_buf *section) ++{ ++ return section->len - section->count; ++} ++ ++/** ++ * Return a pointer to the start of the data in the section_buf. ++ * ++ * @param section The section_buf concerned. ++ * @return The data. ++ */ ++static inline uint8_t* section_buf_data(struct section_buf *section) ++{ ++ return (uint8_t*) section + sizeof(struct section_buf); ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/section.h dvb-apps/lib/libucsi/section.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/section.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/section.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,253 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Kenneth Aafloy (kenneth@linuxtv.org) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_SECTION_H ++#define _UCSI_SECTION_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include ++#include ++#include ++#include ++ ++#define CRC_SIZE 4 ++ ++ ++/** ++ * Generic section header. ++ */ ++struct section { ++ uint8_t table_id; ++ EBIT4(uint16_t syntax_indicator : 1; , ++ uint16_t private_indicator : 1; , /* 2.4.4.10 */ ++ uint16_t reserved : 2; , ++ uint16_t length :12; ); ++} __ucsi_packed; ++ ++/** ++ * Generic extended section header structure. ++ */ ++struct section_ext { ++ uint8_t table_id; ++ EBIT4(uint16_t syntax_indicator : 1; , ++ uint16_t private_indicator : 1; , /* 2.4.4.10 */ ++ uint16_t reserved : 2; , ++ uint16_t length :12; ); ++ ++ uint16_t table_id_ext; ++ EBIT3(uint8_t reserved1 : 2; , ++ uint8_t version_number : 5; , ++ uint8_t current_next_indicator : 1; ); ++ uint8_t section_number; ++ uint8_t last_section_number; ++} __ucsi_packed; ++ ++/** ++ * Structure for keeping track of sections of a PSI table. ++ */ ++struct psi_table_state { ++ uint8_t version_number; ++ uint16_t next_section_number; ++ uint8_t complete:1; ++ uint8_t new_table:1; ++} __ucsi_packed; ++ ++ ++/** ++ * Determine the total length of a section, including the header. ++ * ++ * @param section The parsed section structure. ++ * @return The length. ++ */ ++static inline size_t section_length(struct section *section) ++{ ++ return section->length + sizeof(struct section); ++} ++ ++/** ++ * Determine the total length of an extended section, including the header, ++ * but omitting the CRC. ++ * ++ * @param section The parsed section_ext structure. ++ * @return The length. ++ */ ++static inline size_t section_ext_length(struct section_ext * section) ++{ ++ return section->length + sizeof(struct section) - CRC_SIZE; ++} ++ ++/** ++ * Process a section structure in-place. ++ * ++ * @param buf Pointer to the data. ++ * @param len Length of data. ++ * @return Pointer to the section structure, or NULL if invalid. ++ */ ++static inline struct section * section_codec(uint8_t * buf, size_t len) ++{ ++ struct section * ret = (struct section *)buf; ++ ++ if (len < 3) ++ return NULL; ++ ++ bswap16(buf+1); ++ ++ if (len != ret->length + 3U) ++ return NULL; ++ ++ return ret; ++} ++ ++/** ++ * Some sections have a CRC even though they are not section_exts. ++ * This function is to allow checking of them. ++ * ++ * @param section Pointer to the processed section structure. ++ * @return Nonzero on error, or 0 if the CRC was correct. ++ */ ++static inline int section_check_crc(struct section *section) ++{ ++ uint8_t * buf = (uint8_t *) section; ++ size_t len = section_length(section); ++ uint32_t crc; ++ ++ /* the crc check has to be performed on the unswapped data */ ++ bswap16(buf+1); ++ crc = crc32(CRC32_INIT, buf, len); ++ bswap16(buf+1); ++ ++ /* the crc check includes the crc value, ++ * the result should therefore be zero. ++ */ ++ if (crc) ++ return -1; ++ return 0; ++} ++ ++ ++/** ++ * Decode an extended section structure. ++ * ++ * @param section Pointer to the processed section structure. ++ * @param check_crc If 1, the CRC of the section will also be checked. ++ * @return Pointer to the parsed section_ext structure, or NULL if invalid. ++ */ ++static inline struct section_ext * section_ext_decode(struct section * section, ++ int check_crc) ++{ ++ if (section->syntax_indicator == 0) ++ return NULL; ++ ++ if (check_crc) { ++ if (section_check_crc(section)) ++ return NULL; ++ } ++ ++ bswap16((uint8_t *)section + sizeof(struct section)); ++ ++ return (struct section_ext *)section; ++} ++ ++/** ++ * Encode an extended section structure for transmission. ++ * ++ * @param section Pointer to the section_ext structure. ++ * @param update_crc If 1, the CRC of the section will also be updated. ++ * @return Pointer to the encoded section_ext structure, or NULL if invalid. ++ */ ++static inline struct section_ext * section_ext_encode(struct section_ext* section, ++ int update_crc) ++{ ++ if (section->syntax_indicator == 0) ++ return NULL; ++ ++ bswap16((uint8_t *)section + sizeof(struct section)); ++ ++ if (update_crc) { ++ uint8_t * buf = (uint8_t *) section; ++ int len = sizeof(struct section) + section->length; ++ uint32_t crc; ++ ++ /* the crc has to be performed on the swapped data */ ++ bswap16(buf+1); ++ crc = crc32(CRC32_INIT, buf, len-4); ++ bswap16(buf+1); ++ ++ /* update the CRC */ ++ *((uint32_t*) (buf+len-4)) = crc; ++ bswap32(buf+len-4); ++ } ++ ++ return (struct section_ext *)section; ++} ++ ++/** ++ * Reset a psi_table_state structure. ++ * ++ * @param tstate The structure to reset. ++ */ ++static inline void psi_table_state_reset(struct psi_table_state *tstate) ++{ ++ tstate->version_number = 0xff; ++} ++ ++/** ++ * Check if a supplied section_ext is something we want to process. ++ * ++ * @param section The parsed section_ext structure. ++ * @param tstate The state structure for this PSI table. ++ * @return 0=> not useful. nonzero => useful. ++ */ ++static inline int section_ext_useful(struct section_ext *section, struct psi_table_state *tstate) ++{ ++ if ((section->version_number == tstate->version_number) && tstate->complete) ++ return 0; ++ if (section->version_number != tstate->version_number) { ++ if (section->section_number != 0) ++ return 0; ++ ++ tstate->next_section_number = 0; ++ tstate->complete = 0; ++ tstate->version_number = section->version_number; ++ tstate->new_table = 1; ++ } else if (section->section_number == tstate->next_section_number) { ++ tstate->new_table = 0; ++ } else { ++ return 0; ++ } ++ ++ tstate->next_section_number++; ++ if (section->last_section_number < tstate->next_section_number) { ++ tstate->complete = 1; ++ } ++ ++ return 1; ++} ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/testrecord.txt dvb-apps/lib/libucsi/testrecord.txt +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/testrecord.txt 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/testrecord.txt 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,146 @@ ++libucsi test record. Anything without PASS is either not tested, or is ++currently broken. ++ ++Testing means (a) ensure there are no segfaults etc. (b) dump the raw hex, ++decode it by hand, and check it matches the output. ++ ++Sections: ++PASS mpeg/cat_section.h ++ mpeg/odsmt_section.h ++PASS mpeg/pat_section.h ++PASS mpeg/pmt_section.h ++ mpeg/tsdt_section.h ++ mpeg/metadata_section.h ++ ++PASS dvb/bat_section.h ++ dvb/dit_section.h ++PASS dvb/eit_section.h ++ dvb/int_section.h ++PASS dvb/nit_section.h ++ dvb/rst_section.h ++PASS dvb/sdt_section.h ++ dvb/sit_section.h ++PASS dvb/st_section.h ++PASS dvb/tdt_section.h ++PASS dvb/tot_section.h ++ dvb/tva_container_section.h ++ ++PASS atsc/cvct_section.h ++ atsc/dccsct_section.h ++ atsc/dcct_section.h ++PASS atsc/eit_section.h ++PASS atsc/ett_section.h ++PASS atsc/mgt_section.h ++ atsc/rrt_section.h ++PASS atsc/stt_section.h ++PASS atsc/tvct_section.h ++ ++Descriptors: ++PASS mpeg/audio_stream_descriptor.h ++PASS mpeg/ca_descriptor.h ++ mpeg/content_labelling_descriptor.h ++PASS mpeg/copyright_descriptor.h ++PASS mpeg/data_stream_alignment_descriptor.h ++PASS mpeg/external_es_id_descriptor.h ++ mpeg/fmc_descriptor.h ++PASS mpeg/fmxbuffer_size_descriptor.h ++ mpeg/hierarchy_descriptor.h ++ mpeg/ibp_descriptor.h ++ mpeg/iod_descriptor.h ++PASS mpeg/iso_639_language_descriptor.h ++PASS mpeg/maximum_bitrate_descriptor.h ++ mpeg/metadata_descriptor.h ++ mpeg/metadata_pointer_descriptor.h ++ mpeg/metadata_std_descriptor.h ++ mpeg/mpeg4_audio_descriptor.h ++ mpeg/mpeg4_video_descriptor.h ++ mpeg/multiplex_buffer_descriptor.h ++PASS mpeg/multiplex_buffer_utilization_descriptor.h ++ mpeg/muxcode_descriptor.h ++PASS mpeg/private_data_indicator_descriptor.h ++PASS mpeg/registration_descriptor.h ++ mpeg/sl_descriptor.h ++PASS mpeg/smoothing_buffer_descriptor.h ++PASS mpeg/std_descriptor.h ++PASS mpeg/system_clock_descriptor.h ++ mpeg/target_background_grid_descriptor.h ++PASS mpeg/video_stream_descriptor.h ++ mpeg/video_window_descriptor.h ++ ++ dvb/ac3_descriptor.h ++ dvb/adaptation_field_data_descriptor.h ++ dvb/ait_application_descriptor.h ++ dvb/ait_application_icons_descriptor.h ++ dvb/ait_application_name_descriptor.h ++ dvb/ait_external_application_authorisation_descriptor.h ++ dvb/ancillary_data_descriptor.h ++ dvb/announcement_support_descriptor.h ++ dvb/application_signalling_descriptor.h ++PASS dvb/bouquet_name_descriptor.h ++PASS dvb/ca_identifier_descriptor.h ++ dvb/cable_delivery_descriptor.h ++ dvb/cell_frequency_link_descriptor.h ++ dvb/cell_list_descriptor.h ++PASS dvb/component_descriptor.h ++PASS dvb/content_descriptor.h ++ dvb/content_identifier_descriptor.h ++ dvb/country_availability_descriptor.h ++ dvb/data_broadcast_descriptor.h ++PASS dvb/data_broadcast_id_descriptor.h ++ dvb/default_authority_descriptor.h ++ dvb/dsng_descriptor.h ++ dvb/extended_event_descriptor.h ++PASS dvb/frequency_list_descriptor.h ++PASS dvb/linkage_descriptor.h ++PASS dvb/local_time_offset_descriptor.h ++ dvb/mhp_data_broadcast_id_descriptor.h ++ dvb/mosaic_descriptor.h ++ dvb/multilingual_bouquet_name_descriptor.h ++PASS dvb/multilingual_component_descriptor.h ++ dvb/multilingual_network_name_descriptor.h ++ dvb/multilingual_service_name_descriptor.h ++PASS dvb/network_name_descriptor.h ++ dvb/nvod_reference_descriptor.h ++PASS dvb/parental_rating_descriptor.h ++ dvb/partial_transport_stream_descriptor.h ++ dvb/pdc_descriptor.h ++PASS dvb/private_data_specifier_descriptor.h ++ dvb/related_content_descriptor.h ++ dvb/rnt_rar_over_dvb_stream_descriptor.h ++ dvb/rnt_rar_over_ip_descriptor.h ++ dvb/rnt_rnt_scan_descriptor.h ++ dvb/s2_satellite_delivery_descriptor.h ++PASS dvb/satellite_delivery_descriptor.h ++ dvb/scrambling_descriptor.h ++ dvb/service_availablility_descriptor.h ++PASS dvb/service_descriptor.h ++ dvb/service_identifier_descriptor.h ++PASS dvb/service_list_descriptor.h ++ dvb/service_move_descriptor.h ++PASS dvb/short_event_descriptor.h ++ dvb/short_smoothing_buffer_descriptor.h ++PASS dvb/stream_identifier_descriptor.h ++PASS dvb/stuffing_descriptor.h ++PASS dvb/subtitling_descriptor.h ++ dvb/telephone_descriptor.h ++ dvb/teletext_descriptor.h ++PASS dvb/terrestrial_delivery_descriptor.h ++ dvb/time_shifted_event_descriptor.h ++ dvb/time_shifted_service_descriptor.h ++ dvb/transport_stream_descriptor.h ++ dvb/tva_id_descriptor.h ++ dvb/vbi_data_descriptor.h ++ dvb/vbi_teletext_descriptor.h ++ ++PASS atsc/ac3_descriptor.h ++PASS atsc/caption_service_descriptor.h ++ atsc/component_name_descriptor.h ++PASS atsc/content_advisory_descriptor.h ++ atsc/dcc_arriving_request_descriptor.h ++ atsc/dcc_departing_request_descriptor.h ++PASS atsc/extended_channel_name_descriptor.h ++ atsc/genre_descriptor.h ++ atsc/rc_descriptor.h ++PASS atsc/service_location_descriptor.h ++PASS atsc/stuffing_descriptor.h ++ atsc/time_shifted_service_descriptor.h +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/transport_packet.c dvb-apps/lib/libucsi/transport_packet.c +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/transport_packet.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/transport_packet.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,256 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include "transport_packet.h" ++ ++#define CONTINUITY_VALID 0x80 ++#define CONTINUITY_DUPESEEN 0x40 ++ ++int transport_packet_values_extract(struct transport_packet *pkt, ++ struct transport_values *out, ++ enum transport_value extract) ++{ ++ uint8_t *end = (uint8_t*) pkt + TRANSPORT_PACKET_LENGTH; ++ uint8_t *adapend; ++ uint8_t *pos = (uint8_t*) pkt + sizeof(struct transport_packet); ++ enum transport_value extracted = 0; ++ enum transport_adaptation_flags adapflags = 0; ++ enum transport_adaptation_extension_flags adapextflags = 0; ++ int adaplength = 0; ++ int adapextlength = 0; ++ ++ /* does the packet contain an adaptation field ? */ ++ if ((pkt->adaptation_field_control & 2) == 0) ++ goto extract_payload; ++ ++ /* get the adaptation field length and skip the byte */ ++ adaplength = *pos++; ++ ++ /* do we actually have any adaptation data? */ ++ if (adaplength == 0) ++ goto extract_payload; ++ ++ /* sanity check */ ++ adapend = pos + adaplength; ++ if (adapend > end) ++ return -1; ++ ++ /* extract the adaptation flags (we must have at least 1 byte to be here) */ ++ adapflags = *pos++; ++ ++ /* do we actually want anything else? */ ++ if ((extract & 0xffff) == 0) ++ goto extract_payload; ++ ++ /* PCR? */ ++ if (adapflags & transport_adaptation_flag_pcr) { ++ if ((pos+6) > adapend) ++ return -1; ++ ++ if (extract & transport_value_pcr) { ++ uint64_t base = ((uint64_t) pos[0] << 25) | ++ ((uint64_t) pos[1] << 17) | ++ ((uint64_t) pos[2] << 9) | ++ ((uint64_t) pos[3] << 1) | ++ ((uint64_t) pos[4] >> 7); ++ uint64_t ext = (((uint64_t) pos[4] & 1) << 8) | ++ (uint64_t) pos[5]; ++ out->pcr= base * 300ULL + ext; ++ extracted |= transport_value_pcr; ++ } ++ pos += 6; ++ } ++ ++ /* OPCR? */ ++ if (adapflags & transport_adaptation_flag_opcr) { ++ if ((pos+6) > adapend) ++ return -1; ++ ++ if (extract & transport_value_opcr) { ++ uint64_t base = ((uint64_t) pos[0] << 25) | ++ ((uint64_t) pos[1] << 17) | ++ ((uint64_t) pos[2] << 9) | ++ ((uint64_t) pos[3] << 1) | ++ ((uint64_t) pos[4] >> 7); ++ uint64_t ext = (((uint64_t) pos[4] & 1) << 8) | ++ (uint64_t) pos[5]; ++ out->opcr= base * 300ULL + ext; ++ extracted |= transport_value_opcr; ++ } ++ pos += 6; ++ } ++ ++ /* splice countdown? */ ++ if (adapflags & transport_adaptation_flag_splicing_point) { ++ if ((pos+1) > adapend) ++ return -1; ++ ++ if (extract & transport_value_splice_countdown) { ++ out->splice_countdown = *pos; ++ extracted |= transport_value_splice_countdown; ++ } ++ pos++; ++ } ++ ++ /* private data? */ ++ if (adapflags & transport_adaptation_flag_private_data) { ++ if ((pos+1) > adapend) ++ return -1; ++ if ((pos+1+*pos) > adapend) ++ return -1; ++ ++ if (extract & transport_value_private_data) { ++ out->private_data_length = *pos; ++ out->private_data = pos + 1; ++ extracted |= transport_value_private_data; ++ } ++ pos += 1 + *pos; ++ } ++ ++ /* is there an adaptation extension? */ ++ if (!(adapflags & transport_adaptation_flag_extension)) ++ goto extract_payload; ++ ++ /* get/check the length */ ++ if (pos >= adapend) ++ return -1; ++ adapextlength = *pos++; ++ if ((pos + adapextlength) > adapend) ++ return -1; ++ ++ /* do we want/have anything in the adaptation extension? */ ++ if (((extract & 0xff00) == 0) || (adapextlength == 0)) ++ goto extract_payload; ++ ++ /* extract the adaptation extension flags (we must have at least 1 byte ++ * to be here) */ ++ adapextflags = *pos++; ++ ++ /* LTW? */ ++ if (adapextflags & transport_adaptation_extension_flag_ltw) { ++ if ((pos+2) > adapend) ++ return -1; ++ ++ if (extract & transport_value_ltw) { ++ if (*pos & 0x80) { ++ out->ltw_offset = ((pos[0] & 0x7f) << 8) | ++ (pos[1]); ++ extracted |= transport_value_ltw; ++ } ++ } ++ pos += 2; ++ } ++ ++ /* piecewise_rate? */ ++ if (adapextflags & transport_adaptation_extension_flag_piecewise_rate) { ++ if ((pos+3) > adapend) ++ return -1; ++ ++ if (extract & transport_value_piecewise_rate) { ++ out->piecewise_rate = ((pos[0] & 0x3f) << 16) | ++ (pos[1] << 8) | ++ pos[2]; ++ extracted |= transport_value_piecewise_rate; ++ } ++ pos += 3; ++ } ++ ++ /* seamless_splice? */ ++ if (adapextflags & transport_adaptation_extension_flag_seamless_splice) { ++ if ((pos+5) > adapend) ++ return -1; ++ ++ if (extract & transport_value_piecewise_rate) { ++ out->splice_type = pos[0] >> 4; ++ out->dts_next_au = ((pos[0] & 0x0e) << 29) | ++ (pos[1] << 22) | ++ ((pos[2] & 0xfe) << 14) | ++ (pos[3] << 7) | ++ ((pos[4] & 0xfe) >> 1); ++ extracted |= transport_value_seamless_splice; ++ } ++ pos += 5; ++ } ++ ++ ++ ++extract_payload: ++ /* does the packet contain a payload? */ ++ if (pkt->adaptation_field_control & 1) { ++ int off = sizeof(struct transport_packet); ++ if (pkt->adaptation_field_control & 2) ++ off++; ++ off += adaplength; ++ ++ out->payload = (uint8_t*) pkt + off; ++ out->payload_length = TRANSPORT_PACKET_LENGTH - off; ++ } else { ++ out->payload = NULL; ++ out->payload_length = 0; ++ } ++ ++ out->flags = adapflags; ++ return extracted; ++} ++ ++int transport_packet_continuity_check(struct transport_packet *pkt, ++ int discontinuity_indicator, unsigned char *cstate) ++{ ++ unsigned char pktcontinuity = pkt->continuity_counter; ++ unsigned char prevcontinuity = *cstate & 0x0f; ++ unsigned char nextcontinuity; ++ ++ /* NULL packets have undefined continuity */ ++ if (transport_packet_pid(pkt) == TRANSPORT_NULL_PID) ++ return 0; ++ ++ /* is the state valid? */ ++ if (!(*cstate & CONTINUITY_VALID)) { ++ *cstate = pktcontinuity | CONTINUITY_VALID; ++ return 0; ++ } ++ ++ /* check for discontinuity_indicator */ ++ if (discontinuity_indicator) { ++ *cstate = pktcontinuity | CONTINUITY_VALID; ++ return 0; ++ } ++ ++ /* only packets with a payload should increment the counter */ ++ if (pkt->adaptation_field_control & 1) ++ nextcontinuity = (prevcontinuity + 1) & 0xf; ++ else ++ nextcontinuity = prevcontinuity; ++ ++ /* check for a normal continuity progression */ ++ if (nextcontinuity == pktcontinuity) { ++ *cstate = pktcontinuity | CONTINUITY_VALID; ++ return 0; ++ } ++ ++ /* one dupe is allowed */ ++ if ((prevcontinuity == pktcontinuity) && (!(*cstate & CONTINUITY_DUPESEEN))) { ++ *cstate = pktcontinuity | (CONTINUITY_VALID|CONTINUITY_DUPESEEN); ++ return 0; ++ } ++ ++ /* continuity error */ ++ return -1; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/transport_packet.h dvb-apps/lib/libucsi/transport_packet.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/transport_packet.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/transport_packet.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,195 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_TRANSPORT_PACKET_H ++#define _UCSI_TRANSPORT_PACKET_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++#include ++#include "descriptor.h" ++ ++#define TRANSPORT_PACKET_LENGTH 188 ++#define TRANSPORT_PACKET_SYNC 0x47 ++#define TRANSPORT_MAX_PIDS 0x2000 ++#define TRANSPORT_NULL_PID 0x1fff ++ ++ ++/** ++ * Enumeration of adaptation field control values. ++ */ ++enum transport_adaptation_field_control { ++ transport_adaptation_field_control_reserved = 0x00, ++ transport_adaptation_field_control_payload_only = 0x01, ++ transport_adaptation_field_control_adaptation_only = 0x02, ++ transport_adaptation_field_control_adaptation_payload = 0x03, ++}; ++ ++/** ++ * Enumeration of scrambling control values. ++ */ ++enum transport_scrambling_control { ++ transport_scrambling_control_unscrambled = 0x00, ++ transport_scrambling_control_user_1 = 0x01, ++ transport_scrambling_control_user_2 = 0x02, ++ transport_scrambling_control_user_3 = 0x03, ++}; ++ ++/** ++ * Enumeration of adaptation flags. ++ */ ++enum transport_adaptation_flags { ++ transport_adaptation_flag_discontinuity = 0x80, ++ transport_adaptation_flag_random_access = 0x40, ++ transport_adaptation_flag_es_priority = 0x20, ++ transport_adaptation_flag_pcr = 0x10, ++ transport_adaptation_flag_opcr = 0x08, ++ transport_adaptation_flag_splicing_point = 0x04, ++ transport_adaptation_flag_private_data = 0x02, ++ transport_adaptation_flag_extension = 0x01, ++}; ++ ++/** ++ * Enumeration of adaptation extension flags. ++ */ ++enum transport_adaptation_extension_flags { ++ transport_adaptation_extension_flag_ltw = 0x80, ++ transport_adaptation_extension_flag_piecewise_rate = 0x40, ++ transport_adaptation_extension_flag_seamless_splice = 0x20, ++}; ++ ++/** ++ * Enumeration of flags controlling which values to extract using the ++ * transport_packet_values_extract() function. ++ */ ++enum transport_value { ++ /* normal adaptation */ ++ transport_value_pcr = 0x0001, ++ transport_value_opcr = 0x0002, ++ transport_value_splice_countdown = 0x0004, ++ transport_value_private_data = 0x0008, ++ ++ /* extension adaptation */ ++ transport_value_ltw = 0x0100, ++ transport_value_piecewise_rate = 0x0200, ++ transport_value_seamless_splice = 0x0400, ++}; ++ ++/** ++ * Structure describing a transport packet header. ++ */ ++struct transport_packet { ++ uint8_t sync_byte; ++ EBIT4(uint8_t transport_error_indicator : 1; , ++ uint8_t payload_unit_start_indicator : 1; , ++ uint8_t transport_priority : 1; , ++ uint8_t pid_hi : 5; ); ++ uint8_t pid_lo; ++ EBIT3(uint8_t transport_scrambling_control : 2; , ++ uint8_t adaptation_field_control : 2; , ++ uint8_t continuity_counter : 4; ); ++ /* values */ ++} __ucsi_packed; ++ ++/** ++ * Structure to extract values into using the transport_packet_values_extract() ++ * function. ++ */ ++struct transport_values { ++ enum transport_adaptation_flags flags; /* always extracted */ ++ uint8_t *payload; /* always extracted */ ++ uint16_t payload_length; /* always extracted */ ++ ++ uint64_t pcr; ++ uint64_t opcr; ++ uint8_t splice_countdown; ++ uint8_t private_data_length; ++ uint8_t *private_data; ++ uint16_t ltw_offset; ++ uint32_t piecewise_rate; ++ uint8_t splice_type; ++ uint64_t dts_next_au; ++}; ++ ++/** ++ * Extract the PID from a transport packet. ++ * ++ * @param pkt The packet. ++ * @return The PID. ++ */ ++static inline int transport_packet_pid(struct transport_packet *pkt) ++{ ++ return (pkt->pid_hi << 8) | (pkt->pid_lo); ++} ++ ++/** ++ * Process a buffer into a transport packet. ++ * ++ * @param buf Raw buffer. Note, this function assumes there are 188 bytes available. ++ * @return transport_packet pointer, or NULL on error. ++ */ ++static inline struct transport_packet *transport_packet_init(unsigned char *buf) ++{ ++ struct transport_packet *pkt = (struct transport_packet*) buf; ++ ++ if (pkt->sync_byte != TRANSPORT_PACKET_SYNC) ++ return NULL; ++ ++ if (transport_packet_pid(pkt) >= TRANSPORT_MAX_PIDS) ++ return NULL; ++ ++ return pkt; ++} ++ ++/** ++ * Check the continuity counter for a packet in a PID stream. ++ * ++ * @param pkt transport_packet to check. ++ * @param discontinuity_indicator Set to 1 if the packet's discontinuity_indicator flag is set. ++ * @param cstate Pointer to a single 8 bit character, used to store state for validating ++ * continuity. To initialise the state, simply set it to 0 before the first call. ++ * @return 0 if the continuity was correct, or nonzero on error. cstate will not be updated on error, ++ * it is up to the caller to clear it to accept the next packet. ++ */ ++extern int transport_packet_continuity_check(struct transport_packet *pkt, ++ int discontinuity_indicator, unsigned char *cstate); ++ ++/** ++ * Extract selected fields from a transport packet. ++ * ++ * @param pkt The packet. ++ * @param out Destination structure for values. ++ * @param extract Orred bitmask of enum transport_value - tells it what fields ++ * to extract if they are available. ++ * @return < 0 => error. Otherwise, an orred bitmask of enum transport_value ++ * telling you what fields were successfully extracted. ++ */ ++extern int transport_packet_values_extract(struct transport_packet *pkt, ++ struct transport_values *out, ++ enum transport_value extract); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/libucsi/types.h dvb-apps/lib/libucsi/types.h +--- linuxtv-dvb-apps-1.1.1/lib/libucsi/types.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/libucsi/types.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,36 @@ ++/* ++ * section and descriptor parser ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#ifndef _UCSI_TYPES_H ++#define _UCSI_TYPES_H 1 ++ ++#ifdef __cplusplus ++extern "C" ++{ ++#endif ++ ++typedef uint8_t iso639lang_t[3]; ++typedef uint8_t iso639country_t[3]; ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Nurd linuxtv-dvb-apps-1.1.1/lib/Makefile dvb-apps/lib/Makefile +--- linuxtv-dvb-apps-1.1.1/lib/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/lib/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,11 @@ ++# Makefile for linuxtv.org dvb-apps/lib ++ ++.PHONY: all clean install ++ ++all clean install: ++ $(MAKE) -C libdvbapi $@ ++ $(MAKE) -C libdvbcfg $@ ++ $(MAKE) -C libdvben50221 $@ ++ $(MAKE) -C libdvbsec $@ ++ $(MAKE) -C libesg $@ ++ $(MAKE) -C libucsi $@ +diff -Nurd linuxtv-dvb-apps-1.1.1/libdvb2/README dvb-apps/libdvb2/README +--- linuxtv-dvb-apps-1.1.1/libdvb2/README 2004-01-17 17:59:46.000000000 +0100 ++++ dvb-apps/libdvb2/README 1970-01-01 01:00:00.000000000 +0100 +@@ -1,23 +0,0 @@ +-Late in 2003 the idea to create a simple DVB library from the code snippets +-in the test/utility programs was discussed on the linux-dvb mailing list. +-Hopefully someone will invest some time in this project to turn the idea into +-reality... +- +-Here is an outline of what libdvb2 should be, according to my recollection: +-(For first hand information search the linux-dvb list archives for "libdvb2".) +- +-- C +-- small: The goal is to make the library usable in *any* DVB project, which +- is easier if the library sticks to the basics. Advanced stuff can be +- done in a second library. What exacty "basic" and "advanced" means +- is subject of discussion, but I want avoid to impose a certain programming +- model (e.g. multi-threaded vw. event-loop) on users of the library. +-- a prime target is to establish a standard DVB config and service list +- format, to make this sharable between different applications +-- LGPL +- +-About the name: There already is a libdvb written by the Metzler Bros., +-but the main drawback is that it is written in C++ and thus rejected +-by many projects. +- +-Johannes Stezenbach +diff -Nurd linuxtv-dvb-apps-1.1.1/Makefile dvb-apps/Makefile +--- linuxtv-dvb-apps-1.1.1/Makefile 2004-02-04 19:41:55.000000000 +0100 ++++ dvb-apps/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -1,28 +1,12 @@ + # Makefile for linuxtv.org dvb-apps + +-VERSION := 1.1.0 +-PACKAGE := linuxtv-dvb-apps-$(VERSION) +-CVSROOT := $(shell cat CVS/Root) +-RELEASE_TAG := LINUXTV-DVB-$(subst .,_,$(subst -,_,$(VERSION))) +- +-all: ++.PHONY: all clean install update + +-release dist: +- rm -rf release-tmp $(PACKAGE).tar.gz +- mkdir release-tmp +- ( cd release-tmp; cvs -d$(CVSROOT) export -r$(RELEASE_TAG) -d$(PACKAGE) dvb-apps ) +- find release-tmp -name .cvsignore | xargs rm -v +- ( cd release-tmp; tar cjf ../$(PACKAGE).tar.bz2 $(PACKAGE) ) +- rm -rf release-tmp +- @echo +- @echo -------------------------------------------------------------------------------- +- @echo +- @echo "dist package: ./$(PACKAGE).tar.bz2" +- @echo +- @echo -------------------------------------------------------------------------------- +- @echo ++all clean install: ++ $(MAKE) -C lib $@ ++ $(MAKE) -C test $@ ++ $(MAKE) -C util $@ + +-%:: +-# $(MAKE) -C libdvb2 $(MAKECMDGOALS) +- $(MAKE) -C util $(MAKECMDGOALS) +- $(MAKE) -C test $(MAKECMDGOALS) ++update: ++ @echo "Pulling changes & updating from master repository" ++ hg pull -u +diff -Nurd linuxtv-dvb-apps-1.1.1/Make.rules dvb-apps/Make.rules +--- linuxtv-dvb-apps-1.1.1/Make.rules 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/Make.rules 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,104 @@ ++# build rules for linuxtv.org dvb-apps ++ ++CFLAGS ?= -g -Wall -W -Wshadow -Wpointer-arith -Wstrict-prototypes ++ ++ifneq ($(lib_name),) ++ ++# additional rules for libraries ++ ++CFLAGS_LIB ?= -fPIC ++CFLAGS += $(CFLAGS_LIB) ++ ++libraries = $(lib_name).so $(lib_name).a ++ ++.PHONY: library ++ ++library: $(libraries) ++ ++$(libraries): $(objects) ++ ++endif ++ ++prerequisites = $(subst .o,.d,$(objects)) $(addsuffix .d,$(binaries)) ++ ++.PHONY: clean install ++ ++ifeq ($(static),1) ++LDFLAGS += -static ++endif ++ ++prefix ?= /usr ++ ++bindir ?= $(prefix)/bin ++includedir ?= $(prefix)/include ++libdir ?= $(prefix)/lib ++sharedir ?= $(prefix)/share ++ ++ifneq ($(DESTDIR),) ++DESTDIR = $(DESTDIR)/ ++endif ++ ++ifeq ($(V),1) ++%.o: %.c ++ $(CC) -c $(CPPFLAGS) $(CFLAGS) -MMD -o $@ $< $(filter-out %.h %.c,$^) ++%: %.o ++ $(CC) $(LDFLAGS) -o $@ $^ $(LOADLIBES) $(LDLIBS) ++%: %.c ++ $(CC) $(CPPFLAGS) $(CFLAGS) -MMD $(LDFLAGS) -o $@ $< $(filter-out %.h %.c,$^) $(LOADLIBES) $(LDLIBS) ++%.so: ++ $(CC) -shared -o $@ $^ ++%.a: ++ $(AR) rcs $@ $^ ++clean:: ++ $(RM) -f $(prerequisites) $(objects) $(libraries) $(binaries) $(removing) *~ ++install:: ++ifneq ($(includes),) ++ mkdir -p $(DESTDIR)$(includedir)/$(lib_name) ++ install -m 644 $(includes) $(DESTDIR)$(includedir)/$(lib_name)/ ++endif ++ifneq ($(libraries),) ++ mkdir -p $(DESTDIR)$(libdir) ++ install -m 644 $(libraries) $(DESTDIR)$(libdir)/ ++endif ++ifneq ($(inst_bin),) ++ mkdir -p $(DESTDIR)$(bindir) ++ install -m 755 $(inst_bin) $(DESTDIR)$(bindir)/ ++endif ++else ++%.o: %.c ++ @echo CC $@ ++ @$(CC) -c $(CPPFLAGS) $(CFLAGS) -MMD -o $@ $< $(filter-out %.h %.c,$^) ++%: %.o ++ @echo CC $@ ++ @$(CC) $(LDFLAGS) -o $@ $^ $(LOADLIBES) $(LDLIBS) ++%: %.c ++ @echo CC $@ ++ @$(CC) $(CPPFLAGS) $(CFLAGS) -MMD $(LDFLAGS) -o $@ $< $(filter-out %.h %.c,$^) $(LOADLIBES) $(LDLIBS) ++%.so: ++ @echo CC $@ ++ @$(CC) -shared -o $@ $^ ++%.a: ++ @echo AR $@ ++ @$(AR) rcs $@ $^ ++clean:: ++ @echo cleaning ++ @$(RM) -f $(prerequisites) $(objects) $(libraries) $(binaries) $(removing) *~ ++install:: ++ifneq ($(includes),) ++ @echo installing headers ++ @mkdir -p $(DESTDIR)$(includedir)/$(lib_name) ++ @install -m 644 $(includes) $(DESTDIR)$(includedir)/$(lib_name)/ ++endif ++ifneq ($(libraries),) ++ @echo installing libraries ++ @mkdir -p $(DESTDIR)$(libdir) ++ @install -m 644 $(libraries) $(DESTDIR)$(libdir)/ ++endif ++ifneq ($(inst_bin),) ++ @echo installing binaries ++ @mkdir -p $(DESTDIR)$(bindir) ++ @install -m 755 $(inst_bin) $(DESTDIR)$(bindir)/ ++endif ++endif ++ ++-include $(prerequisites) +diff -Nurd linuxtv-dvb-apps-1.1.1/README dvb-apps/README +--- linuxtv-dvb-apps-1.1.1/README 2006-05-18 01:37:39.000000000 +0200 ++++ dvb-apps/README 2009-06-21 13:29:06.000000000 +0200 +@@ -1,28 +1,40 @@ +-linuxtv-dvb-apps-1.1.1 ++linuxtv-dvb-apps-1.? + ====================== + +-Linux DVB API test/demo applications and utilities. ++Linux DVB API applications and utilities. + +-You find a README in each subdirectory explaining what the code there does. +-For beginners utils/szap/ and utils/scan/ are probably most useful. ++All applications support the DVB-S, DVB-C, DVB-T, and ATSC standards. + +-For convenience, dvb-apps contains a copy of the DVB API include +-files as they are contained in the linuxtv-dvb-1.1.0 realease +-and the 2.6.x Linux kernel. However, since the DVB API hasn't changed, +-the apps will still work with the old "DVB" drivers, should you decide not +-to use linuxtv-dvb-1.1.0 (or the dvb-kernel CVS). ++Main User Applications: ++util/scan - Scan for channels on your digital TV device. ++util/gnutv - Tune, watch and stream your TV. + ++General Utilities: ++util/dvbdate - Set your clock from digital TV. ++util/dvbnet - Control digital data network interfaces. ++util/dvbtraffic - Monitor traffic on a digital device. ++util/femon - Monitor the tuning on a digital TV device. ++util/zap - *Just* tunes a digital device - really intended for developers. + +-Historical note: +-The apps have been copied from the "DVB" CVS tree, which means that +-the stuff in "DVB" is now unmaintained and out of date. ++Hardware Specific Utilities: ++util/av7110_loadkeys - Load remote keys into an av7110 based card ++util/dib3000-watch - Monitor DIB3000 demodulators ++util/dst-utils - Utilities for DST based cards. ++util/ttusb_dec_reset - Reset a TechnoTrends TTUSB DEC device. + ++Libraries: ++lib/libdvbapi - Interface library to digital TV devices. ++lib/libdvbcfg - Library to parse/create digital TV channel configuration files. ++lib/libdvbsec - Library for Satellite Equipment Control operations. ++lib/libucsi - Fast MPEG2 Transport Stream SI table parsing library. ++lib/libdvben50221- Complete implementation of a Cenelec EN 50221 CAM stack. ++lib/libdvbmisc - Miscellaneous utilities used by the other libraries. + +-Johannes Stezenbach ++Various testing applications also live in test. + +-This is an interim point release adding support for ATSC to the 1.1.0 release. +-dvb-apps is currently being rewritten completely with new standardised DVB +-libraries for all aspects of DVB, ca support etc, so expect a 1.2.0 release +-at some point soon. ++For convenience, dvb-apps contains a copy of the DVB API include ++files as they are contained in the linuxtv-dvb-1.? release ++and the 2.6.x Linux kernel. + ++Johannes Stezenbach + Andrew de Quincey +diff -Nurd linuxtv-dvb-apps-1.1.1/test/dia dvb-apps/test/dia +--- linuxtv-dvb-apps-1.1.1/test/dia 2004-01-17 17:59:46.000000000 +0100 ++++ dvb-apps/test/dia 2009-06-21 13:29:06.000000000 +0200 +@@ -4,4 +4,4 @@ + do /usr/X11R6/bin/convert -geomtry 702x576 $f test.mpg + test_video test.mpg + rm test.mpg +-done +\ No newline at end of file ++done +diff -Nurd linuxtv-dvb-apps-1.1.1/test/diseqc.c dvb-apps/test/diseqc.c +--- linuxtv-dvb-apps-1.1.1/test/diseqc.c 2004-01-17 17:59:46.000000000 +0100 ++++ dvb-apps/test/diseqc.c 2009-06-21 13:29:06.000000000 +0200 +@@ -1,11 +1,13 @@ +-/* +- * Test sending DiSEqC commands on a SAT frontend. +- * +- * usage: FRONTEND=/dev/dvb/adapterX/frontendX diseqc [test_seq_no] +- */ ++#define USAGE \ ++"\n" \ ++"\nTest sending DiSEqC commands on a SAT frontend." \ ++"\n" \ ++"\nusage: FRONTEND=/dev/dvb/adapterX/frontendX diseqc [test_seq_no|'all']" \ ++"\n" + + #include + #include ++#include + #include + #include + #include +@@ -109,7 +111,10 @@ + return -1; + } + +- if (argc > 1) { ++ if (argc != 2) { ++ fprintf (stderr, "usage: %s [number|'all']\n" USAGE, argv[0]); ++ return 1; ++ } else if (strcmp(argv[1], "all")) { + int i = atol(argv[1]); + cmd[0] = &switch_cmds[i]; + diseqc_send_msg(fd, +@@ -136,5 +141,3 @@ + + return 0; + } +- +- +diff -Nurd linuxtv-dvb-apps-1.1.1/test/evtest.c dvb-apps/test/evtest.c +--- linuxtv-dvb-apps-1.1.1/test/evtest.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/test/evtest.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,251 @@ ++/* ++ * $Id: evtest.c,v 1.3 2005/08/15 20:43:52 js Exp $ ++ * ++ * Copyright (c) 1999-2000 Vojtech Pavlik ++ * ++ * Event device test program ++ */ ++ ++/* ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ * ++ * Should you need to contact me, the author, you can do so either by ++ * e-mail - mail your message to , or by paper mail: ++ * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic ++ */ ++ ++#include ++ ++#include ++#include ++#include ++#include ++#include ++ ++char *events[EV_MAX + 1] = { "Sync", "Key", "Relative", "Absolute", "Misc", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++NULL, NULL, NULL, "LED", "Sound", NULL, "Repeat", "ForceFeedback", "Power", "ForceFeedbackStatus"}; ++char *syncs[2] = { "Sync", "Config"}; ++char *keys[KEY_MAX + 1] = { ++ // 0x000 ++ "Reserved", "Esc", "1", "2", "3", "4", "5", "6", ++ "7", "8", "9", "0", "Minus", "Equal", "Backspace", "Tab", ++ // 0x010 ++ "Q", "W", "E", "R", "T", "Y", "U", "I", ++ "O", "P", "LeftBrace", "RightBrace", "Enter", "LeftControl", "A", "S", ++ // 0x020 ++ "D", "F", "G", "H", "J", "K", "L", "Semicolon", ++ "Apostrophe", "Grave", "LeftShift", "BackSlash", "Z", "X", "C", "V", ++ // 0x030 ++ "B", "N", "M", "Comma", "Dot", "Slash", "RightShift", "KPAsterisk", ++ "LeftAlt", "Space", "CapsLock", "F1", "F2", "F3", "F4", "F5", ++ // 0x040 ++ "F6", "F7", "F8", "F9", "F10", "NumLock", "ScrollLock", "KP7", ++ "KP8", "KP9", "KPMinus", "KP4", "KP5", "KP6", "KPPlus", "KP1", ++ // 0x050 ++ "KP2", "KP3", "KP0", "KPDot", NULL, "ZENKAKUHANKAKU", "102nd", "F11", ++ "F12", "RO", "KATAKANA", "HIRAGANA", "HENKAN", "KATAKANAHIRAGANA", "MUHENKAN", "KPJPCOMMA", ++ // 0x060 ++ "KPEnter", "RightCtrl", "KPSlash", "SysRq", "RightAlt", "LineFeed", "Home", "Up", ++ "PageUp", "Left", "Right", "End", "Down", "PageDown", "Insert", "Delete", ++ // 0x070 ++ "Macro", "Mute", "VolumeDown", "VolumeUp", "Power", "KPEqual", "KPPlusMinus", "Pause", ++ NULL, "KPComma", "HANGUEL", "HANJA", "YEN", "LeftMeta", "RightMeta", "Compose", ++ // 0x080 ++ "Stop", "Again", "Props", "Undo", "Front", "Copy", "Open", "Paste", ++ "Find", "Cut", "Help", "Menu", "Calc", "Setup", "Sleep", "WakeUp", ++ // 0x090 ++ "File", "SendFile", "DeleteFile", "X-fer", "Prog1", "Prog2", "WWW", "MSDOS", ++ "Coffee", "Direction", "CycleWindows", "Mail", "Bookmarks", "Computer", "Back", "Forward", ++ // 0x0A0 ++ "CloseCD", "EjectCD", "EjectCloseCD", "NextSong", "PlayPause", "PreviousSong", "StopCD", "Record", ++ "Rewind", "Phone", "ISOKey", "Config", "HomePage", "Refresh", "Exit", "Move", ++ // 0x0B0 ++ "Edit", "ScrollUp", "ScrollDown", "KPLeftParenthesis", "KPRightParenthesis", NULL, NULL, "F13", ++ "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", ++ // 0x0C0 ++ "F22", "F23", "F24", NULL, NULL, NULL, NULL, NULL, ++ "PlayCD", "PauseCD", "Prog3", "Prog4", NULL, "Suspend", "Close", "Play", ++ // 0x0D0 ++ "FastForward", "BassBoost", "Print", "HP", "Camera", "Sound", "Question", "EMail", ++ "Chat", "Search", "Connect", "Finance", "Sport", "Shop", "AltErase", "Cancel", ++ // 0x0E0 ++ "BrightnessDown", "BrightnessUp", "Media", NULL, NULL, NULL, NULL, NULL, ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ // 0x0F0 ++ "Unknown", NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ // 0x100 ++ "Btn0", "Btn1", "Btn2", "Btn3", "Btn4", "Btn5", "Btn6", "Btn7", ++ "Btn8", "Btn9", NULL, NULL, NULL, NULL, NULL, NULL, ++ // 0x110 ++ "LeftBtn", "RightBtn", "MiddleBtn", "SideBtn", "ExtraBtn", "ForwardBtn", "BackBtn", "TaskBtn", ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ // 0x120 ++ "Trigger", "ThumbBtn", "ThumbBtn2", "TopBtn", "TopBtn2", "PinkieBtn", "BaseBtn", "BaseBtn2", ++ "BaseBtn3", "BaseBtn4", "BaseBtn5", "BaseBtn6", NULL, NULL, NULL, "BtnDead", ++ // 0x130 ++ "BtnA", "BtnB", "BtnC", "BtnX", "BtnY", "BtnZ", "BtnTL", "BtnTR", ++ "BtnTL2", "BtnTR2", "BtnSelect", "BtnStart", "BtnMode", "BtnThumbL", "BtnThumbR", NULL, ++ // 0x140 ++ "ToolPen", "ToolRubber", "ToolBrush", "ToolPencil", "ToolAirbrush", "ToolFinger", "ToolMouse", "ToolLens", ++ NULL, NULL, "Touch", "Stylus", "Stylus2", "ToolDoubleTap", "ToolTripleTap", NULL, ++ // 0x150 ++ "GearDown", "GearUp", NULL, NULL, NULL, NULL, NULL, NULL, ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ // 0x160 ++ "Ok", "Select", "Goto", "Clear", "Power2", "Option", "Info", "Time", ++ "Vendor", "Archive", "Program", "Channel", "Favorites", "EPG", "PVR", "MHP", ++ // 0x170 ++ "Language", "Title", "Subtitle", "Angle", "Zoom", "Mode", "Keyboard", "Screen", ++ "PC", "TV", "TV2", "VCR", "VCR2", "Sat", "Sat2", "CD", ++ // 0x180 ++ "Tape", "Radio", "Tuner", "Player", "Text", "DVD", "Aux", "MP3", ++ "Audio", "Video", "Directory", "List", "Memo", "Calendar", "Red", "Green", ++ // 0x190 ++ "Yellow", "Blue", "ChannelUp", "ChannelDown", "First", "Last", "AB", "Next", ++ "Restart", "Slow", "Shuffle", "Break", "Previous", "Digits", "Teen", "Twen", ++ // 0x1A0 ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ // 0x1B0 ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ // 0x1C0 ++ "DelEOL", "DelEOS", "InsLine", "DelLine", NULL, NULL, NULL, NULL, ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ // 0x1D0 ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ // 0x1E0 ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ // 0x1F0 ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++}; ++ ++char *absval[5] = { "Value", "Min ", "Max ", "Fuzz ", "Flat " }; ++char *relatives[REL_MAX + 1] = { ++ "X", "Y", "Z", NULL, NULL, NULL, "HWheel", "Dial", ++ "Wheel", "Misc", NULL, NULL, NULL, NULL, NULL, NULL, ++}; ++char *absolutes[ABS_MAX + 1] = { ++ // 0x00 ++ "X", "Y", "Z", "Rx", "Ry", "Rz", "Throttle", "Rudder", ++ "Wheel", "Gas", "Brake", NULL, NULL, NULL, NULL, NULL, ++ // 0x10 ++ "Hat0X", "Hat0Y", "Hat1X", "Hat1Y", "Hat2X", "Hat2Y", "Hat3X", "Hat 3Y", ++ "Pressure", "Distance", "XTilt", "YTilt", "ToolWidth", NULL, NULL, NULL, ++ // 0x20 ++ "Volume", NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ "Misc", NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ // 0x30 ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++}; ++char *leds[LED_MAX + 1] = { "NumLock", "CapsLock", "ScrollLock", "Compose", "Kana", "Sleep", "Suspend", "Mute" }; ++char *repeats[REP_MAX + 1] = { "Delay", "Period" }; ++char *sounds[SND_MAX + 1] = { "Bell", "Click" }; ++ ++char **names[EV_MAX + 1] = { syncs, keys, relatives, absolutes, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++NULL, NULL, leds, sounds, NULL, repeats, NULL, NULL, NULL }; ++ ++#ifndef BITS_PER_LONG ++#define BITS_PER_LONG (sizeof(long) * 8) ++#endif ++#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1) ++#define OFF(x) ((x)%BITS_PER_LONG) ++#define BIT(x) (1UL<> OFF(bit)) & 1) ++ ++int main (int argc, char **argv) ++{ ++ int fd, rd, i, j, k; ++ struct input_event ev[64]; ++ int version; ++ unsigned short id[4]; ++ unsigned long bit[EV_MAX][NBITS(KEY_MAX)]; ++ char name[256] = "Unknown"; ++ int _abs[5]; ++ ++ if (argc < 2) { ++ printf("Usage: evtest /dev/input/eventX\n"); ++ printf("Where X = input device number\n"); ++ exit(1); ++ } ++ ++ if ((fd = open(argv[argc - 1], O_RDONLY)) < 0) { ++ perror("evtest"); ++ exit(1); ++ } ++ ++ if (ioctl(fd, EVIOCGVERSION, &version)) { ++ perror("evtest: can't get version"); ++ exit(1); ++ } ++ ++ printf("Input driver version is %d.%d.%d\n", ++ version >> 16, (version >> 8) & 0xff, version & 0xff); ++ ++ ioctl(fd, EVIOCGID, id); ++ printf("Input device ID: bus 0x%x vendor 0x%x product 0x%x version 0x%x\n", ++ id[ID_BUS], id[ID_VENDOR], id[ID_PRODUCT], id[ID_VERSION]); ++ ++ ioctl(fd, EVIOCGNAME(sizeof(name)), name); ++ printf("Input device name: \"%s\"\n", name); ++ ++ memset(bit, 0, sizeof(bit)); ++ ioctl(fd, EVIOCGBIT(0, EV_MAX), bit[0]); ++ printf("Supported events:\n"); ++ ++ for (i = 0; i < EV_MAX; i++) ++ if (test_bit(i, bit[0])) { ++ printf(" Event type %d (%s)\n", i, events[i] ? events[i] : "?"); ++ ioctl(fd, EVIOCGBIT(i, KEY_MAX), bit[i]); ++ for (j = 0; j < KEY_MAX; j++) ++ if (test_bit(j, bit[i])) { ++ printf(" Event code %d (%s)\n", j, names[i] ? (names[i][j] ? names[i][j] : "?") : "?"); ++ if (i == EV_ABS) { ++ ioctl(fd, EVIOCGABS(j), _abs); ++ for (k = 0; k < 5; k++) ++ if ((k < 3) || _abs[k]) ++ printf(" %s %6d\n", absval[k], _abs[k]); ++ } ++ } ++ } ++ ++ ++ printf("Testing ... (interrupt to exit)\n"); ++ ++ while (1) { ++ rd = read(fd, ev, sizeof(struct input_event) * 64); ++ ++ if (rd < (int) sizeof(struct input_event)) { ++ printf("yyy\n"); ++ perror("\nevtest: error reading"); ++ exit (1); ++ } ++ ++ for (i = 0; i < rd / (int) sizeof(struct input_event); i++) ++ printf("Event: time %ld.%06ld, type %d (%s), code %d (%s), value %d\n", ++ ev[i].time.tv_sec, ev[i].time.tv_usec, ev[i].type, ++ events[ev[i].type] ? events[ev[i].type] : "?", ++ ev[i].code, ++ names[ev[i].type] ? (names[ev[i].type][ev[i].code] ? names[ev[i].type][ev[i].code] : "?") : "?", ++ ev[i].value); ++ ++ } ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/test/hex_dump.c dvb-apps/test/hex_dump.c +--- linuxtv-dvb-apps-1.1.1/test/hex_dump.c 2004-01-17 17:59:46.000000000 +0100 ++++ dvb-apps/test/hex_dump.c 2009-06-21 13:29:06.000000000 +0200 +@@ -60,4 +60,3 @@ + } + printf("\n"); + } +- +diff -Nurd linuxtv-dvb-apps-1.1.1/test/libdvbcfg/dvbcfg_test.c dvb-apps/test/libdvbcfg/dvbcfg_test.c +--- linuxtv-dvb-apps-1.1.1/test/libdvbcfg/dvbcfg_test.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/test/libdvbcfg/dvbcfg_test.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,100 @@ ++/** ++ * dvbcfg testing. ++ * ++ * Copyright (c) 2005 by Andrew de Quincey ++ * ++ * This library is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU Lesser General Public License as ++ * published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ */ ++ ++#include ++#include ++#include ++#include ++ ++void syntax(void); ++ ++struct dvbcfg_zapchannel *channels = NULL; ++int zapcount = 0; ++int zappos = 0; ++ ++int zapload_callback(struct dvbcfg_zapchannel *channel, void *private); ++int zapsave_callback(struct dvbcfg_zapchannel *channel, void *private); ++ ++int main(int argc, char *argv[]) ++{ ++ if (argc != 4) { ++ syntax(); ++ } ++ ++ if (!strcmp(argv[1], "-zapchannel")) { ++ ++ FILE *f = fopen(argv[2], "r"); ++ if (!f) { ++ fprintf(stderr, "Unable to load %s\n", argv[2]); ++ exit(1); ++ } ++ dvbcfg_zapchannel_parse(f, zapload_callback, NULL); ++ fclose(f); ++ ++ f = fopen(argv[3], "w"); ++ if (!f) { ++ fprintf(stderr, "Unable to write %s\n", argv[3]); ++ exit(1); ++ } ++ dvbcfg_zapchannel_save(f, zapsave_callback, NULL); ++ fclose(f); ++ ++ } else { ++ syntax(); ++ } ++ ++ exit(0); ++} ++ ++int zapload_callback(struct dvbcfg_zapchannel *channel, void *private) ++{ ++ (void) private; ++ ++ struct dvbcfg_zapchannel *tmp = realloc(channels, (zapcount+1) * sizeof(struct dvbcfg_zapchannel)); ++ if (tmp == NULL) { ++ fprintf(stderr, "Out of memory\n"); ++ exit(1); ++ } ++ channels = tmp; ++ ++ memcpy(&channels[zapcount++], channel, sizeof(struct dvbcfg_zapchannel)); ++ ++ return 0; ++} ++ ++int zapsave_callback(struct dvbcfg_zapchannel *channel, void *private) ++{ ++ (void) private; ++ ++ if (zappos >= zapcount) ++ return 1; ++ ++ memcpy(channel, channels + zappos, sizeof(struct dvbcfg_zapchannel)); ++ zappos++; ++ ++ return 0; ++} ++ ++void syntax() ++{ ++ fprintf(stderr, ++ "Syntax: dvbcfg_test <-zapchannel> \n"); ++ exit(1); ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/test/libdvbcfg/Makefile dvb-apps/test/libdvbcfg/Makefile +--- linuxtv-dvb-apps-1.1.1/test/libdvbcfg/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/test/libdvbcfg/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,12 @@ ++# Makefile for linuxtv.org dvb-apps/test/libdvbcfg ++ ++binaries = dvbcfg_test ++ ++CPPFLAGS += -I../../lib ++LDLIBS += ../../lib/libdvbcfg/libdvbcfg.a ++ ++.PHONY: all ++ ++all: $(binaries) ++ ++include ../../Make.rules +diff -Nurd linuxtv-dvb-apps-1.1.1/test/libdvbcfg/test_zapchannels.txt dvb-apps/test/libdvbcfg/test_zapchannels.txt +--- linuxtv-dvb-apps-1.1.1/test/libdvbcfg/test_zapchannels.txt 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/test/libdvbcfg/test_zapchannels.txt 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,446 @@ ++# Most of the major channels in the Raleigh Durham Area. Frequencies the NTSC center freq. ++WRAL:707000000:8VSB:33:36 ++WNCN:719000000:8VSB:49:52 ++WTVD:701000000:8VSB:49:52 ++WRAZ:683000000:8VSB:49:52 ++WUNC:743000000:8VSB:49:52 ++WRDU:551000000:8VSB:33:36 ++WLFL:731000000:8VSB:33:36 ++3sat:394000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:210:220 ++ARD-Online-Kanal:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:1805 ++CNBC:394000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:510:520 ++DLF-Köln:394000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:810 ++DLR-Berlin:394000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:710 ++EinsExtra:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:101:102 ++EinsFestival:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:201:202 ++EinsMuXx:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:301:302 ++EuroNews:394000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:2221:2233 ++Eurosport:394000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:410:420 ++Fritz:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:901 ++KiKa:394000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:310:320 ++MDR FERNSEHEN:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:401:402 ++MDR KULTUR:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:801 ++MDR info:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:1101 ++MHP ARD Online-Kanal:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:102 ++NDR Fernsehen:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:2401:2402 ++ORB-Fernsehen:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:501:502 ++RADIOmultikulti:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:1301 ++Radio 3:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:701 ++SFB1:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:601:602 ++SWR2:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:1401 ++SÃœDWEST BW:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:801:802 ++SÃœDWEST RP:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:3101:3102 ++WDR 3:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:1501 ++WDR 5:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:1601 ++ZDF:394000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:110:120 ++ZDFdigitext:394000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++ZDFdokukanal:394000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:660:670 ++ZDFinfokanal:394000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:610:620 ++ZDFtheaterkanal:394000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++JUMP:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:1001 ++SPUTNIK:426000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:1201 ++Österreich 1:394000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:169 ++ATV 2:434000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:631:632 ++ATV 2:434000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:631:632 ++Adagio:442000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++All Jazz:442000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++Avante:113000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:741:743 ++B5 aktuell:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:3101 ++BBC Prime:113000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:761:762 ++BData3:402000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++BData4:402000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++BData5:402000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++BR-alpha:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:701:702 ++Barock Fantasie:442000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++Bayerisches FS:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:201:202 ++Bayern 1:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:3601 ++Bayern 4 Klassik:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:3001 ++BibelTV:113000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:731:732 ++Bloomberg:346000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++CLASSICA:354000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:767:768 ++COUNTRY:362000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:656 ++Canal 24 Horas:121000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:991:992 ++Club:113000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:711:713 ++Cristal New Age:442000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++DANCE:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:304 ++DW-tv:610000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:634:632 ++Das Erste:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:101:102 ++Detskij Mir:121000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:931:932 ++ERT-Sat:434000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:691:692 ++Einstein TV:113000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:701:702 ++Euronews:610000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:597:596 ++Eurosport News:113000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:771:772 ++Extreme Sports:113000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:791:793 ++Extreme Sports:346000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++Fashion TV:346000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++Fox Kids:434000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:671:672 ++Fox Kids:434000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:671:673 ++GOLD:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:320 ++HITLISTE:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:784 ++HR XXL:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:3501 ++JAZZ:378000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:640 ++Jazz legends:442000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++Kabel Wizard:346000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++Kanal 7:121000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++Kanal 7:610000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:49:52 ++Kanal D:434000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:651:652 ++Kanal D:434000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:651:652 ++LATIN:362000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:368 ++Landscape:346000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++Leitseite:346000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:2254:0 ++Liberty TV:113000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:721:723 ++MTV Base:113000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:781:782 ++MV-Test:442000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++Modem-Setup:354000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++Movie Sounds:442000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++Musica Antica:442000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++Musica Camerata:442000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++NDR Info:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:3701 ++NTV international:442000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++NTVI:434000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:611:612 ++Nashe Kino:434000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:621:622 ++NordwestRadio:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:3801 ++OLD GOLD:362000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:336 ++Opernfestival:442000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++PCNE:434000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:681:682 ++PREMIERE SPORT INTERACTIVE:362000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++PREMIERE DIREKT 1:378000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++PREMIERE DIREKT 2:378000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++PREMIERE DIREKT 3:378000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++PREMIERE DIREKT 4:378000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:2815:2816 ++PREMIERE EROTIK:378000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:1279:1280 ++PREMIERE NOSTALGIE:378000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:2559:2560 ++PREMIERE SERIE:378000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:1023:1024 ++PREMIERE SPORT 1:362000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:255:258 ++PREMIERE SPORT 2:378000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:3839:3840 ++PREMIERE START:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:255:256 ++Parlamentsfernsehen:610000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:33:36 ++Phoenix:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:901:902 ++Portal:402000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++RTP Internacional:434000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:661:662 ++Rai 1:121000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:951:952 ++Rai 2:121000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:961:962 ++Rai 3:121000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:971:972 ++SCHLAGER:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:384 ++SR 1:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:3901 ++SR Fernsehen Suedwest:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:501:502 ++Show TV:121000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:911:912 ++Sinfonica:442000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++TGRT:121000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:921:922 ++TM V1.0:354000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++TV Polonia:434000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:641:642 ++TVEi:121000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:981:982 ++TW1:113000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:751:752 ++Test-R:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:701:702 ++Travel:610000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:595:594 ++VCR-Setup:354000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++VH1 Classic:610000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:604:603 ++Videotext:378000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++WDR FERNSEHEN:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:601:602 ++ZEE TV:442000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++arte:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:401:403 ++hessen fernsehen:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:301:302 ++hr-chronos:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:3201 ++hr-klassik:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:3401 ++hr2:410000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:3301 ++13 TH STREET:354000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:2303:2304 ++ALTERNATIVE ROCK:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:544 ++BEATE-UHSE.TV:354000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:1023:1024 ++CHILLOUT:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:400 ++CLASSIC ROCK:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:352 ++DISCOVERY CHANNEL:378000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:1791:1792 ++DISNEY CHANNEL:354000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:2559:2560 ++DEUTSCHE HITS:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:800 ++EASY LISTENING:378000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:608 ++Einstein:346000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++FILM & MUSICAL:378000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:592 ++FOX KIDS:354000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:1279:1280 ++GOLDSTAR TV:354000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:3839:3840 ++HARD ROCK:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:816 ++HEIMATKANAL:354000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:1535:1536 ++HIP HOP/R&B:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:576 ++JUNIOR:354000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:255:256 ++K-TOON:354000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++KLASSIK POPULÄR:378000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:624 ++KRIMI &CO:378000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:1535:1536 ++LOVE SONGS:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:592 ++NEW COUNTRY:362000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:384 ++ORCHESTRALE WERKE:378000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:560 ++PLANET:354000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:1791:1792 ++PREMIERE 1:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:511:512 ++PREMIERE 2:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:1791:1793 ++PREMIERE 3:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:2303:2304 ++PREMIERE 4:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:767:768 ++PREMIERE 5:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:1279:1280 ++PREMIERE 6:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:1535:1536 ++PREMIERE 7:370000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:1023:1024 ++SOUL CLASSICS:362000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:352 ++STUDIO UNIVERSAL:354000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:2047:2048 ++Sonnenklar TV:402000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:0:0 ++Das Erste:11837:h:0:27500:101:102:28106 ++ZDF:11954:h:0:27500:110:120:28006 ++3sat:11954:h:0:27500:210:220:28007 ++EinsMuXx:12110:h:0:27500:301:302:28203 ++EinsFestival:12110:h:0:27500:201:202:28202 ++EinsExtra:12110:h:0:27500:101:102:28201 ++MDR FERNSEHEN:12110:h:0:27500:401:402:28204 ++ORB-Fernsehen:12110:h:0:27500:501:502:28205 ++B1 Berlin:12110:h:0:27500:601:602:28206 ++SWR Fernsehen:11837:h:0:27500:801:802:28113 ++SR Fernsehen Suedwes:11837:h:0:27500:501:502:28110 ++hessen fernsehen:11837:h:0:27500:301:302:28108 ++WDR FERNSEHEN:11837:h:0:27500:601:602:28111 ++Bayerisches FS:11837:h:0:27500:201:202:28107 ++N3:12110:h:0:27500:2401:2402:28224 ++BR-alpha:11837:h:0:27500:701:702:28112 ++KiKa:11954:h:0:27500:310:320:28008 ++arte:11836:h:0:27500:401:402:28109 ++ZDF Theaterkanal:11954:h:0:27500:1110:1120:28016 ++ZDF.info:11954:h:0:27500:610:620:28011 ++ZDF.doku:11954:h:0:27500:660:670:28014 ++Phoenix:11837:h:0:27500:901:902:28114 ++DW-tv:10786:v:0:21997:305:306:9005 ++RTL Television:12188:h:0:27500:163:104:12003 ++SAT.1:12480:v:0:27500:1791:1792:46 ++ProSieben:12480:v:0:27500:255:256:898 ++RTL2:12188:h:0:27500:166:128:12020 ++Super RTL:12188:h:0:27500:165:120:12040 ++KABEL1:12480:v:0:27500:511:512:899 ++VOX:12188:h:0:27500:167:136:12060 ++tm3:12480:v:0:27500:767:768:897 ++Bloomberg TV Germany:12552:v:0:22000:162:99:12160 ++EuroNews:11954:h:0:27500:2221:2233:28015 ++N24:12480:v:0:27500:2047:2048:47 ++n-tv:12670:v:0:22000:162:96:12730 ++DSF:12480:v:0:27500:1023:1024:900 ++Eurosport:11954:h:0:27500:410:420:28009 ++Via 1 - Sch ner Re:12148:h:0:27500:511:512:44 ++Home Order Tel:12480:v:0:27500:1279:1280:40 ++QVC GERMANY:12552:v:0:22000:165:166:12100 ++TW 1:12692:h:0:22000:166:167:13013 ++Canal Canarias:12441:v:0:27500:513:681:29700 ++ProSieben A:12051:v:0:27500:161:84:20002 ++ProSieben CH:12051:v:0:27500:289:290:20001 ++Kabel 1 Austria:12051:v:0:27500:166:167:20004 ++Kabel 1 Schweiz:12051:v:0:27500:162:163:20003 ++CNN Int.:12168:v:0:27500:165:100:28512 ++Sky News:12552:v:0:22000:305:306:3995 ++Travel:12168:v:0:27500:163:92:28001 ++AB SAT / XXL:12266:h:0:27500:164:96:17004 ++MOTEURS:12266:h:0:27500:160:80:17000 ++HOT GM:12148:h:0:27500:767:768:45 ++KTO:12129:v:0:27500:170:120:8411 ++LA CINQUIEME:12207:v:0:27500:160:80:8501 ++LCP:12207:v:0:27500:165:100:8506 ++LibertyTV.com:12611:v:0:22000:941:942:12280 ++TV5 Europe:12611:v:0:22000:45:46:12240 ++Motors TV:12611:v:0:22000:191:194:12300 ++Wishline:12611:v:0:22000:214:216:12320 ++TV 5:10786:v:0:21997:164:112:9001 ++RTM - MAROC:10786:v:0:21997:162:96:9002 ++ESC1 - EGYPTE:10786:v:0:21997:163:104:9003 ++RAI 1:10786:v:0:21997:289:290:9004 ++RTPI:10786:v:0:21997:300:301:9006 ++TV7:10786:v:0:21997:166:128:9007 ++ARTE:10786:v:0:21997:167:136:9009 ++Colourbars:12611:v:0:22000:48:49:3982 ++Alice:12611:v:0:22000:162:96:12200 ++Video Italia:12611:v:0:22000:121:122:12220 ++ANDALUCIA TV:11934:v:0:27500:166:104:29011 ++TVC INT.:12441:v:0:27500:512:660:29701 ++TV4:11992:h:0:27500:165:98:20365 ++TV Niepokalanow:11876:h:0:27500:161:82:20601 ++VIVA:12670:v:0:22000:309:310:12732 ++VIVA ZWEI:12552:v:0:22000:171:172:12120 ++MTV Central:12699:v:0:22000:3031:3032:28643 ++ONYX:12692:h:1:27500:161:84:502 ++VIVA polska:11603:h:1:27500:190:191:611 ++DeeJay TV:11603:h:1:27500:160:161:602 ++NBC:11053:h:1:27500:550:551:8008 ++EWTN:10722:h:1:29900:1001:1201:4601 ++MTA INTL:10722:h:1:29900:1004:1204:4604 ++VOX:11053:h:1:27500:500:501:8002 ++SAT.1 A:11053:h:1:27500:511:512:8003 ++RTL2 AUSTRIA:11053:h:1:27500:520:521:8004 ++ZDF:11053:h:1:27500:570:571:8011 ++K-TV:11053:h:1:27500:580:581:8012 ++RTL Television:11053:h:1:27500:160:80:8001 ++ARTE:11059:v:1:6510:98:99:1 ++HOT Italia:11095:h:1:27500:4194:4195:3714 ++Olisat:11095:h:1:27500:33:34:3718 ++VIVA-POLSKA:11128:h:1:4340:98:99:1 ++DW-tv:11195:v:1:9099:101:102:5301 ++Canal 24 Horas:11203:h:1:3999:4130:4131:5301 ++TV5:11337:v:1:5631:512:640:1 ++SAT.1 CH:11603:h:1:27500:101:102:601 ++KurdSat:11603:h:1:27500:111:112:603 ++ARD "Das Erste":11603:h:1:27500:172:173:606 ++RTL 2 CH:11603:h:1:27500:175:176:609 ++Super RTL A:11603:h:1:27500:180:181:610 ++TV ROMANIA:11622:v:1:27500:227:247:10707 ++MRTV:11622:v:1:27500:222:242:10702 ++102.5 HIT Ch:11622:v:1:27500:224:244:10704 ++TLC SAT:11622:v:1:27500:225:245:10705 ++PRO-SAT:11622:v:1:27500:246:226:10706 ++Channel SUN:11622:v:1:27500:229:249:10709 ++Racing Channel:11622:v:1:27500:228:248:10708 ++3 ABN:11622:v:1:27500:221:241:10701 ++Bloom.Germany:11642:h:1:27500:1460:1420:4 ++Bloomberg TV UK:11642:h:1:27500:1560:1520:4 ++Sat 7:11642:h:1:27500:1660:1620:4 ++EDTV 1:11746:h:1:27500:4130:4131:9501 ++EDTV SPORT:11746:h:1:27500:4386:4387:9502 ++EDTV BUSINESS:11746:h:1:27500:4642:4643:9503 ++EDTV DRAMA:11746:h:1:27500:4898:4899:9504 ++RAI1:11765:v:1:27499:160:80:3401 ++RAI2:11765:v:1:27499:161:84:3402 ++RAI3:11765:v:1:27499:162:88:3403 ++RaiWayTEST2:11765:v:1:27499:516:654:3405 ++RAIMOSAICO:11765:v:1:27499:518:8191:3407 ++RAINews24:11803:v:1:27500:516:654:3301 ++CAMERA DEPUTATI:11803:v:1:27500:517:655:3302 ++TELEPACE:11803:v:1:27500:515:653:3304 ++RAISPORTSAT:11803:v:1:27500:512:650:3305 ++RAINettunoSAT2:11803:v:1:27500:513:651:3306 ++RAIeducational:11803:v:1:27500:514:652:3307 ++RAINettunoSAT1:11803:v:1:27500:519:657:3308 ++SAT2000:11803:v:1:27500:518:656:3309 ++I1:11918:v:1:27499:512:650:1 ++C5:11918:v:1:27499:513:660:2 ++R4:11918:v:1:27499:514:670:3 ++Telesierra:12091:h:1:27500:4160:4161:8704 ++C. Milagro:12091:h:1:27500:4368:4369:8711 ++Italia Sat:12091:h:1:27500:4600:4601:8728 ++TVE Internacional:12091:h:1:27500:4208:4209:8707 ++Fiesta:12091:h:1:27500:4432:4433:8720 ++Retelsat:12091:h:1:27500:4464:4465:8722 ++ART EUROPE:12013:h:1:27495:164:96:450 ++EGYPT SAT. CH. 2:12013:h:1:27495:166:104:470 ++IQRA:12013:h:1:27495:168:112:474 ++MAURITANIA TV:12110:v:1:27500:230:231:704 ++ARMENIA TV:12110:v:1:27500:240:241:705 ++SAILING CHANNEL:12110:v:1:27500:260:261:707 ++AL JAZEERA:12110:v:1:27500:270:271:708 ++Coming Soon TV:12110:v:1:27500:310:311:717 ++SaluteBenessere:12110:v:1:27500:320:321:718 ++AH-EDP1:12148:v:1:27499:96:97:7201 ++AH-EDP2:12148:v:1:27499:112:113:7202 ++Espresso:12148:v:1:27499:192:193:7203 ++Alice:12148:v:1:27499:160:161:7220 ++Nuvolari:12148:v:1:27499:176:177:7221 ++Leonardo:12148:v:1:27499:128:129:7222 ++AH-EDP3:12148:v:1:27499:36:37:7205 ++OTE Promo:12187:v:1:27500:517:655:1001 ++RTS SAT:12187:v:1:27500:519:657:1022 ++ERT SAT:12187:v:1:27500:514:652:1102 ++EXTRA:12187:v:1:27500:516:654:1106 ++TRIAL:12187:v:1:27500:513:651:1108 ++Minimax:11303:h:1:19540:300:301:3 ++TVN1:12209:h:1:5631:4194:4195:1 ++RR TEST:10978:v:1:8998:33:34:1 ++TV 5 Thailand:10978:v:1:8998:1057:1058:2 ++TEST-1:10978:v:1:8998:3105:3106:4 ++FASHION:12244:h:1:27500:123:133:103 ++AJARA TV:12244:h:1:27500:127:137:107 ++SLO-TV1:12300:v:1:27495:200:201:3201 ++POLONIA 1:12302:v:1:27500:205:206:3203 ++SUPER 1:12302:v:1:27500:207:208:3207 ++NAPOLI INT.:12302:v:1:27500:240:241:3210 ++MAGIC:12302:v:1:27500:245:246:3211 ++COUNTDOWN:12302:v:1:27500:235:236:3212 ++TBNE:12302:v:1:27500:230:231:3213 ++NAPOLI CHANNEL:12302:v:1:27500:227:228:3215 ++KURDISTAN TV:12302:v:1:27500:225:226:3214 ++ATLAS TV:12379:v:1:27500:3022:3032:3002 ++TELE 24 SWITZERLAND:12379:v:1:27500:3023:3033:3003 ++Abu Dhabi TV:12379:v:1:27500:3024:3034:3004 ++RTV MONTENEGRO:12379:v:1:27500:3026:3036:3006 ++JAAM-E-JAM 1:12436:h:1:27500:160:80:1 ++JAAM-E-JAM 2:12436:h:1:27500:161:82:2 ++SAHAR:12436:h:1:27500:162:84:3 ++SAHAR 2:12436:h:1:27500:163:86:4 ++IRINN:12436:h:1:27500:164:88:5 ++Musicmax:11303:h:1:19540:500:501:6 ++TEST:12474:h:1:27500:771:8191:10608 ++EbS:12474:h:1:27500:101:201:10601 ++MOU.2:12474:h:1:27500:42:43:10602 ++PINK PLUS:12474:h:1:27500:308:256:10605 ++LibertyTV.com:12474:h:1:27500:941:942:10603 ++2M Maroc:12474:h:1:27500:601:602:10607 ++ZEE TV:12474:h:1:27500:910:911:10604 ++WorldNet Europe:12483:v:1:8299:4260:4220:1 ++WorldNet:12483:v:1:8299:4560:4520:4 ++SICILIA INTERNATIONA:12519:v:1:27499:501:502:8309 ++SARDEGNA UNO:12519:v:1:27499:503:504:8310 ++EuroMed:12519:v:1:27499:510:511:8312 ++TGRT:12519:v:1:27499:505:506:8313 ++VIDEOLINA:12519:v:1:27499:515:516:8318 ++MEDIOLANUM:12538:h:1:27500:1131:1132:8987 ++www.travel:12538:h:1:27500:1180:1183:8992 ++MonteCarloSat:12538:h:1:27500:5126:5122:8877 ++Bulgaria TV:12538:h:1:27500:4612:4613:8827 ++TVN1:12571:h:1:5631:4194:4195:1 ++JSTV 1:12595:v:1:27500:2000:2001:8213 ++JSTV 2:12595:v:1:27500:2011:2013:8214 ++MBC:12595:v:1:27500:160:80:8201 ++ANN:12595:v:1:27500:161:84:8202 ++BET:12595:v:1:27500:167:108:8208 ++EuroNews:12595:v:1:27500:2221:2231:8211 ++Sharjah Arabs:12653:h:1:27500:1160:1120:1 ++Qatar Arabs:12653:h:1:27500:1260:1220:2 ++Saudi 1 Arabs:12653:h:1:27500:1360:1320:3 ++Kuwait Arabs:12653:h:1:27500:1460:1420:4 ++Libya Arabs:12653:h:1:27500:1560:1520:5 ++Sudan Arabs:12653:h:1:27500:1660:1620:6 ++Oman Arabs:12653:h:1:27500:1760:1720:7 ++Jordan Arabs:12653:h:1:27500:1860:1820:8 ++IRAQ TV:12653:h:1:27500:1960:1920:9 ++Dubai Sport:12653:h:1:27500:1060:1020:10 ++Digitaly:12672:v:1:27500:220:221:4203 ++Telemarket:12672:v:1:27500:350:351:4211 ++eVision:12672:v:1:27500:360:361:4214 ++Thai TV5:12672:v:1:27500:200:201:4201 ++Studio Europa:12672:v:1:27500:230:231:4204 ++Video Italia:12672:v:1:27500:340:341:4210 ++GAME NETWORK:12672:v:1:27500:291:292:4213 ++BBC-Choice:578000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:620:621 ++BBC-Knowledge:578000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:630:631 ++BBC-News24:578000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:640:641 ++BBC-1:578000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:600:601 ++BBC-Parliament:578000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:0:660 ++BBC-2:578000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:610:611 ++ITV-1:850000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:513:651 ++ITV-2:850000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:2818:2819 ++ITV-Sport:850000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:2836:2837 ++FilmFour:850000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:2822:2823 ++C4:850000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:2826:2827 ++E4:850000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:2831:2832 ++C5:713833334:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:6017:6018 ++Shop:713833334:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:6049:6050 ++ITVSelect-Info:713833334:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:6065:6066 ++ITVSelect-1:713833334:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:6081:6082 ++ITVSelect-2:713833334:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:6097:6098 ++ITVSelect-3:713833334:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:6113:6114 ++ITVSelect-4:713833334:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:6129:6130 ++Carlton-Cinema:721833334:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:288:289 ++Sky-One:721833334:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:544:545 ++Sky-Sports-1:721833334:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:800:801 ++Sky-Premier:721833334:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:1056:1057 ++CartoonNetwork:721833334:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:1312:1313 ++UK-Horizons:721833334:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:2336:2337 ++ITV-Sport-Plus:721833334:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:2592:2593 ++ITVSportSelect:721833334:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:0:2596 ++BreezeMen&Mtrs:690000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:800:801 ++Granada-Plus:690000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:544:545 ++MTV:690000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:1568:1569 ++Sky-Movie-Max:690000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:1312:1313 ++Sky-Sports-2:690000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:2080:2081 ++UK-Gold:690000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:288:289 ++Wellbeing:690000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:1824:1825 ++PLAY-uk:538000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:288:289 ++UK-Style:538000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:544:545 ++no-name:538000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:800:801 ++Discovery:538000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:1312:1313 ++Nick/Paramount:538000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:2080:2081 ++Sky-Sports-3:538000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:2336:2337 ++Brit-Eurosport:538000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:2592:2593 +diff -Nurd linuxtv-dvb-apps-1.1.1/test/libdvben50221/Makefile dvb-apps/test/libdvben50221/Makefile +--- linuxtv-dvb-apps-1.1.1/test/libdvben50221/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/test/libdvben50221/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,14 @@ ++# Makefile for linuxtv.org dvb-apps/test/libdvben50221 ++ ++binaries = test-app \ ++ test-session \ ++ test-transport ++ ++CPPFLAGS += -I../../lib ++LDLIBS += ../../lib/libdvbapi/libdvbapi.a ../../lib/libdvben50221/libdvben50221.a ../../lib/libucsi/libucsi.a -lpthread ++ ++.PHONY: all ++ ++all: $(binaries) ++ ++include ../../Make.rules +diff -Nurd linuxtv-dvb-apps-1.1.1/test/libdvben50221/test-app.c dvb-apps/test/libdvben50221/test-app.c +--- linuxtv-dvb-apps-1.1.1/test/libdvben50221/test-app.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/test/libdvben50221/test-app.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,854 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com) ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define DEFAULT_SLOT 0 ++ ++#define MAX_SESSIONS 256 ++#define MAX_TC 32 ++ ++void *stackthread_func(void* arg); ++void *pmtthread_func(void* arg); ++int test_lookup_callback(void *arg, uint8_t slot_id, uint32_t requested_resource_id, ++ en50221_sl_resource_callback *callback_out, void **arg_out, uint32_t *connected_resource_id); ++int test_session_callback(void *arg, int reason, uint8_t slot_id, uint16_t session_number, uint32_t resource_id); ++ ++int test_datetime_enquiry_callback(void *arg, uint8_t slot_id, uint16_t session_number, uint8_t response_interval); ++ ++int test_rm_enq_callback(void *arg, uint8_t slot_id, uint16_t session_number); ++int test_rm_reply_callback(void *arg, uint8_t slot_id, uint16_t session_number, uint32_t resource_id_count, uint32_t *resource_ids); ++int test_rm_changed_callback(void *arg, uint8_t slot_id, uint16_t session_number); ++ ++int test_ai_callback(void *arg, uint8_t slot_id, uint16_t session_number, ++ uint8_t application_type, uint16_t application_manufacturer, ++ uint16_t manufacturer_code, uint8_t menu_string_length, ++ uint8_t *menu_string); ++ ++int test_ca_info_callback(void *arg, uint8_t slot_id, uint16_t session_number, uint32_t ca_id_count, uint16_t *ca_ids); ++int test_ca_pmt_reply_callback(void *arg, uint8_t slot_id, uint16_t session_number, ++ struct en50221_app_pmt_reply *reply, uint32_t reply_size); ++ ++int test_mmi_close_callback(void *arg, uint8_t slot_id, uint16_t session_number, uint8_t cmd_id, uint8_t delay); ++ ++int test_mmi_display_control_callback(void *arg, uint8_t slot_id, uint16_t session_number, ++ uint8_t cmd_id, uint8_t mmi_mode); ++ ++int test_mmi_keypad_control_callback(void *arg, uint8_t slot_id, uint16_t session_number, ++ uint8_t cmd_id, uint8_t *key_codes, uint32_t key_codes_count); ++ ++int test_mmi_subtitle_segment_callback(void *arg, uint8_t slot_id, uint16_t session_number, ++ uint8_t *segment, uint32_t segment_size); ++ ++int test_mmi_scene_end_mark_callback(void *arg, uint8_t slot_id, uint16_t session_number, ++ uint8_t decoder_continue_flag, uint8_t scene_reveal_flag, ++ uint8_t send_scene_done, uint8_t scene_tag); ++ ++int test_mmi_scene_control_callback(void *arg, uint8_t slot_id, uint16_t session_number, ++ uint8_t decoder_continue_flag, uint8_t scene_reveal_flag, ++ uint8_t scene_tag); ++ ++int test_mmi_subtitle_download_callback(void *arg, uint8_t slot_id, uint16_t session_number, ++ uint8_t *segment, uint32_t segment_size); ++ ++int test_mmi_flush_download_callback(void *arg, uint8_t slot_id, uint16_t session_number); ++ ++int test_mmi_enq_callback(void *arg, uint8_t slot_id, uint16_t session_number, ++ uint8_t blind_answer, uint8_t expected_answer_length, ++ uint8_t *text, uint32_t text_size); ++ ++int test_mmi_menu_callback(void *arg, uint8_t slot_id, uint16_t session_number, ++ struct en50221_app_mmi_text *title, ++ struct en50221_app_mmi_text *sub_title, ++ struct en50221_app_mmi_text *bottom, ++ uint32_t item_count, struct en50221_app_mmi_text *items, ++ uint32_t item_raw_length, uint8_t *items_raw); ++ ++int test_app_mmi_list_callback(void *arg, uint8_t slot_id, uint16_t session_number, ++ struct en50221_app_mmi_text *title, ++ struct en50221_app_mmi_text *sub_title, ++ struct en50221_app_mmi_text *bottom, ++ uint32_t item_count, struct en50221_app_mmi_text *items, ++ uint32_t item_raw_length, uint8_t *items_raw); ++ ++struct section_ext *read_section_ext(char *buf, int buflen, int adapter, int demux, int pid, int table_id); ++ ++ ++ ++ ++ ++ ++ ++int adapterid; ++ ++int shutdown_stackthread = 0; ++int shutdown_pmtthread = 0; ++int in_menu = 0; ++int in_enq = 0; ++int ca_connected = 0; ++int pmt_pid = -1; ++int ca_session_number = 0; ++ ++ ++// instances of resources we actually implement here ++struct en50221_app_rm *rm_resource; ++struct en50221_app_datetime *datetime_resource; ++struct en50221_app_ai *ai_resource; ++struct en50221_app_ca *ca_resource; ++struct en50221_app_mmi *mmi_resource; ++ ++// lookup table used in resource manager implementation ++struct resource { ++ struct en50221_app_public_resource_id resid; ++ uint32_t binary_resource_id; ++ en50221_sl_resource_callback callback; ++ void *arg; ++}; ++struct resource resources[20]; ++int resources_count = 0; ++ ++// this contains all known resource ids so we can see if the cam asks for something exotic ++uint32_t resource_ids[] = { EN50221_APP_TELETEXT_RESOURCEID, ++ EN50221_APP_SMARTCARD_RESOURCEID(1), ++ EN50221_APP_RM_RESOURCEID, ++ EN50221_APP_MMI_RESOURCEID, ++ EN50221_APP_LOWSPEED_RESOURCEID(1,1), ++ EN50221_APP_EPG_RESOURCEID(1), ++ EN50221_APP_DVB_RESOURCEID, ++ EN50221_APP_CA_RESOURCEID, ++ EN50221_APP_DATETIME_RESOURCEID, ++ EN50221_APP_AUTH_RESOURCEID, ++ EN50221_APP_AI_RESOURCEID, }; ++int resource_ids_count = sizeof(resource_ids)/4; ++ ++ ++uint16_t ai_session_numbers[5]; ++ ++uint16_t mmi_session_number; ++ ++int main(int argc, char * argv[]) ++{ ++ pthread_t stackthread; ++ pthread_t pmtthread; ++ struct en50221_app_send_functions sendfuncs; ++ ++ if ((argc < 2) || (argc > 3)) { ++ fprintf(stderr, "Syntax: test-app []\n"); ++ exit(1); ++ } ++ adapterid = atoi(argv[1]); ++ if (argc == 3) { ++ if (sscanf(argv[2], "%i", &pmt_pid) != 1) { ++ fprintf(stderr, "Unable to parse PMT PID\n"); ++ exit(1); ++ } ++ } ++ ++ // create transport layer ++ struct en50221_transport_layer *tl = en50221_tl_create(5, 32); ++ if (tl == NULL) { ++ fprintf(stderr, "Failed to create transport layer\n"); ++ exit(1); ++ } ++ ++ // find CAMs ++ int cafd; ++ if (((cafd = dvbca_open(adapterid, 0)) < 0) || (dvbca_get_cam_state(cafd, DEFAULT_SLOT) == DVBCA_CAMSTATE_MISSING)) { ++ fprintf(stderr, "Unable to open CAM on adapter %i\n", adapterid); ++ exit(1); ++ } ++ ++ // reset it and wait ++ dvbca_reset(cafd, DEFAULT_SLOT); ++ printf("Found a CAM on adapter%i... waiting...\n", adapterid); ++ while(dvbca_get_cam_state(cafd, DEFAULT_SLOT) != DVBCA_CAMSTATE_READY) { ++ usleep(1000); ++ } ++ ++ // register it with the CA stack ++ int slot_id = 0; ++ if ((slot_id = en50221_tl_register_slot(tl, cafd, DEFAULT_SLOT, 1000, 100)) < 0) { ++ fprintf(stderr, "Slot registration failed\n"); ++ exit(1); ++ } ++ printf("slotid: %i\n", slot_id); ++ ++ // create session layer ++ struct en50221_session_layer *sl = en50221_sl_create(tl, 256); ++ if (sl == NULL) { ++ fprintf(stderr, "Failed to create session layer\n"); ++ exit(1); ++ } ++ ++ // create the sendfuncs ++ sendfuncs.arg = sl; ++ sendfuncs.send_data = (en50221_send_data) en50221_sl_send_data; ++ sendfuncs.send_datav = (en50221_send_datav) en50221_sl_send_datav; ++ ++ // create the resource manager resource ++ rm_resource = en50221_app_rm_create(&sendfuncs); ++ en50221_app_decode_public_resource_id(&resources[resources_count].resid, EN50221_APP_RM_RESOURCEID); ++ resources[resources_count].binary_resource_id = EN50221_APP_RM_RESOURCEID; ++ resources[resources_count].callback = (en50221_sl_resource_callback) en50221_app_rm_message; ++ resources[resources_count].arg = rm_resource; ++ en50221_app_rm_register_enq_callback(rm_resource, test_rm_enq_callback, NULL); ++ en50221_app_rm_register_reply_callback(rm_resource, test_rm_reply_callback, NULL); ++ en50221_app_rm_register_changed_callback(rm_resource, test_rm_changed_callback, NULL); ++ resources_count++; ++ ++ // create the datetime resource ++ datetime_resource = en50221_app_datetime_create(&sendfuncs); ++ en50221_app_decode_public_resource_id(&resources[resources_count].resid, EN50221_APP_DATETIME_RESOURCEID); ++ resources[resources_count].binary_resource_id = EN50221_APP_DATETIME_RESOURCEID; ++ resources[resources_count].callback = (en50221_sl_resource_callback) en50221_app_datetime_message; ++ resources[resources_count].arg = datetime_resource; ++ en50221_app_datetime_register_enquiry_callback(datetime_resource, test_datetime_enquiry_callback, NULL); ++ resources_count++; ++ ++ // create the application information resource ++ ai_resource = en50221_app_ai_create(&sendfuncs); ++ en50221_app_decode_public_resource_id(&resources[resources_count].resid, EN50221_APP_AI_RESOURCEID); ++ resources[resources_count].binary_resource_id = EN50221_APP_AI_RESOURCEID; ++ resources[resources_count].callback = (en50221_sl_resource_callback) en50221_app_ai_message; ++ resources[resources_count].arg = ai_resource; ++ en50221_app_ai_register_callback(ai_resource, test_ai_callback, NULL); ++ resources_count++; ++ ++ // create the CA resource ++ ca_resource = en50221_app_ca_create(&sendfuncs); ++ en50221_app_decode_public_resource_id(&resources[resources_count].resid, EN50221_APP_CA_RESOURCEID); ++ resources[resources_count].binary_resource_id = EN50221_APP_CA_RESOURCEID; ++ resources[resources_count].callback = (en50221_sl_resource_callback) en50221_app_ca_message; ++ resources[resources_count].arg = ca_resource; ++ en50221_app_ca_register_info_callback(ca_resource, test_ca_info_callback, NULL); ++ en50221_app_ca_register_pmt_reply_callback(ca_resource, test_ca_pmt_reply_callback, NULL); ++ resources_count++; ++ ++ // create the MMI resource ++ mmi_resource = en50221_app_mmi_create(&sendfuncs); ++ en50221_app_decode_public_resource_id(&resources[resources_count].resid, EN50221_APP_MMI_RESOURCEID); ++ resources[resources_count].binary_resource_id = EN50221_APP_MMI_RESOURCEID; ++ resources[resources_count].callback = (en50221_sl_resource_callback) en50221_app_mmi_message; ++ resources[resources_count].arg = mmi_resource; ++ en50221_app_mmi_register_close_callback(mmi_resource, test_mmi_close_callback, NULL); ++ en50221_app_mmi_register_display_control_callback(mmi_resource, test_mmi_display_control_callback, NULL); ++ en50221_app_mmi_register_keypad_control_callback(mmi_resource, test_mmi_keypad_control_callback, NULL); ++ en50221_app_mmi_register_subtitle_segment_callback(mmi_resource, test_mmi_subtitle_segment_callback, NULL); ++ en50221_app_mmi_register_scene_end_mark_callback(mmi_resource, test_mmi_scene_end_mark_callback, NULL); ++ en50221_app_mmi_register_scene_control_callback(mmi_resource, test_mmi_scene_control_callback, NULL); ++ en50221_app_mmi_register_subtitle_download_callback(mmi_resource, test_mmi_subtitle_download_callback, NULL); ++ en50221_app_mmi_register_flush_download_callback(mmi_resource, test_mmi_flush_download_callback, NULL); ++ en50221_app_mmi_register_enq_callback(mmi_resource, test_mmi_enq_callback, NULL); ++ en50221_app_mmi_register_menu_callback(mmi_resource, test_mmi_menu_callback, NULL); ++ en50221_app_mmi_register_list_callback(mmi_resource, test_app_mmi_list_callback, NULL); ++ resources_count++; ++ ++ // start another thread running the stack ++ pthread_create(&stackthread, NULL, stackthread_func, tl); ++ ++ // start another thread parsing PMT ++ if (pmt_pid != -1) { ++ pthread_create(&pmtthread, NULL, pmtthread_func, tl); ++ } ++ ++ // register callbacks ++ en50221_sl_register_lookup_callback(sl, test_lookup_callback, sl); ++ en50221_sl_register_session_callback(sl, test_session_callback, sl); ++ ++ // create a new connection on each slot ++ int tc = en50221_tl_new_tc(tl, slot_id); ++ printf("tcid: %i\n", tc); ++ ++ printf("Press a key to enter menu\n"); ++ getchar(); ++ en50221_app_ai_entermenu(ai_resource, ai_session_numbers[slot_id]); ++ ++ // wait ++ char tmp[256]; ++ while(1) { ++ fgets(tmp, sizeof(tmp), stdin); ++ int choice = atoi(tmp); ++ ++ if (in_menu) { ++ en50221_app_mmi_menu_answ(mmi_resource, mmi_session_number, choice); ++ in_menu = 0; ++ } ++ if (in_enq) { ++ uint32_t i; ++ uint32_t len = strlen(tmp); ++ for(i=0; i< len; i++) { ++ if (!isdigit(tmp[i])) { ++ len = i; ++ break; ++ } ++ } ++ en50221_app_mmi_answ(mmi_resource, mmi_session_number, MMI_ANSW_ID_ANSWER, (uint8_t*) tmp, len); ++ in_enq = 0; ++ } ++ } ++ printf("Press a key to exit\n"); ++ getchar(); ++ ++ // destroy slots ++ en50221_tl_destroy_slot(tl, slot_id); ++ shutdown_stackthread = 1; ++ shutdown_pmtthread = 1; ++ pthread_join(stackthread, NULL); ++ if (pmt_pid != -1) { ++ pthread_join(pmtthread, NULL); ++ } ++ ++ // destroy session layer ++ en50221_sl_destroy(sl); ++ ++ // destroy transport layer ++ en50221_tl_destroy(tl); ++ ++ return 0; ++} ++ ++int test_lookup_callback(void *arg, uint8_t slot_id, uint32_t requested_resource_id, ++ en50221_sl_resource_callback *callback_out, void **arg_out, uint32_t *connected_resource_id) ++{ ++ struct en50221_app_public_resource_id resid; ++ (void)arg; ++ ++ // decode the resource id ++ if (en50221_app_decode_public_resource_id(&resid, requested_resource_id)) { ++ printf("%02x:Public resource lookup callback %i %i %i\n", slot_id, ++ resid.resource_class, resid.resource_type, resid.resource_version); ++ } else { ++ printf("%02x:Private resource lookup callback %08x\n", slot_id, requested_resource_id); ++ return -1; ++ } ++ ++ // FIXME: need better comparison ++ // FIXME: return resourceid we actually connected to ++ ++ // try and find an instance of the resource ++ int i; ++ for(i=0; itext_length, title->text); ++ printf(" sub_title: %.*s\n", sub_title->text_length, sub_title->text); ++ printf(" bottom: %.*s\n", bottom->text_length, bottom->text); ++ ++ uint32_t i; ++ for(i=0; i< item_count; i++) { ++ printf(" item %i: %.*s\n", i+1, items[i].text_length, items[i].text); ++ } ++ printf(" raw_length: %i\n", item_raw_length); ++ ++ mmi_session_number = session_number; ++ in_menu = 1; ++ ++ return 0; ++} ++ ++int test_app_mmi_list_callback(void *arg, uint8_t slot_id, uint16_t session_number, ++ struct en50221_app_mmi_text *title, ++ struct en50221_app_mmi_text *sub_title, ++ struct en50221_app_mmi_text *bottom, ++ uint32_t item_count, struct en50221_app_mmi_text *items, ++ uint32_t item_raw_length, uint8_t *items_raw) ++{ ++ (void)arg; ++ (void)items_raw; ++ (void)arg; ++ ++ printf("%02x:%s\n", slot_id, __func__); ++ ++ printf(" title: %.*s\n", title->text_length, title->text); ++ printf(" sub_title: %.*s\n", sub_title->text_length, sub_title->text); ++ printf(" bottom: %.*s\n", bottom->text_length, bottom->text); ++ ++ uint32_t i; ++ for(i=0; i< item_count; i++) { ++ printf(" item %i: %.*s\n", i+1, items[i].text_length, items[i].text); ++ } ++ printf(" raw_length: %i\n", item_raw_length); ++ ++ mmi_session_number = session_number; ++ in_menu = 1; ++ ++ return 0; ++} ++ ++ ++ ++ ++ ++ ++ ++void *stackthread_func(void* arg) { ++ struct en50221_transport_layer *tl = arg; ++ int lasterror = 0; ++ ++ while(!shutdown_stackthread) { ++ int error; ++ if ((error = en50221_tl_poll(tl)) != 0) { ++ if (error != lasterror) { ++ fprintf(stderr, "Error reported by stack slot:%i error:%i\n", ++ en50221_tl_get_error_slot(tl), ++ en50221_tl_get_error(tl)); ++ } ++ lasterror = error; ++ } ++ } ++ ++ shutdown_stackthread = 0; ++ return 0; ++} ++ ++void *pmtthread_func(void* arg) { ++ (void)arg; ++ char buf[4096]; ++ uint8_t capmt[4096]; ++ int pmtversion = -1; ++ ++ while(!shutdown_pmtthread) { ++ ++ if (!ca_connected) { ++ sleep(1); ++ continue; ++ } ++ ++ // read the PMT ++ struct section_ext *section_ext = read_section_ext(buf, sizeof(buf), adapterid, 0, pmt_pid, stag_mpeg_program_map); ++ if (section_ext == NULL) { ++ fprintf(stderr, "Failed to read PMT\n"); ++ exit(1); ++ } ++ struct mpeg_pmt_section *pmt = mpeg_pmt_section_codec(section_ext); ++ if (pmt == NULL) { ++ fprintf(stderr, "Bad PMT received\n"); ++ exit(1); ++ } ++ if (pmt->head.version_number == pmtversion) { ++ continue; ++ } ++ ++ // translate it into a CA PMT ++ int listmgmt = CA_LIST_MANAGEMENT_ONLY; ++ if (pmtversion != -1) { ++ listmgmt = CA_LIST_MANAGEMENT_UPDATE; ++ } ++ int size; ++ if ((size = en50221_ca_format_pmt(pmt, ++ capmt, ++ sizeof(capmt), ++ listmgmt, ++ 0, ++ CA_PMT_CMD_ID_OK_DESCRAMBLING)) < 0) { ++ fprintf(stderr, "Failed to format CA PMT object\n"); ++ exit(1); ++ } ++ ++ // set it ++ if (en50221_app_ca_pmt(ca_resource, ca_session_number, capmt, size)) { ++ fprintf(stderr, "Failed to send CA PMT object\n"); ++ exit(1); ++ } ++ pmtversion = pmt->head.version_number; ++ } ++ shutdown_pmtthread = 0; ++ return 0; ++} ++ ++ ++struct section_ext *read_section_ext(char *buf, int buflen, int adapter, int demux, int pid, int table_id) ++{ ++ int demux_fd = -1; ++ uint8_t filter[18]; ++ uint8_t mask[18]; ++ int size; ++ struct section *section; ++ struct section_ext *result = NULL; ++ ++ // open the demuxer ++ if ((demux_fd = dvbdemux_open_demux(adapter, demux, 0)) < 0) { ++ goto exit; ++ } ++ ++ // create a section filter ++ memset(filter, 0, sizeof(filter)); ++ memset(mask, 0, sizeof(mask)); ++ filter[0] = table_id; ++ mask[0] = 0xFF; ++ if (dvbdemux_set_section_filter(demux_fd, pid, filter, mask, 1, 1)) { ++ goto exit; ++ } ++ ++ // read the section ++ if ((size = read(demux_fd, buf, buflen)) < 0) { ++ goto exit; ++ } ++ ++ // parse it as a section ++ section = section_codec((uint8_t*) buf, size); ++ if (section == NULL) { ++ goto exit; ++ } ++ ++ // parse it as a section_ext ++ result = section_ext_decode(section, 0); ++ ++exit: ++ if (demux_fd != -1) ++ close(demux_fd); ++ return result; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/test/libdvben50221/test-session.c dvb-apps/test/libdvben50221/test-session.c +--- linuxtv-dvb-apps-1.1.1/test/libdvben50221/test-session.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/test/libdvben50221/test-session.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,171 @@ ++/* ++ en50221 encoder An implementation for libdvb ++ an implementation for the en50221 transport layer ++ ++ Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com) ++ Copyright (C) 2005 Julian Scheel (julian at jusst dot de) ++ Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net) ++ ++ This library is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++*/ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++void *stackthread_func(void* arg); ++int test_lookup_callback(void *arg, uint8_t slot_id, uint32_t requested_resource_id, ++ en50221_sl_resource_callback *callback_out, void **arg_out, uint32_t *connected_resource_id); ++int test_session_callback(void *arg, int reason, uint8_t slot_id, uint16_t session_number, uint32_t resource_id); ++ ++ ++int shutdown_stackthread = 0; ++ ++#define DEFAULT_SLOT 0 ++ ++int main(int argc, char * argv[]) ++{ ++ (void)argc; ++ (void)argv; ++ ++ int i; ++ pthread_t stackthread; ++ ++ // create transport layer ++ struct en50221_transport_layer *tl = en50221_tl_create(5, 32); ++ if (tl == NULL) { ++ fprintf(stderr, "Failed to create transport layer\n"); ++ exit(1); ++ } ++ ++ // find CAMs ++ int slot_count = 0; ++ int cafd= -1; ++ for(i=0; i<20; i++) { ++ if ((cafd = dvbca_open(i, 0)) > 0) { ++ if (dvbca_get_cam_state(cafd, DEFAULT_SLOT) == DVBCA_CAMSTATE_MISSING) { ++ close(cafd); ++ continue; ++ } ++ ++ // reset it and wait ++ dvbca_reset(cafd, DEFAULT_SLOT); ++ printf("Found a CAM on adapter%i... waiting...\n", i); ++ while(dvbca_get_cam_state(cafd, DEFAULT_SLOT) != DVBCA_CAMSTATE_READY) { ++ usleep(1000); ++ } ++ ++ // register it with the CA stack ++ int slot_id = 0; ++ if ((slot_id = en50221_tl_register_slot(tl, cafd, DEFAULT_SLOT, 1000, 100)) < 0) { ++ fprintf(stderr, "Slot registration failed\n"); ++ exit(1); ++ } ++ printf("slotid: %i\n", slot_id); ++ slot_count++; ++ } ++ } ++ ++ // create session layer ++ struct en50221_session_layer *sl = en50221_sl_create(tl, 256); ++ if (sl == NULL) { ++ fprintf(stderr, "Failed to create session layer\n"); ++ exit(1); ++ } ++ ++ // start another thread running the stack ++ pthread_create(&stackthread, NULL, stackthread_func, tl); ++ ++ // register callbacks ++ en50221_sl_register_lookup_callback(sl, test_lookup_callback, sl); ++ en50221_sl_register_session_callback(sl, test_session_callback, sl); ++ ++ // create a new connection ++ for(i=0; i ++#include ++#include ++#include ++#include ++ ++void *stackthread_func(void* arg); ++void test_callback(void *arg, int reason, ++ uint8_t *data, uint32_t data_length, ++ uint8_t slot_id, uint8_t connection_id); ++ ++int shutdown_stackthread = 0; ++ ++#define DEFAULT_SLOT 0 ++ ++int main(int argc, char * argv[]) ++{ ++ (void)argc; ++ (void)argv; ++ ++ int i; ++ pthread_t stackthread; ++ ++ // create transport layer ++ struct en50221_transport_layer *tl = en50221_tl_create(5, 32); ++ if (tl == NULL) { ++ fprintf(stderr, "Failed to create transport layer\n"); ++ exit(1); ++ } ++ ++ // find CAMs ++ int slot_count = 0; ++ int cafd= -1; ++ for(i=0; i<20; i++) { ++ if ((cafd = dvbca_open(i, 0)) > 0) { ++ if (dvbca_get_cam_state(cafd, DEFAULT_SLOT) == DVBCA_CAMSTATE_MISSING) { ++ close(cafd); ++ continue; ++ } ++ ++ // reset it and wait ++ dvbca_reset(cafd, DEFAULT_SLOT); ++ printf("Found a CAM on adapter%i... waiting...\n", i); ++ while(dvbca_get_cam_state(cafd, DEFAULT_SLOT) != DVBCA_CAMSTATE_READY) { ++ usleep(1000); ++ } ++ ++ // register it with the CA stack ++ int slot_id = 0; ++ if ((slot_id = en50221_tl_register_slot(tl, cafd, DEFAULT_SLOT, 1000, 100)) < 0) { ++ fprintf(stderr, "Slot registration failed\n"); ++ exit(1); ++ } ++ printf("slotid: %i\n", slot_id); ++ slot_count++; ++ } ++ } ++ ++ // start another thread to running the stack ++ pthread_create(&stackthread, NULL, stackthread_func, tl); ++ ++ // register callback ++ en50221_tl_register_callback(tl, test_callback, tl); ++ ++ // create a new connection ++ for(i=0; i ++ * ++ * This library is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU Lesser General Public License as ++ * published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ */ ++ ++#include ++#include ++#include ++#include ++ ++void syntax(void); ++ ++struct dvbsec_config *secconfigs = NULL; ++int seccount = 0; ++ ++int secload_callback(void *private, struct dvbsec_config *sec); ++ ++int main(int argc, char *argv[]) ++{ ++ if (argc != 4) { ++ syntax(); ++ } ++ ++ if (!strcmp(argv[1], "-sec")) { ++ ++ FILE *f = fopen(argv[2], "r"); ++ if (!f) { ++ fprintf(stderr, "Unable to load %s\n", argv[2]); ++ exit(1); ++ } ++ dvbsec_cfg_load(f, NULL, secload_callback); ++ fclose(f); ++ ++ f = fopen(argv[3], "w"); ++ if (!f) { ++ fprintf(stderr, "Unable to write %s\n", argv[3]); ++ exit(1); ++ } ++ dvbsec_cfg_save(f, secconfigs, seccount); ++ fclose(f); ++ ++ } else { ++ syntax(); ++ } ++ ++ exit(0); ++} ++ ++int secload_callback(void *private, struct dvbsec_config *sec) ++{ ++ (void) private; ++ ++ struct dvbsec_config *tmp = realloc(secconfigs, (seccount+1) * sizeof(struct dvbsec_config)); ++ if (tmp == NULL) { ++ fprintf(stderr, "Out of memory\n"); ++ exit(1); ++ } ++ secconfigs = tmp; ++ ++ memcpy(&secconfigs[seccount++], sec, sizeof(struct dvbsec_config)); ++ ++ return 0; ++} ++ ++void syntax() ++{ ++ fprintf(stderr, ++ "Syntax: dvbcfg_test <-zapchannel|-sec> \n"); ++ exit(1); ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/test/libdvbsec/Makefile dvb-apps/test/libdvbsec/Makefile +--- linuxtv-dvb-apps-1.1.1/test/libdvbsec/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/test/libdvbsec/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,12 @@ ++# Makefile for linuxtv.org dvb-apps/test/libdvbsec ++ ++binaries = dvbsec_test ++ ++CPPFLAGS += -I../../lib ++LDLIBS += ../../lib/libdvbsec/libdvbsec.a ++ ++.PHONY: all ++ ++all: $(binaries) ++ ++include ../../Make.rules +diff -Nurd linuxtv-dvb-apps-1.1.1/test/libdvbsec/test_sec.txt dvb-apps/test/libdvbsec/test_sec.txt +--- linuxtv-dvb-apps-1.1.1/test/libdvbsec/test_sec.txt 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/test/libdvbsec/test_sec.txt 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,28 @@ ++[sec] ++name=test1 ++switch-frequency=100000 ++lof-lo-v=20 ++lof-lo-h=30 ++lof-lo-l=40 ++lof-lo-r=50 ++lof-hi-v=60 ++lof-hi-h=70 ++lof-hi-l=80 ++lof-hi-r=90 ++config-type=none ++ ++[sec] ++name=test2 ++switch-frequency=200 ++lof-lo-v=40 ++lof-hi-h=50 ++config-type=simple ++ ++[sec] ++name=test3 ++switch-frequency=100000 ++lof-lo-l=20 ++lof-hi-r=30 ++config-type=advanced ++cmd-lo-v=MOOVH ++cmd-lo-h=MOOLH +diff -Nurd linuxtv-dvb-apps-1.1.1/test/libesg/Makefile dvb-apps/test/libesg/Makefile +--- linuxtv-dvb-apps-1.1.1/test/libesg/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/test/libesg/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,12 @@ ++# Makefile for linuxtv.org dvb-apps/test/libucsi ++ ++binaries = testesg ++ ++CPPFLAGS += -I../../lib ++LDLIBS += ../../lib/libesg/libesg.a ++ ++.PHONY: all ++ ++all: $(binaries) ++ ++include ../../Make.rules +diff -Nurd linuxtv-dvb-apps-1.1.1/test/libesg/samples/ESGProviderDiscoveryDescriptor.xml dvb-apps/test/libesg/samples/ESGProviderDiscoveryDescriptor.xml +--- linuxtv-dvb-apps-1.1.1/test/libesg/samples/ESGProviderDiscoveryDescriptor.xml 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/test/libesg/samples/ESGProviderDiscoveryDescriptor.xml 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,13 @@ ++ ++ ++ ++ http://www.sidsa.com ++ SIDSA (Multiple Stream) ++ 1 ++ ++ ++ http://www.sidsa.com ++ SIDSA (Single Stream) ++ 2 ++ ++ +diff -Nurd linuxtv-dvb-apps-1.1.1/test/libesg/testesg.c dvb-apps/test/libesg/testesg.c +--- linuxtv-dvb-apps-1.1.1/test/libesg/testesg.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/test/libesg/testesg.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,563 @@ ++/* ++ * ESG parser ++ * ++ * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define MAX_FILENAME 256 ++ ++void usage(void) { ++ static const char *_usage = ++ "Usage: testesg [-a ]\n" ++ " [-c ]\n" ++ " [-X XXXX]\n"; ++ ++ fprintf(stderr, "%s", _usage); ++ exit(1); ++} ++ ++void read_from_file(const char *filename, char **buffer, int *size) { ++ int fd; ++ struct stat fs; ++ ++ if ((fd = open(filename, O_RDONLY)) <= 0) { ++ fprintf(stderr, "File not found\n"); ++ exit(1); ++ } ++ ++ if (fstat(fd, &fs) < 0) { ++ fprintf(stderr, "File not readable\n"); ++ exit(1); ++ } ++ *size = fs.st_size; ++ ++ *buffer = (char *) malloc(*size); ++ if (read(fd, *buffer, *size) != *size) { ++ fprintf(stderr, "File read error\n"); ++ exit(1); ++ } ++ ++ close(fd); ++ ++ return; ++} ++ ++int main(int argc, char *argv[]) { ++ char access_descriptor_filename[MAX_FILENAME] = ""; ++ char container_filename[MAX_FILENAME] = ""; ++ int c; ++ char *buffer = NULL; ++ int size; ++ ++ // Read command line options ++ while ((c = getopt(argc, argv, "a:c:")) != -1) { ++ switch (c) { ++ case 'a': ++ strncpy(access_descriptor_filename, optarg, MAX_FILENAME); ++ break; ++ case 'c': ++ strncpy(container_filename, optarg, MAX_FILENAME); ++ break; ++ default: ++ usage(); ++ } ++ } ++ ++ // ESGAccessDescriptor ++ if (strncmp(access_descriptor_filename, "", MAX_FILENAME) != 0) { ++ fprintf(stdout, "**************************************************\n"); ++ fprintf(stdout, "Reading ESG Access Descriptor = %s\n", access_descriptor_filename); ++ fprintf(stdout, "**************************************************\n\n"); ++ ++ read_from_file(access_descriptor_filename, &buffer, &size); ++ ++ struct esg_access_descriptor *access_descriptor = esg_access_descriptor_decode((uint8_t *) buffer, size); ++ free(buffer); ++ if (access_descriptor == NULL) { ++ fprintf(stderr, "ESG Access Descriptor decode error\n"); ++ exit(1); ++ } ++ fprintf(stdout, "n_o_ESGEntries %d\n\n", access_descriptor->n_o_entries); ++ ++ struct esg_entry *entry; ++ esg_access_descriptor_entry_list_for_each(access_descriptor, entry) { ++ fprintf(stdout, " ESGEntryVersion %d\n", entry->version); ++ fprintf(stdout, " MultipleStreamTransport %d\n", entry->multiple_stream_transport); ++ fprintf(stdout, " IPVersion6 %d\n", entry->ip_version_6); ++ fprintf(stdout, " ProviderID %d\n", entry->provider_id); ++ if (entry->ip_version_6 == 0) { ++ fprintf(stdout, " SourceIPAddress %d.%d.%d.%d\n", ++ entry->source_ip.ipv4[0], ++ entry->source_ip.ipv4[1], ++ entry->source_ip.ipv4[2], ++ entry->source_ip.ipv4[3]); ++ fprintf(stdout, " DestinationIPAddress %d.%d.%d.%d\n", ++ entry->destination_ip.ipv4[0], ++ entry->destination_ip.ipv4[1], ++ entry->destination_ip.ipv4[2], ++ entry->destination_ip.ipv4[3]); ++ } else if (entry->ip_version_6 == 1) { ++ fprintf(stdout, " SourceIPAddress %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n", ++ entry->source_ip.ipv6[0], ++ entry->source_ip.ipv6[1], ++ entry->source_ip.ipv6[2], ++ entry->source_ip.ipv6[3], ++ entry->source_ip.ipv6[4], ++ entry->source_ip.ipv6[5], ++ entry->source_ip.ipv6[6], ++ entry->source_ip.ipv6[7], ++ entry->source_ip.ipv6[8], ++ entry->source_ip.ipv6[9], ++ entry->source_ip.ipv6[10], ++ entry->source_ip.ipv6[11], ++ entry->source_ip.ipv6[12], ++ entry->source_ip.ipv6[13], ++ entry->source_ip.ipv6[14], ++ entry->source_ip.ipv6[15]); ++ fprintf(stdout, " DestinationIPAddress %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n", ++ entry->destination_ip.ipv6[0], ++ entry->destination_ip.ipv6[1], ++ entry->destination_ip.ipv6[2], ++ entry->destination_ip.ipv6[3], ++ entry->destination_ip.ipv6[4], ++ entry->destination_ip.ipv6[5], ++ entry->destination_ip.ipv6[6], ++ entry->destination_ip.ipv6[7], ++ entry->destination_ip.ipv6[8], ++ entry->destination_ip.ipv6[9], ++ entry->destination_ip.ipv6[10], ++ entry->destination_ip.ipv6[11], ++ entry->destination_ip.ipv6[12], ++ entry->destination_ip.ipv6[13], ++ entry->destination_ip.ipv6[14], ++ entry->destination_ip.ipv6[15]); ++ } ++ fprintf(stdout, "Port %d\n", entry->port); ++ fprintf(stdout, "TSI %d\n", entry->tsi); ++ fprintf(stdout, "\n"); ++ } ++ } ++ ++ // ESGContainer ++ if (strncmp(container_filename, "", MAX_FILENAME) != 0) { ++ fprintf(stdout, "**************************************************\n"); ++ fprintf(stdout, "Reading ESG Container = %s\n", container_filename); ++ fprintf(stdout, "**************************************************\n\n"); ++ ++ read_from_file(container_filename, &buffer, &size); ++ ++ struct esg_container *container = esg_container_decode((uint8_t *) buffer, size); ++ free(buffer); ++ if (container == NULL) { ++ fprintf(stderr, "ESG Container decode error\n"); ++ exit(1); ++ } ++ if (container->header == NULL) { ++ fprintf(stderr, "ESG Container no header found\n"); ++ exit(1); ++ } ++ ++ struct esg_encapsulation_structure *fragment_management_information = NULL; ++ struct esg_data_repository *data_repository = NULL; ++ struct esg_string_repository *string_repository = NULL; ++ struct esg_container_structure *structure = NULL; ++ struct esg_init_message *init_message = NULL; ++ struct esg_textual_encoding_parameters *textual_encoding_parameters = NULL; ++ struct esg_textual_decoder_init *textual_decoder_init = NULL; ++ struct esg_namespace_prefix *namespace_prefix = NULL; ++ struct esg_xml_fragment_type *xml_fragment_type = NULL; ++ struct esg_bim_encoding_parameters *bim_encoding_parameters = NULL; ++ struct esg_bim_decoder_init *bim_decoder_init = NULL; ++ struct esg_session_partition_declaration *partition = NULL; ++ struct esg_session_field *field = NULL; ++ struct esg_session_ip_stream *ip_stream = NULL; ++ struct esg_session_ip_stream_field *ip_stream_field = NULL; ++ esg_container_header_structure_list_for_each(container->header, structure) { ++ fprintf(stdout, " structure_type %d [0x%02x]\n", structure->type, structure->type); ++ fprintf(stdout, " structure_id %d [0x%02x]\n", structure->id, structure->id); ++ fprintf(stdout, " structure_ptr %d\n", structure->ptr); ++ fprintf(stdout, " structure_length %d\n\n", structure->length); ++ switch (structure->type) { ++ case 0x01: { ++ switch (structure->id) { ++ case 0x00: { ++ fprintf(stdout, " ESG Fragment Management Information\n"); ++ ++ fragment_management_information = (struct esg_encapsulation_structure *) structure->data; ++ if (fragment_management_information == NULL) { ++ fprintf(stderr, "ESG Fragment Management Information decode error\n"); ++ exit(1); ++ } ++ ++ fprintf(stdout, " fragment_reference_format %d [0x%02x]\n\n", fragment_management_information->header->fragment_reference_format, fragment_management_information->header->fragment_reference_format); ++ ++ struct esg_encapsulation_entry *entry; ++ esg_encapsulation_structure_entry_list_for_each(fragment_management_information, entry) { ++ fprintf(stdout, " fragment_type %d [0x%02x]\n", entry->fragment_reference->fragment_type, entry->fragment_reference->fragment_type); ++ fprintf(stdout, " data_repository_offset %d\n", entry->fragment_reference->data_repository_offset); ++ fprintf(stdout, " fragment_version %d\n", entry->fragment_version); ++ fprintf(stdout, " fragment_id %d\n\n", entry->fragment_id); ++ } ++ ++ break; ++ } ++ default: { ++ fprintf(stdout, " Unknown structure_id\n"); ++ } ++ } ++ break; ++ } ++ case 0x02: { ++ switch (structure->id) { ++ case 0x00: { ++ fprintf(stdout, " ESG String Repository / "); ++ ++ string_repository = (struct esg_string_repository *) structure->data; ++ if (string_repository == NULL) { ++ fprintf(stderr, "ESG String Repository decode error\n"); ++ exit(1); ++ } ++ ++ fprintf(stdout, "encoding_type %d / length %d\n\n", string_repository->encoding_type, string_repository->length); ++ ++ break; ++ } ++ default: { ++ fprintf(stdout, " Unknown structure_id\n"); ++ } ++ } ++ break; ++ } ++ case 0x03: { ++ //TODO ++ break; ++ } ++ case 0x04: { ++ //TODO ++ break; ++ } ++ case 0x05: { ++ //TODO ++ break; ++ } ++ case 0xE0: { ++ switch (structure->id) { ++ case 0x00: { ++ fprintf(stdout, " ESG Data Repository / "); ++ ++ data_repository = (struct esg_data_repository *) structure->data; ++ if (data_repository == NULL) { ++ fprintf(stderr, "ESG Data Repository decode error\n"); ++ exit(1); ++ } ++ ++ fprintf(stdout, "length %d\n\n", data_repository->length); ++ ++ break; ++ } ++ default: { ++ fprintf(stdout, " Unknown structure_id\n"); ++ } ++ } ++ break; ++ } ++ case 0xE1: { ++ switch (structure->id) { ++ case 0xFF: { ++ fprintf(stdout, " ESG Session Partition Declaration\n"); ++ ++ partition = (struct esg_session_partition_declaration *) structure->data; ++ fprintf(stdout, " num_fields %d\n", partition->num_fields); ++ fprintf(stdout, " overlapping %d\n\n", partition->overlapping); ++ esg_session_partition_declaration_field_list_for_each(partition, field) { ++ fprintf(stdout, " identifier %d\n", field->identifier); ++ fprintf(stdout, " encoding %d\n",field->encoding); ++ fprintf(stdout, " length %d\n\n",field->length); ++ } ++ fprintf(stdout, " n_o_IPStreams %d\n", partition->n_o_ip_streams); ++ fprintf(stdout, " IPVersion6 %d\n\n", partition->ip_version_6); ++ esg_session_partition_declaration_ip_stream_list_for_each(partition, ip_stream) { ++ fprintf(stdout, " IPStreamID %d\n", ip_stream->id); ++ if (partition->ip_version_6 == 0) { ++ fprintf(stdout, " SourceIPAddress %d.%d.%d.%d\n", ++ ip_stream->source_ip.ipv4[0], ++ ip_stream->source_ip.ipv4[1], ++ ip_stream->source_ip.ipv4[2], ++ ip_stream->source_ip.ipv4[3]); ++ fprintf(stdout, " DestinationIPAddress %d.%d.%d.%d\n", ++ ip_stream->destination_ip.ipv4[0], ++ ip_stream->destination_ip.ipv4[1], ++ ip_stream->destination_ip.ipv4[2], ++ ip_stream->destination_ip.ipv4[3]); ++ } else if (partition->ip_version_6 == 1) { ++ fprintf(stdout, " SourceIPAddress %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n", ++ ip_stream->source_ip.ipv6[0], ++ ip_stream->source_ip.ipv6[1], ++ ip_stream->source_ip.ipv6[2], ++ ip_stream->source_ip.ipv6[3], ++ ip_stream->source_ip.ipv6[4], ++ ip_stream->source_ip.ipv6[5], ++ ip_stream->source_ip.ipv6[6], ++ ip_stream->source_ip.ipv6[7], ++ ip_stream->source_ip.ipv6[8], ++ ip_stream->source_ip.ipv6[9], ++ ip_stream->source_ip.ipv6[10], ++ ip_stream->source_ip.ipv6[11], ++ ip_stream->source_ip.ipv6[12], ++ ip_stream->source_ip.ipv6[13], ++ ip_stream->source_ip.ipv6[14], ++ ip_stream->source_ip.ipv6[15]); ++ fprintf(stdout, " DestinationIPAddress %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n", ++ ip_stream->destination_ip.ipv6[0], ++ ip_stream->destination_ip.ipv6[1], ++ ip_stream->destination_ip.ipv6[2], ++ ip_stream->destination_ip.ipv6[3], ++ ip_stream->destination_ip.ipv6[4], ++ ip_stream->destination_ip.ipv6[5], ++ ip_stream->destination_ip.ipv6[6], ++ ip_stream->destination_ip.ipv6[7], ++ ip_stream->destination_ip.ipv6[8], ++ ip_stream->destination_ip.ipv6[9], ++ ip_stream->destination_ip.ipv6[10], ++ ip_stream->destination_ip.ipv6[11], ++ ip_stream->destination_ip.ipv6[12], ++ ip_stream->destination_ip.ipv6[13], ++ ip_stream->destination_ip.ipv6[14], ++ ip_stream->destination_ip.ipv6[15]); ++ } ++ fprintf(stdout, " Port %d\n", ip_stream->port); ++ fprintf(stdout, " SessionID %d\n", ip_stream->session_id); ++ ++ field = partition->field_list; ++ esg_session_ip_stream_field_list_for_each(ip_stream, ip_stream_field) { ++ switch (field->encoding) { ++ case 0x0000: { ++ if (ip_stream_field->start_field_value != NULL) { ++ fprintf(stdout, " start_field_value %s\n", ip_stream_field->start_field_value->string); ++ } ++ fprintf(stdout, " end_field_value %s\n", ip_stream_field->end_field_value->string); ++ break; ++ } ++ case 0x0101: { ++ if (ip_stream_field->start_field_value != NULL) { ++ fprintf(stdout, " start_field_value %d\n", ip_stream_field->start_field_value->unsigned_short); ++ } ++ fprintf(stdout, " end_field_value %d\n", ip_stream_field->end_field_value->unsigned_short); ++ break; ++ } ++ } ++ ++ field = field->_next; ++ } ++ fprintf(stdout, "\n"); ++ } ++ break; ++ } ++ default: { ++ fprintf(stdout, " Unknown structure_id\n"); ++ } ++ } ++ break; ++ } ++ case 0xE2: { ++ switch (structure->id) { ++ case 0x00: { ++ fprintf(stdout, " ESG Init Message\n"); ++ ++ init_message = (struct esg_init_message *) structure->data; ++ if (init_message == NULL) { ++ fprintf(stderr, "ESG Init Message decode error\n"); ++ exit(1); ++ } ++ ++ fprintf(stdout, " EncodingVersion %d [0x%02x]\n", init_message->encoding_version, init_message->encoding_version); ++ fprintf(stdout, " IndexingFlag %d\n", init_message->indexing_flag); ++ fprintf(stdout, " DecoderInitptr %d\n", init_message->decoder_init_ptr); ++ if (init_message->indexing_flag) { ++ fprintf(stdout, " IndexingVersion %d\n", init_message->indexing_version); ++ } ++ ++ switch (init_message->encoding_version) { ++ case 0xF1: { ++ bim_encoding_parameters = (struct esg_bim_encoding_parameters *) init_message->encoding_parameters; ++ if (bim_encoding_parameters == NULL) { ++ fprintf(stderr, "ESG Init Message decode error / bim_encoding_parameters\n"); ++ exit(1); ++ } ++ fprintf(stdout, " BufferSizeFlag %d\n", bim_encoding_parameters->buffer_size_flag); ++ fprintf(stdout, " PositionCodeFlag %d\n", bim_encoding_parameters->position_code_flag); ++ fprintf(stdout, " CharacterEncoding %d\n", bim_encoding_parameters->character_encoding); ++ if (bim_encoding_parameters->buffer_size_flag) { ++ fprintf(stdout, " BufferSize %d\n", bim_encoding_parameters->buffer_size); ++ } ++ ++ // TODO BimDecoderInit ++ break; ++ } ++ case 0xF2: ++ case 0xF3: { ++ textual_encoding_parameters = (struct esg_textual_encoding_parameters *) init_message->encoding_parameters; ++ if (textual_encoding_parameters == NULL) { ++ fprintf(stderr, "ESG Init Message decode error / textual_encoding_parameters\n"); ++ exit(1); ++ } ++ fprintf(stdout, " CharacterEncoding %d\n\n", textual_encoding_parameters->character_encoding); ++ ++ // TextualDecoderInit ++ textual_decoder_init = (struct esg_textual_decoder_init *) init_message->decoder_init; ++ if (textual_decoder_init == NULL) { ++ fprintf(stderr, "ESG Init Message decode error / textual_decoder_init\n"); ++ exit(1); ++ } ++ fprintf(stdout, " Textual DecoderInit\n"); ++ fprintf(stdout, " num_namespaces_prefixes %d\n\n", textual_decoder_init->num_namespace_prefixes); ++ esg_textual_decoder_namespace_prefix_list_for_each(textual_decoder_init, namespace_prefix) { ++ fprintf(stdout, " prefix_string_ptr %d\n", namespace_prefix->prefix_string_ptr); ++ fprintf(stdout, " namespace_URI_ptr %d\n\n", namespace_prefix->namespace_uri_ptr); ++ } ++ fprintf(stdout, " num_fragment_types %d\n\n", textual_decoder_init->num_fragment_types); ++ esg_textual_decoder_xml_fragment_type_list_for_each(textual_decoder_init, xml_fragment_type) { ++ fprintf(stdout, " xpath_ptr %d\n", xml_fragment_type->xpath_ptr); ++ fprintf(stdout, " ESG_XML_fragment_type %d\n\n", xml_fragment_type->xml_fragment_type); ++ } ++ break; ++ } ++ default: { ++ fprintf(stdout, " Unknown EncodingVersion\n"); ++ } ++ } ++ ++ break; ++ } ++ default: { ++ fprintf(stdout, " Unknown structure_id\n"); ++ } ++ } ++ break; ++ } ++ default: { ++ fprintf(stdout, " Unknown structure_type\n"); ++ } ++ } ++ } ++ fprintf(stdout, "\n"); ++ ++ fprintf(stdout, "structure_body_ptr %d\n", container->structure_body_ptr); ++ fprintf(stdout, "structure_body_length %d\n\n", container->structure_body_length); ++ ++ // ESG XML Fragment ++ if (fragment_management_information) { ++ fprintf(stdout, "**************************************************\n"); ++ fprintf(stdout, "ESG XML Fragment\n"); ++ fprintf(stdout, "**************************************************\n\n"); ++ ++ struct esg_encapsulation_entry *entry; ++ esg_encapsulation_structure_entry_list_for_each(fragment_management_information, entry) { ++ switch (entry->fragment_reference->fragment_type) { ++ case 0x00: { ++ if (data_repository) { ++ struct esg_encapsulated_textual_esg_xml_fragment *esg_xml_fragment = esg_encapsulated_textual_esg_xml_fragment_decode(data_repository->data + entry->fragment_reference->data_repository_offset, data_repository->length); ++ ++ fprintf(stdout, "ESG_XML_fragment_type %d\n", esg_xml_fragment->esg_xml_fragment_type); ++ fprintf(stdout, "data_length %d\n", esg_xml_fragment->data_length); ++ fprintf(stdout, "fragment_version %d\n", entry->fragment_version); ++ fprintf(stdout, "fragment_id %d\n\n", entry->fragment_id); ++ char *string = (char *) malloc(esg_xml_fragment->data_length + 1); ++ memcpy(string, esg_xml_fragment->data, esg_xml_fragment->data_length); ++ string[esg_xml_fragment->data_length] = 0; ++ fprintf(stdout, "%s\n", string); ++ ++ } else { ++ fprintf(stderr, "ESG Data Repository not found"); ++ } ++ break; ++ } ++ case 0x01: { ++ // TODO ++ break; ++ } ++ case 0x02: { ++ // TODO ++ break; ++ } ++ default: { ++ } ++ } ++ } ++ } ++ ++ // String ++ if (init_message) { ++ fprintf(stdout, "**************************************************\n"); ++ fprintf(stdout, "String\n"); ++ fprintf(stdout, "**************************************************\n\n"); ++ ++ switch (init_message->encoding_version) { ++ case 0xF1: { ++ // TODO Bim ++ break; ++ } ++ case 0xF2: { ++ // TODO GZIP ++ break; ++ } ++ case 0xF3: { ++ // RAW ++ if (string_repository) { ++ textual_decoder_init = (struct esg_textual_decoder_init *) init_message->decoder_init; ++ esg_textual_decoder_namespace_prefix_list_for_each(textual_decoder_init, namespace_prefix) { ++ fprintf(stdout, "prefix_string_ptr %d\n", namespace_prefix->prefix_string_ptr); ++ fprintf(stdout, "%s\n", string_repository->data + namespace_prefix->prefix_string_ptr); ++ fprintf(stdout, "namespace_URI_ptr %d\n", namespace_prefix->namespace_uri_ptr); ++ fprintf(stdout, "%s\n\n", string_repository->data + namespace_prefix->namespace_uri_ptr - 1); // TODO -1 ++ } ++ ++ esg_textual_decoder_xml_fragment_type_list_for_each(textual_decoder_init, xml_fragment_type) { ++ fprintf(stdout, "xpath_ptr %d\n", xml_fragment_type->xpath_ptr); ++ fprintf(stdout, "ESG_XML_fragment_type %d\n", xml_fragment_type->xml_fragment_type); ++ fprintf(stdout, "%s\n\n", string_repository->data + xml_fragment_type->xpath_ptr - 1); // TODO -1 ++ } ++ } ++ break; ++ } ++ default: { ++ fprintf(stdout, " Unknown EncodingVersion\n"); ++ } ++ } ++ } ++ } ++ ++ return 0; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/test/libucsi/Makefile dvb-apps/test/libucsi/Makefile +--- linuxtv-dvb-apps-1.1.1/test/libucsi/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/test/libucsi/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,13 @@ ++# Makefile for linuxtv.org dvb-apps/test/libucsi ++ ++binaries = testucsi ++ ++CPPFLAGS += -I../../lib ++LDLIBS += ../../lib/libdvbapi/libdvbapi.a ../../lib/libdvbcfg/libdvbcfg.a \ ++ ../../lib/libdvbsec/libdvbsec.a ../../lib/libucsi/libucsi.a ++ ++.PHONY: all ++ ++all: $(binaries) ++ ++include ../../Make.rules +diff -Nurd linuxtv-dvb-apps-1.1.1/test/libucsi/testucsi.c dvb-apps/test/libucsi/testucsi.c +--- linuxtv-dvb-apps-1.1.1/test/libucsi/testucsi.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/test/libucsi/testucsi.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,3528 @@ ++/* ++ * section and descriptor parser test/sample application. ++ * ++ * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net) ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++void receive_data(int dvrfd, int timeout, int data_type); ++void parse_section(uint8_t *buf, int len, int pid, int data_type); ++void parse_dvb_section(uint8_t *buf, int len, int pid, int data_type, struct section *section); ++void parse_atsc_section(uint8_t *buf, int len, int pid, int data_type, struct section *section); ++void parse_descriptor(struct descriptor *d, int indent, int data_type); ++void parse_dvb_descriptor(struct descriptor *d, int indent, int data_type); ++void parse_atsc_descriptor(struct descriptor *d, int indent, int data_type); ++void iprintf(int indent, char *fmt, ...); ++void hexdump(int indent, char *prefix, uint8_t *buf, int buflen); ++void atsctextdump(char *header, int indent, struct atsc_text *atext, int len); ++int channels_cb(struct dvbcfg_zapchannel *channel, void *private); ++void ts_from_file(char *filename, int data_type); ++ ++#define TIME_CHECK_VAL 1131835761 ++#define DURATION_CHECK_VAL 5643 ++ ++#define MAX_TUNE_TIME 3000 ++#define MAX_DUMP_TIME 60 ++ ++#define DATA_TYPE_MPEG 0 ++#define DATA_TYPE_DVB 1 ++#define DATA_TYPE_ATSC 2 ++ ++ ++struct dvbfe_handle *fe; ++struct dvbfe_info feinfo; ++int demuxfd; ++int dvrfd; ++ ++int main(int argc, char *argv[]) ++{ ++ int adapter; ++ char *channelsfile; ++ int pidlimit = -1; ++ dvbdate_t dvbdate; ++ dvbduration_t dvbduration; ++ ++ // process arguments ++ if ((argc < 3) || (argc > 4)) { ++ fprintf(stderr, "Syntax: testucsi |-atscfile []\n"); ++ exit(1); ++ } ++ if (!strcmp(argv[1], "-atscfile")) { ++ ts_from_file(argv[2], DATA_TYPE_ATSC); ++ exit(0); ++ } ++ adapter = atoi(argv[1]); ++ channelsfile = argv[2]; ++ if (argc == 4) ++ sscanf(argv[3], "%i", &pidlimit); ++ printf("Using adapter %i\n", adapter); ++ ++ // check the dvbdate conversion functions ++ unixtime_to_dvbdate(TIME_CHECK_VAL, dvbdate); ++ if (dvbdate_to_unixtime(dvbdate) != TIME_CHECK_VAL) { ++ fprintf(stderr, "XXXX dvbdate function check failed (%i!=%i)\n", ++ TIME_CHECK_VAL, (int) dvbdate_to_unixtime(dvbdate)); ++ exit(1); ++ } ++ seconds_to_dvbduration(DURATION_CHECK_VAL, dvbduration); ++ if (dvbduration_to_seconds(dvbduration) != DURATION_CHECK_VAL) { ++ fprintf(stderr, "XXXX dvbduration function check failed (%i!=%i)\n", ++ DURATION_CHECK_VAL, (int) dvbduration_to_seconds(dvbduration)); ++ exit(1); ++ } ++ ++ // open the frontend ++ if ((fe = dvbfe_open(adapter, 0, 0)) == NULL) { ++ perror("open frontend"); ++ exit(1); ++ } ++ dvbfe_get_info(fe, 0, &feinfo, DVBFE_INFO_QUERYTYPE_IMMEDIATE, 0); ++ int data_type = DATA_TYPE_MPEG; ++ switch(feinfo.type) { ++ case DVBFE_TYPE_DVBS: ++ case DVBFE_TYPE_DVBC: ++ case DVBFE_TYPE_DVBT: ++ data_type = DATA_TYPE_DVB; ++ break; ++ ++ case DVBFE_TYPE_ATSC: ++ data_type = DATA_TYPE_ATSC; ++ break; ++ } ++ ++ // open demux devices ++ if ((demuxfd = dvbdemux_open_demux(adapter, 0, 0)) < 0) { ++ perror("demux"); ++ exit(1); ++ } ++ if ((dvrfd = dvbdemux_open_dvr(adapter, 0, 1, 1)) < 0) { ++ perror("dvr"); ++ exit(1); ++ } ++ ++ // make the demux buffer a bit larger ++ if (dvbdemux_set_buffer(demuxfd, 1024*1024)) { ++ perror("set buffer"); ++ exit(1); ++ } ++ ++ // setup filter to capture stuff ++ if (dvbdemux_set_pid_filter(demuxfd, pidlimit, DVBDEMUX_INPUT_FRONTEND, DVBDEMUX_OUTPUT_DVR, 1)) { ++ perror("set pid filter"); ++ exit(1); ++ } ++ ++ // process all the channels ++ FILE *channels = fopen(channelsfile, "r"); ++ if (channels == NULL) { ++ fprintf(stderr, "Unable to open %s\n", channelsfile); ++ exit(1); ++ } ++ dvbcfg_zapchannel_parse(channels, channels_cb, (void*) (long) data_type); ++ return 0; ++} ++ ++void ts_from_file(char *filename, int data_type) { ++ int fd = open(filename, O_RDONLY); ++ if (fd < 0) { ++ fprintf(stderr, "Unable to open file %s\n", filename); ++ exit(1); ++ } ++ receive_data(fd, 1000000000, data_type); ++} ++ ++int channels_cb(struct dvbcfg_zapchannel *channel, void *private) ++{ ++ long data_type = (long) private; ++ struct dvbsec_config sec; ++ ++ if (dvbsec_cfg_find(NULL, "UNIVERSAL", &sec)) { ++ fprintf(stderr, "Unable to find SEC id\n"); ++ exit(1); ++ } ++ ++ if (dvbsec_set(fe, ++ &sec, ++ channel->polarization, ++ DISEQC_SWITCH_UNCHANGED, ++ DISEQC_SWITCH_UNCHANGED, ++ &channel->fe_params, ++ MAX_TUNE_TIME)) { ++ fprintf(stderr, "Failed to lock!\n"); ++ } else { ++ printf("Tuned successfully!\n"); ++ receive_data(dvrfd, MAX_DUMP_TIME, data_type); ++ } ++ ++ return 0; ++} ++ ++void receive_data(int _dvrfd, int timeout, int data_type) ++{ ++ unsigned char databuf[TRANSPORT_PACKET_LENGTH*20]; ++ int sz; ++ int pid; ++ int i; ++ int used; ++ int section_status; ++ time_t starttime; ++ unsigned char continuities[TRANSPORT_MAX_PIDS]; ++ struct section_buf *section_bufs[TRANSPORT_MAX_PIDS]; ++ struct transport_packet *tspkt; ++ struct transport_values tsvals; ++ ++ // process the data ++ starttime = time(NULL); ++ memset(continuities, 0, sizeof(continuities)); ++ memset(section_bufs, 0, sizeof(section_bufs)); ++ while((time(NULL) - starttime) < timeout) { ++ // got some! ++ if ((sz = read(_dvrfd, databuf, sizeof(databuf))) < 0) { ++ if (errno == EOVERFLOW) { ++ fprintf(stderr, "data overflow!\n"); ++ continue; ++ } else if (errno == EAGAIN) { ++ usleep(100); ++ continue; ++ } else { ++ perror("read error"); ++ exit(1); ++ } ++ } ++ for(i=0; i < sz; i+=TRANSPORT_PACKET_LENGTH) { ++ // parse the transport packet ++ tspkt = transport_packet_init(databuf + i); ++ if (tspkt == NULL) { ++ fprintf(stderr, "XXXX Bad sync byte\n"); ++ continue; ++ } ++ pid = transport_packet_pid(tspkt); ++ ++ // extract all TS packet values even though we don't need them (to check for ++ // library segfaults etc) ++ if (transport_packet_values_extract(tspkt, &tsvals, 0xffff) < 0) { ++ fprintf(stderr, "XXXX Bad packet received (pid:%04x)\n", pid); ++ continue; ++ } ++ ++ // check continuity ++ if (transport_packet_continuity_check(tspkt, ++ tsvals.flags & transport_adaptation_flag_discontinuity, ++ continuities + pid)) { ++ fprintf(stderr, "XXXX Continuity error (pid:%04x)\n", pid); ++ continuities[pid] = 0; ++ if (section_bufs[pid] != NULL) { ++ section_buf_reset(section_bufs[pid]); ++ } ++ continue; ++ } ++ ++ // allocate section buf if we don't have one already ++ if (section_bufs[pid] == NULL) { ++ section_bufs[pid] = (struct section_buf*) ++ malloc(sizeof(struct section_buf) + DVB_MAX_SECTION_BYTES); ++ if (section_bufs[pid] == NULL) { ++ fprintf(stderr, "Failed to allocate section buf (pid:%04x)\n", pid); ++ exit(1); ++ } ++ section_buf_init(section_bufs[pid], DVB_MAX_SECTION_BYTES); ++ } ++ ++ // process the payload data as a section ++ while(tsvals.payload_length) { ++ used = section_buf_add_transport_payload(section_bufs[pid], ++ tsvals.payload, ++ tsvals.payload_length, ++ tspkt->payload_unit_start_indicator, ++ §ion_status); ++ tspkt->payload_unit_start_indicator = 0; ++ tsvals.payload_length -= used; ++ tsvals.payload += used; ++ ++ if (section_status == 1) { ++ parse_section(section_buf_data(section_bufs[pid]), ++ section_bufs[pid]->len, pid, data_type); ++ section_buf_reset(section_bufs[pid]); ++ } else if (section_status < 0) { ++ // some kind of error - just discard ++ fprintf(stderr, "XXXX bad section %04x %i\n",pid, section_status); ++ section_buf_reset(section_bufs[pid]); ++ } ++ } ++ } ++ } ++} ++ ++void parse_section(uint8_t *buf, int len, int pid, int data_type) ++{ ++ struct section *section; ++ struct section_ext *section_ext = NULL; ++ ++ if ((section = section_codec(buf, len)) == NULL) { ++ return; ++ } ++ ++ switch(section->table_id) { ++ case stag_mpeg_program_association: ++ { ++ struct mpeg_pat_section *pat; ++ struct mpeg_pat_program *cur; ++ ++ if ((section_ext = section_ext_decode(section, 1)) == NULL) { ++ return; ++ } ++ printf("SCT Decode PAT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((pat = mpeg_pat_section_codec(section_ext)) == NULL) { ++ fprintf(stderr, "SCT XXXX PAT section decode error\n"); ++ return; ++ } ++ printf("SCT transport_stream_id:0x%04x\n", mpeg_pat_section_transport_stream_id(pat)); ++ mpeg_pat_section_programs_for_each(pat, cur) { ++ printf("\tSCT program_number:0x%04x pid:0x%04x\n", cur->program_number, cur->pid); ++ } ++ break; ++ } ++ ++ case stag_mpeg_conditional_access: ++ { ++ struct mpeg_cat_section *cat; ++ struct descriptor *curd; ++ ++ if ((section_ext = section_ext_decode(section, 1)) == NULL) { ++ return; ++ } ++ printf("SCT Decode CAT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((cat = mpeg_cat_section_codec(section_ext)) == NULL) { ++ fprintf(stderr, "SCT XXXX CAT section decode error\n"); ++ return; ++ } ++ mpeg_cat_section_descriptors_for_each(cat, curd) { ++ parse_descriptor(curd, 1, data_type); ++ } ++ break; ++ } ++ ++ case stag_mpeg_program_map: ++ { ++ struct mpeg_pmt_section *pmt; ++ struct descriptor *curd; ++ struct mpeg_pmt_stream *cur_stream; ++ ++ if ((section_ext = section_ext_decode(section, 1)) == NULL) { ++ return; ++ } ++ printf("SCT Decode PMT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((pmt = mpeg_pmt_section_codec(section_ext)) == NULL) { ++ fprintf(stderr, "SCT XXXX PMT section decode error\n"); ++ return; ++ } ++ printf("SCT program_number:0x%04x pcr_pid:0x%02x\n", mpeg_pmt_section_program_number(pmt), pmt->pcr_pid); ++ mpeg_pmt_section_descriptors_for_each(pmt, curd) { ++ parse_descriptor(curd, 1, data_type); ++ } ++ mpeg_pmt_section_streams_for_each(pmt, cur_stream) { ++ printf("\tSCT stream_type:0x%02x pid:0x%04x\n", cur_stream->stream_type, cur_stream->pid); ++ mpeg_pmt_stream_descriptors_for_each(cur_stream, curd) { ++ parse_descriptor(curd, 2, data_type); ++ } ++ } ++ break; ++ } ++ ++ case stag_mpeg_transport_stream_description: ++ { ++ struct mpeg_tsdt_section *tsdt; ++ struct descriptor *curd; ++ ++ if ((section_ext = section_ext_decode(section, 1)) == NULL) { ++ return; ++ } ++ printf("SCT Decode TSDT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((tsdt = mpeg_tsdt_section_codec(section_ext)) == NULL) { ++ fprintf(stderr, "SCT XXXX TSDT section decode error\n"); ++ return; ++ } ++ mpeg_tsdt_section_descriptors_for_each(tsdt, curd) { ++ parse_descriptor(curd, 1, data_type); ++ } ++ ++ hexdump(0, "SCT ", buf, len); ++ getchar(); ++ break; ++ } ++ ++ case stag_mpeg_metadata: ++ { ++ struct mpeg_metadata_section *metadata; ++ ++ if ((section_ext = section_ext_decode(section, 1)) == NULL) { ++ return; ++ } ++ printf("SCT Decode metadata (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((metadata = mpeg_metadata_section_codec(section_ext)) == NULL) { ++ fprintf(stderr, "SCT XXXX metadata section decode error\n"); ++ return; ++ } ++ printf("SCT random_access_indicator:%i decoder_config_flag:%i fragment_indicator:%i service_id:%02x\n", ++ mpeg_metadata_section_random_access_indicator(metadata), ++ mpeg_metadata_section_decoder_config_flag(metadata), ++ mpeg_metadata_section_fragment_indicator(metadata), ++ mpeg_metadata_section_service_id(metadata)); ++ hexdump(0, "SCT ", mpeg_metadata_section_data(metadata), mpeg_metadata_section_data_length(metadata)); ++ ++ hexdump(0, "SCT ", buf, len); ++ getchar(); ++ break; ++ } ++ ++ case stag_mpeg_iso14496_scene_description: ++ case stag_mpeg_iso14496_object_description: ++ { ++ struct mpeg_odsmt_section *odsmt; ++ struct mpeg_odsmt_stream *cur_stream; ++ struct descriptor *curd; ++ int _index; ++ uint8_t *objects; ++ size_t objects_length; ++ ++ if ((section_ext = section_ext_decode(section, 1)) == NULL) { ++ return; ++ } ++ printf("SCT Decode ISO14496 (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((odsmt = mpeg_odsmt_section_codec(section_ext)) == NULL) { ++ fprintf(stderr, "XXXX ISO14496 section decode error\n"); ++ return; ++ } ++ printf("SCT PID:0x%04x\n", mpeg_odsmt_section_pid(odsmt)); ++ mpeg_odsmt_section_streams_for_each(osdmt, cur_stream, _index) { ++ if (odsmt->stream_count == 0) { ++ printf("\tSCT SINGLE 0x%04x\n", cur_stream->u.single.esid); ++ } else { ++ printf("\tSCT MULTI 0x%04x 0x%02x\n", cur_stream->u.multi.esid, cur_stream->u.multi.fmc); ++ } ++ mpeg_odsmt_stream_descriptors_for_each(osdmt, cur_stream, curd) { ++ parse_descriptor(curd, 2, data_type); ++ } ++ } ++ objects = mpeg_odsmt_section_object_descriptors(odsmt, &objects_length); ++ if (objects == NULL) { ++ printf("SCT XXXX OSDMT parse error\n"); ++ break; ++ } ++ hexdump(1, "SCT ", objects, objects_length); ++ ++ hexdump(0, "SCT ", buf, len); ++ getchar(); ++ break; ++ } ++ ++ default: ++ switch(data_type) { ++ case DATA_TYPE_DVB: ++ parse_dvb_section(buf, len, pid, data_type, section); ++ break; ++ ++ case DATA_TYPE_ATSC: ++ parse_atsc_section(buf, len, pid, data_type, section); ++ break; ++ ++ default: ++ fprintf(stderr, "SCT XXXX Unknown table_id:0x%02x (pid:0x%04x)\n", ++ section->table_id, pid); ++// hexdump(0, "SCT ", buf, len); ++ return; ++ } ++ } ++ ++ printf("\n"); ++} ++ ++void parse_dvb_section(uint8_t *buf, int len, int pid, int data_type, struct section *section) ++{ ++ struct section_ext *section_ext = NULL; ++ ++ switch(section->table_id) { ++ case stag_dvb_network_information_actual: ++ case stag_dvb_network_information_other: ++ { ++ struct dvb_nit_section *nit; ++ struct descriptor *curd; ++ struct dvb_nit_section_part2 *part2; ++ struct dvb_nit_transport *cur_transport; ++ ++ if ((section_ext = section_ext_decode(section, 1)) == NULL) { ++ return; ++ } ++ printf("SCT Decode NIT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((nit = dvb_nit_section_codec(section_ext)) == NULL) { ++ fprintf(stderr, "SCT XXXX NIT section decode error\n"); ++ return; ++ } ++ printf("SCT network_id:0x%04x\n", dvb_nit_section_network_id(nit)); ++ dvb_nit_section_descriptors_for_each(nit, curd) { ++ parse_descriptor(curd, 1, data_type); ++ } ++ part2 = dvb_nit_section_part2(nit); ++ dvb_nit_section_transports_for_each(nit, part2, cur_transport) { ++ printf("\tSCT transport_stream_id:0x%04x original_network_id:0x%04x\n", cur_transport->transport_stream_id, cur_transport->original_network_id); ++ dvb_nit_transport_descriptors_for_each(cur_transport, curd) { ++ parse_descriptor(curd, 2, data_type); ++ } ++ } ++ break; ++ } ++ ++ case stag_dvb_service_description_actual: ++ case stag_dvb_service_description_other: ++ { ++ struct dvb_sdt_section *sdt; ++ struct dvb_sdt_service *cur_service; ++ struct descriptor *curd; ++ ++ if ((section_ext = section_ext_decode(section, 1)) == NULL) { ++ return; ++ } ++ printf("SCT Decode SDT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((sdt = dvb_sdt_section_codec(section_ext)) == NULL) { ++ fprintf(stderr, "XXXX SDT section decode error\n"); ++ return; ++ } ++ printf("SCT transport_stream_id:0x%04x original_network_id:0x%04x\n", dvb_sdt_section_transport_stream_id(sdt), sdt->original_network_id); ++ dvb_sdt_section_services_for_each(sdt, cur_service) { ++ printf("\tSCT service_id:0x%04x eit_schedule_flag:%i eit_present_following_flag:%i running_status:%i free_ca_mode:%i\n", ++ cur_service->service_id, ++ cur_service->eit_schedule_flag, ++ cur_service->eit_present_following_flag, ++ cur_service->running_status, ++ cur_service->free_ca_mode); ++ dvb_sdt_service_descriptors_for_each(cur_service, curd) { ++ parse_descriptor(curd, 2, data_type); ++ } ++ } ++ break; ++ } ++ ++ case stag_dvb_bouquet_association: ++ { ++ struct dvb_bat_section *bat; ++ struct descriptor *curd; ++ struct dvb_bat_section_part2 *part2; ++ struct dvb_bat_transport *cur_transport; ++ ++ if ((section_ext = section_ext_decode(section, 1)) == NULL) { ++ return; ++ } ++ printf("SCT Decode BAT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((bat = dvb_bat_section_codec(section_ext)) == NULL) { ++ fprintf(stderr, "SCT XXXX BAT section decode error\n"); ++ return; ++ } ++ printf("SCT bouquet_id:0x%04x\n", dvb_bat_section_bouquet_id(bat)); ++ dvb_bat_section_descriptors_for_each(bat, curd) { ++ parse_descriptor(curd, 1, data_type); ++ } ++ part2 = dvb_bat_section_part2(bat); ++ dvb_bat_section_transports_for_each(part2, cur_transport) { ++ printf("\tSCT transport_stream_id:0x%04x original_network_id:0x%04x\n", ++ cur_transport->transport_stream_id, ++ cur_transport->original_network_id); ++ dvb_bat_transport_descriptors_for_each(cur_transport, curd) { ++ parse_descriptor(curd, 2, data_type); ++ } ++ } ++ break; ++ } ++ ++ case stag_dvb_update_notification: ++ case stag_dvb_ip_mac_notification: ++ { ++ struct dvb_int_section *_int; ++ struct descriptor *curd; ++ struct dvb_int_target *cur_target; ++ struct dvb_int_operational_loop *operational_loop; ++ ++ if ((section_ext = section_ext_decode(section, 1)) == NULL) { ++ return; ++ } ++ printf("SCT Decode INT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((_int = dvb_int_section_codec(section_ext)) == NULL) { ++ fprintf(stderr, "XXXX INT section decode error\n"); ++ return; ++ } ++ printf("SCT action_type:0x%02x platform_id_hash:0x%02x platform_id:0x%06x processing_order:0x%02x\n", ++ dvb_int_section_action_type(_int), ++ dvb_int_section_platform_id_hash(_int), ++ _int->platform_id, ++ _int->processing_order); ++ dvb_int_section_platform_descriptors_for_each(_int, curd) { ++ parse_descriptor(curd, 1, data_type); ++ } ++ dvb_int_section_target_loop_for_each(_int, cur_target) { ++ dvb_int_target_target_descriptors_for_each(cur_target, curd) { ++ parse_descriptor(curd, 2, data_type); ++ } ++ operational_loop = dvb_int_target_operational_loop(cur_target); ++ dvb_int_operational_loop_operational_descriptors_for_each(operational_loop, curd) { ++ parse_descriptor(curd, 3, data_type); ++ } ++ } ++ ++ hexdump(0, "SCT ", buf, len); ++ getchar(); ++ break; ++ } ++ ++ case stag_dvb_event_information_nownext_actual: ++ case stag_dvb_event_information_nownext_other: ++ case 0x50: case 0x51: case 0x52: case 0x53: case 0x54: case 0x55: case 0x56: case 0x57: ++ case 0x58: case 0x59: case 0x5a: case 0x5b: case 0x5c: case 0x5d: case 0x5e: case 0x5f: ++ case 0x60: case 0x61: case 0x62: case 0x63: case 0x64: case 0x65: case 0x66: case 0x67: ++ case 0x68: case 0x69: case 0x6a: case 0x6b: case 0x6c: case 0x6d: case 0x6e: case 0x6f: ++ { ++ struct dvb_eit_section *eit; ++ struct dvb_eit_event *cur_event; ++ struct descriptor *curd; ++ time_t start_time; ++ ++ if ((section_ext = section_ext_decode(section, 1)) == NULL) { ++ return; ++ } ++ printf("SCT Decode EIT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((eit = dvb_eit_section_codec(section_ext)) == NULL) { ++ fprintf(stderr, "XXXX EIT section decode error\n"); ++ return; ++ } ++ printf("SCT service_id:0x%04x transport_stream_id:0x%04x original_network_id:0x%04x segment_last_section_number:0x%02x last_table_id:0x%02x\n", ++ dvb_eit_section_service_id(eit), ++ eit->transport_stream_id, ++ eit->original_network_id, ++ eit->segment_last_section_number, ++ eit->last_table_id); ++ dvb_eit_section_events_for_each(eit, cur_event) { ++ start_time = dvbdate_to_unixtime(cur_event->start_time); ++ printf("\tSCT event_id:0x%04x duration:%i running_status:%i free_ca_mode:%i start_time:%i -- %s", ++ cur_event->event_id, ++ dvbduration_to_seconds(cur_event->duration), ++ cur_event->running_status, ++ cur_event->free_ca_mode, ++ (int) start_time, ++ ctime(&start_time)); ++ dvb_eit_event_descriptors_for_each(cur_event, curd) { ++ parse_descriptor(curd, 2, data_type); ++ } ++ } ++ break; ++ } ++ ++ case stag_dvb_time_date: ++ { ++ struct dvb_tdt_section *tdt; ++ time_t dvbtime; ++ ++ printf("SCT Decode TDT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((tdt = dvb_tdt_section_codec(section)) == NULL) { ++ fprintf(stderr, "XXXX TDT section decode error\n"); ++ return; ++ } ++ dvbtime = dvbdate_to_unixtime(tdt->utc_time); ++ printf("SCT Time: %i -- %s", (int) dvbtime, ctime(&dvbtime)); ++ break; ++ } ++ ++ case stag_dvb_running_status: ++ { ++ struct dvb_rst_section *rst; ++ struct dvb_rst_status *cur_status; ++ ++ printf("SCT Decode RST (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((rst = dvb_rst_section_codec(section)) == NULL) { ++ fprintf(stderr, "SCT XXXX RST section decode error\n"); ++ return; ++ } ++ dvb_rst_section_statuses_for_each(rst, cur_status) { ++ printf("\tSCT transport_stream_id:0x%04x original_network_id:0x%04x service_id:0x%04x event_id:0x%04x running_status:%i\n", ++ cur_status->transport_stream_id, ++ cur_status->original_network_id, ++ cur_status->service_id, ++ cur_status->event_id, ++ cur_status->running_status); ++ } ++ ++// hexdump(0, "SCT ", buf, len); ++// getchar(); ++ break; ++ } ++ ++ case stag_dvb_stuffing: ++ { ++ struct dvb_st_section *st; ++ ++ printf("SCT Decode ST (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((st = dvb_st_section_codec(section)) == NULL) { ++ fprintf(stderr, "SCT XXXX ST section decode error\n"); ++ return; ++ } ++ printf("SCT Length: %i\n", dvb_st_section_data_length(st)); ++ break; ++ } ++ ++ case stag_dvb_time_offset: ++ { ++ struct dvb_tot_section *tot; ++ struct descriptor *curd; ++ time_t dvbtime; ++ ++ if (section_check_crc(section)) ++ return; ++ printf("SCT Decode TOT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((tot = dvb_tot_section_codec(section)) == NULL) { ++ fprintf(stderr, "SCT XXXX TOT section decode error\n"); ++ return; ++ } ++ dvbtime = dvbdate_to_unixtime(tot->utc_time); ++ printf("SCT utc_time: %i -- %s", (int) dvbtime, ctime(&dvbtime)); ++ dvb_tot_section_descriptors_for_each(tot, curd) { ++ parse_descriptor(curd, 1, data_type); ++ } ++ break; ++ } ++ ++ case stag_dvb_tva_container: ++ { ++ struct dvb_tva_container_section *tva; ++ ++ if ((section_ext = section_ext_decode(section, 1)) == NULL) { ++ return; ++ } ++ printf("SCT Decode tva (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((tva = dvb_tva_container_section_codec(section_ext)) == NULL) { ++ fprintf(stderr, "SCT XXXX tva section decode error\n"); ++ return; ++ } ++ printf("SCT container_id:%04x\n", ++ dvb_tva_container_section_container_id(tva)); ++ hexdump(0, "SCT ", dvb_tva_container_section_data(tva), dvb_tva_container_section_data_length(tva)); ++ ++ hexdump(0, "SCT ", buf, len); ++ getchar(); ++ break; ++ } ++ ++ case stag_dvb_discontinuity_information: ++ { ++ struct dvb_dit_section *dit; ++ ++ printf("SCT Decode DIT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((dit = dvb_dit_section_codec(section)) == NULL) { ++ fprintf(stderr, "SCT XXXX DIT section decode error\n"); ++ return; ++ } ++ printf("SCT transition_flag:%i\n", dit->transition_flag); ++ ++// hexdump(0, "SCT ", buf, len); ++// getchar(); ++ break; ++ } ++ ++ case stag_dvb_selection_information: ++ { ++ struct dvb_sit_section *sit; ++ struct descriptor *curd; ++ struct dvb_sit_service *cur_service; ++ ++ if ((section_ext = section_ext_decode(section, 1)) == NULL) { ++ return; ++ } ++ printf("SCT Decode SIT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((sit = dvb_sit_section_codec(section_ext)) == NULL) { ++ fprintf(stderr, "SCT XXXX SIT section decode error\n"); ++ return; ++ } ++ dvb_sit_section_descriptors_for_each(sit, curd) { ++ parse_descriptor(curd, 1, data_type); ++ } ++ dvb_sit_section_services_for_each(sit, cur_service) { ++ printf("\tSCT service_id:0x%04x running_status:%i\n", cur_service->service_id, cur_service->running_status); ++ dvb_sit_service_descriptors_for_each(cur_service, curd) { ++ parse_descriptor(curd, 2, data_type); ++ } ++ } ++ ++ hexdump(0, "SCT ", buf, len); ++ getchar(); ++ break; ++ } ++ ++ default: ++ fprintf(stderr, "SCT XXXX Unknown table_id:0x%02x (pid:0x%04x)\n", section->table_id, pid); ++// hexdump(0, "SCT ", buf, len); ++ return; ++ } ++} ++ ++void parse_atsc_section(uint8_t *buf, int len, int pid, int data_type, struct section *section) ++{ ++ struct section_ext *section_ext = NULL; ++ struct atsc_section_psip *section_psip = NULL; ++ if ((section_ext = section_ext_decode(section, 1)) == NULL) { ++ return; ++ } ++ if ((section_psip = atsc_section_psip_decode(section_ext)) == NULL) { ++ return; ++ } ++ ++ printf("SCT protocol_version:%i\n", section_psip->protocol_version); ++ ++ switch(section->table_id) { ++ case stag_atsc_master_guide: ++ { ++ struct atsc_mgt_section *mgt; ++ struct atsc_mgt_table *cur_table; ++ struct atsc_mgt_section_part2 *part2; ++ struct descriptor *curd; ++ int idx; ++ ++ printf("SCT Decode MGT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((mgt = atsc_mgt_section_codec(section_psip)) == NULL) { ++ fprintf(stderr, "SCT XXXX MGT section decode error\n"); ++ return; ++ } ++ atsc_mgt_section_tables_for_each(mgt, cur_table, idx) { ++ printf("\tSCT table_type:0x%04x table_type_PID:%04x table_type_version_number:%i number_bytes:%i\n", ++ cur_table->table_type, ++ cur_table->table_type_PID, ++ cur_table->table_type_version_number, ++ cur_table->number_bytes); ++ atsc_mgt_table_descriptors_for_each(cur_table, curd) { ++ parse_descriptor(curd, 2, data_type); ++ } ++ } ++ ++ part2 = atsc_mgt_section_part2(mgt); ++ atsc_mgt_section_part2_descriptors_for_each(part2, curd) { ++ parse_descriptor(curd, 1, data_type); ++ } ++ break; ++ } ++ ++ case stag_atsc_terrestrial_virtual_channel: ++ { ++ struct atsc_tvct_section *tvct; ++ struct atsc_tvct_channel *cur_channel; ++ struct atsc_tvct_section_part2 *part2; ++ struct descriptor *curd; ++ int idx; ++ ++ printf("SCT Decode TVCT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((tvct = atsc_tvct_section_codec(section_psip)) == NULL) { ++ fprintf(stderr, "SCT XXXX TVCT section decode error\n"); ++ return; ++ } ++ printf("\tSCT tranport_stream_id:0x%04x\n", ++ atsc_tvct_section_transport_stream_id(tvct)); ++ ++ atsc_tvct_section_channels_for_each(tvct, cur_channel, idx) { ++ hexdump(0, "SCT short_name ", (uint8_t*) cur_channel->short_name, 7*2); ++ ++ printf("\tSCT major_channel_number:%04x minor_channel_number:%04x modulation_mode:%02x carrier_frequency:%i channel_TSID:%04x program_number:%04x ETM_location:%i access_controlled:%i hidden:%i hide_guide:%i service_type:%02x source_id:%04x\n", ++ cur_channel->major_channel_number, ++ cur_channel->minor_channel_number, ++ cur_channel->modulation_mode, ++ cur_channel->carrier_frequency, ++ cur_channel->channel_TSID, ++ cur_channel->program_number, ++ cur_channel->ETM_location, ++ cur_channel->access_controlled, ++ cur_channel->hidden, ++ cur_channel->hide_guide, ++ cur_channel->service_type, ++ cur_channel->source_id); ++ atsc_tvct_channel_descriptors_for_each(cur_channel, curd) { ++ parse_descriptor(curd, 2, data_type); ++ } ++ } ++ ++ part2 = atsc_tvct_section_part2(tvct); ++ atsc_tvct_section_part2_descriptors_for_each(part2, curd) { ++ parse_descriptor(curd, 1, data_type); ++ } ++ break; ++ } ++ ++ case stag_atsc_cable_virtual_channel: ++ { ++ struct atsc_cvct_section *cvct; ++ struct atsc_cvct_channel *cur_channel; ++ struct atsc_cvct_section_part2 *part2; ++ struct descriptor *curd; ++ int idx; ++ ++ printf("SCT Decode CVCT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((cvct = atsc_cvct_section_codec(section_psip)) == NULL) { ++ fprintf(stderr, "SCT XXXX CVCT section decode error\n"); ++ return; ++ } ++ printf("\tSCT tranport_stream_id:0x%04x\n", ++ atsc_cvct_section_transport_stream_id(cvct)); ++ ++ atsc_cvct_section_channels_for_each(cvct, cur_channel, idx) { ++ hexdump(0, "SCT short_name ", (uint8_t*) cur_channel->short_name, 7*2); ++ ++ printf("\tSCT major_channel_number:%04x minor_channel_number:%04x modulation_mode:%02x carrier_frequency:%i channel_TSID:%04x program_number:%04x ETM_location:%i access_controlled:%i hidden:%i path_select:%i out_of_band:%i hide_guide:%i service_type:%02x source_id:%04x\n", ++ cur_channel->major_channel_number, ++ cur_channel->minor_channel_number, ++ cur_channel->modulation_mode, ++ cur_channel->carrier_frequency, ++ cur_channel->channel_TSID, ++ cur_channel->program_number, ++ cur_channel->ETM_location, ++ cur_channel->access_controlled, ++ cur_channel->hidden, ++ cur_channel->path_select, ++ cur_channel->out_of_band, ++ cur_channel->hide_guide, ++ cur_channel->service_type, ++ cur_channel->source_id); ++ atsc_cvct_channel_descriptors_for_each(cur_channel, curd) { ++ parse_descriptor(curd, 2, data_type); ++ } ++ } ++ ++ part2 = atsc_cvct_section_part2(cvct); ++ atsc_cvct_section_part2_descriptors_for_each(part2, curd) { ++ parse_descriptor(curd, 1, data_type); ++ } ++ break; ++ } ++ ++ case stag_atsc_rating_region: ++ { ++ struct atsc_rrt_section *rrt; ++ struct atsc_rrt_section_part2 *part2; ++ struct atsc_rrt_dimension *cur_dimension; ++ struct atsc_rrt_dimension_part2 *dpart2; ++ struct atsc_rrt_dimension_value *cur_value; ++ struct atsc_rrt_dimension_value_part2 *vpart2; ++ struct atsc_rrt_section_part3 *part3; ++ struct descriptor *curd; ++ int didx; ++ int vidx; ++ ++ printf("SCT Decode RRT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((rrt = atsc_rrt_section_codec(section_psip)) == NULL) { ++ fprintf(stderr, "SCT XXXX RRT section decode error\n"); ++ return; ++ } ++ printf("\tSCT rating_region:0x%02x\n", ++ atsc_rrt_section_rating_region(rrt)); ++ atsctextdump("SCT region_name:", 1, ++ atsc_rrt_section_rating_region_name_text(rrt), ++ rrt->rating_region_name_length); ++ ++ part2 = atsc_rrt_section_part2(rrt); ++ atsc_rrt_section_dimensions_for_each(part2, cur_dimension, didx) { ++ atsctextdump("SCT dimension_name:", 2, ++ atsc_rrt_dimension_name_text(cur_dimension), ++ cur_dimension->dimension_name_length); ++ ++ dpart2 = atsc_rrt_dimension_part2(cur_dimension); ++ printf("\tSCT graduated_scale:%i\n", ++ dpart2->graduated_scale); ++ ++ atsc_rrt_dimension_part2_values_for_each(dpart2, cur_value, vidx) { ++ atsctextdump("SCT value_abbrev_name:", 3, ++ atsc_rrt_dimension_value_abbrev_rating_value_text(cur_value), ++ cur_value->abbrev_rating_value_length); ++ ++ vpart2 = atsc_rrt_dimension_value_part2(cur_value); ++ atsctextdump("SCT value_text:", 3, ++ atsc_rrt_dimension_value_part2_rating_value_text(vpart2), ++ vpart2->rating_value_length); ++ } ++ } ++ ++ part3 = atsc_rrt_section_part3(part2); ++ atsc_rrt_section_part3_descriptors_for_each(part3, curd) { ++ parse_descriptor(curd, 1, data_type); ++ } ++ ++ hexdump(0, "SCT ", buf, len); ++ getchar(); ++ break; ++ } ++ ++ case stag_atsc_event_information: ++ { ++ struct atsc_eit_section *eit; ++ struct atsc_eit_event *cur_event; ++ struct atsc_eit_event_part2 *part2; ++ struct descriptor *curd; ++ int idx; ++ ++ printf("SCT Decode EIT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((eit = atsc_eit_section_codec(section_psip)) == NULL) { ++ fprintf(stderr, "SCT XXXX EIT section decode error\n"); ++ return; ++ } ++ printf("\tSCT source_id:0x%04x\n", ++ atsc_eit_section_source_id(eit)); ++ ++ atsc_eit_section_events_for_each(eit, cur_event, idx) { ++ printf("\t\tSCT event_id:%04x start_time:%i ETM_location:%i length_in_secs:%i\n", ++ cur_event->event_id, ++ cur_event->start_time, ++ cur_event->ETM_location, ++ cur_event->length_in_seconds); ++ ++ atsctextdump("SCT title:", 2, ++ atsc_eit_event_name_title_text(cur_event), ++ cur_event->title_length); ++ ++ part2 = atsc_eit_event_part2(cur_event); ++ ++ atsc_eit_event_part2_descriptors_for_each(part2, curd) { ++ parse_descriptor(curd, 2, data_type); ++ } ++ } ++ break; ++ } ++ ++ case stag_atsc_extended_text: ++ { ++ struct atsc_ett_section *ett; ++ ++ printf("SCT Decode ETT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((ett = atsc_ett_section_codec(section_psip)) == NULL) { ++ fprintf(stderr, "SCT XXXX ETT section decode error\n"); ++ return; ++ } ++ printf("\tSCT ETM_source_id:0x%04x ETM_sub_id:%04x ETM_type:%02x\n", ++ ett->ETM_source_id, ++ ett->ETM_sub_id, ++ ett->ETM_type); ++ atsctextdump("SCT text:", 1, ++ atsc_ett_section_extended_text_message(ett), ++ atsc_ett_section_extended_text_message_length(ett)); ++ break; ++ } ++ ++ case stag_atsc_system_time: ++ { ++ struct atsc_stt_section *stt; ++ struct descriptor *curd; ++ ++ printf("SCT Decode STT (pid:0x%04x) (table:0x%02x)\n", pid, section->table_id); ++ if ((stt = atsc_stt_section_codec(section_psip)) == NULL) { ++ fprintf(stderr, "SCT XXXX STT section decode error\n"); ++ return; ++ } ++ printf("\tSCT system_time:%i gps_utc_offset:%i DS_status:%i DS_day_of_month:%i DS_hour:%i\n", ++ stt->system_time, ++ stt->gps_utc_offset, ++ stt->DS_status, ++ stt->DS_day_of_month, ++ stt->DS_hour); ++ atsc_stt_section_descriptors_for_each(stt, curd) { ++ parse_descriptor(curd, 2, data_type); ++ } ++ break; ++ } ++ ++ default: ++ fprintf(stderr, "SCT XXXX Unknown table_id:0x%02x (pid:0x%04x)\n", section->table_id, pid); ++ hexdump(0, "SCT ", buf, len); ++ return; ++ } ++} ++ ++void parse_descriptor(struct descriptor *d, int indent, int data_type) ++{ ++ switch(d->tag) { ++ case dtag_mpeg_video_stream: ++ { ++ struct mpeg_video_stream_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_video_stream_descriptor\n"); ++ dx = mpeg_video_stream_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_video_stream_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC multiple_frame_rate_flag:%i frame_rate_code:%i mpeg_1_only_flag:%i constrained_parameter_flag:%i still_picture_flag:%i\n", ++ dx->multiple_frame_rate_flag, ++ dx->frame_rate_code, ++ dx->mpeg_1_only_flag, ++ dx->constrained_parameter_flag, ++ dx->still_picture_flag); ++ if (!dx->mpeg_1_only_flag) { ++ struct mpeg_video_stream_extra *extra = mpeg_video_stream_descriptor_extra(dx); ++ iprintf(indent, "DSC profile_and_level_indication:0x%02x chroma_format:%i frame_rate_extension:%i\n", ++ extra->profile_and_level_indication, ++ extra->chroma_format, ++ extra->frame_rate_extension); ++ } ++ break; ++ } ++ ++ case dtag_mpeg_audio_stream: ++ { ++ struct mpeg_audio_stream_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_audio_stream_descriptor\n"); ++ dx = mpeg_audio_stream_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_audio_stream_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC free_format_flag:%i id:%i layer:%i variable_rate_audio_indicator:%i\n", ++ dx->free_format_flag, ++ dx->id, ++ dx->layer, ++ dx->variable_rate_audio_indicator); ++ break; ++ } ++ ++ case dtag_mpeg_hierarchy: ++ { ++ struct mpeg_hierarchy_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_hierarchy_descriptor\n"); ++ dx = mpeg_hierarchy_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_hierarchy_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC hierarchy_type:%i hierarchy_layer_index:%i hierarchy_embedded_layer_index:%i hierarchy_channel:%i\n", ++ dx->hierarchy_type, ++ dx->hierarchy_layer_index, ++ dx->hierarchy_embedded_layer_index, ++ dx->hierarchy_channel); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_mpeg_registration: ++ { ++ struct mpeg_registration_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_registration_descriptor\n"); ++ dx = mpeg_registration_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_registration_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC format_identifier:0x%x\n", ++ dx->format_identifier); ++ iprintf(indent, "DSC additional_id_info:\n"); ++ hexdump(indent, "DSC ", ++ mpeg_registration_descriptor_additional_id_info(dx), ++ mpeg_registration_descriptor_additional_id_info_length(dx)); ++ break; ++ } ++ ++ case dtag_mpeg_data_stream_alignment: ++ { ++ struct mpeg_data_stream_alignment_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_data_stream_alignment_descriptor\n"); ++ dx = mpeg_data_stream_alignment_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_data_stream_alignment_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC alignment_type:%i\n", ++ dx->alignment_type); ++ break; ++ } ++ ++ case dtag_mpeg_target_background_grid: ++ { ++ struct mpeg_target_background_grid_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_target_background_grid_descriptor\n"); ++ dx = mpeg_target_background_grid_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_target_background_grid_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC horizontal_size:%i vertical_size:%i aspect_ratio_information:%i\n", ++ dx->horizontal_size, ++ dx->vertical_size, ++ dx->aspect_ratio_information); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_mpeg_video_window: ++ { ++ struct mpeg_video_window_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_video_window_descriptor\n"); ++ dx = mpeg_video_window_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_video_window_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC horizontal_offset:%i vertical_offset:%i window_priority:%i\n", ++ dx->horizontal_offset, ++ dx->vertical_offset, ++ dx->window_priority); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_mpeg_ca: ++ { ++ struct mpeg_ca_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_ca_descriptor\n"); ++ dx = mpeg_ca_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_ca_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC ca_system_id:0x%04x ca_pid:0x%04x\n", ++ dx->ca_system_id, ++ dx->ca_pid); ++ iprintf(indent, "DSC data:\n"); ++ hexdump(indent, "DSC ", mpeg_ca_descriptor_data(dx), mpeg_ca_descriptor_data_length(dx)); ++ break; ++ } ++ ++ case dtag_mpeg_iso_639_language: ++ { ++ struct mpeg_iso_639_language_descriptor *dx; ++ struct mpeg_iso_639_language_code *cur_lang; ++ ++ iprintf(indent, "DSC Decode mpeg_iso_639_language_descriptor\n"); ++ dx = mpeg_iso_639_language_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_iso_639_language_descriptor decode error\n"); ++ return; ++ } ++ mpeg_iso_639_language_descriptor_languages_for_each(dx, cur_lang) { ++ iprintf(indent+1, "DSC language_code:%.3s audio_type:0x%02x\n", ++ cur_lang->language_code, ++ cur_lang->audio_type); ++ } ++ break; ++ } ++ ++ case dtag_mpeg_system_clock: ++ { ++ struct mpeg_system_clock_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_system_clock_descriptor\n"); ++ dx = mpeg_system_clock_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_system_clock_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC external_clock_reference_indicator:%i clock_accuracy_integer:%i clock_accuracy_exponent:%i\n", ++ dx->external_clock_reference_indicator, ++ dx->clock_accuracy_integer, ++ dx->clock_accuracy_exponent); ++ break; ++ } ++ ++ case dtag_mpeg_multiplex_buffer_utilization: ++ { ++ struct mpeg_multiplex_buffer_utilization_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_multiplex_buffer_utilization_descriptor\n"); ++ dx = mpeg_multiplex_buffer_utilization_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_multiplex_buffer_utilization_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC bound_valid_flag:%i ltw_offset_lower_bound:%i ltw_offset_upper_bound:%i\n", ++ dx->bound_valid_flag, ++ dx->ltw_offset_lower_bound, ++ dx->ltw_offset_upper_bound); ++ break; ++ } ++ ++ case dtag_mpeg_copyright: ++ { ++ struct mpeg_copyright_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_copyright_descriptor\n"); ++ dx = mpeg_copyright_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_copyright_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC copyright_identifier:0x%08x\n", ++ dx->copyright_identifier); ++ iprintf(indent, "DSC data:\n"); ++ hexdump(indent, "DSC ", mpeg_copyright_descriptor_data(dx), mpeg_copyright_descriptor_data_length(dx)); ++ break; ++ } ++ ++ case dtag_mpeg_maximum_bitrate: ++ { ++ struct mpeg_maximum_bitrate_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_maximum_bitrate_descriptor\n"); ++ dx = mpeg_maximum_bitrate_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_maximum_bitrate_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC maximum_bitrate:%i\n", ++ dx->maximum_bitrate); ++ break; ++ } ++ ++ case dtag_mpeg_private_data_indicator: ++ { ++ struct mpeg_private_data_indicator_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_private_data_indicator_descriptor\n"); ++ dx = mpeg_private_data_indicator_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_private_data_indicator_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC private_data_indicator:0x%x\n", ++ dx->private_data_indicator); ++ break; ++ } ++ ++ case dtag_mpeg_smoothing_buffer: ++ { ++ struct mpeg_smoothing_buffer_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_smoothing_buffer_descriptor\n"); ++ dx = mpeg_smoothing_buffer_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_smoothing_buffer_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC sb_leak_rate:%i sb_size:%i\n", ++ dx->sb_leak_rate, ++ dx->sb_size); ++ break; ++ } ++ ++ case dtag_mpeg_std: ++ { ++ struct mpeg_std_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_std_descriptor\n"); ++ dx = mpeg_std_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_std_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC leak_valid_flag:%i\n", ++ dx->leak_valid_flag); ++ break; ++ } ++ ++ case dtag_mpeg_ibp: ++ { ++ struct mpeg_ibp_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_ibp_descriptor\n"); ++ dx = mpeg_ibp_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_ibp_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC closed_gop_flag:%i identical_gop_flag:%i max_gop_length:%i\n", ++ dx->closed_gop_flag, dx->identical_gop_flag, dx->max_gop_length); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_mpeg_4_video: ++ { ++ struct mpeg4_video_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg4_video_descriptor\n"); ++ dx = mpeg4_video_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg4_video_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC mpeg4_visual_profile_and_level:0x%02x\n", ++ dx->mpeg4_visual_profile_and_level); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_mpeg_4_audio: ++ { ++ struct mpeg4_audio_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg4_audio_descriptor\n"); ++ dx = mpeg4_audio_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg4_audio_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC mpeg4_audio_profile_and_level:0x%02x\n", ++ dx->mpeg4_audio_profile_and_level); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_mpeg_iod: ++ { ++ struct mpeg_iod_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_iod_descriptor\n"); ++ dx = mpeg_iod_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_iod_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC scope_of_iod_label:0x%08x iod_label:0x%02x\n", ++ dx->scope_of_iod_label, dx->iod_label); ++ iprintf(indent, "DSC iod:\n"); ++ hexdump(indent, "DSC ", mpeg_iod_descriptor_iod(dx), mpeg_iod_descriptor_iod_length(dx)); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_mpeg_sl: ++ { ++ struct mpeg_sl_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_sl_descriptor\n"); ++ dx = mpeg_sl_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_sl_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC es_id:0x%04x\n", ++ dx->es_id); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_mpeg_fmc: ++ { ++ struct mpeg_fmc_descriptor *dx; ++ struct mpeg_flex_mux *cur_fm; ++ ++ iprintf(indent, "DSC Decode mpeg_fmc_descriptor\n"); ++ dx = mpeg_fmc_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_fmc_descriptor_descriptor decode error\n"); ++ return; ++ } ++ mpeg_fmc_descriptor_muxes_for_each(dx, cur_fm) { ++ iprintf(indent+1, "DSC es_id:0x%04x flex_mux_channel:0x%02x\n", ++ cur_fm->es_id, ++ cur_fm->flex_mux_channel); ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_mpeg_external_es_id: ++ { ++ struct mpeg_external_es_id_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_external_es_id_descriptor\n"); ++ dx = mpeg_external_es_id_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_external_es_id_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC external_es_id:0x%04x\n", ++ dx->external_es_id); ++ break; ++ } ++ ++ case dtag_mpeg_muxcode: ++ { ++ struct mpeg_muxcode_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_muxcode_descriptor\n"); ++ dx = mpeg_muxcode_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_muxcode_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC entries:\n"); ++ hexdump(indent, "DSC ", mpeg_muxcode_descriptor_entries(dx), mpeg_muxcode_descriptor_entries_length(dx)); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_mpeg_fmxbuffer_size: ++ { ++ struct mpeg_fmxbuffer_size_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_fmxbuffer_size_descriptor\n"); ++ dx = mpeg_fmxbuffer_size_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_fmxbuffer_size_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC descriptors:\n"); ++ hexdump(indent, "DSC ", mpeg_fmxbuffer_size_descriptor_descriptors(dx), mpeg_fmxbuffer_size_descriptor_descriptors_length(dx)); ++ break; ++ } ++ ++ case dtag_mpeg_multiplex_buffer: ++ { ++ struct mpeg_multiplex_buffer_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_multiplex_buffer_descriptor\n"); ++ dx = mpeg_multiplex_buffer_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_multiplex_buffer_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC mb_buffer_size:%i tb_leak_rate:%i\n", ++ dx->mb_buffer_size, dx->tb_leak_rate); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_mpeg_content_labelling: ++ { ++ struct mpeg_content_labelling_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_content_labelling_descriptor\n"); ++ dx = mpeg_content_labelling_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_content_labelling_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC metadata_application_format:%04x\n", ++ dx->metadata_application_format); ++ struct mpeg_content_labelling_descriptor_application_format_identifier *id = ++ mpeg_content_labelling_descriptor_id(dx); ++ if (id != NULL) { ++ iprintf(indent, "DSC application_format_id:%04x\n", ++ id->id); ++ } ++ struct mpeg_content_labelling_descriptor_flags *flags = ++ mpeg_content_labelling_descriptor_flags(dx); ++ if (flags != NULL) { ++ iprintf(indent, "DSC content_reference_id_record_flag:%i content_time_base_indicator:%02x\n", ++ flags->content_reference_id_record_flag, ++ flags->content_time_base_indicator); ++ ++ struct mpeg_content_labelling_descriptor_reference_id *reference_id = ++ mpeg_content_labelling_descriptor_reference_id(flags); ++ if (reference_id != NULL) { ++ hexdump(indent, "DSC reference_id " , ++ mpeg_content_reference_id_data(reference_id), ++ reference_id->content_reference_id_record_length); ++ } ++ ++ struct mpeg_content_labelling_descriptor_time_base *time_base = ++ mpeg_content_labelling_descriptor_time_base(flags); ++ if (time_base != NULL) { ++ iprintf(indent, "DSC time_base content_time_base_value:%lli metadata_time_base_value:%lli\n", ++ time_base->content_time_base_value, ++ time_base->metadata_time_base_value); ++ } ++ ++ struct mpeg_content_labelling_descriptor_content_id *content_id = ++ mpeg_content_labelling_descriptor_content_id(flags); ++ if (content_id != NULL) { ++ iprintf(indent, "DSC content_id contentId:%i\n", ++ content_id->contentId); ++ } ++ ++ struct mpeg_content_labelling_descriptor_time_base_association *time_base_assoc = ++ mpeg_content_labelling_descriptor_time_base_assoc(flags); ++ if (time_base_assoc != NULL) { ++ hexdump(indent, "DSC time_base_assoc" , ++ mpeg_time_base_association_data(time_base_assoc), ++ time_base_assoc->time_base_association_data_length); ++ } ++ ++ uint8_t *priv; ++ int priv_length; ++ priv = mpeg_content_labelling_descriptor_data(dx, flags, &priv_length); ++ hexdump(indent, "DSC private_data", priv, priv_length); ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_mpeg_metadata_pointer: ++ { ++ struct mpeg_metadata_pointer_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_metadata_pointer_descriptor\n"); ++ dx = mpeg_metadata_pointer_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_metadata_pointer_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC metadata_application_format:%04x\n", ++ dx->metadata_application_format); ++ ++ struct mpeg_metadata_pointer_descriptor_application_format_identifier *id = ++ mpeg_metadata_pointer_descriptor_appid(dx); ++ if (id != NULL) { ++ iprintf(indent, "DSC application_format_id:%04x\n", ++ id->id); ++ } ++ ++ struct mpeg_metadata_pointer_descriptor_format_identifier *did = ++ mpeg_metadata_pointer_descriptor_formid(dx); ++ if (did != NULL) { ++ iprintf(indent, "DSC mpeg_metadata_pointer_descriptor_format_id:%04x\n", ++ did->id); ++ } ++ ++ struct mpeg_metadata_pointer_descriptor_flags *flags = ++ mpeg_metadata_pointer_descriptor_flags(dx); ++ if (flags != NULL) { ++ iprintf(indent, "DSC metadata_service_id:%i metadata_locator_record_flag:%i mpeg_carriage_flags:%x\n", ++ flags->metadata_service_id, ++ flags->metadata_locator_record_flag, ++ flags->mpeg_carriage_flags); ++ ++ struct mpeg_metadata_pointer_descriptor_locator *locator = ++ mpeg_metadata_pointer_descriptor_locator(flags); ++ if (locator != NULL) { ++ hexdump(indent, "DSC locator" , ++ mpeg_metadata_pointer_descriptor_locator_data(locator), ++ locator->metadata_locator_record_length); ++ } ++ ++ struct mpeg_metadata_pointer_descriptor_program_number *pnum= ++ mpeg_metadata_pointer_descriptor_program_number(flags); ++ if (pnum != NULL) { ++ iprintf(indent, "DSC program_number number:%04x\n", ++ pnum->number); ++ } ++ ++ struct mpeg_metadata_pointer_descriptor_carriage *carriage = ++ mpeg_metadata_pointer_descriptor_carriage(flags); ++ if (carriage != NULL) { ++ iprintf(indent, "DSC carriage transport_stream_location:%04x transport_stream_id:%04x\n", ++ carriage->transport_stream_location, ++ carriage->transport_stream_id); ++ } ++ ++ uint8_t *priv; ++ int priv_length; ++ priv = mpeg_metadata_pointer_descriptor_private_data(dx, flags, &priv_length); ++ hexdump(indent, "DSC private_data" , priv, priv_length); ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_mpeg_metadata: ++ { ++ struct mpeg_metadata_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_metadata_descriptor\n"); ++ dx = mpeg_metadata_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_metadata_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC metadata_application_format:%04x\n", ++ dx->metadata_application_format); ++ ++ struct mpeg_metadata_descriptor_application_format_identifier *id = ++ mpeg_metadata_descriptor_appid(dx); ++ if (id != NULL) { ++ iprintf(indent, "DSC application_format_id:%04x\n", ++ id->id); ++ } ++ ++ struct mpeg_metadata_descriptor_format_identifier *did = ++ mpeg_metadata_descriptor_formid(dx); ++ if (did != NULL) { ++ iprintf(indent, "DSC mpeg_metadata_descriptor_format_id:%04x\n", ++ did->id); ++ } ++ ++ struct mpeg_metadata_descriptor_flags *flags = ++ mpeg_metadata_descriptor_flags(dx); ++ if (flags != NULL) { ++ iprintf(indent, "DSC metadata_service_id:%i decoder_config_flags:%i dsm_cc_flag:%x\n", ++ flags->metadata_service_id, ++ flags->decoder_config_flags, ++ flags->dsm_cc_flag); ++ ++ struct mpeg_metadata_descriptor_service_identifier *serviceid= ++ mpeg_metadata_descriptor_sevice_identifier(flags); ++ if (serviceid != NULL) { ++ hexdump(indent, "DSC service_id" , ++ mpeg_metadata_descriptor_service_identifier_data(serviceid), ++ serviceid->service_identification_length); ++ } ++ ++ struct mpeg_metadata_descriptor_decoder_config *dconfig= ++ mpeg_metadata_descriptor_decoder_config(flags); ++ if (dconfig != NULL) { ++ hexdump(indent, "DSC decoder_config" , ++ mpeg_metadata_descriptor_decoder_config_data(dconfig), ++ dconfig->decoder_config_length); ++ } ++ ++ struct mpeg_metadata_descriptor_decoder_config_id_record *dconfigid= ++ mpeg_metadata_descriptor_decoder_config_id_record(flags); ++ if (dconfigid != NULL) { ++ hexdump(indent, "DSC decoder_config" , ++ mpeg_metadata_descriptor_decoder_config_id_record_data(dconfigid), ++ dconfigid->decoder_config_id_record_length); ++ } ++ ++ struct mpeg_metadata_descriptor_decoder_config_service_id *dserviceid= ++ mpeg_metadata_descriptor_decoder_config_service_id(flags); ++ if (dserviceid != NULL) { ++ iprintf(indent, "DSC decoder config service_id:%04x\n", ++ dserviceid->decoder_config_metadata_service_id); ++ } ++ ++ struct mpeg_metadata_descriptor_decoder_config_reserved *reserved= ++ mpeg_metadata_descriptor_decoder_config_reserved(flags); ++ if (reserved != NULL) { ++ hexdump(indent, "DSC reserved" , ++ mpeg_metadata_descriptor_decoder_config_reserved_data(reserved), ++ reserved->reserved_data_length); ++ } ++ ++ uint8_t *priv; ++ int priv_length; ++ priv = mpeg_metadata_descriptor_private_data(dx, flags, &priv_length); ++ hexdump(indent, "DSC private_data" , priv, priv_length); ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_mpeg_metadata_std: ++ { ++ struct mpeg_metadata_std_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode mpeg_metadata_std_descriptor\n"); ++ dx = mpeg_metadata_std_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX mpeg_metadata_std_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC metadata_input_leak_rate:%i metadata_buffer_size:%i metadata_output_leak_rate:%i\n", ++ dx->metadata_input_leak_rate, ++ dx->metadata_buffer_size, ++ dx->metadata_output_leak_rate); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ default: ++ switch(data_type) { ++ case DATA_TYPE_DVB: ++ parse_dvb_descriptor(d, indent, data_type); ++ return; ++ ++ case DATA_TYPE_ATSC: ++ parse_atsc_descriptor(d, indent, data_type); ++ return; ++ ++ default: ++ fprintf(stderr, "DSC XXXX Unknown descriptor_tag:0x%02x\n", d->tag); ++ hexdump(0, "DSC ", (uint8_t*) d, d->len+2); ++ return; ++ } ++ } ++} ++ ++void parse_dvb_descriptor(struct descriptor *d, int indent, int data_type) ++{ ++ (void) data_type; ++ ++ switch(d->tag) { ++ case dtag_dvb_network_name: ++ { ++ struct dvb_network_name_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_network_name_descriptor\n"); ++ dx = dvb_network_name_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_network_name_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC name:%.*s\n", ++ dvb_network_name_descriptor_name_length(dx), ++ dvb_network_name_descriptor_name(dx)); ++ break; ++ } ++ ++ case dtag_dvb_service_list: ++ { ++ struct dvb_service_list_descriptor *dx; ++ struct dvb_service_list_service *curs; ++ ++ iprintf(indent, "DSC Decode dvb_service_list_descriptor\n"); ++ dx = dvb_service_list_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_service_list_descriptor decode error\n"); ++ return; ++ } ++ dvb_service_list_descriptor_services_for_each(dx, curs) { ++ iprintf(indent+1, "DSC service_id:0x%04x service_type:0x%02x\n", ++ curs->service_id, curs->service_type); ++ } ++ break; ++ } ++ ++ case dtag_dvb_stuffing: ++ { ++ struct dvb_stuffing_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_stuffing_descriptor\n"); ++ dx = dvb_stuffing_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_stuffing_descriptor decode error\n"); ++ return; ++ } ++ hexdump(indent, "DSC", ++ dvb_stuffing_descriptor_data(dx), ++ dvb_stuffing_descriptor_data_length(dx)); ++ break; ++ } ++ ++ case dtag_dvb_satellite_delivery_system: ++ { ++ struct dvb_satellite_delivery_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_satellite_delivery_descriptor\n"); ++ dx = dvb_satellite_delivery_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_satellite_delivery_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC frequency:%i orbital_position:%i west_east:%i polarization:%i roll_off:%i modulation_system:%i modulation_type: %i symbol_rate:%i fec_inner:%i\n", ++ dx->frequency, ++ dx->orbital_position, ++ dx->west_east_flag, ++ dx->polarization, ++ dx->roll_off, ++ dx->modulation_system, ++ dx->modulation_type, ++ dx->symbol_rate, ++ dx->fec_inner); ++ break; ++ } ++ ++ case dtag_dvb_cable_delivery_system: ++ { ++ struct dvb_cable_delivery_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_cable_delivery_descriptor\n"); ++ dx = dvb_cable_delivery_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_cable_delivery_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC frequency:%i fec_outer:%i modulation:%i symbol_rate:%i fec_inner:%i\n", ++ dx->frequency, dx->fec_outer, dx->modulation, ++ dx->symbol_rate, dx->fec_inner); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_vbi_data: ++ { ++ struct dvb_vbi_data_descriptor *dx; ++ struct dvb_vbi_data_entry *cur; ++ struct dvb_vbi_data_x *curx; ++ ++ iprintf(indent, "DSC Decode dvb_vbi_data_descriptor\n"); ++ dx = dvb_vbi_data_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_vbi_data_descriptor decode error\n"); ++ return; ++ } ++ dvb_vbi_data_descriptor_entries_for_each(dx, cur) { ++ curx = dvb_vbi_data_entry_data_x(cur); ++ iprintf(indent+1, "DSC data_service_id:0x%04x\n", cur->data_service_id); ++ if (cur == NULL) { ++ hexdump(indent+1, "DSC", dvb_vbi_data_entry_data(cur), cur->data_length); ++ } else { ++ iprintf(indent+1, "DSC field_parity:%i line_offset:%i\n", ++ curx->field_parity, curx->line_offset); ++ } ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_vbi_teletext: ++ { ++ struct dvb_vbi_teletext_descriptor *dx; ++ struct dvb_vbi_teletext_entry *cur; ++ ++ iprintf(indent, "DSC Decode dvb_vbi_teletext_descriptor\n"); ++ dx = dvb_vbi_teletext_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_vbi_teletext_descriptor decode error\n"); ++ return; ++ } ++ dvb_vbi_teletext_descriptor_entries_for_each(dx, cur) { ++ iprintf(indent+1, "DSC language_code:%.3s type:%i magazine_number:%i page_number:%i\n", ++ cur->language_code, ++ cur->type, cur->magazine_number, cur->page_number); ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_bouquet_name: ++ { ++ struct dvb_bouquet_name_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_bouquet_name_descriptor\n"); ++ dx = dvb_bouquet_name_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_bouquet_name_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC name:%.*s\n", ++ dvb_bouquet_name_descriptor_name_length(dx), ++ dvb_bouquet_name_descriptor_name(dx)); ++ break; ++ } ++ ++ case dtag_dvb_service: ++ { ++ struct dvb_service_descriptor *dx; ++ struct dvb_service_descriptor_part2 *part2; ++ ++ iprintf(indent, "DSC Decode dvb_service_descriptor\n"); ++ dx = dvb_service_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_service_descriptor decode error\n"); ++ return; ++ } ++ part2 = dvb_service_descriptor_part2(dx); ++ iprintf(indent, "DSC service_type:%02x provider_name:%.*s service_name:%.*s\n", ++ dx->service_type, ++ dx->service_provider_name_length, ++ dvb_service_descriptor_service_provider_name(dx), ++ part2->service_name_length, ++ dvb_service_descriptor_service_name(part2)); ++ break; ++ } ++ ++ case dtag_dvb_country_availability: ++ { ++ struct dvb_country_availability_descriptor *dx; ++ struct dvb_country_availability_entry *cur; ++ ++ iprintf(indent, "DSC Decode dvb_country_availability_descriptor\n"); ++ dx = dvb_country_availability_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_country_availability_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC country_availability_flag:%i\n", dx->country_availability_flag); ++ dvb_country_availability_descriptor_countries_for_each(dx, cur) { ++ iprintf(indent+1, "DSC country_code:%.3s\n", cur->country_code); ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_linkage: ++ { ++ struct dvb_linkage_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_linkage_descriptor\n"); ++ dx = dvb_linkage_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_linkage_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC transport_stream_id:0x%04x original_network_id:0x%04x service_id:0x%04x linkage_type:0x%02x\n", ++ dx->transport_stream_id, dx->original_network_id, dx->service_id, dx->linkage_type); ++ switch(dx->linkage_type) { ++ case 0x08: ++ { ++ struct dvb_linkage_data_08 *d08 = dvb_linkage_data_08(dx); ++ int network_id = dvb_linkage_data_08_network_id(dx, d08); ++ int initial_service_id = dvb_linkage_data_08_initial_service_id(dx, d08); ++ int length = 0; ++ uint8_t *data; ++ ++ data = dvb_linkage_data_08_data(dx, d08, &length); ++ iprintf(indent, "DSC hand_over_type:%i origin_type:%i\n", ++ d08->hand_over_type, d08->origin_type); ++ if (network_id != -1) { ++ iprintf(indent, "DSC network_id:0x%04x\n", network_id); ++ } ++ if (initial_service_id != -1) { ++ iprintf(indent, "DSC initial_service_id:0x%04x\n", initial_service_id); ++ } ++ } ++ ++ case 0x0b: ++ { ++ struct dvb_linkage_data_0b *data = dvb_linkage_data_0b(dx); ++ struct dvb_platform_id *platid; ++ struct dvb_platform_name *curplatname; ++ ++ dvb_linkage_data_0b_platform_id_for_each(data, platid) { ++ iprintf(indent+1, "DSC platform_id:0x%06x\n", platid->platform_id); ++ dvb_platform_id_platform_name_for_each(platid, curplatname) { ++ iprintf(indent+2, "DSC language_code:%.3s platform_name:%.*s\n", ++ curplatname->language_code, ++ curplatname->platform_name_length, dvb_platform_name_text(curplatname)); ++ } ++ } ++ break; ++ } ++ ++ case 0x0c: ++ { ++ struct dvb_linkage_data_0c *data = dvb_linkage_data_0c(dx); ++ ++ iprintf(indent, "DSC table_type:0x%02x\n", data->table_type); ++ if (dvb_linkage_data_0c_bouquet_id(data)) { ++ iprintf(indent, "DSC bouquet_id:0x%04x\n", ++ dvb_linkage_data_0c_bouquet_id(data)); ++ } ++ break; ++ } ++ ++ default: ++ hexdump(indent+1, "DSC", dvb_linkage_descriptor_data(dx), dvb_linkage_descriptor_data_length(dx)); ++ break; ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_nvod_reference: ++ { ++ struct dvb_nvod_reference_descriptor *dx; ++ struct dvb_nvod_reference *cur; ++ ++ iprintf(indent, "DSC Decode dvb_nvod_reference_descriptor\n"); ++ dx = dvb_nvod_reference_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_nvod_reference_descriptor decode error\n"); ++ return; ++ } ++ dvb_nvod_reference_descriptor_references_for_each(dx, cur) { ++ iprintf(indent+1, "DSC transport_stream_id:0x%04x original_network_id:0x%04x service_id:0x%04x\n", ++ cur->transport_stream_id, cur->original_network_id, ++ cur->service_id); ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_time_shifted_service: ++ { ++ struct dvb_time_shifted_service_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_time_shifted_service_descriptor\n"); ++ dx = dvb_time_shifted_service_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_time_shifted_service_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC reference_service_id:0x%04x\n", dx->reference_service_id); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_short_event: ++ { ++ struct dvb_short_event_descriptor *dx; ++ struct dvb_short_event_descriptor_part2 *part2; ++ ++ iprintf(indent, "DSC Decode dvb_short_event_descriptor\n"); ++ dx = dvb_short_event_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_short_event_descriptor decode error\n"); ++ return; ++ } ++ part2 = dvb_short_event_descriptor_part2(dx); ++ iprintf(indent, "DSC language_code:%.3s event_name:%.*s text:%.*s\n", ++ dx->language_code, ++ dx->event_name_length, dvb_short_event_descriptor_event_name(dx), ++ part2->text_length, dvb_short_event_descriptor_text(part2)); ++ break; ++ } ++ ++ case dtag_dvb_extended_event: ++ { ++ struct dvb_extended_event_descriptor *dx; ++ struct dvb_extended_event_descriptor_part2 *part2; ++ struct dvb_extended_event_item *cur; ++ ++ iprintf(indent, "DSC Decode dvb_extended_event_descriptor\n"); ++ dx = dvb_extended_event_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_extended_event_descriptor decode error\n"); ++ return; ++ } ++ part2 = dvb_extended_event_descriptor_part2(dx); ++ iprintf(indent, "DSC descriptor_number:%i last_descriptor_number:%i language_code:%.3s text:%.*s\n", ++ dx->descriptor_number, dx->last_descriptor_number, ++ dx->language_code, ++ part2->text_length, dvb_extended_event_descriptor_part2_text(part2)); ++ dvb_extended_event_descriptor_items_for_each(dx, cur) { ++ struct dvb_extended_event_item_part2 *ipart2 = ++ dvb_extended_event_item_part2(cur); ++ iprintf(indent+1, "DSC description:%.*s item:%.*s\n", ++ cur->item_description_length, dvb_extended_event_item_description(cur), ++ ipart2->item_length, dvb_extended_event_item_part2_item(ipart2)); ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_time_shifted_event: ++ { ++ struct dvb_time_shifted_event_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_time_shifted_event_descriptor\n"); ++ dx = dvb_time_shifted_event_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_time_shifted_event_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC reference_service_id:0x%04x reference_event_id:0x%04x\n", ++ dx->reference_service_id, dx->reference_event_id); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_component: ++ { ++ struct dvb_component_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_component_descriptor\n"); ++ dx = dvb_component_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_component_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC stream_content:%i component_type:%i component_tag: %i language_code:%.3s, text:%.*s\n", ++ dx->stream_content, ++ dx->component_type, ++ dx->component_tag, ++ dx->language_code, ++ dvb_component_descriptor_text_length(dx), ++ dvb_component_descriptor_text(dx)); ++ break; ++ } ++ ++ case dtag_dvb_mosaic: ++ { ++ struct dvb_mosaic_descriptor *dx; ++ struct dvb_mosaic_info *curinfo; ++ ++ iprintf(indent, "DSC Decode dvb_mosaic_descriptor\n"); ++ dx = dvb_mosaic_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_mosaic_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC mosaic_entry_point:%i number_of_horiz_elementary_cells:%i number_of_vert_elementary_cells:%i\n", ++ dx->mosaic_entry_point, dx->number_of_horiz_elementary_cells, ++ dx->number_of_vert_elementary_cells); ++ dvb_mosaic_descriptor_infos_for_each(dx, curinfo) { ++ struct dvb_mosaic_info_part2 *part2; ++ struct dvb_mosaic_linkage *linkage; ++ struct dvb_mosaic_elementary_cell_field *curfield; ++ ++ part2 = dvb_mosaic_info_part2(curinfo); ++ linkage = dvb_mosaic_linkage(part2); ++ iprintf(indent+1, "DSC logical_cell_id:%i logical_cell_presentation_info:%i cell_linkage_info:0x%02x\n", ++ curinfo->logical_cell_id, curinfo->logical_cell_presentation_info, ++ part2->cell_linkage_info); ++ if (linkage) { ++ switch(part2->cell_linkage_info) { ++ case 0x01: ++ iprintf(indent+1, "DSC bouquet_id:0x%04x\n", ++ linkage->u.linkage_01.bouquet_id); ++ break; ++ ++ case 0x02: ++ iprintf(indent+1, "DSC original_network_id:0x%04x transport_stream_id:0x%04x service_id:0x%04x\n", ++ linkage->u.linkage_02.original_network_id, ++ linkage->u.linkage_02.transport_stream_id, ++ linkage->u.linkage_02.service_id); ++ break; ++ ++ case 0x03: ++ iprintf(indent+1, "DSC original_network_id:0x%04x transport_stream_id:0x%04x service_id:0x%04x\n", ++ linkage->u.linkage_03.original_network_id, ++ linkage->u.linkage_03.transport_stream_id, ++ linkage->u.linkage_03.service_id); ++ break; ++ ++ case 0x04: ++ iprintf(indent+1, "DSC original_network_id:0x%04x transport_stream_id:0x%04x service_id:0x%04x event_id:0x%04x\n", ++ linkage->u.linkage_04.original_network_id, ++ linkage->u.linkage_04.transport_stream_id, ++ linkage->u.linkage_04.service_id, ++ linkage->u.linkage_04.event_id); ++ break; ++ } ++ } ++ ++ dvb_mosaic_info_fields_for_each(curinfo, curfield) { ++ iprintf(indent+2, "DSC elementary_cell_id:0x%02x\n", ++ curfield->elementary_cell_id); ++ } ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_stream_identifier: ++ { ++ struct dvb_stream_identifier_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_stream_identifier_descriptor\n"); ++ dx = dvb_stream_identifier_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_stream_identifier_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC component_tag:%i\n", ++ dx->component_tag); ++ break; ++ } ++ ++ case dtag_dvb_ca_identifier: ++ { ++ struct dvb_ca_identifier_descriptor *dx; ++ int i; ++ uint16_t *ids; ++ ++ iprintf(indent, "DSC Decode dvb_ca_identifier_descriptor\n"); ++ dx = dvb_ca_identifier_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_ca_identifier_descriptor decode error\n"); ++ return; ++ } ++ ids = dvb_ca_identifier_descriptor_ca_system_ids(dx); ++ for(i=0; i< dvb_ca_identifier_descriptor_ca_system_ids_count(dx); i++) { ++ iprintf(indent+i, "DSC system_id:0x%04x\n", ids[i]); ++ } ++ break; ++ } ++ ++ case dtag_dvb_content: ++ { ++ struct dvb_content_descriptor *dx; ++ struct dvb_content_nibble *cur; ++ ++ iprintf(indent, "DSC Decode dvb_content_descriptor\n"); ++ dx = dvb_content_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_content_descriptor decode error\n"); ++ return; ++ } ++ dvb_content_descriptor_nibbles_for_each(dx, cur) { ++ iprintf(indent+1, "DSC content_nibble_level_1:%i content_nibble_level_2:%i user_nibble_1:%i user_nibble_2:%i\n", ++ cur->content_nibble_level_1, cur->content_nibble_level_2, ++ cur->user_nibble_1, cur->user_nibble_2); ++ } ++ break; ++ } ++ ++ case dtag_dvb_parental_rating: ++ { ++ struct dvb_parental_rating_descriptor *dx; ++ struct dvb_parental_rating *cur; ++ ++ iprintf(indent, "DSC Decode dvb_parental_rating_descriptor\n"); ++ dx = dvb_parental_rating_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_parental_rating_descriptor decode error\n"); ++ return; ++ } ++ dvb_parental_rating_descriptor_ratings_for_each(dx, cur) { ++ iprintf(indent+1, "DSC country_code:%.3s rating:%i\n", ++ cur->country_code, cur->rating); ++ } ++ break; ++ } ++ ++ case dtag_dvb_teletext: ++ { ++ struct dvb_teletext_descriptor *dx; ++ struct dvb_teletext_entry *cur; ++ ++ iprintf(indent, "DSC Decode dvb_teletext_descriptor\n"); ++ dx = dvb_teletext_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_teletext_descriptor decode error\n"); ++ return; ++ } ++ dvb_teletext_descriptor_entries_for_each(dx, cur) { ++ iprintf(indent+1, "DSC language_code:%.3s type:%i magazine_number:%i page_number:%i\n", ++ cur->language_code, ++ cur->type, cur->magazine_number, cur->page_number); ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_telephone: ++ { ++ struct dvb_telephone_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_telephone_descriptor\n"); ++ dx = dvb_telephone_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_telephone_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, ++ "DSC foreign_availability:%i connection_type:%i country_prefix:%.*s " ++ "international_area_code:%.*s operator_code:%.*s national_area_code:%.*s core_number:%.*s\n", ++ dx->foreign_availability, dx->connection_type, ++ dx->country_prefix_length, dvb_telephone_descriptor_country_prefix(dx), ++ dx->international_area_code_length, dvb_telephone_descriptor_international_area_code(dx), ++ dx->operator_code_length, dvb_telephone_descriptor_operator_code(dx), ++ dx->national_area_code_length, dvb_telephone_descriptor_national_area_code(dx), ++ dx->core_number_length, dvb_telephone_descriptor_core_number(dx)); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_local_time_offset: ++ { ++ struct dvb_local_time_offset_descriptor *dx; ++ struct dvb_local_time_offset *cur; ++ ++ iprintf(indent, "DSC Decode dvb_local_time_offset_descriptor\n"); ++ dx = dvb_local_time_offset_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_local_time_offset_descriptor decode error\n"); ++ return; ++ } ++ dvb_local_time_offset_descriptor_offsets_for_each(dx, cur) { ++ iprintf(indent+1, ++ "DSC country_code:%.3s country_region_id:%i " ++ "local_time_offset_polarity:%i local_time_offset:%i " ++ "time_of_change:%i next_time_offset:%i\n", ++ cur->country_code, cur->country_region_id, ++ cur->local_time_offset_polarity, ++ dvbhhmm_to_seconds(cur->local_time_offset), ++ dvbdate_to_unixtime(cur->time_of_change), ++ dvbhhmm_to_seconds(cur->next_time_offset)); ++ } ++ break; ++ } ++ ++ case dtag_dvb_subtitling: ++ { ++ struct dvb_subtitling_descriptor *dx; ++ struct dvb_subtitling_entry *cur; ++ ++ iprintf(indent, "DSC Decode dvb_subtitling_descriptor\n"); ++ dx = dvb_subtitling_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_subtitling_descriptor decode error\n"); ++ return; ++ } ++ dvb_subtitling_descriptor_subtitles_for_each(dx, cur) { ++ iprintf(indent+1, ++ "DSC language_code:%.3s subtitling_type:0x%02x composition_page_id:0x%04x ancillary_page_id:0x%04x\n", ++ cur->language_code, cur->subtitling_type, ++ cur->composition_page_id, cur->ancillary_page_id); ++ } ++ break; ++ } ++ ++ case dtag_dvb_terrestial_delivery_system: ++ { ++ struct dvb_terrestrial_delivery_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_terrestrial_delivery_descriptor\n"); ++ dx = dvb_terrestrial_delivery_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_terrestrial_delivery_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC centre_frequency:%i bandwidth:%i priority:%i " ++ "time_slicing_indicator:%i mpe_fec_indicator:%i constellation:%i " ++ "hierarchy_information:%i code_rate_hp_stream:%i " ++ "code_rate_lp_stream:%i guard_interval:%i transmission_mode:%i " ++ "other_frequency_flag:%i\n", ++ dx->centre_frequency, dx->bandwidth, dx->priority, ++ dx->time_slicing_indicator, dx->mpe_fec_indicator, ++ dx->constellation, ++ dx->hierarchy_information, dx->code_rate_hp_stream, ++ dx->code_rate_lp_stream, dx->guard_interval, ++ dx->transmission_mode, dx->other_frequency_flag); ++ break; ++ } ++ ++ case dtag_dvb_multilingual_network_name: ++ { ++ struct dvb_multilingual_network_name_descriptor *dx; ++ struct dvb_multilingual_network_name *cur; ++ ++ iprintf(indent, "DSC Decode dvb_multilingual_network_name_descriptor\n"); ++ dx = dvb_multilingual_network_name_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_multilingual_network_name_descriptor decode error\n"); ++ return; ++ } ++ dvb_multilingual_network_name_descriptor_names_for_each(dx, cur) { ++ iprintf(indent+1, ++ "DSC language_code:%.3s network_name:%.*s\n", ++ cur->language_code, ++ cur->network_name_length, ++ dvb_multilingual_network_name_name(cur)); ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_multilingual_bouquet_name: ++ { ++ struct dvb_multilingual_bouquet_name_descriptor *dx; ++ struct dvb_multilingual_bouquet_name *cur; ++ ++ iprintf(indent, "DSC Decode dvb_multilingual_bouquet_name_descriptor\n"); ++ dx = dvb_multilingual_bouquet_name_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_multilingual_bouquet_name_descriptor decode error\n"); ++ return; ++ } ++ dvb_multilingual_bouquet_name_descriptor_names_for_each(dx, cur) { ++ iprintf(indent+1, ++ "DSC language_code:%.3s bouquet_name:%.*s\n", ++ cur->language_code, ++ cur->bouquet_name_length, ++ dvb_multilingual_bouquet_name_name(cur)); ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_multilingual_service_name: ++ { ++ struct dvb_multilingual_service_name_descriptor *dx; ++ struct dvb_multilingual_service_name *cur; ++ ++ iprintf(indent, "DSC Decode dvb_multilingual_service_name_descriptor\n"); ++ dx = dvb_multilingual_service_name_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_multilingual_service_name_descriptor decode error\n"); ++ return; ++ } ++ dvb_multilingual_service_name_descriptor_names_for_each(dx, cur) { ++ struct dvb_multilingual_service_name_part2 *part2; ++ part2 = dvb_multilingual_service_name_part2(cur); ++ ++ iprintf(indent+1, ++ "DSC language_code:%.3s provider_name:%.*s service_name:%.*s\n", ++ cur->language_code, ++ cur->service_provider_name_length, ++ dvb_multilingual_service_name_service_provider_name(cur), ++ part2->service_name_length, ++ dvb_multilingual_service_name_service_name(part2)); ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_multilingual_component: ++ { ++ struct dvb_multilingual_component_descriptor *dx; ++ struct dvb_multilingual_component *cur; ++ ++ iprintf(indent, "DSC Decode dvb_multilingual_component_descriptor\n"); ++ dx = dvb_multilingual_component_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_multilingual_component_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC component_tag:%02x\n", dx->component_tag); ++ dvb_multilingual_component_descriptor_components_for_each(dx, cur) { ++ iprintf(indent+1, ++ "DSC language_code:%.3s description:%.*s\n", ++ cur->language_code, ++ cur->text_description_length, ++ dvb_multilingual_component_text_char(cur)); ++ } ++ break; ++ } ++ ++ case dtag_dvb_private_data_specifier: ++ { ++ struct dvb_private_data_specifier_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_private_data_specifier_descriptor\n"); ++ dx = dvb_private_data_specifier_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_private_data_specifier_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC private_data_specifier:0x%08x\n", ++ dx->private_data_specifier); ++ break; ++ } ++ ++ case dtag_dvb_service_move: ++ { ++ struct dvb_service_move_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_service_move_descriptor\n"); ++ dx = dvb_service_move_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_service_move_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC new_original_network_id:0x%04x new_transport_stream_id:0x%04x new_service_id:0x%04x\n", ++ dx->new_original_network_id, dx->new_transport_stream_id, dx->new_service_id); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_short_smoothing_buffer: ++ { ++ struct dvb_short_smoothing_buffer_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_short_smoothing_buffer_descriptor\n"); ++ dx = dvb_short_smoothing_buffer_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_short_smoothing_buffer_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC sb_size:%i sb_leak_rate:%i\n", ++ dx->sb_size, dx->sb_leak_rate); ++ hexdump(indent, "DSC", ++ dvb_short_smoothing_buffer_descriptor_reserved(dx), ++ dvb_short_smoothing_buffer_descriptor_reserved_length(dx)); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_frequency_list: ++ { ++ struct dvb_frequency_list_descriptor *dx; ++ uint32_t *freqs; ++ int count; ++ int i; ++ ++ iprintf(indent, "DSC Decode dvb_frequency_list_descriptor\n"); ++ dx = dvb_frequency_list_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_frequency_list_descriptor decode error\n"); ++ return; ++ } ++ iprintf(0, "DSC coding_type=%i\n", dx->coding_type); ++ ++ freqs = dvb_frequency_list_descriptor_centre_frequencies(dx); ++ count = dvb_frequency_list_descriptor_centre_frequencies_count(dx); ++ for(i=0; i< count; i++) { ++ iprintf(indent+1, "DSC %i\n", freqs[i]); ++ } ++ break; ++ } ++ ++ case dtag_dvb_partial_transport_stream: ++ { ++ struct dvb_partial_transport_stream_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_partial_transport_stream_descriptor\n"); ++ dx = dvb_partial_transport_stream_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_partial_transport_stream_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC peak_rate:%i minimum_overall_smoothing_rate:%i maximum_overall_smoothing_rate:%i\n", ++ dx->peak_rate, dx->minimum_overall_smoothing_rate, dx->maximum_overall_smoothing_rate); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_data_broadcast: ++ { ++ struct dvb_data_broadcast_descriptor *dx; ++ struct dvb_data_broadcast_descriptor_part2 *part2; ++ ++ iprintf(indent, "DSC Decode dvb_data_broadcast_descriptor\n"); ++ dx = dvb_data_broadcast_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_data_broadcast_descriptor decode error\n"); ++ return; ++ } ++ part2 = dvb_data_broadcast_descriptor_part2(dx); ++ ++ iprintf(indent, "DSC data_broadcast_id:0x%04x component_tag:0x%02x selector:%.*s language_code:%.3s text:%.*s\n", ++ dx->data_broadcast_id, dx->component_tag, ++ dx->selector_length, dvb_data_broadcast_descriptor_selector(dx), ++ part2->language_code, ++ part2->text_length, dvb_data_broadcast_descriptor_part2_text(part2)); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_scrambling: ++ { ++ struct dvb_scrambling_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_scrambling_descriptor\n"); ++ dx = dvb_scrambling_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_scrambling_descriptor decode error\n"); ++ return; ++ } ++ ++ iprintf(indent, "DSC scrambling_mode:0x%02x\n", ++ dx->scrambling_mode); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_data_broadcast_id: ++ { ++ struct dvb_data_broadcast_id_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_data_broadcast_id_descriptor\n"); ++ dx = dvb_data_broadcast_id_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_data_broadcast_id_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC data_broadcast_id:0x%04x\n", ++ dx->data_broadcast_id); ++ hexdump(indent+1, "DSC", ++ dvb_data_broadcast_id_descriptor_id_selector_byte(dx), ++ dvb_data_broadcast_id_descriptor_id_selector_byte_length(dx)); ++ break; ++ } ++ ++ case dtag_dvb_transport_stream: ++ { ++ struct dvb_transport_stream_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_transport_stream_descriptor\n"); ++ dx = dvb_transport_stream_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_transport_stream_descriptor decode error\n"); ++ return; ++ } ++ hexdump(indent, "DSC", ++ dvb_transport_stream_descriptor_data(dx), ++ dvb_transport_stream_descriptor_data_length(dx)); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_dsng: ++ { ++ struct dvb_dsng_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_dsng_descriptor\n"); ++ dx = dvb_dsng_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_dsng_descriptor decode error\n"); ++ return; ++ } ++ hexdump(indent, "DSC", ++ dvb_dsng_descriptor_data(dx), ++ dvb_dsng_descriptor_data_length(dx)); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_pdc: ++ { ++ struct dvb_pdc_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_pdc_descriptor\n"); ++ dx = dvb_pdc_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_pdc_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC programme_id_label:0x%06x\n", ++ dx->programme_id_label); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_ac3: ++ { ++ struct dvb_ac3_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_ac3_descriptor\n"); ++ dx = dvb_ac3_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_ac3_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC ac3_type_flag:%i bsid_flag:%i mainid_flag:%i asvc_flag:%i\n", ++ dx->ac3_type_flag, dx->bsid_flag, dx->mainid_flag, dx->asvc_flag); ++ hexdump(indent+1, "DSC", ++ dvb_ac3_descriptor_additional_info(dx), ++ dvb_ac3_descriptor_additional_info_length(dx)); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_ancillary_data: ++ { ++ struct dvb_ancillary_data_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_ancillary_data_descriptor\n"); ++ dx = dvb_ancillary_data_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_ancillary_data_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, "DSC scale_factor_error_check:%i dab_ancillary_data:%i announcement_switching_data:%i extended_ancillary_data:%i dvd_video_ancillary_data:%i\n", ++ dx->scale_factor_error_check, ++ dx->dab_ancillary_data, ++ dx->announcement_switching_data, ++ dx->extended_ancillary_data, ++ dx->dvd_video_ancillary_data); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_cell_list: ++ { ++ struct dvb_cell_list_descriptor *dx; ++ struct dvb_cell_list_entry *cur; ++ struct dvb_subcell_list_entry *cur_subcell; ++ ++ iprintf(indent, "DSC Decode dvb_cell_list_descriptor\n"); ++ dx = dvb_cell_list_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_cell_list_descriptor decode error\n"); ++ return; ++ } ++ dvb_cell_list_descriptor_cells_for_each(dx, cur) { ++ iprintf(indent+1, ++ "DSC cell_id:%04x cell_latitude:%i cell_longitude:%i cell_extend_of_latitude:%i cell_extend_of_longitude:%i\n", ++ cur->cell_id, ++ cur->cell_latitude, ++ cur->cell_longitude, ++ cur->cell_extend_of_latitude, ++ cur->cell_extend_of_longitude); ++ ++ dvb_cell_list_entry_subcells_for_each(cur, cur_subcell) { ++ iprintf(indent+2, ++ "DSC cell_id_extension:%04x subcell_latitude:%i subcell_longitude:%i subcell_extend_of_latitude:%i subcell_extend_of_longitude:%i\n", ++ cur_subcell->cell_id_extension, ++ cur_subcell->subcell_latitude, ++ cur_subcell->subcell_longitude, ++ cur_subcell->subcell_extend_of_latitude, ++ cur_subcell->subcell_extend_of_longitude); ++ } ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_cell_frequency_link: ++ { ++ struct dvb_cell_frequency_link_descriptor *dx; ++ struct dvb_cell_frequency_link_cell *cur; ++ struct dvb_cell_frequency_link_cell_subcell *cur_subcell; ++ ++ iprintf(indent, "DSC Decode dvb_cell_frequency_link_descriptor\n"); ++ dx = dvb_cell_frequency_link_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_cell_frequency_link_descriptor decode error\n"); ++ return; ++ } ++ dvb_cell_frequency_link_descriptor_cells_for_each(dx, cur) { ++ iprintf(indent+1, ++ "DSC cell_id:%04x frequency:%i\n", ++ cur->cell_id, ++ cur->frequency); ++ ++ dvb_cell_frequency_link_cell_subcells_for_each(cur, cur_subcell) { ++ iprintf(indent+2, ++ "DSC cell_id_extension:%04x transposer_frequency:%i\n", ++ cur_subcell->cell_id_extension, ++ cur_subcell->transposer_frequency); ++ } ++ } ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_announcement_support: ++ { ++ struct dvb_announcement_support_descriptor *dx; ++ struct dvb_announcement_support_entry *cur; ++ struct dvb_announcement_support_reference *ref; ++ ++ iprintf(indent, "DSC Decode dvb_announcement_support_descriptor\n"); ++ dx = dvb_announcement_support_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_announcement_support_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, ++ "DSC announcement_support_indicator:%04x\n", ++ dx->announcement_support_indicator); ++ ++ dvb_announcement_support_descriptor_entries_for_each(dx, cur) { ++ iprintf(indent+1, ++ "DSC announcement_type:%i reference_type:%i\n", ++ cur->announcement_type, ++ cur->reference_type); ++ ++ ref = dvb_announcement_support_entry_reference(cur); ++ if (ref) { ++ iprintf(indent+1, ++ "DSC original_network_id:%04x transport_stream_id:%04x service_id:%04x component_tag:%02x\n", ++ ref->original_network_id, ++ ref->transport_stream_id, ++ ref->service_id, ++ ref->component_tag); ++ } ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_application_signalling: ++ { ++ struct dvb_application_signalling_descriptor *dx; ++ struct dvb_application_signalling_entry *cur; ++ ++ iprintf(indent, "DSC Decode dvb_application_signalling_descriptor\n"); ++ dx = dvb_application_signalling_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_application_signalling_descriptor decode error\n"); ++ return; ++ } ++ ++ dvb_application_signalling_descriptor_entries_for_each(dx, cur) { ++ iprintf(indent+1, ++ "DSC application_type:%i AIT_version_number:%i\n", ++ cur->application_type, ++ cur->AIT_version_number); ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_adaptation_field_data: ++ { ++ struct dvb_adaptation_field_data_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_adaptation_field_data_descriptor\n"); ++ dx = dvb_adaptation_field_data_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_adaptation_field_data_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, ++ "DSC announcement_switching_data:%i\n", ++ dx->announcement_switching_data); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_service_identifier: ++ { ++ struct dvb_service_identifier_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_service_identifier_descriptor\n"); ++ dx = dvb_service_identifier_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_service_identifier_descriptor decode error\n"); ++ return; ++ } ++ hexdump(indent, "DSC", ++ dvb_service_identifier_descriptor_identifier(dx), ++ dvb_service_identifier_descriptor_identifier_length(dx)); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_service_availability: ++ { ++ struct dvb_service_availability_descriptor *dx; ++ uint16_t *cellids; ++ int count; ++ int i; ++ ++ iprintf(indent, "DSC Decode dvb_service_availability_descriptor\n"); ++ dx = dvb_service_availability_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_service_availability_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent, ++ "DSC availability_flag:%i\n", ++ dx->availability_flag); ++ ++ cellids = dvb_service_availability_descriptor_cell_ids(dx); ++ count = dvb_service_availability_descriptor_cell_ids_count(dx); ++ for(i=0; i< count; i++) { ++ iprintf(indent+1, "DSC", "%04x\n", cellids[i]); ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_default_authority: ++ { ++ struct dvb_default_authority_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_default_authority_descriptor\n"); ++ dx = dvb_default_authority_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_default_authority_descriptor decode error\n"); ++ return; ++ } ++ hexdump(indent, "DSC", ++ dvb_default_authority_descriptor_name(dx), ++ dvb_default_authority_descriptor_name_length(dx)); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_related_content: ++ { ++ struct dvb_related_content_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_related_content_descriptor\n"); ++ dx = dvb_related_content_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_related_content_descriptor decode error\n"); ++ return; ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_tva_id: ++ { ++ struct dvb_tva_id_descriptor *dx; ++ struct dvb_tva_id_entry *cur; ++ ++ iprintf(indent, "DSC Decode dvb_tva_id_descriptor\n"); ++ dx = dvb_tva_id_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_tva_id_descriptor decode error\n"); ++ return; ++ } ++ ++ dvb_tva_id_descriptor_entries_for_each(dx, cur) { ++ iprintf(indent+1, ++ "DSC tva_id:%04x running_status:%i\n", ++ cur->tva_id, ++ cur->running_status); ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_content_identifier: ++ { ++ struct dvb_content_identifier_descriptor *dx; ++ struct dvb_content_identifier_entry *cur; ++ struct dvb_content_identifier_entry_data_0 *data0; ++ struct dvb_content_identifier_entry_data_1 *data1; ++ ++ iprintf(indent, "DSC Decode dvb_tva_id_descriptor\n"); ++ dx = dvb_content_identifier_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_content_identifier_descriptor decode error\n"); ++ return; ++ } ++ ++ dvb_content_identifier_descriptor_entries_for_each(dx, cur) { ++ iprintf(indent+1, ++ "DSC crid_type:%i crid_location:%i\n", ++ cur->crid_type, ++ cur->crid_location); ++ ++ data0 = dvb_content_identifier_entry_data_0(cur); ++ if (data0) { ++ hexdump(indent, "DSC data0", ++ dvb_content_identifier_entry_data_0_data(data0), ++ data0->crid_length); ++ } ++ ++ data1 = dvb_content_identifier_entry_data_1(cur); ++ if (data1) { ++ iprintf(indent+1, ++ "DSC crid_ref:%04x\n", ++ data1->crid_ref); ++ } ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_dvb_s2_satellite_delivery_descriptor: ++ { ++ struct dvb_s2_satellite_delivery_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode dvb_s2_satellite_delivery_descriptor\n"); ++ dx = dvb_s2_satellite_delivery_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX dvb_s2_satellite_delivery_descriptor decode error\n"); ++ return; ++ } ++ ++ iprintf(indent, ++ "DSC scrambling_sequence_selector:%i multiple_input_stream:%i backwards_compatability:%i\n", ++ dx->scrambling_sequence_selector, ++ dx->multiple_input_stream, ++ dx->backwards_compatability); ++ if (dx->scrambling_sequence_selector) { ++ iprintf(indent, ++ "DSC scrambling_sequence_index:%i\n", ++ dvb_s2_satellite_delivery_descriptor_scrambling_sequence_index(dx)); ++ } ++ if (dx->multiple_input_stream) { ++ iprintf(indent, ++ "DSC input_stream_id:%i\n", ++ dvb_s2_satellite_delivery_descriptor_input_stream_id(dx)); ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ default: ++ fprintf(stderr, "DSC XXXX Unknown descriptor_tag:0x%02x\n", d->tag); ++ hexdump(0, "DSC ", (uint8_t*) d, d->len+2); ++ return; ++ } ++} ++ ++void parse_atsc_descriptor(struct descriptor *d, int indent, int data_type) ++{ ++ (void) data_type; ++ ++ switch(d->tag) { ++ case dtag_atsc_stuffing: ++ { ++ struct atsc_stuffing_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode atsc_stuffing_descriptor\n"); ++ dx = atsc_stuffing_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX atsc_stuffing_descriptor decode error\n"); ++ return; ++ } ++ hexdump(indent, "DSC", ++ atsc_stuffing_descriptor_data(dx), ++ atsc_stuffing_descriptor_data_length(dx)); ++ break; ++ } ++ ++ case dtag_atsc_ac3_audio: ++ { ++ struct atsc_ac3_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode atsc_ac3_descriptor\n"); ++ dx = atsc_ac3_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX atsc_ac3_descriptor decode error\n"); ++ return; ++ } ++ ++ iprintf(indent, ++ "DSC sample_rate_code:%i bsid:%i bit_rate_code:%i surround_mode:%i bsmod:%i num_channels:%i full_svc:%i\n", ++ dx->sample_rate_code, ++ dx->bsid, ++ dx->bit_rate_code, ++ dx->surround_mode, ++ dx->bsmod, ++ dx->num_channels, ++ dx->full_svc); ++ ++ hexdump(indent+1, "DSC additional_info", ++ atsc_ac3_descriptor_additional_info(dx), ++ atsc_ac3_descriptor_additional_info_length(dx)); ++ break; ++ } ++ ++ case dtag_atsc_caption_service: ++ { ++ struct atsc_caption_service_descriptor *dx; ++ struct atsc_caption_service_entry *cur; ++ int idx; ++ ++ iprintf(indent, "DSC Decode atsc_caption_service_descriptor\n"); ++ dx = atsc_caption_service_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX atsc_caption_service_descriptor decode error\n"); ++ return; ++ } ++ ++ atsc_caption_service_descriptor_entries_for_each(dx, cur, idx) { ++ iprintf(indent+1, ++ "DSC language_code:%.3s digital_cc:%i value:%i easy_reader:%i wide_aspect_ratio:%i\n", ++ cur->language_code, ++ cur->digital_cc, ++ cur->value, ++ cur->easy_reader, ++ cur->wide_aspect_ratio); ++ } ++ break; ++ } ++ ++ case dtag_atsc_content_advisory: ++ { ++ struct atsc_content_advisory_descriptor *dx; ++ struct atsc_content_advisory_entry *cure; ++ struct atsc_content_advisory_entry_dimension *curd; ++ struct atsc_content_advisory_entry_part2 *part2; ++ int eidx; ++ int didx; ++ ++ iprintf(indent, "DSC Decode atsc_content_advisory_descriptor\n"); ++ dx = atsc_content_advisory_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX atsc_content_advisory_descriptor decode error\n"); ++ return; ++ } ++ ++ atsc_content_advisory_descriptor_entries_for_each(dx, cure, eidx) { ++ iprintf(indent+1, ++ "DSC rating_region:%i\n", ++ cure->rating_region); ++ ++ atsc_content_advisory_entry_dimensions_for_each(cure, curd, didx) { ++ iprintf(indent+2, ++ "DSC rating_dimension_j:%i rating_value:%i\n", ++ curd->rating_dimension_j, ++ curd->rating_value); ++ } ++ ++ part2 = atsc_content_advisory_entry_part2(cure); ++ ++ atsctextdump("DSC description:", ++ indent, ++ atsc_content_advisory_entry_part2_description(part2), ++ part2->rating_description_length); ++ } ++ ++ break; ++ } ++ ++ case dtag_atsc_extended_channel_name: ++ { ++ struct atsc_extended_channel_name_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode atsc_extended_channel_name_descriptor\n"); ++ dx = atsc_extended_channel_name_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX atsc_extended_channel_name_descriptor decode error\n"); ++ return; ++ } ++ ++ atsctextdump("SCT text:", 1, ++ atsc_extended_channel_name_descriptor_text(dx), ++ atsc_extended_channel_name_descriptor_text_length(dx)); ++ break; ++ } ++ ++ case dtag_atsc_service_location: ++ { ++ struct atsc_service_location_descriptor *dx; ++ struct atsc_caption_service_location_element *cur; ++ int idx; ++ ++ iprintf(indent, "DSC Decode atsc_service_location_descriptor\n"); ++ dx = atsc_service_location_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX atsc_service_location_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent+1, "DSC PCR_PID:%04x\n", dx->PCR_PID); ++ ++ atsc_service_location_descriptor_elements_for_each(dx, cur, idx) { ++ iprintf(indent+1, "DSC stream_type:%02x elementary_PID:%04x language_code:%.3s\n", ++ cur->stream_type, ++ cur->elementary_PID, ++ cur->language_code); ++ } ++ break; ++ } ++ ++ case dtag_atsc_time_shifted_service: ++ { ++ struct atsc_time_shifted_service_descriptor *dx; ++ struct atsc_time_shifted_service *cur; ++ int idx; ++ ++ iprintf(indent, "DSC Decode atsc_time_shifted_service_descriptor\n"); ++ dx = atsc_time_shifted_service_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX atsc_time_shifted_service_descriptor decode error\n"); ++ return; ++ } ++ ++ atsc_time_shifted_service_descriptor_services_for_each(dx, cur, idx) { ++ iprintf(indent+1, "DSC time_shift:%i major_channel_number:%04x minor_channel_number:%04x\n", ++ cur->time_shift, ++ cur->major_channel_number, ++ cur->minor_channel_number); ++ } ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_atsc_component_name: ++ { ++ struct atsc_component_name_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode atsc_component_name_descriptor\n"); ++ dx = atsc_component_name_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX atsc_component_name_descriptor decode error\n"); ++ return; ++ } ++ ++ atsctextdump("SCT name:", 1, ++ atsc_component_name_descriptor_text(dx), ++ atsc_component_name_descriptor_text_length(dx)); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_atsc_dcc_departing_request: ++ { ++ struct atsc_dcc_departing_request_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode atsc_dcc_departing_request_descriptor\n"); ++ dx = atsc_dcc_departing_request_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX atsc_dcc_departing_request_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent+1, "DSC dcc_departing_request_type:%02x\n", ++ dx->dcc_departing_request_type); ++ ++ atsctextdump("SCT text:", 1, ++ atsc_dcc_departing_request_descriptor_text(dx), ++ atsc_dcc_departing_request_descriptor_text_length(dx)); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_atsc_dcc_arriving_request: ++ { ++ struct atsc_dcc_arriving_request_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode atsc_dcc_arriving_request_descriptor\n"); ++ dx = atsc_dcc_arriving_request_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX atsc_dcc_arriving_request_descriptor decode error\n"); ++ return; ++ } ++ iprintf(indent+1, "DSC dcc_arriving_request_type:%02x\n", ++ dx->dcc_arriving_request_type); ++ ++ atsctextdump("SCT text:", 1, ++ atsc_dcc_arriving_request_descriptor_text(dx), ++ atsc_dcc_arriving_request_descriptor_text_length(dx)); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_atsc_redistribution_control: ++ { ++ struct atsc_rc_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode atsc_rc_descriptor\n"); ++ dx = atsc_rc_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX atsc_rc_descriptor decode error\n"); ++ return; ++ } ++ hexdump(indent, "DSC", ++ atsc_rc_descriptor_info(dx), ++ atsc_rc_descriptor_info_length(dx)); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_atsc_genre: ++ { ++ struct atsc_genre_descriptor *dx; ++ ++ iprintf(indent, "DSC Decode atsc_genre_descriptor\n"); ++ dx = atsc_genre_descriptor_codec(d); ++ if (dx == NULL) { ++ fprintf(stderr, "DSC XXXX atsc_genre_descriptor decode error\n"); ++ return; ++ } ++ hexdump(indent, "DSC", ++ atsc_genre_descriptor_attributes(dx), ++ dx->attribute_count); ++ ++ hexdump(0, "XXX", (uint8_t*) d, d->len + 2); ++ getchar(); ++ break; ++ } ++ ++ case dtag_atsc_private_information: ++ // FIXME: whats the format? ++ ++ case dtag_atsc_content_identifier: ++ // FIXME: whats the format? ++ ++ default: ++ fprintf(stderr, "DSC XXXX Unknown descriptor_tag:0x%02x\n", d->tag); ++ hexdump(0, "DSC ", (uint8_t*) d, d->len+2); ++ return; ++ } ++} ++ ++void iprintf(int indent, char *fmt, ...) ++{ ++ va_list ap; ++ ++ while(indent--) { ++ printf("\t"); ++ } ++ ++ va_start(ap, fmt); ++ vprintf(fmt, ap); ++ va_end(ap); ++} ++ ++void hexdump(int indent, char *prefix, uint8_t *buf, int buflen) ++{ ++ int i; ++ int j; ++ int max; ++ char line[512]; ++ ++ for(i=0; i< buflen; i+=16) { ++ max = 16; ++ if ((i + max) > buflen) ++ max = buflen - i; ++ ++ memset(line, 0, sizeof(line)); ++ memset(line + 4 + 48 + 1, ' ', 16); ++ sprintf(line, "%02x: ", i); ++ for(j=0; j 31) && (buf[i+j] < 127)) ++ line[4 + 48 + 1 + j] = buf[i+j]; ++ else ++ line[4 + 48 + 1 + j] = '.'; ++ } ++ ++ for(j=0; j< 4 + 48; j++) { ++ if (!line[j]) ++ line[j] = ' '; ++ } ++ line[4+48] = '|'; ++ ++ for(j=0; j < indent; j++) { ++ printf("\t"); ++ } ++ printf("%s%s|\n", prefix, line); ++ } ++} ++ ++void atsctextdump(char *header, int indent, struct atsc_text *atext, int len) ++{ ++ struct atsc_text_string *cur_string; ++ struct atsc_text_string_segment *cur_segment; ++ int str_idx; ++ int seg_idx; ++ ++ if (len == 0) ++ return; ++ ++ atsc_text_strings_for_each(atext, cur_string, str_idx) { ++ iprintf(indent+1, "%s String %i language:%.3s\n", header, str_idx, cur_string->language_code); ++ ++ atsc_text_string_segments_for_each(cur_string, cur_segment, seg_idx) { ++ iprintf(indent+2, "Segment %i compression_type:%i mode:%i\n", ++ seg_idx, ++ cur_segment->compression_type, ++ cur_segment->mode); ++ ++ hexdump(indent+2, "rawbytes ", ++ atsc_text_string_segment_bytes(cur_segment), ++ cur_segment->number_bytes); ++ ++ if (cur_segment->compression_type < 0x3e) { ++ uint8_t *decoded = NULL; ++ size_t decodedlen = 0; ++ size_t decodedpos = 0; ++ ++ if (atsc_text_segment_decode(cur_segment, ++ &decoded, ++ &decodedlen, ++ &decodedpos) < 0) { ++ iprintf(indent+2, "Decode error\n"); ++ } else { ++ hexdump(indent+2, "decoded ", decoded, decodedpos); ++ } ++ if (decoded) ++ free(decoded); ++ } ++ } ++ } ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/test/lnb.c dvb-apps/test/lnb.c +--- linuxtv-dvb-apps-1.1.1/test/lnb.c 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/test/lnb.c 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,101 @@ ++#include ++#include ++#include ++#include "lnb.h" ++ ++static char *univ_desc[] = { ++ "Europe", ++ "10800 to 11800 MHz and 11600 to 12700 Mhz", ++ "Dual LO, loband 9750, hiband 10600 MHz", ++ (char *)NULL }; ++ ++static char *dbs_desc[] = { ++ "Expressvu, North America", ++ "12200 to 12700 MHz", ++ "Single LO, 11250 MHz", ++ (char *)NULL }; ++ ++static char *standard_desc[] = { ++ "10945 to 11450 Mhz", ++ "Single LO, 10000 Mhz", ++ (char *)NULL }; ++ ++static char *enhan_desc[] = { ++ "Astra", ++ "10700 to 11700 MHz", ++ "Single LO, 9750 MHz", ++ (char *)NULL }; ++ ++static char *cband_desc[] = { ++ "Big Dish", ++ "3700 to 4200 MHz", ++ "Single LO, 5150 Mhz", ++ (char *)NULL }; ++ ++static struct lnb_types_st lnbs[] = { ++ {"UNIVERSAL", univ_desc, 9750, 10600, 11700 }, ++ {"DBS", dbs_desc, 11250, 0, 0 }, ++ {"STANDARD", standard_desc, 10000, 0, 0 }, ++ {"ENHANCED", enhan_desc, 9750, 0, 0 }, ++ {"C-BAND", cband_desc, 5150, 0, 0 } ++}; ++ ++/* Enumerate through standard types of LNB's until NULL returned. ++ * Increment curno each time ++ */ ++ ++struct lnb_types_st * ++lnb_enum(int curno) ++{ ++ if (curno >= (int) (sizeof(lnbs) / sizeof(lnbs[0]))) ++ return (struct lnb_types_st *)NULL; ++ return &lnbs[curno]; ++} ++ ++/* Decode an lnb type, for example given on a command line ++ * If alpha and standard type, e.g. "Universal" then match that ++ * otherwise low[,high[,switch]] ++ */ ++ ++int ++lnb_decode(char *str, struct lnb_types_st *lnbp) ++{ ++int i; ++char *cp, *np; ++ ++ memset(lnbp, 0, sizeof(*lnbp)); ++ cp = str; ++ while(*cp && isspace(*cp)) ++ cp++; ++ if (isalpha(*cp)) { ++ for (i = 0; i < (int)(sizeof(lnbs) / sizeof(lnbs[0])); i++) { ++ if (!strcasecmp(lnbs[i].name, cp)) { ++ *lnbp = lnbs[i]; ++ return 1; ++ } ++ } ++ return -1; ++ } ++ if (*cp == '\0' || !isdigit(*cp)) ++ return -1; ++ lnbp->low_val = strtoul(cp, &np, 0); ++ if (lnbp->low_val == 0) ++ return -1; ++ cp = np; ++ while(*cp && (isspace(*cp) || *cp == ',')) ++ cp++; ++ if (*cp == '\0') ++ return 1; ++ if (!isdigit(*cp)) ++ return -1; ++ lnbp->high_val = strtoul(cp, &np, 0); ++ cp = np; ++ while(*cp && (isspace(*cp) || *cp == ',')) ++ cp++; ++ if (*cp == '\0') ++ return 1; ++ if (!isdigit(*cp)) ++ return -1; ++ lnbp->switch_val = strtoul(cp, NULL, 0); ++ return 1; ++} +diff -Nurd linuxtv-dvb-apps-1.1.1/test/lnb.h dvb-apps/test/lnb.h +--- linuxtv-dvb-apps-1.1.1/test/lnb.h 1970-01-01 01:00:00.000000000 +0100 ++++ dvb-apps/test/lnb.h 2009-06-21 13:29:06.000000000 +0200 +@@ -0,0 +1,22 @@ ++struct lnb_types_st { ++ char *name; ++ char **desc; ++ unsigned long low_val; ++ unsigned long high_val; /* zero indicates no hiband */ ++ unsigned long switch_val; /* zero indicates no hiband */ ++}; ++ ++/* Enumerate through standard types of LNB's until NULL returned. ++ * Increment curno each time ++ */ ++ ++struct lnb_types_st * ++lnb_enum(int curno); ++ ++/* Decode an lnb type, for example given on a command line ++ * If alpha and standard type, e.g. "Universal" then match that ++ * otherwise low[,high[,switch]] ++ */ ++ ++int ++lnb_decode(char *str, struct lnb_types_st *lnbp); +diff -Nurd linuxtv-dvb-apps-1.1.1/test/Makefile dvb-apps/test/Makefile +--- linuxtv-dvb-apps-1.1.1/test/Makefile 2004-01-17 17:59:46.000000000 +0100 ++++ dvb-apps/test/Makefile 2009-06-21 13:29:06.000000000 +0200 +@@ -1,37 +1,41 @@ +-# Makefile for Linux DVB API Version 3 test programs ++# Makefile for linuxtv.org dvb-apps/test + +-CC = gcc +-CFLAGS = -g -O2 -W -Wall -I../include ++objects = hex_dump.o lnb.o + +-TARGETS = \ +- diseqc \ +- set22k \ +- sendburst \ +- setvoltage \ +- setpid \ +- video \ +- test_sections \ +- test_sec_ne \ +- test_pes \ +- test_dvr \ +- test_dvr_play \ +- test_tt \ +- test_av \ +- test_av_play \ +- test_vevent \ +- test_stc \ +- test_stillimage ++binaries = diseqc \ ++ sendburst \ ++ set22k \ ++ setpid \ ++ setvoltage \ ++ test_av \ ++ test_av_play \ ++ test_dvr \ ++ test_dvr_play \ ++ test_pes \ ++ test_sec_ne \ ++ test_sections \ ++ test_stc \ ++ test_stillimage \ ++ test_tt \ ++ test_vevent \ ++ evtest \ ++ video \ ++ szap2 + +-# test \ +-# test_audio \ +-# test_front \ +-# test_switch \ +-# test_video \ ++.PHONY: all + +-all: $(TARGETS) ++all: $(binaries) ++ make -C libdvbcfg $@ ++ make -C libdvben50221 $@ ++ make -C libesg $@ ++ make -C libucsi $@ + +-test_sections test_sec_ne test_pes test_tt: hex_dump.o ++$(binaries): $(objects) + +-clean: +- rm -f $(TARGETS) *.o ++clean:: ++ make -C libdvbcfg $@ ++ make -C libdvben50221 $@ ++ make -C libesg $@ ++ make -C libucsi $@ + ++include ../Make.rules +diff -Nurd linuxtv-dvb-apps-1.1.1/test/README dvb-apps/test/README +--- linuxtv-dvb-apps-1.1.1/test/README 2004-01-17 17:59:46.000000000 +0100 ++++ dvb-apps/test/README 2009-06-21 13:29:06.000000000 +0200 +@@ -1,4 +1,4 @@ +-Various small test/sample programs for the Linux DVB API Version 2 ++Various small test/sample programs for the Linux DVB API Version 2/3 + + The default devices used by the test programs are generally + /dev/dvb/adapter0/*0, and can be overridden using environment +@@ -33,13 +33,13 @@ + test_stc : Test DMX_GET_STC. + + test_stillimage : Display single iframes as stillimages +- iframes can be created with the 'convert' tool from +- imagemagick and mpeg2encode from ftp.mpeg.org, and must ++ iframes can be created with the 'convert' tool from ++ imagemagick and mpeg2encode from ftp.mpeg.org, and must + have a supported size, e.g. 702x576 + ($ convert -sample 702x576\! test.jpg test.mpg) + +-(test_av_play : Test playing MPEG TS from a file (apparently broken)) +- ++test_av_play : Test playing MPEG PES (VDR format) from a file ++test_dvr_play : Test playing MPEG TS from a file (don't try, driver is broken) + + test : + test_audio : +@@ -48,4 +48,3 @@ + test_front : + test_switch : + test_video : +- +diff -Nurd linuxtv-dvb-apps-1.1.1/test/sendburst.c dvb-apps/test/sendburst.c +--- linuxtv-dvb-apps-1.1.1/test/sendburst.c 2004-01-17 17:59:46.000000000 +0100 ++++ dvb-apps/test/sendburst.c 2009-06-21 13:29:06.000000000 +0200 +@@ -1,8 +1,9 @@ +-/* +- * Test sending the burst mini command A/B on a SAT frontend. +- * +- * usage: FRONTEND=/dev/dvb/adapterX/frontendX sendburst {a|b} +- */ ++#define USAGE \ ++"\n" \ ++"\nTest sending the burst mini command A/B on a SAT frontend." \ ++"\n" \ ++"\nusage: FRONTEND=/dev/dvb/adapterX/frontendX sendburst {a|b}" \ ++"\n" + + #include + #include +@@ -22,7 +23,7 @@ + int fd, r; + + if (argc != 2 || (strcmp(argv[1], "a") && strcmp(argv[1], "b"))) { +- fprintf (stderr, "usage: %s \n", argv[0]); ++ fprintf (stderr, "usage: %s \n" USAGE, argv[0]); + return 1; + } + +@@ -52,4 +53,3 @@ + + return 0; + } +- +diff -Nurd linuxtv-dvb-apps-1.1.1/test/set22k.c dvb-apps/test/set22k.c +--- linuxtv-dvb-apps-1.1.1/test/set22k.c 2004-01-17 17:59:46.000000000 +0100 ++++ dvb-apps/test/set22k.c 2009-06-21 13:29:06.000000000 +0200 +@@ -1,10 +1,11 @@ +-/* +- * Test switching the 22kHz tone signal on and off on a SAT frontend. +- * (Note: DiSEqC equipment ignores this after it has once seen a diseqc +- * sequence; reload the driver or unplug/replug the SAT cable to reset.) +- * +- * usage: FRONTEND=/dev/dvb/adapterX/frontendX set22k {on|off} +- */ ++#define USAGE \ ++"\n" \ ++"\nTest switching the 22kHz tone signal on and off on a SAT frontend." \ ++"\n(Note: DiSEqC equipment ignores this after it has once seen a diseqc" \ ++"\n sequence; reload the driver or unplug/replug the SAT cable to reset.)" \ ++"\n" \ ++"\nusage: FRONTEND=/dev/dvb/adapterX/frontendX set22k {on|off}" \ ++"\n" + + #include + #include +@@ -24,7 +25,7 @@ + int fd, r; + + if (argc != 2 || (strcmp(argv[1], "on") && strcmp(argv[1], "off"))) { +- fprintf (stderr, "usage: %s \n", argv[0]); ++ fprintf (stderr, "usage: %s \n" USAGE, argv[0]); + return 1; + } + if (getenv("FRONTEND")) +@@ -47,4 +48,3 @@ + + return 0; + } +- +diff -Nurd linuxtv-dvb-apps-1.1.1/test/setpid.c dvb-apps/test/setpid.c +--- linuxtv-dvb-apps-1.1.1/test/setpid.c 2004-01-17 17:59:46.000000000 +0100 ++++ dvb-apps/test/setpid.c 2009-06-21 13:29:06.000000000 +0200 +@@ -1,9 +1,10 @@ +-/* +- * Set video and audio PIDs in the demux; useful only if you have +- * a hardware MPEG decoder and you're tuned to a transport stream. +- * +- * usage: DEMUX=/dev/dvb/adapterX/demuxX setpid video_pid audio_pid +- */ ++#define USAGE \ ++"\n" \ ++"\nSet video and audio PIDs in the demux; useful only if you have" \ ++"\na hardware MPEG decoder and you're tuned to a transport stream." \ ++"\n" \ ++"\nusage: DEMUX=/dev/dvb/adapterX/demuxX setpid video_pid audio_pid" \ ++"\n" + + #include + #include +@@ -69,7 +70,7 @@ + int video_pid, audio_pid; + + if (argc != 3) { +- printf ("\nusage: %s